示例#1
0
 def get(self, key):
         rel = XTargetReleaseParser().get(self.get_current(), self.cfg['release_file'])
         if not rel:
                 raise XTargetError("Parsing target release file failed")
         if not rel.has_key(key):
                 raise XTargetError("Key '%s' is not available in target release file" % key)
         return rel[key]
示例#2
0
 def list_targets(self):
         """ List installed targets.
         Looks for targets in /usr/targets (TARGETS_DIR) """
         tgt_list = []
         if not os.path.isdir(self.cfg['targets_dir']):
                 return tgt_list
         # Since we have a test suite using this output and os.listdir output
         # is in arbitrary order, we have to add a call to sort method
         # We can't directly use os.listdir().sort(), since sort is in place
         tt = os.listdir(self.cfg['targets_dir'])
         tt.sort()
         for tgt_name in tt:
                 tgt_path = os.path.normpath(self.cfg['targets_dir'] + '/' + tgt_name)
                 tgt_root = os.path.normpath(tgt_path + "/root")
                 if not os.path.isdir(tgt_path) or \
                    not os.path.isdir(tgt_root) or \
                    os.path.islink(tgt_path):
                         continue
                 rel = XTargetReleaseParser().get(tgt_path, self.cfg['release_file'])
                 if not rel:
                         rel = {}
                 if rel.has_key('name') and rel.has_key('version'):
                         tgt_pkg = '%s-%s' % (rel['name'], rel['version'])
                 else:
                         tgt_pkg = None
                 tgt_list.append((tgt_name,
                                  tgt_pkg,
                                  rel.get('arch', None),
                                  rel.get('flags', None)))
         return tgt_list
示例#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 get(self, key):
     rel = XTargetReleaseParser().get(self.get_current(),
                                      self.cfg['release_file'])
     if not rel:
         raise XTargetError("Parsing target release file failed")
     if not rel.has_key(key):
         raise XTargetError(
             "Key '%s' is not available in target release file" % key)
     return rel[key]
示例#5
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))
示例#6
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))
示例#7
0
 def list_targets(self):
     """ List installed targets.
             Looks for targets in /usr/targets (TARGETS_DIR) """
     tgt_list = []
     if not os.path.isdir(self.cfg['targets_dir']):
         return tgt_list
     # Since we have a test suite using this output and os.listdir output
     # is in arbitrary order, we have to add a call to sort method
     # We can't directly use os.listdir().sort(), since sort is in place
     tt = os.listdir(self.cfg['targets_dir'])
     tt.sort()
     for tgt_name in tt:
         tgt_path = os.path.normpath(self.cfg['targets_dir'] + '/' +
                                     tgt_name)
         tgt_root = os.path.normpath(tgt_path + "/root")
         if not os.path.isdir(tgt_path) or \
            not os.path.isdir(tgt_root) or \
            os.path.islink(tgt_path):
             continue
         rel = XTargetReleaseParser().get(tgt_path,
                                          self.cfg['release_file'])
         if not rel:
             rel = {}
         if rel.has_key('name') and rel.has_key('version'):
             tgt_pkg = '%s-%s' % (rel['name'], rel['version'])
         else:
             tgt_pkg = None
         tgt_list.append(
             (tgt_name, tgt_pkg, rel.get('arch',
                                         None), rel.get('flags', None)))
     return tgt_list
示例#8
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)