Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: man/, pym/portage/package/ebuild/_config/, pym/portage/, cnf/, pym/_emerge/
Date: Wed, 31 Aug 2011 17:57:30
Message-Id: 377720b203f2f22609da0429ec866ba671fc2da0.zmedico@gentoo
1 commit: 377720b203f2f22609da0429ec866ba671fc2da0
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Wed Aug 31 17:54:52 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Wed Aug 31 17:54:52 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=377720b2
7
8 Add FEATURES=clean-logs support.
9
10 Enable automatic execution of the command specified by the
11 PORT_LOGDIR_CLEAN variable. The default PORT_LOGDIR_CLEAN setting will
12 remove all files from PORT_LOGDIR that were last modified at least 7
13 days ago.
14
15 ---
16 cnf/make.globals | 3 ++
17 man/make.conf.5 | 13 +++++++
18 pym/_emerge/main.py | 35 ++++++++++++++++++-
19 pym/portage/const.py | 3 +-
20 .../package/ebuild/_config/special_env_vars.py | 2 +-
21 5 files changed, 52 insertions(+), 4 deletions(-)
22
23 diff --git a/cnf/make.globals b/cnf/make.globals
24 index 2892d50..fcd0b41 100644
25 --- a/cnf/make.globals
26 +++ b/cnf/make.globals
27 @@ -101,6 +101,9 @@ PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress
28 # message should be produced.
29 PORTAGE_SYNC_STALE="30"
30
31 +# Executed before emerge exit if FEATURES=clean-logs is enabled.
32 +PORT_LOGDIR_CLEAN="find \"\${PORT_LOGDIR}\" -type f ! -name \"summary.log*\" -mtime +7 -delete"
33 +
34 # Minimal CONFIG_PROTECT
35 CONFIG_PROTECT="/etc"
36 CONFIG_PROTECT_MASK="/etc/env.d"
37
38 diff --git a/man/make.conf.5 b/man/make.conf.5
39 index 76f32f7..ac49c88 100644
40 --- a/man/make.conf.5
41 +++ b/man/make.conf.5
42 @@ -247,6 +247,12 @@ like "File not recognized: File truncated"), try recompiling the application
43 with ccache disabled before reporting a bug. Unless you are doing development
44 work, do not enable ccache.
45 .TP
46 +.B clean\-logs
47 +Enable automatic execution of the command specified by the
48 +PORT_LOGDIR_CLEAN variable. The default PORT_LOGDIR_CLEAN setting will
49 +remove all files from PORT_LOGDIR that were last modified at least 7
50 +days ago.
51 +.TP
52 .B collision\-protect
53 A QA\-feature to ensure that a package doesn't overwrite files it doesn't own.
54 The \fICOLLISION_IGNORE\fR variable can be used to selectively disable this
55 @@ -609,6 +615,13 @@ directory does not exist, it will be created automatically and group permissions
56 will be applied to it. If the directory already exists, portage will not
57 modify it's permissions.
58 .TP
59 +.B PORT_LOGDIR_CLEAN
60 +This variable should contain a command for portage to call in order
61 +to clean PORT_LOGDIR. The command string should contain a
62 +\\${PORT_LOGDIR} place\-holder that will be substituted
63 +with the value of that variable. This variable will have no effect
64 +unless \fBclean\-logs\fR is enabled in \fBFEATURES\fR.
65 +.TP
66 \fBPORTAGE_BINHOST\fR = \fI[space delimited URI list]\fR
67 This is a list of hosts from which portage will grab prebuilt\-binary packages.
68 Each entry in the list must specify the full address of a directory
69
70 diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
71 index 343fd58..b3e047c 100644
72 --- a/pym/_emerge/main.py
73 +++ b/pym/_emerge/main.py
74 @@ -28,7 +28,8 @@ import portage.exception
75 from portage.data import secpass
76 from portage.dbapi.dep_expand import dep_expand
77 from portage.util import normalize_path as normpath
78 -from portage.util import shlex_split, writemsg_level, writemsg_stdout
79 +from portage.util import (shlex_split, varexpand,
80 + writemsg_level, writemsg_stdout)
81 from portage._sets import SETPREFIX
82 from portage._global_updates import _global_updates
83
84 @@ -388,6 +389,8 @@ def post_emerge(myaction, myopts, myfiles,
85 " %s spawn failed of %s\n" % (bad("*"), postemerge,),
86 level=logging.ERROR, noiselevel=-1)
87
88 + clean_logs(settings)
89 +
90 if "--quiet" not in myopts and \
91 myaction is None and "@world" in myfiles:
92 show_depclean_suggestion()
93 @@ -1222,7 +1225,6 @@ def ionice(settings):
94 if not ionice_cmd:
95 return
96
97 - from portage.util import varexpand
98 variables = {"PID" : str(os.getpid())}
99 cmd = [varexpand(x, mydict=variables) for x in ionice_cmd]
100
101 @@ -1238,6 +1240,35 @@ def ionice(settings):
102 out.eerror("PORTAGE_IONICE_COMMAND returned %d" % (rval,))
103 out.eerror("See the make.conf(5) man page for PORTAGE_IONICE_COMMAND usage instructions.")
104
105 +def clean_logs(settings):
106 +
107 + if "clean-logs" not in settings.features:
108 + return
109 +
110 + clean_cmd = settings.get("PORT_LOGDIR_CLEAN")
111 + if clean_cmd:
112 + clean_cmd = shlex_split(clean_cmd)
113 + if not clean_cmd:
114 + return
115 +
116 + logdir = settings.get("PORT_LOGDIR")
117 + if logdir is None or not os.path.isdir(logdir):
118 + return
119 +
120 + variables = {"PORT_LOGDIR" : logdir}
121 + cmd = [varexpand(x, mydict=variables) for x in clean_cmd]
122 +
123 + try:
124 + rval = portage.process.spawn(cmd, env=os.environ)
125 + except portage.exception.CommandNotFound:
126 + rval = 127
127 +
128 + if rval != os.EX_OK:
129 + out = portage.output.EOutput()
130 + out.eerror("PORT_LOGDIR_CLEAN returned %d" % (rval,))
131 + out.eerror("See the make.conf(5) man page for "
132 + "PORT_LOGDIR_CLEAN usage instructions.")
133 +
134 def setconfig_fallback(root_config):
135 from portage._sets.base import DummyPackageSet
136 from portage._sets.files import WorldSelectedSet
137
138 diff --git a/pym/portage/const.py b/pym/portage/const.py
139 index ecaa8f1..f24a1a9 100644
140 --- a/pym/portage/const.py
141 +++ b/pym/portage/const.py
142 @@ -88,7 +88,8 @@ EBUILD_PHASES = ("pretend", "setup", "unpack", "prepare", "configure"
143 SUPPORTED_FEATURES = frozenset([
144 "allow-missing-manifests",
145 "assume-digests", "binpkg-logs", "buildpkg", "buildsyspkg", "candy",
146 - "ccache", "chflags", "collision-protect", "compress-build-logs",
147 + "ccache", "chflags", "clean-logs",
148 + "collision-protect", "compress-build-logs",
149 "digest", "distcc", "distcc-pump", "distlocks", "ebuild-locks", "fakeroot",
150 "fail-clean", "fixpackages", "force-mirror", "getbinpkg",
151 "installsources", "keeptemp", "keepwork", "fixlafiles", "lmirror",
152
153 diff --git a/pym/portage/package/ebuild/_config/special_env_vars.py b/pym/portage/package/ebuild/_config/special_env_vars.py
154 index 1b54867..99321e2 100644
155 --- a/pym/portage/package/ebuild/_config/special_env_vars.py
156 +++ b/pym/portage/package/ebuild/_config/special_env_vars.py
157 @@ -156,7 +156,7 @@ environ_filter += [
158 "PORTAGE_RO_DISTDIRS",
159 "PORTAGE_RSYNC_EXTRA_OPTS", "PORTAGE_RSYNC_OPTS",
160 "PORTAGE_RSYNC_RETRIES", "PORTAGE_SYNC_STALE",
161 - "PORTAGE_USE", "PORT_LOGDIR",
162 + "PORTAGE_USE", "PORT_LOGDIR", "PORT_LOGDIR_CLEAN",
163 "QUICKPKG_DEFAULT_OPTS",
164 "RESUMECOMMAND", "RESUMECOMMAND_FTP",
165 "RESUMECOMMAND_HTTP", "RESUMECOMMAND_HTTPS",