def sync_overlay(self, dir=None): vinfo("Syncing overlays to release specified revision") try: XTargetBuilder.sync_overlay(self, dir) except XTargetError, e: if e.log: error(e.log) die(str(e))
def sync(self): vinfo("Doing overlay syncing") try: XTargetBuilder.sync(self) except XTargetError, e: if e.log: error(e.log) die(str(e))
def __init__(self, arch=None, sync=False, config=None): if is_verbose(): stdout = sys.stdout stderr = sys.stderr else: stdout = stderr = None try: XTargetBuilder.__init__(self, arch, sync, stdout, stderr, config) except XTargetError, e: die(str(e))
def delete(self, target_dir=None): if target_dir is None or target_dir == "current": target_dir = get_current_target(config=self.cfg) # check in config cfg = load_config() if cfg['ask_delete'] and not userquery("Are you sure you want to delete %s" % target_dir): info("Abort") return vinfo("Deleting %s" % target_dir) try: XTargetBuilder.delete(self, target_dir) except XTargetError, e: if e.log: error(e.log) die(str(e))
def list_targets(self): tgt_list = XTargetBuilder.list_targets(self) curr_tgt = get_current_target(config=self.cfg) if not curr_tgt or not curr_tgt.startswith(self.cfg['targets_dir']): curr_tgt = None else: curr_tgt = os.path.basename(curr_tgt) # sort tgt_list by alphabetic order tgt_list.sort() for name, pkg, arch, use in tgt_list: out_str = " %-20s " % name if pkg is None: out_str += "[%-20s] " % "Unknown" else: out_str += "[%-20s] " % pkg if name == curr_tgt: out_str += color.teal("(current) ") if is_verbose(): if arch is not None: out_str += "ARCH=\"%s\" " % arch if use is not None: out_str += "USE=\" " for flag, val in use.iteritems(): if val == '0': out_str += "-%s " % flag else: out_str += "%s " % flag out_str += "\"" print out_str
def delete(self, target_dir=None): if target_dir is None or target_dir == "current": target_dir = get_current_target(config=self.cfg) # check in config cfg = load_config() if cfg['ask_delete'] and not userquery( "Are you sure you want to delete %s" % target_dir): info("Abort") return vinfo("Deleting %s" % target_dir) try: XTargetBuilder.delete(self, target_dir) except XTargetError, e: if e.log: error(e.log) die(str(e))
def list_profiles(self, pkg_atom=None): verbose = is_verbose() try: tgt_list = XTargetBuilder.list_profiles_ng(self, pkg_atom, version=verbose, filter=self._arch_given) except XTargetError, e: die(str(e))
def create(self, pkg_atom, arch=None, dir=None): try: target_dir = XTargetBuilder.create(self, pkg_atom, arch, dir) rel = XTargetReleaseParser().get(target_dir, self.cfg['release_file']) if rel.has_key('name') and rel.has_key('version'): target_name = '%s-%s' % (rel['name'], rel['version']) else: target_name = pkg_atom except XTargetError, e: if e.log: error(e.log) die(str(e))
def list(self, env=None): return (JOB_FINISHED, XTargetBuilder().list_targets())
def get(self, key): try: print "%s" % XTargetBuilder.get(self, key) except XTargetError, e: die(str(e))
def set(self, target_dir): try: XTargetBuilder.set(self, target_dir) except XTargetError, e: die(str(e))
("xtarget_delete", self.delete), ("xtarget_sync", self.sync), ]) def list(self, env=None): return (JOB_FINISHED, XTargetBuilder().list_targets()) def list_profiles(self, pkg_atom=None, arch=None, env=None): return (JOB_FINISHED, XTargetBuilder(arch).list_profiles(pkg_atom)) def create(self, name, arch, dir, async=False, env=None): if async: return self.spawn(self.create, name, arch, dir, False, env) else: try: ret = (JOB_FINISHED, XTargetBuilder(arch).create(name, arch, dir)) except Exception, e: ret = (JOB_ERROR, str(e)) return ret def set(self, name, env=None): try: XTargetBuilder().set(name) ret = (JOB_FINISHED, None) except Exception, e: ret = (JOB_ERROR, str(e)) return ret def get_current(self): try: ret = get_current_target()
if rel.has_key('name') and rel.has_key('version'): target_name = '%s-%s' % (rel['name'], rel['version']) else: target_name = pkg_atom except XTargetError, e: if e.log: error(e.log) die(str(e)) info("Target %s built in %s" % (target_name, target_dir)) if self.cfg['create_autocurrent']: # set new target to be current one self.set(target_dir) if self.cfg['create_autosync']: try: XTargetBuilder.sync_overlay(self, target_dir) except XTargetError, e: die(str(e)) info("Overlays of target %s sync" % target_dir) def list_targets(self): tgt_list = XTargetBuilder.list_targets(self) curr_tgt = get_current_target(config=self.cfg) if not curr_tgt or not curr_tgt.startswith(self.cfg['targets_dir']): curr_tgt = None else: curr_tgt = os.path.basename(curr_tgt) # sort tgt_list by alphabetic order tgt_list.sort() for name, pkg, arch, use in tgt_list:
def set(self, name, env=None): try: XTargetBuilder().set(name) ret = (JOB_FINISHED, None) except Exception, e: ret = (JOB_ERROR, str(e))
def list_profiles(self, pkg_atom=None, arch=None, env=None): return (JOB_FINISHED, XTargetBuilder(arch).list_profiles(pkg_atom))