Gentoo Archives: gentoo-commits

From: "Fabian Groffen (grobian)" <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r13869 - in main/branches/prefix: bin man pym/_emerge pym/portage
Date: Fri, 31 Jul 2009 07:41:18
Message-Id: E1MWmjr-0003Bf-BI@stork.gentoo.org
1 Author: grobian
2 Date: 2009-07-31 07:41:14 +0000 (Fri, 31 Jul 2009)
3 New Revision: 13869
4
5 Added:
6 main/branches/prefix/bin/setsid
7 Modified:
8 main/branches/prefix/bin/ebuild.sh
9 main/branches/prefix/bin/portageq
10 main/branches/prefix/man/portage.5
11 main/branches/prefix/pym/_emerge/actions.py
12 main/branches/prefix/pym/_emerge/depgraph.py
13 main/branches/prefix/pym/portage/util.py
14 Log:
15 Merged from trunk -r13857:13865
16
17 | 13858 | Add get_updated_config_files in portage API |
18 | volkmar | chk_updated_cfg_files in _emerge API is now using |
19 | | get_updated_config_files It lets other app to get updated |
20 | | config files without ouputs |
21
22 | 13859 | Rename get_updated_config_files() to |
23 | zmedico | find_updated_config_files() and make it an iterator of |
24 | | tuples. |
25
26 | 13860 | Updating find_updated_config_files function description |
27 | volkmar | |
28
29 | 13861 | Move the setsid code (from bug #278895) as early as |
30 | zmedico | possible. |
31
32 | 13862 | Fix breakage in owners() handling of abs paths. |
33 | zmedico | |
34
35 | 13863 | Add a python-based setsid script for use with USERLAND=BSD. |
36 | zmedico | |
37
38 | 13864 | Bug #276264 - Advise manual removal of the metadata/cache/ |
39 | zmedico | direcory when using eclass-overrides. |
40
41 | 13865 | In depgraph._show_slot_collision_notice(), display $ROOT (if |
42 | zmedico | not /) with each slot atom. |
43
44
45 Modified: main/branches/prefix/bin/ebuild.sh
46 ===================================================================
47 --- main/branches/prefix/bin/ebuild.sh 2009-07-31 07:38:05 UTC (rev 13868)
48 +++ main/branches/prefix/bin/ebuild.sh 2009-07-31 07:41:14 UTC (rev 13869)
49 @@ -18,6 +18,28 @@
50 unset PORTAGE_ROOTPATH
51 fi
52
53 +ROOTPATH=${ROOTPATH##:}
54 +ROOTPATH=${ROOTPATH%%:}
55 +PREROOTPATH=${PREROOTPATH##:}
56 +PREROOTPATH=${PREROOTPATH%%:}
57 +#PATH=$PORTAGE_BIN_PATH/ebuild-helpers:$PREROOTPATH${PREROOTPATH:+:}/usr/local/sbin:/sbin:/usr/sbin:/usr/local/bin:/bin:/usr/bin${ROOTPATH:+:}$ROOTPATH
58 +# PREFIX: we deviate in path order, should we split up DEFAULT_PATH?
59 +PATH="$PORTAGE_BIN_PATH/ebuild-helpers:$PREROOTPATH${PREROOTPATH:+:}${DEFAULT_PATH}:${ROOTPATH:+:}$ROOTPATH"
60 +export PATH
61 +
62 +if [[ -z $PORTAGE_SETSID && -n $1 && $1 != depend ]] ; then
63 + # If available, use setsid to create a new login session so that we can use
64 + # SIGHUP to ensure that no orphaned subprocesses are left running.
65 + if type -P setsid >/dev/null ; then
66 + export PORTAGE_SETSID=1
67 + exec setsid "$PORTAGE_BIN_PATH/ebuild.sh" "$@"
68 + elif [[ -x $PORTAGE_BIN_PATH/setsid ]] ; then
69 + export PORTAGE_SETSID=1
70 + exec "$PORTAGE_BIN_PATH/setsid" "$PORTAGE_BIN_PATH/ebuild.sh" "$@"
71 + fi
72 +fi
73 +[[ $PORTAGE_SETSID = 1 ]] && trap 'trap : SIGHUP ; kill -s SIGHUP 0 ;' EXIT
74 +
75 # These two functions wrap sourcing and calling respectively. At present they
76 # perform a qa check to make sure eclasses and ebuilds and profiles don't mess
77 # with shell opts (shopts). Ebuilds/eclasses changing shopts should reset them
78 @@ -64,26 +86,6 @@
79 # Unset some variables that break things.
80 unset GZIP BZIP BZIP2 CDPATH GREP_OPTIONS GREP_COLOR GLOBIGNORE
81
82 -ROOTPATH=${ROOTPATH##:}
83 -ROOTPATH=${ROOTPATH%%:}
84 -PREROOTPATH=${PREROOTPATH##:}
85 -PREROOTPATH=${PREROOTPATH%%:}
86 -#PATH=$PORTAGE_BIN_PATH/ebuild-helpers:$PREROOTPATH${PREROOTPATH:+:}/usr/local/sbin:/sbin:/usr/sbin:/usr/local/bin:/bin:/usr/bin${ROOTPATH:+:}$ROOTPATH
87 -# PREFIX: we deviate in path order, should we split up DEFAULT_PATH?
88 -PATH="$PORTAGE_BIN_PATH/ebuild-helpers:$PREROOTPATH${PREROOTPATH:+:}${DEFAULT_PATH}:${ROOTPATH:+:}$ROOTPATH"
89 -export PATH
90 -
91 -if [[ -z $PORTAGE_SETSID && \
92 - -n $EBUILD_SH_ARGS && $EBUILD_SH_ARGS != depend ]] ; then
93 - if type -P setsid >/dev/null ; then
94 - # Use setsid to create a new login session so that we can use SIGHUP
95 - # to ensure that no orphaned subprocesses are left running.
96 - export PORTAGE_SETSID=1
97 - exec setsid "$PORTAGE_BIN_PATH/ebuild.sh" $EBUILD_SH_ARGS
98 - fi
99 -fi
100 -trap '[[ $PORTAGE_SETSID = 1 ]] && { trap : SIGHUP ; kill -s SIGHUP 0 ; }' EXIT
101 -
102 source "${PORTAGE_BIN_PATH}/isolated-functions.sh" &>/dev/null
103
104 # Set IMAGE for minimal backward compatibility with
105
106 Modified: main/branches/prefix/bin/portageq
107 ===================================================================
108 --- main/branches/prefix/bin/portageq 2009-07-31 07:38:05 UTC (rev 13868)
109 +++ main/branches/prefix/bin/portageq 2009-07-31 07:41:14 UTC (rev 13869)
110 @@ -198,7 +198,7 @@
111 if is_basename:
112 files.append(f)
113 else:
114 - files.append(f[len(root):])
115 + files.append(f[len(root)-1:])
116
117 owners = vardb._owners.get_owners(files)
118
119
120 Copied: main/branches/prefix/bin/setsid (from rev 13865, main/trunk/bin/setsid)
121 ===================================================================
122 --- main/branches/prefix/bin/setsid (rev 0)
123 +++ main/branches/prefix/bin/setsid 2009-07-31 07:41:14 UTC (rev 13869)
124 @@ -0,0 +1,10 @@
125 +#!/usr/bin/python -O
126 +# Copyright 2009 Gentoo Foundation
127 +# Distributed under the terms of the GNU General Public License v2
128 +# $Id$
129 +
130 +import os
131 +import sys
132 +
133 +os.setsid()
134 +os.execl(sys.argv[1], *sys.argv[1:])
135
136 Modified: main/branches/prefix/man/portage.5
137 ===================================================================
138 --- main/branches/prefix/man/portage.5 2009-07-31 07:38:05 UTC (rev 13868)
139 +++ main/branches/prefix/man/portage.5 2009-07-31 07:41:14 UTC (rev 13869)
140 @@ -558,8 +558,9 @@
141 eclass inheritance (especially due to \fBeclass\-overrides\fR) may trigger
142 performance issues under some circumstances (see \fBbug #124041\fR). When
143 using \fBeclass\-overrides\fR, due to bug #276264, you must ensure that
144 -your portage tree does not contain a metadata/cache/. For example, you
145 -should set PORTAGE_RSYNC_EXTRA_OPTS="\-\-exclude=/metadata/cache" in
146 +your portage tree does not contain a metadata/cache/ directory. If that
147 +directory exists then you should remove it entirely, and set
148 +PORTAGE_RSYNC_EXTRA_OPTS="\-\-exclude=/metadata/cache" in
149 make.conf in order to exclude the metadata/cache/ directory during
150 \fBemerge\fR(1) \-\-sync operations.
151
152
153 Modified: main/branches/prefix/pym/_emerge/actions.py
154 ===================================================================
155 --- main/branches/prefix/pym/_emerge/actions.py 2009-07-31 07:38:05 UTC (rev 13868)
156 +++ main/branches/prefix/pym/_emerge/actions.py 2009-07-31 07:41:14 UTC (rev 13869)
157 @@ -2660,59 +2660,21 @@
158 return settings, trees, mtimedb
159
160 def chk_updated_cfg_files(target_root, config_protect):
161 - if config_protect:
162 - #number of directories with some protect files in them
163 - procount=0
164 - for x in config_protect:
165 - x = os.path.join(target_root, x.lstrip(os.path.sep))
166 - if not os.access(x, os.W_OK):
167 - # Avoid Permission denied errors generated
168 - # later by `find`.
169 - continue
170 - try:
171 - mymode = os.lstat(x).st_mode
172 - except OSError:
173 - continue
174 - if stat.S_ISLNK(mymode):
175 - # We want to treat it like a directory if it
176 - # is a symlink to an existing directory.
177 - try:
178 - real_mode = os.stat(x).st_mode
179 - if stat.S_ISDIR(real_mode):
180 - mymode = real_mode
181 - except OSError:
182 - pass
183 - if stat.S_ISDIR(mymode):
184 - mycommand = "find '%s' -name '.*' -type d -prune -o -name '._cfg????_*'" % x
185 - else:
186 - mycommand = "find '%s' -maxdepth 1 -name '._cfg????_%s'" % \
187 - os.path.split(x.rstrip(os.path.sep))
188 - mycommand += " ! -name '.*~' ! -iname '.*.bak' -print0"
189 - a = commands.getstatusoutput(mycommand)
190 - if a[0] != 0:
191 - sys.stderr.write(" %s error scanning '%s': " % (bad("*"), x))
192 - sys.stderr.flush()
193 - # Show the error message alone, sending stdout to /dev/null.
194 - os.system(mycommand + " 1>/dev/null")
195 - else:
196 - files = a[1].split('\0')
197 - # split always produces an empty string as the last element
198 - if files and not files[-1]:
199 - del files[-1]
200 - if files:
201 - procount += 1
202 - print "\n"+colorize("WARN", " * IMPORTANT:"),
203 - if stat.S_ISDIR(mymode):
204 - print "%d config files in '%s' need updating." % \
205 - (len(files), x)
206 - else:
207 - print "config file '%s' needs updating." % x
208 + result = list(
209 + portage.util.find_updated_config_files(target_root, config_protect))
210
211 - if procount:
212 - print " "+yellow("*")+" See the "+colorize("INFORM","CONFIGURATION FILES")+ \
213 - " section of the " + bold("emerge")
214 - print " "+yellow("*")+" man page to learn how to update config files."
215 + for x in result:
216 + print "\n"+colorize("WARN", " * IMPORTANT:"),
217 + if not x[1]: # it's a protected file
218 + print "config file '%s' needs updating." % x[0]
219 + else: # it's a protected dir
220 + print "%d config files in '%s' need updating." % (len(x[1]), x[0])
221
222 + if result:
223 + print " "+yellow("*")+" See the "+colorize("INFORM","CONFIGURATION FILES")\
224 + + " section of the " + bold("emerge")
225 + print " "+yellow("*")+" man page to learn how to update config files."
226 +
227 def display_news_notification(root_config, myopts):
228 target_root = root_config.root
229 trees = root_config.trees
230
231 Modified: main/branches/prefix/pym/_emerge/depgraph.py
232 ===================================================================
233 --- main/branches/prefix/pym/_emerge/depgraph.py 2009-07-31 07:38:05 UTC (rev 13868)
234 +++ main/branches/prefix/pym/_emerge/depgraph.py 2009-07-31 07:41:14 UTC (rev 13869)
235 @@ -398,6 +398,8 @@
236 for (slot_atom, root), slot_nodes \
237 in self._dynamic_config._slot_collision_info.iteritems():
238 msg.append(str(slot_atom))
239 + if root != '/':
240 + msg.append(" for %s" % (root,))
241 msg.append("\n\n")
242
243 for node in slot_nodes:
244
245 Modified: main/branches/prefix/pym/portage/util.py
246 ===================================================================
247 --- main/branches/prefix/pym/portage/util.py 2009-07-31 07:38:05 UTC (rev 13868)
248 +++ main/branches/prefix/pym/portage/util.py 2009-07-31 07:41:14 UTC (rev 13869)
249 @@ -5,13 +5,14 @@
250 __all__ = ['apply_permissions', 'apply_recursive_permissions',
251 'apply_secpass_permissions', 'apply_stat_permissions', 'atomic_ofstream',
252 'cmp_sort_key', 'ConfigProtect', 'dump_traceback', 'ensure_dirs',
253 - 'getconfig', 'getlibpaths', 'grabdict', 'grabdict_package', 'grabfile',
254 - 'grabfile_package', 'grablines', 'initialize_logger', 'LazyItemsDict',
255 - 'map_dictlist_vals', 'new_protect_filename', 'normalize_path',
256 - 'pickle_read', 'stack_dictlist', 'stack_dicts', 'stack_lists',
257 - 'unique_array', 'varexpand', 'write_atomic', 'writedict', 'writemsg',
258 - 'writemsg_level', 'writemsg_stdout']
259 + 'find_updated_config_files', 'getconfig', 'getlibpaths', 'grabdict',
260 + 'grabdict_package', 'grabfile', 'grabfile_package', 'grablines',
261 + 'initialize_logger', 'LazyItemsDict', 'map_dictlist_vals',
262 + 'new_protect_filename', 'normalize_path', 'pickle_read', 'stack_dictlist',
263 + 'stack_dicts', 'stack_lists', 'unique_array', 'varexpand', 'write_atomic',
264 + 'writedict', 'writemsg', 'writemsg_level', 'writemsg_stdout']
265
266 +import commands
267 import codecs
268 import os
269 import errno
270 @@ -1291,6 +1292,59 @@
271 return old_pfile
272 return new_pfile
273
274 +def find_updated_config_files(target_root, config_protect):
275 + """
276 + Return a tuple of configuration files that needs to be updated.
277 + The tuple contains lists organized like this:
278 + [ protected_dir, file_list ]
279 + If the protected config isn't a protected_dir but a procted_file, list is:
280 + [ protected_file, None ]
281 + If no configuration files needs to be updated, None is returned
282 + """
283 +
284 + if config_protect:
285 + # directories with some protect files in them
286 + for x in config_protect:
287 + files = []
288 +
289 + x = os.path.join(target_root, x.lstrip(os.path.sep))
290 + if not os.access(x, os.W_OK):
291 + continue
292 + try:
293 + mymode = os.lstat(x).st_mode
294 + except OSError:
295 + continue
296 +
297 + if stat.S_ISLNK(mymode):
298 + # We want to treat it like a directory if it
299 + # is a symlink to an existing directory.
300 + try:
301 + real_mode = os.stat(x).st_mode
302 + if stat.S_ISDIR(real_mode):
303 + mymode = real_mode
304 + except OSError:
305 + pass
306 +
307 + if stat.S_ISDIR(mymode):
308 + mycommand = \
309 + "find '%s' -name '.*' -type d -prune -o -name '._cfg????_*'" % x
310 + else:
311 + mycommand = "find '%s' -maxdepth 1 -name '._cfg????_%s'" % \
312 + os.path.split(x.rstrip(os.path.sep))
313 + mycommand += " ! -name '.*~' ! -iname '.*.bak' -print0"
314 + a = commands.getstatusoutput(mycommand)
315 +
316 + if a[0] == 0:
317 + files = a[1].split('\0')
318 + # split always produces an empty string as the last element
319 + if files and not files[-1]:
320 + del files[-1]
321 + if files:
322 + if stat.S_ISDIR(mymode):
323 + yield (x, files)
324 + else:
325 + yield (x, None)
326 +
327 def getlibpaths(root):
328 """ Return a list of paths that are used for library lookups """