]> git.saurik.com Git - apt.git/commitdiff
Arranged to rename downloaded files to include all impo...
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:52:39 +0000 (16:52 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:52:39 +0000 (16:52 +0000)
Author: jgg
Date: 1999-02-01 02:22:11 GMT
Arranged to rename downloaded files to include all important info

apt-pkg/acquire-item.cc
apt-pkg/acquire-item.h
apt-pkg/cacheiterators.h
apt-pkg/deb/deblistparser.cc
apt-pkg/pkgcache.h
doc/cache.sgml

index e64190078e0c080eb2154e92d9864f2970507aa9..beb4260ac38e7be5199f7c009684f99998aaae59 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-item.cc,v 1.21 1999/01/31 22:25:34 jgg Exp $
+// $Id: acquire-item.cc,v 1.22 1999/02/01 02:22:11 jgg Exp $
 /* ######################################################################
 
    Acquire Item - Item to acquire
 /* ######################################################################
 
    Acquire Item - Item to acquire
@@ -59,7 +59,7 @@ void pkgAcquire::Item::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
    {
       /* 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
    {
       /* 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 */
+        retried [CDROMs] */
       if (Cnf->LocalOnly == true &&
          StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
       {
       if (Cnf->LocalOnly == true &&
          StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
       {
@@ -75,7 +75,8 @@ void pkgAcquire::Item::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
                                                                        /*}}}*/
 // Acquire::Item::Start - Item has begun to download                   /*{{{*/
 // ---------------------------------------------------------------------
                                                                        /*}}}*/
 // Acquire::Item::Start - Item has begun to download                   /*{{{*/
 // ---------------------------------------------------------------------
-/* */
+/* Stash status and the file size. Note that setting Complete means 
+   sub-phases of the acquire process such as decompresion are operating */
 void pkgAcquire::Item::Start(string Message,unsigned long Size)
 {
    Status = StatFetching;
 void pkgAcquire::Item::Start(string Message,unsigned long Size)
 {
    Status = StatFetching;
@@ -349,7 +350,8 @@ void pkgAcqIndexRel::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
 
 // AcqArchive::AcqArchive - Constructor                                        /*{{{*/
 // ---------------------------------------------------------------------
 
 // AcqArchive::AcqArchive - Constructor                                        /*{{{*/
 // ---------------------------------------------------------------------
-/* */
+/* This just sets up the initial fetch environment and queues the first
+   possibilitiy */
 pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
                             pkgRecords *Recs,pkgCache::VerIterator const &Version,
                             string &StoreFilename) :
 pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
                             pkgRecords *Recs,pkgCache::VerIterator const &Version,
                             string &StoreFilename) :
@@ -358,6 +360,11 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
 {
    Retries = _config->FindI("Acquire::Retries",0);
       
 {
    Retries = _config->FindI("Acquire::Retries",0);
       
+   // Generate the final file name as: package_version_arch.deb
+   StoreFilename = QuoteString(Version.ParentPkg().Name(),"_:") + '_' +
+                   QuoteString(Version.VerStr(),"_:") + '_' +
+                   QuoteString(Version.Arch(),"_:") + ".deb";
+   
    // Select a source
    if (QueueNext() == false && _error->PendingError() == false)
       _error->Error("I wasn't able to locate file for the %s package. "
    // Select a source
    if (QueueNext() == false && _error->PendingError() == false)
       _error->Error("I wasn't able to locate file for the %s package. "
@@ -367,7 +374,9 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
                                                                        /*}}}*/
 // AcqArchive::QueueNext - Queue the next file source                  /*{{{*/
 // ---------------------------------------------------------------------
                                                                        /*}}}*/
 // AcqArchive::QueueNext - Queue the next file source                  /*{{{*/
 // ---------------------------------------------------------------------
-/* This queues the next available file version for download. */
+/* This queues the next available file version for download. It checks if
+   the archive is already available in the cache and stashs the MD5 for
+   checking later. */
 bool pkgAcqArchive::QueueNext()
 {
    for (; Vf.end() == false; Vf++)
 bool pkgAcqArchive::QueueNext()
 {
    for (; Vf.end() == false; Vf++)
@@ -398,7 +407,7 @@ bool pkgAcqArchive::QueueNext()
                              "field for package %s."
                              ,Version.ParentPkg().Name());
 
                              "field for package %s."
                              ,Version.ParentPkg().Name());
 
-      // See if we already have the file.
+      // See if we already have the file. (Legacy filenames)
       FileSize = Version->Size;
       string FinalFile = _config->FindDir("Dir::Cache::Archives") + flNotDir(PkgFile);
       struct stat Buf;
       FileSize = Version->Size;
       string FinalFile = _config->FindDir("Dir::Cache::Archives") + flNotDir(PkgFile);
       struct stat Buf;
@@ -418,8 +427,27 @@ bool pkgAcqArchive::QueueNext()
            happen.. */
         unlink(FinalFile.c_str());
       }
            happen.. */
         unlink(FinalFile.c_str());
       }
-      
-      DestFile = _config->FindDir("Dir::Cache::Archives") + "partial/" + flNotDir(PkgFile);
+
+      // Check it again using the new style output filenames
+      FinalFile = _config->FindDir("Dir::Cache::Archives") + flNotDir(StoreFilename);
+      if (stat(FinalFile.c_str(),&Buf) == 0)
+      {
+        // Make sure the size matches
+        if ((unsigned)Buf.st_size == Version->Size)
+        {
+           Complete = true;
+           Local = true;
+           Status = StatDone;
+           StoreFilename = DestFile = FinalFile;
+           return true;
+        }
+        
+        /* Hmm, we have a file and its size does not match, this shouldnt
+           happen.. */
+        unlink(FinalFile.c_str());
+      }
+
+      DestFile = _config->FindDir("Dir::Cache::Archives") + "partial/" + flNotDir(StoreFilename);
       
       // Create the item
       Desc.URI = Location->ArchiveURI(PkgFile);
       
       // Create the item
       Desc.URI = Location->ArchiveURI(PkgFile);
@@ -479,7 +507,7 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash)
    
    // Done, move it into position
    string FinalFile = _config->FindDir("Dir::Cache::Archives");
    
    // Done, move it into position
    string FinalFile = _config->FindDir("Dir::Cache::Archives");
-   FinalFile += flNotDir(DestFile);
+   FinalFile += flNotDir(StoreFilename);
    Rename(DestFile,FinalFile);
    
    StoreFilename = DestFile = FinalFile;
    Rename(DestFile,FinalFile);
    
    StoreFilename = DestFile = FinalFile;
index 4429b1ceb8cef4cf1ac516cf36ded10be729564a..fd01bbb9a32c6323bdcf4d9f9fe2710a971308ee 100644 (file)
@@ -1,19 +1,19 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-item.h,v 1.15 1999/01/31 22:25:34 jgg Exp $
+// $Id: acquire-item.h,v 1.16 1999/02/01 02:22:11 jgg Exp $
 /* ######################################################################
 
    Acquire Item - Item to acquire
 
    When an item is instantiated it will add it self to the local list in
    the Owner Acquire class. Derived classes will then call QueueURI to 
 /* ######################################################################
 
    Acquire Item - Item to acquire
 
    When an item is instantiated it will add it self to the local list in
    the Owner Acquire class. Derived classes will then call QueueURI to 
-   register all the URI's they wish to fetch for at the initial moment.   
+   register all the URI's they wish to fetch at the initial moment.   
    
    Two item classes are provided to provide functionality for downloading
    of Index files and downloading of Packages.
    
    A Archive class is provided for downloading .deb files. It does Md5
    
    Two item classes are provided to provide functionality for downloading
    of Index files and downloading of Packages.
    
    A Archive class is provided for downloading .deb files. It does Md5
-   checking and source location.
+   checking and source location as well as a retry algorithm.
    
    ##################################################################### */
                                                                        /*}}}*/
    
    ##################################################################### */
                                                                        /*}}}*/
@@ -33,11 +33,13 @@ class pkgAcquire::Item
 {  
    protected:
    
 {  
    protected:
    
+   // Some private helper methods for registering URIs
    pkgAcquire *Owner;
    inline void QueueURI(ItemDesc &Item)
                  {Owner->Enqueue(Item);};
    inline void Dequeue() {Owner->Dequeue(this);};
    
    pkgAcquire *Owner;
    inline void QueueURI(ItemDesc &Item)
                  {Owner->Enqueue(Item);};
    inline void Dequeue() {Owner->Dequeue(this);};
    
+   // Safe rename function with timestamp preservation
    void Rename(string From,string To);
    
    public:
    void Rename(string From,string To);
    
    public:
@@ -57,14 +59,16 @@ class pkgAcquire::Item
    // File to write the fetch into
    string DestFile;
 
    // File to write the fetch into
    string DestFile;
 
+   // Action members invoked by the worker
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
    virtual void Done(string Message,unsigned long Size,string Md5Hash);
    virtual void Start(string Message,unsigned long Size);
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
    virtual void Done(string Message,unsigned long Size,string Md5Hash);
    virtual void Start(string Message,unsigned long Size);
+   virtual string Custom600Headers() {return string();};
+   
+   // Inquire functions
    virtual string MD5Sum() {return string();};
    virtual string Describe() = 0;
    virtual string MD5Sum() {return string();};
    virtual string Describe() = 0;
-   
-   virtual string Custom600Headers() {return string();};
-      
+         
    Item(pkgAcquire *Owner);
    virtual ~Item();
 };
    Item(pkgAcquire *Owner);
    virtual ~Item();
 };
@@ -81,6 +85,7 @@ class pkgAcqIndex : public pkgAcquire::Item
    
    public:
    
    
    public:
    
+   // Specialized action members
    virtual void Done(string Message,unsigned long Size,string Md5Hash);   
    virtual string Custom600Headers();
    virtual string Describe();
    virtual void Done(string Message,unsigned long Size,string Md5Hash);   
    virtual string Custom600Headers();
    virtual string Describe();
@@ -98,6 +103,7 @@ class pkgAcqIndexRel : public pkgAcquire::Item
    
    public:
    
    
    public:
    
+   // Specialized action members
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
    virtual void Done(string Message,unsigned long Size,string Md5Hash);   
    virtual string Custom600Headers();
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
    virtual void Done(string Message,unsigned long Size,string Md5Hash);   
    virtual string Custom600Headers();
@@ -111,6 +117,7 @@ class pkgAcqArchive : public pkgAcquire::Item
 {
    protected:
    
 {
    protected:
    
+   // State information for the retry mechanism
    pkgCache::VerIterator Version;
    pkgAcquire::ItemDesc Desc;
    pkgSourceList *Sources;
    pkgCache::VerIterator Version;
    pkgAcquire::ItemDesc Desc;
    pkgSourceList *Sources;
@@ -119,15 +126,17 @@ class pkgAcqArchive : public pkgAcquire::Item
    string &StoreFilename;
    pkgCache::VerFileIterator Vf;
    unsigned int Retries;
    string &StoreFilename;
    pkgCache::VerFileIterator Vf;
    unsigned int Retries;
-   
+
+   // Queue the next available file for download.
    bool QueueNext();
    
    public:
    
    bool QueueNext();
    
    public:
    
+   // Specialized action members
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual string MD5Sum() {return MD5;};
    virtual void Done(string Message,unsigned long Size,string Md5Hash);
    virtual string Describe();
    virtual void Done(string Message,unsigned long Size,string Md5Hash);
    virtual string Describe();
+   virtual string MD5Sum() {return MD5;};
    
    pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
                 pkgRecords *Recs,pkgCache::VerIterator const &Version,
    
    pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
                 pkgRecords *Recs,pkgCache::VerIterator const &Version,
index 1de574634239f741cf1ad4ab8da31768b383b027..6e71e8c8de844d334c65df078a787f9bffc841f3 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: cacheiterators.h,v 1.11 1998/12/14 08:07:28 jgg Exp $
+// $Id: cacheiterators.h,v 1.12 1999/02/01 02:22:11 jgg Exp $
 /* ######################################################################
    
    Cache Iterators - Iterators for navigating the cache structure
 /* ######################################################################
    
    Cache Iterators - Iterators for navigating the cache structure
@@ -120,6 +120,7 @@ class pkgCache::VerIterator
    
    inline const char *VerStr() const {return Ver->VerStr == 0?0:Owner.StrP + Ver->VerStr;};
    inline const char *Section() const {return Ver->Section == 0?0:Owner.StrP + Ver->Section;};
    
    inline const char *VerStr() const {return Ver->VerStr == 0?0:Owner.StrP + Ver->VerStr;};
    inline const char *Section() const {return Ver->Section == 0?0:Owner.StrP + Ver->Section;};
+   inline const char *Arch() const {return Ver->Arch == 0?0:Owner.StrP + Ver->Arch;};
    inline PkgIterator ParentPkg() const {return PkgIterator(Owner,Owner.PkgP + Ver->ParentPkg);};
    inline DepIterator DependsList() const;
    inline PrvIterator ProvidesList() const;
    inline PkgIterator ParentPkg() const {return PkgIterator(Owner,Owner.PkgP + Ver->ParentPkg);};
    inline DepIterator DependsList() const;
    inline PrvIterator ProvidesList() const;
index 4797694d0c4d4cf2ec18b28b87d070fe3c7f0e90..d6f25bd010443bbf999b4ad5fc127f9dc2f6a3b1 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: deblistparser.cc,v 1.14 1999/01/27 02:48:53 jgg Exp $
+// $Id: deblistparser.cc,v 1.15 1999/02/01 02:22:11 jgg Exp $
 /* ######################################################################
    
    Package Cache Generator - Generator for the cache structure.
 /* ######################################################################
    
    Package Cache Generator - Generator for the cache structure.
@@ -65,6 +65,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
 {
    // Parse the section
    Ver->Section = UniqFindTagWrite("Section");
 {
    // Parse the section
    Ver->Section = UniqFindTagWrite("Section");
+   Ver->Arch = UniqFindTagWrite("Architecture");
    
    // Archive Size
    Ver->Size = (unsigned)Section.FindI("Size");
    
    // Archive Size
    Ver->Size = (unsigned)Section.FindI("Size");
index 2d174cc0103f9d5cb84c55982c11a9be28f69b40..ce9c866fb6cdc96ad26232422d4e21db3785f05c 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgcache.h,v 1.15 1998/12/14 08:07:29 jgg Exp $
+// $Id: pkgcache.h,v 1.16 1999/02/01 02:22:11 jgg Exp $
 /* ######################################################################
    
    Cache - Structure definitions for the cache file
 /* ######################################################################
    
    Cache - Structure definitions for the cache file
@@ -227,7 +227,8 @@ struct pkgCache::Version
 {
    __apt_ptrloc VerStr;            // Stringtable
    __apt_ptrloc Section;           // StringTable (StringItem)
 {
    __apt_ptrloc VerStr;            // Stringtable
    __apt_ptrloc Section;           // StringTable (StringItem)
-   
+   __apt_ptrloc Arch;              // StringTable
+      
    // Lists
    __apt_ptrloc FileList;          // VerFile
    __apt_ptrloc NextVer;           // Version
    // Lists
    __apt_ptrloc FileList;          // VerFile
    __apt_ptrloc NextVer;           // Version
index 7e7328a1ef922af554e36df7b6c1d83f6d6fcf16..2e80838fab41bda9698d684c18cf17a7ca96dc74 100644 (file)
@@ -4,7 +4,7 @@
 <title>APT Cache File Format</title>
 
 <author>Jason Gunthorpe <email>jgg@debian.org</email></author>
 <title>APT Cache File Format</title>
 
 <author>Jason Gunthorpe <email>jgg@debian.org</email></author>
-<version>$Id: cache.sgml,v 1.5 1998/12/14 08:23:10 jgg Exp $</version>
+<version>$Id: cache.sgml,v 1.6 1999/02/01 02:22:11 jgg Exp $</version>
 
 <abstract>
 This document describes the complete implementation and format of the APT
 
 <abstract>
 This document describes the complete implementation and format of the APT
@@ -414,6 +414,7 @@ VerStr).
    {
       unsigned long VerStr;            // Stringtable
       unsigned long Section;           // StringTable (StringItem)
    {
       unsigned long VerStr;            // Stringtable
       unsigned long Section;           // StringTable (StringItem)
+      unsigned long Arch;              // StringTable
       
       // Lists
       unsigned long FileList;          // VerFile
       
       // Lists
       unsigned long FileList;          // VerFile
@@ -443,6 +444,9 @@ a 0 in all other fields excluding VerStr and Possibly NextVer.
 This string indicates which section it is part of. The string should be
 contained in the StringItem list.
 
 This string indicates which section it is part of. The string should be
 contained in the StringItem list.
 
+<tag>Arch<item>
+Architecture the package was compiled for.
+
 <tag>NextVer<item>
 Next step in the linked list.
 
 <tag>NextVer<item>
 Next step in the linked list.