summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Mauch <genone@gentoo.org>2006-03-26 06:35:24 +0000
committerMarius Mauch <genone@gentoo.org>2006-03-26 06:35:24 +0000
commit2e8c935fb78beff2f4ebbb16876866be765194ac (patch)
tree2bdd68cdd59264632ad9d1fc62b82bcac5029144
parenteb81ae800e93a6103ab233d363afa417a8f0c2a4 (diff)
downloadportage-2e8c935fb78beff2f4ebbb16876866be765194ac.tar.gz
portage-2e8c935fb78beff2f4ebbb16876866be765194ac.tar.bz2
portage-2e8c935fb78beff2f4ebbb16876866be765194ac.zip
move some elog defaults into make.globals, add new vars for mail from and subject (bug #116637), change default location for mod_save logfiles to PORT_LOGDIR/elog (bug #124165)
svn path=/main/trunk/; revision=3014
-rw-r--r--cnf/make.conf14
-rw-r--r--cnf/make.globals7
-rw-r--r--pym/elog_modules/mod_mail.py46
-rw-r--r--pym/elog_modules/mod_save.py5
4 files changed, 50 insertions, 22 deletions
diff --git a/cnf/make.conf b/cnf/make.conf
index d993464ca..472d49bb3 100644
--- a/cnf/make.conf
+++ b/cnf/make.conf
@@ -305,7 +305,8 @@ PORTAGE_ELOG_CLASSES="warn error log"
# PORTAGE_ELOG_SYSTEM: selects the module(s) to process the log messages. Modules
# included in portage are (empty means logging is disabled):
-# save (saves one log per package in $PORTAGE_TMPDIR/elogs)
+# save (saves one log per package in $PORT_LOGDIR/elog,
+# /var/log/portage/elog if $PORT_LOGDIR is unset)
# custom (passes all messages to $PORTAGE_LOG_COMMAND)
# syslog (sends all messages to syslog)
# mail (send all messages to the mailserver defined
@@ -337,3 +338,14 @@ PORTAGE_ELOG_CLASSES="warn error log"
#PORTAGE_ELOG_MAILURI="root@localhost localhost" (this is also the default setting)
#PORTAGE_ELOG_MAILURI="user@some.domain mail.some.domain" (sends mails to user@some.domain using the mailserver mail.some.domain)
#PORTAGE_ELOG_MAILURI="user@some.domain user:secret@mail.some.domain:100465" (this is left uncommented as a reader excercise ;)
+
+# PORTAGE_ELOG_MAILFROM: you can set the from-address of logmails with this variable,
+# if unset mails are sent by "portage" (this default may fail
+# in some environments).
+#PORTAGE_ELOG_MAILFROM="portage@some.domain"
+
+# PORTAGE_ELOG_MAILSUBJECT: template string to be used as subject for logmails. The following
+# variables are exanded:
+# ${PACKAGE} - see description of PORTAGE_ELOG_COMMAND
+# ${HOST} - FQDN of the host portage is running on
+#PORTAGE_ELOG_MAILSUBJECT="package ${PACKAGE} merged on ${HOST} with notice"
diff --git a/cnf/make.globals b/cnf/make.globals
index 36f1d3042..dfc5d48a6 100644
--- a/cnf/make.globals
+++ b/cnf/make.globals
@@ -69,6 +69,13 @@ PORTAGE_INST_GID="0"
# Mode bits for ${WORKDIR} (see ebuild.5).
PORTAGE_WORKDIR_MODE="0700"
+# Some defaults for elog
+PORTAGE_ELOG_CLASSES="log warn error"
+
+PORTAGE_ELOG_MAILURI="root"
+PORTAGE_ELOG_MAILSUBJECT="[portage] ebuild log for \${PACKAGE} on \${HOST}"
+PORTAGE_ELOG_MAILFROM="portage"
+
# *****************************
# ** DO NOT EDIT THIS FILE **
# ***************************************************
diff --git a/pym/elog_modules/mod_mail.py b/pym/elog_modules/mod_mail.py
index 59fd56a8e..68771ba51 100644
--- a/pym/elog_modules/mod_mail.py
+++ b/pym/elog_modules/mod_mail.py
@@ -14,29 +14,35 @@ def process(mysettings, cpv, logentries, fulltext):
# passwd: password for smtp auth (defaults to none)
# mailserver: smtp server that should be used to deliver the mail (defaults to localhost)
# port: port to use on the given smtp server (defaults to 25, values > 100000 indicate that starttls should be used on (port-100000))
- if "PORTAGE_ELOG_MAILURI" in mysettings.keys():
- if " " in mysettings["PORTAGE_ELOG_MAILURI"]:
- myrecipient, mymailuri = mysettings["PORTAGE_ELOG_MAILURI"].split()
- if "@" in mymailuri:
- myauthdata, myconndata = mymailuri.rsplit("@", 1)
- try:
- mymailuser,mymailpasswd = myauthdata.split(":")
- except ValueError:
- print "!!! invalid SMTP AUTH configuration, trying unauthenticated ..."
- else:
- myconndata = mymailuri
- if ":" in myconndata:
- mymailhost,mymailport = myconndata.split(":")
- else:
- mymailhost = myconndata
+ if " " in mysettings["PORTAGE_ELOG_MAILURI"]:
+ myrecipient, mymailuri = mysettings["PORTAGE_ELOG_MAILURI"].split()
+ if "@" in mymailuri:
+ myauthdata, myconndata = mymailuri.rsplit("@", 1)
+ try:
+ mymailuser,mymailpasswd = myauthdata.split(":")
+ except ValueError:
+ print "!!! invalid SMTP AUTH configuration, trying unauthenticated ..."
else:
- myrecipient = mysettings["PORTAGE_ELOG_MAILURI"]
+ myconndata = mymailuri
+ if ":" in myconndata:
+ mymailhost,mymailport = myconndata.split(":")
+ else:
+ mymailhost = myconndata
+ else:
+ myrecipient = mysettings["PORTAGE_ELOG_MAILURI"]
try:
+ myfrom = mysettings["PORTAGE_ELOG_MAILFROM"]
+
mymessage = email.Message.Message()
- mymessage.set_unixfrom("portage")
+ mymessage.set_unixfrom(myfrom)
mymessage.set_payload(fulltext)
mymessage["To"] = myrecipient
- mymessage["Subject"] = "[portage] Ebuild log for %s" % cpv
+
+ mysubject = mysettings["PORTAGE_ELOG_MAILSUBJECT"]
+ mysubject = mysubject.replace("${PACKAGE}", cpv)
+ mysubject = mysubject.replace("${HOST}", socket.getfqdn())
+
+ mymessage["Subject"] = mysubject
if int(mymailport) > 100000:
myconn = smtplib.SMTP(mymailhost, int(mymailport) - 100000)
@@ -45,10 +51,10 @@ def process(mysettings, cpv, logentries, fulltext):
myconn = smtplib.SMTP(mymailhost, mymailport)
if mymailuser != "" and mymailpasswd != "":
myconn.login(mymailuser, mymailpasswd)
- myconn.sendmail("portage", myrecipient, mymessage.as_string())
+ myconn.sendmail(myfrom, myrecipient, mymessage.as_string())
myconn.quit()
except smtplib.SMTPException, e:
raise portage_exception.PortageException("!!! An error occured while trying to send logmail:\n"+str(e))
except socket.error, e:
- raise portage_exception.PortageException("!!! A network error occured while trying to send logmail:\n"+str(e)+"\nSure you configured PORTAGE_LOG_MAILURI correctly?")
+ raise portage_exception.PortageException("!!! A network error occured while trying to send logmail:\n"+str(e)+"\nSure you configured PORTAGE_ELOG_MAILURI correctly?")
return
diff --git a/pym/elog_modules/mod_save.py b/pym/elog_modules/mod_save.py
index 106e8800a..6c16c2041 100644
--- a/pym/elog_modules/mod_save.py
+++ b/pym/elog_modules/mod_save.py
@@ -4,7 +4,10 @@ from portage_data import portage_uid, portage_gid
def process(mysettings, cpv, logentries, fulltext):
cpv_path = cpv.replace("/", ":")
- elogdir = mysettings["PORTAGE_TMPDIR"]+"/elogs"
+ if mysettings["PORT_LOGDIR"] != "":
+ elogdir = os.path.join(mysettings["PORT_LOGDIR"], "elog")
+ else:
+ elogdir = os.path.join(os.sep, "var", "log", "portage", "elog")
if not os.path.exists(elogdir):
os.makedirs(elogdir)
os.chown(elogdir, portage_uid, portage_gid)