From 00b6a181fe1efb86ba5eb98a369da8f9d2ab063f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 29 Jun 2011 19:38:52 +0200 Subject: * apt-pkg/pkgcache.h: - readd All{Foreign,Allowed} as suggested by Julian to remain strictly API compatible --- apt-pkg/pkgcache.h | 4 +++- debian/changelog | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h index 280f37bca..9a9f79420 100644 --- a/apt-pkg/pkgcache.h +++ b/apt-pkg/pkgcache.h @@ -506,7 +506,9 @@ struct pkgCache::Version All = (1<<0), /*!< will cause that Ver.Arch() will report "all" */ Foreign = (1<<1), /*!< can satisfy dependencies in another architecture */ Same = (1<<2), /*!< can be co-installed with itself from other architectures */ - Allowed = (1<<3) /*!< other packages are allowed to depend on thispkg:any */ }; + Allowed = (1<<3), /*!< other packages are allowed to depend on thispkg:any */ + AllForeign = All | Foreign, + AllAllowed = All | Allowed }; /** \brief stores the MultiArch capabilities of this version Flags used are defined in pkgCache::Version::VerMultiArch diff --git a/debian/changelog b/debian/changelog index 0c104137e..af6db28b9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +apt (0.8.16~exp3) experimental; urgency=low + + [ David Kalnischkies ] + * apt-pkg/pkgcache.h: + - readd All{Foreign,Allowed} as suggested by Julian to + remain strictly API compatible + + -- David Kalnischkies Wed, 29 Jun 2011 19:38:44 +0200 + apt (0.8.16~exp2) experimental; urgency=low [ David Kalnischkies ] -- cgit v1.2.3 From 5efbd59693fbdb87496bb4aa78d7957c1ebea7d4 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 29 Jun 2011 19:39:21 +0200 Subject: =?UTF-8?q?fix=20compiler=20warning=20by=20reordering=20init-list?= =?UTF-8?q?=20apt-pkg/acquire.h:=20In=20constructor=20=E2=80=98pkgAcquire:?= =?UTF-8?q?:pkgAcquire()=E2=80=99:=20apt-pkg/acquire.h:175:9:=20warning:?= =?UTF-8?q?=20=E2=80=98pkgAcquire::Running=E2=80=99=20will=20be=20initiali?= =?UTF-8?q?zed=20after=20[-Wreorder]=20apt-pkg/acquire.h:96:8:=20warning:?= =?UTF-8?q?=20=20=20=E2=80=98int=20pkgAcquire::LockFD=E2=80=99=20[-Wreorde?= =?UTF-8?q?r]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apt-pkg/acquire.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 9478cdfb4..939c7f4c5 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -37,9 +37,9 @@ using namespace std; // Acquire::pkgAcquire - Constructor /*{{{*/ // --------------------------------------------------------------------- /* We grab some runtime state from the configuration space */ -pkgAcquire::pkgAcquire() : Queues(0), Workers(0), Configs(0), Log(NULL), ToFetch(0), +pkgAcquire::pkgAcquire() : LockFD(-1), Queues(0), Workers(0), Configs(0), Log(NULL), ToFetch(0), Debug(_config->FindB("Debug::pkgAcquire",false)), - Running(false), LockFD(-1) + Running(false) { string const Mode = _config->Find("Acquire::Queue-Mode","host"); if (strcasecmp(Mode.c_str(),"host") == 0) @@ -47,10 +47,10 @@ pkgAcquire::pkgAcquire() : Queues(0), Workers(0), Configs(0), Log(NULL), ToFetch if (strcasecmp(Mode.c_str(),"access") == 0) QueueMode = QueueAccess; } -pkgAcquire::pkgAcquire(pkgAcquireStatus *Progress) : Queues(0), Workers(0), +pkgAcquire::pkgAcquire(pkgAcquireStatus *Progress) : LockFD(-1), Queues(0), Workers(0), Configs(0), Log(Progress), ToFetch(0), Debug(_config->FindB("Debug::pkgAcquire",false)), - Running(false), LockFD(-1) + Running(false) { string const Mode = _config->Find("Acquire::Queue-Mode","host"); if (strcasecmp(Mode.c_str(),"host") == 0) -- cgit v1.2.3 From ef25649c3d6a535706d1039aba128e1b22341f91 Mon Sep 17 00:00:00 2001 From: Matt Emmerton Date: Wed, 29 Jun 2011 20:22:02 +0200 Subject: Make private sha2 functions static (freebsd which can be considered the "official" upstream has applied it) --- apt-pkg/contrib/sha2_internal.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apt-pkg/contrib/sha2_internal.cc b/apt-pkg/contrib/sha2_internal.cc index 10b82dec4..565db2f91 100644 --- a/apt-pkg/contrib/sha2_internal.cc +++ b/apt-pkg/contrib/sha2_internal.cc @@ -219,9 +219,9 @@ typedef u_int64_t sha2_word64; /* Exactly 8 bytes */ * library -- they are intended for private internal visibility/use * only. */ -void SHA512_Last(SHA512_CTX*); -void SHA256_Transform(SHA256_CTX*, const sha2_word32*); -void SHA512_Transform(SHA512_CTX*, const sha2_word64*); +static void SHA512_Last(SHA512_CTX*); +static void SHA256_Transform(SHA256_CTX*, const sha2_word32*); +static void SHA512_Transform(SHA512_CTX*, const sha2_word64*); /*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/ @@ -379,7 +379,7 @@ void SHA256_Init(SHA256_CTX* context) { (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ j++ -void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { +static void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { sha2_word32 a, b, c, d, e, f, g, h, s0, s1; sha2_word32 T1, *W256; int j; @@ -437,7 +437,7 @@ void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { #else /* SHA2_UNROLL_TRANSFORM */ -void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { +static void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { sha2_word32 a, b, c, d, e, f, g, h, s0, s1; sha2_word32 T1, T2, *W256; int j; @@ -706,7 +706,7 @@ void SHA512_Init(SHA512_CTX* context) { (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ j++ -void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { +static void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { sha2_word64 a, b, c, d, e, f, g, h, s0, s1; sha2_word64 T1, *W512 = (sha2_word64*)context->buffer; int j; @@ -761,7 +761,7 @@ void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { #else /* SHA2_UNROLL_TRANSFORM */ -void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { +static void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { sha2_word64 a, b, c, d, e, f, g, h, s0, s1; sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer; int j; @@ -887,7 +887,7 @@ void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) { usedspace = freespace = 0; } -void SHA512_Last(SHA512_CTX* context) { +static void SHA512_Last(SHA512_CTX* context) { unsigned int usedspace; usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; -- cgit v1.2.3 From 73da43e90be945d3be9b4f3b6e5016fb7bacb59d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 5 Jul 2011 15:58:32 +0200 Subject: * apt-pkg/acquire*.{cc,h}: - try even harder to support really big files in the fetcher by converting (hopefully) everything to 'long long' (Closes: #632271) --- apt-pkg/acquire-item.cc | 30 +++++++++++++++--------------- apt-pkg/acquire-item.h | 22 +++++++++++----------- apt-pkg/acquire-method.h | 4 ++-- apt-pkg/acquire-worker.cc | 4 ++-- apt-pkg/acquire-worker.h | 6 +++--- apt-pkg/acquire.cc | 2 +- apt-pkg/acquire.h | 11 +++-------- debian/changelog | 5 ++++- 8 files changed, 41 insertions(+), 43 deletions(-) diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index d790bd898..a6698b367 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -94,7 +94,7 @@ void pkgAcquire::Item::Failed(string Message,pkgAcquire::MethodConfig *Cnf) // --------------------------------------------------------------------- /* 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 long Size) { Status = StatFetching; if (FileSize == 0 && Complete == false) @@ -104,7 +104,7 @@ void pkgAcquire::Item::Start(string /*Message*/,unsigned long Size) // Acquire::Item::Done - Item downloaded OK /*{{{*/ // --------------------------------------------------------------------- /* */ -void pkgAcquire::Item::Done(string Message,unsigned long Size,string Hash, +void pkgAcquire::Item::Done(string Message,unsigned long long Size,string Hash, pkgAcquire::MethodConfig *Cnf) { // We just downloaded something.. @@ -245,7 +245,7 @@ void pkgAcqSubIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{* } } /*}}}*/ -void pkgAcqSubIndex::Done(string Message,unsigned long Size,string Md5Hash, /*{{{*/ +void pkgAcqSubIndex::Done(string Message,unsigned long long Size,string Md5Hash, /*{{{*/ pkgAcquire::MethodConfig *Cnf) { if(Debug) @@ -544,7 +544,7 @@ void pkgAcqDiffIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{ Dequeue(); } /*}}}*/ -void pkgAcqDiffIndex::Done(string Message,unsigned long Size,string Md5Hash, /*{{{*/ +void pkgAcqDiffIndex::Done(string Message,unsigned long long Size,string Md5Hash, /*{{{*/ pkgAcquire::MethodConfig *Cnf) { if(Debug) @@ -710,7 +710,7 @@ bool pkgAcqIndexDiffs::QueueNextDiff() /*{{{*/ return true; } /*}}}*/ -void pkgAcqIndexDiffs::Done(string Message,unsigned long Size,string Md5Hash, /*{{{*/ +void pkgAcqIndexDiffs::Done(string Message,unsigned long long Size,string Md5Hash, /*{{{*/ pkgAcquire::MethodConfig *Cnf) { if(Debug) @@ -881,7 +881,7 @@ void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{*/ to the uncompressed version of the file. If this is so the file is copied into the partial directory. In all other cases the file is decompressed with a gzip uri. */ -void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash, +void pkgAcqIndex::Done(string Message,unsigned long long Size,string Hash, pkgAcquire::MethodConfig *Cfg) { Item::Done(Message,Size,Hash,Cfg); @@ -1123,7 +1123,7 @@ string pkgAcqMetaSig::Custom600Headers() return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime); } -void pkgAcqMetaSig::Done(string Message,unsigned long Size,string MD5, +void pkgAcqMetaSig::Done(string Message,unsigned long long Size,string MD5, pkgAcquire::MethodConfig *Cfg) { Item::Done(Message,Size,MD5,Cfg); @@ -1232,7 +1232,7 @@ string pkgAcqMetaIndex::Custom600Headers() return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime); } /*}}}*/ -void pkgAcqMetaIndex::Done(string Message,unsigned long Size,string Hash, /*{{{*/ +void pkgAcqMetaIndex::Done(string Message,unsigned long long Size,string Hash, /*{{{*/ pkgAcquire::MethodConfig *Cfg) { Item::Done(Message,Size,Hash,Cfg); @@ -1768,7 +1768,7 @@ bool pkgAcqArchive::QueueNext() if (stat(FinalFile.c_str(),&Buf) == 0) { // Make sure the size matches - if ((unsigned)Buf.st_size == Version->Size) + if ((unsigned long long)Buf.st_size == Version->Size) { Complete = true; Local = true; @@ -1787,7 +1787,7 @@ bool pkgAcqArchive::QueueNext() if (stat(FinalFile.c_str(),&Buf) == 0) { // Make sure the size matches - if ((unsigned)Buf.st_size == Version->Size) + if ((unsigned long long)Buf.st_size == Version->Size) { Complete = true; Local = true; @@ -1807,7 +1807,7 @@ bool pkgAcqArchive::QueueNext() if (stat(DestFile.c_str(),&Buf) == 0) { // Hmm, the partial file is too big, erase it - if ((unsigned)Buf.st_size > Version->Size) + if ((unsigned long long)Buf.st_size > Version->Size) unlink(DestFile.c_str()); else PartialSize = Buf.st_size; @@ -1830,7 +1830,7 @@ bool pkgAcqArchive::QueueNext() // AcqArchive::Done - Finished fetching /*{{{*/ // --------------------------------------------------------------------- /* */ -void pkgAcqArchive::Done(string Message,unsigned long Size,string CalcHash, +void pkgAcqArchive::Done(string Message,unsigned long long Size,string CalcHash, pkgAcquire::MethodConfig *Cfg) { Item::Done(Message,Size,CalcHash,Cfg); @@ -1941,7 +1941,7 @@ 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, + unsigned long long Size,string Dsc,string ShortDesc, const string &DestDir, const string &DestFilename, bool IsIndexFile) : Item(Owner), ExpectedHash(Hash), IsIndexFile(IsIndexFile) @@ -1969,7 +1969,7 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string Hash, if (stat(DestFile.c_str(),&Buf) == 0) { // Hmm, the partial file is too big, erase it - if ((unsigned)Buf.st_size > Size) + if ((unsigned long long)Buf.st_size > Size) unlink(DestFile.c_str()); else PartialSize = Buf.st_size; @@ -1981,7 +1981,7 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string Hash, // AcqFile::Done - Item downloaded OK /*{{{*/ // --------------------------------------------------------------------- /* */ -void pkgAcqFile::Done(string Message,unsigned long Size,string CalcHash, +void pkgAcqFile::Done(string Message,unsigned long long Size,string CalcHash, pkgAcquire::MethodConfig *Cnf) { Item::Done(Message,Size,CalcHash,Cnf); diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index f763577ee..e6916a834 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -194,7 +194,7 @@ class pkgAcquire::Item : public WeakPointable * * \sa pkgAcqMethod */ - virtual void Done(string Message,unsigned long Size,string Hash, + virtual void Done(string Message,unsigned long long Size,string Hash, pkgAcquire::MethodConfig *Cnf); /** \brief Invoked when the worker starts to fetch this object. @@ -206,7 +206,7 @@ class pkgAcquire::Item : public WeakPointable * * \sa pkgAcqMethod */ - virtual void Start(string Message,unsigned long Size); + virtual void Start(string Message,unsigned long long Size); /** \brief Custom headers to be sent to the fetch process. * @@ -309,7 +309,7 @@ class pkgAcqSubIndex : 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 void Done(string Message,unsigned long long Size,string Md5Hash, pkgAcquire::MethodConfig *Cnf); virtual string DescURI() {return Desc.URI;}; virtual string Custom600Headers(); @@ -372,7 +372,7 @@ class pkgAcqDiffIndex : 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 void Done(string Message,unsigned long long Size,string Md5Hash, pkgAcquire::MethodConfig *Cnf); virtual string DescURI() {return RealURI + "Index";}; virtual string Custom600Headers(); @@ -508,7 +508,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item */ 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 long Size,string Md5Hash, pkgAcquire::MethodConfig *Cnf); virtual string DescURI() {return RealURI + "Index";}; @@ -581,7 +581,7 @@ class pkgAcqIndex : public pkgAcquire::Item // Specialized action members 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 long Size,string Md5Hash, pkgAcquire::MethodConfig *Cnf); virtual string Custom600Headers(); virtual string DescURI() {return Desc.URI;}; @@ -723,7 +723,7 @@ class pkgAcqMetaSig : public pkgAcquire::Item // Specialized action members 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 long Size,string Md5Hash, pkgAcquire::MethodConfig *Cnf); virtual string Custom600Headers(); virtual string DescURI() {return RealURI; }; @@ -818,7 +818,7 @@ class pkgAcqMetaIndex : public pkgAcquire::Item // Specialized action members virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(string Message,unsigned long Size, string Hash, + virtual void Done(string Message,unsigned long long Size, string Hash, pkgAcquire::MethodConfig *Cnf); virtual string Custom600Headers(); virtual string DescURI() {return RealURI; }; @@ -918,7 +918,7 @@ class pkgAcqArchive : public pkgAcquire::Item public: virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(string Message,unsigned long Size,string Hash, + virtual void Done(string Message,unsigned long long Size,string Hash, pkgAcquire::MethodConfig *Cnf); virtual string DescURI() {return Desc.URI;}; virtual string ShortDesc() {return Desc.ShortDesc;}; @@ -975,7 +975,7 @@ class pkgAcqFile : public pkgAcquire::Item // Specialized action members virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(string Message,unsigned long Size,string CalcHash, + virtual void Done(string Message,unsigned long long Size,string CalcHash, pkgAcquire::MethodConfig *Cnf); virtual string DescURI() {return Desc.URI;}; virtual string HashSum() {return ExpectedHash.toStr(); }; @@ -1012,7 +1012,7 @@ class pkgAcqFile : public pkgAcquire::Item * is the absolute name to which the file should be downloaded. */ - pkgAcqFile(pkgAcquire *Owner, string URI, string Hash, unsigned long Size, + pkgAcqFile(pkgAcquire *Owner, string URI, string Hash, unsigned long long Size, string Desc, string ShortDesc, const string &DestDir="", const string &DestFilename="", bool IsIndexFile=false); diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h index 2d0fa4590..6551170c4 100644 --- a/apt-pkg/acquire-method.h +++ b/apt-pkg/acquire-method.h @@ -51,8 +51,8 @@ class pkgAcqMethod time_t LastModified; bool IMSHit; string Filename; - unsigned long Size; - unsigned long ResumePoint; + unsigned long long Size; + unsigned long long ResumePoint; void TakeHashes(Hashes &Hash); FetchResult(); diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index 75e03232a..3e1fd98db 100644 --- a/apt-pkg/acquire-worker.cc +++ b/apt-pkg/acquire-worker.cc @@ -287,9 +287,9 @@ bool pkgAcquire::Worker::RunMessages() Log->Pulse(Owner->GetOwner()); OwnerQ->ItemDone(Itm); - unsigned long const ServerSize = atol(LookupTag(Message,"Size","0").c_str()); + unsigned long long const ServerSize = atoll(LookupTag(Message,"Size","0").c_str()); if (TotalSize != 0 && ServerSize != TotalSize) - _error->Warning("Size of file %s is not what the server reported %s %lu", + _error->Warning("Size of file %s is not what the server reported %s %llu", Owner->DestFile.c_str(), LookupTag(Message,"Size","0").c_str(),TotalSize); // see if there is a hash to verify diff --git a/apt-pkg/acquire-worker.h b/apt-pkg/acquire-worker.h index 62545829a..ce19091e4 100644 --- a/apt-pkg/acquire-worker.h +++ b/apt-pkg/acquire-worker.h @@ -247,17 +247,17 @@ class pkgAcquire::Worker : public WeakPointable /** \brief How many bytes of the file have been downloaded. Zero * if the current progress of the file cannot be determined. */ - unsigned long CurrentSize; + unsigned long long CurrentSize; /** \brief The total number of bytes to be downloaded. Zero if the * total size of the final is unknown. */ - unsigned long TotalSize; + unsigned long long TotalSize; /** \brief How much of the file was already downloaded prior to * starting this worker. */ - unsigned long ResumePoint; + unsigned long long ResumePoint; /** \brief Tell the subprocess to download the given item. * diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 939c7f4c5..fff487dc8 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -912,7 +912,7 @@ void pkgAcquireStatus::Stop() // AcquireStatus::Fetched - Called when a byte set has been fetched /*{{{*/ // --------------------------------------------------------------------- /* This is used to get accurate final transfer rate reporting. */ -void pkgAcquireStatus::Fetched(unsigned long Size,unsigned long Resume) +void pkgAcquireStatus::Fetched(unsigned long long Size,unsigned long long Resume) { FetchedBytes += Size - Resume; } diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 7db7a9958..8fad91497 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -148,12 +148,7 @@ class pkgAcquire /** \brief The progress indicator for this download. */ pkgAcquireStatus *Log; - /** \brief The total size of the files which are to be fetched. - * - * This is not necessarily the total number of bytes to download - * when, e.g., download resumption and list updates via patches - * are taken into account. - */ + /** \brief The number of files which are to be fetched. */ unsigned long ToFetch; // Configurable parameters for the scheduler @@ -484,7 +479,7 @@ class pkgAcquire::Queue * * \todo Unimplemented. Implement it or remove? */ - bool ItemStart(QItem *Itm,unsigned long Size); + bool ItemStart(QItem *Itm,unsigned long long Size); /** \brief Remove the given item from this queue and set its state * to pkgAcquire::Item::StatDone. @@ -734,7 +729,7 @@ class pkgAcquireStatus * * \param ResumePoint How much of the file was already fetched. */ - virtual void Fetched(unsigned long Size,unsigned long ResumePoint); + virtual void Fetched(unsigned long long Size,unsigned long long ResumePoint); /** \brief Invoked when the user should be prompted to change the * inserted removable media. diff --git a/debian/changelog b/debian/changelog index af6db28b9..cfbea1df7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,8 +4,11 @@ apt (0.8.16~exp3) experimental; urgency=low * apt-pkg/pkgcache.h: - readd All{Foreign,Allowed} as suggested by Julian to remain strictly API compatible + * apt-pkg/acquire*.{cc,h}: + - try even harder to support really big files in the fetcher by + converting (hopefully) everything to 'long long' (Closes: #632271) - -- David Kalnischkies Wed, 29 Jun 2011 19:38:44 +0200 + -- David Kalnischkies Tue, 05 Jul 2011 15:56:42 +0200 apt (0.8.16~exp2) experimental; urgency=low -- cgit v1.2.3 From 30fd3c9f07a4222e55c6d776b2937c2697a79254 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 5 Jul 2011 19:00:42 +0200 Subject: cherrypick sources.list option documentation from my sid branch --- debian/changelog | 34 ++++++++++++++++++++++++++++++++++ doc/sources.list.5.xml | 18 +++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index cfbea1df7..73881ac54 100644 --- a/debian/changelog +++ b/debian/changelog @@ -50,6 +50,40 @@ apt (0.8.16~exp1) experimental; urgency=low -- Michael Vogt Wed, 29 Jun 2011 12:40:31 +0200 +apt (0.8.15.2) unstable; urgency=low + + [ David Kalnischkies ] + * apt-pkg/pkgcachegen.cc: + - fallback to memory if file is not writeable even if access() + told us the opposite before (e.g. in fakeroot 1.16) (Closes: #630591) + * doc/sources.list.5.xml: + - document available [options] for sources.list entries (Closes: 632441) + + -- David Kalnischkies Tue, 05 Jul 2011 15:12:21 +0200 + +apt (0.8.15.1) unstable; urgency=low + + [ David Kalnischkies ] + * doc/makefile: + - create doxygen directory to avoid depending on magic (Closes: #628799) + * cmdline/apt-key: + - explicitly state that net-update is not supported if no url is set + - require to be root for add, rm, update and net-update + - clarify update vs. net-update in different distros (Closes: #632043) + * debian/apt.symbols: + - forgot 'mips' in the list for all architecture dependent symbols + - comment out gcc-4.5 specific symbols as gcc-4.6 is now default + - the symbol for PrintStatus() is architecture dependent + * apt-pkg/policy.cc: + - do not segfault in pinning if a package with this name doesn't exist. + Thanks to Ferdinand Thommes for the report! + - Defaults is a vector of Pin not of PkgPin + - ensure that only the first specific stanza for a package is used + - save all stanzas which had no effect in Unmatched + - allow package:architecure in Package: + + -- Michael Vogt Thu, 30 Jun 2011 10:05:36 +0200 + apt (0.8.15) unstable; urgency=low [ Julian Andres Klode ] diff --git a/doc/sources.list.5.xml b/doc/sources.list.5.xml index 837f07683..fab125b4e 100644 --- a/doc/sources.list.5.xml +++ b/doc/sources.list.5.xml @@ -78,7 +78,7 @@ The format for a sources.list entry using the deb and deb-src types is: - deb uri distribution [component1] [component2] [...] + deb [ options ] uri distribution [component1] [component2] [...] The URI for the deb type must specify the base of the Debian distribution, from which APT will find the information it needs. @@ -109,6 +109,17 @@ simultaneous anonymous users. APT also parallelizes connections to different hosts to more effectively deal with sites with low bandwidth. + options is always optional and needs to be surounded by + square brackets. It can consist of multiple settings in the form + setting=value. + Multiple settings are separated by spaces. The following settings are supported by APT, + note through that unsupported settings will be ignored silently: + arch=arch1,arch2,… + can be used to specify for which architectures packages information should + be downloaded. If this option is not set all architectures defined by the + APT::Architectures option will be downloaded. + + It is important to list sources in order of preference, with the most preferred source listed first. Typically this will result in sorting by speed from fastest to slowest (CD-ROM followed by hosts on a local @@ -206,6 +217,11 @@ deb http://security.debian.org/ &stable-codename;/updates main contrib non-free Source line for the above deb-src file:/home/jason/debian unstable main contrib non-free + The first line gets package information for the architectures in APT::Architectures + while the second always retrieves amd64 and armel. + deb http://ftp.debian.org/debian &stable-codename; main +deb [ arch=amd64,armel ] http://ftp.debian.org/debian &stable-codename; main + Uses HTTP to access the archive at archive.debian.org, and uses only the hamm/main area. deb http://archive.debian.org/debian-archive hamm main -- cgit v1.2.3 From c31c1dded85ee1e88231a041aac7e507f2ed426c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 13 Jul 2011 16:37:15 +0200 Subject: move implementation of checksums around by abstracting even more --- apt-pkg/contrib/hashsum.cc | 28 +++++++++++++++++++++++++ apt-pkg/contrib/hashsum_template.h | 20 ++++++++++++++++++ apt-pkg/contrib/md5.cc | 23 -------------------- apt-pkg/contrib/md5.h | 16 ++++++-------- apt-pkg/contrib/sha1.cc | 23 -------------------- apt-pkg/contrib/sha1.h | 11 +++------- apt-pkg/contrib/sha2.cc | 43 -------------------------------------- apt-pkg/contrib/sha2.h | 27 +++++++----------------- apt-pkg/makefile | 2 +- 9 files changed, 66 insertions(+), 127 deletions(-) create mode 100644 apt-pkg/contrib/hashsum.cc delete mode 100644 apt-pkg/contrib/sha2.cc diff --git a/apt-pkg/contrib/hashsum.cc b/apt-pkg/contrib/hashsum.cc new file mode 100644 index 000000000..b97eaf831 --- /dev/null +++ b/apt-pkg/contrib/hashsum.cc @@ -0,0 +1,28 @@ +// Cryptographic API Base + +#include +#include "hashsum_template.h" + +// Summation::AddFD - Add content of file into the checksum /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool SummationImplementation::AddFD(int const Fd, unsigned long Size) { + unsigned char Buf[64 * 64]; + int Res = 0; + int ToEOF = (Size == 0); + unsigned long n = sizeof(Buf); + if (!ToEOF) + n = std::min(Size, n); + while (Size != 0 || ToEOF) + { + Res = read(Fd, Buf, n); + if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read + return false; + if (ToEOF && Res == 0) // EOF + break; + Size -= Res; + Add(Buf,Res); + } + return true; +} + /*}}}*/ diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h index 7667baf92..2847f3308 100644 --- a/apt-pkg/contrib/hashsum_template.h +++ b/apt-pkg/contrib/hashsum_template.h @@ -84,4 +84,24 @@ class HashSumValue } }; +class SummationImplementation +{ + public: + virtual bool Add(const unsigned char *inbuf, unsigned long inlen) = 0; + inline bool Add(const char *inbuf, unsigned long const inlen) + { return Add((unsigned char *)inbuf, inlen); }; + + inline bool Add(const unsigned char *Data) + { return Add(Data, strlen((const char *)Data)); }; + inline bool Add(const char *Data) + { return Add((const unsigned char *)Data, strlen((const char *)Data)); }; + + inline bool Add(const unsigned char *Beg, const unsigned char *End) + { return Add(Beg, End - Beg); }; + inline bool Add(const char *Beg, const char *End) + { return Add((const unsigned char *)Beg, End - Beg); }; + + bool AddFD(int Fd, unsigned long Size); +}; + #endif diff --git a/apt-pkg/contrib/md5.cc b/apt-pkg/contrib/md5.cc index 6820d3951..65e20e9bb 100644 --- a/apt-pkg/contrib/md5.cc +++ b/apt-pkg/contrib/md5.cc @@ -231,29 +231,6 @@ bool MD5Summation::Add(const unsigned char *data,unsigned long len) return true; } /*}}}*/ -// MD5Summation::AddFD - Add the contents of a FD to the hash /*{{{*/ -// --------------------------------------------------------------------- -/* */ -bool MD5Summation::AddFD(int Fd,unsigned long Size) -{ - unsigned char Buf[64*64]; - int Res = 0; - int ToEOF = (Size == 0); - while (Size != 0 || ToEOF) - { - unsigned n = sizeof(Buf); - if (!ToEOF) n = min(Size,(unsigned long)n); - Res = read(Fd,Buf,n); - if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read - return false; - if (ToEOF && Res == 0) // EOF - break; - Size -= Res; - Add(Buf,Res); - } - return true; -} - /*}}}*/ // MD5Summation::Result - Returns the value of the sum /*{{{*/ // --------------------------------------------------------------------- /* Because this must add in the last bytes of the series it prevents anyone diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h index 9cc88cfbe..e76428325 100644 --- a/apt-pkg/contrib/md5.h +++ b/apt-pkg/contrib/md5.h @@ -34,26 +34,22 @@ using std::min; #include "hashsum_template.h" -class MD5Summation; - typedef HashSumValue<128> MD5SumValue; -class MD5Summation +class MD5Summation : public SummationImplementation { uint32_t Buf[4]; unsigned char Bytes[2*4]; unsigned char In[16*4]; bool Done; - + public: - bool Add(const unsigned char *Data,unsigned long Size); - inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));}; - bool AddFD(int Fd,unsigned long Size); - inline bool Add(const unsigned char *Beg,const unsigned char *End) - {return Add(Beg,End-Beg);}; + bool Add(const unsigned char *inbuf, unsigned long inlen); + using SummationImplementation::Add; + MD5SumValue Result(); - + MD5Summation(); }; diff --git a/apt-pkg/contrib/sha1.cc b/apt-pkg/contrib/sha1.cc index 9a6725ef3..4b0552102 100644 --- a/apt-pkg/contrib/sha1.cc +++ b/apt-pkg/contrib/sha1.cc @@ -273,26 +273,3 @@ bool SHA1Summation::Add(const unsigned char *data,unsigned long len) return true; } /*}}}*/ -// SHA1Summation::AddFD - Add content of file into the checksum /*{{{*/ -// --------------------------------------------------------------------- -/* */ -bool SHA1Summation::AddFD(int Fd,unsigned long Size) -{ - unsigned char Buf[64 * 64]; - int Res = 0; - int ToEOF = (Size == 0); - while (Size != 0 || ToEOF) - { - unsigned n = sizeof(Buf); - if (!ToEOF) n = min(Size,(unsigned long)n); - Res = read(Fd,Buf,n); - if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read - return false; - if (ToEOF && Res == 0) // EOF - break; - Size -= Res; - Add(Buf,Res); - } - return true; -} - /*}}}*/ diff --git a/apt-pkg/contrib/sha1.h b/apt-pkg/contrib/sha1.h index e7683fa7b..2701fc67e 100644 --- a/apt-pkg/contrib/sha1.h +++ b/apt-pkg/contrib/sha1.h @@ -23,11 +23,9 @@ using std::min; #include "hashsum_template.h" -class SHA1Summation; - typedef HashSumValue<160> SHA1SumValue; -class SHA1Summation +class SHA1Summation : public SummationImplementation { /* assumes 64-bit alignment just in case */ unsigned char Buffer[64] __attribute__((aligned(8))); @@ -36,12 +34,9 @@ class SHA1Summation bool Done; public: + bool Add(const unsigned char *inbuf, unsigned long inlen); + using SummationImplementation::Add; - bool Add(const unsigned char *inbuf,unsigned long inlen); - inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));}; - bool AddFD(int Fd,unsigned long Size); - inline bool Add(const unsigned char *Beg,const unsigned char *End) - {return Add(Beg,End-Beg);}; SHA1SumValue Result(); SHA1Summation(); diff --git a/apt-pkg/contrib/sha2.cc b/apt-pkg/contrib/sha2.cc deleted file mode 100644 index 4604d3167..000000000 --- a/apt-pkg/contrib/sha2.cc +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Cryptographic API. {{{ - * - * SHA-512, as specified in - * http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf - * - * 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. - * - */ /*}}}*/ - -#ifdef __GNUG__ -#pragma implementation "apt-pkg/sha2.h" -#endif - -#include -#include - -// SHA2Summation::AddFD - Add content of file into the checksum /*{{{*/ -// --------------------------------------------------------------------- -/* */ -bool SHA2SummationBase::AddFD(int Fd,unsigned long Size){ - unsigned char Buf[64 * 64]; - int Res = 0; - int ToEOF = (Size == 0); - while (Size != 0 || ToEOF) - { - unsigned n = sizeof(Buf); - if (!ToEOF) n = min(Size,(unsigned long)n); - Res = read(Fd,Buf,n); - if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read - return false; - if (ToEOF && Res == 0) // EOF - break; - Size -= Res; - Add(Buf,Res); - } - return true; -} - /*}}}*/ - diff --git a/apt-pkg/contrib/sha2.h b/apt-pkg/contrib/sha2.h index bd5472527..386225889 100644 --- a/apt-pkg/contrib/sha2.h +++ b/apt-pkg/contrib/sha2.h @@ -22,31 +22,16 @@ #include "sha2_internal.h" #include "hashsum_template.h" -using std::string; -using std::min; - -class SHA512Summation; -class SHA256Summation; - typedef HashSumValue<512> SHA512SumValue; typedef HashSumValue<256> SHA256SumValue; -class SHA2SummationBase +class SHA2SummationBase : public SummationImplementation { protected: bool Done; public: - virtual bool Add(const unsigned char *inbuf,unsigned long inlen) = 0; - virtual bool AddFD(int Fd,unsigned long Size); + bool Add(const unsigned char *inbuf, unsigned long len) = 0; - inline bool Add(const char *Data) - { - return Add((unsigned char *)Data,strlen(Data)); - }; - inline bool Add(const unsigned char *Beg,const unsigned char *End) - { - return Add(Beg,End-Beg); - }; void Result(); }; @@ -56,13 +41,15 @@ class SHA256Summation : public SHA2SummationBase unsigned char Sum[32]; public: - virtual bool Add(const unsigned char *inbuf, unsigned long len) + bool Add(const unsigned char *inbuf, unsigned long len) { if (Done) return false; SHA256_Update(&ctx, inbuf, len); return true; }; + using SummationImplementation::Add; + SHA256SumValue Result() { if (!Done) { @@ -86,13 +73,15 @@ class SHA512Summation : public SHA2SummationBase unsigned char Sum[64]; public: - virtual bool Add(const unsigned char *inbuf, unsigned long len) + bool Add(const unsigned char *inbuf, unsigned long len) { if (Done) return false; SHA512_Update(&ctx, inbuf, len); return true; }; + using SummationImplementation::Add; + SHA512SumValue Result() { if (!Done) { diff --git a/apt-pkg/makefile b/apt-pkg/makefile index b11e35250..69d6cbffd 100644 --- a/apt-pkg/makefile +++ b/apt-pkg/makefile @@ -20,7 +20,7 @@ APT_DOMAIN:=libapt-pkg$(LIBAPTPKG_MAJOR) # Source code for the contributed non-core things SOURCE = contrib/mmap.cc contrib/error.cc contrib/strutl.cc \ contrib/configuration.cc contrib/progress.cc contrib/cmndline.cc \ - contrib/md5.cc contrib/sha1.cc contrib/sha2.cc \ + contrib/hashsum.cc contrib/md5.cc contrib/sha1.cc \ contrib/sha2_internal.cc\ contrib/hashes.cc \ contrib/cdromutl.cc contrib/crc-16.cc contrib/netrc.cc \ -- cgit v1.2.3 From 67dc3830798e6b59a9fce03682c9802233b0a1fe Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 13 Jul 2011 19:34:11 +0200 Subject: move hash test to libapt-testcases and add a few more tests --- test/hash.cc | 82 ------------------------------ test/libapt/hashsums_test.cc | 116 +++++++++++++++++++++++++++++++++++++++++++ test/libapt/makefile | 6 +++ test/libapt/run-tests | 7 +++ 4 files changed, 129 insertions(+), 82 deletions(-) delete mode 100644 test/hash.cc create mode 100644 test/libapt/hashsums_test.cc diff --git a/test/hash.cc b/test/hash.cc deleted file mode 100644 index 88f09fca0..000000000 --- a/test/hash.cc +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include -#include -#include -#include - -using namespace std; - -template void Test(const char *In,const char *Out) -{ - T Sum; - Sum.Add(In); - - cout << "expected: '" << Out << "'" << endl; - cout << "got : '" << Sum.Result().Value() << "'" << endl; - cout << "got : '" << Sum.Result().Value() << "'" << endl; - cout << "got : '" << Sum.Result().Value() << "'" << endl; - if (stringcasecmp(Sum.Result().Value(), Out) != 0) { - cout << "FAIL" << endl << endl; - abort(); - } else { - cout << "PASS" << endl << endl; - } -} - -template void TestMill(const char *Out) -{ - T Sum; - - const unsigned char As[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - unsigned Count = 1000000; - for (; Count != 0;) - { - if (Count >= 64) - { - Sum.Add(As,64); - Count -= 64; - } - else - { - Sum.Add(As,Count); - Count = 0; - } - } - - if (stringcasecmp(Sum.Result().Value(), Out) != 0) - abort(); -} - -int main() -{ - // From FIPS PUB 180-1 - Test("abc","A9993E364706816ABA3E25717850C26C9CD0D89D"); - Test("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", - "84983E441C3BD26EBAAE4AA1F95129E5E54670F1"); - TestMill("34AA973CD4C4DAA4F61EEB2BDBAD27316534016F"); - - // MD5 tests from RFC 1321 - Test("","d41d8cd98f00b204e9800998ecf8427e"); - Test("a","0cc175b9c0f1b6a831c399e269772661"); - Test("abc","900150983cd24fb0d6963f7d28e17f72"); - Test("message digest","f96b697d7cb7938d525a2f31aaf161d0"); - Test("abcdefghijklmnopqrstuvwxyz","c3fcd3d76192e4007dfb496cca67e13b"); - Test("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - "d174ab98d277d9f5a5611c2c9f419d9f"); - Test("12345678901234567890123456789012345678901234567890123456789012345678901234567890", - "57edf4a22be3c955ac49da2e2107b67a"); - - // SHA-256, From FIPS 180-2 - Test("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", - "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"); - - // SHA-512, From - Test( - "abc", - "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" - "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"); - - return 0; -} - - diff --git a/test/libapt/hashsums_test.cc b/test/libapt/hashsums_test.cc new file mode 100644 index 000000000..12096be15 --- /dev/null +++ b/test/libapt/hashsums_test.cc @@ -0,0 +1,116 @@ +#include +#include +#include +#include +#include +#include + +#include + +#include "assert.h" + +template void Test(const char *In,const char *Out) +{ + T Sum; + Sum.Add(In); + equals(Sum.Result().Value(), Out); +} + +template void TestMill(const char *Out) +{ + T Sum; + + const unsigned char As[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + unsigned Count = 1000000; + for (; Count != 0;) + { + if (Count >= 64) + { + Sum.Add(As,64); + Count -= 64; + } + else + { + Sum.Add(As,Count); + Count = 0; + } + } + + if (stringcasecmp(Sum.Result().Value(), Out) != 0) + abort(); +} + +int main(int argc, char** argv) +{ + // From FIPS PUB 180-1 + Test("","da39a3ee5e6b4b0d3255bfef95601890afd80709"); + Test("abc","a9993e364706816aba3e25717850c26c9cd0d89d"); + Test("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "84983e441c3bd26ebaae4aa1f95129e5e54670f1"); + TestMill("34aa973cd4c4daa4f61eeb2bdbad27316534016f"); + + // MD5 tests from RFC 1321 + Test("","d41d8cd98f00b204e9800998ecf8427e"); + Test("a","0cc175b9c0f1b6a831c399e269772661"); + Test("abc","900150983cd24fb0d6963f7d28e17f72"); + Test("message digest","f96b697d7cb7938d525a2f31aaf161d0"); + Test("abcdefghijklmnopqrstuvwxyz","c3fcd3d76192e4007dfb496cca67e13b"); + Test("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + "d174ab98d277d9f5a5611c2c9f419d9f"); + Test("12345678901234567890123456789012345678901234567890123456789012345678901234567890", + "57edf4a22be3c955ac49da2e2107b67a"); + + // SHA-256, From FIPS 180-2 + Test("", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); + Test("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"); + + // SHA-512 + Test("", + "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce" + "47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"); + Test( + "abc", + "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" + "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"); + + + Test("The quick brown fox jumps over the lazy dog", "9e107d9d372bb6826bd81d3542a419d6"); + Test("The quick brown fox jumps over the lazy dog.", "e4d909c290d0fb1ca068ffaddf22cbd0"); + Test("The quick brown fox jumps over the lazy dog", "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12"); + Test("The quick brown fox jumps over the lazy cog", "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3"); + Test("The quick brown fox jumps over the lazy dog", "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592"); + Test("The quick brown fox jumps over the lazy dog.", "ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c"); + Test("The quick brown fox jumps over the lazy dog", "07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb64" + "2e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6"); + Test("The quick brown fox jumps over the lazy dog.", "91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bb" + "c6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed"); + + FILE* fd = fopen(argv[1], "r"); + if (fd == NULL) { + std::cerr << "Can't open file for 1. testing: " << argv[1] << std::endl; + return 1; + } + Hashes hashes; + hashes.AddFD(fileno(fd)); + equals(argv[2], hashes.MD5.Result().Value()); + equals(argv[3], hashes.SHA1.Result().Value()); + equals(argv[4], hashes.SHA256.Result().Value()); + equals(argv[5], hashes.SHA512.Result().Value()); + + fseek(fd, 0L, SEEK_END); + unsigned long sz = ftell(fd); + fseek(fd, 0L, SEEK_SET); + + Hashes hashes2; + hashes2.AddFD(fileno(fd), sz); + fclose(fd); + equals(argv[2], hashes2.MD5.Result().Value()); + equals(argv[3], hashes2.SHA1.Result().Value()); + equals(argv[4], hashes2.SHA256.Result().Value()); + equals(argv[5], hashes2.SHA512.Result().Value()); + + return 0; +} + + diff --git a/test/libapt/makefile b/test/libapt/makefile index 50058262e..1d36f0c7c 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -46,3 +46,9 @@ PROGRAM = GlobalError${BASENAME} SLIBS = -lapt-pkg SOURCE = globalerror_test.cc include $(PROGRAM_H) + +# test the different Hashsum classes +PROGRAM = HashSums${BASENAME} +SLIBS = -lapt-pkg +SOURCE = hashsums_test.cc +include $(PROGRAM_H) diff --git a/test/libapt/run-tests b/test/libapt/run-tests index 4b71c2097..0eea6d4f8 100755 --- a/test/libapt/run-tests +++ b/test/libapt/run-tests @@ -53,6 +53,13 @@ do "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-pt" \ "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-se~" \ "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak" + elif [ $name = "HashSums${EXT}" ]; then + TMP="$(mktemp)" + dmesg > $TMP + echo -n "Testing with \033[1;35m${name}\033[0m ... " + LD_LIBRARY_PATH=${LDPATH} ${testapp} $TMP $(md5sum $TMP | cut -d' ' -f 1) $(sha1sum $TMP | cut -d' ' -f 1) $(sha256sum $TMP | cut -d' ' -f 1) $(sha512sum $TMP | cut -d' ' -f 1) && echo "\033[1;32mOKAY\033[0m" || echo "\033[1;31mFAILED\033[0m" + rm $TMP + continue fi echo -n "Testing with \033[1;35m${name}\033[0m ... " -- cgit v1.2.3 From 96c9fb174df24fadcde516f26f89d1a64f42eea7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 13 Jul 2011 22:29:37 +0200 Subject: test that AddFD for single summations works, too --- test/libapt/hashsums_test.cc | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/test/libapt/hashsums_test.cc b/test/libapt/hashsums_test.cc index 12096be15..ff1536718 100644 --- a/test/libapt/hashsums_test.cc +++ b/test/libapt/hashsums_test.cc @@ -91,25 +91,50 @@ int main(int argc, char** argv) std::cerr << "Can't open file for 1. testing: " << argv[1] << std::endl; return 1; } + { Hashes hashes; hashes.AddFD(fileno(fd)); equals(argv[2], hashes.MD5.Result().Value()); equals(argv[3], hashes.SHA1.Result().Value()); equals(argv[4], hashes.SHA256.Result().Value()); equals(argv[5], hashes.SHA512.Result().Value()); - + } fseek(fd, 0L, SEEK_END); unsigned long sz = ftell(fd); fseek(fd, 0L, SEEK_SET); - - Hashes hashes2; - hashes2.AddFD(fileno(fd), sz); + { + Hashes hashes; + hashes.AddFD(fileno(fd), sz); + equals(argv[2], hashes.MD5.Result().Value()); + equals(argv[3], hashes.SHA1.Result().Value()); + equals(argv[4], hashes.SHA256.Result().Value()); + equals(argv[5], hashes.SHA512.Result().Value()); + } + fseek(fd, 0L, SEEK_SET); + { + MD5Summation md5; + md5.AddFD(fileno(fd)); + equals(argv[2], md5.Result().Value()); + } + fseek(fd, 0L, SEEK_SET); + { + SHA1Summation sha1; + sha1.AddFD(fileno(fd)); + equals(argv[3], sha1.Result().Value()); + } + fseek(fd, 0L, SEEK_SET); + { + SHA256Summation sha2; + sha2.AddFD(fileno(fd)); + equals(argv[4], sha2.Result().Value()); + } + fseek(fd, 0L, SEEK_SET); + { + SHA512Summation sha2; + sha2.AddFD(fileno(fd)); + equals(argv[5], sha2.Result().Value()); + } fclose(fd); - equals(argv[2], hashes2.MD5.Result().Value()); - equals(argv[3], hashes2.SHA1.Result().Value()); - equals(argv[4], hashes2.SHA256.Result().Value()); - equals(argv[5], hashes2.SHA512.Result().Value()); - return 0; } -- cgit v1.2.3 From 1dab797ca6dc0357474675a0f132c962dee4a2c2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 13 Jul 2011 23:10:38 +0200 Subject: enable Hashes::AddFD() to skip creation of certain hashes --- apt-pkg/contrib/hashes.cc | 19 ++++++++++++------- apt-pkg/contrib/hashes.h | 5 ++++- apt-pkg/contrib/hashsum.cc | 5 ++--- apt-pkg/contrib/hashsum_template.h | 2 +- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index 66ae33146..d217747df 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -107,7 +107,8 @@ string HashString::toStr() const // Hashes::AddFD - Add the contents of the FD /*{{{*/ // --------------------------------------------------------------------- /* */ -bool Hashes::AddFD(int Fd,unsigned long Size) +bool Hashes::AddFD(int const Fd,unsigned long Size, bool const addMD5, + bool const addSHA1, bool const addSHA256, bool const addSHA512) { unsigned char Buf[64*64]; int Res = 0; @@ -118,14 +119,18 @@ bool Hashes::AddFD(int Fd,unsigned long Size) if (!ToEOF) n = min(Size,(unsigned long)n); Res = read(Fd,Buf,n); if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read - return false; + return false; if (ToEOF && Res == 0) // EOF - break; + break; Size -= Res; - MD5.Add(Buf,Res); - SHA1.Add(Buf,Res); - SHA256.Add(Buf,Res); - SHA512.Add(Buf,Res); + if (addMD5 == true) + MD5.Add(Buf,Res); + if (addSHA1 == true) + SHA1.Add(Buf,Res); + if (addSHA256 == true) + SHA256.Add(Buf,Res); + if (addSHA512 == true) + SHA512.Add(Buf,Res); } return true; } diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h index 4b6a08b1f..e702fcca2 100644 --- a/apt-pkg/contrib/hashes.h +++ b/apt-pkg/contrib/hashes.h @@ -67,7 +67,10 @@ class Hashes return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size) && SHA512.Add(Data,Size); }; inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));}; - bool AddFD(int Fd,unsigned long Size); + inline bool AddFD(int const Fd,unsigned long Size = 0) + { return AddFD(Fd, Size, true, true, true, true); }; + bool AddFD(int const Fd, unsigned long Size, bool const addMD5, + bool const addSHA1, bool const addSHA256, bool const addSHA512); inline bool Add(const unsigned char *Beg,const unsigned char *End) {return Add(Beg,End-Beg);}; }; diff --git a/apt-pkg/contrib/hashsum.cc b/apt-pkg/contrib/hashsum.cc index b97eaf831..728747d7a 100644 --- a/apt-pkg/contrib/hashsum.cc +++ b/apt-pkg/contrib/hashsum.cc @@ -10,11 +10,10 @@ bool SummationImplementation::AddFD(int const Fd, unsigned long Size) { unsigned char Buf[64 * 64]; int Res = 0; int ToEOF = (Size == 0); - unsigned long n = sizeof(Buf); - if (!ToEOF) - n = std::min(Size, n); while (Size != 0 || ToEOF) { + unsigned n = sizeof(Buf); + if (!ToEOF) n = min(Size,(unsigned long)n); Res = read(Fd, Buf, n); if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read return false; diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h index 2847f3308..85d94c2af 100644 --- a/apt-pkg/contrib/hashsum_template.h +++ b/apt-pkg/contrib/hashsum_template.h @@ -101,7 +101,7 @@ class SummationImplementation inline bool Add(const char *Beg, const char *End) { return Add((const unsigned char *)Beg, End - Beg); }; - bool AddFD(int Fd, unsigned long Size); + bool AddFD(int Fd, unsigned long Size = 0); }; #endif -- cgit v1.2.3 From 8c4e1f97686c412f88bb57827a84b776626d9980 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 13 Jul 2011 23:23:04 +0200 Subject: * ftparchive/writer.cc: - generate all checksums in one run over the file for Release --- debian/changelog | 4 +++- ftparchive/writer.cc | 34 ++++++++-------------------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9aeb2f809..7b1ca1df0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,13 +7,15 @@ apt (0.8.16~exp3) UNRELEASEDexperimental; urgency=low * apt-pkg/acquire*.{cc,h}: - try even harder to support really big files in the fetcher by converting (hopefully) everything to 'long long' (Closes: #632271) + * ftparchive/writer.cc: + - generate all checksums in one run over the file for Release [ Michael Vogt ] * merge fixes from the debian/unstable upload * merge lp:~mvo/apt/sha512-template to get fixes for the sha1/md5 verifiation (closes: #632520) - -- David Kalnischkies Tue, 05 Jul 2011 15:56:42 +0200 + -- David Kalnischkies Wed, 13 Jul 2011 23:22:14 +0200 apt (0.8.16~exp2) experimental; urgency=low diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index c43e8f4b4..60db8b990 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -19,8 +19,7 @@ #include #include #include -#include -#include +#include #include #include @@ -1040,35 +1039,18 @@ bool ReleaseWriter::DoPackage(string FileName) CheckSums[NewFileName].size = fd.Size(); + Hashes hs; + hs.AddFD(fd.Fd(), 0, DoMD5, DoSHA1, DoSHA256, DoSHA512); if (DoMD5 == true) - { - MD5Summation MD5; - MD5.AddFD(fd.Fd(), fd.Size()); - CheckSums[NewFileName].MD5 = MD5.Result(); - fd.Seek(0); - } + CheckSums[NewFileName].MD5 = hs.MD5.Result(); if (DoSHA1 == true) - { - SHA1Summation SHA1; - SHA1.AddFD(fd.Fd(), fd.Size()); - CheckSums[NewFileName].SHA1 = SHA1.Result(); - fd.Seek(0); - } + CheckSums[NewFileName].SHA1 = hs.SHA1.Result(); if (DoSHA256 == true) - { - SHA256Summation SHA256; - SHA256.AddFD(fd.Fd(), fd.Size()); - CheckSums[NewFileName].SHA256 = SHA256.Result(); - } - + CheckSums[NewFileName].SHA256 = hs.SHA256.Result(); if (DoSHA512 == true) - { - SHA512Summation SHA512; - SHA512.AddFD(fd.Fd(), fd.Size()); - CheckSums[NewFileName].SHA512 = SHA512.Result(); - } + CheckSums[NewFileName].SHA512 = hs.SHA512.Result(); fd.Close(); - + return true; } -- cgit v1.2.3 From 2dcf7b8f9b9e037901339ddef7d94a6a2bab90db Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 14 Jul 2011 01:44:35 +0200 Subject: fix sha512 calculation in Hashes::VerifyFiles() --- apt-pkg/contrib/hashes.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index d217747df..4407574fa 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -53,31 +53,30 @@ HashString::HashString(string StringedHash) /*{{{*/ /*}}}*/ bool HashString::VerifyFile(string filename) const /*{{{*/ { - FileFd fd; - MD5Summation MD5; - SHA1Summation SHA1; - SHA256Summation SHA256; - SHA256Summation SHA512; string fileHash; FileFd Fd(filename, FileFd::ReadOnly); - if(Type == "MD5Sum") + if(Type == "MD5Sum") { + MD5Summation MD5; MD5.AddFD(Fd.Fd(), Fd.Size()); fileHash = (string)MD5.Result(); - } + } else if (Type == "SHA1") { + SHA1Summation SHA1; SHA1.AddFD(Fd.Fd(), Fd.Size()); fileHash = (string)SHA1.Result(); - } - else if (Type == "SHA256") + } + else if (Type == "SHA256") { + SHA256Summation SHA256; SHA256.AddFD(Fd.Fd(), Fd.Size()); fileHash = (string)SHA256.Result(); } - else if (Type == "SHA512") + else if (Type == "SHA512") { + SHA512Summation SHA512; SHA512.AddFD(Fd.Fd(), Fd.Size()); fileHash = (string)SHA512.Result(); } -- cgit v1.2.3 From d4cfaed3d822b207f24ce11768ee14682a0c8f6b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 14 Jul 2011 12:08:16 +0200 Subject: * cmdline/apt-get.cc: - add an --assume-no option for testing to say 'no' to everything --- cmdline/apt-get.cc | 8 +++++++- debian/changelog | 4 +++- doc/apt-get.8.xml | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 66ebd30b8..94e078cb3 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -135,6 +135,11 @@ bool YnPrompt(bool Default=true) c1out << _("Y") << endl; return true; } + else if (_config->FindB("APT::Get::Assume-No",false) == true) + { + c1out << _("N") << endl; + return false; + } char response[1024] = ""; cin.getline(response, sizeof(response)); @@ -3245,7 +3250,8 @@ int main(int argc,const char *argv[]) /*{{{*/ {'s',"dry-run","APT::Get::Simulate",0}, {'s',"no-act","APT::Get::Simulate",0}, {'y',"yes","APT::Get::Assume-Yes",0}, - {'y',"assume-yes","APT::Get::Assume-Yes",0}, + {'y',"assume-yes","APT::Get::Assume-Yes",0}, + {0,"assume-no","APT::Get::Assume-No",0}, {'f',"fix-broken","APT::Get::Fix-Broken",0}, {'u',"show-upgraded","APT::Get::Show-Upgraded",0}, {'m',"ignore-missing","APT::Get::Fix-Missing",0}, diff --git a/debian/changelog b/debian/changelog index 7b1ca1df0..5686e02fa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,13 +9,15 @@ apt (0.8.16~exp3) UNRELEASEDexperimental; urgency=low converting (hopefully) everything to 'long long' (Closes: #632271) * ftparchive/writer.cc: - generate all checksums in one run over the file for Release + * cmdline/apt-get.cc: + - add an --assume-no option for testing to say 'no' to everything [ Michael Vogt ] * merge fixes from the debian/unstable upload * merge lp:~mvo/apt/sha512-template to get fixes for the sha1/md5 verifiation (closes: #632520) - -- David Kalnischkies Wed, 13 Jul 2011 23:22:14 +0200 + -- David Kalnischkies Thu, 14 Jul 2011 12:01:53 +0200 apt (0.8.16~exp2) experimental; urgency=low diff --git a/doc/apt-get.8.xml b/doc/apt-get.8.xml index 11b53e5e7..23e682fd9 100644 --- a/doc/apt-get.8.xml +++ b/doc/apt-get.8.xml @@ -422,6 +422,11 @@ Configuration Item: APT::Get::Assume-Yes. + + Automatic "no" to all prompts. + Configuration Item: APT::Get::Assume-No. + + Show upgraded packages; Print out a list of all packages that are to be upgraded. -- cgit v1.2.3 From dbbc549457825d5b6507fdd62bcf323ed3a3fb2a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 14 Jul 2011 15:54:25 +0200 Subject: replace the last standing double's with long long --- apt-pkg/acquire.cc | 9 ++++----- apt-pkg/acquire.h | 14 ++++++-------- cmdline/acqprogress.cc | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index fff487dc8..2064abc50 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -799,7 +799,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) } // Compute the current completion - unsigned long ResumeSize = 0; + unsigned long long ResumeSize = 0; for (pkgAcquire::Worker *I = Owner->WorkersBegin(); I != 0; I = Owner->WorkerStep(I)) if (I->CurrentItem != 0 && I->CurrentItem->Owner->Complete == false) @@ -838,7 +838,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) else CurrentCPS = ((CurrentBytes - ResumeSize) - LastBytes)/Delta; LastBytes = CurrentBytes - ResumeSize; - ElapsedTime = (unsigned long)Delta; + ElapsedTime = (unsigned long long)Delta; Time = NewTime; } @@ -849,8 +849,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) char msg[200]; long i = CurrentItems < TotalItems ? CurrentItems + 1 : CurrentItems; - unsigned long ETA = - (unsigned long)((TotalBytes - CurrentBytes) / CurrentCPS); + unsigned long long const ETA = (TotalBytes - CurrentBytes) / CurrentCPS; // only show the ETA if it makes sense if (ETA > 0 && ETA < 172800 /* two days */ ) @@ -906,7 +905,7 @@ void pkgAcquireStatus::Stop() else CurrentCPS = FetchedBytes/Delta; LastBytes = CurrentBytes; - ElapsedTime = (unsigned int)Delta; + ElapsedTime = (unsigned long long)Delta; } /*}}}*/ // AcquireStatus::Fetched - Called when a byte set has been fetched /*{{{*/ diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 8fad91497..c9eaa67d1 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -650,8 +650,6 @@ struct pkgAcquire::MethodConfig /** \brief A monitor object for downloads controlled by the pkgAcquire class. {{{ * * \todo Why protected members? - * - * \todo Should the double members be uint64_t? */ class pkgAcquireStatus { @@ -669,34 +667,34 @@ class pkgAcquireStatus /** \brief The number of bytes fetched as of the previous call to * pkgAcquireStatus::Pulse, including local items. */ - double LastBytes; + unsigned long long LastBytes; /** \brief The current rate of download as of the most recent call * to pkgAcquireStatus::Pulse, in bytes per second. */ - double CurrentCPS; + unsigned long long CurrentCPS; /** \brief The number of bytes fetched as of the most recent call * to pkgAcquireStatus::Pulse, including local items. */ - double CurrentBytes; + unsigned long long CurrentBytes; /** \brief The total number of bytes that need to be fetched. * * \warning This member is inaccurate, as new items might be * enqueued while the download is in progress! */ - double TotalBytes; + unsigned long long TotalBytes; /** \brief The total number of bytes accounted for by items that * were successfully fetched. */ - double FetchedBytes; + unsigned long long FetchedBytes; /** \brief The amount of time that has elapsed since the download * started. */ - unsigned long ElapsedTime; + unsigned long long ElapsedTime; /** \brief The total number of items that need to be fetched. * diff --git a/cmdline/acqprogress.cc b/cmdline/acqprogress.cc index ba334ce05..d2db949ea 100644 --- a/cmdline/acqprogress.cc +++ b/cmdline/acqprogress.cc @@ -200,7 +200,7 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner) // Add the current progress if (Mode == Long) - snprintf(S,End-S," %lu",I->CurrentSize); + snprintf(S,End-S," %llu",I->CurrentSize); else { if (Mode == Medium || I->TotalSize == 0) -- cgit v1.2.3 From 4b42f43bed369817398b6c8d538f08e5bf6dff76 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 14 Jul 2011 21:06:09 +0200 Subject: * apt-pkg/deb/debmetaindex.cc: - add trusted=yes option to mark unsigned (local) repository as trusted based on a patch from Ansgar Burchardt, thanks a lot! (Closes: #596498) Note that "apt-get update" still warns about unknown signatures even when [trusted=yes] is given for the source. --- apt-pkg/deb/debmetaindex.cc | 39 ++++++++++++++---- apt-pkg/deb/debmetaindex.h | 3 ++ apt-pkg/metaindex.h | 4 ++ debian/changelog | 5 ++- doc/sources.list.5.xml | 9 ++++- .../test-bug-596498-trusted-unsigned-repo | 47 ++++++++++++++++++++++ 6 files changed, 97 insertions(+), 10 deletions(-) create mode 100755 test/integration/test-bug-596498-trusted-unsigned-repo diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index a91cc34e9..81afb22b6 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -142,11 +142,13 @@ string debReleaseIndex::TranslationIndexURI(const char *Type, const string &Sect return URI + "dists/" + Dist + "/" + TranslationIndexURISuffix(Type, Section); } -debReleaseIndex::debReleaseIndex(string const &URI, string const &Dist) { - this->URI = URI; - this->Dist = Dist; - this->Indexes = NULL; - this->Type = "deb"; +debReleaseIndex::debReleaseIndex(string const &URI, string const &Dist) : + metaIndex(URI, Dist, "deb"), Trusted(CHECK_TRUST) +{} + +debReleaseIndex::debReleaseIndex(string const &URI, string const &Dist, bool const Trusted) : + metaIndex(URI, Dist, "deb") { + SetTrusted(Trusted); } debReleaseIndex::~debReleaseIndex() { @@ -252,8 +254,22 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const return true; } +void debReleaseIndex::SetTrusted(bool const Trusted) +{ + if (Trusted == true) + this->Trusted = ALWAYS_TRUSTED; + else + this->Trusted = NEVER_TRUSTED; +} + bool debReleaseIndex::IsTrusted() const { + if (Trusted == ALWAYS_TRUSTED) + return true; + else if (Trusted == NEVER_TRUSTED) + return false; + + if(_config->FindB("APT::Authentication::TrustCDROM", false)) if(URI.substr(0,strlen("cdrom:")) == "cdrom:") return true; @@ -349,6 +365,7 @@ class debSLTypeDebian : public pkgSourceList::Type vector const Archs = (arch != Options.end()) ? VectorizeString(arch->second, ',') : APT::Configuration::getArchitectures(); + map::const_iterator const trusted = Options.find("trusted"); for (vector::const_iterator I = List.begin(); I != List.end(); I++) @@ -358,6 +375,9 @@ class debSLTypeDebian : public pkgSourceList::Type continue; debReleaseIndex *Deb = (debReleaseIndex *) (*I); + if (trusted != Options.end()) + Deb->SetTrusted(StringToBool(trusted->second, false)); + /* This check insures that there will be only one Release file queued for all the Packages files and Sources files it corresponds to. */ @@ -375,9 +395,14 @@ class debSLTypeDebian : public pkgSourceList::Type return true; } } + // No currently created Release file indexes this entry, so we create a new one. - // XXX determine whether this release is trusted or not - debReleaseIndex *Deb = new debReleaseIndex(URI, Dist); + debReleaseIndex *Deb; + if (trusted != Options.end()) + Deb = new debReleaseIndex(URI, Dist, StringToBool(trusted->second, false)); + else + Deb = new debReleaseIndex(URI, Dist); + if (IsSrc == true) Deb->PushSectionEntry ("source", new debReleaseIndex::debSectionEntry(Section, IsSrc)); else diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h index 0aaf7f14a..695cfa7cc 100644 --- a/apt-pkg/deb/debmetaindex.h +++ b/apt-pkg/deb/debmetaindex.h @@ -22,10 +22,12 @@ class debReleaseIndex : public metaIndex { /** \brief dpointer placeholder (for later in case we need it) */ void *d; std::map > ArchEntries; + enum { ALWAYS_TRUSTED, NEVER_TRUSTED, CHECK_TRUST } Trusted; public: debReleaseIndex(string const &URI, string const &Dist); + debReleaseIndex(string const &URI, string const &Dist, bool const Trusted); virtual ~debReleaseIndex(); virtual string ArchiveURI(string const &File) const {return URI + File;}; @@ -43,6 +45,7 @@ class debReleaseIndex : public metaIndex { string TranslationIndexURISuffix(const char *Type, const string &Section) const; virtual vector *GetIndexFiles(); + void SetTrusted(bool const Trusted); virtual bool IsTrusted() const; void PushSectionEntry(vector const &Archs, const debSectionEntry *Entry); diff --git a/apt-pkg/metaindex.h b/apt-pkg/metaindex.h index 1d2140799..f60235a5d 100644 --- a/apt-pkg/metaindex.h +++ b/apt-pkg/metaindex.h @@ -39,6 +39,10 @@ class metaIndex virtual vector *GetIndexFiles() = 0; virtual bool IsTrusted() const = 0; + metaIndex(string const &URI, string const &Dist, char const * const Type) : + Indexes(NULL), Type(Type), URI(URI), Dist(Dist) { + } + virtual ~metaIndex() { if (Indexes == 0) return; diff --git a/debian/changelog b/debian/changelog index 5686e02fa..d226d91c4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,13 +11,16 @@ apt (0.8.16~exp3) UNRELEASEDexperimental; urgency=low - generate all checksums in one run over the file for Release * cmdline/apt-get.cc: - add an --assume-no option for testing to say 'no' to everything + * apt-pkg/deb/debmetaindex.cc: + - add trusted=yes option to mark unsigned (local) repository as trusted + based on a patch from Ansgar Burchardt, thanks a lot! (Closes: #596498) [ Michael Vogt ] * merge fixes from the debian/unstable upload * merge lp:~mvo/apt/sha512-template to get fixes for the sha1/md5 verifiation (closes: #632520) - -- David Kalnischkies Thu, 14 Jul 2011 12:01:53 +0200 + -- David Kalnischkies Thu, 14 Jul 2011 20:56:45 +0200 apt (0.8.16~exp2) experimental; urgency=low diff --git a/doc/sources.list.5.xml b/doc/sources.list.5.xml index fab125b4e..bf8356348 100644 --- a/doc/sources.list.5.xml +++ b/doc/sources.list.5.xml @@ -117,8 +117,13 @@ arch=arch1,arch2,… can be used to specify for which architectures packages information should be downloaded. If this option is not set all architectures defined by the - APT::Architectures option will be downloaded. - + APT::Architectures option will be downloaded. + trusted=yes can be set to indicate that packages + from this source are always authenificated even if the Release file + is not signed or the signature can't be checked. This disables parts of &apt-secure; + and should therefore only be used in a local and trusted context. trusted=no + is the opposite which handles even correctly authenificated sources as not authenificated. + It is important to list sources in order of preference, with the most preferred source listed first. Typically this will result in sorting diff --git a/test/integration/test-bug-596498-trusted-unsigned-repo b/test/integration/test-bug-596498-trusted-unsigned-repo new file mode 100755 index 000000000..6ebc4a3bb --- /dev/null +++ b/test/integration/test-bug-596498-trusted-unsigned-repo @@ -0,0 +1,47 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'i386' + +buildsimplenativepackage 'cool' 'i386' '1.0' 'unstable' + +setupaptarchive + +aptgetupdate() { + rm -rf rootdir/var/lib/apt/ rootdir/var/cache/apt/*.bin + aptget update -qq +} + +PKGTEXT="$(aptget install cool --assume-no -d | head -n 7)" +DEBFILE='rootdir/etc/apt/sources.list.d/apt-test-unstable-deb.list' + +testequal "$PKGTEXT +Download complete and in download only mode" aptget install cool --assume-no -d + +sed -i -e 's#deb#deb [trusted=no]#' $DEBFILE +aptgetupdate + +testequal "$PKGTEXT +WARNING: The following packages cannot be authenticated! + cool +Install these packages without verification [y/N]? N +E: Some packages could not be authenticated" aptget install cool --assume-no -d + +find aptarchive/ \( -name 'Release.gpg' -o -name 'InRelease' \) -delete +sed -i -e 's#deb \[trusted=no\]#deb#' $DEBFILE +aptgetupdate + +testequal "$PKGTEXT +WARNING: The following packages cannot be authenticated! + cool +Install these packages without verification [y/N]? N +E: Some packages could not be authenticated" aptget install cool --assume-no -d + +sed -i -e 's#deb#deb [trusted=yes]#' $DEBFILE +aptgetupdate + +testequal "$PKGTEXT +Download complete and in download only mode" aptget install cool --assume-no -d -- cgit v1.2.3