Преглед изворни кода

improve error message for apt-get source pkg:arch{=ver,/release}

Michael Vogt пре 12 година
родитељ
комит
37f45a579d
2 измењених фајлова са 24 додато и 4 уклоњено
  1. 14 4
      cmdline/apt-get.cc
  2. 10 0
      test/integration/test-apt-get-source-arch

+ 14 - 4
cmdline/apt-get.cc

@@ -269,15 +269,15 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
 		  break;
 	    }
 
+            // ignore arches that are not for us
+            if (ArchTag != "" && Ver.Arch() != ArchTag)
+               continue;
+
             // pick highest version for the arch unless the user wants
             // something else
             if (ArchTag != "" && VerTag == "" && RelTag == "")
-            {
-               if(Ver.Arch() != ArchTag)
-                  continue;
                if(Cache->VS().CmpVersion(VerTag, Ver.VerStr()) < 0)
                   VerTag = Ver.VerStr();
-            }
 
 	    // We match against a concrete version (or a part of this version)
 	    if (VerTag.empty() == false &&
@@ -320,6 +320,16 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
 	 }
       }
 
+      if (Src == "" && ArchTag != "")
+      {
+          _error->Error(_("Can not find a package '%s' with version '%s' and "
+                          "release '%s'"), Pkg.FullName().c_str(), 
+                                           VerTag.c_str(), RelTag.c_str());
+         Src = Name;
+         return 0;
+      }
+
+
       if (Src.empty() == true)
       {
 	 // if we don't have found a fitting package yet so we will

+ 10 - 0
test/integration/test-apt-get-source-arch

@@ -58,3 +58,13 @@ Need to get 0 B of source archives.
 testequal "$HEADER
 E: Can not find a package for architecture 'not-a-available-arch'
 E: Unable to find a source package for foo:not-a-available-arch" aptget source -q --print-uris foo:not-a-available-arch
+
+# error on unavailable version for arch
+testequal "$HEADER
+E: Can not find a package 'foo:amd64' with version '2.0' and release ''
+E: Unable to find a source package for foo:amd64=2.0" aptget source -q --print-uris foo:amd64=2.0
+
+# error on unavailable release for arch 
+testequal "$HEADER
+E: Can not find a package 'foo:amd64' with version '' and release 'oldstable'
+E: Unable to find a source package for foo:amd64/oldstable" aptget source -q --print-uris foo:amd64/oldstable