For bug #184566, enable the emerge --info action to run an option pkg_info() function...
authorZac Medico <zmedico@gentoo.org>
Sun, 8 Jul 2007 07:24:12 +0000 (07:24 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 8 Jul 2007 07:24:12 +0000 (07:24 -0000)
svn path=/main/trunk/; revision=7201

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

index ffe904e9cfe10d7e6154fd112d946ee4fdadcf6e..b7636b1e3d44ed538e2604a3f05b8d92ac8e3aee 100755 (executable)
@@ -1538,7 +1538,12 @@ for myarg in ${EBUILD_SH_ARGS} ; do
                qa_call pkg_nofetch
                exit 1
                ;;
-       prerm|postrm|postinst|config)
+       prerm|postrm|postinst|config|info)
+               if [ "${myarg}" == "info" ] && \
+                       [ "$(type -t pkg_${myarg})" != "function" ]; then
+                       ewarn  "pkg_${myarg}() is not defined: '${EBUILD##*/}'"
+                       continue
+               fi
                export SANDBOX_ON="0"
                if [ "$PORTAGE_DEBUG" != "1" ]; then
                        [ "$(type -t pre_pkg_${myarg})" == "function" ] && qa_call pre_pkg_${myarg}
index cbecf9b22456ebe8f4c2ba2c0e7367a68934faad..477164e8876ba844ef2d2a556f93fc24754dfc95 100644 (file)
@@ -5166,7 +5166,12 @@ def action_info(settings, trees, myopts, myfiles):
 
                # Loop through each package
                # Only print settings if they differ from global settings
-               header_printed = False
+               header_title = "Package Settings"
+               print header_width * "="
+               print header_title.rjust(int(header_width/2 + len(header_title)/2))
+               print header_width * "="
+               from portage.output import EOutput
+               out = EOutput()
                for pkg in mypkgs:
                        # Get all package specific variables
                        auxvalues = vardb.aux_get(pkg, auxkeys)
@@ -5196,16 +5201,6 @@ def action_info(settings, trees, myopts, myfiles):
                        # If a difference was found, print the info for
                        # this package.
                        if diff_values:
-
-                               # If we have not yet printed the header, 
-                               # print it now
-                               if not header_printed:
-                                       header_title = "Package Settings"
-                                       print header_width * "="
-                                       print header_title.rjust(int(header_width/2 + len(header_title)/2))
-                                       print header_width * "="
-                                       header_printed = True
-
                                # Print package info
                                print "%s was built with the following:" % pkg
                                for myvar in mydesiredvars + ["USE"]:
@@ -5214,6 +5209,15 @@ def action_info(settings, trees, myopts, myfiles):
                                                mylist.sort()
                                                print "%s=\"%s\"" % (myvar, " ".join(mylist))
                                print
+                       print ">>> Attempting to run pkg_info() for '%s'" % pkg
+                       ebuildpath = vardb.findname(pkg)
+                       if not ebuildpath or not os.path.exists(ebuildpath):
+                               out.ewarn("No ebuild found for '%s'" % pkg)
+                               continue
+                       portage.doebuild(ebuildpath, "info", pkgsettings["ROOT"],
+                               pkgsettings, debug=(settings.get("PORTAGE_DEBUG", "") == 1),
+                               mydbapi=trees[settings["ROOT"]]["vartree"].dbapi,
+                               tree="vartree")
 
 def action_search(settings, portdb, vartree, myopts, myfiles, spinner):
        if not myfiles:
index b15f4ced170919cd0f9ca83fcb920cc45272cc1a..8de8457b61ffa64dfcbb3c832036c7beed5c39a7 100644 (file)
@@ -3614,7 +3614,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
        features = mysettings.features
 
        validcommands = ["help","clean","prerm","postrm","cleanrm","preinst","postinst",
-                       "config","setup","depend","fetch","digest",
+                       "config","info","setup","depend","fetch","digest",
                        "unpack","compile","test","install","rpm","qmerge","merge",
                        "package","unmerge", "manifest"]
 
@@ -3839,7 +3839,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                                        writemsg("!!! post postinst failed; exiting.\n",
                                                noiselevel=-1)
                        return phase_retval
-               elif mydo in ["prerm","postrm","config"]:
+               elif mydo in ("prerm", "postrm", "config", "info"):
                        mysettings.load_infodir(mysettings["O"])
                        return spawn(EBUILD_SH_BINARY + " " + mydo,
                                mysettings, debug=debug, free=1, logfile=logfile)