doebuild: update environment.bz2 for pre/postinst v2.2.0_alpha129
authorZac Medico <zmedico@gentoo.org>
Tue, 18 Sep 2012 02:59:23 +0000 (19:59 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 18 Sep 2012 02:59:23 +0000 (19:59 -0700)
Also, remove unnecessary __dyn_preinst func.

bin/misc-functions.sh
bin/phase-functions.sh
bin/save-ebuild-env.sh
pym/portage/package/ebuild/doebuild.py

index 486b8d29a4f33d95da8bdc8c241d5063448d99c0..1159ca523878396ed8ff29ebfdb6037e750d833d 100755 (executable)
@@ -1082,7 +1082,7 @@ preinst_selinux_labels() {
                 return 1
        fi
        if has selinux ${FEATURES}; then
-               # SELinux file labeling (needs to always be last in __dyn_preinst)
+               # SELinux file labeling (needs to execute after preinst)
                # only attempt to label if setfiles is executable
                # and 'context' is available on selinuxfs.
                if [ -f /selinux/context -o -f /sys/fs/selinux/context ] && \
index 7048419ff29dad794adaf8377e1d989ce4a28c70..92e25c65f515ed574ab1647efa4f70f813ed1cb1 100644 (file)
@@ -601,14 +601,6 @@ __dyn_install() {
        trap - SIGINT SIGQUIT
 }
 
-__dyn_preinst() {
-       if [ -z "${D}" ]; then
-               eerror "${FUNCNAME}: D is unset"
-               return 1
-       fi
-       __ebuild_phase_with_hooks pkg_preinst
-}
-
 __dyn_help() {
        echo
        echo "Portage"
@@ -871,7 +863,7 @@ __ebuild_main() {
        nofetch)
                __ebuild_phase_with_hooks pkg_nofetch
                ;;
-       prerm|postrm|postinst|config|info)
+       prerm|postrm|preinst|postinst|config|info)
                if has "${1}" config info && \
                        ! declare -F "pkg_${1}" >/dev/null ; then
                        ewarn  "pkg_${1}() is not defined: '${EBUILD##*/}'"
@@ -884,7 +876,7 @@ __ebuild_main() {
                        __ebuild_phase_with_hooks pkg_${1}
                        set +x
                fi
-               if [[ $EBUILD_PHASE == postinst ]] && [[ -n $PORTAGE_UPDATE_ENV ]]; then
+               if [[ -n $PORTAGE_UPDATE_ENV ]] ; then
                        # Update environment.bz2 in case installation phases
                        # need to pass some variables to uninstallation phases.
                        __save_ebuild_env --exclude-init-phases | \
@@ -960,7 +952,7 @@ __ebuild_main() {
                fi
                export SANDBOX_ON="0"
                ;;
-       help|pretend|setup|preinst)
+       help|pretend|setup)
                #pkg_setup needs to be out of the sandbox for tmp file creation;
                #for example, awking and piping a file in /tmp requires a temp file to be created
                #in /etc.  If pkg_setup is in the sandbox, both our lilo and apache ebuilds break.
index de8e1fb1a28d4f75dd6b52f2690f5425f16fe0e1..7ae3938cee9d1bc9cacbc7dc826c0b8d3302d03b 100644 (file)
@@ -63,7 +63,7 @@ __save_ebuild_env() {
                __abort_handler __abort_prepare __abort_configure __abort_compile \
                __abort_test __abort_install __dyn_prepare __dyn_configure \
                __dyn_compile __dyn_test __dyn_install \
-               __dyn_preinst __dyn_pretend __dyn_help \
+               __dyn_pretend __dyn_help \
                debug-print debug-print-function \
                debug-print-section __helpers_die inherit EXPORT_FUNCTIONS \
                nonfatal register_success_hook \
index 89b6050022421dbfa8df14f9b33078ee45b8498f..7200327e467e20ab6e853a0f122c62ac84cd261c 100644 (file)
@@ -904,8 +904,16 @@ def doebuild(myebuild, mydo, _unused=None, settings=None, debug=0, listonly=0,
                # the sandbox -- and stop now.
                if mydo in ("config", "help", "info", "postinst",
                        "preinst", "pretend", "postrm", "prerm"):
-                       return _spawn_phase(mydo, mysettings,
-                               fd_pipes=fd_pipes, logfile=logfile, returnpid=returnpid)
+                       if mydo in ("preinst", "postinst"):
+                               env_file = os.path.join(os.path.dirname(mysettings["EBUILD"]),
+                                       "environment.bz2")
+                               if os.path.isfile(env_file):
+                                       mysettings["PORTAGE_UPDATE_ENV"] = env_file
+                       try:
+                               return _spawn_phase(mydo, mysettings,
+                                       fd_pipes=fd_pipes, logfile=logfile, returnpid=returnpid)
+                       finally:
+                               mysettings.pop("PORTAGE_UPDATE_ENV", None)
 
                mycpv = "/".join((mysettings["CATEGORY"], mysettings["PF"]))