示例#1
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
示例#2
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
示例#3
0
        def sync_overlay(self, dir=None):
                """Sync target's overlays"""
                if not dir:
                        dir = get_current_target(config=self.cfg)

                local_env = self.local_env.copy()
                local_env["ROOT"] = dir + "/root/"
                local_env["PORTAGE_CONFIGROOT"] = dir + "/root/"
                local_env["NO_TARGET_UPDATE"] = "True"

                rel = XTargetReleaseParser().get(dir, self.cfg['release_file'])
                if rel and rel.has_key('overlay'):
                        for ov in rel['overlay']:
                                var = "PORTAGE_%s_REVISION" % ov['name'].upper()
                                local_env[var] = ov['version']

                cmd = Popen(["emerge", "--sync"], bufsize=-1,
                        stdout=self.stdout, stderr=self.stderr, shell=False,
                        cwd=None, env=local_env)
                (stdout, stderr) = cmd.communicate()
                ret = cmd.returncode

                if ret != 0:
                        raise XTargetError("Syncing overlays of target failed", stdout, stderr)


		rel = XTargetReleaseParser().get(dir, self.cfg['release_file'])
		xportage = XPortage(root=dir + "/root")

		base_mirror = xportage.config['BASE_MIRROR']
		if base_mirror:
			local_env["PORTAGE_BINHOST"] = base_mirror + "/" + rel.get('name', '') + "/" + rel.get('arch', '') + "/" +  xportage.config.get('CHOST', '')

		local_env["DISTDIR"] = dir + "/distfiles/"
		local_env["PORTAGE_TMPDIR"] = dir + "/build/"

                if not self.cfg["create_bootstrap"]:
                        return

                # For backward compatibility.
                bootstrap_package = "virtual/libc"

                # If bootstrap package defined, use it instead.
                cmd = Popen(["emerge", "-p", "virtual/bootstrap"], bufsize=-1,
                            shell=False, cwd=None, env=local_env)
                cmd.communicate()
                if cmd.returncode == 0:
                        bootstrap_package = "virtual/bootstrap"

		cmd2 = Popen(["emerge", "-bugn", bootstrap_package], bufsize=-1,
                            stdout=self.stdout, stderr=self.stderr, shell=False,
                            cwd=None, env=local_env)
                (stdout2, stderr2) = cmd2.communicate()
                ret2 = cmd2.returncode

                if ret2 != 0:
                        raise XTargetError("Merging libc failed", stdout2, stderr2)
示例#4
0
    def sync_overlay(self, dir=None):
        """Sync target's overlays"""
        if not dir:
            dir = get_current_target(config=self.cfg)

        self.local_env["ROOT"] = dir + "/root/"
        self.local_env["PORTAGE_CONFIGROOT"] = dir + "/root/"
        self.local_env["NO_TARGET_UPDATE"] = "True"

        rel = XTargetReleaseParser().get(dir, self.cfg['release_file'])
        if rel and rel.has_key('overlay'):
            for ov in rel['overlay']:
                var = "PORTAGE_%s_REVISION" % ov['name'].upper()
                self.local_env[var] = ov['version']

        cmd = Popen(["emerge", "--sync"],
                    bufsize=-1,
                    stdout=self.stdout,
                    stderr=self.stderr,
                    shell=False,
                    cwd=None,
                    env=self.local_env)
        (stdout, stderr) = cmd.communicate()
        ret = cmd.returncode

        if ret != 0:
            raise XTargetError("Syncing overlays of target failed", stdout,
                               stderr)

        rel = XTargetReleaseParser().get(dir, self.cfg['release_file'])
        xportage = XPortage(root=dir + "/root")

        base_mirror = xportage.config['BASE_MIRROR']
        if base_mirror:
            self.local_env["PORTAGE_BINHOST"] = base_mirror + "/" + rel.get(
                'name', '') + "/" + rel.get(
                    'arch', '') + "/" + xportage.config.get('CHOST', '')

        self.local_env["DISTDIR"] = dir + "/distfiles/"
        self.local_env["PORTAGE_TMPDIR"] = dir + "/build/"

        if not self.cfg['create_libc']:
            return
        cmd2 = Popen(["emerge", "-bug", "virtual/libc"],
                     bufsize=-1,
                     stdout=self.stdout,
                     stderr=self.stderr,
                     shell=False,
                     cwd=None,
                     env=self.local_env)
        (stdout2, stderr2) = cmd2.communicate()
        ret2 = cmd2.returncode

        if ret2 != 0:
            raise XTargetError("Merging libc failed", stdout2, stderr2)
示例#5
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))
示例#6
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))
示例#7
0
 def get_current(self):
         return get_current_target(config=self.cfg)
示例#8
0
 def get_current(self):
     return get_current_target(config=self.cfg)
示例#9
0
 def get_current(self):
         try:
                 ret = get_current_target()
                 ret = (JOB_FINISHED, ret)
         except Exception, e:
                 ret = (JOB_ERROR, str(e))