From dee447cb2d9cc98be2561ca84c05e40909905bc9 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Fri, 19 Feb 2010 10:12:27 +0000 Subject: [PATCH] Merged from trunk -r15340:15350 | 15341 | Fix dblink._eerror argument where list is required instead | | zmedico | of string. | | 15342 | Remove unnecessary newline in dblink._eerror message. | | zmedico | | | 15343 | Logg errors that occur during binpkg extraction. | | zmedico | | | 15344 | Use os.environ instead of the config.environ(). This solves | | zmedico | binpkg extraction issues with catalyst stage1 due to PATH | | | being unset and bzip2/tar binaries not being found by bash. | | 15345 | When creating a config instance for ROOT=/ with a clean env, | | zmedico | copy PATH and TERM variables, since they may be useful. | | 15346 | Bug #304793 - Update --newuse docs to indicate that this | | zmedico | option also implies --selective. | | 15347 | Bug #262647 - Explicitly exclude SRC_URI and other | | zmedico | potentially long metadata variables from config.environ() | | | exports, to avoid potential E2BIG errors from execve calls. | | 15348 | Evaluate USE conditionals when writing vdb entries after | | zmedico | src_install. | | 15349 | After src_install, save fewer variables when writing the vdb | | zmedico | entry for a virtual package. | | 15350 | Don't save SRC_URI as a vdb entry since it's pretty useless | | zmedico | and it's available in environment.bz2 anyway. | svn path=/main/branches/prefix/; revision=15384 --- bin/ebuild.sh | 17 +++++---- man/emerge.1 | 6 ++-- pym/_emerge/Binpkg.py | 9 +++-- pym/_emerge/BinpkgExtractorAsync.py | 12 +++++-- pym/_emerge/help.py | 7 ++-- pym/portage/__init__.py | 54 +++++++++++++++++++++++------ pym/portage/dbapi/vartree.py | 3 +- 7 files changed, 81 insertions(+), 27 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index f61d322d3..3d6f2ef28 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -1089,17 +1089,22 @@ dyn_install() { set -f local f x IFS=$' \t\n\r' - for f in ASFLAGS CATEGORY CBUILD CC CFLAGS CHOST CTARGET CXX \ - CXXFLAGS DEFINED_PHASES DEPEND EXTRA_ECONF EXTRA_EINSTALL EXTRA_MAKE \ - FEATURES INHERITED IUSE LDFLAGS LIBCFLAGS LIBCXXFLAGS \ - LICENSE PDEPEND PF PKGUSE PROPERTIES PROVIDE RDEPEND RESTRICT SLOT \ - KEYWORDS HOMEPAGE SRC_URI DESCRIPTION; do + for f in CATEGORY DEFINED_PHASES FEATURES INHERITED IUSE \ + PF PKGUSE SLOT KEYWORDS HOMEPAGE DESCRIPTION ; do x=$(echo -n ${!f}) [[ -n $x ]] && echo "$x" > $f done - echo "${EPREFIX}" > EPREFIX + if [[ $CATEGORY != virtual ]] ; then + for f in ASFLAGS CBUILD CC CFLAGS CHOST CTARGET CXX \ + CXXFLAGS EXTRA_ECONF EXTRA_EINSTALL EXTRA_MAKE \ + LDFLAGS LIBCFLAGS LIBCXXFLAGS ; do + x=$(echo -n ${!f}) + [[ -n $x ]] && echo "$x" > $f + done + fi echo "${USE}" > USE echo "${EAPI:-0}" > EAPI + echo "${EPREFIX}" > EPREFIX set +f # local variables can leak into the saved environment. diff --git a/man/emerge.1 b/man/emerge.1 index 7532797ac..bf9cdaa96 100644 --- a/man/emerge.1 +++ b/man/emerge.1 @@ -403,8 +403,10 @@ analogous options that should be configured via \fBMAKEOPTS\fR in \fBmake.conf\fR(5). .TP .BR "\-\-newuse " (\fB\-N\fR) -Tells emerge to include installed packages where USE flags have changed since -compilation. USE flag changes include: +Tells emerge to include installed packages where USE +flags have changed since compilation. This option +also implies the \fB\-\-selective\fR option. +USE flag changes include: A USE flag was added to a package. A USE flag was removed from a package. diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py index c0d0b88c5..ae61b7918 100644 --- a/pym/_emerge/Binpkg.py +++ b/pym/_emerge/Binpkg.py @@ -22,6 +22,7 @@ if os.environ.__contains__("PORTAGE_PYTHONPATH"): else: sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym")) import portage +import logging from portage.output import colorize from portage.const import EPREFIX @@ -303,15 +304,17 @@ class Binpkg(CompositeTask): extractor = BinpkgExtractorAsync(background=self.background, image_dir=pkgloc, - pkg=self.pkg, pkg_path=self._pkg_path, scheduler=self.scheduler) + pkg=self.pkg, pkg_path=self._pkg_path, + logfile=self.settings.get("PORTAGE_LOG_FILE"), + scheduler=self.scheduler) self._writemsg_level(">>> Extracting %s\n" % self.pkg.cpv) self._start_task(extractor, self._extractor_exit) def _extractor_exit(self, extractor): if self._final_exit(extractor) != os.EX_OK: self._unlock_builddir() - writemsg("!!! Error Extracting '%s'\n" % self._pkg_path, - noiselevel=-1) + self._writemsg_level("!!! Error Extracting '%s'\n" % \ + self._pkg_path, noiselevel=-1, level=logging.ERROR) self.wait() return diff --git a/pym/_emerge/BinpkgExtractorAsync.py b/pym/_emerge/BinpkgExtractorAsync.py index e22fcf65d..45af54136 100644 --- a/pym/_emerge/BinpkgExtractorAsync.py +++ b/pym/_emerge/BinpkgExtractorAsync.py @@ -11,6 +11,7 @@ if os.environ.__contains__("PORTAGE_PYTHONPATH"): else: sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym")) import portage + class BinpkgExtractorAsync(SpawnProcess): __slots__ = ("image_dir", "pkg", "pkg_path") @@ -19,10 +20,15 @@ class BinpkgExtractorAsync(SpawnProcess): def _start(self): self.args = [self._shell_binary, "-c", - "bzip2 -dqc -- %s | tar -xp -C %s -f -" % \ + ("bzip2 -dqc -- %s | tar -xp -C %s -f - ; " + \ + "p=(${PIPESTATUS[@]}) ; " + \ + "if [ ${p[0]} != 0 ] ; then " + \ + "echo bzip2 failed with status ${p[0]} ; exit ${p[0]} ; fi ; " + \ + "if [ ${p[1]} != 0 ] ; then " + \ + "echo tar failed with status ${p[1]} ; exit ${p[1]} ; fi ; " + \ + "exit 0 ;") % \ (portage._shell_quote(self.pkg_path), portage._shell_quote(self.image_dir))] - self.env = self.pkg.root_config.settings.environ() + self.env = os.environ.copy() SpawnProcess._start(self) - diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py index 82f0666c8..88b818cfb 100644 --- a/pym/_emerge/help.py +++ b/pym/_emerge/help.py @@ -442,8 +442,11 @@ def help(myopts, havecolor=1): print(desc_indent + line) print() print(" "+green("--newuse")+" ("+green("-N")+" short option)") - print(" Tells emerge to include installed packages where USE flags have ") - print(" changed since installation.") + desc = "Tells emerge to include installed packages where USE " + \ + "flags have changed since compilation. This option " + \ + "also implies the --selective option." + for line in wrap(desc, desc_width): + print(desc_indent + line) print() print(" "+green("--noconfmem")) print(" Portage keeps track of files that have been placed into") diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 9a55f90e2..6f5ec6424 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1382,12 +1382,10 @@ class config(object): virtuals ...etc you look in here. """ - # Don't include anything that could be extremely long here (like SRC_URI) - # since that could cause execve() calls to fail with E2BIG errors. For - # example, see bug #262647. - _setcpv_aux_keys = ('SLOT', 'RESTRICT', 'LICENSE', - 'KEYWORDS', 'INHERITED', 'IUSE', 'PROVIDE', 'EAPI', - 'PROPERTIES', 'DEFINED_PHASES', 'repository') + _setcpv_aux_keys = ('DEFINED_PHASES', 'DEPEND', 'EAPI', + 'INHERITED', 'IUSE', 'KEYWORDS', 'LICENSE', 'PDEPEND', + 'PROPERTIES', 'PROVIDE', 'RDEPEND', 'SLOT', + 'repository', 'RESTRICT', 'LICENSE',) _env_blacklist = [ "A", "AA", "CATEGORY", "DEPEND", "DESCRIPTION", "EAPI", @@ -1486,6 +1484,13 @@ class config(object): # they don't needlessly propagate down into the ebuild environment. _environ_filter = [] + # Exclude anything that could be extremely long here (like SRC_URI) + # since that could cause execve() calls to fail with E2BIG errors. For + # example, see bug #262647. + _environ_filter += [ + 'DEPEND', 'RDEPEND', 'PDEPEND', 'SRC_URI', + ] + # misc variables inherited from the calling environment _environ_filter += [ "INFOPATH", "MANPATH", "USER", @@ -5883,6 +5888,9 @@ def _post_src_install_chost_fix(settings): write_atomic(os.path.join(settings['PORTAGE_BUILDDIR'], 'build-info', 'CHOST'), chost + '\n') +_vdb_use_conditional_keys = ('DEPEND', 'LICENSE', 'PDEPEND', + 'PROPERTIES', 'PROVIDE', 'RDEPEND', 'RESTRICT',) + def _post_src_install_uid_fix(mysettings, out=None): """ Files in $D with user and group bits that match the "portage" @@ -5985,8 +5993,29 @@ def _post_src_install_uid_fix(mysettings, out=None): for l in _merge_unicode_error(unicode_errors): eerror(l, phase='install', key=mysettings.mycpv, out=out) - open(_unicode_encode(os.path.join(mysettings['PORTAGE_BUILDDIR'], - 'build-info', 'SIZE')), 'w').write(str(size) + '\n') + build_info_dir = os.path.join(mysettings['PORTAGE_BUILDDIR'], + 'build-info') + + codecs.open(_unicode_encode(os.path.join(build_info_dir, + 'SIZE'), encoding=_encodings['fs'], errors='strict'), + 'w', encoding=_encodings['repo.content'], + errors='strict').write(str(size) + '\n') + + use = frozenset(mysettings['PORTAGE_USE'].split()) + for k in _vdb_use_conditional_keys: + v = mysettings.configdict['pkg'].get(k) + if v is None: + continue + v = dep.paren_reduce(v) + v = dep.use_reduce(v, uselist=use) + v = dep.paren_normalize(v) + v = dep.paren_enclose(v) + if not v: + continue + codecs.open(_unicode_encode(os.path.join(build_info_dir, + k), encoding=_encodings['fs'], errors='strict'), + mode='w', encoding=_encodings['repo.content'], + errors='strict').write(v + '\n') if bsd_chflags: # Restore all of the flags saved above. @@ -9252,8 +9281,13 @@ def create_trees(config_root=None, target_root=None, trees=None): # When ROOT != "/" we only want overrides from the calling # environment to apply to the config that's associated - # with ROOT != "/", so pass an empty dict for the env parameter. - settings = config(config_root=None, target_root="/", env={}) + # with ROOT != "/", so pass a nearly empty dict for the env parameter. + clean_env = {} + for k in ('PATH', 'TERM'): + v = settings.get(k) + if v is not None: + clean_env[k] = v + settings = config(config_root=None, target_root="/", env=clean_env) settings.lock() myroots.append((settings["ROOT"], settings)) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 89df6e73f..25f92d402 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -3455,7 +3455,8 @@ class dblink(object): # like hell and continue to hopefully finish all our # administrative and pkg_postinst stuff. self._eerror("postrm", - "Could not chmod or unlink '%s': %s\n" % (file_name, ose)) + ["Could not chmod or unlink '%s': %s" % \ + (file_name, ose)]) finally: if bsd_chflags and pflags != 0: # Restore the parent flags we saved before unlinking -- 2.26.2