Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: pym/portage/package/ebuild/fetch.py

Issue 6677171: Add force-mirror FEATURE. (Closed) Base URL: http://git.chromium.org/git/portage_tool.git@cros-2.1.9
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pym/portage/const.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2010 Gentoo Foundation 1 # Copyright 2010 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2 2 # Distributed under the terms of the GNU General Public License v2
3 3
4 from __future__ import print_function 4 from __future__ import print_function
5 5
6 __all__ = ['fetch'] 6 __all__ = ['fetch']
7 7
8 import codecs 8 import codecs
9 import errno 9 import errno
10 import logging 10 import logging
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 if not myuris: 238 if not myuris:
239 return 1 239 return 1
240 240
241 features = mysettings.features 241 features = mysettings.features
242 restrict = mysettings.get("PORTAGE_RESTRICT","").split() 242 restrict = mysettings.get("PORTAGE_RESTRICT","").split()
243 243
244 userfetch = secpass >= 2 and "userfetch" in features 244 userfetch = secpass >= 2 and "userfetch" in features
245 userpriv = secpass >= 2 and "userpriv" in features 245 userpriv = secpass >= 2 and "userpriv" in features
246 246
247 # 'nomirror' is bad/negative logic. You Restrict mirroring, not no-mirro ring. 247 # 'nomirror' is bad/negative logic. You Restrict mirroring, not no-mirro ring.
248 » if "mirror" in restrict or \ 248 » restrict_mirror = "mirror" in restrict or "nomirror" in restrict
249 » "nomirror" in restrict: 249 » if restrict_mirror:
250 if ("mirror" in features) and ("lmirror" not in features): 250 if ("mirror" in features) and ("lmirror" not in features):
251 # lmirror should allow you to bypass mirror restrictions . 251 # lmirror should allow you to bypass mirror restrictions .
252 # XXX: This is not a good thing, and is temporary at bes t. 252 # XXX: This is not a good thing, and is temporary at bes t.
253 print(_(">>> \"mirror\" mode desired and \"mirror\" rest riction found; skipping fetch.")) 253 print(_(">>> \"mirror\" mode desired and \"mirror\" rest riction found; skipping fetch."))
254 return 1 254 return 1
255 255
256 # Generally, downloading the same file repeatedly from 256 # Generally, downloading the same file repeatedly from
257 # every single available mirror is a waste of bandwidth 257 # every single available mirror is a waste of bandwidth
258 # and time, so there needs to be a cap. 258 # and time, so there needs to be a cap.
259 checksum_failure_max_tries = 5 259 checksum_failure_max_tries = 5
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 _("!!! For fetching to a read-only filesystem, " 337 _("!!! For fetching to a read-only filesystem, "
338 "locking should be turned off.\n")), noiselevel= -1) 338 "locking should be turned off.\n")), noiselevel= -1)
339 writemsg(_("!!! This can be done by adding -distlocks to " 339 writemsg(_("!!! This can be done by adding -distlocks to "
340 "FEATURES in /etc/make.conf\n"), noiselevel=-1) 340 "FEATURES in /etc/make.conf\n"), noiselevel=-1)
341 # use_locks = 0 341 # use_locks = 0
342 342
343 # local mirrors are always added 343 # local mirrors are always added
344 if "local" in custommirrors: 344 if "local" in custommirrors:
345 mymirrors += custommirrors["local"] 345 mymirrors += custommirrors["local"]
346 346
347 » if "nomirror" in restrict or \ 347 » if restrict_mirror:
348 » "mirror" in restrict:
349 # We don't add any mirrors. 348 # We don't add any mirrors.
350 pass 349 pass
351 else: 350 else:
352 if try_mirrors: 351 if try_mirrors:
353 mymirrors += [x.rstrip("/") for x in mysettings["GENTOO_ MIRRORS"].split() if x] 352 mymirrors += [x.rstrip("/") for x in mysettings["GENTOO_ MIRRORS"].split() if x]
354 353
355 skip_manifest = mysettings.get("EBUILD_SKIP_MANIFEST") == "1" 354 skip_manifest = mysettings.get("EBUILD_SKIP_MANIFEST") == "1"
356 pkgdir = mysettings.get("O") 355 pkgdir = mysettings.get("O")
357 if digests is None and not (pkgdir is None or skip_manifest): 356 if digests is None and not (pkgdir is None or skip_manifest):
358 mydigests = Manifest( 357 mydigests = Manifest(
359 pkgdir, mysettings["DISTDIR"]).getTypeDigests("DIST") 358 pkgdir, mysettings["DISTDIR"]).getTypeDigests("DIST")
360 elif digests is None: 359 elif digests is None:
361 # no digests because fetch was not called for a specific package 360 # no digests because fetch was not called for a specific package
362 mydigests = {} 361 mydigests = {}
363 else: 362 else:
364 mydigests = digests 363 mydigests = digests
365 364
366 ro_distdirs = [x for x in \ 365 ro_distdirs = [x for x in \
367 shlex_split(mysettings.get("PORTAGE_RO_DISTDIRS", "")) \ 366 shlex_split(mysettings.get("PORTAGE_RO_DISTDIRS", "")) \
368 if os.path.isdir(x)] 367 if os.path.isdir(x)]
369 368
370 fsmirrors = [] 369 fsmirrors = []
371 for x in range(len(mymirrors)-1,-1,-1): 370 for x in range(len(mymirrors)-1,-1,-1):
372 if mymirrors[x] and mymirrors[x][0]=='/': 371 if mymirrors[x] and mymirrors[x][0]=='/':
373 fsmirrors += [mymirrors[x]] 372 fsmirrors += [mymirrors[x]]
374 del mymirrors[x] 373 del mymirrors[x]
375 374
376 restrict_fetch = "fetch" in restrict 375 restrict_fetch = "fetch" in restrict
376 force_mirror = "force-mirror" in features and not restrict_mirror
377 custom_local_mirrors = custommirrors.get("local", []) 377 custom_local_mirrors = custommirrors.get("local", [])
378 if restrict_fetch: 378 if restrict_fetch:
379 # With fetch restriction, a normal uri may only be fetched from 379 # With fetch restriction, a normal uri may only be fetched from
380 # custom local mirrors (if available). A mirror:// uri may also 380 # custom local mirrors (if available). A mirror:// uri may also
381 # be fetched from specific mirrors (effectively overriding fetch 381 # be fetched from specific mirrors (effectively overriding fetch
382 # restriction, but only for specific mirrors). 382 # restriction, but only for specific mirrors).
383 locations = custom_local_mirrors 383 locations = custom_local_mirrors
384 else: 384 else:
385 locations = mymirrors 385 locations = mymirrors
386 386
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 for locmirr in thirdpartymirrors [mirrorname]] 423 for locmirr in thirdpartymirrors [mirrorname]]
424 filedict[myfile].extend(uris) 424 filedict[myfile].extend(uris)
425 thirdpartymirror_uris.setdefault(myfile, []).extend(uris) 425 thirdpartymirror_uris.setdefault(myfile, []).extend(uris)
426 426
427 if not filedict[myfile]: 427 if not filedict[myfile]:
428 writemsg(_("No known mirror by the name: %s\n") % (mirrorname)) 428 writemsg(_("No known mirror by the name: %s\n") % (mirrorname))
429 else: 429 else:
430 writemsg(_("Invalid mirror definition in SRC_URI :\n"), noiselevel=-1) 430 writemsg(_("Invalid mirror definition in SRC_URI :\n"), noiselevel=-1)
431 writemsg(" %s\n" % (myuri), noiselevel=-1) 431 writemsg(" %s\n" % (myuri), noiselevel=-1)
432 else: 432 else:
433 » » » if restrict_fetch: 433 » » » if restrict_fetch or force_mirror:
434 # Only fetch from specific mirrors is allowed. 434 # Only fetch from specific mirrors is allowed.
435 continue 435 continue
436 if "primaryuri" in restrict: 436 if "primaryuri" in restrict:
437 # Use the source site first. 437 # Use the source site first.
438 if myfile in primaryuri_indexes: 438 if myfile in primaryuri_indexes:
439 primaryuri_indexes[myfile] += 1 439 primaryuri_indexes[myfile] += 1
440 else: 440 else:
441 primaryuri_indexes[myfile] = 0 441 primaryuri_indexes[myfile] = 0
442 filedict[myfile].insert(primaryuri_indexes[myfil e], myuri) 442 filedict[myfile].insert(primaryuri_indexes[myfil e], myuri)
443 else: 443 else:
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 if listonly: 1109 if listonly:
1110 failed_files.add(myfile) 1110 failed_files.add(myfile)
1111 continue 1111 continue
1112 elif fetchonly: 1112 elif fetchonly:
1113 failed_files.add(myfile) 1113 failed_files.add(myfile)
1114 continue 1114 continue
1115 return 0 1115 return 0
1116 if failed_files: 1116 if failed_files:
1117 return 0 1117 return 0
1118 return 1 1118 return 1
OLDNEW
« no previous file with comments | « pym/portage/const.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698