Ejemplo n.º 1
0
 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))
Ejemplo n.º 2
0
 def sync(self):
         vinfo("Doing overlay syncing")
         try:
                 XTargetBuilder.sync(self)
         except XTargetError, e:
                 if e.log:
                         error(e.log)
                 die(str(e))
Ejemplo n.º 3
0
 def sync(self):
     vinfo("Doing overlay syncing")
     try:
         XTargetBuilder.sync(self)
     except XTargetError, e:
         if e.log:
             error(e.log)
         die(str(e))
Ejemplo n.º 4
0
 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))
Ejemplo n.º 5
0
    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))
Ejemplo n.º 6
0
        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))
Ejemplo n.º 7
0
 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))
Ejemplo n.º 8
0
        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
Ejemplo n.º 9
0
 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))
Ejemplo n.º 10
0
    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
Ejemplo n.º 11
0
 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))
Ejemplo n.º 12
0
 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))
Ejemplo n.º 13
0
 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))
Ejemplo n.º 14
0
 def list(self, env=None):
         return (JOB_FINISHED, XTargetBuilder().list_targets())
Ejemplo n.º 15
0
 def get(self, key):
         try:
                 print "%s" % XTargetBuilder.get(self, key)
         except XTargetError, e:
                 die(str(e))
Ejemplo n.º 16
0
 def set(self, target_dir):
     try:
         XTargetBuilder.set(self, target_dir)
     except XTargetError, e:
         die(str(e))
Ejemplo n.º 17
0
 def get(self, key):
     try:
         print "%s" % XTargetBuilder.get(self, key)
     except XTargetError, e:
         die(str(e))
Ejemplo n.º 18
0
 def set(self, target_dir):
         try:
                 XTargetBuilder.set(self, target_dir)
         except XTargetError, e:
                 die(str(e))
Ejemplo n.º 19
0
                                ("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()
Ejemplo n.º 20
0
                        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:
Ejemplo n.º 21
0
 def set(self, name, env=None):
         try:
                 XTargetBuilder().set(name)
                 ret = (JOB_FINISHED, None)
         except Exception, e:
                 ret = (JOB_ERROR, str(e))
Ejemplo n.º 22
0
 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))
Ejemplo n.º 23
0
 def list_profiles(self, pkg_atom=None, arch=None, env=None):
         return (JOB_FINISHED, XTargetBuilder(arch).list_profiles(pkg_atom))
Ejemplo n.º 24
0
            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: