]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-item.cc
Fixed depends error
[apt.git] / apt-pkg / acquire-item.cc
index 63c47f73622f1c4bd3132e5bdea4d0b071084af2..ddaf260eaada86d068a137f4e426f8be2710805e 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-item.cc,v 1.35 1999/08/03 05:19:41 jgg Exp $
+// $Id: acquire-item.cc,v 1.40 1999/10/31 06:32:27 jgg Exp $
 /* ######################################################################
 
    Acquire Item - Item to acquire
@@ -136,7 +136,7 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location)
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
    DestFile += URItoFileName(Location->PackagesURI());
 
-   // Create the item 
+   // Create the item
    Desc.URI = Location->PackagesURI() + ".gz";
    Desc.Description = Location->PackagesInfo();
    Desc.Owner = this;
@@ -565,8 +565,10 @@ void pkgAcqArchive::Finished()
 /* The file is added to the queue */
 pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,
                       unsigned long Size,string Dsc,string ShortDesc) :
-                       Item(Owner), MD5(MD5)
+                       Item(Owner), Md5Hash(MD5)
 {
+   Retries = _config->FindI("Acquire::Retries",0);
+   
    DestFile = flNotDir(URI);
    
    // Create the item
@@ -597,6 +599,18 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,
 /* */
 void pkgAcqFile::Done(string Message,unsigned long Size,string MD5)
 {
+   // Check the md5
+   if (Md5Hash.empty() == false && MD5.empty() == false)
+   {
+      if (Md5Hash != MD5)
+      {
+        Status = StatError;
+        ErrorText = "MD5Sum mismatch";
+        Rename(DestFile,DestFile + ".FAILED");
+        return;
+      }
+   }
+   
    Item::Done(Message,Size,MD5);
 
    string FileName = LookupTag(Message,"Filename");
@@ -617,9 +631,48 @@ void pkgAcqFile::Done(string Message,unsigned long Size,string MD5)
    if (FileName != DestFile)
    {
       Local = true;
-      Desc.URI = "copy:" + FileName;
+      if (_config->FindB("Acquire::Source-Symlinks",true) == false)
+      {
+        Desc.URI = "copy:" + FileName;
+        QueueURI(Desc);
+        return;
+      }
+      
+      // Erase the file if it is a symlink so we can overwrite it
+      struct stat St;
+      if (lstat(DestFile.c_str(),&St) == 0)
+      {
+        if (S_ISLNK(St.st_mode) != 0)
+           unlink(DestFile.c_str());
+      }
+      
+      // Symlink the file
+      if (symlink(FileName.c_str(),DestFile.c_str()) != 0)
+      {
+        ErrorText = "Link to " + DestFile + " failure ";
+        Status = StatError;
+        Complete = false;
+      }      
+   }
+}
+                                                                       /*}}}*/
+// AcqFile::Failed - Failure handler                                   /*{{{*/
+// ---------------------------------------------------------------------
+/* Here we try other sources */
+void pkgAcqFile::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
+{
+   ErrorText = LookupTag(Message,"Message");
+   
+   // This is the retry counter
+   if (Retries != 0 &&
+       Cnf->LocalOnly == false &&
+       StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
+   {
+      Retries--;
       QueueURI(Desc);
       return;
    }
+   
+   Item::Failed(Message,Cnf);
 }
                                                                        /*}}}*/