From: Fabian Groffen Date: Sat, 10 Dec 2011 10:56:53 +0000 (+0100) Subject: Merge remote-tracking branch 'overlays-gentoo-org/master' into prefix X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=28b58821c000fc413312cb44c85f6697a555625c;p=portage.git Merge remote-tracking branch 'overlays-gentoo-org/master' into prefix Conflicts: bin/dispatch-conf bin/egencache bin/phase-functions.sh bin/portageq bin/repoman cnf/make.globals pym/_emerge/Binpkg.py pym/portage/__init__.py pym/portage/data.py pym/portage/dispatch_conf.py pym/portage/package/ebuild/_config/special_env_vars.py --- 28b58821c000fc413312cb44c85f6697a555625c diff --cc bin/dispatch-conf index e639b66d8,75e991189..1b86461c9 --- a/bin/dispatch-conf +++ b/bin/dispatch-conf @@@ -92,7 -85,7 +92,7 @@@ class dispatch confs = [] count = 0 - config_root = os.environ.get("__PORTAGE_TEST_EPREFIX", EPREFIX) - config_root = portage.const.EPREFIX or os.sep ++ config_root = EPREFIX or os.sep self.options = portage.dispatch_conf.read_config(MANDATORY_OPTS) if "log-file" in self.options: diff --cc bin/egencache index d27754d4a,6d18f66e5..b7893e694 --- a/bin/egencache +++ b/bin/egencache @@@ -842,12 -841,10 +842,10 @@@ def egencache_main(args) if options.portdir is not None: env['PORTDIR'] = options.portdir - eprefix = os.environ.get("__PORTAGE_TEST_EPREFIX") - if not eprefix: - eprefix = EPREFIX - eprefix = portage.const.EPREFIX ++ eprefix = EPREFIX settings = portage.config(config_root=config_root, - local_config=False, env=env, _eprefix=eprefix) + local_config=False, env=env, eprefix=eprefix) default_opts = None if not options.ignore_default_opts: diff --cc bin/phase-functions.sh index 40decb75d,f862b30fe..331afc8ae --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@@ -28,7 -28,7 +28,7 @@@ PORTAGE_READONLY_VARS="D EBUILD EBUILD_ PORTAGE_TMPDIR PORTAGE_UPDATE_ENV PORTAGE_USERNAME \ PORTAGE_VERBOSE PORTAGE_WORKDIR_MODE PORTDIR PORTDIR_OVERLAY \ PROFILE_PATHS REPLACING_VERSIONS REPLACED_BY_VERSION T WORKDIR \ - __PORTAGE_TEST_EPREFIX ED EROOT" - PORTAGE_OVERRIDE_EPREFIX" ++ PORTAGE_OVERRIDE_EPREFIX ED EROOT" PORTAGE_SAVED_READONLY_VARS="A CATEGORY P PF PN PR PV PVR" diff --cc pym/_emerge/Binpkg.py index 4b66033b0,b25906918..213ced256 --- a/pym/_emerge/Binpkg.py +++ b/pym/_emerge/Binpkg.py @@@ -19,8 -19,8 +20,9 @@@ from portage import _unicode_decod from portage import _unicode_encode import io import logging + import shutil from portage.output import colorize +from portage.const import EPREFIX class Binpkg(CompositeTask): @@@ -267,23 -267,6 +270,25 @@@ finally: f.close() ++ # PREFIX LOCAL: deal with EPREFIX from binpkg + # Retrieve the EPREFIX this package was built with - self._buildprefix = pkg_xpak.getfile(_unicode_encode("EPREFIX", ++ self._build_prefix = pkg_xpak.getfile(_unicode_encode("EPREFIX", + encoding=_encodings['repo.content'])) - if not self._buildprefix: - self._buildprefix = '' ++ if not self._buil_dprefix: ++ self._build_prefix = '' + else: - self._buildprefix = self._buildprefix.strip() ++ self._build_prefix = self._build_prefix.strip() + # We want to install in "our" prefix, not the binary one + self.settings["EPREFIX"] = EPREFIX + f = io.open(_unicode_encode(os.path.join(infloc, 'EPREFIX'), + encoding=_encodings['fs'], errors='strict'), + mode='w', encoding=_encodings['content'], errors='strict') + try: + f.write(_unicode_decode(EPREFIX + "\n")) + finally: + f.close() ++ # END PREFIX LOCAL + env_extractor = BinpkgEnvExtractor(background=self.background, scheduler=self.scheduler, settings=self.settings) @@@ -309,16 -292,9 +314,18 @@@ self.wait() return ++ # PREFIX LOCAL: + # if the prefix differs, we copy it to the image after + # extraction using chpathtool - if (self._buildprefix != EPREFIX): ++ if (self._build_prefix != EPREFIX): + pkgloc = self._work_dir + else: + pkgloc = self._image_dir ++ # END PREFIX LOCAL + extractor = BinpkgExtractorAsync(background=self.background, env=self.settings.environ(), - image_dir=self._image_dir, + image_dir=pkgloc, pkg=self.pkg, pkg_path=self._pkg_path, logfile=self.settings.get("PORTAGE_LOG_FILE"), scheduler=self.scheduler) @@@ -333,21 -309,61 +340,27 @@@ self.wait() return - if self._buildprefix != EPREFIX: - try: - with io.open(_unicode_encode(os.path.join(self._infloc, "EPREFIX"), - encoding=_encodings['fs'], errors='strict'), mode='r', - encoding=_encodings['repo.content'], errors='replace') as f: - self._build_prefix = f.read().rstrip('\n') - except IOError: - self._build_prefix = "" - - if self._build_prefix == self.settings["EPREFIX"]: - ensure_dirs(self.settings["ED"]) - self._current_task = None - self.returncode = os.EX_OK ++ # PREFIX LOCAL: use chpathtool binary ++ if self._build_prefix != EPREFIX: + chpathtool = BinpkgChpathtoolAsync(background=self.background, + image_dir=self._image_dir, work_dir=self._work_dir, - buildprefix=self._buildprefix, eprefix=EPREFIX, ++ buildprefix=self._build_prefix, eprefix=EPREFIX, + pkg=self.pkg, scheduler=self.scheduler) + self._writemsg_level(">>> Adjusting Prefix to %s\n" % EPREFIX) + self._start_task(chpathtool, self._chpathtool_exit) + else: self.wait() - return - - chpathtool = SpawnProcess( - args=[portage._python_interpreter, - os.path.join(self.settings["PORTAGE_BIN_PATH"], "chpathtool.py"), - self.settings["D"], self._build_prefix, self.settings["EPREFIX"]], - background=self.background, env=self.settings.environ(), - scheduler=self.scheduler, - logfile=self.settings.get('PORTAGE_LOG_FILE')) - self._writemsg_level(">>> Adjusting Prefix to %s\n" % self.settings["EPREFIX"]) - self._start_task(chpathtool, self._chpathtool_exit) ++ # END PREFIX LOCAL def _chpathtool_exit(self, chpathtool): if self._final_exit(chpathtool) != os.EX_OK: self._unlock_builddir() - writemsg("!!! Error Adjusting Prefix to %s\n" % EPREFIX, - noiselevel=-1) + self._writemsg_level("!!! Error Adjusting Prefix to %s" % + (self.settings["EPREFIX"],), + noiselevel=-1, level=logging.ERROR) + self.wait() + return + - # We want to install in "our" prefix, not the binary one - with io.open(_unicode_encode(os.path.join(self._infloc, "EPREFIX"), - encoding=_encodings['fs'], errors='strict'), mode='w', - encoding=_encodings['repo.content'], errors='strict') as f: - f.write(self.settings["EPREFIX"] + "\n") - - # Move the files to the correct location for merge. - image_tmp_dir = os.path.join( - self.settings["PORTAGE_BUILDDIR"], "image_tmp") - build_d = os.path.join(self.settings["D"], - self._build_prefix.lstrip(os.sep)) - if not os.path.isdir(build_d): - # Assume this is a virtual package or something. - shutil.rmtree(self._image_dir) - ensure_dirs(self.settings["ED"]) - else: - os.rename(build_d, image_tmp_dir) - shutil.rmtree(self._image_dir) - ensure_dirs(os.path.dirname(self.settings["ED"].rstrip(os.sep))) - os.rename(image_tmp_dir, self.settings["ED"]) - self.wait() def _unlock_builddir(self): diff --cc pym/portage/__init__.py index c5b7f7682,1df956633..21ca69e12 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@@ -505,11 -505,9 +506,8 @@@ def create_trees(config_root=None, targ if env is None: env = os.environ - eprefix = env.get("__PORTAGE_TEST_EPREFIX") - if not eprefix: - eprefix = EPREFIX - settings = config(config_root=config_root, target_root=target_root, - env=env, _eprefix=eprefix) + env=env, eprefix=eprefix) settings.lock() trees._target_eroot = settings['EROOT'] diff --cc pym/portage/const.py index 83d669658,a32933c4b..2223b4c5e --- a/pym/portage/const.py +++ b/pym/portage/const.py @@@ -191,13 -146,11 +191,13 @@@ MANIFEST2_IDENTIFIERS = ("AUX", "MIS # a config instance (since it's possible to contruct a config instance with # a different EPREFIX). Therefore, the EPREFIX constant should *NOT* be used # in the definition of any other contstants within this file. -EPREFIX="" +# PREFIX LOCAL: rely on EPREFIX from autotools +#EPREFIX="" +# END PREFIX LOCAL # pick up EPREFIX from the environment if set - if "__PORTAGE_TEST_EPREFIX" in os.environ: - EPREFIX = os.environ["__PORTAGE_TEST_EPREFIX"] + if "PORTAGE_OVERRIDE_EPREFIX" in os.environ: + EPREFIX = os.environ["PORTAGE_OVERRIDE_EPREFIX"] if EPREFIX: EPREFIX = os.path.normpath(EPREFIX) diff --cc pym/portage/data.py index e8a0a3ab0,53af6b966..196e5dc95 --- a/pym/portage/data.py +++ b/pym/portage/data.py @@@ -95,15 -86,8 +90,16 @@@ def _get_global(k) secpass = 2 #Discover the uid and gid of the portage user/group try: - portage_gid = grp.getgrnam(_get_global('_portage_grpname'))[2] - portage_uid = pwd.getpwnam(_get_global('_portage_uname')).pw_uid + portage_gid = grp.getgrnam(_get_global('_portage_grpname')).gr_gid + except KeyError: - # some sysadmins are insane, bug #344307 ++ # PREFIX LOCAL: some sysadmins are insane, bug #344307 + if _get_global('_portage_grpname').isdigit(): + portage_gid = int(_get_global('_portage_grpname')) + else: + portage_gid = None ++ # END PREFIX LOCAL + try: - portage_uid = pwd.getpwnam(_get_global('_portage_uname'))[2] ++ portage_uid = pwd.getpwnam(_get_global('_portage_uname')).pw_uid if secpass < 1 and portage_gid in os.getgroups(): secpass = 1 except KeyError: diff --cc pym/portage/dispatch_conf.py index bfd6517b2,7f407fffe..11a6a7d83 --- a/pym/portage/dispatch_conf.py +++ b/pym/portage/dispatch_conf.py @@@ -40,8 -39,8 +40,9 @@@ def diffstatusoutput_len(cmd) return (1, 1) def read_config(mandatory_opts): - eprefix = os.environ.get("__PORTAGE_TEST_EPREFIX", EPREFIX) - config_path = os.path.join(eprefix, "etc/dispatch-conf.conf") - eprefix = portage.const.EPREFIX ++ eprefix = EPREFIX + config_path = os.path.join(eprefix or os.sep, "etc/dispatch-conf.conf") ++>>>>>>> overlays-gentoo-org/master loader = KeyValuePairFileLoader(config_path, None) opts, errors = loader.load() if not opts: diff --cc pym/portage/package/ebuild/_config/special_env_vars.py index d07f68b35,3911e9773..a2f65057f --- a/pym/portage/package/ebuild/_config/special_env_vars.py +++ b/pym/portage/package/ebuild/_config/special_env_vars.py @@@ -66,9 -66,7 +66,9 @@@ environ_whitelist += "REPLACING_VERSIONS", "REPLACED_BY_VERSION", "ROOT", "ROOTPATH", "T", "TMP", "TMPDIR", "USE_EXPAND", "USE_ORDER", "WORKDIR", - "XARGS", "__PORTAGE_TEST_EPREFIX", + "XARGS", "PORTAGE_OVERRIDE_EPREFIX", + "BPREFIX", "DEFAULT_PATH", "EXTRA_PATH", + "PORTAGE_GROUP", "PORTAGE_USER", ] # user config variables