summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorMarius Mauch <genone@gentoo.org>2005-11-13 14:49:21 +0000
committerMarius Mauch <genone@gentoo.org>2005-11-13 14:49:21 +0000
commit6c3c1b0cf62e59eaad40d425fee97f33ff3b639a (patch)
treec2677cb8de672fe092662dbd1863cdf1b759dbb0 /pym
parentacdd7b0551cdbe07d04f4412c42855900c4003d4 (diff)
downloadportage-6c3c1b0cf62e59eaad40d425fee97f33ff3b639a.tar.gz
portage-6c3c1b0cf62e59eaad40d425fee97f33ff3b639a.tar.bz2
portage-6c3c1b0cf62e59eaad40d425fee97f33ff3b639a.zip
Add slightly modified elog_base patch containing the basic framework for ebuild logging.
svn path=/main/trunk/; revision=2306
Diffstat (limited to 'pym')
-rw-r--r--pym/portage.py61
-rw-r--r--pym/portage_const.py1
2 files changed, 62 insertions, 0 deletions
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