summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-09-14 13:22:19 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2011-09-14 13:22:19 +0200
commita0e07f3ec885c12c733c12805391646c202f3f31 (patch)
treefaa658f29d7dff42c6ed475037dd462384eab46e /apt-pkg
parentb11fe392b2245354591296df88c3be2e6218af12 (diff)
parentafd7b358f94efddb83a2911ec1a21e7280074b1e (diff)
merged from lp:~donkult/apt/experimental
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc53
-rw-r--r--apt-pkg/acquire-method.cc2
-rw-r--r--apt-pkg/acquire-worker.cc16
-rw-r--r--apt-pkg/acquire.cc10
-rw-r--r--apt-pkg/algorithms.cc6
-rw-r--r--apt-pkg/aptconfiguration.cc2
-rw-r--r--apt-pkg/cachefile.cc18
-rw-r--r--apt-pkg/cachefile.h1
-rw-r--r--apt-pkg/cachefilter.cc2
-rw-r--r--apt-pkg/cacheset.cc6
-rw-r--r--apt-pkg/cdrom.cc5
-rw-r--r--apt-pkg/clean.cc6
-rw-r--r--apt-pkg/contrib/cdromutl.cc6
-rw-r--r--apt-pkg/contrib/cmndline.cc4
-rw-r--r--apt-pkg/contrib/configuration.cc5
-rw-r--r--apt-pkg/contrib/crc-16.cc4
-rw-r--r--apt-pkg/contrib/crc-16.h2
-rw-r--r--apt-pkg/contrib/error.cc5
-rw-r--r--apt-pkg/contrib/fileutl.cc40
-rw-r--r--apt-pkg/contrib/fileutl.h35
-rw-r--r--apt-pkg/contrib/hashes.cc14
-rw-r--r--apt-pkg/contrib/hashes.h6
-rw-r--r--apt-pkg/contrib/hashsum.cc11
-rw-r--r--apt-pkg/contrib/hashsum_template.h6
-rw-r--r--apt-pkg/contrib/md5.cc5
-rw-r--r--apt-pkg/contrib/md5.h2
-rw-r--r--apt-pkg/contrib/mmap.cc25
-rw-r--r--apt-pkg/contrib/mmap.h8
-rw-r--r--apt-pkg/contrib/netrc.cc1
-rw-r--r--apt-pkg/contrib/progress.cc14
-rw-r--r--apt-pkg/contrib/progress.h16
-rw-r--r--apt-pkg/contrib/sha1.cc5
-rw-r--r--apt-pkg/contrib/sha1.h2
-rw-r--r--apt-pkg/contrib/sha2.h6
-rw-r--r--apt-pkg/contrib/sha2_internal.cc1
-rw-r--r--apt-pkg/contrib/strutl.cc34
-rw-r--r--apt-pkg/contrib/strutl.h1
-rw-r--r--apt-pkg/deb/debindexfile.cc2
-rw-r--r--apt-pkg/deb/deblistparser.cc2
-rw-r--r--apt-pkg/deb/debmetaindex.cc1
-rw-r--r--apt-pkg/deb/debrecords.cc2
-rw-r--r--apt-pkg/deb/debsrcrecords.cc2
-rw-r--r--apt-pkg/deb/debsystem.cc5
-rw-r--r--apt-pkg/deb/debversion.cc1
-rw-r--r--apt-pkg/deb/dpkgpm.cc3
-rw-r--r--apt-pkg/depcache.cc10
-rw-r--r--apt-pkg/edsp.cc6
-rw-r--r--apt-pkg/edsp/edspindexfile.cc2
-rw-r--r--apt-pkg/edsp/edsplistparser.cc2
-rw-r--r--apt-pkg/edsp/edspsystem.cc5
-rw-r--r--apt-pkg/indexcopy.cc29
-rw-r--r--apt-pkg/indexcopy.h6
-rw-r--r--apt-pkg/indexfile.cc2
-rw-r--r--apt-pkg/indexrecords.cc31
-rw-r--r--apt-pkg/indexrecords.h4
-rw-r--r--apt-pkg/init.cc6
-rw-r--r--apt-pkg/orderlist.cc72
-rw-r--r--apt-pkg/orderlist.h4
-rw-r--r--apt-pkg/packagemanager.cc42
-rw-r--r--apt-pkg/pkgcache.cc9
-rw-r--r--apt-pkg/pkgcachegen.cc7
-rw-r--r--apt-pkg/pkgrecords.cc6
-rw-r--r--apt-pkg/pkgrecords.h1
-rw-r--r--apt-pkg/pkgsystem.cc2
-rw-r--r--apt-pkg/policy.cc6
-rw-r--r--apt-pkg/sourcelist.cc6
-rw-r--r--apt-pkg/srcrecords.cc6
-rw-r--r--apt-pkg/tagfile.cc24
-rw-r--r--apt-pkg/tagfile.h4
-rw-r--r--apt-pkg/vendor.cc2
-rw-r--r--apt-pkg/vendorlist.cc2
-rw-r--r--apt-pkg/version.cc2
-rw-r--r--apt-pkg/versionmatch.cc4
73 files changed, 467 insertions, 238 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 223303ea8..b46489f87 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -13,6 +13,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/aptconfiguration.h>
@@ -24,8 +26,6 @@
#include <apt-pkg/sha1.h>
#include <apt-pkg/tagfile.h>
-#include <apti18n.h>
-
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
@@ -33,6 +33,8 @@
#include <sstream>
#include <stdio.h>
#include <ctime>
+
+#include <apti18n.h>
/*}}}*/
using namespace std;
@@ -1266,9 +1268,9 @@ void pkgAcqMetaIndex::Done(string Message,unsigned long long Size,string Hash, /
if (SigFile == "")
{
// There was no signature file, so we are finished. Download
- // the indexes and do only hashsum verification
+ // the indexes and do only hashsum verification if possible
MetaIndexParser->Load(DestFile);
- QueueIndexes(true);
+ QueueIndexes(false);
}
else
{
@@ -1386,33 +1388,30 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/
++Target)
{
HashString ExpectedIndexHash;
- if (verify)
+ const indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey);
+ if (Record == NULL)
{
- const indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey);
- if (Record == NULL)
+ if (verify == true && (*Target)->IsOptional() == false)
{
- if ((*Target)->IsOptional() == false)
- {
- Status = StatAuthError;
- strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), (*Target)->MetaKey.c_str());
- return;
- }
+ Status = StatAuthError;
+ strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), (*Target)->MetaKey.c_str());
+ return;
}
- else
+ }
+ else
+ {
+ ExpectedIndexHash = Record->Hash;
+ if (_config->FindB("Debug::pkgAcquire::Auth", false))
{
- ExpectedIndexHash = Record->Hash;
- if (_config->FindB("Debug::pkgAcquire::Auth", false))
- {
- std::cerr << "Queueing: " << (*Target)->URI << std::endl;
- std::cerr << "Expected Hash: " << ExpectedIndexHash.toStr() << std::endl;
- std::cerr << "For: " << Record->MetaKeyFilename << std::endl;
- }
- if (ExpectedIndexHash.empty() == true && (*Target)->IsOptional() == false)
- {
- Status = StatAuthError;
- strprintf(ErrorText, _("Unable to find hash sum for '%s' in Release file"), (*Target)->MetaKey.c_str());
- return;
- }
+ std::cerr << "Queueing: " << (*Target)->URI << std::endl;
+ std::cerr << "Expected Hash: " << ExpectedIndexHash.toStr() << std::endl;
+ std::cerr << "For: " << Record->MetaKeyFilename << std::endl;
+ }
+ if (verify == true && ExpectedIndexHash.empty() == true && (*Target)->IsOptional() == false)
+ {
+ Status = StatAuthError;
+ strprintf(ErrorText, _("Unable to find hash sum for '%s' in Release file"), (*Target)->MetaKey.c_str());
+ return;
}
}
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index 25c6c674d..1ae139b40 100644
--- a/apt-pkg/acquire-method.cc
+++ b/apt-pkg/acquire-method.cc
@@ -15,6 +15,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index 3e1fd98db..3bb977e14 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -12,6 +12,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/acquire-worker.h>
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/configuration.h>
@@ -19,18 +21,18 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/strutl.h>
-#include <apti18n.h>
-
#include <iostream>
#include <sstream>
#include <fstream>
-
+
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <errno.h>
+
+#include <apti18n.h>
/*}}}*/
using namespace std;
@@ -256,9 +258,9 @@ bool pkgAcquire::Worker::RunMessages()
CurrentItem = Itm;
CurrentSize = 0;
- TotalSize = atoi(LookupTag(Message,"Size","0").c_str());
- ResumePoint = atoi(LookupTag(Message,"Resume-Point","0").c_str());
- Itm->Owner->Start(Message,atoi(LookupTag(Message,"Size","0").c_str()));
+ TotalSize = strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10);
+ ResumePoint = strtoull(LookupTag(Message,"Resume-Point","0").c_str(), NULL, 10);
+ Itm->Owner->Start(Message,strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10));
// Display update before completion
if (Log != 0 && Log->MorePulses == true)
@@ -287,7 +289,7 @@ bool pkgAcquire::Worker::RunMessages()
Log->Pulse(Owner->GetOwner());
OwnerQ->ItemDone(Itm);
- unsigned long long const ServerSize = atoll(LookupTag(Message,"Size","0").c_str());
+ unsigned long long const ServerSize = strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10);
if (TotalSize != 0 && ServerSize != TotalSize)
_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);
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 8c00748b2..cdc3fba4b 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -13,6 +13,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/acquire.h>
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/acquire-worker.h>
@@ -21,8 +23,6 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
-#include <apti18n.h>
-
#include <iostream>
#include <sstream>
#include <stdio.h>
@@ -30,6 +30,8 @@
#include <dirent.h>
#include <sys/time.h>
#include <errno.h>
+
+#include <apti18n.h>
/*}}}*/
using namespace std;
@@ -445,6 +447,10 @@ pkgAcquire::Worker *pkgAcquire::WorkerStep(Worker *I)
if it is part of the download set. */
bool pkgAcquire::Clean(string Dir)
{
+ // non-existing directories are by definition clean…
+ if (DirectoryExists(Dir) == false)
+ return true;
+
DIR *D = opendir(Dir.c_str());
if (D == 0)
return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 08d1f8cb7..40368c91f 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -14,6 +14,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/algorithms.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
@@ -22,13 +24,13 @@
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/edsp.h>
-#include <apti18n.h>
#include <sys/types.h>
#include <cstdlib>
#include <algorithm>
#include <iostream>
-
#include <stdio.h>
+
+#include <apti18n.h>
/*}}}*/
using namespace std;
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index 6ec5fa03a..e1bc94f31 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -8,6 +8,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc
index 964c5bd8b..f38dfc581 100644
--- a/apt-pkg/cachefile.cc
+++ b/apt-pkg/cachefile.cc
@@ -12,6 +12,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/cachefile.h>
#include <apt-pkg/error.h>
#include <apt-pkg/sourcelist.h>
@@ -21,7 +23,7 @@
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/fileutl.h>
-
+
#include <apti18n.h>
/*}}}*/
// CacheFile::CacheFile - Constructor /*{{{*/
@@ -163,6 +165,20 @@ bool pkgCacheFile::Open(OpProgress *Progress, bool WithLock)
return true;
}
/*}}}*/
+// CacheFile::RemoveCaches - remove all cache files from disk /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgCacheFile::RemoveCaches()
+{
+ std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache");
+ std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache");
+
+ if (pkgcache.empty() == false && RealFileExists(pkgcache) == true)
+ unlink(pkgcache.c_str());
+ if (srcpkgcache.empty() == false && RealFileExists(srcpkgcache) == true)
+ unlink(srcpkgcache.c_str());
+}
+ /*}}}*/
// CacheFile::Close - close the cache files /*{{{*/
// ---------------------------------------------------------------------
/* */
diff --git a/apt-pkg/cachefile.h b/apt-pkg/cachefile.h
index d07337d38..243061f0f 100644
--- a/apt-pkg/cachefile.h
+++ b/apt-pkg/cachefile.h
@@ -60,6 +60,7 @@ class pkgCacheFile
bool Open(OpProgress *Progress = NULL, bool WithLock = true);
inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); };
__deprecated bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); };
+ static void RemoveCaches();
void Close();
inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; };
diff --git a/apt-pkg/cachefilter.cc b/apt-pkg/cachefilter.cc
index 8f0725ea3..210a9a9ab 100644
--- a/apt-pkg/cachefilter.cc
+++ b/apt-pkg/cachefilter.cc
@@ -4,6 +4,8 @@
Collection of functor classes */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/cachefilter.h>
#include <apt-pkg/error.h>
#include <apt-pkg/pkgcache.h>
diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc
index a1de613e2..386ecfb5f 100644
--- a/apt-pkg/cacheset.cc
+++ b/apt-pkg/cacheset.cc
@@ -9,6 +9,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/cachefilter.h>
#include <apt-pkg/cacheset.h>
@@ -16,11 +18,11 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/versionmatch.h>
-#include <apti18n.h>
-
#include <vector>
#include <regex.h>
+
+#include <apti18n.h>
/*}}}*/
namespace APT {
// FromTask - Return all packages in the cache from a specific task /*{{{*/
diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index df1ffedf2..392cd890e 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -1,5 +1,6 @@
/*
*/
+#include<config.h>
#include<apt-pkg/init.h>
#include<apt-pkg/error.h>
@@ -10,8 +11,6 @@
#include<sstream>
#include<fstream>
-#include<config.h>
-#include<apti18n.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
@@ -22,6 +21,8 @@
#include "indexcopy.h"
+#include<apti18n.h>
+
using namespace std;
// FindPackages - Find the package files on the CDROM /*{{{*/
diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc
index 9850b93b4..1f96e941b 100644
--- a/apt-pkg/clean.cc
+++ b/apt-pkg/clean.cc
@@ -8,17 +8,19 @@
##################################################################### */
/*}}}*/
// Includes /*{{{*/
+#include<config.h>
+
#include <apt-pkg/clean.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/aptconfiguration.h>
-#include <apti18n.h>
-
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
+
+#include <apti18n.h>
/*}}}*/
// ArchiveCleaner::Go - Perform smart cleanup of the archive /*{{{*/
// ---------------------------------------------------------------------
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index e25caf1a5..9de795b60 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -10,6 +10,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/cdromutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/md5.h>
@@ -17,8 +19,6 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/strutl.h>
-#include <apti18n.h>
-
#include <sys/wait.h>
#include <sys/statvfs.h>
#include <dirent.h>
@@ -26,6 +26,8 @@
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
+
+#include <apti18n.h>
/*}}}*/
// IsMounted - Returns true if the mount point is mounted /*{{{*/
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index 5a9944096..34e90da20 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -11,11 +11,13 @@
##################################################################### */
/*}}}*/
// Include files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/cmndline.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
-#include <apti18n.h>
+#include <apti18n.h>
/*}}}*/
using namespace std;
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index ece05e8f6..0f7b37ee9 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -15,16 +15,19 @@
##################################################################### */
/*}}}*/
// Include files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
-#include <apti18n.h>
#include <vector>
#include <fstream>
#include <iostream>
+#include <apti18n.h>
+
using namespace std;
/*}}}*/
diff --git a/apt-pkg/contrib/crc-16.cc b/apt-pkg/contrib/crc-16.cc
index b300ed67e..4058821f9 100644
--- a/apt-pkg/contrib/crc-16.cc
+++ b/apt-pkg/contrib/crc-16.cc
@@ -15,6 +15,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/crc-16.h>
/*}}}*/
@@ -63,7 +65,7 @@ static unsigned short const crc16_table[256] =
/* Recompute the FCS with one more character appended. */
#define CalcFCS(fcs, c) (((fcs) >> 8) ^ crc16_table[((fcs) ^ (c)) & 0xff])
unsigned short AddCRC16(unsigned short fcs, void const *Buf,
- unsigned long len)
+ unsigned long long len)
{
unsigned char const *buf = (unsigned char const *)Buf;
while (len--)
diff --git a/apt-pkg/contrib/crc-16.h b/apt-pkg/contrib/crc-16.h
index f30678bac..702de40b2 100644
--- a/apt-pkg/contrib/crc-16.h
+++ b/apt-pkg/contrib/crc-16.h
@@ -12,6 +12,6 @@
#define INIT_FCS 0xffff
unsigned short AddCRC16(unsigned short fcs, void const *buf,
- unsigned long len);
+ unsigned long long len);
#endif
diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc
index edb290f34..122e2c809 100644
--- a/apt-pkg/contrib/error.cc
+++ b/apt-pkg/contrib/error.cc
@@ -13,6 +13,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/error.h>
#include <iostream>
@@ -24,8 +26,7 @@
#include <string>
#include <cstring>
-#include "config.h"
- /*}}}*/
+ /*}}}*/
// Global Error Object /*{{{*/
/* If the implementation supports posix threads then the accessor function
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 85dc6f600..95058cbde 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -18,14 +18,14 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/fileutl.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/sptr.h>
#include <apt-pkg/configuration.h>
-#include <apti18n.h>
-
#include <cstdlib>
#include <cstring>
#include <cstdio>
@@ -43,10 +43,11 @@
#include <set>
#include <algorithm>
-#include <config.h>
#ifdef WORDS_BIGENDIAN
#include <inttypes.h>
#endif
+
+#include <apti18n.h>
/*}}}*/
using namespace std;
@@ -132,10 +133,10 @@ bool CopyFile(FileFd &From,FileFd &To)
// Buffered copy between fds
SPtrArray<unsigned char> Buf = new unsigned char[64000];
- unsigned long Size = From.Size();
+ unsigned long long Size = From.Size();
while (Size != 0)
{
- unsigned long ToRead = Size;
+ unsigned long long ToRead = Size;
if (Size > 64000)
ToRead = 64000;
@@ -810,7 +811,7 @@ FileFd::~FileFd()
// ---------------------------------------------------------------------
/* We are carefull to handle interruption by a signal while reading
gracefully. */
-bool FileFd::Read(void *To,unsigned long Size,unsigned long *Actual)
+bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
{
int Res;
errno = 0;
@@ -849,13 +850,13 @@ bool FileFd::Read(void *To,unsigned long Size,unsigned long *Actual)
}
Flags |= Fail;
- return _error->Error(_("read, still have %lu to read but none left"),Size);
+ return _error->Error(_("read, still have %llu to read but none left"), Size);
}
/*}}}*/
// FileFd::Write - Write to the file /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool FileFd::Write(const void *From,unsigned long Size)
+bool FileFd::Write(const void *From,unsigned long long Size)
{
int Res;
errno = 0;
@@ -882,13 +883,13 @@ bool FileFd::Write(const void *From,unsigned long Size)
return true;
Flags |= Fail;
- return _error->Error(_("write, still have %lu to write but couldn't"),Size);
+ return _error->Error(_("write, still have %llu to write but couldn't"), Size);
}
/*}}}*/
// FileFd::Seek - Seek in the file /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool FileFd::Seek(unsigned long To)
+bool FileFd::Seek(unsigned long long To)
{
int res;
if (gz)
@@ -898,7 +899,7 @@ bool FileFd::Seek(unsigned long To)
if (res != (signed)To)
{
Flags |= Fail;
- return _error->Error("Unable to seek to %lu",To);
+ return _error->Error("Unable to seek to %llu", To);
}
return true;
@@ -907,7 +908,7 @@ bool FileFd::Seek(unsigned long To)
// FileFd::Skip - Seek in the file /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool FileFd::Skip(unsigned long Over)
+bool FileFd::Skip(unsigned long long Over)
{
int res;
if (gz)
@@ -917,7 +918,7 @@ bool FileFd::Skip(unsigned long Over)
if (res < 0)
{
Flags |= Fail;
- return _error->Error("Unable to seek ahead %lu",Over);
+ return _error->Error("Unable to seek ahead %llu",Over);
}
return true;
@@ -926,7 +927,7 @@ bool FileFd::Skip(unsigned long Over)
// FileFd::Truncate - Truncate the file /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool FileFd::Truncate(unsigned long To)
+bool FileFd::Truncate(unsigned long long To)
{
if (gz)
{
@@ -936,7 +937,7 @@ bool FileFd::Truncate(unsigned long To)
if (ftruncate(iFd,To) != 0)
{
Flags |= Fail;
- return _error->Error("Unable to truncate to %lu",To);
+ return _error->Error("Unable to truncate to %llu",To);
}
return true;
@@ -945,7 +946,7 @@ bool FileFd::Truncate(unsigned long To)
// FileFd::Tell - Current seek position /*{{{*/
// ---------------------------------------------------------------------
/* */
-unsigned long FileFd::Tell()
+unsigned long long FileFd::Tell()
{
off_t Res;
if (gz)
@@ -960,7 +961,7 @@ unsigned long FileFd::Tell()
// FileFd::FileSize - Return the size of the file /*{{{*/
// ---------------------------------------------------------------------
/* */
-unsigned long FileFd::FileSize()
+unsigned long long FileFd::FileSize()
{
struct stat Buf;
@@ -972,9 +973,9 @@ unsigned long FileFd::FileSize()
// FileFd::Size - Return the size of the content in the file /*{{{*/
// ---------------------------------------------------------------------
/* */
-unsigned long FileFd::Size()
+unsigned long long FileFd::Size()
{
- unsigned long size = FileSize();
+ unsigned long long size = FileSize();
// only check gzsize if we are actually a gzip file, just checking for
// "gz" is not sufficient as uncompressed files will be opened with
@@ -984,6 +985,7 @@ unsigned long FileFd::Size()
/* unfortunately zlib.h doesn't provide a gzsize(), so we have to do
* this ourselves; the original (uncompressed) file size is the last 32
* bits of the file */
+ // FIXME: Size for gz-files is limited by 32bit… no largefile support
off_t orig_pos = lseek(iFd, 0, SEEK_CUR);
if (lseek(iFd, -4, SEEK_END) < 0)
return _error->Errno("lseek","Unable to seek to end of gzipped file");
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index a1b177f38..973a38cff 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -49,21 +49,36 @@ class FileFd
enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp,ReadOnlyGzip,
WriteAtomic};
- inline bool Read(void *To,unsigned long Size,bool AllowEof)
+ inline bool Read(void *To,unsigned long long Size,bool AllowEof)
{
- unsigned long Jnk;
+ unsigned long long Jnk;
if (AllowEof)
return Read(To,Size,&Jnk);
return Read(To,Size);
}
- bool Read(void *To,unsigned long Size,unsigned long *Actual = 0);
- bool Write(const void *From,unsigned long Size);
- bool Seek(unsigned long To);
- bool Skip(unsigned long To);
- bool Truncate(unsigned long To);
- unsigned long Tell();
- unsigned long Size();
- unsigned long FileSize();
+ bool Read(void *To,unsigned long long Size,unsigned long long *Actual = 0);
+ bool Write(const void *From,unsigned long long Size);
+ bool Seek(unsigned long long To);
+ bool Skip(unsigned long long To);
+ bool Truncate(unsigned long long To);
+ unsigned long long Tell();
+ unsigned long long Size();
+ unsigned long long FileSize();
+
+ /* You want to use 'unsigned long long' if you are talking about a file
+ to be able to support large files (>2 or >4 GB) properly.
+ This shouldn't happen all to often for the indexes, but deb's might be…
+ And as the auto-conversation converts a 'unsigned long *' to a 'bool'
+ instead of 'unsigned long long *' we need to provide this explicitely -
+ otherwise applications magically start to fail… */
+ __deprecated bool Read(void *To,unsigned long long Size,unsigned long *Actual)
+ {
+ unsigned long long R;
+ bool const T = Read(To, Size, &R);
+ *Actual = R;
+ return T;
+ }
+
bool Open(string FileName,OpenMode Mode,unsigned long Perms = 0666);
bool OpenDescriptor(int Fd, OpenMode Mode, bool AutoClose=false);
bool Close();
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index 4407574fa..fd76bf229 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -11,12 +11,14 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/hashes.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/macros.h>
-#include <unistd.h>
+#include <unistd.h>
#include <string>
#include <iostream>
/*}}}*/
@@ -106,18 +108,18 @@ string HashString::toStr() const
// Hashes::AddFD - Add the contents of the FD /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool Hashes::AddFD(int const Fd,unsigned long Size, bool const addMD5,
+bool Hashes::AddFD(int const Fd,unsigned long long Size, bool const addMD5,
bool const addSHA1, bool const addSHA256, bool const addSHA512)
{
unsigned char Buf[64*64];
- int Res = 0;
+ ssize_t Res = 0;
int ToEOF = (Size == 0);
while (Size != 0 || ToEOF)
{
- unsigned n = sizeof(Buf);
- if (!ToEOF) n = min(Size,(unsigned long)n);
+ unsigned long long n = sizeof(Buf);
+ if (!ToEOF) n = min(Size, n);
Res = read(Fd,Buf,n);
- if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
+ if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read
return false;
if (ToEOF && Res == 0) // EOF
break;
diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h
index e702fcca2..40c2ad064 100644
--- a/apt-pkg/contrib/hashes.h
+++ b/apt-pkg/contrib/hashes.h
@@ -62,14 +62,14 @@ class Hashes
SHA256Summation SHA256;
SHA512Summation SHA512;
- inline bool Add(const unsigned char *Data,unsigned long Size)
+ inline bool Add(const unsigned char *Data,unsigned long long Size)
{
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));};
- inline bool AddFD(int const Fd,unsigned long Size = 0)
+ inline bool AddFD(int const Fd,unsigned long long Size = 0)
{ return AddFD(Fd, Size, true, true, true, true); };
- bool AddFD(int const Fd, unsigned long Size, bool const addMD5,
+ bool AddFD(int const Fd, unsigned long 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 728747d7a..0edcbb364 100644
--- a/apt-pkg/contrib/hashsum.cc
+++ b/apt-pkg/contrib/hashsum.cc
@@ -1,4 +1,5 @@
// Cryptographic API Base
+#include <config.h>
#include <unistd.h>
#include "hashsum_template.h"
@@ -6,16 +7,16 @@
// Summation::AddFD - Add content of file into the checksum /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool SummationImplementation::AddFD(int const Fd, unsigned long Size) {
+bool SummationImplementation::AddFD(int const Fd, unsigned long long Size) {
unsigned char Buf[64 * 64];
- int Res = 0;
+ ssize_t Res = 0;
int ToEOF = (Size == 0);
while (Size != 0 || ToEOF)
{
- unsigned n = sizeof(Buf);
- if (!ToEOF) n = min(Size,(unsigned long)n);
+ unsigned long long n = sizeof(Buf);
+ if (!ToEOF) n = min(Size, n);
Res = read(Fd, Buf, n);
- if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
+ if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read
return false;
if (ToEOF && Res == 0) // EOF
break;
diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h
index 85d94c2af..9157754e3 100644
--- a/apt-pkg/contrib/hashsum_template.h
+++ b/apt-pkg/contrib/hashsum_template.h
@@ -87,8 +87,8 @@ 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)
+ virtual bool Add(const unsigned char *inbuf, unsigned long long inlen) = 0;
+ inline bool Add(const char *inbuf, unsigned long long const inlen)
{ return Add((unsigned char *)inbuf, inlen); };
inline bool Add(const unsigned char *Data)
@@ -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 = 0);
+ bool AddFD(int Fd, unsigned long long Size = 0);
};
#endif
diff --git a/apt-pkg/contrib/md5.cc b/apt-pkg/contrib/md5.cc
index 65e20e9bb..4351aeb22 100644
--- a/apt-pkg/contrib/md5.cc
+++ b/apt-pkg/contrib/md5.cc
@@ -35,6 +35,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/md5.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/macros.h>
@@ -43,7 +45,6 @@
#include <unistd.h>
#include <netinet/in.h> // For htonl
#include <inttypes.h>
-#include <config.h>
/*}}}*/
// byteSwap - Swap bytes in a buffer /*{{{*/
@@ -186,7 +187,7 @@ MD5Summation::MD5Summation()
// MD5Summation::Add - 'Add' a data set to the hash /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool MD5Summation::Add(const unsigned char *data,unsigned long len)
+bool MD5Summation::Add(const unsigned char *data,unsigned long long len)
{
if (Done == true)
return false;
diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h
index e76428325..305cdb20d 100644
--- a/apt-pkg/contrib/md5.h
+++ b/apt-pkg/contrib/md5.h
@@ -45,7 +45,7 @@ class MD5Summation : public SummationImplementation
public:
- bool Add(const unsigned char *inbuf, unsigned long inlen);
+ bool Add(const unsigned char *inbuf, unsigned long long inlen);
using SummationImplementation::Add;
MD5SumValue Result();
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index 19381ae47..a110a7019 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -17,20 +17,21 @@
/*}}}*/
// Include Files /*{{{*/
#define _BSD_SOURCE
+#include <config.h>
+
#include <apt-pkg/mmap.h>
#include <apt-pkg/error.h>
-#include <apti18n.h>
-
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <errno.h>
-
#include <cstring>
- /*}}}*/
+
+#include <apti18n.h>
+ /*}}}*/
// MMap::MMap - Constructor /*{{{*/
// ---------------------------------------------------------------------
@@ -94,7 +95,7 @@ bool MMap::Map(FileFd &Fd)
return false;
}
else
- return _error->Errno("mmap",_("Couldn't make mmap of %lu bytes"),
+ return _error->Errno("mmap",_("Couldn't make mmap of %llu bytes"),
iSize);
}
@@ -165,7 +166,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
return true;
#ifdef _POSIX_SYNCHRONIZED_IO
- unsigned long PSize = sysconf(_SC_PAGESIZE);
+ unsigned long long PSize = sysconf(_SC_PAGESIZE);
if ((Flags & ReadOnly) != ReadOnly)
{
if (SyncToFd != 0)
@@ -176,7 +177,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
}
else
{
- if (msync((char *)Base+(int)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0)
+ if (msync((char *)Base+(unsigned long long)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0)
return _error->Errno("msync", _("Unable to synchronize mmap"));
}
}
@@ -196,7 +197,7 @@ DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long const &Work
if (_error->PendingError() == true)
return;
- unsigned long EndOfFile = Fd->Size();
+ unsigned long long EndOfFile = Fd->Size();
if (EndOfFile > WorkSpace)
WorkSpace = EndOfFile;
else if(WorkSpace > 0)
@@ -284,7 +285,7 @@ DynamicMMap::~DynamicMMap()
return;
}
- unsigned long EndOfFile = iSize;
+ unsigned long long EndOfFile = iSize;
iSize = WorkSpace;
Close(false);
if(ftruncate(Fd->Fd(),EndOfFile) < 0)
@@ -294,9 +295,9 @@ DynamicMMap::~DynamicMMap()
// DynamicMMap::RawAllocate - Allocate a raw chunk of unaligned space /*{{{*/
// ---------------------------------------------------------------------
/* This allocates a block of memory aligned to the given size */
-unsigned long DynamicMMap::RawAllocate(unsigned long Size,unsigned long Aln)
+unsigned long DynamicMMap::RawAllocate(unsigned long long Size,unsigned long Aln)
{
- unsigned long Result = iSize;
+ unsigned long long Result = iSize;
if (Aln != 0)
Result += Aln - (iSize%Aln);
@@ -411,7 +412,7 @@ bool DynamicMMap::Grow() {
if (GrowFactor <= 0)
return _error->Error(_("Unable to increase size of the MMap as automatic growing is disabled by user."));
- unsigned long const newSize = WorkSpace + GrowFactor;
+ unsigned long long const newSize = WorkSpace + GrowFactor;
if(Fd != 0) {
Fd->Seek(newSize - 1);
diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h
index 2bf2c1540..e0ff8db95 100644
--- a/apt-pkg/contrib/mmap.h
+++ b/apt-pkg/contrib/mmap.h
@@ -41,7 +41,7 @@ class MMap
protected:
unsigned long Flags;
- unsigned long iSize;
+ unsigned long long iSize;
void *Base;
// In case mmap can not be used, we keep a dup of the file
@@ -60,8 +60,8 @@ class MMap
// Simple accessors
inline operator void *() {return Base;};
inline void *Data() {return Base;};
- inline unsigned long Size() {return iSize;};
- inline void AddSize(unsigned long const size) {iSize += size;};
+ inline unsigned long long Size() {return iSize;};
+ inline void AddSize(unsigned long long const size) {iSize += size;};
inline bool validData() const { return Base != (void *)-1 && Base != 0; };
// File manipulators
@@ -99,7 +99,7 @@ class DynamicMMap : public MMap
public:
// Allocation
- unsigned long RawAllocate(unsigned long Size,unsigned long Aln = 0);
+ unsigned long RawAllocate(unsigned long long Size,unsigned long Aln = 0);
unsigned long Allocate(unsigned long ItemSize);
unsigned long WriteString(const char *String,unsigned long Len = (unsigned long)-1);
inline unsigned long WriteString(const string &S) {return WriteString(S.c_str(),S.length());};
diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc
index 9ff5796c5..b9d0749e2 100644
--- a/apt-pkg/contrib/netrc.cc
+++ b/apt-pkg/contrib/netrc.cc
@@ -11,6 +11,7 @@
##################################################################### */
/*}}}*/
+#include <config.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/fileutl.h>
diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc
index 84ee4c124..317048845 100644
--- a/apt-pkg/contrib/progress.cc
+++ b/apt-pkg/contrib/progress.cc
@@ -8,15 +8,17 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/progress.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
-#include <apti18n.h>
-
#include <iostream>
#include <stdio.h>
#include <cstring>
+
+#include <apti18n.h>
/*}}}*/
using namespace std;
@@ -35,7 +37,7 @@ OpProgress::OpProgress() : Current(0), Total(0), Size(0), SubTotal(1),
/* Current is the Base Overall progress in units of Total. Cur is the sub
progress in units of SubTotal. Size is a scaling factor that says what
percent of Total SubTotal is. */
-void OpProgress::Progress(unsigned long Cur)
+void OpProgress::Progress(unsigned long long Cur)
{
if (Total == 0 || Size == 0 || SubTotal == 0)
Percent = 0;
@@ -47,8 +49,8 @@ void OpProgress::Progress(unsigned long Cur)
// OpProgress::OverallProgress - Set the overall progress /*{{{*/
// ---------------------------------------------------------------------
/* */
-void OpProgress::OverallProgress(unsigned long Current, unsigned long Total,
- unsigned long Size,const string &Op)
+void OpProgress::OverallProgress(unsigned long long Current, unsigned long long Total,
+ unsigned long long Size,const string &Op)
{
this->Current = Current;
this->Total = Total;
@@ -65,7 +67,7 @@ void OpProgress::OverallProgress(unsigned long Current, unsigned long Total,
// OpProgress::SubProgress - Set the sub progress state /*{{{*/
// ---------------------------------------------------------------------
/* */
-void OpProgress::SubProgress(unsigned long SubTotal,const string &Op,
+void OpProgress::SubProgress(unsigned long long SubTotal,const string &Op,
float const Percent)
{
this->SubTotal = SubTotal;
diff --git a/apt-pkg/contrib/progress.h b/apt-pkg/contrib/progress.h
index 3a914d17f..5344323f6 100644
--- a/apt-pkg/contrib/progress.h
+++ b/apt-pkg/contrib/progress.h
@@ -30,10 +30,10 @@ using std::string;
class Configuration;
class OpProgress
{
- unsigned long Current;
- unsigned long Total;
- unsigned long Size;
- unsigned long SubTotal;
+ unsigned long long Current;
+ unsigned long long Total;
+ unsigned long long Size;
+ unsigned long long SubTotal;
float LastPercent;
// Change reduction code
@@ -54,10 +54,10 @@ class OpProgress
public:
- void Progress(unsigned long Current);
- void SubProgress(unsigned long SubTotal, const string &Op = "", float const Percent = -1);
- void OverallProgress(unsigned long Current,unsigned long Total,
- unsigned long Size,const string &Op);
+ void Progress(unsigned long long Current);
+ void SubProgress(unsigned long long SubTotal, const string &Op = "", float const Percent = -1);
+ void OverallProgress(unsigned long long Current,unsigned long long Total,
+ unsigned long long Size,const string &Op);
virtual void Done() {};
OpProgress();
diff --git a/apt-pkg/contrib/sha1.cc b/apt-pkg/contrib/sha1.cc
index 5b9db202d..b5a6a2440 100644
--- a/apt-pkg/contrib/sha1.cc
+++ b/apt-pkg/contrib/sha1.cc
@@ -29,6 +29,8 @@
*/
/*}}} */
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/sha1.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/macros.h>
@@ -36,7 +38,6 @@
#include <string.h>
#include <unistd.h>
#include <inttypes.h>
-#include <config.h>
/*}}}*/
// SHA1Transform - Alters an existing SHA-1 hash /*{{{*/
@@ -241,7 +242,7 @@ SHA1SumValue SHA1Summation::Result()
// SHA1Summation::Add - Adds content of buffer into the checksum /*{{{*/
// ---------------------------------------------------------------------
/* May not be called after Result() is called */
-bool SHA1Summation::Add(const unsigned char *data,unsigned long len)
+bool SHA1Summation::Add(const unsigned char *data,unsigned long long len)
{
if (Done)
return false;
diff --git a/apt-pkg/contrib/sha1.h b/apt-pkg/contrib/sha1.h
index 2701fc67e..916faec1b 100644
--- a/apt-pkg/contrib/sha1.h
+++ b/apt-pkg/contrib/sha1.h
@@ -34,7 +34,7 @@ class SHA1Summation : public SummationImplementation
bool Done;
public:
- bool Add(const unsigned char *inbuf, unsigned long inlen);
+ bool Add(const unsigned char *inbuf, unsigned long long inlen);
using SummationImplementation::Add;
SHA1SumValue Result();
diff --git a/apt-pkg/contrib/sha2.h b/apt-pkg/contrib/sha2.h
index 386225889..51c921dbd 100644
--- a/apt-pkg/contrib/sha2.h
+++ b/apt-pkg/contrib/sha2.h
@@ -30,7 +30,7 @@ class SHA2SummationBase : public SummationImplementation
protected:
bool Done;
public:
- bool Add(const unsigned char *inbuf, unsigned long len) = 0;
+ bool Add(const unsigned char *inbuf, unsigned long long len) = 0;
void Result();
};
@@ -41,7 +41,7 @@ class SHA256Summation : public SHA2SummationBase
unsigned char Sum[32];
public:
- bool Add(const unsigned char *inbuf, unsigned long len)
+ bool Add(const unsigned char *inbuf, unsigned long long len)
{
if (Done)
return false;
@@ -73,7 +73,7 @@ class SHA512Summation : public SHA2SummationBase
unsigned char Sum[64];
public:
- bool Add(const unsigned char *inbuf, unsigned long len)
+ bool Add(const unsigned char *inbuf, unsigned long long len)
{
if (Done)
return false;
diff --git a/apt-pkg/contrib/sha2_internal.cc b/apt-pkg/contrib/sha2_internal.cc
index 565db2f91..ff995cdf2 100644
--- a/apt-pkg/contrib/sha2_internal.cc
+++ b/apt-pkg/contrib/sha2_internal.cc
@@ -31,6 +31,7 @@
*
* $Id: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $
*/
+#include <config.h>
#include <string.h> /* memcpy()/memset() or bcopy()/bzero() */
#include <assert.h> /* assert() */
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 867bb313b..aaf44b7ff 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -15,12 +15,12 @@
##################################################################### */
/*}}}*/
// Includes /*{{{*/
+#include <config.h>
+
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
-#include <apti18n.h>
-
#include <ctype.h>
#include <string.h>
#include <stdio.h>
@@ -31,7 +31,7 @@
#include <stdarg.h>
#include <iconv.h>
-#include "config.h"
+#include <apti18n.h>
using namespace std;
/*}}}*/
@@ -970,6 +970,34 @@ bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base)
return true;
}
/*}}}*/
+// StrToNum - Convert a fixed length string to a number /*{{{*/
+// ---------------------------------------------------------------------
+/* This is used in decoding the crazy fixed length string headers in
+ tar and ar files. */
+bool StrToNum(const char *Str,unsigned long long &Res,unsigned Len,unsigned Base)
+{
+ char S[30];
+ if (Len >= sizeof(S))
+ return false;
+ memcpy(S,Str,Len);
+ S[Len] = 0;
+
+ // All spaces is a zero
+ Res = 0;
+ unsigned I;
+ for (I = 0; S[I] == ' '; I++);
+ if (S[I] == 0)
+ return true;
+
+ char *End;
+ Res = strtoull(S,&End,Base);
+ if (End == S)
+ return false;
+
+ return true;
+}
+ /*}}}*/
+
// Base256ToNum - Convert a fixed length binary to a number /*{{{*/
// ---------------------------------------------------------------------
/* This is used in decoding the 256bit encoded fixed length fields in
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index fba85cf94..ab4b54722 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -56,6 +56,7 @@ string LookupTag(const string &Message,const char *Tag,const char *Default = 0);
int StringToBool(const string &Text,int Default = -1);
bool ReadMessages(int Fd, vector<string> &List);
bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base = 0);
+bool StrToNum(const char *Str,unsigned long long &Res,unsigned Len,unsigned Base = 0);
bool Base256ToNum(const char *Str,unsigned long &Res,unsigned int Len);
bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length);
bool TokSplitString(char Tok,char *Input,char **List,
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index e3d4063dc..27c1f7f32 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -9,6 +9,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/debindexfile.h>
#include <apt-pkg/debsrcrecords.h>
#include <apt-pkg/deblistparser.h>
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 952433428..a4a974897 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -10,6 +10,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/deblistparser.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index e1f8219e3..1d3754b00 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -1,4 +1,5 @@
// ijones, walters
+#include <config.h>
#include <apt-pkg/debmetaindex.h>
#include <apt-pkg/debindexfile.h>
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc
index 2571aae52..4dfc8b56a 100644
--- a/apt-pkg/deb/debrecords.cc
+++ b/apt-pkg/deb/debrecords.cc
@@ -8,6 +8,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/debrecords.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/error.h>
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index 749305005..c9c20267b 100644
--- a/apt-pkg/deb/debsrcrecords.cc
+++ b/apt-pkg/deb/debsrcrecords.cc
@@ -9,6 +9,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/deblistparser.h>
#include <apt-pkg/debsrcrecords.h>
#include <apt-pkg/error.h>
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index 7644bc66b..080af5659 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -10,6 +10,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/debsystem.h>
#include <apt-pkg/debversion.h>
#include <apt-pkg/debindexfile.h>
@@ -17,11 +19,12 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <apti18n.h>
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
#include <errno.h>
+
+#include <apti18n.h>
/*}}}*/
debSystem debSys;
diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc
index 755ffbe96..ba32b2dd4 100644
--- a/apt-pkg/deb/debversion.cc
+++ b/apt-pkg/deb/debversion.cc
@@ -11,6 +11,7 @@
/*}}}*/
// Include Files /*{{{*/
#define APT_COMPATIBILITY 986
+#include <config.h>
#include <apt-pkg/debversion.h>
#include <apt-pkg/pkgcache.h>
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 3c4c244cc..2c34465c0 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -8,6 +8,8 @@
##################################################################### */
/*}}}*/
// Includes /*{{{*/
+#include <config.h>
+
#include <apt-pkg/dpkgpm.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
@@ -40,7 +42,6 @@
#include <sys/ioctl.h>
#include <pty.h>
-#include <config.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index e9527647e..f816630ae 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -8,6 +8,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/depcache.h>
#include <apt-pkg/version.h>
#include <apt-pkg/versionmatch.h>
@@ -23,12 +25,12 @@
#include <apt-pkg/tagfile.h>
#include <iostream>
-#include <sstream>
+#include <sstream>
#include <set>
#include <sys/stat.h>
-#include <apti18n.h>
+#include <apti18n.h>
/*}}}*/
// helper for Install-Recommends-Sections and Never-MarkAuto-Sections /*{{{*/
static bool
@@ -169,14 +171,14 @@ bool pkgDepCache::readStateFile(OpProgress *Prog) /*{{{*/
string const state = _config->FindFile("Dir::State::extended_states");
if(RealFileExists(state)) {
state_file.Open(state, FileFd::ReadOnly);
- int const file_size = state_file.Size();
+ off_t const file_size = state_file.Size();
if(Prog != NULL)
Prog->OverallProgress(0, file_size, 1,
_("Reading state information"));
pkgTagFile tagfile(&state_file);
pkgTagSection section;
- int amt = 0;
+ off_t amt = 0;
bool const debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false);
while(tagfile.Step(section)) {
string const pkgname = section.FindS("Package");
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index 4d2230613..44f7dbfd6 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -5,6 +5,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/edsp.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
@@ -12,10 +14,10 @@
#include <apt-pkg/policy.h>
#include <apt-pkg/tagfile.h>
-#include <apti18n.h>
#include <limits>
-
#include <stdio.h>
+
+#include <apti18n.h>
/*}}}*/
// we could use pkgCache::DepType and ::Priority, but these would be localized strings…
diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc
index f5881e663..b417a7562 100644
--- a/apt-pkg/edsp/edspindexfile.cc
+++ b/apt-pkg/edsp/edspindexfile.cc
@@ -6,6 +6,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/edspindexfile.h>
#include <apt-pkg/edsplistparser.h>
#include <apt-pkg/sourcelist.h>
diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc
index 3349e8cce..e00abdbcc 100644
--- a/apt-pkg/edsp/edsplistparser.cc
+++ b/apt-pkg/edsp/edsplistparser.cc
@@ -9,6 +9,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/edsplistparser.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
diff --git a/apt-pkg/edsp/edspsystem.cc b/apt-pkg/edsp/edspsystem.cc
index ac0bb8beb..10d75771a 100644
--- a/apt-pkg/edsp/edspsystem.cc
+++ b/apt-pkg/edsp/edspsystem.cc
@@ -9,17 +9,20 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/edspsystem.h>
#include <apt-pkg/debversion.h>
#include <apt-pkg/edspindexfile.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <apti18n.h>
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
#include <errno.h>
+
+#include <apti18n.h>
/*}}}*/
edspSystem edspSys;
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index 747e464be..4df018ef4 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -10,7 +10,7 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include "indexcopy.h"
+#include<config.h>
#include <apt-pkg/error.h>
#include <apt-pkg/progress.h>
@@ -21,7 +21,6 @@
#include <apt-pkg/indexrecords.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/cdrom.h>
-#include <apti18n.h>
#include <iostream>
#include <sstream>
@@ -30,6 +29,10 @@
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
+#include <stdlib.h>
+
+#include "indexcopy.h"
+#include <apti18n.h>
/*}}}*/
using namespace std;
@@ -53,7 +56,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
bool Debug = _config->FindB("Debug::aptcdrom",false);
// Prepare the progress indicator
- unsigned long TotalSize = 0;
+ off_t TotalSize = 0;
for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
struct stat Buf;
@@ -64,14 +67,14 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
TotalSize += Buf.st_size;
}
- unsigned long CurrentSize = 0;
+ off_t CurrentSize = 0;
unsigned int NotFound = 0;
unsigned int WrongSize = 0;
unsigned int Packages = 0;
for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string OrigPath = string(*I,CDROM.length());
- unsigned long FileSize = 0;
+ off_t FileSize = 0;
// Open the package file
FileFd Pkg;
@@ -164,7 +167,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
if(Progress)
Progress->Progress(Parser.Offset());
string File;
- unsigned long Size;
+ unsigned long long Size;
if (GetFile(File,Size) == false)
{
fclose(TargetFl);
@@ -219,7 +222,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
}
// Size match
- if ((unsigned)Buf.st_size != Size)
+ if ((unsigned long long)Buf.st_size != Size)
{
if (Debug == true)
clog << "Wrong Size: " << File << endl;
@@ -453,7 +456,7 @@ bool IndexCopy::GrabFirst(string Path,string &To,unsigned int Depth)
// PackageCopy::GetFile - Get the file information from the section /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool PackageCopy::GetFile(string &File,unsigned long &Size)
+bool PackageCopy::GetFile(string &File,unsigned long long &Size)
{
File = Section->FindS("Filename");
Size = Section->FindI("Size");
@@ -479,7 +482,7 @@ bool PackageCopy::RewriteEntry(FILE *Target,string File)
// SourceCopy::GetFile - Get the file information from the section /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool SourceCopy::GetFile(string &File,unsigned long &Size)
+bool SourceCopy::GetFile(string &File,unsigned long long &Size)
{
string Files = Section->FindS("Files");
if (Files.empty() == true)
@@ -502,7 +505,7 @@ bool SourceCopy::GetFile(string &File,unsigned long &Size)
return _error->Error("Error parsing file record");
// Parse the size and append the directory
- Size = atoi(sSize.c_str());
+ Size = strtoull(sSize.c_str(), NULL, 10);
File = Base + File;
return true;
}
@@ -785,7 +788,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/
bool Debug = _config->FindB("Debug::aptcdrom",false);
// Prepare the progress indicator
- unsigned long TotalSize = 0;
+ off_t TotalSize = 0;
for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
struct stat Buf;
@@ -796,14 +799,14 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/
TotalSize += Buf.st_size;
}
- unsigned long CurrentSize = 0;
+ off_t CurrentSize = 0;
unsigned int NotFound = 0;
unsigned int WrongSize = 0;
unsigned int Packages = 0;
for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string OrigPath = string(*I,CDROM.length());
- unsigned long FileSize = 0;
+ off_t FileSize = 0;
// Open the package file
FileFd Pkg;
diff --git a/apt-pkg/indexcopy.h b/apt-pkg/indexcopy.h
index 277fb561c..60c90dd4a 100644
--- a/apt-pkg/indexcopy.h
+++ b/apt-pkg/indexcopy.h
@@ -37,7 +37,7 @@ class IndexCopy /*{{{*/
bool ReconstructChop(unsigned long &Chop,string Dir,string File);
void ConvertToSourceList(string CD,string &Path);
bool GrabFirst(string Path,string &To,unsigned int Depth);
- virtual bool GetFile(string &Filename,unsigned long &Size) = 0;
+ virtual bool GetFile(string &Filename,unsigned long long &Size) = 0;
virtual bool RewriteEntry(FILE *Target,string File) = 0;
virtual const char *GetFileName() = 0;
virtual const char *Type() = 0;
@@ -53,7 +53,7 @@ class PackageCopy : public IndexCopy /*{{{*/
{
protected:
- virtual bool GetFile(string &Filename,unsigned long &Size);
+ virtual bool GetFile(string &Filename,unsigned long long &Size);
virtual bool RewriteEntry(FILE *Target,string File);
virtual const char *GetFileName() {return "Packages";};
virtual const char *Type() {return "Package";};
@@ -64,7 +64,7 @@ class SourceCopy : public IndexCopy /*{{{*/
{
protected:
- virtual bool GetFile(string &Filename,unsigned long &Size);
+ virtual bool GetFile(string &Filename,unsigned long long &Size);
virtual bool RewriteEntry(FILE *Target,string File);
virtual const char *GetFileName() {return "Sources";};
virtual const char *Type() {return "Source";};
diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc
index f18ddbfaa..68e9df4c8 100644
--- a/apt-pkg/indexfile.cc
+++ b/apt-pkg/indexfile.cc
@@ -8,6 +8,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/indexfile.h>
#include <apt-pkg/error.h>
#include <apt-pkg/aptconfiguration.h>
diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc
index 10e154ad2..448a76c27 100644
--- a/apt-pkg/indexrecords.cc
+++ b/apt-pkg/indexrecords.cc
@@ -3,15 +3,17 @@
// $Id: indexrecords.cc,v 1.1.2.4 2003/12/30 02:11:43 mdz Exp $
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/indexrecords.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/configuration.h>
-#include <apti18n.h>
#include <sys/stat.h>
#include <clocale>
+#include <apti18n.h>
/*}}}*/
string indexRecords::GetDist() const
{
@@ -78,7 +80,7 @@ bool indexRecords::Load(const string Filename) /*{{{*/
string Name;
string Hash;
- size_t Size;
+ unsigned long long Size;
while (Start < End)
{
if (!parseSumData(Start, End, Name, Hash, Size))
@@ -113,10 +115,14 @@ bool indexRecords::Load(const string Filename) /*{{{*/
}
// get the user settings for this archive and use what expires earlier
int MaxAge = _config->FindI("Acquire::Max-ValidTime", 0);
- if (Label.empty() == true)
+ if (Label.empty() == false)
MaxAge = _config->FindI(string("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge);
+ int MinAge = _config->FindI("Acquire::Min-ValidTime", 0);
+ if (Label.empty() == false)
+ MinAge = _config->FindI(string("Acquire::Min-ValidTime::" + Label).c_str(), MinAge);
- if(MaxAge == 0) // No user settings, use the one from the Release file
+ if(MaxAge == 0 &&
+ (MinAge == 0 || ValidUntil == 0)) // No user settings, use the one from the Release file
return true;
time_t date;
@@ -125,10 +131,17 @@ bool indexRecords::Load(const string Filename) /*{{{*/
strprintf(ErrorText, _("Invalid 'Date' entry in Release file %s"), Filename.c_str());
return false;
}
- date += 24*60*60*MaxAge;
- if (ValidUntil == 0 || ValidUntil > date)
- ValidUntil = date;
+ if (MinAge != 0 && ValidUntil != 0) {
+ time_t const min_date = date + MinAge;
+ if (ValidUntil < min_date)
+ ValidUntil = min_date;
+ }
+ if (MaxAge != 0) {
+ time_t const max_date = date + MaxAge;
+ if (ValidUntil == 0 || ValidUntil > max_date)
+ ValidUntil = max_date;
+ }
return true;
}
@@ -145,7 +158,7 @@ vector<string> indexRecords::MetaKeys() /*{{{*/
}
/*}}}*/
bool indexRecords::parseSumData(const char *&Start, const char *End, /*{{{*/
- string &Name, string &Hash, size_t &Size)
+ string &Name, string &Hash, unsigned long long &Size)
{
Name = "";
Hash = "";
@@ -182,7 +195,7 @@ bool indexRecords::parseSumData(const char *&Start, const char *End, /*{{{*/
if (EntryEnd == End)
return false;
- Size = strtol (Start, NULL, 10);
+ Size = strtoull (Start, NULL, 10);
/* Skip over intermediate blanks */
Start = EntryEnd;
diff --git a/apt-pkg/indexrecords.h b/apt-pkg/indexrecords.h
index 5b532c1a5..0f933b93c 100644
--- a/apt-pkg/indexrecords.h
+++ b/apt-pkg/indexrecords.h
@@ -17,7 +17,7 @@
class indexRecords
{
bool parseSumData(const char *&Start, const char *End, string &Name,
- string &Hash, size_t &Size);
+ string &Hash, unsigned long long &Size);
public:
struct checkSum;
string ErrorText;
@@ -53,7 +53,7 @@ struct indexRecords::checkSum
{
string MetaKeyFilename;
HashString Hash;
- size_t Size;
+ unsigned long long Size;
};
#endif
diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc
index 8f20c31df..97a39e96e 100644
--- a/apt-pkg/init.cc
+++ b/apt-pkg/init.cc
@@ -8,14 +8,16 @@
##################################################################### */
/*}}}*/
// Include files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/init.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
-#include <apti18n.h>
-#include <config.h>
#include <cstdlib>
#include <sys/stat.h>
+
+#include <apti18n.h>
/*}}}*/
#define Stringfy_(x) # x
diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc
index a58efa987..80d7b6619 100644
--- a/apt-pkg/orderlist.cc
+++ b/apt-pkg/orderlist.cc
@@ -63,6 +63,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/orderlist.h>
#include <apt-pkg/depcache.h>
#include <apt-pkg/error.h>
@@ -152,7 +154,7 @@ bool pkgOrderList::DoRun()
iterator OldEnd = End;
End = NList;
for (iterator I = List; I != OldEnd; ++I)
- if (VisitNode(PkgIterator(Cache,*I)) == false)
+ if (VisitNode(PkgIterator(Cache,*I), "DoRun") == false)
{
End = OldEnd;
return false;
@@ -495,33 +497,69 @@ bool pkgOrderList::VisitRProvides(DepFunc F,VerIterator Ver)
/*}}}*/
// OrderList::VisitProvides - Visit all of the providing packages /*{{{*/
// ---------------------------------------------------------------------
-/* This routine calls visit on all providing packages. */
+/* This routine calls visit on all providing packages.
+
+ If the dependency is negative it first visits packages which are
+ intended to be removed and after that all other packages.
+ It does so to avoid situations in which this package is used to
+ satisfy a (or-group/provides) dependency of another package which
+ could have been satisfied also by upgrading another package -
+ otherwise we have more broken packages dpkg needs to auto-
+ deconfigure and in very complicated situations it even decides
+ against it! */
bool pkgOrderList::VisitProvides(DepIterator D,bool Critical)
-{
+{
SPtrArray<Version *> List = D.AllTargets();
- for (Version **I = List; *I != 0; I++)
+ for (Version **I = List; *I != 0; ++I)
{
VerIterator Ver(Cache,*I);
PkgIterator Pkg = Ver.ParentPkg();
+ if (D.IsNegative() == true && Cache[Pkg].Delete() == false)
+ continue;
+
if (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing)
continue;
-
+
if (D.IsNegative() == false &&
Cache[Pkg].InstallVer != *I)
continue;
-
+
if (D.IsNegative() == true &&
(Version *)Pkg.CurrentVer() != *I)
continue;
-
+
// Skip over missing files
if (Critical == false && IsMissing(D.ParentPkg()) == true)
continue;
- if (VisitNode(Pkg) == false)
+ if (VisitNode(Pkg, "Provides-1") == false)
return false;
}
+ if (D.IsNegative() == false)
+ return true;
+ for (Version **I = List; *I != 0; ++I)
+ {
+ VerIterator Ver(Cache,*I);
+ PkgIterator Pkg = Ver.ParentPkg();
+
+ if (Cache[Pkg].Delete() == true)
+ continue;
+
+ if (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing)
+ continue;
+
+ if ((Version *)Pkg.CurrentVer() != *I)
+ continue;
+
+ // Skip over missing files
+ if (Critical == false && IsMissing(D.ParentPkg()) == true)
+ continue;
+
+ if (VisitNode(Pkg, "Provides-2") == false)
+ return false;
+ }
+
return true;
}
/*}}}*/
@@ -530,7 +568,7 @@ bool pkgOrderList::VisitProvides(DepIterator D,bool Critical)
/* This is the core ordering routine. It calls the set dependency
consideration functions which then potentialy call this again. Finite
depth is achived through the colouring mechinism. */
-bool pkgOrderList::VisitNode(PkgIterator Pkg)
+bool pkgOrderList::VisitNode(PkgIterator Pkg, char const* from)
{
// Looping or irrelevent.
// This should probably trancend not installed packages
@@ -541,7 +579,7 @@ bool pkgOrderList::VisitNode(PkgIterator Pkg)
if (Debug == true)
{
for (int j = 0; j != Depth; j++) clog << ' ';
- clog << "Visit " << Pkg.FullName() << endl;
+ clog << "Visit " << Pkg.FullName() << " from " << from << endl;
}
Depth++;
@@ -636,7 +674,7 @@ bool pkgOrderList::DepUnPackCrit(DepIterator D)
if (CheckDep(D) == true)
continue;
- if (VisitNode(D.ParentPkg()) == false)
+ if (VisitNode(D.ParentPkg(), "UnPackCrit") == false)
return false;
}
else
@@ -811,7 +849,7 @@ bool pkgOrderList::DepUnPackDep(DepIterator D)
if (IsMissing(D.ParentPkg()) == true)
continue;
- if (VisitNode(D.ParentPkg()) == false)
+ if (VisitNode(D.ParentPkg(), "UnPackDep-Parent") == false)
return false;
}
else
@@ -825,7 +863,7 @@ bool pkgOrderList::DepUnPackDep(DepIterator D)
if (CheckDep(D) == true)
continue;
- if (VisitNode(D.TargetPkg()) == false)
+ if (VisitNode(D.TargetPkg(), "UnPackDep-Target") == false)
return false;
}
}
@@ -924,7 +962,7 @@ bool pkgOrderList::DepRemove(DepIterator D)
if (IsFlag(P, InList) == true &&
IsFlag(P, AddPending) == false &&
Cache[P].InstallVer != 0 &&
- VisitNode(P) == true)
+ VisitNode(P, "Remove-P") == true)
{
Flag(P, Immediate);
tryFixDeps = false;
@@ -960,7 +998,7 @@ bool pkgOrderList::DepRemove(DepIterator D)
if (IsFlag(F.TargetPkg(), InList) == true &&
IsFlag(F.TargetPkg(), AddPending) == false &&
Cache[F.TargetPkg()].InstallVer != 0 &&
- VisitNode(F.TargetPkg()) == true)
+ VisitNode(F.TargetPkg(), "Remove-Target") == true)
{
Flag(F.TargetPkg(), Immediate);
tryFixDeps = false;
@@ -974,7 +1012,7 @@ bool pkgOrderList::DepRemove(DepIterator D)
if (IsFlag(Prv.OwnerPkg(), InList) == true &&
IsFlag(Prv.OwnerPkg(), AddPending) == false &&
Cache[Prv.OwnerPkg()].InstallVer != 0 &&
- VisitNode(Prv.OwnerPkg()) == true)
+ VisitNode(Prv.OwnerPkg(), "Remove-Owner") == true)
{
Flag(Prv.OwnerPkg(), Immediate);
tryFixDeps = false;
@@ -994,7 +1032,7 @@ bool pkgOrderList::DepRemove(DepIterator D)
if (IsMissing(D.ParentPkg()) == true)
continue;
- if (VisitNode(D.ParentPkg()) == false)
+ if (VisitNode(D.ParentPkg(), "Remove-Parent") == false)
return false;
}
diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h
index bbceb3879..264f7ba03 100644
--- a/apt-pkg/orderlist.h
+++ b/apt-pkg/orderlist.h
@@ -18,6 +18,7 @@
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/macros.h>
class pkgDepCache;
class pkgOrderList : protected pkgCache::Namespace
@@ -45,7 +46,8 @@ class pkgOrderList : protected pkgCache::Namespace
bool Debug;
// Main visit function
- bool VisitNode(PkgIterator Pkg);
+ __deprecated bool VisitNode(PkgIterator Pkg) { return VisitNode(Pkg, "UNKNOWN"); };
+ bool VisitNode(PkgIterator Pkg, char const* from);
bool VisitDeps(DepFunc F,PkgIterator Pkg);
bool VisitRDeps(DepFunc F,PkgIterator Pkg);
bool VisitRProvides(DepFunc F,VerIterator Ver);
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index a3ba26f7c..c41a1f1ee 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -13,6 +13,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/packagemanager.h>
#include <apt-pkg/orderlist.h>
#include <apt-pkg/depcache.h>
@@ -22,10 +24,10 @@
#include <apt-pkg/algorithms.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/sptr.h>
-
-#include <apti18n.h>
+
+#include <apti18n.h>
#include <iostream>
-#include <fcntl.h>
+#include <fcntl.h>
/*}}}*/
using namespace std;
@@ -598,22 +600,44 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate)
for (PrvIterator P = instVer.ProvidesList();
P.end() == false; ++P)
- CheckRConflicts(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion());
+ if (Pkg->Group != P.OwnerPkg()->Group)
+ CheckRConflicts(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion());
List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States);
- if ((instVer->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same)
+ if (Immediate == true && instVer->MultiArch == pkgCache::Version::Same)
+ {
+ /* Do lockstep M-A:same unpacking in two phases:
+ First unpack all installed architectures, then the not installed.
+ This way we avoid that M-A: enabled packages are installed before
+ their older non-M-A enabled packages are replaced by newer versions */
+ bool const installed = Pkg->CurrentVer != 0;
+ if (installed == true && Install(Pkg,FileNames[Pkg->ID]) == false)
+ return false;
for (PkgIterator P = Pkg.Group().PackageList();
P.end() == false; P = Pkg.Group().NextPkg(P))
{
- if (Pkg == P || List->IsFlag(P,pkgOrderList::UnPacked) == true ||
+ if (P->CurrentVer == 0 || P == Pkg || List->IsFlag(P,pkgOrderList::UnPacked) == true ||
Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer &&
(Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall))
continue;
- SmartUnPack(P, false);
+ if (SmartUnPack(P, false) == false)
+ return false;
}
-
- if(Install(Pkg,FileNames[Pkg->ID]) == false)
+ if (installed == false && Install(Pkg,FileNames[Pkg->ID]) == false)
+ return false;
+ for (PkgIterator P = Pkg.Group().PackageList();
+ P.end() == false; P = Pkg.Group().NextPkg(P))
+ {
+ if (P->CurrentVer != 0 || P == Pkg || List->IsFlag(P,pkgOrderList::UnPacked) == true ||
+ Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer &&
+ (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall))
+ continue;
+ if (SmartUnPack(P, false) == false)
+ return false;
+ }
+ }
+ else if (Install(Pkg,FileNames[Pkg->ID]) == false)
return false;
// Perform immedate configuration of the package.
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index faccafbef..089648271 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -20,6 +20,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/policy.h>
#include <apt-pkg/version.h>
@@ -29,13 +31,12 @@
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/macros.h>
-#include <apti18n.h>
-
#include <string>
#include <sys/stat.h>
#include <unistd.h>
-
#include <ctype.h>
+
+#include <apti18n.h>
/*}}}*/
using std::string;
@@ -637,7 +638,7 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
continue;
if (IsNegative() == true &&
- ParentPkg() == I.OwnerPkg())
+ ParentPkg()->Group == I.OwnerPkg()->Group)
continue;
Size++;
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index f41bb5a0a..a39aa9f59 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -11,6 +11,7 @@
/*}}}*/
// Include Files /*{{{*/
#define APT_COMPATIBILITY 986
+#include <config.h>
#include <apt-pkg/pkgcachegen.h>
#include <apt-pkg/error.h>
@@ -23,17 +24,15 @@
#include <apt-pkg/sptr.h>
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/macros.h>
-
#include <apt-pkg/tagfile.h>
-#include <apti18n.h>
-
#include <vector>
-
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
+
+#include <apti18n.h>
/*}}}*/
typedef vector<pkgIndexFile *>::iterator FileIterator;
template <typename Iter> std::vector<Iter*> pkgCacheGenerator::Dynamic<Iter>::toReMap;
diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc
index 1a7585d8f..7709f133a 100644
--- a/apt-pkg/pkgrecords.cc
+++ b/apt-pkg/pkgrecords.cc
@@ -9,12 +9,14 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/indexfile.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
-
-#include <apti18n.h>
+
+#include <apti18n.h>
/*}}}*/
// Records::pkgRecords - Constructor /*{{{*/
diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h
index ce92cacc4..8741533b9 100644
--- a/apt-pkg/pkgrecords.h
+++ b/apt-pkg/pkgrecords.h
@@ -19,7 +19,6 @@
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/fileutl.h>
#include <vector>
class pkgRecords /*{{{*/
diff --git a/apt-pkg/pkgsystem.cc b/apt-pkg/pkgsystem.cc
index 6dd2d3ee4..f61c140fa 100644
--- a/apt-pkg/pkgsystem.cc
+++ b/apt-pkg/pkgsystem.cc
@@ -10,6 +10,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/policy.h>
#include <cassert>
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index 0cc77e0af..e6c44ebe2 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -23,6 +23,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/policy.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/tagfile.h>
@@ -31,10 +33,10 @@
#include <apt-pkg/error.h>
#include <apt-pkg/sptr.h>
-#include <apti18n.h>
-
#include <iostream>
#include <sstream>
+
+#include <apti18n.h>
/*}}}*/
using namespace std;
diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc
index 47800b0c2..e20ec4704 100644
--- a/apt-pkg/sourcelist.cc
+++ b/apt-pkg/sourcelist.cc
@@ -8,15 +8,17 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/sourcelist.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/configuration.h>
-#include <apti18n.h>
-
#include <fstream>
+
+#include <apti18n.h>
/*}}}*/
using namespace std;
diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc
index 946ac1a1a..8c1de2ea5 100644
--- a/apt-pkg/srcrecords.cc
+++ b/apt-pkg/srcrecords.cc
@@ -11,12 +11,14 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/srcrecords.h>
#include <apt-pkg/error.h>
#include <apt-pkg/sourcelist.h>
#include <apt-pkg/strutl.h>
-
-#include <apti18n.h>
+
+#include <apti18n.h>
/*}}}*/
// SrcRecords::pkgSrcRecords - Constructor /*{{{*/
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index a8f04b23a..418e6bed8 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -11,15 +11,17 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/tagfile.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
-#include <apti18n.h>
-
#include <string>
#include <stdio.h>
#include <ctype.h>
+
+#include <apti18n.h>
/*}}}*/
using std::string;
@@ -27,7 +29,7 @@ using std::string;
class pkgTagFilePrivate
{
public:
- pkgTagFilePrivate(FileFd *pFd, unsigned long Size) : Fd(*pFd), Size(Size)
+ pkgTagFilePrivate(FileFd *pFd, unsigned long long Size) : Fd(*pFd), Size(Size)
{
}
FileFd &Fd;
@@ -35,14 +37,14 @@ public:
char *Start;
char *End;
bool Done;
- unsigned long iOffset;
- unsigned long Size;
+ unsigned long long iOffset;
+ unsigned long long Size;
};
// TagFile::pkgTagFile - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size)
+pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long long Size)
{
d = new pkgTagFilePrivate(pFd, Size);
@@ -84,7 +86,7 @@ unsigned long pkgTagFile::Offset()
bool pkgTagFile::Resize()
{
char *tmp;
- unsigned long EndSize = d->End - d->Start;
+ unsigned long long EndSize = d->End - d->Start;
// fail is the buffer grows too big
if(d->Size > 1024*1024+1)
@@ -136,8 +138,8 @@ bool pkgTagFile::Step(pkgTagSection &Tag)
then fills the rest from the file */
bool pkgTagFile::Fill()
{
- unsigned long EndSize = d->End - d->Start;
- unsigned long Actual = 0;
+ unsigned long long EndSize = d->End - d->Start;
+ unsigned long long Actual = 0;
memmove(d->Buffer,d->Start,EndSize);
d->Start = d->Buffer;
@@ -178,12 +180,12 @@ bool pkgTagFile::Fill()
// ---------------------------------------------------------------------
/* This jumps to a pre-recorded file location and reads the record
that is there */
-bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long Offset)
+bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long long Offset)
{
// We are within a buffer space of the next hit..
if (Offset >= d->iOffset && d->iOffset + (d->End - d->Start) > Offset)
{
- unsigned long Dist = Offset - d->iOffset;
+ unsigned long long Dist = Offset - d->iOffset;
d->Start += Dist;
d->iOffset += Dist;
return Step(Tag);
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
index 3a2dee7c7..28f7fcc24 100644
--- a/apt-pkg/tagfile.h
+++ b/apt-pkg/tagfile.h
@@ -94,9 +94,9 @@ class pkgTagFile
bool Step(pkgTagSection &Section);
unsigned long Offset();
- bool Jump(pkgTagSection &Tag,unsigned long Offset);
+ bool Jump(pkgTagSection &Tag,unsigned long long Offset);
- pkgTagFile(FileFd *F,unsigned long Size = 32*1024);
+ pkgTagFile(FileFd *F,unsigned long long Size = 32*1024);
virtual ~pkgTagFile();
};
diff --git a/apt-pkg/vendor.cc b/apt-pkg/vendor.cc
index 2350afe69..eab6d448f 100644
--- a/apt-pkg/vendor.cc
+++ b/apt-pkg/vendor.cc
@@ -1,3 +1,5 @@
+#include<config.h>
+
#include <iostream>
#include <apt-pkg/error.h>
#include <apt-pkg/vendor.h>
diff --git a/apt-pkg/vendorlist.cc b/apt-pkg/vendorlist.cc
index 4cc500727..731f11acf 100644
--- a/apt-pkg/vendorlist.cc
+++ b/apt-pkg/vendorlist.cc
@@ -1,3 +1,5 @@
+#include<config.h>
+
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
#include <apti18n.h>
diff --git a/apt-pkg/version.cc b/apt-pkg/version.cc
index 42e449d36..a9d4fb763 100644
--- a/apt-pkg/version.cc
+++ b/apt-pkg/version.cc
@@ -8,6 +8,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include<config.h>
+
#include <apt-pkg/version.h>
#include <apt-pkg/pkgcache.h>
diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc
index 6d667acad..f336b3c35 100644
--- a/apt-pkg/versionmatch.cc
+++ b/apt-pkg/versionmatch.cc
@@ -11,8 +11,9 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include <apt-pkg/versionmatch.h>
+#include<config.h>
+#include <apt-pkg/versionmatch.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/error.h>
@@ -21,7 +22,6 @@
#include <fnmatch.h>
#include <sys/types.h>
#include <regex.h>
-
/*}}}*/
// VersionMatch::pkgVersionMatch - Constructor /*{{{*/