From 0e79d89fd45e754b2be7d3762c6737f2fc4c820e Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Fri, 8 Dec 2006 08:05:32 +0000 Subject: [PATCH] Merged from trunk 5196:5205 For bug #157385, enable portage.digestgen() to fetch any distfiles for which there are no existing digests. Fix broken SRC_URI logic from the previous commit. Fix broken SRC_URI logic in doebuild. Make repoman bail out if it's unable to generate the Manifest. For bug #157393, fix up ebuild path normalization so that it's compatible with portdbapi handling and works properly with symlinks (like crossdev creates). Make sure the ebuild path is properly normalized. Revert r5175 for bug #152127 since the original = behavior seems more desirable. We can change the >= and <= behavior instead. For bug #152127, make vercmp give less value to implcit .0, so two versions that aren't literally equal are not ambiguously given the same value (in sorting, for example). svn path=/main/branches/prefix/; revision=5224 --- bin/ebuild | 20 ++++++++++++++--- bin/repoman | 5 +++-- pym/portage.py | 50 ++++++++++++++++++++++++++++++++--------- pym/portage_dep.py | 13 ++--------- pym/portage_versions.py | 7 ++++-- 5 files changed, 66 insertions(+), 29 deletions(-) diff --git a/bin/ebuild b/bin/ebuild index 6a73dce16..f120f0c14 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -38,7 +38,21 @@ if portage.settings["NOCOLOR"] in ("yes","true") or not sys.stdout.isatty(): 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 @@ -66,7 +80,7 @@ else: 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 @@ -74,7 +88,7 @@ else: 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) diff --git a/bin/repoman b/bin/repoman index b991bd641..7f58346a0 100755 --- a/bin/repoman +++ b/bin/repoman @@ -944,8 +944,9 @@ for x in scanlist: 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") diff --git a/pym/portage.py b/pym/portage.py index 7c8eba97b..7ab191ce5 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -2482,9 +2482,41 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None 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, @@ -2492,8 +2524,8 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None 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: @@ -3193,13 +3225,9 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, 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[:] diff --git a/pym/portage_dep.py b/pym/portage_dep.py index e7c82ff3c..82b434a7b 100644 --- a/pym/portage_dep.py +++ b/pym/portage_dep.py @@ -533,17 +533,8 @@ def match_from_list(mydep, candidate_list): 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. diff --git a/pym/portage_versions.py b/pym/portage_versions.py index 7492d606e..1d9a1972c 100644 --- a/pym/portage_versions.py +++ b/pym/portage_versions.py @@ -54,12 +54,15 @@ def vercmp(ver1, ver2, silent=1): 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])) -- 2.26.2