Explorar o código

Arranged to rename downloaded files to include all impo...
Author: jgg
Date: 1999-02-01 02:22:11 GMT
Arranged to rename downloaded files to include all important info

Arch Librarian %!s(int64=22) %!d(string=hai) anos
pai
achega
17caf1b193

+ 37 - 9
apt-pkg/acquire-item.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // 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
       /* 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
          be sometime later. If we do a retry cycle then this should be
-	 retried */
+	 retried [CDROMs] */
       if (Cnf->LocalOnly == true &&
       if (Cnf->LocalOnly == true &&
 	  StringToBool(LookupTag(Message,"Transient-Failure"),false) == 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)
 void pkgAcquire::Item::Start(string Message,unsigned long Size)
 {
 {
    Status = StatFetching;
    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,
 pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
 			     pkgRecords *Recs,pkgCache::VerIterator const &Version,
 			     pkgRecords *Recs,pkgCache::VerIterator const &Version,
 			     string &StoreFilename) :
 			     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
    // Select a source
    if (QueueNext() == false && _error->PendingError() == false)
    if (QueueNext() == false && _error->PendingError() == false)
       _error->Error("I wasn't able to locate file for the %s package. "
       _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()
 bool pkgAcqArchive::QueueNext()
 {
 {
    for (; Vf.end() == false; Vf++)
    for (; Vf.end() == false; Vf++)
@@ -398,7 +407,7 @@ bool pkgAcqArchive::QueueNext()
 			      "field for package %s."
 			      "field for package %s."
 			      ,Version.ParentPkg().Name());
 			      ,Version.ParentPkg().Name());
 
 
-      // See if we already have the file.
+      // See if we already have the file. (Legacy filenames)
       FileSize = Version->Size;
       FileSize = Version->Size;
       string FinalFile = _config->FindDir("Dir::Cache::Archives") + flNotDir(PkgFile);
       string FinalFile = _config->FindDir("Dir::Cache::Archives") + flNotDir(PkgFile);
       struct stat Buf;
       struct stat Buf;
@@ -418,8 +427,27 @@ bool pkgAcqArchive::QueueNext()
 	    happen.. */
 	    happen.. */
 	 unlink(FinalFile.c_str());
 	 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
       // Create the item
       Desc.URI = Location->ArchiveURI(PkgFile);
       Desc.URI = Location->ArchiveURI(PkgFile);
@@ -479,7 +507,7 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash)
    
    
    // Done, move it into position
    // Done, move it into position
    string FinalFile = _config->FindDir("Dir::Cache::Archives");
    string FinalFile = _config->FindDir("Dir::Cache::Archives");
-   FinalFile += flNotDir(DestFile);
+   FinalFile += flNotDir(StoreFilename);
    Rename(DestFile,FinalFile);
    Rename(DestFile,FinalFile);
    
    
    StoreFilename = DestFile = FinalFile;
    StoreFilename = DestFile = FinalFile;

+ 17 - 8
apt-pkg/acquire-item.h

@@ -1,19 +1,19 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // 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
    Acquire Item - Item to acquire
 
 
    When an item is instantiated it will add it self to the local list in
    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 
    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
    Two item classes are provided to provide functionality for downloading
    of Index files and downloading of Packages.
    of Index files and downloading of Packages.
    
    
    A Archive class is provided for downloading .deb files. It does Md5
    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;
    pkgAcquire *Owner;
    inline void QueueURI(ItemDesc &Item)
    inline void QueueURI(ItemDesc &Item)
                  {Owner->Enqueue(Item);};
                  {Owner->Enqueue(Item);};
    inline void Dequeue() {Owner->Dequeue(this);};
    inline void Dequeue() {Owner->Dequeue(this);};
    
    
+   // Safe rename function with timestamp preservation
    void Rename(string From,string To);
    void Rename(string From,string To);
    
    
    public:
    public:
@@ -57,14 +59,16 @@ class pkgAcquire::Item
    // File to write the fetch into
    // File to write the fetch into
    string DestFile;
    string DestFile;
 
 
+   // Action members invoked by the worker
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
    virtual void Done(string Message,unsigned long Size,string Md5Hash);
    virtual void Done(string Message,unsigned long Size,string Md5Hash);
    virtual void Start(string Message,unsigned long Size);
    virtual void Start(string Message,unsigned long Size);
+   virtual string Custom600Headers() {return string();};
+   
+   // Inquire functions
    virtual string MD5Sum() {return string();};
    virtual string MD5Sum() {return string();};
    virtual string Describe() = 0;
    virtual string Describe() = 0;
-   
-   virtual string Custom600Headers() {return string();};
-      
+         
    Item(pkgAcquire *Owner);
    Item(pkgAcquire *Owner);
    virtual ~Item();
    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 void Done(string Message,unsigned long Size,string Md5Hash);   
    virtual string Custom600Headers();
    virtual string Custom600Headers();
    virtual string Describe();
    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 Failed(string Message,pkgAcquire::MethodConfig *Cnf);
    virtual void Done(string Message,unsigned long Size,string Md5Hash);   
    virtual void Done(string Message,unsigned long Size,string Md5Hash);   
    virtual string Custom600Headers();
    virtual string Custom600Headers();
@@ -111,6 +117,7 @@ class pkgAcqArchive : public pkgAcquire::Item
 {
 {
    protected:
    protected:
    
    
+   // State information for the retry mechanism
    pkgCache::VerIterator Version;
    pkgCache::VerIterator Version;
    pkgAcquire::ItemDesc Desc;
    pkgAcquire::ItemDesc Desc;
    pkgSourceList *Sources;
    pkgSourceList *Sources;
@@ -119,15 +126,17 @@ class pkgAcqArchive : public pkgAcquire::Item
    string &StoreFilename;
    string &StoreFilename;
    pkgCache::VerFileIterator Vf;
    pkgCache::VerFileIterator Vf;
    unsigned int Retries;
    unsigned int Retries;
-   
+
+   // Queue the next available file for download.
    bool QueueNext();
    bool QueueNext();
    
    
    public:
    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 void Done(string Message,unsigned long Size,string Md5Hash);
    virtual string Describe();
    virtual string Describe();
+   virtual string MD5Sum() {return MD5;};
    
    
    pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
    pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
 		 pkgRecords *Recs,pkgCache::VerIterator const &Version,
 		 pkgRecords *Recs,pkgCache::VerIterator const &Version,

+ 2 - 1
apt-pkg/cacheiterators.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // 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 *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 *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 PkgIterator ParentPkg() const {return PkgIterator(Owner,Owner.PkgP + Ver->ParentPkg);};
    inline DepIterator DependsList() const;
    inline DepIterator DependsList() const;
    inline PrvIterator ProvidesList() const;
    inline PrvIterator ProvidesList() const;

+ 2 - 1
apt-pkg/deb/deblistparser.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // 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
    // Parse the section
    Ver->Section = UniqFindTagWrite("Section");
    Ver->Section = UniqFindTagWrite("Section");
+   Ver->Arch = UniqFindTagWrite("Architecture");
    
    
    // Archive Size
    // Archive Size
    Ver->Size = (unsigned)Section.FindI("Size");
    Ver->Size = (unsigned)Section.FindI("Size");

+ 3 - 2
apt-pkg/pkgcache.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // 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 VerStr;            // Stringtable
    __apt_ptrloc Section;           // StringTable (StringItem)
    __apt_ptrloc Section;           // StringTable (StringItem)
-   
+   __apt_ptrloc Arch;              // StringTable
+      
    // Lists
    // Lists
    __apt_ptrloc FileList;          // VerFile
    __apt_ptrloc FileList;          // VerFile
    __apt_ptrloc NextVer;           // Version
    __apt_ptrloc NextVer;           // Version

+ 5 - 1
doc/cache.sgml

@@ -4,7 +4,7 @@
 <title>APT Cache File Format</title>
 <title>APT Cache File Format</title>
 
 
 <author>Jason Gunthorpe <email>jgg@debian.org</email></author>
 <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>
 <abstract>
 This document describes the complete implementation and format of the APT
 This document describes the complete implementation and format of the APT
@@ -414,6 +414,7 @@ VerStr).
    {
    {
       unsigned long VerStr;            // Stringtable
       unsigned long VerStr;            // Stringtable
       unsigned long Section;           // StringTable (StringItem)
       unsigned long Section;           // StringTable (StringItem)
+      unsigned long Arch;              // StringTable
       
       
       // Lists
       // Lists
       unsigned long FileList;          // VerFile
       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
 This string indicates which section it is part of. The string should be
 contained in the StringItem list.
 contained in the StringItem list.
 
 
+<tag>Arch<item>
+Architecture the package was compiled for.
+
 <tag>NextVer<item>
 <tag>NextVer<item>
 Next step in the linked list.
 Next step in the linked list.