Bug #273622 - Add pkg_pretend support for the ebuild(1) command (emerge
authorZac Medico <zmedico@gentoo.org>
Mon, 6 Jul 2009 20:23:57 +0000 (20:23 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 6 Jul 2009 20:23:57 +0000 (20:23 -0000)
support not implemented yet). Thanks to Markus Meier <maekke@gentoo.org>
for this patch.

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

bin/ebuild.sh
pym/portage/__init__.py

index c9008e33e8b8655959fdbc531dae06635a30e3a9..634b3ce4f9471a30c282ca50724d9e95abbd0191 100755 (executable)
@@ -662,6 +662,10 @@ ebuild_phase_with_hooks() {
        done
 }
 
+dyn_pretend() {
+       ebuild_phase_with_hooks pkg_pretend
+}
+
 dyn_setup() {
        ebuild_phase_with_hooks pkg_setup
 }
@@ -1079,6 +1083,7 @@ dyn_help() {
        echo "than one option is specified, each will be executed in order."
        echo
        echo "  help        : show this help screen"
+       echo "  pretend     : execute package specific pretend actions"
        echo "  setup       : execute package specific setup actions"
        echo "  fetch       : download source archive(s) and patches"
        echo "  digest      : create a manifest file for the package"
@@ -1346,6 +1351,10 @@ _ebuild_arg_to_phase() {
        local phase_func=""
 
        case "$arg" in
+               pretend)
+                       ! hasq $eapi 0 1 2 && \
+                               phase_func=pkg_pretend
+                       ;;
                setup)
                        phase_func=pkg_setup
                        ;;
@@ -1802,11 +1811,16 @@ _source_ebuild() {
                                pkg_nofetch pkg_postinst pkg_postrm pkg_preinst pkg_prerm
                                pkg_setup src_test src_unpack"
                        ;;
-               *)
+               2)
                        valid_phases="src_compile pkg_config src_configure pkg_info
                                src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst
                                src_prepare pkg_prerm pkg_setup src_test src_unpack"
                        ;;
+               *)
+                       valid_phases="src_compile pkg_config src_configure pkg_info
+                               src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst
+                               src_prepare pkg_prerm pkg_pretend pkg_setup src_test src_unpack"
+                       ;;
        esac
 
        DEFINED_PHASES=
@@ -2003,7 +2017,7 @@ ebuild_main() {
                fi
                export SANDBOX_ON="0"
                ;;
-       help|setup|preinst)
+       help|pretend|setup|preinst)
                #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 46117563839b3ef008ac5beadde25e2668089b0a..1ad8b15b66296fffb3cd471dbd2933a89a588ab3 100644 (file)
@@ -4920,6 +4920,9 @@ def spawnebuild(mydo, actionmap, mysettings, debug, alwaysdep=0,
        if mydo == "prepare" and eapi in ("0", "1"):
                return os.EX_OK
 
+       if mydo == "pretend" and eapi in ("0", "1", "2"):
+               return os.EX_OK
+
        kwargs = actionmap[mydo]["args"]
        mysettings["EBUILD_PHASE"] = mydo
        _doebuild_exit_status_unlink(
@@ -5882,7 +5885,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
 
        clean_phases = ("clean", "cleanrm")
        validcommands = ["help","clean","prerm","postrm","cleanrm","preinst","postinst",
-                       "config", "info", "setup", "depend",
+                       "config", "info", "setup", "depend", "pretend",
                        "fetch", "fetchall", "digest",
                        "unpack", "prepare", "configure", "compile", "test",
                        "install", "rpm", "qmerge", "merge",
@@ -6451,6 +6454,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
 
                # args are for the to spawn function
                actionmap = {
+"pretend":  {"cmd":ebuild_sh, "args":{"droppriv":0,        "free":1,         "sesandbox":0,         "fakeroot":0}},
 "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}},