diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-item.cc | 14 | ||||
-rw-r--r-- | apt-pkg/acquire-item.h | 12 | ||||
-rw-r--r-- | apt-pkg/acquire-worker.h | 3 | ||||
-rw-r--r-- | apt-pkg/acquire.h | 3 | ||||
-rw-r--r-- | apt-pkg/contrib/weakptr.h | 62 | ||||
-rw-r--r-- | apt-pkg/depcache.cc | 4 | ||||
-rw-r--r-- | apt-pkg/makefile | 2 | ||||
-rw-r--r-- | apt-pkg/pkgcache.cc | 2 | ||||
-rw-r--r-- | apt-pkg/policy.cc | 2 |
9 files changed, 93 insertions, 11 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 916fca71e..1f253bb81 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1561,8 +1561,9 @@ void pkgAcqArchive::Finished() /* The file is added to the queue */ pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string Hash, unsigned long Size,string Dsc,string ShortDesc, - const string &DestDir, const string &DestFilename) : - Item(Owner), ExpectedHash(Hash) + const string &DestDir, const string &DestFilename, + bool IsIndexFile) : + Item(Owner), ExpectedHash(Hash), IsIndexFile(IsIndexFile) { Retries = _config->FindI("Acquire::Retries",0); @@ -1677,3 +1678,12 @@ void pkgAcqFile::Failed(string Message,pkgAcquire::MethodConfig *Cnf) Item::Failed(Message,Cnf); } /*}}}*/ +// AcqIndex::Custom600Headers - Insert custom request headers /*{{{*/ +// --------------------------------------------------------------------- +/* The only header we use is the last-modified header. */ +string pkgAcqFile::Custom600Headers() +{ + if (IsIndexFile) + return "\nIndex-File: true"; +} + /*}}}*/ diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index d862d0fdd..b338b2a41 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -27,6 +27,7 @@ #include <apt-pkg/pkgrecords.h> #include <apt-pkg/indexrecords.h> #include <apt-pkg/hashes.h> +#include <apt-pkg/weakptr.h> /** \addtogroup acquire * @{ @@ -46,7 +47,7 @@ * * \see pkgAcquire */ -class pkgAcquire::Item +class pkgAcquire::Item : public WeakPointable { protected: @@ -861,6 +862,9 @@ class pkgAcqFile : public pkgAcquire::Item */ unsigned int Retries; + /** \brief Should this file be considered a index file */ + bool IsIndexFile; + public: // Specialized action members @@ -869,6 +873,7 @@ class pkgAcqFile : public pkgAcquire::Item pkgAcquire::MethodConfig *Cnf); virtual string DescURI() {return Desc.URI;}; virtual string HashSum() {return ExpectedHash.toStr(); }; + virtual string Custom600Headers(); /** \brief Create a new pkgAcqFile object. * @@ -892,6 +897,8 @@ class pkgAcqFile : public pkgAcquire::Item * * \param DestFilename The filename+path the file is downloaded to. * + * \param IsIndexFile The file is considered a IndexFile and cache-control + * headers like "cache-control: max-age=0" are send * * If DestFilename is empty, download to DestDir/<basename> if * DestDir is non-empty, $CWD/<basename> otherwise. If @@ -901,7 +908,8 @@ class pkgAcqFile : public pkgAcquire::Item pkgAcqFile(pkgAcquire *Owner, string URI, string Hash, unsigned long Size, string Desc, string ShortDesc, - const string &DestDir="", const string &DestFilename=""); + const string &DestDir="", const string &DestFilename="", + bool IsIndexFile=false); }; /*}}}*/ /** @} */ diff --git a/apt-pkg/acquire-worker.h b/apt-pkg/acquire-worker.h index 2942df69f..06283922e 100644 --- a/apt-pkg/acquire-worker.h +++ b/apt-pkg/acquire-worker.h @@ -20,6 +20,7 @@ #define PKGLIB_ACQUIRE_WORKER_H #include <apt-pkg/acquire.h> +#include <apt-pkg/weakptr.h> /** \brief A fetch subprocess. @@ -41,7 +42,7 @@ * * \sa pkgAcqMethod, pkgAcquire::Item, pkgAcquire */ -class pkgAcquire::Worker +class pkgAcquire::Worker : public WeakPointable { friend class pkgAcquire; diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 9e91a9f67..8e2c21151 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -67,6 +67,7 @@ #define PKGLIB_ACQUIRE_H #include <apt-pkg/macros.h> +#include <apt-pkg/weakptr.h> #include <vector> #include <string> @@ -376,7 +377,7 @@ class pkgAcquire * * An item may have several assocated ItemDescs over its lifetime. */ -struct pkgAcquire::ItemDesc +struct pkgAcquire::ItemDesc : public WeakPointable { /** \brief The URI from which to download this item. */ string URI; diff --git a/apt-pkg/contrib/weakptr.h b/apt-pkg/contrib/weakptr.h new file mode 100644 index 000000000..5158e393c --- /dev/null +++ b/apt-pkg/contrib/weakptr.h @@ -0,0 +1,62 @@ +/* weakptr.h - An object which supports weak pointers. + * + * Copyright (C) 2010 Julian Andres Klode <jak@debian.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef WEAK_POINTER_H +#define WEAK_POINTER_H + +#include <set> +/** + * Class for objects providing support for weak pointers. + * + * This class allows for the registration of certain pointers as weak, + * which will cause them to be set to NULL when the destructor of the + * object is called. + */ +class WeakPointable { +private: + std::set<WeakPointable**> pointers; + +public: + + /** + * Add a new weak pointer. + */ + inline void AddWeakPointer(WeakPointable** weakptr) { + pointers.insert(weakptr); + } + + /** + * Remove the weak pointer from the list of weak pointers. + */ + inline void RemoveWeakPointer(WeakPointable **weakptr) { + pointers.erase(weakptr); + } + + /** + * Deconstruct the object, set all weak pointers to NULL. + */ + ~WeakPointable() { + std::set<WeakPointable**>::iterator iter = pointers.begin(); + while (iter != pointers.end()) + **(iter++) = NULL; + } +}; + +#endif // WEAK_POINTER_H diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 659c4227e..4d1a08eb6 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -192,7 +192,7 @@ bool pkgDepCache::readStateFile(OpProgress *Prog) /*{{{*/ { PkgState[pkg->ID].Flags |= Flag::Auto; if (unlikely(debug_autoremove)) - std::cout << "Auto-Installed : " << pkg.FullName() << std::endl; + std::clog << "Auto-Installed : " << pkg.FullName() << std::endl; if (pkgarch == "any") { pkgCache::GrpIterator G = pkg.Group(); @@ -1819,7 +1819,7 @@ bool pkgDepCache::Sweep() /*{{{*/ { state.Garbage=true; if(debug_autoremove) - std::cout << "Garbage: " << p.FullName() << std::endl; + std::clog << "Garbage: " << p.FullName() << std::endl; } } diff --git a/apt-pkg/makefile b/apt-pkg/makefile index bdd49c089..148ad581b 100644 --- a/apt-pkg/makefile +++ b/apt-pkg/makefile @@ -25,7 +25,7 @@ SOURCE = contrib/mmap.cc contrib/error.cc contrib/strutl.cc \ contrib/fileutl.cc HEADERS = mmap.h error.h configuration.h fileutl.h cmndline.h netrc.h\ md5.h crc-16.h cdromutl.h strutl.h sptr.h sha1.h sha256.h hashes.h \ - macros.h + macros.h weakptr.h # Source code for the core main library SOURCE+= pkgcache.cc version.cc depcache.cc \ diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index ba3c5cbf8..a59a06d65 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -221,7 +221,7 @@ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) { /* Returns 0 on error, pointer to the package otherwise */ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name, string const &Arch) { if (MultiArchCache() == false) { - if (Arch == "native" || Arch == "all" || + if (Arch == "native" || Arch == "all" || Arch == "any" || Arch == _config->Find("APT::Architecture")) return SingleArchFindPkg(Name); else diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index 9b24c2ef1..479cf3935 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -106,7 +106,7 @@ bool pkgPolicy::InitDefaults() if (_config->FindB("Debug::pkgPolicy",false) == true) for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); F++) - cout << "Prio of " << F.FileName() << ' ' << PFPriority[F->ID] << endl; + std::clog << "Prio of " << F.FileName() << ' ' << PFPriority[F->ID] << std::endl; return true; } |