Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 27864 - post- and pre-command feature in portage
Summary: post- and pre-command feature in portage
Status: RESOLVED DUPLICATE of bug 21131
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-03 09:26 UTC by Sven Blumenstein (RETIRED)
Modified: 2011-10-30 22:21 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
prepost-portage-2.0.49-r3.patch (prepost-portage-2.0.49-r3.patch,1.13 KB, patch)
2003-09-03 09:29 UTC, Sven Blumenstein (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Blumenstein (RETIRED) gentoo-dev 2003-09-03 09:26:05 UTC
Hi, 
I had the idea of adding the functionality of executing commands before and
after an 'emerge'. Below is a small patch against portage 2.0.49-r3 which adds this.

Just set the commands to execute in your make.conf. For example:

PRECMD="echo starting emerge process > /dev/speechd"
POSTCMD="wavplay /home/bleh/ring.wav"

As you can use any command, you could also send out an email, notify your pager,
execute a shell script or whatever you want. 

I also wanted to add a ERRCMD which gets executed on a failed emerge but I didnt
look closer at the error handling of portage yet. Seems I'd have to add my code
to ebuild.sh...

Anyway, here is the patch... it may be solved in a better way, but I dont code
in Python that much :)

----- PATCH START -----

--- /usr/lib/portage/bin/emerge 2003-09-03 17:19:41.000000000 +0200
+++ /usr/lib/portage/bin/emerge.new     2003-09-03 18:05:22.000000000 +0200
@@ -1248,6 +1248,10 @@
                                pkgindex=3
                        y=portage.portdb.findname(x[pkgindex])
                        if not "--pretend" in myopts:
+                               myprecmd=portage.settings["PRECMD"]
+                               if len(string.strip(myprecmd)) > 0:
+                                       print ">>> executing pre-emerge
command:",myprecmd
+                                       os.system(myprecmd)
                                print ">>> emerge ("+str(mergecount)+" of
"+str(len(mymergelist))+")",x[pkgindex],"to",x[1]
                                emergelog(" >>> emerge ("+str(mergecount)+" of
"+str(len(mymergelist))+") "+x[pkgindex]+" to "+x[1])
                        if x[0] in ["ebuild","blocks"]:
@@ -1640,6 +1644,12 @@
                        #print " "+yellow("*")+" Type "+green("emerge --help
config")+" to learn how to update config files."
                        print " "+yellow("*")+" Type "+green("emerge --help
config")+" to learn how to update config files."
                print
+
+       mypostcmd=portage.settings["POSTCMD"]
+       if len(string.strip(mypostcmd)) > 0:
+               print ">>> executing post-emerge command:",mypostcmd
+               os.system(mypostcmd)
+
        sys.exit(retval)
 
 # general options that should be taken into account before any action

----- PATCH END -----
Comment 1 Sven Blumenstein (RETIRED) gentoo-dev 2003-09-03 09:29:01 UTC
Created attachment 17008 [details, diff]
prepost-portage-2.0.49-r3.patch
Comment 2 Sven Blumenstein (RETIRED) gentoo-dev 2003-09-03 09:29:49 UTC
Comment on attachment 17008 [details, diff]
prepost-portage-2.0.49-r3.patch

Here is the patch. Its a bit messed up above :-)
Comment 3 Sven Blumenstein (RETIRED) gentoo-dev 2003-09-15 13:39:33 UTC
Any opinions on this idea(s)?
Comment 4 Marius Mauch (RETIRED) gentoo-dev 2003-09-19 14:21:03 UTC
I don't like the idea of adding this to portage code as you can just make a wrapper script or alias to do the same. Just my personal opinion though.
Comment 5 Christian Birchinger (RETIRED) gentoo-dev 2004-01-26 05:11:33 UTC
I think this is a good idea. I know many users who run pre and post scripts.
And they would prefer something like this over wrappers and aliases.
Comment 6 Marius Mauch (RETIRED) gentoo-dev 2004-02-04 23:31:20 UTC

*** This bug has been marked as a duplicate of 21131 ***