Split dyn_package from ebuild.sh to misc-functions.sh and add MISC_SH_BINARY support...
authorZac Medico <zmedico@gentoo.org>
Thu, 9 Mar 2006 04:07:49 +0000 (04:07 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 9 Mar 2006 04:07:49 +0000 (04:07 -0000)
svn path=/main/trunk/; revision=2831

bin/ebuild.sh
bin/misc-functions.sh [new file with mode: 0644]
pym/portage.py
pym/portage_const.py

index d92d5efc3d49e1830edfa4281409d16dc30fc3db..87d72f4f53db90cd7175ff08af8fa477f38035f3 100755 (executable)
@@ -891,13 +891,6 @@ abort_unpack() {
        exit 1
 }
 
-abort_package() {
-       abort_handler "dyn_package" $1
-       rm -f "${PORTAGE_BUILDDIR}/.packaged"
-       rm -f "${PKGDIR}"/All/${PF}.t*
-       exit 1
-}
-
 abort_test() {
        abort_handler "dyn_test" $1
        rm -f "${PORTAGE_BUILDDIR}/.tested"
@@ -998,27 +991,6 @@ dyn_compile() {
        trap SIGINT SIGQUIT
 }
 
-dyn_package() {
-       trap "abort_package" SIGINT SIGQUIT
-       cd "${PORTAGE_BUILDDIR}/image"
-       install_mask "${PORTAGE_BUILDDIR}/image" ${PKG_INSTALL_MASK}
-       tar cpvf - ./ | bzip2 -f > ../bin.tar.bz2 || die "Failed to create tarball"
-       cd ..
-       xpak build-info inf.xpak
-       tbz2tool join bin.tar.bz2 inf.xpak "${PF}.tbz2"
-       mv "${PF}.tbz2" "${PKGDIR}/All" || die "Failed to move tbz2 to ${PKGDIR}/All"
-       rm -f inf.xpak bin.tar.bz2
-       if [ ! -d "${PKGDIR}/${CATEGORY}" ]; then
-               install -d "${PKGDIR}/${CATEGORY}"
-       fi
-       ln -sf "../All/${PF}.tbz2" "${PKGDIR}/${CATEGORY}/${PF}.tbz2" || die "Failed to create symlink in ${PKGDIR}/${CATEGORY}"
-       echo ">>> Done."
-       cd "${PORTAGE_BUILDDIR}"
-       touch .packaged || die "Failed to 'touch .packaged' in ${PORTAGE_BUILDDIR}"
-       trap SIGINT SIGQUIT
-}
-
-
 dyn_test() {
        [ "$(type -t pre_src_test)" == "function" ] && pre_src_test
        if [ "${PORTAGE_BUILDDIR}/.tested" -nt "${WORKDIR}" ]; then
@@ -2004,7 +1976,7 @@ for myarg in $*; do
                        set +x
                fi
                ;;
-       package|rpm)
+       rpm)
                export SANDBOX_ON="0"
                if [ "$PORTAGE_DEBUG" != "1" ]; then
                        dyn_${myarg}
@@ -2069,7 +2041,8 @@ for myarg in $*; do
        #fi
 done
 
-if [ "$myarg" != "clean" ]; then
+# Save the env only for relevant phases.
+if [ -n "$myarg" ] && [ "$myarg" != "clean" ]; then
        # Save current environment and touch a success file. (echo for success)
        umask 002
        set | egrep -v "^SANDBOX_" > "${T}/environment" 2>/dev/null
@@ -2077,4 +2050,5 @@ if [ "$myarg" != "clean" ]; then
        chmod g+w "${T}/environment" &>/dev/null
 fi
 
-exit 0
+# Do not exit when ebuild.sh is sourced by other scripts.
+true
diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
new file mode 100644 (file)
index 0000000..0eb184b
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header$
+#
+# Miscellaneous shell functions that make use of the ebuild env but don't need
+# to be included directly in ebuild.sh.
+#
+# We're sourcing ebuild.sh here so that we inherit all of it's goodness,
+# including bashrc trickery.  This approach allows us to do our miscellaneous
+# shell work withing the same env that ebuild.sh has, but without polluting
+# ebuild.sh itself with unneeded logic and shell code.
+#
+# XXX hack: clear the args so ebuild.sh doesn't see them
+MISC_FUNCTIONS_ARGS="$@"
+shift $#
+source /usr/lib/portage/bin/ebuild.sh
+
+dyn_package() {
+       cd "${PORTAGE_BUILDDIR}/image"
+       install_mask "${PORTAGE_BUILDDIR}/image" ${PKG_INSTALL_MASK}
+       tar cpvf - ./ | bzip2 -f > ../bin.tar.bz2 || die "Failed to create tarball"
+       cd ..
+       xpak build-info inf.xpak
+       tbz2tool join bin.tar.bz2 inf.xpak "${PF}.tbz2"
+       addwrite "${PKGDIR}"
+       mv "${PF}.tbz2" "${PKGDIR}/All" || die "Failed to move tbz2 to ${PKGDIR}/All"
+       rm -f inf.xpak bin.tar.bz2
+       if [ ! -d "${PKGDIR}/${CATEGORY}" ]; then
+               install -d "${PKGDIR}/${CATEGORY}"
+       fi
+       ln -sf "../All/${PF}.tbz2" "${PKGDIR}/${CATEGORY}/${PF}.tbz2" || die "Failed to create symlink in ${PKGDIR}/${CATEGORY}"
+       echo ">>> Done."
+       cd "${PORTAGE_BUILDDIR}"
+       touch .packaged || die "Failed to 'touch .packaged' in ${PORTAGE_BUILDDIR}"
+}
+
+if [ -n "${MISC_FUNCTIONS_ARGS}" ]; then
+       [ "$PORTAGE_DEBUG" == "1" ] && set -x
+       for x in ${MISC_FUNCTIONS_ARGS}; do
+               ${x}
+       done
+fi
+
+true
index e3d5ad742ed5d8ee2902d6ed72a3d64474e85d92..6468b0f87f2e47446f370213ef6c56fdf24cee3e 100644 (file)
@@ -86,7 +86,7 @@ try:
          MOVE_BINARY, PRELINK_BINARY, WORLD_FILE, MAKE_CONF_FILE, MAKE_DEFAULTS_FILE, \
          DEPRECATED_PROFILE_FILE, USER_VIRTUALS_FILE, EBUILD_SH_ENV_FILE, \
          INVALID_ENV_FILE, CUSTOM_MIRRORS_FILE, CONFIG_MEMORY_FILE,\
-         INCREMENTALS, STICKIES, EAPI
+         INCREMENTALS, STICKIES, EAPI, MISC_SH_BINARY
 
        from portage_data import ostype, lchown, userland, secpass, uid, wheelgid, \
                                 portage_uid, portage_gid
@@ -2367,18 +2367,21 @@ def spawnebuild(mydo,actionmap,mysettings,debug,alwaysdep=0,logfile=None):
                        retval=spawnebuild(actionmap[mydo]["dep"],actionmap,mysettings,debug,alwaysdep=alwaysdep,logfile=logfile)
                        if retval:
                                return retval
-       # spawn ebuild.sh
-       mycommand = EBUILD_SH_BINARY + " "
+       # spawn ebuild.sh or misc-functions.sh as appropriate
+       if mydo in ["package"]:
+               mycommand = MISC_SH_BINARY + " dyn_" + mydo
+       else:
+               mycommand = EBUILD_SH_BINARY + " " + mydo
        if selinux_enabled and ("sesandbox" in features) and (mydo in ["unpack","compile","test","install"]):
                con=selinux.getcontext()
                con=string.replace(con,mysettings["PORTAGE_T"],mysettings["PORTAGE_SANDBOX_T"])
                selinux.setexec(con)
-               retval=spawn(mycommand + mydo,mysettings,debug=debug,
+               retval=spawn(mycommand, mysettings, debug=debug,
                                free=actionmap[mydo]["args"][0],
                                droppriv=actionmap[mydo]["args"][1],logfile=logfile)
                selinux.setexec(None)
        else:
-               retval=spawn(mycommand + mydo,mysettings, debug=debug,
+               retval=spawn(mycommandmysettings, debug=debug,
                                free=actionmap[mydo]["args"][0],
                                droppriv=actionmap[mydo]["args"][1],logfile=logfile)
        return retval
index 99082a77c8741f1df97f0488e741577ad86b32cb..04b61c4b739432b951f71bcfa024baada4599a9e 100644 (file)
@@ -24,6 +24,7 @@ PROFILE_PATH            = "/etc/make.profile"
 LOCALE_DATA_PATH        = PORTAGE_BASE_PATH+"/locale"
 
 EBUILD_SH_BINARY        = PORTAGE_BIN_PATH+"/ebuild.sh"
+MISC_SH_BINARY          = PORTAGE_BIN_PATH + "/misc-functions.sh"
 SANDBOX_BINARY          = "/usr/bin/sandbox"
 BASH_BINARY             = "/bin/bash"
 MOVE_BINARY             = "/bin/mv"