summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc46
-rw-r--r--apt-pkg/acquire-item.h25
-rw-r--r--apt-pkg/cacheiterators.h3
-rw-r--r--apt-pkg/deb/deblistparser.cc3
-rw-r--r--apt-pkg/pkgcache.h5
5 files changed, 61 insertions, 21 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index e64190078..beb4260ac 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -1,6 +1,6 @@
// -*- 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
@@ -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
- retried */
+ retried [CDROMs] */
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 /*{{{*/
// ---------------------------------------------------------------------
-/* */
+/* 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;
@@ -349,7 +350,8 @@ void pkgAcqIndexRel::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
// 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) :
@@ -358,6 +360,11 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
{
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. "
@@ -367,7 +374,9 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
/*}}}*/
// 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++)
@@ -398,7 +407,7 @@ bool pkgAcqArchive::QueueNext()
"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;
@@ -418,8 +427,27 @@ bool pkgAcqArchive::QueueNext()
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);
@@ -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");
- FinalFile += flNotDir(DestFile);
+ FinalFile += flNotDir(StoreFilename);
Rename(DestFile,FinalFile);
StoreFilename = DestFile = FinalFile;
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index 4429b1ceb..fd01bbb9a 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -1,19 +1,19 @@
// -*- 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
- 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
- checking and source location.
+ checking and source location as well as a retry algorithm.
##################################################################### */
/*}}}*/
@@ -33,11 +33,13 @@ class pkgAcquire::Item
{
protected:
+ // Some private helper methods for registering URIs
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:
@@ -57,14 +59,16 @@ class pkgAcquire::Item
// 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 string Custom600Headers() {return string();};
+
+ // Inquire functions
virtual string MD5Sum() {return string();};
virtual string Describe() = 0;
-
- virtual string Custom600Headers() {return string();};
-
+
Item(pkgAcquire *Owner);
virtual ~Item();
};
@@ -81,6 +85,7 @@ class pkgAcqIndex : public pkgAcquire::Item
public:
+ // Specialized action members
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:
+ // Specialized action members
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:
+ // State information for the retry mechanism
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;
-
+
+ // Queue the next available file for download.
bool QueueNext();
public:
+ // Specialized action members
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 string MD5Sum() {return MD5;};
pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
pkgRecords *Recs,pkgCache::VerIterator const &Version,
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h
index 1de574634..6e71e8c8d 100644
--- a/apt-pkg/cacheiterators.h
+++ b/apt-pkg/cacheiterators.h
@@ -1,6 +1,6 @@
// -*- 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
@@ -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 *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;
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 4797694d0..d6f25bd01 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -1,6 +1,6 @@
// -*- 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.
@@ -65,6 +65,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
{
// Parse the section
Ver->Section = UniqFindTagWrite("Section");
+ Ver->Arch = UniqFindTagWrite("Architecture");
// Archive Size
Ver->Size = (unsigned)Section.FindI("Size");
diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h
index 2d174cc01..ce9c866fb 100644
--- a/apt-pkg/pkgcache.h
+++ b/apt-pkg/pkgcache.h
@@ -1,6 +1,6 @@
// -*- 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
@@ -227,7 +227,8 @@ struct pkgCache::Version
{
__apt_ptrloc VerStr; // Stringtable
__apt_ptrloc Section; // StringTable (StringItem)
-
+ __apt_ptrloc Arch; // StringTable
+
// Lists
__apt_ptrloc FileList; // VerFile
__apt_ptrloc NextVer; // Version