Merged from trunk 5196:5205
authorFabian Groffen <grobian@gentoo.org>
Fri, 8 Dec 2006 08:05:32 +0000 (08:05 -0000)
committerFabian Groffen <grobian@gentoo.org>
Fri, 8 Dec 2006 08:05:32 +0000 (08:05 -0000)
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
bin/repoman
pym/portage.py
pym/portage_dep.py
pym/portage_versions.py

index 6a73dce16094536b3326b397164c8abc12ebb4d2..f120f0c145f7913495e72db45a9bae6af3663c67 100755 (executable)
@@ -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)
 
index b991bd6416bff97b4d7500b1d76f59a49e2157f4..7f58346a021bcfb80b6250e5c5f60865a0fe8616 100755 (executable)
@@ -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")
index 7c8eba97bec280826bbbda2adac94c8662e9759e..7ab191ce582c7e1bcd95d5b93312c2b5510ab9fd 100644 (file)
@@ -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[:]
index e7c82ff3c221cd21ef000558f254c970d8f641eb..82b434a7b12c2629c7a12c40d87269ae72a8cb0d 100644 (file)
@@ -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.
index 7492d606e3ed0e5b578ee1ac104896aa796aad99..1d9a1972c016643be9171edd50891896e2feae3b 100644 (file)
@@ -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]))