From 46e00f9d71300f3a80a4a311e369e64a48ce396f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 22 Nov 2005 19:34:02 +0000 Subject: [PATCH] * ABI change: merged more flexible pkgAcquireFile code --- apt-pkg/acquire-item.cc | 27 +++++++++++++++------------ apt-pkg/acquire-item.h | 11 ++++++++--- apt-pkg/init.h | 2 +- apt-pkg/makefile | 2 +- debian/changelog | 1 + methods/makefile | 2 +- 6 files changed, 27 insertions(+), 18 deletions(-) diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index debd1fac..88c25de4 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -184,7 +184,7 @@ string pkgAcqIndex::Custom600Headers() void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) { // no .bz2 found, retry with .gz - if(Desc.URI.substr(Desc.URI.size()-3,Desc.URI.size()-1) == "bz2") { + if(Desc.URI.substr(Desc.URI.size()-3) == "bz2") { Desc.URI = Desc.URI.substr(0,Desc.URI.size()-3) + "gz"; // retry with a gzip one @@ -290,7 +290,7 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5, else Local = true; - string compExt = Desc.URI.substr(Desc.URI.size()-3,Desc.URI.size()-1); + string compExt = Desc.URI.substr(Desc.URI.size()-3); char *decompProg; if(compExt == "bz2") decompProg = "bzip2"; @@ -315,10 +315,9 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner, const vector* IndexTargets, indexRecords* MetaIndexParser) : Item(Owner), RealURI(URI), MetaIndexURI(MetaIndexURI), - MetaIndexURIDesc(MetaIndexURIDesc), MetaIndexShortDesc(MetaIndexShortDesc) + MetaIndexURIDesc(MetaIndexURIDesc), MetaIndexShortDesc(MetaIndexShortDesc), + MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets) { - this->MetaIndexParser = MetaIndexParser; - this->IndexTargets = IndexTargets; DestFile = _config->FindDir("Dir::State::lists") + "partial/"; DestFile += URItoFileName(URI); @@ -430,11 +429,9 @@ pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire *Owner, string SigFile, const vector* IndexTargets, indexRecords* MetaIndexParser) : - Item(Owner), RealURI(URI), SigFile(SigFile) + Item(Owner), RealURI(URI), SigFile(SigFile), AuthPass(false), + MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets) { - this->AuthPass = false; - this->MetaIndexParser = MetaIndexParser; - this->IndexTargets = IndexTargets; DestFile = _config->FindDir("Dir::State::lists") + "partial/"; DestFile += URItoFileName(URI); @@ -1008,13 +1005,19 @@ 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) : + unsigned long Size,string Dsc,string ShortDesc, + const string &DestDir, const string &DestFilename) : Item(Owner), Md5Hash(MD5) { Retries = _config->FindI("Acquire::Retries",0); - DestFile = flNotDir(URI); - + if(!DestFilename.empty()) + DestFile = DestFilename; + else if(!DestDir.empty()) + DestFile = DestDir + "/" + flNotDir(URI); + else + DestFile = flNotDir(URI); + // Create the item Desc.URI = URI; Desc.Description = Dsc; diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 90f80368..c34b5ef6 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -224,9 +224,14 @@ class pkgAcqFile : public pkgAcquire::Item pkgAcquire::MethodConfig *Cnf); virtual string MD5Sum() {return Md5Hash;}; virtual string DescURI() {return Desc.URI;}; - - pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,unsigned long Size, - string Desc,string ShortDesc); + + // If DestFilename is empty, download to DestDir/ if + // DestDir is non-empty, $CWD/ otherwise. If + // DestFilename is NOT empty, DestDir is ignored and DestFilename + // is the absolute name to which the file should be downloaded. + pkgAcqFile(pkgAcquire *Owner, string URI, string MD5, unsigned long Size, + string Desc, string ShortDesc, + const string &DestDir="", const string &DestFilename=""); }; #endif diff --git a/apt-pkg/init.h b/apt-pkg/init.h index e2135179..8255b406 100644 --- a/apt-pkg/init.h +++ b/apt-pkg/init.h @@ -18,7 +18,7 @@ // See the makefile #define APT_PKG_MAJOR 3 -#define APT_PKG_MINOR 10 +#define APT_PKG_MINOR 11 #define APT_PKG_RELEASE 0 extern const char *pkgVersion; diff --git a/apt-pkg/makefile b/apt-pkg/makefile index 8de7d945..0e6aecc6 100644 --- a/apt-pkg/makefile +++ b/apt-pkg/makefile @@ -13,7 +13,7 @@ include ../buildlib/defaults.mak # methods/makefile - FIXME LIBRARY=apt-pkg LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER) -MAJOR=3.10 +MAJOR=3.11 MINOR=0 SLIBS=$(PTHREADLIB) $(INTLLIBS) APT_DOMAIN:=libapt-pkg$(MAJOR) diff --git a/debian/changelog b/debian/changelog index bca8a14b..2022448a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,7 @@ apt (0.6.42.4) unstable; urgency=low * make pkgDirStream (a bit) more complete * fix bug in pkgCache::VerIterator::end() (thanks to Daniel Burrows) (closes: #339533) + * pkgAcqFile is more flexible now (closes: #57091) -- diff --git a/methods/makefile b/methods/makefile index 06fd2a6f..1e3b1ef8 100644 --- a/methods/makefile +++ b/methods/makefile @@ -7,7 +7,7 @@ include ../buildlib/defaults.mak BIN := $(BIN)/methods # FIXME.. -LIB_APT_PKG_MAJOR = 3.10 +LIB_APT_PKG_MAJOR = 3.11 APT_DOMAIN := libapt-pkg$(LIB_APT_PKG_MAJOR) # The file method -- 2.20.1