Merged from trunk 8754:8781
authorFabian Groffen <grobian@gentoo.org>
Sun, 2 Dec 2007 21:32:12 +0000 (21:32 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sun, 2 Dec 2007 21:32:12 +0000 (21:32 -0000)
   | 8755    | Remove unused EBUILD_ENV_FILE variable.                      |
   | zmedico |                                                              |

   | 8757    | * After the initial setup phase, the original ebuild and     |
   | zmedico | eclasses are no longer needed because the same ebuild        |
   |         | environment is reused for the entire lifecycle of the        |
   |         | package, including uninstallation.                           |

   | 8759    | Make config.environ() export PKGDIR to the ebuild            |
   | zmedico | environment during the "package" phase since it's currently  |
   |         | referenced there.                                            |

   | 8761    | Don't use sandbox's BASH_ENV for new shells because it does  |
   | zmedico | 'source /etc/profile' which can interfere with the build     |
   |         | environment by modifying our PATH.                           |

   | 8763    | Add some variables such as TERM to the whitelist of          |
   | zmedico | variables from the calling environment that are allowed into |
   |         | the ebuild environment.                                      |

   | 8765    | Bug #200775 - Save more portage generated environment        |
   | zmedico | variables that are in environment.bz2 so that they are       |
   |         | available for use by tools such as epm.                      |

   | 8768    | sandbox unsets ROOTPATH, so we have to back it up on the     |
   | zmedico | python side then restore it on the bash side.                |

   | 8770    | Bug #200863 - Don't filter ${KV} since kernel-2.eclass uses  |
   | zmedico | that variable and we don't want to interfere.                |

   | 8771    | In doebuild_environment(), fix KV logic so that it never     |
   | zmedico | gets set during the "depend" phase. Also, use                |
   |         | backup_changes() to properly cache the result.               |

   | 8774    | Fix quoting for PORTAGE_ROOTPATH.                            |
   | zmedico |                                                              |

   | 8776    | Update comments about ROOTPATH: sandbox's bashrc sources     |
   | zmedico | /etc/profile which unsets ROOTPATH, so we have to back it up |
   |         | and restore it.                                              |

   | 8777    | Update comments about ROOTPATH: sandbox's bashrc sources     |
   | zmedico | /etc/profile which unsets ROOTPATH, so we have to back it up |
   |         | and restore it                                               |

   | 8779    | * whitelist DISTDIR, PORTDIR, and PORTAGE_TMPDIR,            |
   | zmedico | PORTAGE_WORKDIR_MODE. * whitelist RPMDIR just for the "rpm"  |
   |         | phase.                                                       |

   | 8781    | * whitelist PREROOTPATH in config.environ() * filter         |
   | zmedico | PREROOTPATH in save_ebuild_env()                             |

svn path=/main/branches/prefix/; revision=8813

NEWS
bin/ebuild.sh
bin/isolated-functions.sh
pym/portage/__init__.py

diff --git a/NEWS b/NEWS
index dcb884ab79a43ac3c0375a8cbe9ac94cb576e843..86c9d5489af8e9328593bcbe553e0bc36b2976ae 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,13 @@ portage-2.2
 * Add support for news items (GLEP 42)
 * Add support for generic package sets (also see RELEASE-NOTES)
 
+portage-2.1.4
+-------------
+
+* After the initial setup phase, the original ebuild and eclasses are no
+  longer needed because the same ebuild environment is reused for the
+  entire lifecycle of the package, including uninstallation.
+
 portage-2.1.3
 -------------
 
index 5ae30bda9d9ef9407fa49693de2f74f23947eddd..7e3c21b1af81be1e806dad930cd3ba3e1a079604 100755 (executable)
@@ -10,6 +10,17 @@ SANDBOX_PREDICT="${SANDBOX_PREDICT}:/proc/self/maps:/dev/console:/dev/random"
 export SANDBOX_PREDICT="${SANDBOX_PREDICT}:${PORTAGE_PYM_PATH}:${PORTAGE_DEPCACHEDIR}"
 export SANDBOX_WRITE="${SANDBOX_WRITE}:/dev/shm:/dev/stdout:/dev/stderr:${PORTAGE_TMPDIR}"
 export SANDBOX_READ="${SANDBOX_READ}:/dev/shm:/dev/stdin:${PORTAGE_TMPDIR}"
+# Don't use sandbox's BASH_ENV for new shells because it does
+# 'source /etc/profile' which can interfere with the build
+# environment by modifying our PATH.
+unset BASH_ENV
+
+# sandbox's bashrc sources /etc/profile which unsets ROOTPATH,
+# so we have to back it up and restore it.
+if [ -n "${PORTAGE_ROOTPATH}" ] ; then
+       export ROOTPATH=${PORTAGE_ROOTPATH}
+       unset PORTAGE_ROOTPATH
+fi
 
 if [ ! -z "${PORTAGE_GPG_DIR}" ]; then
        SANDBOX_PREDICT="${SANDBOX_PREDICT}:${PORTAGE_GPG_DIR}"
@@ -1001,7 +1012,8 @@ dyn_install() {
                # the global environment though, in case the user wants to repeat
                # this phase (like with FEATURES=noauto and the ebuild command).
                unset S _E_DOCDESTTREE_ _E_EXEDESTTREE_
-               save_ebuild_env | filter_readonly_variables --filter-sandbox > environment
+               save_ebuild_env | filter_readonly_variables \
+                       --filter-sandbox --allow-extra-vars > environment
        )
        bzip2 -f9 environment
 
@@ -1366,19 +1378,21 @@ READONLY_EBUILD_METADATA="DEPEND DESCRIPTION
        EAPI HOMEPAGE INHERITED IUSE KEYWORDS LICENSE
        PDEPEND PROVIDE RDEPEND RESTRICT SLOT SRC_URI"
 
-READONLY_PORTAGE_VARS="A CATEGORY D EBUILD EBUILD_ENV_FILE EBUILD_PHASE \
-       EBUILD_SH_ARGS EMERGE_FROM FILESDIR P PF PN \
+READONLY_PORTAGE_VARS="D EBUILD EBUILD_PHASE \
+       EBUILD_SH_ARGS EMERGE_FROM FILESDIR \
        PORTAGE_BIN_PATH PORTAGE_PYM_PATH PORTAGE_MUTABLE_FILTERED_VARS \
-       PORTAGE_TMPDIR PR PV PVR T WORKDIR ED"
+       PORTAGE_SAVED_READONLY_VARS PORTAGE_TMPDIR T WORKDIR ED"
+
+PORTAGE_SAVED_READONLY_VARS="A CATEGORY P PF PN PR PV PVR"
 
 # Variables that portage sets but doesn't mark readonly.
 # In order to prevent changed values from causing unexpected
 # interference, they are filtered out of the environment when
 # it is saved or loaded (any mutations do not persist).
-PORTAGE_MUTABLE_FILTERED_VARS="AA"
+PORTAGE_MUTABLE_FILTERED_VARS="AA HOSTNAME"
 
 # @FUNCTION: filter_readonly_variables
-# @DESCRIPTION: [--filter-sandbox]
+# @DESCRIPTION: [--filter-sandbox] [--allow-extra-vars]
 # Read an environment from stdin and echo to stdout while filtering readonly
 # variables.
 #
@@ -1386,6 +1400,9 @@ PORTAGE_MUTABLE_FILTERED_VARS="AA"
 # is only desired in certain cases, such as during preprocessing or when
 # saving environment.bz2 for a binary or installed package.
 #
+# ---allow-extra-vars causes some extra vars to be allowd through, such
+# as ${PORTAGE_SAVED_READONLY_VARS} and ${PORTAGE_MUTABLE_FILTERED_VARS}.
+#
 # In bash-3.2_p20+ an attempt to assign BASH_*, FUNCNAME, GROUPS or any
 # readonly variable cause the shell to exit while executing the "source"
 # builtin command. To avoid this problem, this function filters those
@@ -1398,12 +1415,19 @@ filter_readonly_variables() {
                SANDBOX_DEBUG_LOG SANDBOX_DISABLED SANDBOX_LIB
                SANDBOX_LOG"
        filtered_vars="${readonly_bash_vars} ${READONLY_PORTAGE_VARS}
-               ${PORTAGE_MUTABLE_FILTERED_VARS} BASH_[_[:alnum:]]*"
+               BASH_[_[:alnum:]]*"
        if hasq --filter-sandbox $* ; then
                filtered_vars="${filtered_vars} SANDBOX_[_[:alnum:]]*"
        else
                filtered_vars="${filtered_vars} ${filtered_sandbox_vars}"
        fi
+       if ! hasq --allow-extra-vars $* ; then
+               filtered_vars="
+                       ${filtered_vars}
+                       ${PORTAGE_SAVED_READONLY_VARS}
+                       ${PORTAGE_MUTABLE_FILTERED_VARS}
+               "
+       fi
        set -f
        for x in ${filtered_vars} ; do
                var_grep="${var_grep}|${x}"
index c08044cbf990890de5c9953943ddd9928b825fa8..91117828631dad5b8395ddaa23f369d1d85ad7a5 100755 (executable)
@@ -393,7 +393,7 @@ save_ebuild_env() {
        (
 
                # misc variables set by bash
-               unset BASH HOSTNAME HOSTTYPE IFS MACHTYPE OLDPWD \
+               unset BASH HOSTTYPE IFS MACHTYPE OLDPWD \
                        OPTERR OPTIND OSTYPE PS4 PWD SHELL SHLVL
 
                # misc variables inherited from the calling environment
@@ -425,7 +425,7 @@ save_ebuild_env() {
                        EBUILD_EXIT_STATUS_FILE EBUILD_MASTER_PID \
                        ECLASSDIR ECLASS_DEPTH ENDCOL FAKEROOTKEY FEATURES \
                        GOOD HILITE HOME IMAGE \
-                       KV LAST_E_CMD LAST_E_LEN LD_PRELOAD MISC_FUNCTIONS_ARGS MOPREFIX \
+                       LAST_E_CMD LAST_E_LEN LD_PRELOAD MISC_FUNCTIONS_ARGS MOPREFIX \
                        NORMAL PATH PKGDIR PKGUSE PKG_LOGDIR PKG_TMPDIR \
                        PORTAGE_ACTUAL_DISTDIR PORTAGE_ARCHLIST PORTAGE_BASHRC \
                        PORTAGE_BINPKG_TMPFILE PORTAGE_BUILDDIR \
@@ -433,7 +433,8 @@ save_ebuild_env() {
                        PORTAGE_DEPCACHEDIR PORTAGE_GID PORTAGE_INST_GID \
                        PORTAGE_INST_UID PORTAGE_LOG_FILE PORTAGE_MASTER_PID \
                        PORTAGE_REPO_NAME PORTAGE_RESTRICT PORTAGE_WORKDIR_MODE PORTDIR \
-                       PORTDIR_OVERLAY PROFILE_PATHS PWORKDIR QA_INTERCEPTORS \
+                       PORTDIR_OVERLAY PREROOTPATH \
+                       PROFILE_PATHS PWORKDIR QA_INTERCEPTORS \
                        RC_DEFAULT_INDENT RC_DOT_PATTERN RC_ENDCOL \
                        RC_INDENTATION READONLY_EBUILD_METADATA READONLY_PORTAGE_VARS \
                        ROOT ROOTPATH RPMDIR STARTDIR TMP TMPDIR USE_EXPAND \
index cd1ee4a2d7c1b71d204289b961ff0f9d0553df69..22128a949997fae14d04e1229877c0eaddd204f6 100644 (file)
@@ -863,16 +863,29 @@ class config(object):
        virtuals ...etc you look in here.
        """
 
+       _environ_whitelist = []
+
        # Preserve backupenv values that are initialized in the config
        # constructor. Also, preserve XARGS since it is set by the
        # portage.data module.
-       _environ_whitelist = frozenset([
-               "FEATURES", "PORTAGE_BIN_PATH",
+       _environ_whitelist += [
+               "DISTDIR", "FEATURES", "PORTAGE_BIN_PATH",
                "PORTAGE_CONFIGROOT", "PORTAGE_DEPCACHEDIR",
                "PORTAGE_GID", "PORTAGE_INST_GID", "PORTAGE_INST_UID",
-               "PORTAGE_PYM_PATH", "PORTDIR_OVERLAY", "ROOT", "USE_ORDER",
+               "PORTAGE_PYM_PATH", "PORTAGE_WORKDIR_MODE",
+               "PORTDIR", "PORTDIR_OVERLAY", "PREROOTPATH",
+               "ROOT", "ROOTPATH", "USE_ORDER",
                "XARGS",
-       ])
+       ]
+
+       # misc variables inherited from the calling environment
+       _environ_whitelist += [
+               "COLORTERM", "DISPLAY", "EDITOR", "LESS",
+               "LESSOPEN", "LOGNAME", "LS_COLORS", "PAGER",
+               "TERM", "TERMCAP", "USER",
+       ]
+
+       _environ_whitelist = frozenset(_environ_whitelist)
 
        # Filter selected variables in the config.environ() method so that
        # they don't needlessly propagate down into the ebuild environment.
@@ -2578,6 +2591,25 @@ class config(object):
                        writemsg("*** HOME not set. Setting to "+mydict["BUILD_PREFIX"]+"\n")
                        mydict["HOME"]=mydict["BUILD_PREFIX"][:]
 
+               if filter_calling_env:
+                       phase = self.get("EBUILD_PHASE")
+                       if phase:
+                               whitelist = []
+                               if "package" == phase:
+                                       whitelist.append("PKGDIR")
+                               if "rpm" == phase:
+                                       whitelist.append("RPMDIR")
+                               for k in whitelist:
+                                       v = self.get(k)
+                                       if v is not None:
+                                               mydict[k] = v
+
+               # sandbox's bashrc sources /etc/profile which unsets ROOTPATH,
+               # so we have to back it up and restore it.
+               rootpath = mydict.get("ROOTPATH")
+               if rootpath:
+                       mydict["PORTAGE_ROOTPATH"] = rootpath
+
                return mydict
 
        def thirdpartymirrors(self):
@@ -3855,13 +3887,14 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m
                mysettings["PORTAGE_BUILDDIR"], ".exit_status")
 
        #set up KV variable -- DEP SPEEDUP :: Don't waste time. Keep var persistent.
-       if (mydo!="depend") or not mysettings.has_key("KV"):
+       if mydo != "depend" and "KV" not in mysettings:
                mykv,err1=ExtractKernelVersion(os.path.join(myroot, EPREFIX_LSTRIP, "usr/src/linux"))
                if mykv:
                        # Regular source tree
                        mysettings["KV"]=mykv
                else:
                        mysettings["KV"]=""
+               mysettings.backup_changes("KV")
 
        # Allow color.map to control colors associated with einfo, ewarn, etc...
        mycolors = []