* apt-pkg/acquire-item.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Fri, 9 Apr 2010 13:38:48 +0000 (15:38 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Fri, 9 Apr 2010 13:38:48 +0000 (15:38 +0200)
  - Acquire::ForceHash to force method for expected hash
  - display MD5Sum in --print-uris if not forced to use another method
    instead of displaying the strongest available (Closes: #576420)

apt-pkg/acquire-item.cc
cmdline/apt-get.cc
debian/changelog
doc/examples/configure-index
test/makefile

index 4f0abbb..916fca7 100644 (file)
@@ -1327,7 +1327,8 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
    the archive is already available in the cache and stashs the MD5 for
    checking later. */
 bool pkgAcqArchive::QueueNext()
-{   
+{
+   string const ForceHash = _config->Find("Acquire::ForceHash");
    for (; Vf.end() == false; Vf++)
    {
       // Ignore not source sources
@@ -1350,12 +1351,25 @@ bool pkgAcqArchive::QueueNext()
         return false;
       
       string PkgFile = Parse.FileName();
-      if(Parse.SHA256Hash() != "")
-        ExpectedHash = HashString("SHA256", Parse.SHA256Hash());
-      else if (Parse.SHA1Hash() != "")
-        ExpectedHash = HashString("SHA1", Parse.SHA1Hash());
-      else 
-        ExpectedHash = HashString("MD5Sum", Parse.MD5Hash());
+      if (ForceHash.empty() == false)
+      {
+        if(stringcasecmp(ForceHash, "sha256") == 0)
+           ExpectedHash = HashString("SHA256", Parse.SHA256Hash());
+        else if (stringcasecmp(ForceHash, "sha1") == 0)
+           ExpectedHash = HashString("SHA1", Parse.SHA1Hash());
+        else
+           ExpectedHash = HashString("MD5Sum", Parse.MD5Hash());
+      }
+      else
+      {
+        string Hash;
+        if ((Hash = Parse.SHA256Hash()).empty() == false)
+           ExpectedHash = HashString("SHA256", Hash);
+        else if ((Hash = Parse.SHA1Hash()).empty() == false)
+           ExpectedHash = HashString("SHA1", Hash);
+        else
+           ExpectedHash = HashString("MD5Sum", Parse.MD5Hash());
+      }
       if (PkgFile.empty() == true)
         return _error->Error(_("The package index files are corrupted. No Filename: "
                              "field for package %s."),
index 416d316..7c42e67 100644 (file)
@@ -815,8 +815,14 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
    // Create the download object
    pkgAcquire Fetcher;
    AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));   
-   if (Fetcher.Setup(&Stat, _config->FindB("APT::Get::Print-URIs", false)
-       ? "" : _config->FindDir("Dir::Cache::Archives")) == false)
+   if (_config->FindB("APT::Get::Print-URIs", false) == true)
+   {
+      // force a hashsum for compatibility reasons
+      _config->CndSet("Acquire::ForceHash", "md5sum");
+      if (Fetcher.Setup(&Stat, "") == false)
+        return false;
+   }
+   else if (Fetcher.Setup(&Stat, _config->FindDir("Dir::Cache::Archives")) == false)
       return false;
 
    // Read the source list
@@ -1441,6 +1447,9 @@ bool DoUpdate(CommandLine &CmdL)
    // Just print out the uris an exit if the --print-uris flag was used
    if (_config->FindB("APT::Get::Print-URIs") == true)
    {
+      // force a hashsum for compatibility reasons
+      _config->CndSet("Acquire::ForceHash", "md5sum");
+
       // get a fetcher
       pkgAcquire Fetcher;
       if (Fetcher.Setup(&Stat) == false)
index ffab08e..4cdbd4d 100644 (file)
@@ -11,8 +11,12 @@ apt (0.7.26~exp4) experimental; urgency=low
     - check for and create directories in Setup if needed instead of
       error out unfriendly in the Constructor (Closes: #523920, #525783)
     - optional handle a lock file in Setup()
+  * apt-pkg/acquire-item.cc:
+    - Acquire::ForceHash to force method for expected hash
   * cmdline/apt-get.cc:
     - remove the lock file handling and let Acquire take care of it instead
+    - display MD5Sum in --print-uris if not forced to use another method
+      instead of displaying the strongest available (Closes: #576420)
 
  -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 03 Apr 2010 14:58:39 +0200
 
index 3167e46..d168417 100644 (file)
@@ -169,6 +169,7 @@ Acquire
   Queue-Mode "host";       // host|access
   Retries "0";
   Source-Symlinks "true";
+  ForceHash "sha256"; // hashmethod used for expected hash: sha256, sha1 or md5sum
 
   PDiffs "true";     // try to get the IndexFile diffs
   PDiffs::FileLimit "4"; // don't use diffs if we would need more than 4 diffs
index b8c104e..52adb96 100644 (file)
@@ -68,7 +68,7 @@ SOURCE = test_udevcdrom.cc
 include $(PROGRAM_H)
 
 # Program for checking rpm versions
-PROGRAM=rpmver
-SLIBS = -lapt-pkg -lrpm
-SOURCE = rpmver.cc
-include $(PROGRAM_H)
+#PROGRAM=rpmver
+#SLIBS = -lapt-pkg -lrpm
+#SOURCE = rpmver.cc
+#include $(PROGRAM_H)