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:28:02 +0000 (07:28 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 8 Jul 2007 07:28:02 +0000 (07:28 -0000)
svn path=/main/branches/2.1.2/; revision=7202

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

index 117268230b3412131c3a52b62ea5ad62ecaec4ed..cc09080bd9d424192c761fbef7d948768d6f7bb7 100755 (executable)
@@ -1616,7 +1616,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 4145b6b2a948bf9e73f4d16a973448a97f3f3f81..fd600aa86b93fa631f8e9587571937ccb939d775 100755 (executable)
@@ -5016,7 +5016,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 output import EOutput
+               out = EOutput()
                for pkg in mypkgs:
                        # Get all package specific variables
                        auxvalues = vardb.aux_get(pkg, auxkeys)
@@ -5046,16 +5051,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"]:
@@ -5064,6 +5059,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 ec36ede3454b2127a5f95cff17090d64fc67362c..cefbd0c8bcd81dfc0d8bd335eddb6031bfd55523 100644 (file)
@@ -3506,7 +3506,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"]
 
@@ -3731,7 +3731,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)