Ver código fonte

* cherry-picked patches from apt--fixes and apt--mvo

Patches applied:

 * michael.vogt@ubuntu.com--2005/apt--fixes--0--patch-14
   * added Hashsum support for file and cdrom 

 * michael.vogt@ubuntu.com--2005/apt--fixes--0--patch-18
   * Change pkgPolicy::Pin from private to protected 

 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-47
   * improve the timeout handling (again)
Michael Vogt 21 anos atrás
pai
commit
bdcf3b4936
7 arquivos alterados com 32 adições e 6 exclusões
  1. 4 2
      apt-pkg/acquire-item.cc
  2. 2 2
      apt-pkg/policy.h
  3. 1 1
      cmdline/apt-get.cc
  4. 8 0
      debian/changelog
  5. 7 0
      methods/cdrom.cc
  6. 3 0
      methods/connect.cc
  7. 7 1
      methods/file.cc

+ 4 - 2
apt-pkg/acquire-item.cc

@@ -401,7 +401,8 @@ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
    unlink(Final.c_str());
    unlink(Final.c_str());
 
 
    // if we get a timeout if fail
    // if we get a timeout if fail
-   if(LookupTag(Message,"FailReason") == "Timeout") {
+   if(LookupTag(Message,"FailReason") == "Timeout" || 
+      LookupTag(Message,"FailReason") == "TmpResolveFailure") {
       Item::Failed(Message,Cnf);
       Item::Failed(Message,Cnf);
       return;
       return;
    }
    }
@@ -904,7 +905,8 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash,
       {
       {
 	 Status = StatError;
 	 Status = StatError;
 	 ErrorText = _("MD5Sum mismatch");
 	 ErrorText = _("MD5Sum mismatch");
-	 Rename(DestFile,DestFile + ".FAILED");
+	 if(FileExists(DestFile))
+	    Rename(DestFile,DestFile + ".FAILED");
 	 return;
 	 return;
       }
       }
    }
    }

+ 2 - 2
apt-pkg/policy.h

@@ -45,6 +45,8 @@ using std::vector;
 
 
 class pkgPolicy : public pkgDepCache::Policy
 class pkgPolicy : public pkgDepCache::Policy
 {
 {
+   protected:
+
    struct Pin
    struct Pin
    {
    {
       pkgVersionMatch::MatchType Type;
       pkgVersionMatch::MatchType Type;
@@ -58,8 +60,6 @@ class pkgPolicy : public pkgDepCache::Policy
       string Pkg;
       string Pkg;
    };
    };
    
    
-   protected:
-   
    Pin *Pins;
    Pin *Pins;
    signed short *PFPriority;
    signed short *PFPriority;
    vector<Pin> Defaults;
    vector<Pin> Defaults;

+ 1 - 1
cmdline/apt-get.cc

@@ -1659,7 +1659,7 @@ bool DoInstall(CommandLine &CmdL)
    // See if we need to prompt
    // See if we need to prompt
    if (Cache->InstCount() == ExpectedInst && Cache->DelCount() == 0)
    if (Cache->InstCount() == ExpectedInst && Cache->DelCount() == 0)
       return InstallPackages(Cache,false,false);
       return InstallPackages(Cache,false,false);
-   
+
    return InstallPackages(Cache,false);   
    return InstallPackages(Cache,false);   
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 8 - 0
debian/changelog

@@ -3,6 +3,14 @@ apt (0.6.40.2) unstable; urgency=low
   * improved the support for "error" and "conffile" reporting from
   * improved the support for "error" and "conffile" reporting from
     dpkg, added the format to README.progress-reporting
     dpkg, added the format to README.progress-reporting
   * added README.progress-reporting to the apt-doc package
   * added README.progress-reporting to the apt-doc package
+  * Do md5sum checking for file and cdrom method (closes: #319142)
+  * Change pkgPolicy::Pin from private to protected to let subclasses
+    access it too (closes: #321799)
+  * methods/connect.cc:
+    - send failure reason for EAI_AGAIN (TmpResolveFailure) to acuire-item
+  * apt-pkg/acquire-item.cc:
+    - fail early if a FailReason is TmpResolveFailure (avoids hangs during
+      the install when no network is available)
 
 
  --
  --
 
 

+ 7 - 0
methods/cdrom.cc

@@ -13,6 +13,7 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
+#include <apt-pkg/hashes.h>
 
 
 #include <sys/stat.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <unistd.h>
@@ -180,6 +181,12 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
       CurrentID = NewID;
       CurrentID = NewID;
    Res.LastModified = Buf.st_mtime;
    Res.LastModified = Buf.st_mtime;
    Res.Size = Buf.st_size;
    Res.Size = Buf.st_size;
+
+   Hashes Hash;
+   FileFd Fd(Res.Filename, FileFd::ReadOnly);
+   Hash.AddFD(Fd.Fd(), Fd.Size());
+   Res.TakeHashes(Hash);
+
    URIDone(Res);
    URIDone(Res);
    return true;
    return true;
 }
 }

+ 3 - 0
methods/connect.cc

@@ -166,8 +166,11 @@ bool Connect(string Host,int Port,const char *Service,int DefPort,int &Fd,
 	    }
 	    }
 	    
 	    
 	    if (Res == EAI_AGAIN)
 	    if (Res == EAI_AGAIN)
+	    {
+	       Owner->SetFailExtraMsg("\nFailReason: TmpResolveFailure");
 	       return _error->Error(_("Temporary failure resolving '%s'"),
 	       return _error->Error(_("Temporary failure resolving '%s'"),
 				    Host.c_str());
 				    Host.c_str());
+	    }
 	    return _error->Error(_("Something wicked happened resolving '%s:%s' (%i)"),
 	    return _error->Error(_("Something wicked happened resolving '%s:%s' (%i)"),
 				 Host.c_str(),ServStr,Res);
 				 Host.c_str(),ServStr,Res);
 	 }
 	 }

+ 7 - 1
methods/file.cc

@@ -15,6 +15,8 @@
 // Include Files							/*{{{*/
 // Include Files							/*{{{*/
 #include <apt-pkg/acquire-method.h>
 #include <apt-pkg/acquire-method.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
+#include <apt-pkg/hashes.h>
+#include <apt-pkg/fileutl.h>
 
 
 #include <sys/stat.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <unistd.h>
@@ -75,7 +77,11 @@ bool FileMethod::Fetch(FetchItem *Itm)
    
    
    if (Res.Filename.empty() == true)
    if (Res.Filename.empty() == true)
       return _error->Error(_("File not found"));
       return _error->Error(_("File not found"));
-   
+
+   Hashes Hash;
+   FileFd Fd(Res.Filename, FileFd::ReadOnly);
+   Hash.AddFD(Fd.Fd(), Fd.Size());
+   Res.TakeHashes(Hash);
    URIDone(Res);
    URIDone(Res);
    return true;
    return true;
 }
 }