* cmdline/apt-get.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Mon, 18 Jun 2012 11:19:47 +0000 (13:19 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Mon, 18 Jun 2012 11:19:47 +0000 (13:19 +0200)
  - print a friendly message in 'download' if a package can't be
    downloaded (Closes: #677887)

cmdline/apt-get.cc
debian/changelog
test/integration/test-apt-get-download

index 870c772..d4c7f42 100644 (file)
@@ -2362,6 +2362,8 @@ bool DoDownload(CommandLine &CmdL)
 
    pkgRecords Recs(Cache);
    pkgSourceList *SrcList = Cache.GetSourceList();
+   bool gotAll = true;
+
    for (APT::VersionList::const_iterator Ver = verset.begin(); 
         Ver != verset.end(); 
         ++Ver) 
@@ -2372,11 +2374,19 @@ bool DoDownload(CommandLine &CmdL)
       pkgRecords::Parser &rec=Recs.Lookup(Ver.FileList());
       pkgCache::VerFileIterator Vf = Ver.FileList();
       if (Vf.end() == true)
-         return _error->Error("Can not find VerFile");
+      {
+        _error->Error("Can not find VerFile for %s in version %s", Pkg.FullName().c_str(), Ver.VerStr());
+        gotAll = false;
+        continue;
+      }
       pkgCache::PkgFileIterator F = Vf.File();
       pkgIndexFile *index;
       if(SrcList->FindIndex(F, index) == false)
-         return _error->Error("FindIndex failed");
+      {
+        _error->Error(_("Can't find a source to download version '%s' of '%s'"), Ver.VerStr(), Pkg.FullName().c_str());
+        gotAll = false;
+        continue;
+      }
       string uri = index->ArchiveURI(rec.FileName());
       strprintf(descr, _("Downloading %s %s"), Pkg.Name(), Ver.VerStr());
       // get the most appropriate hash
@@ -2392,6 +2402,8 @@ bool DoDownload(CommandLine &CmdL)
       // get the file
       new pkgAcqFile(&Fetcher, uri, hash.toStr(), (*Ver)->Size, descr, Pkg.Name(), ".");
    }
+   if (gotAll == false)
+      return false;
 
    // Just print out the uris and exit if the --print-uris flag was used
    if (_config->FindB("APT::Get::Print-URIs") == true)
index ad5a4a1..2819158 100644 (file)
@@ -20,6 +20,9 @@ apt (0.9.6.1) UNRELEASED; urgency=low
   * buildlib/configure.mak:
     - print a message detailing how to get config.guess and config.sub
       in case they are not in /usr/share/misc (Closes: #677312)
+  * cmdline/apt-get.cc:
+    - print a friendly message in 'download' if a package can't be
+      downloaded (Closes: #677887)
 
  -- David Kalnischkies <kalnischkies@gmail.com>  Thu, 14 Jun 2012 15:45:13 +0200
 
index 4edb7c1..b164f7d 100755 (executable)
@@ -9,6 +9,7 @@ configarchitecture "i386"
 
 buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
 buildsimplenativepackage 'apt' 'all' '2.0' 'unstable'
+insertinstalledpackage 'vrms' 'all' '1.0'
 
 setupaptarchive
 
@@ -26,3 +27,6 @@ testdownload apt_2.0_all.deb apt
 
 DEBFILE="$(readlink -f aptarchive)/pool/apt_2.0_all.deb"
 testequal "'file://${DEBFILE}' apt_2.0_all.deb $(stat -c%s $DEBFILE) sha256:$(sha256sum $DEBFILE | cut -d' ' -f 1)" aptget download apt --print-uris
+
+# deb:677887
+testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms