From 73554c69c4b52ccb9c097ce7ffecf81fe7746943 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Thu, 20 Dec 2007 18:32:15 +0000 Subject: [PATCH] Merged from trunk 8941:8967 | 8942 | Generalize the sed -> gsed wrapper script so that it's | | zmedico | possible to create awk, make, and patch symlinks that behave | | | analogously. These symlinks will make it unnecessary for | | | default-bsd profiles to define profile.bashrc aliases for | | | these commands. | | 8943 | Fix typo: %% -> ##. | | zmedico | | | 8944 | Bug #176467 - Filter out USE flags that aren't part of IUSE. | | zmedico | Some flags are considered to be implicit members of IUSE: * | | | Flags derived from ARCH * Flags derived from | | | USE_EXPAND_HIDDEN variables * Forced flags, such as those | | | from {,package}use.force | | 8945 | Create a PORTAGE_IUSE variable containing an egrep pattern | | zmedico | for use by the QA check that's built into useq(). This | | | allows the IUSE logic for this check to be isolated in the | | | python code. | | 8949 | Include masked flags in PORTAGE_IUSE to avoid more false | | zmedico | positives in the useq() IUSE check. | | 8951 | Only enable the PORTAGE_IUSE check during build time phases | | zmedico | since that's the only time it's valid for now. | | 8953 | Display the merge list with blockers any time that there are | | zmedico | blockers, instead of telling the user to try again with | | | --pretend. | | 8955 | Make special build and bootstrap flags into implicit members | | zmedico | of IUSE so that stage builds will work again. | | 8957 | Fix USE filtering code so that it doesn't rely on | | zmedico | config.setcpv() calling config.regenerate(). | | 8959 | Store filtered USE for config.environ() calls in a special | | zmedico | attribute so that the normal global USE is still available | | | for things like emerge --info output. | | 8961 | Trigger a config.regenerate() call inside setcpv() when the | | zmedico | EBUILD_PHASE variable is defined. It's too expensive to do | | | the regenerate() call every time. Do in when EBUILD_PHASE is | | | defined since it's needed to create the filtered USE that | | | environ() passes to the ebuild environment. | | 8963 | Keep filtered USE in the PORTAGE_USE variable to keep it | | zmedico | separate from the global USE that's shown by emerge --info. | | 8965 | Bug #140180 - Ignore missing HOMEPAGE and LICENSE variables | | zmedico | for new-style virtual packages. | | 8967 | Always add ARCH to USE without relying on it being listed in | | zmedico | PORTAGE_ARCHLIST. | svn path=/main/branches/prefix/; revision=9000 --- bin/ebuild.sh | 22 +++++------ bin/repoman | 3 +- bin/sed | 19 +++++---- pym/_emerge/__init__.py | 11 ++++-- pym/portage/__init__.py | 85 +++++++++++++++++++++++++++++++++++++---- 5 files changed, 109 insertions(+), 31 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 9e9c139e7..461aa7267 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -138,16 +138,15 @@ useq() { fi # Make sure we have this USE flag in IUSE - if ! hasq "${u}" ${IUSE} ${E_IUSE} && \ - ! hasq "+${u}" ${IUSE} ${E_IUSE} && \ - ! hasq "-${u}" ${IUSE} ${E_IUSE} && \ - ! hasq "${u}" ${PORTAGE_ARCHLIST} selinux && \ - [[ ${u} != prefix ]] && \ - [[ ${u} != arch_* ]] && \ - [[ ${u} != elibc_* ]] && \ - [[ ${u} != kernel_* ]] && \ - [[ ${u} != userland_* ]] ; then - eqawarn "QA Notice: USE Flag '${u}' not in IUSE for ${CATEGORY}/${PF}" + if [[ -n ${PORTAGE_IUSE} ]] && \ + [[ -n ${EBUILD_PHASE} ]] && \ + ! hasq ${EBUILD_PHASE} config depend info prerm postrm postinst && \ + [[ ${EMERGE_FROM} != binary ]] ; then + # TODO: Implement PORTAGE_IUSE for binary packages. Currently, + # it is only valid for build time phases. + echo "${u}" | egrep -q "${PORTAGE_IUSE}" || \ + eqawarn "QA Notice: USE Flag '${u}' not" \ + "in IUSE for ${CATEGORY}/${PF}" fi if hasq ${u} ${USE} ; then @@ -1388,7 +1387,8 @@ READONLY_EBUILD_METADATA="DEPEND DESCRIPTION READONLY_PORTAGE_VARS="D EBUILD EBUILD_PHASE \ EBUILD_SH_ARGS EMERGE_FROM FILESDIR PORTAGE_BINPKG_FILE \ - PORTAGE_BIN_PATH PORTAGE_PYM_PATH PORTAGE_MUTABLE_FILTERED_VARS \ + PORTAGE_BIN_PATH PORTAGE_IUSE \ + PORTAGE_PYM_PATH PORTAGE_MUTABLE_FILTERED_VARS \ PORTAGE_SAVED_READONLY_VARS PORTAGE_TMPDIR T WORKDIR ED" PORTAGE_SAVED_READONLY_VARS="A CATEGORY P PF PN PR PV PVR" diff --git a/bin/repoman b/bin/repoman index 3d2c1df7e..83f494263 100755 --- a/bin/repoman +++ b/bin/repoman @@ -1339,7 +1339,8 @@ for x in scanlist: for pos, missing_var in enumerate(missingvars): if not myaux.get(missing_var): - if missing_var == "LICENSE" and catdir == "virtual": + if catdir == "virtual" and \ + missing_var in ("HOMEPAGE", "LICENSE"): continue myqakey=missingvars[pos]+".missing" stats[myqakey]=stats[myqakey]+1 diff --git a/bin/sed b/bin/sed index d0ad70a74..fbff4ffdf 100755 --- a/bin/sed +++ b/bin/sed @@ -1,21 +1,24 @@ #!@BASH@ # Copyright 2006 Gentoo Foundation +# Copyright 2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 - -scriptpath="${BASH_SOURCE[0]}" +# $Id$ + +scriptpath=${BASH_SOURCE[0]} +scriptname=${scriptpath##*/} -if [[ -n ${ESED} ]]; then +if [[ sed == ${scriptname} ]] && [[ -n ${ESED} ]]; then exec ${ESED} "$@" -elif type -P gsed > /dev/null ; then - exec gsed "$@" +elif type -P g${scriptname} > /dev/null ; then + exec g${scriptname} "$@" else old_IFS="${IFS}" IFS=":" for path in $PATH; do - [[ ${path}/sed == $scriptpath ]] && continue - if [[ -x $path/sed ]]; then - exec $path/sed "$@" + [[ ${path}/${scriptname} == ${scriptpath} ]] && continue + if [[ -x ${path}/${scriptname} ]]; then + exec ${path}/${scriptname} "$@" exit 0 fi done diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index e3dc277ef..b32d8b7a9 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -6610,12 +6610,15 @@ def action_build(settings, trees, mtimedb, for x in pkglist: if x[0] != "blocks": continue - msg = "Error: the " + x[2] + " package conflicts " + \ - "with another package; the two packages cannot " + \ - "be installed on the same system together. " + \ - "Please use 'emerge --pretend' to determine blockers." + retval = mydepgraph.display(mydepgraph.altlist( + reversed=("--tree" in myopts)), + favorites=favorites) + msg = "Error: The above package list contains " + \ + "packages which cannot be installed " + \ + "at the same time on the same system." prefix = bad(" * ") from textwrap import wrap + print for line in wrap(msg, 70): print prefix + line if "--quiet" not in myopts: diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 9c776f1a0..94c16336e 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -886,6 +886,7 @@ class config(object): "PORTAGE_BUILDDIR", "PORTAGE_COLORMAP", "PORTAGE_CONFIGROOT", "PORTAGE_DEBUG", "PORTAGE_DEPCACHEDIR", "PORTAGE_GID", "PORTAGE_INST_GID", "PORTAGE_INST_UID", + "PORTAGE_IUSE", "PORTAGE_LOG_FILE", "PORTAGE_MASTER_PID", "PORTAGE_PYM_PATH", "PORTAGE_REPO_NAME", "PORTAGE_RESTRICT", "PORTAGE_TMPDIR", "PORTAGE_WORKDIR_MODE", @@ -947,7 +948,8 @@ class config(object): "PORTAGE_ELOG_MAILURI", "PORTAGE_ELOG_SYSTEM", "PORTAGE_GPG_DIR", "PORTAGE_GPG_KEY", "PORTAGE_PACKAGE_EMPTY_ABORT", "PORTAGE_RSYNC_EXTRA_OPTS", "PORTAGE_RSYNC_OPTS", - "PORTAGE_RSYNC_RETRIES", "PORT_LOGDIR", "QUICKPKG_DEFAULT_OPTS", + "PORTAGE_RSYNC_RETRIES", "PORTAGE_USE", "PORT_LOGDIR", + "QUICKPKG_DEFAULT_OPTS", "RESUMECOMMAND", "RESUMECOMMAND_HTTP", "RESUMECOMMAND_HTTP", "RESUMECOMMAND_SFTP", "SYNC", "USE_EXPAND_HIDDEN", "USE_ORDER", ] @@ -1922,7 +1924,7 @@ class config(object): self.configdict["pkg"]["USE"] = self.puse[:] # this gets appended to USE if iuse != self.configdict["pkg"].get("IUSE",""): self.configdict["pkg"]["IUSE"] = iuse - if self._use_wildcards: + if self._use_wildcards or self.get("EBUILD_PHASE"): # Without this conditional, regenerate() would be called # *every* time. has_changed = True @@ -2400,11 +2402,71 @@ class config(object): # USE_EXPAND context. pass - # Pre-Pend ARCH variable to USE settings so '-*' in env doesn't kill arch. - if self.configdict["defaults"].has_key("ARCH"): - if self.configdict["defaults"]["ARCH"]: - if self.configdict["defaults"]["ARCH"] not in usesplit: - usesplit.insert(0,self.configdict["defaults"]["ARCH"]) + arch = self.configdict["defaults"].get("ARCH") + if arch and arch not in usesplit: + usesplit.append(arch) + + # Filter out USE flags that aren't part of IUSE. Some + # flags are considered to be implicit members of IUSE: + # + # * Flags derived from ARCH + # * Flags derived from USE_EXPAND_HIDDEN variables + # * Masked flags, such as those from {,package}use.mask + # * Forced flags, such as those from {,package}use.force + # * build and bootstrap flags used by bootstrap.sh + + if True: + # Do this even when there's no package since setcpv() can + # optimize away regenerate() calls. + iuse_implicit = set(iuse) + + # Flags derived from ARCH. + if arch: + iuse_implicit.add(arch) + iuse_implicit.update(self.get("PORTAGE_ARCHLIST", "").split()) + + # Flags derived from USE_EXPAND_HIDDEN variables + # such as ELIBC, KERNEL, and USERLAND. + use_expand_hidden = self.get("USE_EXPAND_HIDDEN", "").split() + use_expand_hidden_raw = use_expand_hidden + if use_expand_hidden: + use_expand_hidden = re.compile("^(%s)_.*" % \ + ("|".join(x.lower() for x in use_expand_hidden))) + for x in usesplit: + if use_expand_hidden.match(x): + iuse_implicit.add(x) + + # Flags that have been masked or forced. + iuse_implicit.update(self.usemask) + iuse_implicit.update(self.useforce) + + # build and bootstrap flags used by bootstrap.sh + iuse_implicit.add("build") + iuse_implicit.add("bootstrap") + + # prefix flag is used in Prefix + iuse_implicit.add("prefix") + + iuse_grep = iuse_implicit.copy() + if use_expand_hidden_raw: + for x in use_expand_hidden_raw: + iuse_grep.add(x.lower() + "_.*") + if iuse_grep: + iuse_grep = "^(%s)$" % "|".join(sorted(iuse_grep)) + else: + iuse_grep = "" + self["PORTAGE_IUSE"] = iuse_grep + + usesplit = [x for x in usesplit if \ + x not in self.usemask] + + # Filtered for the ebuild environment. Store this in a separate + # attribute since we still want to be able to see global USE + # settings for things like emerge --info. + self["PORTAGE_USE"] = " ".join(sorted( + x for x in usesplit if \ + x in iuse_implicit)) + self.backup_changes("PORTAGE_USE") usesplit.sort() self.configlist[-1]["USE"]= " ".join(usesplit) @@ -2608,6 +2670,9 @@ class config(object): if v is not None: mydict[k] = v + # Filtered by IUSE and implicit IUSE. + mydict["USE"] = self["PORTAGE_USE"] + # sandbox's bashrc sources /etc/profile which unsets ROOTPATH, # so we have to back it up and restore it. rootpath = mydict.get("ROOTPATH") @@ -3797,6 +3862,11 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m # so that the caller can override it. tmpdir = mysettings["PORTAGE_TMPDIR"] + # This variable is a signal to setcpv where it triggers + # filtering of USE for the ebuild environment. + mysettings["EBUILD_PHASE"] = mydo + mysettings.backup_changes("EBUILD_PHASE") + if mydo != "depend": """For performance reasons, setcpv only triggers reset when it detects a package-specific change in config. For the ebuild @@ -3810,6 +3880,7 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m # so restore it to it's original value. mysettings["PORTAGE_TMPDIR"] = tmpdir + mysettings.pop("EBUILD_PHASE", None) # remove from backupenv mysettings["EBUILD_PHASE"] = mydo mysettings["PORTAGE_MASTER_PID"] = str(os.getpid()) -- 2.26.2