Browse Source

merged from the debian-experimental2 branch

debian/1.8.y
Michael Vogt 11 years ago
parent
commit
216d0bd886
  1. 2
      apt-inst/makefile
  2. 54
      apt-pkg/acquire-item.cc
  3. 57
      apt-pkg/acquire-item.h
  4. 7
      apt-pkg/acquire-method.cc
  5. 5
      apt-pkg/acquire-method.h
  6. 4
      apt-pkg/acquire-worker.cc
  7. 11
      apt-pkg/acquire-worker.h
  8. 19
      apt-pkg/acquire.cc
  9. 52
      apt-pkg/acquire.h
  10. 55
      apt-pkg/algorithms.cc
  11. 6
      apt-pkg/algorithms.h
  12. 3
      apt-pkg/cachefile.h
  13. 2
      apt-pkg/cachefilter.h
  14. 8
      apt-pkg/cacheiterators.h
  15. 2
      apt-pkg/cacheset.h
  16. 10
      apt-pkg/cdrom.cc
  17. 8
      apt-pkg/cdrom.h
  18. 3
      apt-pkg/clean.h
  19. 41
      apt-pkg/contrib/hashes.cc
  20. 10
      apt-pkg/contrib/hashes.h
  21. 27
      apt-pkg/contrib/hashsum.cc
  22. 107
      apt-pkg/contrib/hashsum_template.h
  23. 80
      apt-pkg/contrib/md5.cc
  24. 37
      apt-pkg/contrib/md5.h
  25. 27
      apt-pkg/contrib/progress.cc
  26. 3
      apt-pkg/contrib/progress.h
  27. 88
      apt-pkg/contrib/sha1.cc
  28. 32
      apt-pkg/contrib/sha1.h
  29. 103
      apt-pkg/contrib/sha2.h
  30. 424
      apt-pkg/contrib/sha256.cc
  31. 68
      apt-pkg/contrib/sha256.h
  32. 1065
      apt-pkg/contrib/sha2_internal.cc
  33. 188
      apt-pkg/contrib/sha2_internal.h
  34. 20
      apt-pkg/deb/debindexfile.h
  35. 11
      apt-pkg/deb/deblistparser.cc
  36. 10
      apt-pkg/deb/deblistparser.h
  37. 39
      apt-pkg/deb/debmetaindex.cc
  38. 7
      apt-pkg/deb/debmetaindex.h
  39. 19
      apt-pkg/deb/debrecords.cc
  40. 8
      apt-pkg/deb/debrecords.h
  41. 5
      apt-pkg/deb/debsrcrecords.h
  42. 62
      apt-pkg/deb/debsystem.cc
  43. 13
      apt-pkg/deb/debsystem.h
  44. 108
      apt-pkg/deb/dpkgpm.cc
  45. 11
      apt-pkg/deb/dpkgpm.h
  46. 122
      apt-pkg/depcache.cc
  47. 38
      apt-pkg/depcache.h
  48. 564
      apt-pkg/edsp.cc
  49. 222
      apt-pkg/edsp.h
  50. 78
      apt-pkg/edsp/edspindexfile.cc
  51. 28
      apt-pkg/edsp/edspindexfile.h
  52. 90
      apt-pkg/edsp/edsplistparser.cc
  53. 38
      apt-pkg/edsp/edsplistparser.h
  54. 124
      apt-pkg/edsp/edspsystem.cc
  55. 41
      apt-pkg/edsp/edspsystem.h
  56. 8
      apt-pkg/indexcopy.h
  57. 1
      apt-pkg/init.cc
  58. 4
      apt-pkg/init.h
  59. 18
      apt-pkg/makefile
  60. 4
      apt-pkg/metaindex.h
  61. 4
      apt-pkg/packagemanager.cc
  62. 8
      apt-pkg/pkgcache.cc
  63. 22
      apt-pkg/pkgcache.h
  64. 1
      apt-pkg/pkgcachegen.cc
  65. 11
      apt-pkg/pkgrecords.h
  66. 4
      apt-pkg/policy.cc
  67. 7
      apt-pkg/policy.h
  68. 8
      apt-pkg/sourcelist.cc
  69. 4
      apt-pkg/srcrecords.h
  70. 124
      apt-pkg/tagfile.cc
  71. 21
      apt-pkg/tagfile.h
  72. 2
      cmdline/acqprogress.cc
  73. 50
      cmdline/apt-dump-solver.cc
  74. 21
      cmdline/apt-get.cc
  75. 190
      cmdline/apt-internal-solver.cc
  76. 14
      cmdline/makefile
  77. 2
      configure.in
  78. 1
      debian/apt-doc.docs
  79. 2
      debian/apt-utils.dirs
  80. 2
      debian/apt-utils.install
  81. 1
      debian/apt-utils.links
  82. 1
      debian/apt.dirs
  83. 3
      debian/apt.install
  84. 290
      debian/changelog
  85. 85
      debian/control
  86. 2
      debian/libapt-inst1.3.install
  87. 5
      debian/libapt-inst1.3.symbols
  88. 2
      debian/libapt-pkg4.11.install
  89. 140
      debian/libapt-pkg4.11.symbols
  90. 71
      debian/rules
  91. 5
      doc/apt-get.8.xml
  92. 299
      doc/external-dependency-solver-protocol.txt
  93. 98
      doc/po/apt-doc.pot
  94. 151
      doc/po/de.po
  95. 126
      doc/po/es.po
  96. 157
      doc/po/fr.po
  97. 101
      doc/po/it.po
  98. 118
      doc/po/ja.po
  99. 129
      doc/po/pl.po
  100. 126
      doc/po/pt.po

2
apt-inst/makefile

@ -14,7 +14,7 @@ include ../buildlib/libversion.mak
# The library name
LIBRARY=apt-inst
MAJOR=1.2
MAJOR=1.3
MINOR=0
SLIBS=$(PTHREADLIB) -lapt-pkg
APT_DOMAIN:=libapt-inst$(MAJOR)

54
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)
@ -808,6 +808,13 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const *Target,
if (CompressionExtension.empty() == false)
CompressionExtension.erase(CompressionExtension.end()-1);
// only verify non-optional targets, see acquire-item.h for a FIXME
// to make this more flexible
if (Target->IsOptional())
Verify = false;
else
Verify = true;
Init(Target->URI, Target->Description, Target->ShortDesc);
}
/*}}}*/
@ -881,7 +888,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);
@ -905,6 +912,7 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash,
/* Verify the index file for correctness (all indexes must
* have a Package field) (LP: #346386) (Closes: #627642) */
if (Verify == true)
{
FileFd fd(DestFile, FileFd::ReadOnly);
pkgTagSection sec;
@ -1123,7 +1131,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 +1240,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);
@ -1734,6 +1742,8 @@ bool pkgAcqArchive::QueueNext()
string PkgFile = Parse.FileName();
if (ForceHash.empty() == false)
{
if(stringcasecmp(ForceHash, "sha512") == 0)
ExpectedHash = HashString("SHA512", Parse.SHA512Hash());
if(stringcasecmp(ForceHash, "sha256") == 0)
ExpectedHash = HashString("SHA256", Parse.SHA256Hash());
else if (stringcasecmp(ForceHash, "sha1") == 0)
@ -1744,7 +1754,9 @@ bool pkgAcqArchive::QueueNext()
else
{
string Hash;
if ((Hash = Parse.SHA256Hash()).empty() == false)
if ((Hash = Parse.SHA512Hash()).empty() == false)
ExpectedHash = HashString("SHA512", Hash);
else if ((Hash = Parse.SHA256Hash()).empty() == false)
ExpectedHash = HashString("SHA256", Hash);
else if ((Hash = Parse.SHA1Hash()).empty() == false)
ExpectedHash = HashString("SHA1", Hash);
@ -1768,7 +1780,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 +1799,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 +1819,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 +1842,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 +1953,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 +1981,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 +1993,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);
@ -2069,13 +2081,3 @@ string pkgAcqFile::Custom600Headers()
return "";
}
/*}}}*/
bool IndexTarget::IsOptional() const {
if (strncmp(ShortDesc.c_str(), "Translation", 11) != 0)
return false;
return true;
}
bool IndexTarget::IsSubIndex() const {
if (ShortDesc != "TranslationIndex")
return false;
return true;
}

57
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";};
@ -559,6 +559,16 @@ class pkgAcqIndex : public pkgAcquire::Item
*/
bool Erase;
/** \brief Verify for correctness by checking if a "Package"
* tag is found in the index. This can be set to
* false for optional index targets
*
*/
// FIXME: instead of a bool it should use a verify string that will
// then be used in the pkgAcqIndex::Done method to ensure that
// the downloaded file contains the expected tag
bool Verify;
/** \brief The download request that is currently being
* processed.
*/
@ -581,7 +591,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;};
@ -646,8 +656,9 @@ class pkgAcqIndexTrans : public pkgAcqIndex
};
/*}}}*/
/** \brief Information about an index file. */ /*{{{*/
struct IndexTarget
class IndexTarget
{
public:
/** \brief A URI from which the index file can be downloaded. */
string URI;
@ -662,14 +673,28 @@ struct IndexTarget
*/
string MetaKey;
//FIXME: We should use virtual methods here instead…
bool IsOptional() const;
bool IsSubIndex() const;
virtual bool IsOptional() const {
return false;
}
virtual bool IsSubIndex() const {
return false;
}
};
/*}}}*/
/** \brief Information about an optional index file. */ /*{{{*/
struct OptionalIndexTarget : public IndexTarget
class OptionalIndexTarget : public IndexTarget
{
virtual bool IsOptional() const {
return true;
}
};
/*}}}*/
/** \brief Information about an subindex index file. */ /*{{{*/
class SubIndexTarget : public IndexTarget
{
virtual bool IsSubIndex() const {
return true;
}
};
/*}}}*/
@ -723,7 +748,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 +843,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 +943,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 +1000,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 +1037,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);

7
apt-pkg/acquire-method.cc

@ -166,6 +166,8 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
std::cout << "SHA1-Hash: " << Res.SHA1Sum << "\n";
if (Res.SHA256Sum.empty() == false)
std::cout << "SHA256-Hash: " << Res.SHA256Sum << "\n";
if (Res.SHA512Sum.empty() == false)
std::cout << "SHA512-Hash: " << Res.SHA512Sum << "\n";
if (UsedMirror.empty() == false)
std::cout << "UsedMirror: " << UsedMirror << "\n";
if (Res.GPGVOutput.empty() == false)
@ -199,7 +201,9 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
std::cout << "Alt-SHA1-Hash: " << Alt->SHA1Sum << "\n";
if (Alt->SHA256Sum.empty() == false)
std::cout << "Alt-SHA256-Hash: " << Alt->SHA256Sum << "\n";
if (Alt->SHA512Sum.empty() == false)
std::cout << "Alt-SHA512-Hash: " << Alt->SHA512Sum << "\n";
if (Alt->IMSHit == true)
std::cout << "Alt-IMS-Hit: true\n";
}
@ -460,5 +464,6 @@ void pkgAcqMethod::FetchResult::TakeHashes(Hashes &Hash)
MD5Sum = Hash.MD5.Result();
SHA1Sum = Hash.SHA1.Result();
SHA256Sum = Hash.SHA256.Result();
SHA512Sum = Hash.SHA512.Result();
}
/*}}}*/

5
apt-pkg/acquire-method.h

@ -46,12 +46,13 @@ class pkgAcqMethod
string MD5Sum;
string SHA1Sum;
string SHA256Sum;
string SHA512Sum;
vector<string> GPGVOutput;
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();

4
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

11
apt-pkg/acquire-worker.h

@ -44,6 +44,9 @@
*/
class pkgAcquire::Worker : public WeakPointable
{
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
friend class pkgAcquire;
protected:
@ -244,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.
*
@ -314,7 +317,7 @@ class pkgAcquire::Worker : public WeakPointable
* Closes the file descriptors; if MethodConfig::NeedsCleanup is
* \b false, also rudely interrupts the worker with a SIGINT.
*/
~Worker();
virtual ~Worker();
};
/** @} */

19
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)
@ -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,13 +905,13 @@ 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 /*{{{*/
// ---------------------------------------------------------------------
/* 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;
}

52
apt-pkg/acquire.h

@ -91,6 +91,12 @@ class pkgAcquireStatus;
*/
class pkgAcquire
{
private:
/** \brief FD of the Lock file we acquire in Setup (if any) */
int LockFD;
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
public:
class Item;
@ -142,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
@ -361,9 +362,6 @@ class pkgAcquire
*/
virtual ~pkgAcquire();
private:
/** \brief FD of the Lock file we acquire in Setup (if any) */
int LockFD;
};
/** \brief Represents a single download source from which an item
@ -393,6 +391,9 @@ class pkgAcquire::Queue
friend class pkgAcquire::UriIterator;
friend class pkgAcquire::Worker;
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
/** \brief The next queue in the pkgAcquire object's list of queues. */
Queue *Next;
@ -480,7 +481,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.
@ -542,12 +543,15 @@ class pkgAcquire::Queue
/** Shut down all the worker processes associated with this queue
* and empty the queue.
*/
~Queue();
virtual ~Queue();
};
/*}}}*/
/** \brief Iterates over all the URIs being fetched by a pkgAcquire object. {{{*/
class pkgAcquire::UriIterator
{
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
/** The next queue to iterate over. */
pkgAcquire::Queue *CurQ;
/** The item that we currently point at. */
@ -583,11 +587,15 @@ class pkgAcquire::UriIterator
CurQ = CurQ->Next;
}
}
virtual ~UriIterator() {};
};
/*}}}*/
/** \brief Information about the properties of a single acquire method. {{{*/
struct pkgAcquire::MethodConfig
{
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
/** \brief The next link on the acquire method list.
*
* \todo Why not an STL container?
@ -636,16 +644,20 @@ struct pkgAcquire::MethodConfig
* appropriate.
*/
MethodConfig();
/* \brief Destructor, empty currently */
virtual ~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
{
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
protected:
/** \brief The last time at which this monitor object was updated. */
@ -657,34 +669,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.
*
@ -717,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.

55
apt-pkg/algorithms.cc

@ -20,12 +20,15 @@
#include <apt-pkg/version.h>
#include <apt-pkg/sptr.h>
#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>
/*}}}*/
using namespace std;
@ -327,6 +330,12 @@ bool pkgFixBroken(pkgDepCache &Cache)
*/
bool pkgDistUpgrade(pkgDepCache &Cache)
{
std::string const solver = _config->Find("APT::Solver", "internal");
if (solver != "internal") {
OpTextProgress Prog(*_config);
return EDSP::ResolveExternal(solver.c_str(), Cache, false, true, false, &Prog);
}
pkgDepCache::ActionGroup group(Cache);
/* Upgrade all installed packages first without autoinst to help the resolver
@ -379,6 +388,12 @@ bool pkgDistUpgrade(pkgDepCache &Cache)
to install packages not marked for install */
bool pkgAllUpgrade(pkgDepCache &Cache)
{
std::string const solver = _config->Find("APT::Solver", "internal");
if (solver != "internal") {
OpTextProgress Prog(*_config);
return EDSP::ResolveExternal(solver.c_str(), Cache, true, false, false, &Prog);
}
pkgDepCache::ActionGroup group(Cache);
pkgProblemResolver Fix(&Cache);
@ -725,7 +740,20 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
return true;
}
/*}}}*/
// ProblemResolver::Resolve - Run the resolution pass /*{{{*/
// ProblemResolver::Resolve - calls a resolver to fix the situation /*{{{*/
// ---------------------------------------------------------------------
/* */
bool pkgProblemResolver::Resolve(bool BrokenFix)
{
std::string const solver = _config->Find("APT::Solver", "internal");
if (solver != "internal") {
OpTextProgress Prog(*_config);
return EDSP::ResolveExternal(solver.c_str(), Cache, false, false, false, &Prog);
}
return ResolveInternal(BrokenFix);
}
/*}}}*/
// ProblemResolver::ResolveInternal - Run the resolution pass /*{{{*/
// ---------------------------------------------------------------------
/* This routines works by calculating a score for each package. The score
is derived by considering the package's priority and all reverse
@ -739,12 +767,10 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
The BrokenFix flag enables a mode where the algorithm tries to
upgrade packages to advoid problems. */
bool pkgProblemResolver::Resolve(bool BrokenFix)
bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
{
pkgDepCache::ActionGroup group(Cache);
unsigned long Size = Cache.Head().PackageCount;
// Record which packages are marked for install
bool Again = false;
do
@ -774,7 +800,9 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
clog << "Starting" << endl;
MakeScores();
unsigned long const Size = Cache.Head().PackageCount;
/* We have to order the packages so that the broken fixing pass
operates from highest score to lowest. This prevents problems when
high score packages cause the removal of lower score packages that
@ -1207,6 +1235,21 @@ bool pkgProblemResolver::InstOrNewPolicyBroken(pkgCache::PkgIterator I)
in that it does not install or remove any packages. It is assumed that the
system was non-broken previously. */
bool pkgProblemResolver::ResolveByKeep()
{
std::string const solver = _config->Find("APT::Solver", "internal");
if (solver != "internal") {
OpTextProgress Prog(*_config);
return EDSP::ResolveExternal(solver.c_str(), Cache, true, false, false, &Prog);
}
return ResolveByKeepInternal();
}
/*}}}*/
// ProblemResolver::ResolveByKeepInternal - Resolve problems using keep /*{{{*/
// ---------------------------------------------------------------------
/* This is the work horse of the soft upgrade routine. It is very gental
in that it does not install or remove any packages. It is assumed that the
system was non-broken previously. */
bool pkgProblemResolver::ResolveByKeepInternal()
{
pkgDepCache::ActionGroup group(Cache);

6
apt-pkg/algorithms.h

@ -78,6 +78,9 @@ private:
/*}}}*/
class pkgProblemResolver /*{{{*/
{
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
pkgDepCache &Cache;
typedef pkgCache::PkgIterator PkgIterator;
typedef pkgCache::VerIterator VerIterator;
@ -105,6 +108,9 @@ class pkgProblemResolver /*{{{*/
void MakeScores();
bool DoUpgrade(pkgCache::PkgIterator Pkg);
bool ResolveInternal(bool const BrokenFix = false);
bool ResolveByKeepInternal();
protected:
bool InstOrNewPolicyBroken(pkgCache::PkgIterator Pkg);

3
apt-pkg/cachefile.h

@ -25,6 +25,9 @@
class pkgCacheFile
{
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
protected:
MMap *Map;

2
apt-pkg/cachefilter.h

@ -16,6 +16,8 @@ namespace APT {
namespace CacheFilter {
// PackageNameMatchesRegEx /*{{{*/
class PackageNameMatchesRegEx {
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
regex_t* pattern;
public:
PackageNameMatchesRegEx(std::string const &Pattern);

8
apt-pkg/cacheiterators.h

@ -206,15 +206,10 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
inline const char *VerStr() const {return S->VerStr == 0?0:Owner->StrP + S->VerStr;};
inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;};
inline const char *Arch() const {
if (S->MultiArch == pkgCache::Version::All ||
S->MultiArch == pkgCache::Version::AllForeign ||
S->MultiArch == pkgCache::Version::AllAllowed)
if (S->MultiArch == pkgCache::Version::All)
return "all";
return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch;
};
__deprecated inline const char *Arch(bool const pseudo) const {
return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch;
};
inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);};
inline DescIterator DescriptionList() const;
@ -227,7 +222,6 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
string RelStr() const;
bool Automatic() const;
__deprecated bool Pseudo() const;
VerFileIterator NewestFile() const;
inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Iterator<Version, VerIterator>(Owner, Trg) {

2
apt-pkg/cacheset.h

@ -257,7 +257,6 @@ public: /*{{{*/
inline const char *VerStr() const { return (**this).VerStr(); };
inline const char *Section() const { return (**this).Section(); };
inline const char *Arch() const { return (**this).Arch(); };
__deprecated inline const char *Arch(bool const pseudo) const { return (**this).Arch(); };
inline pkgCache::PkgIterator ParentPkg() const { return (**this).ParentPkg(); };
inline pkgCache::DescIterator DescriptionList() const { return (**this).DescriptionList(); };
inline pkgCache::DescIterator TranslatedDescription() const { return (**this).TranslatedDescription(); };
@ -268,7 +267,6 @@ public: /*{{{*/
inline const char *PriorityType() const { return (**this).PriorityType(); };
inline string RelStr() const { return (**this).RelStr(); };
inline bool Automatic() const { return (**this).Automatic(); };
__deprecated inline bool Pseudo() const { return false; };
inline pkgCache::VerFileIterator NewestFile() const { return (**this).NewestFile(); };
};
/*}}}*/

10
apt-pkg/cdrom.cc

@ -874,9 +874,7 @@ pkgUdevCdromDevices::Dlopen() /*{{{*/
libudev_handle = h;
udev_new = (udev* (*)(void)) dlsym(h, "udev_new");
udev_enumerate_add_match_property = (int (*)(udev_enumerate*, const char*, const char*))dlsym(h, "udev_enumerate_add_match_property");
#if 0 // FIXME: uncomment on next ABI break
udev_enumerate_add_match_sysattr = (int (*)(udev_enumerate*, const char*, const char*))dlsym(h, "udev_enumerate_add_match_sysattr");
#endif
udev_enumerate_scan_devices = (int (*)(udev_enumerate*))dlsym(h, "udev_enumerate_scan_devices");
udev_enumerate_get_list_entry = (udev_list_entry* (*)(udev_enumerate*))dlsym(h, "udev_enumerate_get_list_entry");
udev_device_new_from_syspath = (udev_device* (*)(udev*, const char*))dlsym(h, "udev_device_new_from_syspath");
@ -890,10 +888,8 @@ pkgUdevCdromDevices::Dlopen() /*{{{*/
return true;
}
/*}}}*/
/*{{{*/
// compatiblity only with the old API/ABI, can be removed on the next
// ABI break
// convenience interface, this will just call ScanForRemovable
vector<CdromDevice>
pkgUdevCdromDevices::Scan()
{
@ -918,10 +914,6 @@ pkgUdevCdromDevices::ScanForRemovable(bool CdromOnly)
if (CdromOnly)
udev_enumerate_add_match_property(enumerate, "ID_CDROM", "1");
else {
#if 1 // FIXME: remove the next two lines on the next ABI break
int (*udev_enumerate_add_match_sysattr)(struct udev_enumerate *udev_enumerate, const char *property, const char *value);
udev_enumerate_add_match_sysattr = (int (*)(udev_enumerate*, const char*, const char*))dlsym(libudev_handle, "udev_enumerate_add_match_sysattr");
#endif
udev_enumerate_add_match_sysattr(enumerate, "removable", "1");
}

8
apt-pkg/cdrom.h

@ -92,9 +92,7 @@ class pkgUdevCdromDevices /*{{{*/
struct udev_enumerate *(*udev_enumerate_new) (struct udev *udev);
struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *list_entry);
const char* (*udev_device_get_property_value)(struct udev_device *udev_device, const char *key);
#if 0 // FIXME: uncomment on next ABI break
int (*udev_enumerate_add_match_sysattr)(struct udev_enumerate *udev_enumerate, const char *property, const char *value);
#endif
// end libudev dlopen
public:
@ -104,11 +102,11 @@ class pkgUdevCdromDevices /*{{{*/
// try to open
bool Dlopen();
// this is the new interface
vector<CdromDevice> ScanForRemovable(bool CdromOnly);
// FIXME: compat with the old interface/API/ABI only
// convenience interface, this will just call ScanForRemovable
// with "APT::cdrom::CdromOnly"
vector<CdromDevice> Scan();
vector<CdromDevice> ScanForRemovable(bool CdromOnly);
};
/*}}}*/

3
apt-pkg/clean.h

@ -15,6 +15,9 @@
class pkgArchiveCleaner
{
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
protected:
virtual void Erase(const char * /*File*/,string /*Pkg*/,string /*Ver*/,struct stat & /*St*/) {};

41
apt-pkg/contrib/hashes.cc

@ -23,7 +23,7 @@
const char* HashString::_SupportedHashes[] =
{
"SHA256", "SHA1", "MD5Sum", NULL
"SHA512", "SHA256", "SHA1", "MD5Sum", NULL
};
HashString::HashString()
@ -53,28 +53,33 @@ HashString::HashString(string StringedHash) /*{{{*/
/*}}}*/
bool HashString::VerifyFile(string filename) const /*{{{*/
{
FileFd fd;
MD5Summation MD5;
SHA1Summation SHA1;
SHA256Summation SHA256;
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")
{
SHA512Summation SHA512;
SHA512.AddFD(Fd.Fd(), Fd.Size());
fileHash = (string)SHA512.Result();
}
Fd.Close();
if(_config->FindB("Debug::Hashes",false) == true)
@ -101,7 +106,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;
@ -112,13 +118,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);
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;
}

10
apt-pkg/contrib/hashes.h

@ -16,7 +16,7 @@
#include <apt-pkg/md5.h>
#include <apt-pkg/sha1.h>
#include <apt-pkg/sha256.h>
#include <apt-pkg/sha2.h>
#include <algorithm>
#include <vector>
@ -60,13 +60,17 @@ class Hashes
MD5Summation MD5;
SHA1Summation SHA1;
SHA256Summation SHA256;
SHA512Summation SHA512;
inline bool Add(const unsigned char *Data,unsigned long Size)
{
return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,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));};
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);};
};

27
apt-pkg/contrib/hashsum.cc

@ -0,0 +1,27 @@
// Cryptographic API Base
#include <unistd.h>
#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);
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;
}
/*}}}*/

107
apt-pkg/contrib/hashsum_template.h

<
@ -0,0 +1,107 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// $Id: hashsum_template.h,v 1.3 2001/05/07 05:05:47 jgg Exp $
/* ######################################################################
HashSumValueTemplate - Generic Storage for a hash value
##################################################################### */
/*}}}*/
#ifndef APTPKG_HASHSUM_TEMPLATE_H
#define APTPKG_HASHSUM_TEMPLATE_H
#include <string>
#include <cstring>
#include <algorithm>
#include <stdint.h>
using std::string;
using std::min;
template<int N>
class HashSumValue
{
unsigned char Sum[N/8];
public:
// Accessors
bool operator ==(const HashSumValue &rhs) const
{
return memcmp(Sum,rhs.Sum,sizeof(Sum)) == 0;
};
string Value() const
{
char Conv[16] =
{ '0','1','2','3','4','5','6','7','8','9','a','b',
'c','d','e','f'
};
char Result[((N/8)*2)+1];
Result[(N/8)*2] = 0;
// Convert each char into two letters
int J = 0;
int I = 0;
for (; I != (N/8)*2; J++,I += 2)
{
Result[I] = Conv[Sum[J] >> 4];
Result[I + 1] = Conv[Sum[J] & 0xF];
}
return string(Result);
};
inline void Value(unsigned char S[N/8])
{
for (int I = 0; I != sizeof(Sum); I++)
S[I] = Sum[I];
};
inline operator string() const
{
return Value();
};
bool Set(string Str)
{
return Hex2Num(Str,Sum,sizeof(Sum));
};
inline void Set(unsigned char S[N/8])
{
for (int I = 0; I != sizeof(Sum); I++)
Sum[I] = S[I];
};
HashSumValue(string Str)
{
memset(Sum,0,sizeof(Sum));
Set(Str);
}
HashSumValue()
{
memset(Sum,0,sizeof(Sum));
}
};
class SummationImplementation
{
public:
virtual bool Add(const unsigned char *inbuf, unsigned long inlen) = 0;