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 -----
Created attachment 17008 [details, diff] prepost-portage-2.0.49-r3.patch
Comment on attachment 17008 [details, diff] prepost-portage-2.0.49-r3.patch Here is the patch. Its a bit messed up above :-)
Any opinions on this idea(s)?
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.
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.
*** This bug has been marked as a duplicate of 21131 ***