]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-item.cc
Configuration fixes
[apt.git] / apt-pkg / acquire-item.cc
index 532d4e6f2f1c4eb4c62d790b4ccb090cbfc4fc2e..59301784e04b3ce79f0a56a1c1926bef8a0b42c8 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-item.cc,v 1.12 1998/11/13 07:08:48 jgg Exp $
+// $Id: acquire-item.cc,v 1.17 1998/12/11 06:32:33 jgg Exp $
 /* ######################################################################
 
    Acquire Item - Item to acquire
 /* ######################################################################
 
    Acquire Item - Item to acquire
@@ -9,7 +9,7 @@
    cannot create an item that fetches two uri's to two files at the same 
    time. The pkgAcqIndex class creates a second class upon instantiation
    to fetch the other index files because of this.
    cannot create an item that fetches two uri's to two files at the same 
    time. The pkgAcqIndex class creates a second class upon instantiation
    to fetch the other index files because of this.
-   
+
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
@@ -54,9 +54,19 @@ pkgAcquire::Item::~Item()
 void pkgAcquire::Item::Failed(string Message)
 {
    Status = StatIdle;
 void pkgAcquire::Item::Failed(string Message)
 {
    Status = StatIdle;
+   ErrorText = LookupTag(Message,"Message");
    if (QueueCounter <= 1)
    {
    if (QueueCounter <= 1)
    {
-      ErrorText = LookupTag(Message,"Message");
+      /* This indicates that the file is not available right now but might
+         be sometime later. If we do a retry cycle then this should be 
+        retried */
+      if (StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
+      {
+        Status = StatIdle;
+        Owner->Dequeue(this);
+        return;
+      }
+      
       Status = StatError;
       Owner->Dequeue(this);
    }   
       Status = StatError;
       Owner->Dequeue(this);
    }   
@@ -147,9 +157,9 @@ string pkgAcqIndex::Custom600Headers()
    
    struct stat Buf;
    if (stat(Final.c_str(),&Buf) != 0)
    
    struct stat Buf;
    if (stat(Final.c_str(),&Buf) != 0)
-      return string();
+      return "\nIndex-File: true";
    
    
-   return "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
+   return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
 }
                                                                        /*}}}*/
 // AcqIndex::Done - Finished a fetch                                   /*{{{*/
 }
                                                                        /*}}}*/
 // AcqIndex::Done - Finished a fetch                                   /*{{{*/
@@ -224,6 +234,14 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5)
    Mode = "gzip";
 }
                                                                        /*}}}*/
    Mode = "gzip";
 }
                                                                        /*}}}*/
+// AcqIndex::Describe - Describe the Item                              /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string pkgAcqIndex::Describe()
+{
+   return Location->PackagesURI();
+}
+                                                                       /*}}}*/
 
 // AcqIndexRel::pkgAcqIndexRel - Constructor                           /*{{{*/
 // ---------------------------------------------------------------------
 
 // AcqIndexRel::pkgAcqIndexRel - Constructor                           /*{{{*/
 // ---------------------------------------------------------------------
@@ -259,9 +277,9 @@ string pkgAcqIndexRel::Custom600Headers()
    
    struct stat Buf;
    if (stat(Final.c_str(),&Buf) != 0)
    
    struct stat Buf;
    if (stat(Final.c_str(),&Buf) != 0)
-      return string();
+      return "\nIndex-File: true";
    
    
-   return "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
+   return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
 }
                                                                        /*}}}*/
 // AcqIndexRel::Done - Item downloaded OK                              /*{{{*/
 }
                                                                        /*}}}*/
 // AcqIndexRel::Done - Item downloaded OK                              /*{{{*/
@@ -302,16 +320,36 @@ void pkgAcqIndexRel::Done(string Message,unsigned long Size,string MD5)
    Rename(DestFile,FinalFile);
 }
                                                                        /*}}}*/
    Rename(DestFile,FinalFile);
 }
                                                                        /*}}}*/
+// AcqIndexRel::Describe - Describe the Item                           /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string pkgAcqIndexRel::Describe()
+{
+   return Location->ReleaseURI();
+}
+                                                                       /*}}}*/
 
 // AcqArchive::AcqArchive - Constructor                                        /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
 
 // AcqArchive::AcqArchive - Constructor                                        /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
-                            pkgRecords *Recs,pkgCache::VerIterator const &Version) :
-               Item(Owner), Version(Version), Sources(Sources), Recs(Recs)
+                            pkgRecords *Recs,pkgCache::VerIterator const &Version,
+                            string &StoreFilename) :
+               Item(Owner), Version(Version), Sources(Sources), Recs(Recs), 
+               StoreFilename(StoreFilename), Vf(Version.FileList())
 {
    // Select a source
 {
    // Select a source
-   pkgCache::VerFileIterator Vf = Version.FileList();
+   if (QueueNext() == false && _error->PendingError() == false)
+      _error->Error("I wasn't able to locate file for the %s package. "
+                   "This might mean you need to manually fix this package.",
+                   Version.ParentPkg().Name());
+}
+                                                                       /*}}}*/
+// AcqArchive::QueueNext - Queue the next file source                  /*{{{*/
+// ---------------------------------------------------------------------
+/* This queues the next available file version for download. */
+bool pkgAcqArchive::QueueNext()
+{
    for (; Vf.end() == false; Vf++)
    {
       // Ignore not source sources
    for (; Vf.end() == false; Vf++)
    {
       // Ignore not source sources
@@ -331,17 +369,14 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
       // Grab the text package record
       pkgRecords::Parser &Parse = Recs->Lookup(Vf);
       if (_error->PendingError() == true)
       // Grab the text package record
       pkgRecords::Parser &Parse = Recs->Lookup(Vf);
       if (_error->PendingError() == true)
-        return;
+        return false;
       
       PkgFile = Parse.FileName();
       MD5 = Parse.MD5Hash();
       if (PkgFile.empty() == true)
       
       PkgFile = Parse.FileName();
       MD5 = Parse.MD5Hash();
       if (PkgFile.empty() == true)
-      {
-        _error->Error("Unable to locate a file name for package %s, "
-                      "perhaps the package files are corrupted.",
-                      Version.ParentPkg().Name());
-        return;
-      }
+        return _error->Error("The package index files are corrupted. No Filename: "
+                             "field for package %s."
+                             ,Version.ParentPkg().Name());
 
       // See if we already have the file.
       FileSize = Version->Size;
 
       // See if we already have the file.
       FileSize = Version->Size;
@@ -355,8 +390,8 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
            Complete = true;
            Local = true;
            Status = StatDone;
            Complete = true;
            Local = true;
            Status = StatDone;
-           DestFile = FinalFile;
-           return;
+           StoreFilename = DestFile = FinalFile;
+           return true;
         }
         
         /* Hmm, we have a file and its size does not match, this shouldnt
         }
         
         /* Hmm, we have a file and its size does not match, this shouldnt
@@ -372,14 +407,12 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
       Desc.Owner = this;
       Desc.ShortDesc = Version.ParentPkg().Name();
       QueueURI(Desc);
       Desc.Owner = this;
       Desc.ShortDesc = Version.ParentPkg().Name();
       QueueURI(Desc);
-      
-      return;
+
+      Vf++;
+      return true;
    }
    }
-   
-  _error->Error("I wasn't able to locate file for the %s package. "
-               "This probably means you need to rerun update.",
-               Version.ParentPkg().Name());
-}
+   return false;
+}   
                                                                        /*}}}*/
 // AcqArchive::Done - Finished fetching                                        /*{{{*/
 // ---------------------------------------------------------------------
                                                                        /*}}}*/
 // AcqArchive::Done - Finished fetching                                        /*{{{*/
 // ---------------------------------------------------------------------
@@ -415,11 +448,11 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash)
    }
 
    Complete = true;
    }
 
    Complete = true;
-   
-   // We have to copy it into place
+
+   // Reference filename
    if (FileName != DestFile)
    {
    if (FileName != DestFile)
    {
-      DestFile = FileName;
+      StoreFilename = DestFile = FileName;
       Local = true;
       return;
    }
       Local = true;
       return;
    }
@@ -429,7 +462,25 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash)
    FinalFile += flNotDir(DestFile);
    Rename(DestFile,FinalFile);
    
    FinalFile += flNotDir(DestFile);
    Rename(DestFile,FinalFile);
    
-   DestFile = FinalFile;
+   StoreFilename = DestFile = FinalFile;
    Complete = true;
 }
                                                                        /*}}}*/
    Complete = true;
 }
                                                                        /*}}}*/
+// AcqArchive::Describe - Describe the Item                            /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string pkgAcqArchive::Describe()
+{
+   return Desc.URI;
+}
+                                                                       /*}}}*/
+// AcqArchive::Failed - Failure handler                                        /*{{{*/
+// ---------------------------------------------------------------------
+/* Here we try other sources */
+void pkgAcqArchive::Failed(string Message)
+{
+   ErrorText = LookupTag(Message,"Message");
+   if (QueueNext() == false)
+      Item::Failed(Message);
+}
+                                                                       /*}}}*/