summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cnf/make.globals3
-rw-r--r--man/make.conf.513
-rw-r--r--pym/_emerge/main.py35
-rw-r--r--pym/portage/const.py3
-rw-r--r--pym/portage/package/ebuild/_config/special_env_vars.py2
5 files changed, 52 insertions, 4 deletions
diff --git a/cnf/make.globals b/cnf/make.globals
index 2892d5089..fcd0b41da 100644
--- a/cnf/make.globals
+++ b/cnf/make.globals
@@ -101,6 +101,9 @@ PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress
# message should be produced.
PORTAGE_SYNC_STALE="30"
+# Executed before emerge exit if FEATURES=clean-logs is enabled.
+PORT_LOGDIR_CLEAN="find \"\${PORT_LOGDIR}\" -type f ! -name \"summary.log*\" -mtime +7 -delete"
+
# Minimal CONFIG_PROTECT
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/env.d"
diff --git a/man/make.conf.5 b/man/make.conf.5
index 76f32f718..ac49c886e 100644
--- a/man/make.conf.5
+++ b/man/make.conf.5
@@ -247,6 +247,12 @@ like "File not recognized: File truncated"), try recompiling the application
with ccache disabled before reporting a bug. Unless you are doing development
work, do not enable ccache.
.TP
+.B clean\-logs
+Enable automatic execution of the command specified by the
+PORT_LOGDIR_CLEAN variable. The default PORT_LOGDIR_CLEAN setting will
+remove all files from PORT_LOGDIR that were last modified at least 7
+days ago.
+.TP
.B collision\-protect
A QA\-feature to ensure that a package doesn't overwrite files it doesn't own.
The \fICOLLISION_IGNORE\fR variable can be used to selectively disable this
@@ -609,6 +615,13 @@ directory does not exist, it will be created automatically and group permissions
will be applied to it. If the directory already exists, portage will not
modify it's permissions.
.TP
+.B PORT_LOGDIR_CLEAN
+This variable should contain a command for portage to call in order
+to clean PORT_LOGDIR. The command string should contain a
+\\${PORT_LOGDIR} place\-holder that will be substituted
+with the value of that variable. This variable will have no effect
+unless \fBclean\-logs\fR is enabled in \fBFEATURES\fR.
+.TP
\fBPORTAGE_BINHOST\fR = \fI[space delimited URI list]\fR
This is a list of hosts from which portage will grab prebuilt\-binary packages.
Each entry in the list must specify the full address of a directory
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 343fd5812..b3e047c9d 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -28,7 +28,8 @@ import portage.exception
from portage.data import secpass
from portage.dbapi.dep_expand import dep_expand
from portage.util import normalize_path as normpath
-from portage.util import shlex_split, writemsg_level, writemsg_stdout
+from portage.util import (shlex_split, varexpand,
+ writemsg_level, writemsg_stdout)
from portage._sets import SETPREFIX
from portage._global_updates import _global_updates
@@ -388,6 +389,8 @@ def post_emerge(myaction, myopts, myfiles,
" %s spawn failed of %s\n" % (bad("*"), postemerge,),
level=logging.ERROR, noiselevel=-1)
+ clean_logs(settings)
+
if "--quiet" not in myopts and \
myaction is None and "@world" in myfiles:
show_depclean_suggestion()
@@ -1222,7 +1225,6 @@ def ionice(settings):
if not ionice_cmd:
return
- from portage.util import varexpand
variables = {"PID" : str(os.getpid())}
cmd = [varexpand(x, mydict=variables) for x in ionice_cmd]
@@ -1238,6 +1240,35 @@ def ionice(settings):
out.eerror("PORTAGE_IONICE_COMMAND returned %d" % (rval,))
out.eerror("See the make.conf(5) man page for PORTAGE_IONICE_COMMAND usage instructions.")
+def clean_logs(settings):
+
+ if "clean-logs" not in settings.features:
+ return
+
+ clean_cmd = settings.get("PORT_LOGDIR_CLEAN")
+ if clean_cmd:
+ clean_cmd = shlex_split(clean_cmd)
+ if not clean_cmd:
+ return
+
+ logdir = settings.get("PORT_LOGDIR")
+ if logdir is None or not os.path.isdir(logdir):
+ return
+
+ variables = {"PORT_LOGDIR" : logdir}
+ cmd = [varexpand(x, mydict=variables) for x in clean_cmd]
+
+ try:
+ rval = portage.process.spawn(cmd, env=os.environ)
+ except portage.exception.CommandNotFound:
+ rval = 127
+
+ if rval != os.EX_OK:
+ out = portage.output.EOutput()
+ out.eerror("PORT_LOGDIR_CLEAN returned %d" % (rval,))
+ out.eerror("See the make.conf(5) man page for "
+ "PORT_LOGDIR_CLEAN usage instructions.")
+
def setconfig_fallback(root_config):
from portage._sets.base import DummyPackageSet
from portage._sets.files import WorldSelectedSet
diff --git a/pym/portage/const.py b/pym/portage/const.py
index ecaa8f1d3..f24a1a912 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -88,7 +88,8 @@ EBUILD_PHASES = ("pretend", "setup", "unpack", "prepare", "configure"
SUPPORTED_FEATURES = frozenset([
"allow-missing-manifests",
"assume-digests", "binpkg-logs", "buildpkg", "buildsyspkg", "candy",
- "ccache", "chflags", "collision-protect", "compress-build-logs",
+ "ccache", "chflags", "clean-logs",
+ "collision-protect", "compress-build-logs",
"digest", "distcc", "distcc-pump", "distlocks", "ebuild-locks", "fakeroot",
"fail-clean", "fixpackages", "force-mirror", "getbinpkg",
"installsources", "keeptemp", "keepwork", "fixlafiles", "lmirror",
diff --git a/pym/portage/package/ebuild/_config/special_env_vars.py b/pym/portage/package/ebuild/_config/special_env_vars.py
index 1b54867be..99321e26e 100644
--- a/pym/portage/package/ebuild/_config/special_env_vars.py
+++ b/pym/portage/package/ebuild/_config/special_env_vars.py
@@ -156,7 +156,7 @@ environ_filter += [
"PORTAGE_RO_DISTDIRS",
"PORTAGE_RSYNC_EXTRA_OPTS", "PORTAGE_RSYNC_OPTS",
"PORTAGE_RSYNC_RETRIES", "PORTAGE_SYNC_STALE",
- "PORTAGE_USE", "PORT_LOGDIR",
+ "PORTAGE_USE", "PORT_LOGDIR", "PORT_LOGDIR_CLEAN",
"QUICKPKG_DEFAULT_OPTS",
"RESUMECOMMAND", "RESUMECOMMAND_FTP",
"RESUMECOMMAND_HTTP", "RESUMECOMMAND_HTTPS",