import output
output.nocolor()
-ebuild = os.path.realpath(pargs.pop(0))
+ebuild = pargs.pop(0)
+if not os.path.isabs(ebuild):
+ mycwd = os.getcwd()
+ # Try to get the non-canonical path from the PWD evironment variable, since
+ # the canonical path returned from os.getcwd() may may be unusable in
+ # cases where the directory stucture is built from symlinks.
+ if "PWD" in os.environ and os.environ["PWD"] != mycwd and \
+ os.path.realpath(os.environ["PWD"]) == mycwd:
+ mycwd = portage.normalize_path(os.environ["PWD"])
+ ebuild = os.path.join(mycwd, ebuild)
+ebuild = portage.normalize_path(ebuild)
+# portdbapi uses the canonical path for the base of the portage tree, but
+# subdirectories of the base can be built from symlinks (like crossdev does).
+ebuild_portdir = os.path.realpath(os.path.dirname(os.path.dirname(ebuild)))
+ebuild = os.path.join(ebuild_portdir, *ebuild.split(os.path.sep)[-2:])
if not os.path.exists(ebuild):
print "'%s' does not exist." % ebuild
portage_ebuild = portage.portdb.findname(cpv)
- if not portage_ebuild or os.path.realpath(portage_ebuild) != ebuild:
+ if not portage_ebuild or portage_ebuild != ebuild:
overlay = "/".join(ebuild_split[:-2])
os.environ["PORTDIR_OVERLAY"] = os.environ.get("PORTDIR_OVERLAY","") + " " + overlay
print "Appending %s to PORTDIR_OVERLAY..." % overlay
reload(portage)
portage_ebuild = portage.portdb.findname(cpv)
- if not portage_ebuild or os.path.realpath(portage_ebuild) != ebuild:
+ if not portage_ebuild or portage_ebuild != ebuild:
print "!!! %s does not seem to have a valid PORTDIR structure." % overlay
sys.exit(1)
if mymode in ("fix", "commit"):
repoman_settings["O"] = checkdir
- portage.digestgen(
- [], repoman_settings, manifestonly=1, myportdb=portdb)
+ if not portage.digestgen([], repoman_settings, myportdb=portdb):
+ print "Unable to generate manifest."
+ sys.exit(1)
mf = Manifest(checkdir, repoman_settings["DISTDIR"])
mydigests=mf.getTypeDigests("DIST")
global _doebuild_manifest_exempt_depend
try:
_doebuild_manifest_exempt_depend += 1
+ distfiles_map = {}
+ fetchlist_dict = FetchlistDict(mysettings["O"], mysettings, myportdb)
+ for cpv, fetchlist in fetchlist_dict.iteritems():
+ for myfile in fetchlist:
+ distfiles_map.setdefault(myfile, []).append(cpv)
mf = Manifest(mysettings["O"], mysettings["DISTDIR"],
- fetchlist_dict=FetchlistDict(mysettings["O"],
- mysettings, myportdb))
+ fetchlist_dict=fetchlist_dict)
+ missing_hashes = set(distfiles_map).difference(
+ mf.fhashdict.get("DIST", {}))
+ if missing_hashes:
+ missing_files = []
+ for myfile in missing_hashes:
+ try:
+ os.stat(os.path.join(mysettings["DISTDIR"], myfile))
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise
+ del e
+ missing_files.append(myfile)
+ if missing_files:
+ mytree = os.path.realpath(os.path.dirname(
+ os.path.dirname(mysettings["O"])))
+ myuris = []
+ for myfile in missing_files:
+ for cpv in distfiles_map[myfile]:
+ alluris, aalist = myportdb.getfetchlist(
+ cpv, mytree=mytree, all=True,
+ mysettings=mysettings)
+ for uri in alluris:
+ if os.path.basename(uri) == myfile:
+ myuris.append(uri)
+ if not fetch(myuris, mysettings):
+ writemsg(("!!! File %s doesn't exist, can't update " + \
+ "Manifest\n") % myfile, noiselevel=-1)
+ return 0
writemsg_stdout(">>> Creating Manifest for %s\n" % mysettings["O"])
try:
mf.create(requiredDistfiles=myarchives,
assumeDistHashesAlways=(
"assume-digests" in mysettings.features))
except portage_exception.FileNotFound, e:
- writemsg("!!! File %s doesn't exist, can't update " + \
- "Manifest\n" % str(e), noiselevel=-1)
+ writemsg(("!!! File %s doesn't exist, can't update " + \
+ "Manifest\n") % e, noiselevel=-1)
return 0
mf.write(sign=False)
if "assume-digests" not in mysettings.features:
mydigests = mf.getTypeDigests("DIST")
for filename, hashes in mydigests.iteritems():
if len(hashes) == len(mf.hashes):
- while True:
- try:
- i = checkme.index(filename) # raises ValueError
- del fetchme[i]
- del checkme[i]
- except ValueError:
- break
+ checkme = [i for i in checkme if i != filename]
+ fetchme = [i for i in fetchme \
+ if os.path.basename(i) != filename]
del filename, hashes
else:
fetchme = newuris[:]
mylist.append(x)
elif operator == "=": # Exact match
- mysplit = ["%s/%s" % (cat, pkg), ver, rev]
- for x in candidate_list:
- try:
- result = pkgcmp(pkgsplit(x), mysplit)
- except SystemExit:
- raise
- except:
- writemsg("\nInvalid package name: %s\n" % x, noiselevel=-1)
- raise
- if result == 0:
- mylist.append(x)
+ if mycpv in candidate_list:
+ mylist = [mycpv]
elif operator == "=*": # glob match
# The old verion ignored _tag suffixes... This one doesn't.
vlist1 = match1.group(3)[1:].split(".")
vlist2 = match2.group(3)[1:].split(".")
for i in range(0, max(len(vlist1), len(vlist2))):
+ # Implcit .0 is given a value of -1, so that 1.0.0 > 1.0, since it
+ # would be ambiguous if two versions that aren't literally equal
+ # are given the same value (in sorting, for example).
if len(vlist1) <= i or len(vlist1[i]) == 0:
- list1.append(0)
+ list1.append(-1)
list2.append(string.atoi(vlist2[i]))
elif len(vlist2) <= i or len(vlist2[i]) == 0:
list1.append(string.atoi(vlist1[i]))
- list2.append(0)
+ list2.append(-1)
# Let's make life easy and use integers unless we're forced to use floats
elif (vlist1[i][0] != "0" and vlist2[i][0] != "0"):
list1.append(string.atoi(vlist1[i]))