diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-06-18 19:55:17 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-06-18 19:55:17 +0000 |
commit | f188808244e7f24589825ce470d59df77b9d754b (patch) | |
tree | 9e05b1c45e87ec208fa2d9a60f20c46a6187f999 | |
parent | 758d31b247052e5658e4bb9e1273e230e2a6a9f1 (diff) | |
download | portage-f188808244e7f24589825ce470d59df77b9d754b.tar.gz portage-f188808244e7f24589825ce470d59df77b9d754b.tar.bz2 portage-f188808244e7f24589825ce470d59df77b9d754b.zip |
Add a EMERGE_LOG_DIR variable to control the location of emerge.log and
emerge-fetch.log. This was requested by Eitan Mosenkis <eitan@mosenkis.net>
for use in his 'online image builder' soc project.
svn path=/main/trunk/; revision=13652
-rw-r--r-- | man/make.conf.5 | 5 | ||||
-rw-r--r-- | pym/_emerge/__init__.py | 20 | ||||
-rw-r--r-- | pym/portage/__init__.py | 1 |
3 files changed, 24 insertions, 2 deletions
diff --git a/man/make.conf.5 b/man/make.conf.5 index ef5913a85..2b5a7645f 100644 --- a/man/make.conf.5 +++ b/man/make.conf.5 @@ -130,6 +130,11 @@ Options to append to the end of the \fBemerge\fR(1) command line on every invoca These options will not be appended to the command line if \-\-ignore\-default\-opts is specified. .TP +.B EMERGE_LOG_DIR +Controls the location of emerge.log and emerge-fetch.log. +.br +Defaults to /var/log. +.TP .B EPAUSE_IGNORE Defines whether or not to ignore short pauses that occur when displaying important informational messages. This variable is unset by default. diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 8ef667a07..a3921b629 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -238,13 +238,15 @@ shortmapping={ "v":"--verbose", "V":"--version" } +_emerge_log_dir = '/var/log' + def emergelog(xterm_titles, mystr, short_msg=None): if xterm_titles and short_msg: if "HOSTNAME" in os.environ: short_msg = os.environ["HOSTNAME"]+": "+short_msg xtermTitle(short_msg) try: - file_path = "/var/log/emerge.log" + file_path = os.path.join(_emerge_log_dir, 'emerge.log') mylogfile = open(file_path, "a") portage.util.apply_secpass_permissions(file_path, uid=portage.portage_uid, gid=portage.portage_gid, @@ -10137,7 +10139,7 @@ class Scheduler(PollScheduler): _bad_resume_opts = set(["--ask", "--changelog", "--resume", "--skipfirst"]) - _fetch_log = "/var/log/emerge-fetch.log" + _fetch_log = os.path.join(_emerge_log_dir, 'emerge-fetch.log') class _iface_class(SlotObject): __slots__ = ("dblinkEbuildPhase", "dblinkDisplayMerge", @@ -16181,6 +16183,20 @@ def emerge_main(): def emergelog(*pargs, **kargs): pass + else: + if 'EMERGE_LOG_DIR' in settings: + try: + # At least the parent needs to exist for the lock file. + portage.util.ensure_dirs(settings['EMERGE_LOG_DIR']) + except portage.exception.PortageException, e: + writemsg_level("!!! Error creating directory for " + \ + "EMERGE_LOG_DIR='%s':\n!!! %s\n" % \ + (settings['EMERGE_LOG_DIR'], e), + noiselevel=-1, level=logging.ERROR) + else: + global _emerge_log_dir + _emerge_log_dir = settings['EMERGE_LOG_DIR'] + if not "--pretend" in myopts: emergelog(xterm_titles, "Started emerge on: "+\ time.strftime("%b %d, %Y %H:%M:%S", time.localtime())) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index cd8adbba4..575e75c4b 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1135,6 +1135,7 @@ class config(object): "ACCEPT_KEYWORDS", "AUTOCLEAN", "CLEAN_DELAY", "COLLISION_IGNORE", "CONFIG_PROTECT", "CONFIG_PROTECT_MASK", "EGENCACHE_DEFAULT_OPTS", "EMERGE_DEFAULT_OPTS", + "EMERGE_LOG_DIR", "EMERGE_WARNING_DELAY", "FETCHCOMMAND", "FETCHCOMMAND_FTP", "FETCHCOMMAND_HTTP", "FETCHCOMMAND_SFTP", "GENTOO_MIRRORS", "NOCONFMEM", "O", |