1 |
Author: grobian |
2 |
Date: 2008-10-28 18:47:54 +0000 (Tue, 28 Oct 2008) |
3 |
New Revision: 11734 |
4 |
|
5 |
Modified: |
6 |
main/branches/prefix/bin/isolated-functions.sh |
7 |
main/branches/prefix/bin/misc-functions.sh |
8 |
main/branches/prefix/pym/_emerge/__init__.py |
9 |
main/branches/prefix/pym/portage/__init__.py |
10 |
main/branches/prefix/pym/portage/dbapi/vartree.py |
11 |
Log: |
12 |
Merged from trunk -r11701:11713 |
13 |
|
14 |
| 11702 | Remove the "found_available_arg" variable from | |
15 |
| zmedico | depgraph._select_pkg() and use the "matched_packages" | |
16 |
| | variable instead. This solve a problem where the | |
17 |
| | "found_available_arg" flag is unreliable due to the slot | |
18 |
| | filtering behavior of depgraph._iter_atoms_for_pkg(). For | |
19 |
| | example, a higher version in a different slot than the | |
20 |
| | available ebuild might be masked or unavailable, and | |
21 |
| | depgraph._iter_atoms_for_pkg() will not identify the | |
22 |
| | available ebuild as a match due to this installed package | |
23 |
| | (which is not available for reinstall). | |
24 |
|
25 |
| 11703 | Simplify logic from the previous commit. | |
26 |
| zmedico | | |
27 |
|
28 |
| 11704 | Revert previous 2 commits since they broke "selective" | |
29 |
| zmedico | behavior. | |
30 |
|
31 |
| 11705 | Handle the case that was intended to be fixed by r11702 | |
32 |
| zmedico | (which got reverted). | |
33 |
|
34 |
| 11706 | Prefer thirdpartymirrors over normal mirrors in cases when | |
35 |
| zmedico | the file does not yet exist on the normal mirrors. Thanks to | |
36 |
| | Maurice van der Pot <griffon26@g.o> for reporting. | |
37 |
|
38 |
| 11707 | Remove redundant duplicate uri elimination code. It's | |
39 |
| zmedico | already handled in the fetch loop. | |
40 |
|
41 |
| 11708 | Add PORTAGE_QUIET to the environment whitelist and filter it | |
42 |
| zmedico | from the saved ebuild environment. | |
43 |
|
44 |
| 11709 | Bug #186842 - Suppress file merge display, as previously | |
45 |
| zmedico | done in --quiet mode, whenever --verbose is not enabled. | |
46 |
| | Also, export PORTAGE_VERBOSE to the ebuild environment and | |
47 |
| | use it to control tar verbosity when creating binary | |
48 |
| | packages. | |
49 |
|
50 |
| 11710 | Use normal return statements instead of calling sys.exit() | |
51 |
| zmedico | inside dblink.mergeme(). | |
52 |
|
53 |
| 11711 | Remove needlessly complex error handling code from | |
54 |
| zmedico | vardbapi.cpv_counter(). | |
55 |
|
56 |
| 11712 | Remove unused imports found by pyflakes. | |
57 |
| zmedico | | |
58 |
|
59 |
| 11713 | Validate PROPERTIES inside doebuild(). | |
60 |
| zmedico | | |
61 |
|
62 |
|
63 |
Modified: main/branches/prefix/bin/isolated-functions.sh |
64 |
=================================================================== |
65 |
--- main/branches/prefix/bin/isolated-functions.sh 2008-10-28 09:25:56 UTC (rev 11733) |
66 |
+++ main/branches/prefix/bin/isolated-functions.sh 2008-10-28 18:47:54 UTC (rev 11734) |
67 |
@@ -535,6 +535,7 @@ |
68 |
PORTAGE_COLORMAP PORTAGE_CONFIGROOT PORTAGE_DEBUG \ |
69 |
PORTAGE_DEPCACHEDIR PORTAGE_GID PORTAGE_INST_GID \ |
70 |
PORTAGE_INST_UID PORTAGE_LOG_FILE PORTAGE_MASTER_PID \ |
71 |
+ PORTAGE_QUIET \ |
72 |
PORTAGE_REPO_NAME PORTAGE_RESTRICT PORTAGE_UPDATE_ENV \ |
73 |
PORTAGE_WORKDIR_MODE PORTDIR \ |
74 |
PORTDIR_OVERLAY ${!PORTAGE_SANDBOX_*} PREROOTPATH \ |
75 |
|
76 |
Modified: main/branches/prefix/bin/misc-functions.sh |
77 |
=================================================================== |
78 |
--- main/branches/prefix/bin/misc-functions.sh 2008-10-28 09:25:56 UTC (rev 11733) |
79 |
+++ main/branches/prefix/bin/misc-functions.sh 2008-10-28 18:47:54 UTC (rev 11734) |
80 |
@@ -739,7 +739,7 @@ |
81 |
cd "${T}" |
82 |
install_mask "${PORTAGE_BUILDDIR}/image" "${PKG_INSTALL_MASK}" |
83 |
local tar_options="" |
84 |
- [ "${PORTAGE_QUIET}" == "1" ] || tar_options="${tar_options} -v" |
85 |
+ [[ $PORTAGE_VERBOSE = 1 ]] && tar_options+=" -v" |
86 |
# Sandbox is disabled in case the user wants to use a symlink |
87 |
# for $PKGDIR and/or $PKGDIR/All. |
88 |
export SANDBOX_ON="0" |
89 |
|
90 |
Modified: main/branches/prefix/pym/_emerge/__init__.py |
91 |
=================================================================== |
92 |
--- main/branches/prefix/pym/_emerge/__init__.py 2008-10-28 09:25:56 UTC (rev 11733) |
93 |
+++ main/branches/prefix/pym/_emerge/__init__.py 2008-10-28 18:47:54 UTC (rev 11734) |
94 |
@@ -5708,6 +5708,22 @@ |
95 |
if pkg.cp == cp] |
96 |
break |
97 |
|
98 |
+ # If the installed version is in a different slot and it is higher than |
99 |
+ # the highest available visible package, _iter_atoms_for_pkg() may fail |
100 |
+ # to properly match the available package with a corresponding argument |
101 |
+ # atom. Detect this case and correct it here. |
102 |
+ if not selective and len(matched_packages) > 1 and \ |
103 |
+ matched_packages[-1].installed and \ |
104 |
+ matched_packages[-1].slot_atom != \ |
105 |
+ matched_packages[-2].slot_atom and \ |
106 |
+ matched_packages[-1] > matched_packages[-2]: |
107 |
+ pkg = matched_packages[-2] |
108 |
+ if pkg.root == self.target_root and \ |
109 |
+ self._set_atoms.findAtomForPackage(pkg): |
110 |
+ # Select the available package instead |
111 |
+ # of the installed package. |
112 |
+ matched_packages.pop() |
113 |
+ |
114 |
if len(matched_packages) > 1: |
115 |
bestmatch = portage.best( |
116 |
[pkg.cpv for pkg in matched_packages]) |
117 |
@@ -13513,6 +13529,10 @@ |
118 |
settings["PORTAGE_QUIET"]="1" |
119 |
settings.backup_changes("PORTAGE_QUIET") |
120 |
|
121 |
+ if "--verbose" in myopts: |
122 |
+ settings["PORTAGE_VERBOSE"] = "1" |
123 |
+ settings.backup_changes("PORTAGE_VERBOSE") |
124 |
+ |
125 |
# Set so that configs will be merged regardless of remembered status |
126 |
if ("--noconfmem" in myopts): |
127 |
settings["NOCONFMEM"]="1" |
128 |
|
129 |
Modified: main/branches/prefix/pym/portage/__init__.py |
130 |
=================================================================== |
131 |
--- main/branches/prefix/pym/portage/__init__.py 2008-10-28 09:25:56 UTC (rev 11733) |
132 |
+++ main/branches/prefix/pym/portage/__init__.py 2008-10-28 18:47:54 UTC (rev 11734) |
133 |
@@ -938,8 +938,10 @@ |
134 |
"PORTAGE_GID", "PORTAGE_INST_GID", "PORTAGE_INST_UID", |
135 |
"PORTAGE_IUSE", |
136 |
"PORTAGE_LOG_FILE", "PORTAGE_MASTER_PID", |
137 |
- "PORTAGE_PYM_PATH", "PORTAGE_REPO_NAME", "PORTAGE_RESTRICT", |
138 |
- "PORTAGE_TMPDIR", "PORTAGE_UPDATE_ENV", "PORTAGE_WORKDIR_MODE", |
139 |
+ "PORTAGE_PYM_PATH", "PORTAGE_QUIET", |
140 |
+ "PORTAGE_REPO_NAME", "PORTAGE_RESTRICT", |
141 |
+ "PORTAGE_TMPDIR", "PORTAGE_UPDATE_ENV", |
142 |
+ "PORTAGE_VERBOSE", "PORTAGE_WORKDIR_MODE", |
143 |
"PORTDIR", "PORTDIR_OVERLAY", "PREROOTPATH", "PROFILE_PATHS", |
144 |
"ROOT", "ROOTPATH", "STARTDIR", "T", "TMP", "TMPDIR", |
145 |
"USE_EXPAND", "USE_ORDER", "WORKDIR", |
146 |
@@ -3514,6 +3516,7 @@ |
147 |
filedict={} |
148 |
primaryuri_indexes={} |
149 |
primaryuri_dict = {} |
150 |
+ thirdpartymirror_uris = {} |
151 |
for myfile, myuri in file_uri_tuples: |
152 |
if myfile not in filedict: |
153 |
filedict[myfile]=[] |
154 |
@@ -3530,16 +3533,15 @@ |
155 |
for cmirr in custommirrors[mirrorname]: |
156 |
filedict[myfile].append( |
157 |
cmirr.rstrip("/") + "/" + path) |
158 |
- # remove the mirrors we tried from the list of official mirrors |
159 |
- if cmirr.strip() in thirdpartymirrors[mirrorname]: |
160 |
- thirdpartymirrors[mirrorname].remove(cmirr) |
161 |
+ |
162 |
# now try the official mirrors |
163 |
if mirrorname in thirdpartymirrors: |
164 |
shuffle(thirdpartymirrors[mirrorname]) |
165 |
|
166 |
- for locmirr in thirdpartymirrors[mirrorname]: |
167 |
- filedict[myfile].append( |
168 |
- locmirr.rstrip("/") + "/" + path) |
169 |
+ uris = [locmirr.rstrip("/") + "/" + path \ |
170 |
+ for locmirr in thirdpartymirrors[mirrorname]] |
171 |
+ filedict[myfile].extend(uris) |
172 |
+ thirdpartymirror_uris.setdefault(myfile, []).extend(uris) |
173 |
|
174 |
if not filedict[myfile]: |
175 |
writemsg("No known mirror by the name: %s\n" % (mirrorname)) |
176 |
@@ -3565,6 +3567,11 @@ |
177 |
primaryuri_dict[myfile] = primaryuris |
178 |
primaryuris.append(myuri) |
179 |
|
180 |
+ # Prefer thirdpartymirrors over normal mirrors in cases when |
181 |
+ # the file does not yet exist on the normal mirrors. |
182 |
+ for myfile, uris in thirdpartymirror_uris.iteritems(): |
183 |
+ primaryuri_dict.setdefault(myfile, []).extend(uris) |
184 |
+ |
185 |
can_fetch=True |
186 |
|
187 |
if listonly: |
188 |
@@ -5425,7 +5432,7 @@ |
189 |
set(["clean", "cleanrm", "help", "prerm", "postrm"]) |
190 |
mycpv = mysettings["CATEGORY"] + "/" + mysettings["PF"] |
191 |
dep_keys = ["DEPEND", "RDEPEND", "PDEPEND"] |
192 |
- misc_keys = ["LICENSE", "PROVIDE", "RESTRICT", "SRC_URI"] |
193 |
+ misc_keys = ["LICENSE", "PROPERTIES", "PROVIDE", "RESTRICT", "SRC_URI"] |
194 |
other_keys = ["SLOT"] |
195 |
all_keys = dep_keys + misc_keys + other_keys |
196 |
metadata = dict(izip(all_keys, mydbapi.aux_get(mycpv, all_keys))) |
197 |
|
198 |
Modified: main/branches/prefix/pym/portage/dbapi/vartree.py |
199 |
=================================================================== |
200 |
--- main/branches/prefix/pym/portage/dbapi/vartree.py 2008-10-28 09:25:56 UTC (rev 11733) |
201 |
+++ main/branches/prefix/pym/portage/dbapi/vartree.py 2008-10-28 18:47:54 UTC (rev 11734) |
202 |
@@ -7,20 +7,19 @@ |
203 |
["write_contents", "tar_contents"] |
204 |
|
205 |
from portage.checksum import perform_md5 |
206 |
-from portage.const import CACHE_PATH, CONFIG_MEMORY_FILE, PORTAGE_BIN_PATH, \ |
207 |
+from portage.const import CACHE_PATH, CONFIG_MEMORY_FILE, \ |
208 |
PRIVATE_PATH, VDB_PATH, EPREFIX, EPREFIX_LSTRIP |
209 |
from portage.data import portage_gid, portage_uid, secpass, ostype |
210 |
from portage.dbapi import dbapi |
211 |
-from portage.dep import dep_getslot, use_reduce, paren_reduce, isvalidatom, \ |
212 |
- isjustname, dep_getkey, match_from_list |
213 |
-from portage.exception import InvalidAtom, InvalidData, InvalidPackageName, \ |
214 |
+from portage.dep import use_reduce, paren_reduce, isvalidatom, \ |
215 |
+ isjustname, dep_getkey |
216 |
+from portage.exception import InvalidData, InvalidPackageName, \ |
217 |
FileNotFound, PermissionDenied, UnsupportedAPIException |
218 |
from portage.locks import lockdir, unlockdir |
219 |
from portage.output import bold, red, green |
220 |
from portage.update import fixdbentries |
221 |
from portage.util import apply_secpass_permissions, ConfigProtect, ensure_dirs, \ |
222 |
- writemsg, writemsg_stdout, writemsg_level, \ |
223 |
- write_atomic, atomic_ofstream, writedict, \ |
224 |
+ writemsg, writemsg_level, write_atomic, atomic_ofstream, writedict, \ |
225 |
grabfile, grabdict, normalize_path, new_protect_filename, getlibpaths |
226 |
from portage.versions import pkgsplit, catpkgsplit, catsplit, best, pkgcmp |
227 |
|
228 |
@@ -31,7 +30,7 @@ |
229 |
from portage.elog import elog_process |
230 |
from portage.elog.filtering import filter_mergephases, filter_unmergephases |
231 |
|
232 |
-import os, re, sys, stat, errno, commands, copy, time, subprocess |
233 |
+import os, re, stat, errno, copy, subprocess |
234 |
import logging |
235 |
import shlex |
236 |
from itertools import izip |
237 |
@@ -1110,54 +1109,11 @@ |
238 |
return long(self.aux_get(mycpv, ["COUNTER"])[0]) |
239 |
except (KeyError, ValueError): |
240 |
pass |
241 |
- cdir = self.getpath(mycpv) |
242 |
- cpath = self.getpath(mycpv, filename="COUNTER") |
243 |
+ writemsg_level(("portage: COUNTER for %s was corrupted; " + \ |
244 |
+ "resetting to value of 0\n") % (mycpv,), |
245 |
+ level=logging.ERROR, noiselevel=-1) |
246 |
+ return 0 |
247 |
|
248 |
- # We write our new counter value to a new file that gets moved into |
249 |
- # place to avoid filesystem corruption on XFS (unexpected reboot.) |
250 |
- corrupted = 0 |
251 |
- if os.path.exists(cpath): |
252 |
- cfile = open(cpath, "r") |
253 |
- try: |
254 |
- counter = long(cfile.readline()) |
255 |
- except ValueError: |
256 |
- print "portage: COUNTER for", mycpv, "was corrupted; resetting to value of 0" |
257 |
- counter = long(0) |
258 |
- corrupted = 1 |
259 |
- cfile.close() |
260 |
- elif os.path.exists(cdir): |
261 |
- mys = pkgsplit(mycpv) |
262 |
- myl = self.match(mys[0], use_cache=0) |
263 |
- print mys, myl |
264 |
- if len(myl) == 1: |
265 |
- try: |
266 |
- # Only one package... Counter doesn't matter. |
267 |
- write_atomic(cpath, "1") |
268 |
- counter = 1 |
269 |
- except SystemExit, e: |
270 |
- raise |
271 |
- except Exception, e: |
272 |
- writemsg("!!! COUNTER file is missing for "+str(mycpv)+" in /var/db.\n", |
273 |
- noiselevel=-1) |
274 |
- writemsg("!!! Please run %s/fix-db.py or\n" % PORTAGE_BIN_PATH, |
275 |
- noiselevel=-1) |
276 |
- writemsg("!!! unmerge this exact version.\n", noiselevel=-1) |
277 |
- writemsg("!!! %s\n" % e, noiselevel=-1) |
278 |
- sys.exit(1) |
279 |
- else: |
280 |
- writemsg("!!! COUNTER file is missing for "+str(mycpv)+" in /var/db.\n", |
281 |
- noiselevel=-1) |
282 |
- writemsg("!!! Please run %s/fix-db.py or\n" % PORTAGE_BIN_PATH, |
283 |
- noiselevel=-1) |
284 |
- writemsg("!!! remerge the package.\n", noiselevel=-1) |
285 |
- sys.exit(1) |
286 |
- else: |
287 |
- counter = long(0) |
288 |
- if corrupted: |
289 |
- # update new global counter file |
290 |
- write_atomic(cpath, str(counter)) |
291 |
- return counter |
292 |
- |
293 |
def cpv_inject(self, mycpv): |
294 |
"injects a real package into our on-disk database; assumes mycpv is valid and doesn't already exist" |
295 |
os.makedirs(self.getpath(mycpv)) |
296 |
@@ -2109,8 +2065,7 @@ |
297 |
self._lock_vdb = None |
298 |
|
299 |
self.settings = mysettings |
300 |
- if self.settings == 1: |
301 |
- raise ValueError |
302 |
+ self._verbose = self.settings.get("PORTAGE_VERBOSE") == "1" |
303 |
|
304 |
self.myroot=myroot |
305 |
protect_obj = ConfigProtect(myroot, |
306 |
@@ -2544,6 +2499,8 @@ |
307 |
return os.EX_OK |
308 |
|
309 |
def _display_merge(self, msg, level=0, noiselevel=0): |
310 |
+ if not self._verbose and noiselevel >= 0 and level < logging.WARN: |
311 |
+ return |
312 |
if self._scheduler is not None: |
313 |
self._scheduler.dblinkDisplayMerge(self, msg, |
314 |
level=level, noiselevel=noiselevel) |
315 |
@@ -3534,7 +3491,9 @@ |
316 |
# couldn't get merged will be added to thirdhand. |
317 |
|
318 |
thirdhand = [] |
319 |
- self.mergeme(srcroot, destroot, outfile, thirdhand, secondhand, cfgfiledict, mymtime) |
320 |
+ if self.mergeme(srcroot, destroot, outfile, thirdhand, |
321 |
+ secondhand, cfgfiledict, mymtime): |
322 |
+ return 1 |
323 |
|
324 |
#swap hands |
325 |
lastlen = len(secondhand) |
326 |
@@ -3546,7 +3505,9 @@ |
327 |
|
328 |
if len(secondhand): |
329 |
# force merge of remaining symlinks (broken or circular; oh well) |
330 |
- self.mergeme(srcroot, destroot, outfile, None, secondhand, cfgfiledict, mymtime) |
331 |
+ if self.mergeme(srcroot, destroot, outfile, None, |
332 |
+ secondhand, cfgfiledict, mymtime): |
333 |
+ return 1 |
334 |
|
335 |
#restore umask |
336 |
os.umask(prevmask) |
337 |
@@ -3689,6 +3650,7 @@ |
338 |
""" |
339 |
|
340 |
showMessage = self._display_merge |
341 |
+ writemsg = self._display_merge |
342 |
scheduler = self._scheduler |
343 |
|
344 |
from os.path import sep, join |
345 |
@@ -3725,7 +3687,7 @@ |
346 |
writemsg(red("!!! and ensure your filesystem is in a sane state. ")+bold("'shutdown -Fr now'\n")) |
347 |
writemsg(red("!!! File: ")+str(mysrc)+"\n", noiselevel=-1) |
348 |
writemsg(red("!!! Error: ")+str(e)+"\n", noiselevel=-1) |
349 |
- sys.exit(1) |
350 |
+ return 1 |
351 |
except Exception, e: |
352 |
writemsg("\n") |
353 |
writemsg(red("!!! ERROR: An unknown error has occurred during the merge process.\n")) |
354 |
@@ -3734,7 +3696,7 @@ |
355 |
writemsg( "!!! this as a portage bug at bugs.gentoo.org. Append 'emerge info'.\n") |
356 |
writemsg( "!!! File: "+str(mysrc)+"\n", noiselevel=-1) |
357 |
writemsg( "!!! Error: "+str(e)+"\n", noiselevel=-1) |
358 |
- sys.exit(1) |
359 |
+ return 1 |
360 |
|
361 |
|
362 |
mymode = mystat[stat.ST_MODE] |
363 |
@@ -3800,9 +3762,11 @@ |
364 |
showMessage(">>> %s -> %s\n" % (mydest, myto)) |
365 |
outfile.write("sym "+myrealdest+" -> "+myto+" "+str(mymtime)+"\n") |
366 |
else: |
367 |
- print "!!! Failed to move file." |
368 |
- print "!!!", mydest, "->", myto |
369 |
- sys.exit(1) |
370 |
+ showMessage("!!! Failed to move file.\n", |
371 |
+ level=logging.ERROR, noiselevel=-1) |
372 |
+ showMessage("!!! %s -> %s\n" % (mydest, myto), |
373 |
+ level=logging.ERROR, noiselevel=-1) |
374 |
+ return 1 |
375 |
elif stat.S_ISDIR(mymode): |
376 |
# we are merging a directory |
377 |
if mydmode != None: |
378 |
@@ -3831,8 +3795,9 @@ |
379 |
else: |
380 |
# a non-directory and non-symlink-to-directory. Won't work for us. Move out of the way. |
381 |
if movefile(mydest, mydest+".backup", mysettings=self.settings) is None: |
382 |
- sys.exit(1) |
383 |
- print "bak", mydest, mydest+".backup" |
384 |
+ return 1 |
385 |
+ showMessage("bak %s %s.backup\n" % (mydest, mydest), |
386 |
+ level=logging.ERROR, noiselevel=-1) |
387 |
#now create our directory |
388 |
if self.settings.selinux_enabled(): |
389 |
import selinux |
390 |
@@ -3916,7 +3881,7 @@ |
391 |
if moveme: |
392 |
mymtime = movefile(mysrc, mydest, newmtime=thismtime, sstat=mystat, mysettings=self.settings) |
393 |
if mymtime is None: |
394 |
- sys.exit(1) |
395 |
+ return 1 |
396 |
zing = ">>>" |
397 |
|
398 |
if mymtime != None: |
399 |
@@ -3930,7 +3895,7 @@ |
400 |
if movefile(mysrc, mydest, newmtime=thismtime, sstat=mystat, mysettings=self.settings) != None: |
401 |
zing = ">>>" |
402 |
else: |
403 |
- sys.exit(1) |
404 |
+ return 1 |
405 |
if stat.S_ISFIFO(mymode): |
406 |
outfile.write("fif %s\n" % myrealdest) |
407 |
else: |