Add a new src_prepare phase function which is called in-between src_unpack
authorZac Medico <zmedico@gentoo.org>
Sat, 23 Aug 2008 02:02:06 +0000 (02:02 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 23 Aug 2008 02:02:06 +0000 (02:02 -0000)
and src_configure (and bump EAPI to 2_pre3). Thanks to Ciaran McCreesh for
the suggestion.

svn path=/main/trunk/; revision=11454

bin/ebuild.sh
bin/isolated-functions.sh
doc/package/ebuild/eapi/2.docbook
pym/_emerge/__init__.py
pym/portage/__init__.py
pym/portage/const.py

index 2a434ef7583b36446e63b9ad393fe1c3c683a402..e45747d02a1583054319e1f709ff584ee512c74d 100755 (executable)
@@ -726,7 +726,7 @@ dyn_clean() {
        fi
 
        if ! hasq keepwork $FEATURES; then
-               rm -f "$PORTAGE_BUILDDIR"/.{exit_status,logid,unpacked} \
+               rm -f "$PORTAGE_BUILDDIR"/.{exit_status,logid,unpacked,prepared} \
                        "$PORTAGE_BUILDDIR"/.{configured,compiled,tested,packaged}
 
                rm -rf "${PORTAGE_BUILDDIR}/build-info"
@@ -832,6 +832,12 @@ abort_handler() {
        trap SIGINT SIGQUIT
 }
 
+abort_prepare() {
+       abort_handler src_prepare $1
+       rm -f "$PORTAGE_BUILDDIR/.prepared"
+       exit 1
+}
+
 abort_configure() {
        abort_handler src_configure $1
        rm -f "$PORTAGE_BUILDDIR/.configured"
@@ -856,6 +862,32 @@ abort_install() {
        exit 1
 }
 
+dyn_prepare() {
+
+       if [[ $PORTAGE_BUILDDIR/.prepared -nt $WORKDIR ]] ; then
+               vecho ">>> It appears that '$PF' is already prepared; skipping."
+               vecho ">>> Remove '$PORTAGE_BUILDDIR/.prepared' to force prepare."
+               return 0
+       fi
+
+       local srcdir
+       if [[ -d $S ]] ; then
+               srcdir=$S
+       else
+               srcdir=$WORKDIR
+       fi
+       cd "$srcdir"
+
+       trap abort_prepare SIGINT SIGQUIT
+
+       ebuild_phase pre_src_prepare
+       ebuild_phase src_prepare
+       touch "$PORTAGE_BUILDDIR"/.prepared
+       ebuild_phase post_src_prepare
+
+       trap SIGINT SIGQUIT
+}
+
 dyn_configure() {
 
        if [[ $PORTAGE_BUILDDIR/.configured -nt $WORKDIR ]] ; then
@@ -1038,7 +1070,8 @@ dyn_help() {
        echo "  fetch       : download source archive(s) and patches"
        echo "  digest      : create a manifest file for the package"
        echo "  manifest    : create a manifest file for the package"
-       echo "  unpack      : unpack/patch sources (auto-fetch if needed)"
+       echo "  unpack      : unpack sources (auto-dependencies if needed)"
+       echo "  prepare     : prepare sources (auto-dependencies if needed)"
        echo "  configure   : configure sources (auto-fetch/unpack if needed)"
        echo "  compile     : compile sources (auto-fetch/unpack/configure if needed)"
        echo "  test        : test package (auto-fetch/unpack/configure/compile if needed)"
@@ -1387,7 +1420,7 @@ _ebuild_phase_funcs() {
        [ $# -ne 2 ] && die "expected exactly 2 args, got $#: $*"
        local eapi=$1
        local phase_func=$2
-       local default_phases="pkg_nofetch src_unpack src_configure
+       local default_phases="pkg_nofetch src_unpack src_prepare src_configure
                src_compile src_install src_test"
        local x y default_func=""
 
@@ -1440,6 +1473,7 @@ _ebuild_phase_funcs() {
 
                                eapi0_pkg_nofetch   () { _eapi0_pkg_nofetch   "$@" ; }
                                eapi0_src_unpack    () { _eapi0_src_unpack    "$@" ; }
+                               eapi0_src_prepare   () { die "$FUNCNAME is not supported" ; }
                                eapi0_src_configure () { die "$FUNCNAME is not supported" ; }
                                eapi0_src_compile   () { _eapi0_src_compile   "$@" ; }
                                eapi0_src_test      () { _eapi0_src_test      "$@" ; }
@@ -1447,6 +1481,7 @@ _ebuild_phase_funcs() {
 
                                eapi1_pkg_nofetch   () { _eapi0_pkg_nofetch   "$@" ; }
                                eapi1_src_unpack    () { _eapi0_src_unpack    "$@" ; }
+                               eapi1_src_prepare   () { die "$FUNCNAME is not supported" ; }
                                eapi1_src_configure () { die "$FUNCNAME is not supported" ; }
                                eapi1_src_compile   () { _eapi1_src_compile   "$@" ; }
                                eapi1_src_test      () { _eapi0_src_test      "$@" ; }
@@ -1454,6 +1489,7 @@ _ebuild_phase_funcs() {
 
                                eapi2_pkg_nofetch   () { _eapi0_pkg_nofetch   "$@" ; }
                                eapi2_src_unpack    () { _eapi0_src_unpack    "$@" ; }
+                               eapi2_src_prepare   () { true ; }
                                eapi2_src_configure () { _eapi2_src_configure "$@" ; }
                                eapi2_src_compile   () { _eapi2_src_compile   "$@" ; }
                                eapi2_src_test      () { _eapi0_src_test      "$@" ; }
@@ -1945,7 +1981,7 @@ ebuild_main() {
                                | bzip2 -c -f9 > "$PORTAGE_UPDATE_ENV"
                fi
                ;;
-       unpack|configure|compile|test|clean|install)
+       unpack|prepare|configure|compile|test|clean|install)
                if [[ ${SANDBOX_DISABLED:-0} = 0 ]] ; then
                        export SANDBOX_ON="1"
                else
index e52c9fd7c7797590fc70aed4f16949d5fb579035..0345bbeadb263efaaa74ea9089c044771c6cde29 100755 (executable)
@@ -517,7 +517,7 @@ save_ebuild_env() {
 
                if hasq --exclude-init-phases $* ; then
                        unset S _E_DOCDESTTREE_ _E_EXEDESTTREE_
-                       unset -f pkg_nofetch src_unpack src_configure \
+                       unset -f pkg_nofetch src_unpack src_prepare src_configure \
                        src_compile src_test src_install
                        if [[ -n $PYTHONPATH ]] ; then
                                export PYTHONPATH=${PYTHONPATH/${PORTAGE_PYM_PATH}:}
@@ -543,7 +543,7 @@ save_ebuild_env() {
                # There's no need to bloat environment.bz2 with internally defined
                # functions and variables, so filter them out if possible.
 
-               for x in pkg_setup pkg_nofetch src_unpack src_configure \
+               for x in pkg_setup pkg_nofetch src_unpack src_prepare src_configure \
                        src_compile src_test src_install pkg_preinst pkg_postinst \
                        pkg_prerm pkg_postrm ; do
                        unset -f {,_}default_$x {,_}eapi{0,1,2}_$x
@@ -559,8 +559,8 @@ save_ebuild_env() {
                        keepdir unpack strip_duplicate_slashes econf einstall \
                        dyn_setup dyn_unpack dyn_clean into insinto exeinto docinto \
                        insopts diropts exeopts libopts \
-                       abort_handler abort_configure abort_compile \
-                       abort_test abort_install dyn_configure \
+                       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_help debug-print debug-print-function \
                        debug-print-section inherit EXPORT_FUNCTIONS newdepend newrdepend \
index 1a4073e5eb1c2166bf6b08591e47347291b71eba..20f7434df6cd3f85c46ae583dd5603ca702488de 100644 (file)
                        <para>
                        The configure portion of the src_compile function has been
                        split into a separate function which is named src_configure. The
-                       src_configure function is called in between the src_unpack and
+                       src_configure function is called in-between the src_unpack and
                        src_compile functions.
                        </para>
                        <programlisting>
@@ -274,3 +274,16 @@ src_compile() {
                </section>
        </section>
 </section>
+<section id='package-ebuild-eapi-2_pre3'>
+       <title>EAPI 2_pre3</title>
+       <section id='package-ebuild-eapi-2-phases'>
+               <title>Phases</title>
+               <section id='package-ebuild-eapi-2-phases-src-prepare'>
+                       <title>New src_prepare Phase Function</title>
+                       <para>
+                       A new src_prepare function is called in-between the src_unpack and
+                       src_configure functions, with cwd initially set to $S.
+                       </para>
+               </section>
+       </section>
+</section>
index c6d8c71fdc53d384a9f6886b708c730595aeb249..333043d4d6070e83fa8b03ef1bb0c1489a609301 100644 (file)
@@ -2588,7 +2588,7 @@ class EbuildExecuter(CompositeTask):
 
        __slots__ = ("pkg", "scheduler", "settings") + ("_tree",)
 
-       _phases = ("configure", "compile", "test", "install")
+       _phases = ("prepare", "configure", "compile", "test", "install")
 
        _live_eclasses = frozenset([
                "cvs",
@@ -2659,8 +2659,12 @@ class EbuildExecuter(CompositeTask):
 
                pkg = self.pkg
                phases = self._phases
-               if pkg.metadata["EAPI"] in ("0", "1", "2_pre1"):
-                       # skip src_configure
+               eapi = pkg.metadata["EAPI"]
+               if eapi in ("0", "1", "2_pre1"):
+                       # skip src_prepare and src_configure
+                       phases = phases[2:]
+               elif eapi in ("2_pre2",):
+                       # skip src_prepare
                        phases = phases[1:]
 
                for phase in phases:
index bcf710842df17d61cb256060f1c192f70aaf03c5..a97f1eec7578467657db427109737952b72c63a7 100644 (file)
@@ -4324,7 +4324,12 @@ def spawnebuild(mydo, actionmap, mysettings, debug, alwaysdep=0,
                        if retval:
                                return retval
 
-       if mydo == "configure" and mysettings["EAPI"] in ("0", "1", "2_pre1"):
+       eapi = mysettings["EAPI"]
+
+       if mydo == "configure" and eapi in ("0", "1", "2_pre1"):
+               return os.EX_OK
+
+       if mydo == "prepare" and eapi in ("0", "1", "2_pre1", "2_pre2"):
                return os.EX_OK
 
        kwargs = actionmap[mydo]["args"]
@@ -4569,7 +4574,7 @@ def _spawn_misc_sh(mysettings, commands, **kwargs):
 def eapi_is_supported(eapi):
        eapi = str(eapi).strip()
 
-       if eapi in ("2_pre2", "2_pre1"):
+       if eapi in ("2_pre3", "2_pre2", "2_pre1"):
                return True
 
        try:
@@ -5105,7 +5110,8 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
        actionmap_deps={
        "setup":  [],
        "unpack": ["setup"],
-       "configure": ["unpack"],
+       "prepare": ["unpack"],
+       "configure": ["prepare"],
        "compile":["configure"],
        "test":   ["compile"],
        "install":["test"],
@@ -5127,7 +5133,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
        validcommands = ["help","clean","prerm","postrm","cleanrm","preinst","postinst",
                        "config", "info", "setup", "depend",
                        "fetch", "fetchall", "digest",
-                       "unpack", "configure", "compile", "test",
+                       "unpack", "prepare", "configure", "compile", "test",
                        "install", "rpm", "qmerge", "merge",
                        "package","unmerge", "manifest"]
 
@@ -5713,6 +5719,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                actionmap = {
 "setup":    {"cmd":ebuild_sh, "args":{"droppriv":0,        "free":1,         "sesandbox":0,         "fakeroot":0}},
 "unpack":   {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":0,         "sesandbox":sesandbox, "fakeroot":0}},
+"prepare":  {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":0,         "sesandbox":sesandbox, "fakeroot":0}},
 "configure":{"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":nosandbox, "sesandbox":sesandbox, "fakeroot":0}},
 "compile":  {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":nosandbox, "sesandbox":sesandbox, "fakeroot":0}},
 "test":     {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":nosandbox, "sesandbox":sesandbox, "fakeroot":0}},
index 3cb1ef6d45921ebb13c60f98f08fe12cd2ad8e3e..1b8b3036e7b763fd597849fe5f5d3a8bdede3b73 100644 (file)
@@ -55,7 +55,7 @@ INCREMENTALS = ["USE", "USE_EXPAND", "USE_EXPAND_HIDDEN", "FEATURES",
        "ACCEPT_KEYWORDS", "ACCEPT_LICENSE",
        "CONFIG_PROTECT_MASK", "CONFIG_PROTECT",
        "PRELINK_PATH", "PRELINK_PATH_MASK", "PROFILE_ONLY_VARIABLES"]
-EBUILD_PHASES           = ["setup", "unpack", "configure",
+EBUILD_PHASES           = ["setup", "unpack", "prepare", "configure",
                           "compile", "test", "install",
                           "package", "preinst", "postinst","prerm", "postrm",
                           "nofetch", "config", "info", "other"]