From 6c3c1b0cf62e59eaad40d425fee97f33ff3b639a Mon Sep 17 00:00:00 2001 From: Marius Mauch Date: Sun, 13 Nov 2005 14:49:21 +0000 Subject: Add slightly modified elog_base patch containing the basic framework for ebuild logging. svn path=/main/trunk/; revision=2306 --- pym/portage.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ pym/portage_const.py | 1 + 2 files changed, 62 insertions(+) (limited to 'pym') diff --git a/pym/portage.py b/pym/portage.py index 7e305ea46..60ab80e4b 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -456,6 +456,57 @@ class digraph: mygraph.okeys=self.okeys[:] return mygraph +def elog_process(cpv, mysettings): + mylogfiles = listdir(mysettings["T"]+"/logging/") + # shortcut for packages without any messages + if len(mylogfiles) == 0: + return + # exploit listdir() file order so we process log entries in cronological order + mylogfiles.reverse() + mylogentries = {} + for f in mylogfiles: + msgfunction, msgtype = f.split(".") + if not msgtype.upper() in mysettings["PORTAGE_ELOG_CLASSES"].split() \ + and not msgtype.lower() in mysettings["PORTAGE_ELOG_CLASSES"].split(): + continue + if msgfunction not in portage_const.EBUILD_PHASES: + print "!!! can't process invalid log file: %s" % f + continue + if not msgfunction in mylogentries: + mylogentries[msgfunction] = [] + msgcontent = open(mysettings["T"]+"/logging/"+f, "r").readlines() + mylogentries[msgfunction].append((msgtype, msgcontent)) + + # in case the filters matched all messages + if len(mylogentries) == 0: + return + + # generate a single string with all log messages + fulllog = "" + for phase in portage_const.EBUILD_PHASES: + if not phase in mylogentries: + continue + for msgtype,msgcontent in mylogentries[phase]: + fulllog += "%s: %s\n" % (msgtype, phase) + for line in msgcontent: + fulllog += line + fulllog += "\n" + + # pass the processing to the individual modules + logsystems = mysettings["PORTAGE_ELOG_SYSTEM"].split() + for s in logsystems: + try: + # FIXME: ugly ad.hoc import code + # TODO: implement a common portage module loader + logmodule = __import__("elog_modules.mod_"+s) + m = getattr(logmodule, "mod_"+s) + m.process(mysettings, cpv, mylogentries, fulllog) + except (ImportError, AttributeError), e: + print "!!! Error while importing logging modules while loading \"mod_%s\":" % s + print e + except portage_exception.PortageException, e: + print e + # valid end of version components; integers specify offset from release version # pre=prerelease, p=patchlevel (should always be followed by an int), rc=release candidate # all but _p (where it is required) can be followed by an optional trailing integer @@ -2510,6 +2561,12 @@ def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,clea os.chown(mysettings["T"],portage_uid,portage_gid) os.chmod(mysettings["T"],02770) + logdir = mysettings["T"]+"/logging" + if not os.path.exists(logdir): + os.makedirs(logdir) + os.chown(logdir, portage_uid, portage_gid) + os.chmod(logdir, 0770) + try: # XXX: negative RESTRICT if not (("nouserpriv" in string.split(mysettings["PORTAGE_RESTRICT"])) or \ ("userpriv" in string.split(mysettings["PORTAGE_RESTRICT"]))): @@ -6544,6 +6601,10 @@ class dblink: if dircache.has_key(self.dbcatdir): del dircache[self.dbcatdir] print ">>>",self.mycpv,"merged." + + # Process ebuild logfiles + elog_process(self.mycpv, self.settings) + return 0 def mergeme(self,srcroot,destroot,outfile,secondhand,stufftomerge,cfgfiledict,thismtime): diff --git a/pym/portage_const.py b/pym/portage_const.py index 296784aeb..e8341ec5f 100644 --- a/pym/portage_const.py +++ b/pym/portage_const.py @@ -41,6 +41,7 @@ CONFIG_MEMORY_FILE = PRIVATE_PATH + "/config" INCREMENTALS=["USE","USE_EXPAND","FEATURES","ACCEPT_KEYWORDS","ACCEPT_LICENSE","CONFIG_PROTECT_MASK","CONFIG_PROTECT","PRELINK_PATH","PRELINK_PATH_MASK"] STICKIES=["KEYWORDS_ACCEPT","USE","CFLAGS","CXXFLAGS","MAKEOPTS","EXTRA_ECONF","EXTRA_EINSTALL","EXTRA_EMAKE"] +EBUILD_PHASES = ["setup","unpack","compile","test","install","preinst","postinst","prerm","postrm"] EAPI = 0 -- cgit v1.2.3-1-g7c22