]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-get.cc
debian/copyright: removed again, this is copied in place by debian/rules
[apt.git] / cmdline / apt-get.cc
index a39b5c55a1aecea583a5177c61ace1e9c2c67594..b379dc82f71389acd4ca85d613cd8cd33f618468 100644 (file)
@@ -1270,12 +1270,30 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
    {
       if(VerTag.empty() == false || DefRel.empty() == false) 
       {
+        bool fuzzy = false;
         // we have a default release, try to locate the pkg. we do it like
         // this because GetCandidateVer() will not "downgrade", that means
         // "apt-get source -t stable apt" won't work on a unstable system
-        for (pkgCache::VerIterator Ver = Pkg.VersionList();
-             Ver.end() == false; Ver++) 
+        for (pkgCache::VerIterator Ver = Pkg.VersionList();; Ver++)
         {
+           // try first only exact matches, later fuzzy matches
+           if (Ver.end() == true)
+           {
+              if (fuzzy == true)
+                 break;
+              fuzzy = true;
+              Ver = Pkg.VersionList();
+              // exit right away from the Pkg.VersionList() loop if we
+              // don't have any versions
+              if (Ver.end() == true)
+                 break;
+           }
+           // We match against a concrete version (or a part of this version)
+           if (VerTag.empty() == false &&
+               (fuzzy == true || Cache.VS().CmpVersion(VerTag, Ver.VerStr()) != 0) && // exact match
+               (fuzzy == false || strncmp(VerTag.c_str(), Ver.VerStr(), VerTag.size()) != 0)) // fuzzy match
+              continue;
+
            for (pkgCache::VerFileIterator VF = Ver.FileList();
                 VF.end() == false; VF++) 
            {
@@ -1288,10 +1306,6 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
                   pkgCache::Flag::NotSource && Pkg.CurrentVer() != Ver)
                  continue;
 
-              // We match against a concrete version (or a part of this version)
-              if (VerTag.empty() == false && strncmp(VerTag.c_str(), Ver.VerStr(), VerTag.size()) != 0)
-                 continue;
-
               // or we match against a release
               if(VerTag.empty() == false ||
                  (VF.File().Archive() != 0 && VF.File().Archive() == DefRel) ||
@@ -1302,10 +1316,9 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
                  // no SourcePkg name, so it is the "binary" name
                  if (Src.empty() == true)
                     Src = TmpSrc;
-                 // no Version, so we try the Version of the SourcePkg -
-                 // and after that the version of the binary package
-                 if (VerTag.empty() == true)
-                    VerTag = Parse.SourceVer();
+                 // the Version we have is possibly fuzzy or includes binUploads,
+                 // so we use the Version of the SourcePkg (empty if same as package)
+                 VerTag = Parse.SourceVer();
                  if (VerTag.empty() == true)
                     VerTag = Ver.VerStr();
                  break;
@@ -1317,9 +1330,11 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
         if (Src.empty() == true) 
         {
            // Sources files have no codename information
-           if (VerTag.empty() == true && DefRel.empty() == false)
-              _error->Warning(_("Ignore unavailable target release '%s' of package '%s'"), DefRel.c_str(), TmpSrc.c_str());
-           DefRel.clear();
+           if (VerTag.empty() == true && DefRel.empty() == false) 
+           {
+              _error->Error(_("Ignore unavailable target release '%s' of package '%s'"), DefRel.c_str(), TmpSrc.c_str());
+              return 0;
+           }
         }
       }
       if (Src.empty() == true)
@@ -1369,7 +1384,8 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
         const string Ver = Parse->Version();
 
         // Ignore all versions which doesn't fit
-        if (VerTag.empty() == false && strncmp(VerTag.c_str(), Ver.c_str(), VerTag.size()) != 0)
+        if (VerTag.empty() == false &&
+            Cache.VS().CmpVersion(VerTag, Ver) != 0) // exact match
            continue;
 
         // Newer version or an exact match? Save the hit
@@ -1386,8 +1402,8 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
       if (Last != 0 || VerTag.empty() == true)
         break;
       //if (VerTag.empty() == false && Last == 0)
-      _error->Warning(_("Ignore unavailable version '%s' of package '%s'"), VerTag.c_str(), TmpSrc.c_str());
-      VerTag.clear();
+      _error->Error(_("Ignore unavailable version '%s' of package '%s'"), VerTag.c_str(), TmpSrc.c_str());
+      return 0;
    }
 
    if (Last == 0 || Last->Jump(Offset) == false)
@@ -2313,6 +2329,7 @@ bool DoSource(CommandLine &CmdL)
    {
       for (unsigned I = 0; I != J; I++)
         ioprintf(cout,_("Fetch source %s\n"),Dsc[I].Package.c_str());
+      delete[] Dsc;
       return true;
    }
    
@@ -2323,6 +2340,7 @@ bool DoSource(CommandLine &CmdL)
       for (; I != Fetcher.UriEnd(); I++)
         cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << 
               I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
+      delete[] Dsc;
       return true;
    }
    
@@ -2348,6 +2366,7 @@ bool DoSource(CommandLine &CmdL)
    if (_config->FindB("APT::Get::Download-only",false) == true)
    {
       c1out << _("Download complete and in download only mode") << endl;
+      delete[] Dsc;
       return true;
    }
 
@@ -2409,7 +2428,8 @@ bool DoSource(CommandLine &CmdL)
       
       _exit(0);
    }
-   
+   delete[] Dsc;
+
    // Wait for the subprocess
    int Status = 0;
    while (waitpid(Process,&Status,0) != Process)