summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc51
-rw-r--r--apt-pkg/acquire-item.h19
-rw-r--r--apt-pkg/acquire-method.cc12
-rw-r--r--apt-pkg/acquire-method.h5
-rw-r--r--apt-pkg/acquire-worker.cc7
-rw-r--r--apt-pkg/acquire-worker.h7
-rw-r--r--apt-pkg/acquire.cc14
-rw-r--r--apt-pkg/acquire.h15
-rw-r--r--apt-pkg/algorithms.cc69
-rw-r--r--apt-pkg/algorithms.h7
-rw-r--r--apt-pkg/aptconfiguration.cc119
-rw-r--r--apt-pkg/aptconfiguration.h9
-rw-r--r--apt-pkg/cachefile.cc13
-rw-r--r--apt-pkg/cachefile.h9
-rw-r--r--apt-pkg/cachefilter.cc4
-rw-r--r--apt-pkg/cachefilter.h3
-rw-r--r--apt-pkg/cacheiterators.h267
-rw-r--r--apt-pkg/cacheset.cc46
-rw-r--r--apt-pkg/cacheset.h190
-rw-r--r--apt-pkg/cdrom.cc81
-rw-r--r--apt-pkg/cdrom.h8
-rw-r--r--apt-pkg/clean.cc4
-rw-r--r--apt-pkg/clean.h7
-rw-r--r--apt-pkg/contrib/cdromutl.cc90
-rw-r--r--apt-pkg/contrib/cmndline.cc5
-rw-r--r--apt-pkg/contrib/cmndline.h8
-rw-r--r--apt-pkg/contrib/configuration.cc28
-rw-r--r--apt-pkg/contrib/configuration.h16
-rw-r--r--apt-pkg/contrib/crc-16.h4
-rw-r--r--apt-pkg/contrib/error.cc6
-rw-r--r--apt-pkg/contrib/error.h37
-rw-r--r--apt-pkg/contrib/fileutl.cc524
-rw-r--r--apt-pkg/contrib/fileutl.h30
-rw-r--r--apt-pkg/contrib/gpgv.cc18
-rw-r--r--apt-pkg/contrib/gpgv.h18
-rw-r--r--apt-pkg/contrib/hashes.cc8
-rw-r--r--apt-pkg/contrib/hashes.h17
-rw-r--r--apt-pkg/contrib/hashsum.cc3
-rw-r--r--apt-pkg/contrib/hashsum_template.h52
-rw-r--r--apt-pkg/contrib/macros.h88
-rw-r--r--apt-pkg/contrib/md5.cc6
-rw-r--r--apt-pkg/contrib/md5.h9
-rw-r--r--apt-pkg/contrib/mmap.cc6
-rw-r--r--apt-pkg/contrib/netrc.cc5
-rw-r--r--apt-pkg/contrib/netrc.h6
-rw-r--r--apt-pkg/contrib/progress.cc14
-rw-r--r--apt-pkg/contrib/sha1.cc5
-rw-r--r--apt-pkg/contrib/sha1.h7
-rw-r--r--apt-pkg/contrib/sha2.h10
-rw-r--r--apt-pkg/contrib/sha2_internal.cc1
-rw-r--r--apt-pkg/contrib/sha2_internal.h1
-rw-r--r--apt-pkg/contrib/strutl.cc17
-rw-r--r--apt-pkg/contrib/strutl.h75
-rw-r--r--apt-pkg/deb/debindexfile.cc16
-rw-r--r--apt-pkg/deb/debindexfile.h20
-rw-r--r--apt-pkg/deb/deblistparser.cc176
-rw-r--r--apt-pkg/deb/deblistparser.h31
-rw-r--r--apt-pkg/deb/debmetaindex.cc11
-rw-r--r--apt-pkg/deb/debmetaindex.h8
-rw-r--r--apt-pkg/deb/debrecords.cc8
-rw-r--r--apt-pkg/deb/debrecords.h3
-rw-r--r--apt-pkg/deb/debsrcrecords.cc15
-rw-r--r--apt-pkg/deb/debsrcrecords.h7
-rw-r--r--apt-pkg/deb/debsystem.cc11
-rw-r--r--apt-pkg/deb/debsystem.h10
-rw-r--r--apt-pkg/deb/debversion.cc2
-rw-r--r--apt-pkg/deb/debversion.h20
-rw-r--r--apt-pkg/deb/dpkgpm.cc82
-rw-r--r--apt-pkg/deb/dpkgpm.h17
-rw-r--r--apt-pkg/depcache.cc120
-rw-r--r--apt-pkg/depcache.h25
-rw-r--r--apt-pkg/edsp.cc27
-rw-r--r--apt-pkg/edsp.h18
-rw-r--r--apt-pkg/edsp/edspindexfile.cc19
-rw-r--r--apt-pkg/edsp/edspindexfile.h6
-rw-r--r--apt-pkg/edsp/edsplistparser.cc14
-rw-r--r--apt-pkg/edsp/edsplistparser.h4
-rw-r--r--apt-pkg/edsp/edspsystem.cc21
-rw-r--r--apt-pkg/edsp/edspsystem.h17
-rw-r--r--apt-pkg/indexcopy.cc38
-rw-r--r--apt-pkg/indexcopy.h10
-rw-r--r--apt-pkg/indexfile.cc16
-rw-r--r--apt-pkg/indexfile.h21
-rw-r--r--apt-pkg/indexrecords.cc25
-rw-r--r--apt-pkg/indexrecords.h6
-rw-r--r--apt-pkg/init.cc4
-rw-r--r--apt-pkg/init.h13
-rw-r--r--apt-pkg/install-progress.cc109
-rw-r--r--apt-pkg/install-progress.h55
-rw-r--r--apt-pkg/makefile3
-rw-r--r--apt-pkg/metaindex.h15
-rw-r--r--apt-pkg/orderlist.cc6
-rw-r--r--apt-pkg/orderlist.h14
-rw-r--r--apt-pkg/packagemanager.cc11
-rw-r--r--apt-pkg/packagemanager.h18
-rw-r--r--apt-pkg/pkgcache.cc33
-rw-r--r--apt-pkg/pkgcache.h68
-rw-r--r--apt-pkg/pkgcachegen.cc54
-rw-r--r--apt-pkg/pkgcachegen.h43
-rw-r--r--apt-pkg/pkgrecords.cc6
-rw-r--r--apt-pkg/pkgrecords.h5
-rw-r--r--apt-pkg/pkgsystem.cc5
-rw-r--r--apt-pkg/pkgsystem.h2
-rw-r--r--apt-pkg/policy.cc16
-rw-r--r--apt-pkg/policy.h5
-rw-r--r--apt-pkg/sourcelist.cc11
-rw-r--r--apt-pkg/sourcelist.h15
-rw-r--r--apt-pkg/srcrecords.cc7
-rw-r--r--apt-pkg/srcrecords.h3
-rw-r--r--apt-pkg/tagfile.cc6
-rw-r--r--apt-pkg/tagfile.h10
-rw-r--r--apt-pkg/update.cc23
-rw-r--r--apt-pkg/upgrade.cc19
-rw-r--r--apt-pkg/upgrade.h4
-rw-r--r--apt-pkg/vendor.cc10
-rw-r--r--apt-pkg/vendor.h2
-rw-r--r--apt-pkg/vendorlist.cc9
-rw-r--r--apt-pkg/vendorlist.h2
-rw-r--r--apt-pkg/version.cc2
-rw-r--r--apt-pkg/version.h2
-rw-r--r--apt-pkg/versionmatch.cc7
-rw-r--r--apt-pkg/versionmatch.h17
122 files changed, 2255 insertions, 1283 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 4041d9457..30743addf 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -22,12 +22,21 @@
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/md5.h>
#include <apt-pkg/sha1.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/indexrecords.h>
-#include <apt-pkg/metaindex.h>
-
+#include <apt-pkg/acquire.h>
+#include <apt-pkg/hashes.h>
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgrecords.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <iostream>
+#include <vector>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
@@ -108,8 +117,8 @@ void pkgAcquire::Item::Start(string /*Message*/,unsigned long long Size)
// Acquire::Item::Done - Item downloaded OK /*{{{*/
// ---------------------------------------------------------------------
/* */
-void pkgAcquire::Item::Done(string Message,unsigned long long Size,string Hash,
- pkgAcquire::MethodConfig *Cnf)
+void pkgAcquire::Item::Done(string Message,unsigned long long Size,string /*Hash*/,
+ pkgAcquire::MethodConfig * /*Cnf*/)
{
// We just downloaded something..
string FileName = LookupTag(Message,"Filename");
@@ -253,10 +262,10 @@ string pkgAcqSubIndex::Custom600Headers()
return "\nIndex-File: true\nFail-Ignore: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
}
/*}}}*/
-void pkgAcqSubIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{*/
+void pkgAcqSubIndex::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)/*{{{*/
{
if(Debug)
- std::clog << "pkgAcqSubIndex failed: " << Desc.URI << std::endl;
+ std::clog << "pkgAcqSubIndex failed: " << Desc.URI << " with " << Message << std::endl;
Complete = false;
Status = StatDone;
@@ -544,10 +553,10 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile) /*{{{*/
return false;
}
/*}}}*/
-void pkgAcqDiffIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{*/
+void pkgAcqDiffIndex::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)/*{{{*/
{
if(Debug)
- std::clog << "pkgAcqDiffIndex failed: " << Desc.URI << std::endl
+ std::clog << "pkgAcqDiffIndex failed: " << Desc.URI << " with " << Message << std::endl
<< "Falling back to normal index file acquire" << std::endl;
new pkgAcqIndex(Owner, RealURI, Description, Desc.ShortDesc,
@@ -624,10 +633,10 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
}
}
/*}}}*/
-void pkgAcqIndexDiffs::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{*/
+void pkgAcqIndexDiffs::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)/*{{{*/
{
if(Debug)
- std::clog << "pkgAcqIndexDiffs failed: " << Desc.URI << std::endl
+ std::clog << "pkgAcqIndexDiffs failed: " << Desc.URI << " with " << Message << std::endl
<< "Falling back to normal index file acquire" << std::endl;
new pkgAcqIndex(Owner, RealURI, Description,Desc.ShortDesc,
ExpectedHash);
@@ -709,7 +718,7 @@ bool pkgAcqIndexDiffs::QueueNextDiff() /*{{{*/
}
// queue the right diff
- Desc.URI = string(RealURI) + ".diff/" + available_patches[0].file + ".gz";
+ Desc.URI = RealURI + ".diff/" + available_patches[0].file + ".gz";
Desc.Description = Description + " " + available_patches[0].file + string(".pdiff");
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
DestFile += URItoFileName(RealURI + ".diff/" + available_patches[0].file);
@@ -797,7 +806,7 @@ pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire *Owner,
Desc.Owner = this;
Desc.ShortDesc = ShortDesc;
- Desc.URI = string(RealURI) + ".diff/" + patch.file + ".gz";
+ Desc.URI = RealURI + ".diff/" + patch.file + ".gz";
Desc.Description = Description + " " + patch.file + string(".pdiff");
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
DestFile += URItoFileName(RealURI + ".diff/" + patch.file);
@@ -808,7 +817,7 @@ pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire *Owner,
QueueURI(Desc);
}
/*}}}*/
-void pkgAcqIndexMergeDiffs::Failed(string Message,pkgAcquire::MethodConfig *Cnf)/*{{{*/
+void pkgAcqIndexMergeDiffs::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)/*{{{*/
{
if(Debug)
std::clog << "pkgAcqIndexMergeDiffs failed: " << Desc.URI << " with " << Message << std::endl;
@@ -1558,7 +1567,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/
{
std::vector<std::string> types = APT::Configuration::getCompressionTypes();
for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
- if (MetaIndexParser->Exists(string((*Target)->MetaKey).append(".").append(*t)) == true)
+ if (MetaIndexParser->Exists((*Target)->MetaKey + "." + *t) == true)
{
compressedAvailable = true;
break;
@@ -1596,7 +1605,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/
else if (transInRelease == false || Record != NULL || compressedAvailable == true)
{
if (_config->FindB("Acquire::PDiffs",true) == true && transInRelease == true &&
- MetaIndexParser->Exists(string((*Target)->MetaKey).append(".diff/Index")) == true)
+ MetaIndexParser->Exists((*Target)->MetaKey + ".diff/Index") == true)
new pkgAcqDiffIndex(Owner, (*Target)->URI, (*Target)->Description,
(*Target)->ShortDesc, ExpectedIndexHash);
else
@@ -1610,7 +1619,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/
in the Meta-Index file. Ideal would be if pkgAcqDiffIndex would test this
instead, but passing the required info to it is to much hassle */
if(_config->FindB("Acquire::PDiffs",true) == true && (verify == false ||
- MetaIndexParser->Exists(string((*Target)->MetaKey).append(".diff/Index")) == true))
+ MetaIndexParser->Exists((*Target)->MetaKey + ".diff/Index") == true))
new pkgAcqDiffIndex(Owner, (*Target)->URI, (*Target)->Description,
(*Target)->ShortDesc, ExpectedIndexHash);
else
@@ -1635,7 +1644,7 @@ bool pkgAcqMetaIndex::VerifyVendor(string Message) /*{{{*/
missingkeys += (Fingerprint);
}
if(!missingkeys.empty())
- _error->Warning("%s", string(msg+missingkeys).c_str());
+ _error->Warning("%s", (msg + missingkeys).c_str());
string Transformed = MetaIndexParser->GetExpectedDist();
@@ -1698,7 +1707,7 @@ bool pkgAcqMetaIndex::VerifyVendor(string Message) /*{{{*/
// pkgAcqMetaIndex::Failed - no Release file present or no signature file present /*{{{*/
// ---------------------------------------------------------------------
/* */
-void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
+void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)
{
if (AuthPass == true)
{
@@ -2149,7 +2158,7 @@ void pkgAcqArchive::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
/*}}}*/
// AcqArchive::IsTrusted - Determine whether this archive comes from a trusted source /*{{{*/
// ---------------------------------------------------------------------
-bool pkgAcqArchive::IsTrusted()
+APT_PURE bool pkgAcqArchive::IsTrusted()
{
return Trusted;
}
@@ -2197,7 +2206,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 long long)Buf.st_size > Size)
+ if ((Size > 0) && (unsigned long long)Buf.st_size > Size)
unlink(DestFile.c_str());
else
PartialSize = Buf.st_size;
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index 5a1c7979c..f48d2a0d7 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -24,6 +24,10 @@
#include <apt-pkg/hashes.h>
#include <apt-pkg/weakptr.h>
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <string>
+#include <vector>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/indexfile.h>
@@ -64,7 +68,7 @@ class pkgAcquire::Item : public WeakPointable
/** \brief Insert this item into its owner's queue.
*
- * \param ItemDesc Metadata about this item (its URI and
+ * \param Item Metadata about this item (its URI and
* description).
*/
inline void QueueURI(ItemDesc &Item)
@@ -79,7 +83,7 @@ class pkgAcquire::Item : public WeakPointable
*
* \param From The file to be renamed.
*
- * \param To The new name of #From. If #To exists it will be
+ * \param To The new name of \a From. If \a To exists it will be
* overwritten.
*/
void Rename(std::string From,std::string To);
@@ -115,7 +119,7 @@ class pkgAcquire::Item : public WeakPointable
} Status;
/** \brief Contains a textual description of the error encountered
- * if #Status is #StatError or #StatAuthError.
+ * if #ItemState is #StatError or #StatAuthError.
*/
std::string ErrorText;
@@ -293,7 +297,6 @@ class pkgAcquire::Item : public WeakPointable
/** \brief Rename failed file and set error
*
* \param state respresenting the error we encountered
- * \param errorMsg a message describing the error
*/
bool RenameOnError(RenameOnErrorState const state);
};
@@ -636,7 +639,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
/** \brief Create an index diff item.
*
* After filling in its basic fields, this invokes Finish(true) if
- * #diffs is empty, or QueueNextDiff() otherwise.
+ * \a diffs is empty, or QueueNextDiff() otherwise.
*
* \param Owner The pkgAcquire object that owns this item.
*
@@ -651,6 +654,8 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
* reconstructed package index file; the index file will be tested
* against this value when it is entirely reconstructed.
*
+ * \param ServerSha1 is the sha1sum of the current file on the server
+ *
* \param diffs The remaining diffs from the index of diffs. They
* should be ordered so that each diff appears before any diff
* that depends on it.
@@ -1162,8 +1167,8 @@ class pkgAcqFile : public pkgAcquire::Item
* \param IsIndexFile The file is considered a IndexFile and cache-control
* headers like "cache-control: max-age=0" are send
*
- * If DestFilename is empty, download to DestDir/<basename> if
- * DestDir is non-empty, $CWD/<basename> otherwise. If
+ * If DestFilename is empty, download to DestDir/\<basename\> if
+ * DestDir is non-empty, $CWD/\<basename\> otherwise. If
* DestFilename is NOT empty, DestDir is ignored and DestFilename
* is the absolute name to which the file should be downloaded.
*/
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index 5bc1c159a..746c553f1 100644
--- a/apt-pkg/acquire-method.cc
+++ b/apt-pkg/acquire-method.cc
@@ -23,10 +23,18 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/hashes.h>
-
+#include <apt-pkg/md5.h>
+#include <apt-pkg/sha1.h>
+#include <apt-pkg/sha2.h>
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <string>
+#include <vector>
#include <iostream>
#include <stdio.h>
-#include <sys/signal.h>
/*}}}*/
using namespace std;
diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h
index 00f99e0a0..221ccf273 100644
--- a/apt-pkg/acquire-method.h
+++ b/apt-pkg/acquire-method.h
@@ -20,7 +20,10 @@
#ifndef PKGLIB_ACQUIRE_METHOD_H
#define PKGLIB_ACQUIRE_METHOD_H
+#include <apt-pkg/macros.h>
+
#include <stdarg.h>
+#include <time.h>
#include <string>
#include <vector>
@@ -106,7 +109,7 @@ class pkgAcqMethod
virtual ~pkgAcqMethod() {};
private:
- void Dequeue();
+ APT_HIDDEN void Dequeue();
};
/** @} */
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index de62080da..047a655ce 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -14,20 +14,23 @@
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/acquire.h>
#include <apt-pkg/acquire-worker.h>
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/strutl.h>
+#include <apt-pkg/hashes.h>
+#include <string>
+#include <vector>
#include <iostream>
#include <sstream>
-#include <fstream>
#include <sys/stat.h>
+#include <stdlib.h>
#include <unistd.h>
-#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <errno.h>
diff --git a/apt-pkg/acquire-worker.h b/apt-pkg/acquire-worker.h
index 848a6bad7..67aee4b59 100644
--- a/apt-pkg/acquire-worker.h
+++ b/apt-pkg/acquire-worker.h
@@ -22,6 +22,9 @@
#include <apt-pkg/acquire.h>
#include <apt-pkg/weakptr.h>
+#include <sys/types.h>
+#include <string>
+#include <vector>
/** \brief A fetch subprocess.
*
@@ -136,8 +139,8 @@ class pkgAcquire::Worker : public WeakPointable
/** \brief Retrieve any available messages from the subprocess.
*
- * The messages are retrieved as in ::ReadMessages(), and
- * MessageFailure() is invoked if an error occurs; in particular,
+ * The messages are retrieved as in \link strutl.h ReadMessages()\endlink, and
+ * #MethodFailure() is invoked if an error occurs; in particular,
* if the pipe to the subprocess dies unexpectedly while a message
* is being read.
*
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 120e809e1..a187a00ae 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -23,12 +23,18 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
+#include <string>
+#include <vector>
#include <iostream>
#include <sstream>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#include <dirent.h>
#include <sys/time.h>
+#include <sys/select.h>
#include <errno.h>
#include <apti18n.h>
@@ -468,7 +474,7 @@ void pkgAcquire::Bump()
pkgAcquire::Worker *pkgAcquire::WorkerStep(Worker *I)
{
return I->NextAcquire;
-};
+}
/*}}}*/
// Acquire::Clean - Cleans a directory /*{{{*/
// ---------------------------------------------------------------------
@@ -520,7 +526,7 @@ bool pkgAcquire::Clean(string Dir)
// Acquire::TotalNeeded - Number of bytes to fetch /*{{{*/
// ---------------------------------------------------------------------
/* This is the total number of bytes needed */
-unsigned long long pkgAcquire::TotalNeeded()
+APT_PURE unsigned long long pkgAcquire::TotalNeeded()
{
unsigned long long Total = 0;
for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)
@@ -531,7 +537,7 @@ unsigned long long pkgAcquire::TotalNeeded()
// Acquire::FetchNeeded - Number of bytes needed to get /*{{{*/
// ---------------------------------------------------------------------
/* This is the number of bytes that is not local */
-unsigned long long pkgAcquire::FetchNeeded()
+APT_PURE unsigned long long pkgAcquire::FetchNeeded()
{
unsigned long long Total = 0;
for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)
@@ -543,7 +549,7 @@ unsigned long long pkgAcquire::FetchNeeded()
// Acquire::PartialPresent - Number of partial bytes we already have /*{{{*/
// ---------------------------------------------------------------------
/* This is the number of bytes that is not local */
-unsigned long long pkgAcquire::PartialPresent()
+APT_PURE unsigned long long pkgAcquire::PartialPresent()
{
unsigned long long Total = 0;
for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I)
diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h
index 3d5d7a4b7..ef16d8556 100644
--- a/apt-pkg/acquire.h
+++ b/apt-pkg/acquire.h
@@ -72,8 +72,13 @@
#include <vector>
#include <string>
+#include <stddef.h>
#include <sys/time.h>
+#include <sys/select.h>
+
+#ifndef APT_10_CLEANER_HEADERS
#include <unistd.h>
+#endif
#ifndef APT_8_CLEANER_HEADERS
using std::vector;
@@ -282,18 +287,18 @@ class pkgAcquire
*/
void Shutdown();
- /** \brief Get the first #Worker object.
+ /** \brief Get the first Worker object.
*
* \return the first active worker in this download process.
*/
inline Worker *WorkersBegin() {return Workers;};
- /** \brief Advance to the next #Worker object.
+ /** \brief Advance to the next Worker object.
*
* \return the worker immediately following I, or \b NULL if none
* exists.
*/
- Worker *WorkerStep(Worker *I);
+ Worker *WorkerStep(Worker *I) APT_PURE;
/** \brief Get the head of the list of items. */
inline ItemIterator ItemsBegin() {return Items.begin();};
@@ -353,7 +358,7 @@ class pkgAcquire
void SetLog(pkgAcquireStatus *Progress) { Log = Progress; }
/** \brief Construct a new pkgAcquire. */
- pkgAcquire(pkgAcquireStatus *Log) __deprecated;
+ pkgAcquire(pkgAcquireStatus *Log) APT_DEPRECATED;
pkgAcquire();
/** \brief Destroy this pkgAcquire object.
@@ -476,7 +481,7 @@ class pkgAcquire::Queue
* \return the first item in the queue whose URI is #URI and that
* is being downloaded by #Owner.
*/
- QItem *FindItem(std::string URI,pkgAcquire::Worker *Owner);
+ QItem *FindItem(std::string URI,pkgAcquire::Worker *Owner) APT_PURE;
/** Presumably this should start downloading an item?
*
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 0363ab3e2..a7b676660 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -19,19 +19,18 @@
#include <apt-pkg/algorithms.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/version.h>
#include <apt-pkg/sptr.h>
-#include <apt-pkg/acquire-item.h>
#include <apt-pkg/edsp.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/fileutl.h>
#include <apt-pkg/progress.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/packagemanager.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
-#include <sys/types.h>
+#include <string.h>
+#include <string>
#include <cstdlib>
-#include <algorithm>
#include <iostream>
-#include <stdio.h>
#include <apti18n.h>
/*}}}*/
@@ -394,8 +393,18 @@ void pkgProblemResolver::MakeScores()
};
int PrioEssentials = _config->FindI("pkgProblemResolver::Scores::Essentials",100);
int PrioInstalledAndNotObsolete = _config->FindI("pkgProblemResolver::Scores::NotObsolete",1);
- int PrioDepends = _config->FindI("pkgProblemResolver::Scores::Depends",1);
- int PrioRecommends = _config->FindI("pkgProblemResolver::Scores::Recommends",1);
+ int DepMap[] = {
+ 0,
+ _config->FindI("pkgProblemResolver::Scores::Depends",1),
+ _config->FindI("pkgProblemResolver::Scores::PreDepends",1),
+ _config->FindI("pkgProblemResolver::Scores::Suggests",0),
+ _config->FindI("pkgProblemResolver::Scores::Recommends",1),
+ _config->FindI("pkgProblemResolver::Scores::Conflicts",-1),
+ _config->FindI("pkgProblemResolver::Scores::Replaces",0),
+ _config->FindI("pkgProblemResolver::Scores::Obsoletes",0),
+ _config->FindI("pkgProblemResolver::Scores::Breaks",-1),
+ _config->FindI("pkgProblemResolver::Scores::Enhances",0)
+ };
int AddProtected = _config->FindI("pkgProblemResolver::Scores::AddProtected",10000);
int AddEssential = _config->FindI("pkgProblemResolver::Scores::AddEssential",5000);
@@ -408,8 +417,15 @@ void pkgProblemResolver::MakeScores()
<< " Extra => " << PrioMap[pkgCache::State::Extra] << endl
<< " Essentials => " << PrioEssentials << endl
<< " InstalledAndNotObsolete => " << PrioInstalledAndNotObsolete << endl
- << " Depends => " << PrioDepends << endl
- << " Recommends => " << PrioRecommends << endl
+ << " Pre-Depends => " << DepMap[pkgCache::Dep::PreDepends] << endl
+ << " Depends => " << DepMap[pkgCache::Dep::Depends] << endl
+ << " Recommends => " << DepMap[pkgCache::Dep::Recommends] << endl
+ << " Suggests => " << DepMap[pkgCache::Dep::Suggests] << endl
+ << " Conflicts => " << DepMap[pkgCache::Dep::Conflicts] << endl
+ << " Breaks => " << DepMap[pkgCache::Dep::DpkgBreaks] << endl
+ << " Replaces => " << DepMap[pkgCache::Dep::Replaces] << endl
+ << " Obsoletes => " << DepMap[pkgCache::Dep::Obsoletes] << endl
+ << " Enhances => " << DepMap[pkgCache::Dep::Enhances] << endl
<< " AddProtected => " << AddProtected << endl
<< " AddEssential => " << AddEssential << endl;
@@ -439,24 +455,23 @@ void pkgProblemResolver::MakeScores()
*/
if (I->CurrentVer != 0 && Cache[I].CandidateVer != 0 && Cache[I].CandidateVerIter(Cache).Downloadable())
Score += PrioInstalledAndNotObsolete;
- }
- // Now that we have the base scores we go and propagate dependencies
- for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
- {
- if (Cache[I].InstallVer == 0)
- continue;
-
+ // propagate score points along dependencies
for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; ++D)
{
- if (D->Type == pkgCache::Dep::Depends ||
- D->Type == pkgCache::Dep::PreDepends)
- Scores[D.TargetPkg()->ID] += PrioDepends;
- else if (D->Type == pkgCache::Dep::Recommends)
- Scores[D.TargetPkg()->ID] += PrioRecommends;
+ if (DepMap[D->Type] == 0)
+ continue;
+ pkgCache::PkgIterator const T = D.TargetPkg();
+ if (D->Version != 0)
+ {
+ pkgCache::VerIterator const IV = Cache[T].InstVerIter(Cache);
+ if (IV.end() == true || D.IsSatisfied(IV) != D.IsNegative())
+ continue;
+ }
+ Scores[T->ID] += DepMap[D->Type];
}
- }
-
+ }
+
// Copy the scores to advoid additive looping
SPtrArray<int> OldScores = new int[Size];
memcpy(OldScores,Scores,sizeof(*Scores)*Size);
@@ -869,8 +884,8 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
}
if (Debug == true)
- clog << " Considering " << Pkg.FullName(false) << ' ' << (int)Scores[Pkg->ID] <<
- " as a solution to " << I.FullName(false) << ' ' << (int)Scores[I->ID] << endl;
+ clog << " Considering " << Pkg.FullName(false) << ' ' << Scores[Pkg->ID] <<
+ " as a solution to " << I.FullName(false) << ' ' << Scores[I->ID] << endl;
/* Try to fix the package under consideration rather than
fiddle with the VList package */
diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h
index 489d81159..f35bd9a13 100644
--- a/apt-pkg/algorithms.h
+++ b/apt-pkg/algorithms.h
@@ -33,8 +33,11 @@
#include <apt-pkg/packagemanager.h>
#include <apt-pkg/depcache.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
#include <iostream>
+#include <string>
#include <apt-pkg/macros.h>
@@ -111,7 +114,7 @@ class pkgProblemResolver /*{{{*/
// Sort stuff
static pkgProblemResolver *This;
- static int ScoreSort(const void *a,const void *b);
+ static int ScoreSort(const void *a,const void *b) APT_PURE;
struct PackageKill
{
@@ -140,7 +143,7 @@ class pkgProblemResolver /*{{{*/
// Try to resolve problems only by using keep
bool ResolveByKeep();
- __deprecated void InstallProtect();
+ APT_DEPRECATED void InstallProtect();
pkgProblemResolver(pkgDepCache *Cache);
~pkgProblemResolver();
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index 0b0b546c5..6ba047560 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -17,14 +17,19 @@
#include <apt-pkg/macros.h>
#include <apt-pkg/strutl.h>
-#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <fcntl.h>
-
+#include <ctype.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#include <algorithm>
#include <string>
#include <vector>
+
+#include <apti18n.h>
/*}}}*/
namespace APT {
// getCompressionTypes - Return Vector of usable compressiontypes /*{{{*/
@@ -49,11 +54,6 @@ const Configuration::getCompressionTypes(bool const &Cached) {
setDefaultConfigurationForCompressors();
std::vector<APT::Configuration::Compressor> const compressors = getCompressors();
- // accept non-list order as override setting for config settings on commandline
- std::string const overrideOrder = _config->Find("Acquire::CompressionTypes::Order","");
- if (overrideOrder.empty() == false)
- types.push_back(overrideOrder);
-
// load the order setting into our vector
std::vector<std::string> const order = _config->FindVector("Acquire::CompressionTypes::Order");
for (std::vector<std::string>::const_iterator o = order.begin();
@@ -227,61 +227,11 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
}
}
} else {
+ // cornercase: LANG=C, so we use only "en" Translation
environment.push_back("en");
}
- // Support settings like Acquire::Languages=none on the command line to
- // override the configuration settings vector of languages.
- string const forceLang = _config->Find("Acquire::Languages","");
- if (forceLang.empty() == false) {
- if (forceLang == "none") {
- codes.clear();
- allCodes.clear();
- allCodes.push_back("none");
- } else {
- if (forceLang == "environment")
- codes = environment;
- else
- codes.push_back(forceLang);
- allCodes = codes;
- for (std::vector<string>::const_iterator b = builtin.begin();
- b != builtin.end(); ++b)
- if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
- allCodes.push_back(*b);
- }
- if (All == true)
- return allCodes;
- else
- return codes;
- }
-
- // cornercase: LANG=C, so we use only "en" Translation
- if (envShort == "C") {
- allCodes = codes = environment;
- allCodes.insert(allCodes.end(), builtin.begin(), builtin.end());
- if (All == true)
- return allCodes;
- else
- return codes;
- }
-
- std::vector<string> const lang = _config->FindVector("Acquire::Languages");
- // the default setting -> "environment, en"
- if (lang.empty() == true) {
- codes = environment;
- if (envShort != "en")
- codes.push_back("en");
- allCodes = codes;
- for (std::vector<string>::const_iterator b = builtin.begin();
- b != builtin.end(); ++b)
- if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
- allCodes.push_back(*b);
- if (All == true)
- return allCodes;
- else
- return codes;
- }
-
+ std::vector<string> const lang = _config->FindVector("Acquire::Languages", "environment,en");
// the configs define the order, so add the environment
// then needed and ensure the codes are not listed twice.
bool noneSeen = false;
@@ -308,10 +258,15 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
allCodes.push_back(*l);
}
- for (std::vector<string>::const_iterator b = builtin.begin();
- b != builtin.end(); ++b)
- if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
- allCodes.push_back(*b);
+ if (allCodes.empty() == false) {
+ for (std::vector<string>::const_iterator b = builtin.begin();
+ b != builtin.end(); ++b)
+ if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
+ allCodes.push_back(*b);
+ } else {
+ // "none" was forced
+ allCodes.push_back("none");
+ }
if (All == true)
return allCodes;
@@ -320,7 +275,7 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
}
/*}}}*/
// checkLanguage - are we interested in the given Language? /*{{{*/
-bool const Configuration::checkLanguage(std::string Lang, bool const All) {
+bool Configuration::checkLanguage(std::string Lang, bool const All) {
// the empty Language is always interesting as it is the original
if (Lang.empty() == true)
return true;
@@ -440,7 +395,7 @@ std::vector<std::string> const Configuration::getArchitectures(bool const &Cache
}
/*}}}*/
// checkArchitecture - are we interested in the given Architecture? /*{{{*/
-bool const Configuration::checkArchitecture(std::string const &Arch) {
+bool Configuration::checkArchitecture(std::string const &Arch) {
if (Arch == "all")
return true;
std::vector<std::string> const archs = getArchitectures(true);
@@ -476,7 +431,7 @@ void Configuration::setDefaultConfigurationForCompressors() {
}
}
/*}}}*/
-// getCompressors - Return Vector of usbale compressors /*{{{*/
+// getCompressors - Return Vector of usealbe compressors /*{{{*/
// ---------------------------------------------------------------------
/* return a vector of compressors used by apt-ftparchive in the
multicompress functionality or to detect data.tar files */
@@ -507,8 +462,16 @@ const Configuration::getCompressors(bool const Cached) {
#endif
if (_config->Exists("Dir::Bin::xz") == false || FileExists(_config->FindFile("Dir::Bin::xz")) == true)
compressors.push_back(Compressor("xz",".xz","xz","-6","-d",4));
+#ifdef HAVE_LZMA
+ else
+ compressors.push_back(Compressor("xz",".xz","false", NULL, NULL, 4));
+#endif
if (_config->Exists("Dir::Bin::lzma") == false || FileExists(_config->FindFile("Dir::Bin::lzma")) == true)
compressors.push_back(Compressor("lzma",".lzma","lzma","-9","-d",5));
+#ifdef HAVE_LZMA
+ else
+ compressors.push_back(Compressor("lzma",".lzma","false", NULL, NULL, 5));
+#endif
std::vector<std::string> const comp = _config->FindVector("APT::Compressor");
for (std::vector<std::string>::const_iterator c = comp.begin();
@@ -558,4 +521,28 @@ Configuration::Compressor::Compressor(char const *name, char const *extension,
UncompressArgs.push_back(uncompressArg);
}
/*}}}*/
+// getBuildProfiles - return a vector of enabled build profiles /*{{{*/
+std::vector<std::string> const Configuration::getBuildProfiles() {
+ // order is: override value (~= commandline), environment variable, list (~= config file)
+ std::string profiles_env = getenv("DEB_BUILD_PROFILES") == 0 ? "" : getenv("DEB_BUILD_PROFILES");
+ if (profiles_env.empty() == false) {
+ profiles_env = SubstVar(profiles_env, " ", ",");
+ std::string const bp = _config->Find("APT::Build-Profiles");
+ _config->Clear("APT::Build-Profiles");
+ if (bp.empty() == false)
+ _config->Set("APT::Build-Profiles", bp);
+ }
+ return _config->FindVector("APT::Build-Profiles", profiles_env);
+}
+std::string const Configuration::getBuildProfilesString() {
+ std::vector<std::string> profiles = getBuildProfiles();
+ if (profiles.empty() == true)
+ return "";
+ std::vector<std::string>::const_iterator p = profiles.begin();
+ std::string list = *p;
+ for (; p != profiles.end(); ++p)
+ list.append(",").append(*p);
+ return list;
+}
+ /*}}}*/
}
diff --git a/apt-pkg/aptconfiguration.h b/apt-pkg/aptconfiguration.h
index bf7deae85..dfed194ae 100644
--- a/apt-pkg/aptconfiguration.h
+++ b/apt-pkg/aptconfiguration.h
@@ -73,7 +73,7 @@ public: /*{{{*/
* \param All defines if we check against all codes or only against used codes
* \return true if we are interested, false otherwise
*/
- bool static const checkLanguage(std::string Lang, bool const All = false);
+ bool static checkLanguage(std::string Lang, bool const All = false);
/** \brief Returns a vector of Architectures we support
*
@@ -89,7 +89,7 @@ public: /*{{{*/
* \param Arch we want to check
* \return true if we are interested, false otherwise
*/
- bool static const checkArchitecture(std::string const &Arch);
+ bool static checkArchitecture(std::string const &Arch);
/** \brief Representation of supported compressors */
struct Compressor {
@@ -117,6 +117,11 @@ public: /*{{{*/
/** \brief Return a vector of extensions supported for data.tar's */
std::vector<std::string> static const getCompressorExtensions();
+
+ /** \return Return a vector of enabled build profile specifications */
+ std::vector<std::string> static const getBuildProfiles();
+ /** \return Return a comma-separated list of enabled build profile specifications */
+ std::string static const getBuildProfilesString();
/*}}}*/
private: /*{{{*/
void static setDefaultConfigurationForCompressors();
diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc
index 7c2276185..0fd40106f 100644
--- a/apt-pkg/cachefile.cc
+++ b/apt-pkg/cachefile.cc
@@ -21,9 +21,16 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/policy.h>
#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/acquire-item.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/progress.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/mmap.h>
+#include <apt-pkg/pkgcache.h>
+
+#include <string.h>
+#include <unistd.h>
+#include <string>
+#include <vector>
#include <apti18n.h>
/*}}}*/
@@ -99,7 +106,7 @@ bool pkgCacheFile::BuildCaches(OpProgress *Progress, bool WithLock)
// CacheFile::BuildSourceList - Open and build all relevant sources.list/*{{{*/
// ---------------------------------------------------------------------
/* */
-bool pkgCacheFile::BuildSourceList(OpProgress *Progress)
+bool pkgCacheFile::BuildSourceList(OpProgress * /*Progress*/)
{
if (SrcList != NULL)
return true;
@@ -113,7 +120,7 @@ bool pkgCacheFile::BuildSourceList(OpProgress *Progress)
// CacheFile::BuildPolicy - Open and build all relevant preferences /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool pkgCacheFile::BuildPolicy(OpProgress *Progress)
+bool pkgCacheFile::BuildPolicy(OpProgress * /*Progress*/)
{
if (Policy != NULL)
return true;
diff --git a/apt-pkg/cachefile.h b/apt-pkg/cachefile.h
index 802b12b61..36b20893a 100644
--- a/apt-pkg/cachefile.h
+++ b/apt-pkg/cachefile.h
@@ -17,8 +17,12 @@
#ifndef PKGLIB_CACHEFILE_H
#define PKGLIB_CACHEFILE_H
+#include <stddef.h>
+
#include <apt-pkg/depcache.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/acquire.h>
@@ -26,6 +30,7 @@
#include <apt-pkg/sourcelist.h>
#endif
+class MMap;
class pkgPolicy;
class pkgSourceList;
class OpProgress;
@@ -60,13 +65,13 @@ class pkgCacheFile
inline unsigned char &operator [](pkgCache::DepIterator const &I) {return (*DCache)[I];};
bool BuildCaches(OpProgress *Progress = NULL,bool WithLock = true);
- __deprecated bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); };
+ APT_DEPRECATED bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); };
bool BuildSourceList(OpProgress *Progress = NULL);
bool BuildPolicy(OpProgress *Progress = NULL);
bool BuildDepCache(OpProgress *Progress = NULL);
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); };
+ APT_DEPRECATED bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); };
static void RemoveCaches();
void Close();
diff --git a/apt-pkg/cachefilter.cc b/apt-pkg/cachefilter.cc
index 57b9af159..e388f2450 100644
--- a/apt-pkg/cachefilter.cc
+++ b/apt-pkg/cachefilter.cc
@@ -9,10 +9,12 @@
#include <apt-pkg/cachefilter.h>
#include <apt-pkg/error.h>
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/strutl.h>
+#include <apt-pkg/macros.h>
#include <string>
-
+#include <string.h>
#include <regex.h>
#include <fnmatch.h>
diff --git a/apt-pkg/cachefilter.h b/apt-pkg/cachefilter.h
index 34b7d0b46..49d2855f5 100644
--- a/apt-pkg/cachefilter.h
+++ b/apt-pkg/cachefilter.h
@@ -7,6 +7,7 @@
#define APT_CACHEFILTER_H
// Include Files /*{{{*/
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
#include <string>
@@ -47,7 +48,7 @@ public:
/** \class PackageArchitectureMatchesSpecification
\brief matching against architecture specification strings
- The strings are of the format <kernel>-<cpu> where either component,
+ The strings are of the format \<kernel\>-\<cpu\> where either component,
or the whole string, can be the wildcard "any" as defined in
debian-policy §11.1 "Architecture specification strings".
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h
index ea6a4afba..2fdf8404d 100644
--- a/apt-pkg/cacheiterators.h
+++ b/apt-pkg/cacheiterators.h
@@ -29,7 +29,12 @@
/*}}}*/
#ifndef PKGLIB_CACHEITERATORS_H
#define PKGLIB_CACHEITERATORS_H
+#include<apt-pkg/pkgcache.h>
+#include<apt-pkg/macros.h>
+
#include<iterator>
+#include <iosfwd>
+#include <string>
#include<string.h>
@@ -55,36 +60,36 @@ template<typename Str, typename Itr> class pkgCache::Iterator :
public:
// Iteration
virtual void operator ++(int) = 0;
- virtual void operator ++() = 0; // Should be {operator ++(0);};
- inline bool end() const {return Owner == 0 || S == OwnerPointer();};
+ virtual void operator ++() = 0; // Should be {operator ++(0);}
+ inline bool end() const {return Owner == 0 || S == OwnerPointer();}
// Comparison
- inline bool operator ==(const Itr &B) const {return S == B.S;};
- inline bool operator !=(const Itr &B) const {return S != B.S;};
+ inline bool operator ==(const Itr &B) const {return S == B.S;}
+ inline bool operator !=(const Itr &B) const {return S != B.S;}
// Accessors
- inline Str *operator ->() {return S;};
- inline Str const *operator ->() const {return S;};
- inline operator Str *() {return S == OwnerPointer() ? 0 : S;};
- inline operator Str const *() const {return S == OwnerPointer() ? 0 : S;};
- inline Str &operator *() {return *S;};
- inline Str const &operator *() const {return *S;};
- inline pkgCache *Cache() const {return Owner;};
+ inline Str *operator ->() {return S;}
+ inline Str const *operator ->() const {return S;}
+ inline operator Str *() {return S == OwnerPointer() ? 0 : S;}
+ inline operator Str const *() const {return S == OwnerPointer() ? 0 : S;}
+ inline Str &operator *() {return *S;}
+ inline Str const &operator *() const {return *S;}
+ inline pkgCache *Cache() const {return Owner;}
// Mixed stuff
- inline void operator =(const Itr &B) {S = B.S; Owner = B.Owner;};
- inline bool IsGood() const { return S && Owner && ! end();};
- inline unsigned long Index() const {return S - OwnerPointer();};
+ inline void operator =(const Itr &B) {S = B.S; Owner = B.Owner;}
+ inline bool IsGood() const { return S && Owner && ! end();}
+ inline unsigned long Index() const {return S - OwnerPointer();}
void ReMap(void const * const oldMap, void const * const newMap) {
if (Owner == 0 || S == 0)
return;
- S += (Str*)(newMap) - (Str*)(oldMap);
+ S += (Str const * const)(newMap) - (Str const * const)(oldMap);
}
// Constructors - look out for the variable assigning
- inline Iterator() : S(0), Owner(0) {};
- inline Iterator(pkgCache &Owner,Str *T = 0) : S(T), Owner(&Owner) {};
+ inline Iterator() : S(0), Owner(0) {}
+ inline Iterator(pkgCache &Owner,Str *T = 0) : S(T), Owner(&Owner) {}
};
/*}}}*/
// Group Iterator /*{{{*/
@@ -98,19 +103,19 @@ class pkgCache::GrpIterator: public Iterator<Group, GrpIterator> {
protected:
inline Group* OwnerPointer() const {
return (Owner != 0) ? Owner->GrpP : 0;
- };
+ }
public:
// This constructor is the 'begin' constructor, never use it.
inline GrpIterator(pkgCache &Owner) : Iterator<Group, GrpIterator>(Owner), HashIndex(-1) {
S = OwnerPointer();
operator ++(0);
- };
+ }
virtual void operator ++(int);
- virtual void operator ++() {operator ++(0);};
+ virtual void operator ++() {operator ++(0);}
- inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;};
+ inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;}
inline PkgIterator PackageList() const;
PkgIterator FindPkg(std::string Arch = "any") const;
/** \brief find the package with the "best" architecture
@@ -127,8 +132,8 @@ class pkgCache::GrpIterator: public Iterator<Group, GrpIterator> {
inline GrpIterator(pkgCache &Owner, Group *Trg) : Iterator<Group, GrpIterator>(Owner, Trg), HashIndex(0) {
if (S == 0)
S = OwnerPointer();
- };
- inline GrpIterator() : Iterator<Group, GrpIterator>(), HashIndex(0) {};
+ }
+ inline GrpIterator() : Iterator<Group, GrpIterator>(), HashIndex(0) {}
};
/*}}}*/
@@ -139,35 +144,35 @@ class pkgCache::PkgIterator: public Iterator<Package, PkgIterator> {
protected:
inline Package* OwnerPointer() const {
return (Owner != 0) ? Owner->PkgP : 0;
- };
+ }
public:
// This constructor is the 'begin' constructor, never use it.
inline PkgIterator(pkgCache &Owner) : Iterator<Package, PkgIterator>(Owner), HashIndex(-1) {
S = OwnerPointer();
operator ++(0);
- };
+ }
virtual void operator ++(int);
- virtual void operator ++() {operator ++(0);};
+ virtual void operator ++() {operator ++(0);}
enum OkState {NeedsNothing,NeedsUnpack,NeedsConfigure};
// Accessors
- inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;};
- inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;};
+ inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;}
+ inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;}
inline bool Purge() const {return S->CurrentState == pkgCache::State::Purge ||
- (S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);};
- inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;};
- inline GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group);};
-
- inline VerIterator VersionList() const;
- inline VerIterator CurrentVer() const;
- inline DepIterator RevDependsList() const;
- inline PrvIterator ProvidesList() const;
- OkState State() const;
- const char *CandVersion() const;
- const char *CurVersion() const;
+ (S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);}
+ inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;}
+ inline APT_PURE GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group);}
+
+ inline VerIterator VersionList() const APT_PURE;
+ inline VerIterator CurrentVer() const APT_PURE;
+ inline DepIterator RevDependsList() const APT_PURE;
+ inline PrvIterator ProvidesList() const APT_PURE;
+ OkState State() const APT_PURE;
+ const char *CandVersion() const APT_PURE;
+ const char *CurVersion() const APT_PURE;
//Nice printable representation
friend std::ostream& operator <<(std::ostream& out, PkgIterator i);
@@ -177,8 +182,8 @@ class pkgCache::PkgIterator: public Iterator<Package, PkgIterator> {
inline PkgIterator(pkgCache &Owner,Package *Trg) : Iterator<Package, PkgIterator>(Owner, Trg), HashIndex(0) {
if (S == 0)
S = OwnerPointer();
- };
- inline PkgIterator() : Iterator<Package, PkgIterator>(), HashIndex(0) {};
+ }
+ inline PkgIterator() : Iterator<Package, PkgIterator>(), HashIndex(0) {}
};
/*}}}*/
// Version Iterator /*{{{*/
@@ -186,12 +191,12 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
protected:
inline Version* OwnerPointer() const {
return (Owner != 0) ? Owner->VerP : 0;
- };
+ }
public:
// Iteration
- void operator ++(int) {if (S != Owner->VerP) S = Owner->VerP + S->NextVer;};
- inline void operator ++() {operator ++(0);};
+ void operator ++(int) {if (S != Owner->VerP) S = Owner->VerP + S->NextVer;}
+ inline void operator ++() {operator ++(0);}
// Comparison
int CompareVer(const VerIterator &B) const;
@@ -201,17 +206,17 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
referring to the same "real" version */
inline bool SimilarVer(const VerIterator &B) const {
return (B.end() == false && S->Hash == B->Hash && strcmp(VerStr(), B.VerStr()) == 0);
- };
+ }
// Accessors
- 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 *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) == pkgCache::Version::All)
return "all";
return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch;
- };
- inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);};
+ }
+ inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);}
inline DescIterator DescriptionList() const;
DescIterator TranslatedDescription() const;
@@ -219,8 +224,8 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
inline PrvIterator ProvidesList() const;
inline VerFileIterator FileList() const;
bool Downloadable() const;
- inline const char *PriorityType() const {return Owner->Priority(S->Priority);};
- const char *MultiArchType() const;
+ inline const char *PriorityType() const {return Owner->Priority(S->Priority);}
+ const char *MultiArchType() const APT_PURE;
std::string RelStr() const;
bool Automatic() const;
@@ -229,8 +234,8 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Iterator<Version, VerIterator>(Owner, Trg) {
if (S == 0)
S = OwnerPointer();
- };
- inline VerIterator() : Iterator<Version, VerIterator>() {};
+ }
+ inline VerIterator() : Iterator<Version, VerIterator>() {}
};
/*}}}*/
// Description Iterator /*{{{*/
@@ -238,26 +243,26 @@ class pkgCache::DescIterator : public Iterator<Description, DescIterator> {
protected:
inline Description* OwnerPointer() const {
return (Owner != 0) ? Owner->DescP : 0;
- };
+ }
public:
// Iteration
- void operator ++(int) {if (S != Owner->DescP) S = Owner->DescP + S->NextDesc;};
- inline void operator ++() {operator ++(0);};
+ void operator ++(int) {if (S != Owner->DescP) S = Owner->DescP + S->NextDesc;}
+ inline void operator ++() {operator ++(0);}
// Comparison
int CompareDesc(const DescIterator &B) const;
// Accessors
- inline const char *LanguageCode() const {return Owner->StrP + S->language_code;};
- inline const char *md5() const {return Owner->StrP + S->md5sum;};
+ inline const char *LanguageCode() const {return Owner->StrP + S->language_code;}
+ inline const char *md5() const {return Owner->StrP + S->md5sum;}
inline DescFileIterator FileList() const;
- inline DescIterator() : Iterator<Description, DescIterator>() {};
+ inline DescIterator() : Iterator<Description, DescIterator>() {}
inline DescIterator(pkgCache &Owner,Description *Trg = 0) : Iterator<Description, DescIterator>(Owner, Trg) {
if (S == 0)
S = Owner.DescP;
- };
+ }
};
/*}}}*/
// Dependency iterator /*{{{*/
@@ -267,33 +272,33 @@ class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
protected:
inline Dependency* OwnerPointer() const {
return (Owner != 0) ? Owner->DepP : 0;
- };
+ }
public:
// Iteration
void operator ++(int) {if (S != Owner->DepP) S = Owner->DepP +
- (Type == DepVer ? S->NextDepends : S->NextRevDepends);};
- inline void operator ++() {operator ++(0);};
+ (Type == DepVer ? S->NextDepends : S->NextRevDepends);}
+ inline void operator ++() {operator ++(0);}
// Accessors
- inline const char *TargetVer() const {return S->Version == 0?0:Owner->StrP + S->Version;};
- inline PkgIterator TargetPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->Package);};
- inline PkgIterator SmartTargetPkg() const {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;};
- inline VerIterator ParentVer() const {return VerIterator(*Owner,Owner->VerP + S->ParentVer);};
- inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->ParentVer].ParentPkg);};
- inline bool Reverse() const {return Type == DepRev;};
- bool IsCritical() const;
- bool IsNegative() const;
- bool IsIgnorable(PrvIterator const &Prv) const;
- bool IsIgnorable(PkgIterator const &Pkg) const;
- bool IsMultiArchImplicit() const;
- bool IsSatisfied(VerIterator const &Ver) const;
- bool IsSatisfied(PrvIterator const &Prv) const;
+ inline const char *TargetVer() const {return S->Version == 0?0:Owner->StrP + S->Version;}
+ inline PkgIterator TargetPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->Package);}
+ inline PkgIterator SmartTargetPkg() const {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;}
+ inline VerIterator ParentVer() const {return VerIterator(*Owner,Owner->VerP + S->ParentVer);}
+ inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->ParentVer].ParentPkg);}
+ inline bool Reverse() const {return Type == DepRev;}
+ bool IsCritical() const APT_PURE;
+ bool IsNegative() const APT_PURE;
+ bool IsIgnorable(PrvIterator const &Prv) const APT_PURE;
+ bool IsIgnorable(PkgIterator const &Pkg) const APT_PURE;
+ bool IsMultiArchImplicit() const APT_PURE;
+ bool IsSatisfied(VerIterator const &Ver) const APT_PURE;
+ bool IsSatisfied(PrvIterator const &Prv) const APT_PURE;
void GlobOr(DepIterator &Start,DepIterator &End);
Version **AllTargets() const;
bool SmartTargetPkg(PkgIterator &Result) const;
- inline const char *CompType() const {return Owner->CompType(S->CompareOp);};
- inline const char *DepType() const {return Owner->DepType(S->Type);};
+ inline const char *CompType() const {return Owner->CompType(S->CompareOp);}
+ inline const char *DepType() const {return Owner->DepType(S->Type);}
//Nice printable representation
friend std::ostream& operator <<(std::ostream& out, DepIterator D);
@@ -302,13 +307,13 @@ class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepVer) {
if (S == 0)
S = Owner.DepP;
- };
+ }
inline DepIterator(pkgCache &Owner, Dependency *Trg, Package*) :
Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepRev) {
if (S == 0)
S = Owner.DepP;
- };
- inline DepIterator() : Iterator<Dependency, DepIterator>(), Type(DepVer) {};
+ }
+ inline DepIterator() : Iterator<Dependency, DepIterator>(), Type(DepVer) {}
};
/*}}}*/
// Provides iterator /*{{{*/
@@ -318,34 +323,34 @@ class pkgCache::PrvIterator : public Iterator<Provides, PrvIterator> {
protected:
inline Provides* OwnerPointer() const {
return (Owner != 0) ? Owner->ProvideP : 0;
- };
+ }
public:
// Iteration
void operator ++(int) {if (S != Owner->ProvideP) S = Owner->ProvideP +
- (Type == PrvVer?S->NextPkgProv:S->NextProvides);};
- inline void operator ++() {operator ++(0);};
+ (Type == PrvVer?S->NextPkgProv:S->NextProvides);}
+ inline void operator ++() {operator ++(0);}
// Accessors
- inline const char *Name() const {return Owner->StrP + Owner->PkgP[S->ParentPkg].Name;};
- inline const char *ProvideVersion() const {return S->ProvideVersion == 0?0:Owner->StrP + S->ProvideVersion;};
- inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);};
- inline VerIterator OwnerVer() const {return VerIterator(*Owner,Owner->VerP + S->Version);};
- inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->Version].ParentPkg);};
+ inline const char *Name() const {return Owner->StrP + Owner->PkgP[S->ParentPkg].Name;}
+ inline const char *ProvideVersion() const {return S->ProvideVersion == 0?0:Owner->StrP + S->ProvideVersion;}
+ inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);}
+ inline VerIterator OwnerVer() const {return VerIterator(*Owner,Owner->VerP + S->Version);}
+ inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->Version].ParentPkg);}
- bool IsMultiArchImplicit() const;
+ bool IsMultiArchImplicit() const APT_PURE;
- inline PrvIterator() : Iterator<Provides, PrvIterator>(), Type(PrvVer) {};
+ inline PrvIterator() : Iterator<Provides, PrvIterator>(), Type(PrvVer) {}
inline PrvIterator(pkgCache &Owner, Provides *Trg, Version*) :
Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvVer) {
if (S == 0)
S = Owner.ProvideP;
- };
+ }
inline PrvIterator(pkgCache &Owner, Provides *Trg, Package*) :
Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvPkg) {
if (S == 0)
S = Owner.ProvideP;
- };
+ }
};
/*}}}*/
// Package file /*{{{*/
@@ -353,32 +358,32 @@ class pkgCache::PkgFileIterator : public Iterator<PackageFile, PkgFileIterator>
protected:
inline PackageFile* OwnerPointer() const {
return (Owner != 0) ? Owner->PkgFileP : 0;
- };
+ }
public:
// Iteration
- void operator ++(int) {if (S != Owner->PkgFileP) S = Owner->PkgFileP + S->NextFile;};
- inline void operator ++() {operator ++(0);};
+ void operator ++(int) {if (S != Owner->PkgFileP) S = Owner->PkgFileP + S->NextFile;}
+ inline void operator ++() {operator ++(0);}
// Accessors
- inline const char *FileName() const {return S->FileName == 0?0:Owner->StrP + S->FileName;};
- inline const char *Archive() const {return S->Archive == 0?0:Owner->StrP + S->Archive;};
- inline const char *Component() const {return S->Component == 0?0:Owner->StrP + S->Component;};
- inline const char *Version() const {return S->Version == 0?0:Owner->StrP + S->Version;};
- inline const char *Origin() const {return S->Origin == 0?0:Owner->StrP + S->Origin;};
- inline const char *Codename() const {return S->Codename ==0?0:Owner->StrP + S->Codename;};
- inline const char *Label() const {return S->Label == 0?0:Owner->StrP + S->Label;};
- inline const char *Site() const {return S->Site == 0?0:Owner->StrP + S->Site;};
- inline const char *Architecture() const {return S->Architecture == 0?0:Owner->StrP + S->Architecture;};
- inline const char *IndexType() const {return S->IndexType == 0?0:Owner->StrP + S->IndexType;};
+ inline const char *FileName() const {return S->FileName == 0?0:Owner->StrP + S->FileName;}
+ inline const char *Archive() const {return S->Archive == 0?0:Owner->StrP + S->Archive;}
+ inline const char *Component() const {return S->Component == 0?0:Owner->StrP + S->Component;}
+ inline const char *Version() const {return S->Version == 0?0:Owner->StrP + S->Version;}
+ inline const char *Origin() const {return S->Origin == 0?0:Owner->StrP + S->Origin;}
+ inline const char *Codename() const {return S->Codename ==0?0:Owner->StrP + S->Codename;}
+ inline const char *Label() const {return S->Label == 0?0:Owner->StrP + S->Label;}
+ inline const char *Site() const {return S->Site == 0?0:Owner->StrP + S->Site;}
+ inline const char *Architecture() const {return S->Architecture == 0?0:Owner->StrP + S->Architecture;}
+ inline const char *IndexType() const {return S->IndexType == 0?0:Owner->StrP + S->IndexType;}
bool IsOk();
std::string RelStr();
// Constructors
- inline PkgFileIterator() : Iterator<PackageFile, PkgFileIterator>() {};
- inline PkgFileIterator(pkgCache &Owner) : Iterator<PackageFile, PkgFileIterator>(Owner, Owner.PkgFileP) {};
- inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Iterator<PackageFile, PkgFileIterator>(Owner, Trg) {};
+ inline PkgFileIterator() : Iterator<PackageFile, PkgFileIterator>() {}
+ inline PkgFileIterator(pkgCache &Owner) : Iterator<PackageFile, PkgFileIterator>(Owner, Owner.PkgFileP) {}
+ inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Iterator<PackageFile, PkgFileIterator>(Owner, Trg) {}
};
/*}}}*/
// Version File /*{{{*/
@@ -386,18 +391,18 @@ class pkgCache::VerFileIterator : public pkgCache::Iterator<VerFile, VerFileIter
protected:
inline VerFile* OwnerPointer() const {
return (Owner != 0) ? Owner->VerFileP : 0;
- };
+ }
public:
// Iteration
- void operator ++(int) {if (S != Owner->VerFileP) S = Owner->VerFileP + S->NextFile;};
- inline void operator ++() {operator ++(0);};
+ void operator ++(int) {if (S != Owner->VerFileP) S = Owner->VerFileP + S->NextFile;}
+ inline void operator ++() {operator ++(0);}
// Accessors
- inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S->File + Owner->PkgFileP);};
+ inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S->File + Owner->PkgFileP);}
- inline VerFileIterator() : Iterator<VerFile, VerFileIterator>() {};
- inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Iterator<VerFile, VerFileIterator>(Owner, Trg) {};
+ inline VerFileIterator() : Iterator<VerFile, VerFileIterator>() {}
+ inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Iterator<VerFile, VerFileIterator>(Owner, Trg) {}
};
/*}}}*/
// Description File /*{{{*/
@@ -405,40 +410,40 @@ class pkgCache::DescFileIterator : public Iterator<DescFile, DescFileIterator> {
protected:
inline DescFile* OwnerPointer() const {
return (Owner != 0) ? Owner->DescFileP : 0;
- };
+ }
public:
// Iteration
- void operator ++(int) {if (S != Owner->DescFileP) S = Owner->DescFileP + S->NextFile;};
- inline void operator ++() {operator ++(0);};
+ void operator ++(int) {if (S != Owner->DescFileP) S = Owner->DescFileP + S->NextFile;}
+ inline void operator ++() {operator ++(0);}
// Accessors
- inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S->File + Owner->PkgFileP);};
+ inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S->File + Owner->PkgFileP);}
- inline DescFileIterator() : Iterator<DescFile, DescFileIterator>() {};
- inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Iterator<DescFile, DescFileIterator>(Owner, Trg) {};
+ inline DescFileIterator() : Iterator<DescFile, DescFileIterator>() {}
+ inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Iterator<DescFile, DescFileIterator>(Owner, Trg) {}
};
/*}}}*/
// Inlined Begin functions can't be in the class because of order problems /*{{{*/
inline pkgCache::PkgIterator pkgCache::GrpIterator::PackageList() const
- {return PkgIterator(*Owner,Owner->PkgP + S->FirstPackage);};
+ {return PkgIterator(*Owner,Owner->PkgP + S->FirstPackage);}
inline pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const
- {return VerIterator(*Owner,Owner->VerP + S->VersionList);};
+ {return VerIterator(*Owner,Owner->VerP + S->VersionList);}
inline pkgCache::VerIterator pkgCache::PkgIterator::CurrentVer() const
- {return VerIterator(*Owner,Owner->VerP + S->CurrentVer);};
+ {return VerIterator(*Owner,Owner->VerP + S->CurrentVer);}
inline pkgCache::DepIterator pkgCache::PkgIterator::RevDependsList() const
- {return DepIterator(*Owner,Owner->DepP + S->RevDepends,S);};
+ {return DepIterator(*Owner,Owner->DepP + S->RevDepends,S);}
inline pkgCache::PrvIterator pkgCache::PkgIterator::ProvidesList() const
- {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);};
+ {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}
inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() const
- {return DescIterator(*Owner,Owner->DescP + S->DescriptionList);};
+ {return DescIterator(*Owner,Owner->DescP + S->DescriptionList);}
inline pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const
- {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);};
+ {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}
inline pkgCache::DepIterator pkgCache::VerIterator::DependsList() const
- {return DepIterator(*Owner,Owner->DepP + S->DependsList,S);};
+ {return DepIterator(*Owner,Owner->DepP + S->DependsList,S);}
inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const
- {return VerFileIterator(*Owner,Owner->VerFileP + S->FileList);};
+ {return VerFileIterator(*Owner,Owner->VerFileP + S->FileList);}
inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const
- {return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);};
+ {return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);}
/*}}}*/
#endif
diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc
index 6b6fdb5ad..d453a2bfb 100644
--- a/apt-pkg/cacheset.cc
+++ b/apt-pkg/cacheset.cc
@@ -16,14 +16,22 @@
#include <apt-pkg/cachefilter.h>
#include <apt-pkg/cacheset.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/versionmatch.h>
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/policy.h>
-
-#include <vector>
-
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
+
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
#include <regex.h>
+#include <list>
+#include <string>
+#include <vector>
#include <apti18n.h>
/*}}}*/
@@ -588,13 +596,13 @@ pkgCache::PkgIterator CacheSetHelper::canNotFindPkgName(pkgCacheFile &Cache,
}
/*}}}*/
// canNotFindTask - handle the case no package is found for a task /*{{{*/
-void CacheSetHelper::canNotFindTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) {
+void CacheSetHelper::canNotFindTask(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string pattern) {
if (ShowError == true)
_error->Insert(ErrorType, _("Couldn't find task '%s'"), pattern.c_str());
}
/*}}}*/
// canNotFindRegEx - handle the case no package is found by a regex /*{{{*/
-void CacheSetHelper::canNotFindRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) {
+void CacheSetHelper::canNotFindRegEx(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string pattern) {
if (ShowError == true)
_error->Insert(ErrorType, _("Couldn't find any package by regex '%s'"), pattern.c_str());
}
@@ -606,25 +614,25 @@ void CacheSetHelper::canNotFindFnmatch(PackageContainerInterface * const pci, pk
}
#endif /*}}}*/
// canNotFindPackage - handle the case no package is found from a string/*{{{*/
-void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &str) {
+APT_CONST void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string const &/*str*/) {
}
/*}}}*/
// canNotFindAllVer /*{{{*/
-void CacheSetHelper::canNotFindAllVer(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+void CacheSetHelper::canNotFindAllVer(VersionContainerInterface * const /*vci*/, pkgCacheFile &/*Cache*/,
pkgCache::PkgIterator const &Pkg) {
if (ShowError == true)
_error->Insert(ErrorType, _("Can't select versions from package '%s' as it is purely virtual"), Pkg.FullName(true).c_str());
}
/*}}}*/
// canNotFindInstCandVer /*{{{*/
-void CacheSetHelper::canNotFindInstCandVer(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+void CacheSetHelper::canNotFindInstCandVer(VersionContainerInterface * const /*vci*/, pkgCacheFile &/*Cache*/,
pkgCache::PkgIterator const &Pkg) {
if (ShowError == true)
_error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str());
}
/*}}}*/
// canNotFindInstCandVer /*{{{*/
-void CacheSetHelper::canNotFindCandInstVer(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+void CacheSetHelper::canNotFindCandInstVer(VersionContainerInterface * const /*vci*/, pkgCacheFile &/*Cache*/,
pkgCache::PkgIterator const &Pkg) {
if (ShowError == true)
_error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str());
@@ -655,27 +663,27 @@ pkgCache::VerIterator CacheSetHelper::canNotFindInstalledVer(pkgCacheFile &Cache
}
/*}}}*/
// showTaskSelection /*{{{*/
-void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &pkg,
- std::string const &pattern) {
+APT_CONST void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &/*pkg*/,
+ std::string const &/*pattern*/) {
}
/*}}}*/
// showRegExSelection /*{{{*/
-void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &pkg,
- std::string const &pattern) {
+APT_CONST void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &/*pkg*/,
+ std::string const &/*pattern*/) {
}
/*}}}*/
#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
// showFnmatchSelection /*{{{*/
-void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg,
+APT_CONST void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg,
std::string const &pattern) {
}
/*}}}*/
#endif
// showSelectedVersion /*{{{*/
-void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &Pkg,
- pkgCache::VerIterator const Ver,
- std::string const &ver,
- bool const verIsRel) {
+APT_CONST void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &/*Pkg*/,
+ pkgCache::VerIterator const /*Ver*/,
+ std::string const &/*ver*/,
+ bool const /*verIsRel*/) {
}
/*}}}*/
}
diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h
index b69d74b8e..16a3daa42 100644
--- a/apt-pkg/cacheset.h
+++ b/apt-pkg/cacheset.h
@@ -9,7 +9,6 @@
#ifndef APT_CACHESET_H
#define APT_CACHESET_H
// Include Files /*{{{*/
-#include <iostream>
#include <fstream>
#include <map>
#include <set>
@@ -17,12 +16,18 @@
#include <string>
#include <iterator>
+#include <stddef.h>
+
#include <apt-pkg/error.h>
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/cachefile.h>
#endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <iostream>
+#endif
/*}}}*/
class pkgCacheFile;
@@ -43,8 +48,8 @@ class CacheSetHelper { /*{{{*/
public: /*{{{*/
CacheSetHelper(bool const ShowError = true,
GlobalError::MsgType ErrorType = GlobalError::ERROR) :
- ShowError(ShowError), ErrorType(ErrorType) {};
- virtual ~CacheSetHelper() {};
+ ShowError(ShowError), ErrorType(ErrorType) {}
+ virtual ~CacheSetHelper() {}
virtual void showTaskSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern);
virtual void showRegExSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern);
@@ -76,9 +81,9 @@ public: /*{{{*/
virtual pkgCache::VerIterator canNotFindInstalledVer(pkgCacheFile &Cache,
pkgCache::PkgIterator const &Pkg);
- bool showErrors() const { return ShowError; };
- bool showErrors(bool const newValue) { if (ShowError == newValue) return ShowError; else return ((ShowError = newValue) == false); };
- GlobalError::MsgType errorType() const { return ErrorType; };
+ bool showErrors() const { return ShowError; }
+ bool showErrors(bool const newValue) { if (ShowError == newValue) return ShowError; else return ((ShowError = newValue) == false); }
+ GlobalError::MsgType errorType() const { return ErrorType; }
GlobalError::MsgType errorType(GlobalError::MsgType const &newValue)
{
if (ErrorType == newValue) return ErrorType;
@@ -87,7 +92,7 @@ public: /*{{{*/
ErrorType = newValue;
return oldValue;
}
- };
+ }
/*}}}*/
protected:
@@ -124,12 +129,12 @@ public:
inline pkgCache::PkgIterator::OkState State() const { return getPkg().State(); }
inline const char *CandVersion() const { return getPkg().CandVersion(); }
inline const char *CurVersion() const { return getPkg().CurVersion(); }
- inline pkgCache *Cache() const { return getPkg().Cache(); };
- inline unsigned long Index() const {return getPkg().Index();};
+ inline pkgCache *Cache() const { return getPkg().Cache(); }
+ inline unsigned long Index() const {return getPkg().Index();}
// we have only valid iterators here
- inline bool end() const { return false; };
+ inline bool end() const { return false; }
- inline pkgCache::Package const * operator->() const {return &*getPkg();};
+ inline pkgCache::Package const * operator->() const {return &*getPkg();}
};
/*}}}*/
@@ -154,7 +159,7 @@ public:
unsigned short ID;
const char * const Alias;
Position Pos;
- Modifier (unsigned short const &id, const char * const alias, Position const &pos) : ID(id), Alias(alias), Pos(pos) {};
+ Modifier (unsigned short const &id, const char * const alias, Position const &pos) : ID(id), Alias(alias), Pos(pos) {}
};
static bool FromModifierCommandLine(unsigned short &modID, PackageContainerInterface * const pci,
@@ -177,12 +182,12 @@ public: /*{{{*/
public:
const_iterator(typename Container::const_iterator i) : _iter(i) {}
pkgCache::PkgIterator getPkg(void) const { return *_iter; }
- inline pkgCache::PkgIterator operator*(void) const { return *_iter; };
+ inline pkgCache::PkgIterator operator*(void) const { return *_iter; }
operator typename Container::const_iterator(void) const { return _iter; }
inline const_iterator& operator++() { ++_iter; return *this; }
inline const_iterator operator++(int) { const_iterator tmp(*this); operator++(); return tmp; }
- inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; };
- inline bool operator==(const_iterator const &i) const { return _iter == i._iter; };
+ inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; }
+ inline bool operator==(const_iterator const &i) const { return _iter == i._iter; }
friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }
};
class iterator : public PackageContainerInterface::const_iterator,
@@ -191,43 +196,43 @@ public: /*{{{*/
public:
iterator(typename Container::iterator i) : _iter(i) {}
pkgCache::PkgIterator getPkg(void) const { return *_iter; }
- inline pkgCache::PkgIterator operator*(void) const { return *_iter; };
+ inline pkgCache::PkgIterator operator*(void) const { return *_iter; }
operator typename Container::iterator(void) const { return _iter; }
operator typename PackageContainer<Container>::const_iterator() { return typename PackageContainer<Container>::const_iterator(_iter); }
inline iterator& operator++() { ++_iter; return *this; }
inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; }
- inline bool operator!=(iterator const &i) const { return _iter != i._iter; };
- inline bool operator==(iterator const &i) const { return _iter == i._iter; };
- inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; };
- inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; };
+ inline bool operator!=(iterator const &i) const { return _iter != i._iter; }
+ inline bool operator==(iterator const &i) const { return _iter == i._iter; }
+ inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; }
+ inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; }
friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
};
/*}}}*/
- bool insert(pkgCache::PkgIterator const &P) { if (P.end() == true) return false; _cont.insert(P); return true; };
- template<class Cont> void insert(PackageContainer<Cont> const &pkgcont) { _cont.insert((typename Cont::const_iterator)pkgcont.begin(), (typename Cont::const_iterator)pkgcont.end()); };
- void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); };
+ bool insert(pkgCache::PkgIterator const &P) { if (P.end() == true) return false; _cont.insert(P); return true; }
+ template<class Cont> void insert(PackageContainer<Cont> const &pkgcont) { _cont.insert((typename Cont::const_iterator)pkgcont.begin(), (typename Cont::const_iterator)pkgcont.end()); }
+ void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); }
- bool empty() const { return _cont.empty(); };
- void clear() { return _cont.clear(); };
+ bool empty() const { return _cont.empty(); }
+ void clear() { return _cont.clear(); }
//FIXME: on ABI break, replace the first with the second without bool
- void erase(iterator position) { _cont.erase((typename Container::iterator)position); };
- iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); };
- size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); };
- void erase(iterator first, iterator last) { _cont.erase(first, last); };
- size_t size() const { return _cont.size(); };
+ void erase(iterator position) { _cont.erase((typename Container::iterator)position); }
+ iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); }
+ size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); }
+ void erase(iterator first, iterator last) { _cont.erase(first, last); }
+ size_t size() const { return _cont.size(); }
- const_iterator begin() const { return const_iterator(_cont.begin()); };
- const_iterator end() const { return const_iterator(_cont.end()); };
- iterator begin() { return iterator(_cont.begin()); };
- iterator end() { return iterator(_cont.end()); };
- const_iterator find(pkgCache::PkgIterator const &P) const { return const_iterator(_cont.find(P)); };
+ const_iterator begin() const { return const_iterator(_cont.begin()); }
+ const_iterator end() const { return const_iterator(_cont.end()); }
+ iterator begin() { return iterator(_cont.begin()); }
+ iterator end() { return iterator(_cont.end()); }
+ const_iterator find(pkgCache::PkgIterator const &P) const { return const_iterator(_cont.find(P)); }
- void setConstructor(Constructor const &by) { ConstructedBy = by; };
- Constructor getConstructor() const { return ConstructedBy; };
+ void setConstructor(Constructor const &by) { ConstructedBy = by; }
+ Constructor getConstructor() const { return ConstructedBy; }
- PackageContainer() : ConstructedBy(UNKNOWN) {};
- PackageContainer(Constructor const &by) : ConstructedBy(by) {};
+ PackageContainer() : ConstructedBy(UNKNOWN) {}
+ PackageContainer(Constructor const &by) : ConstructedBy(by) {}
/** \brief returns all packages in the cache who belong to the given task
@@ -365,7 +370,7 @@ private: /*{{{*/
template<> template<class Cont> void PackageContainer<std::list<pkgCache::PkgIterator> >::insert(PackageContainer<Cont> const &pkgcont) {
for (typename PackageContainer<Cont>::const_iterator p = pkgcont.begin(); p != pkgcont.end(); ++p)
_cont.push_back(*p);
-};
+}
// these two are 'inline' as otherwise the linker has problems with seeing these untemplated
// specializations again and again - but we need to see them, so that library users can use them
template<> inline bool PackageContainer<std::list<pkgCache::PkgIterator> >::insert(pkgCache::PkgIterator const &P) {
@@ -373,11 +378,11 @@ template<> inline bool PackageContainer<std::list<pkgCache::PkgIterator> >::inse
return false;
_cont.push_back(P);
return true;
-};
+}
template<> inline void PackageContainer<std::list<pkgCache::PkgIterator> >::insert(const_iterator begin, const_iterator end) {
for (const_iterator p = begin; p != end; ++p)
_cont.push_back(*p);
-};
+}
typedef PackageContainer<std::set<pkgCache::PkgIterator> > PackageSet;
typedef PackageContainer<std::list<pkgCache::PkgIterator> > PackageList;
@@ -392,27 +397,27 @@ public:
virtual pkgCache::VerIterator getVer() const = 0;
operator pkgCache::VerIterator(void) { return getVer(); }
- inline pkgCache *Cache() const { return getVer().Cache(); };
- inline unsigned long Index() const {return getVer().Index();};
- inline int CompareVer(const pkgCache::VerIterator &B) const { return getVer().CompareVer(B); };
- inline const char *VerStr() const { return getVer().VerStr(); };
- inline const char *Section() const { return getVer().Section(); };
- inline const char *Arch() const { return getVer().Arch(); };
- inline pkgCache::PkgIterator ParentPkg() const { return getVer().ParentPkg(); };
- inline pkgCache::DescIterator DescriptionList() const { return getVer().DescriptionList(); };
- inline pkgCache::DescIterator TranslatedDescription() const { return getVer().TranslatedDescription(); };
- inline pkgCache::DepIterator DependsList() const { return getVer().DependsList(); };
- inline pkgCache::PrvIterator ProvidesList() const { return getVer().ProvidesList(); };
- inline pkgCache::VerFileIterator FileList() const { return getVer().FileList(); };
- inline bool Downloadable() const { return getVer().Downloadable(); };
- inline const char *PriorityType() const { return getVer().PriorityType(); };
- inline std::string RelStr() const { return getVer().RelStr(); };
- inline bool Automatic() const { return getVer().Automatic(); };
- inline pkgCache::VerFileIterator NewestFile() const { return getVer().NewestFile(); };
+ inline pkgCache *Cache() const { return getVer().Cache(); }
+ inline unsigned long Index() const {return getVer().Index();}
+ inline int CompareVer(const pkgCache::VerIterator &B) const { return getVer().CompareVer(B); }
+ inline const char *VerStr() const { return getVer().VerStr(); }
+ inline const char *Section() const { return getVer().Section(); }
+ inline const char *Arch() const { return getVer().Arch(); }
+ inline pkgCache::PkgIterator ParentPkg() const { return getVer().ParentPkg(); }
+ inline pkgCache::DescIterator DescriptionList() const { return getVer().DescriptionList(); }
+ inline pkgCache::DescIterator TranslatedDescription() const { return getVer().TranslatedDescription(); }
+ inline pkgCache::DepIterator DependsList() const { return getVer().DependsList(); }
+ inline pkgCache::PrvIterator ProvidesList() const { return getVer().ProvidesList(); }
+ inline pkgCache::VerFileIterator FileList() const { return getVer().FileList(); }
+ inline bool Downloadable() const { return getVer().Downloadable(); }
+ inline const char *PriorityType() const { return getVer().PriorityType(); }
+ inline std::string RelStr() const { return getVer().RelStr(); }
+ inline bool Automatic() const { return getVer().Automatic(); }
+ inline pkgCache::VerFileIterator NewestFile() const { return getVer().NewestFile(); }
// we have only valid iterators here
- inline bool end() const { return false; };
+ inline bool end() const { return false; }
- inline pkgCache::Version const * operator->() const { return &*getVer(); };
+ inline pkgCache::Version const * operator->() const { return &*getVer(); }
};
/*}}}*/
@@ -446,7 +451,7 @@ public:
Version SelectVersion;
Modifier (unsigned short const &id, const char * const alias, Position const &pos,
Version const &select) : ID(id), Alias(alias), Pos(pos),
- SelectVersion(select) {};
+ SelectVersion(select) {}
};
static bool FromCommandLine(VersionContainerInterface * const vci, pkgCacheFile &Cache,
@@ -479,14 +484,16 @@ protected: /*{{{*/
/** \brief returns the candidate version of the package
\param Cache to be used to query for information
- \param Pkg we want the candidate version from this package */
+ \param Pkg we want the candidate version from this package
+ \param helper used in this container instance */
static pkgCache::VerIterator getCandidateVer(pkgCacheFile &Cache,
pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper);
/** \brief returns the installed version of the package
\param Cache to be used to query for information
- \param Pkg we want the installed version from this package */
+ \param Pkg we want the installed version from this package
+ \param helper used in this container instance */
static pkgCache::VerIterator getInstalledVer(pkgCacheFile &Cache,
pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper);
/*}}}*/
@@ -507,12 +514,12 @@ public: /*{{{*/
public:
const_iterator(typename Container::const_iterator i) : _iter(i) {}
pkgCache::VerIterator getVer(void) const { return *_iter; }
- inline pkgCache::VerIterator operator*(void) const { return *_iter; };
+ inline pkgCache::VerIterator operator*(void) const { return *_iter; }
operator typename Container::const_iterator(void) const { return _iter; }
inline const_iterator& operator++() { ++_iter; return *this; }
inline const_iterator operator++(int) { const_iterator tmp(*this); operator++(); return tmp; }
- inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; };
- inline bool operator==(const_iterator const &i) const { return _iter == i._iter; };
+ inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; }
+ inline bool operator==(const_iterator const &i) const { return _iter == i._iter; }
friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }
};
class iterator : public VersionContainerInterface::const_iterator,
@@ -521,36 +528,36 @@ public: /*{{{*/
public:
iterator(typename Container::iterator i) : _iter(i) {}
pkgCache::VerIterator getVer(void) const { return *_iter; }
- inline pkgCache::VerIterator operator*(void) const { return *_iter; };
+ inline pkgCache::VerIterator operator*(void) const { return *_iter; }
operator typename Container::iterator(void) const { return _iter; }
operator typename VersionContainer<Container>::const_iterator() { return typename VersionContainer<Container>::const_iterator(_iter); }
inline iterator& operator++() { ++_iter; return *this; }
inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; }
- inline bool operator!=(iterator const &i) const { return _iter != i._iter; };
- inline bool operator==(iterator const &i) const { return _iter == i._iter; };
- inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; };
- inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; };
+ inline bool operator!=(iterator const &i) const { return _iter != i._iter; }
+ inline bool operator==(iterator const &i) const { return _iter == i._iter; }
+ inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; }
+ inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; }
friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
};
/*}}}*/
- bool insert(pkgCache::VerIterator const &V) { if (V.end() == true) return false; _cont.insert(V); return true; };
- template<class Cont> void insert(VersionContainer<Cont> const &vercont) { _cont.insert((typename Cont::const_iterator)vercont.begin(), (typename Cont::const_iterator)vercont.end()); };
- void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); };
- bool empty() const { return _cont.empty(); };
- void clear() { return _cont.clear(); };
+ bool insert(pkgCache::VerIterator const &V) { if (V.end() == true) return false; _cont.insert(V); return true; }
+ template<class Cont> void insert(VersionContainer<Cont> const &vercont) { _cont.insert((typename Cont::const_iterator)vercont.begin(), (typename Cont::const_iterator)vercont.end()); }
+ void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); }
+ bool empty() const { return _cont.empty(); }
+ void clear() { return _cont.clear(); }
//FIXME: on ABI break, replace the first with the second without bool
- void erase(iterator position) { _cont.erase((typename Container::iterator)position); };
- iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); };
- size_t erase(const pkgCache::VerIterator x) { return _cont.erase(x); };
- void erase(iterator first, iterator last) { _cont.erase(first, last); };
- size_t size() const { return _cont.size(); };
-
- const_iterator begin() const { return const_iterator(_cont.begin()); };
- const_iterator end() const { return const_iterator(_cont.end()); };
- iterator begin() { return iterator(_cont.begin()); };
- iterator end() { return iterator(_cont.end()); };
- const_iterator find(pkgCache::VerIterator const &V) const { return const_iterator(_cont.find(V)); };
+ void erase(iterator position) { _cont.erase((typename Container::iterator)position); }
+ iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); }
+ size_t erase(const pkgCache::VerIterator x) { return _cont.erase(x); }
+ void erase(iterator first, iterator last) { _cont.erase(first, last); }
+ size_t size() const { return _cont.size(); }
+
+ const_iterator begin() const { return const_iterator(_cont.begin()); }
+ const_iterator end() const { return const_iterator(_cont.end()); }
+ iterator begin() { return iterator(_cont.begin()); }
+ iterator end() { return iterator(_cont.end()); }
+ const_iterator find(pkgCache::VerIterator const &V) const { return const_iterator(_cont.find(V)); }
/** \brief returns all versions specified on the commandline
@@ -558,6 +565,7 @@ public: /*{{{*/
non specifically requested and executes regex's if needed on names.
\param Cache the packages and versions are in
\param cmdline Command line the versions should be extracted from
+ \param fallback version specification
\param helper responsible for error and message handling */
static VersionContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline,
Version const &fallback, CacheSetHelper &helper) {
@@ -656,7 +664,7 @@ public: /*{{{*/
template<> template<class Cont> void VersionContainer<std::list<pkgCache::VerIterator> >::insert(VersionContainer<Cont> const &vercont) {
for (typename VersionContainer<Cont>::const_iterator v = vercont.begin(); v != vercont.end(); ++v)
_cont.push_back(*v);
-};
+}
// these two are 'inline' as otherwise the linker has problems with seeing these untemplated
// specializations again and again - but we need to see them, so that library users can use them
template<> inline bool VersionContainer<std::list<pkgCache::VerIterator> >::insert(pkgCache::VerIterator const &V) {
@@ -664,11 +672,11 @@ template<> inline bool VersionContainer<std::list<pkgCache::VerIterator> >::inse
return false;
_cont.push_back(V);
return true;
-};
+}
template<> inline void VersionContainer<std::list<pkgCache::VerIterator> >::insert(const_iterator begin, const_iterator end) {
for (const_iterator v = begin; v != end; ++v)
_cont.push_back(*v);
-};
+}
typedef VersionContainer<std::set<pkgCache::VerIterator> > VersionSet;
typedef VersionContainer<std::list<pkgCache::VerIterator> > VersionList;
}
diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index 3ae1e8b1d..2635ede76 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -1,28 +1,30 @@
/*
*/
-#include<config.h>
-
-#include<apt-pkg/init.h>
-#include<apt-pkg/error.h>
-#include<apt-pkg/cdromutl.h>
-#include<apt-pkg/strutl.h>
-#include<apt-pkg/cdrom.h>
-#include<apt-pkg/aptconfiguration.h>
-#include<apt-pkg/configuration.h>
-#include<apt-pkg/fileutl.h>
-
-#include<sstream>
-#include<fstream>
+#include <config.h>
+
+#include <apt-pkg/error.h>
+#include <apt-pkg/cdromutl.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/cdrom.h>
+#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/indexcopy.h>
+
+
+#include <string.h>
+#include <iostream>
+#include <string>
+#include <vector>
+#include <sstream>
+#include <fstream>
#include <sys/stat.h>
-#include <fcntl.h>
#include <dirent.h>
#include <unistd.h>
#include <stdio.h>
#include <algorithm>
#include <dlfcn.h>
-#include "indexcopy.h"
-
#include<apti18n.h>
using namespace std;
@@ -369,7 +371,7 @@ bool pkgCdrom::DropRepeats(vector<string> &List,const char *Name)
// ---------------------------------------------------------------------
/* This takes the list of source list expressed entires and collects
similar ones to form a single entry for each dist */
-void pkgCdrom::ReduceSourcelist(string CD,vector<string> &List)
+void pkgCdrom::ReduceSourcelist(string /*CD*/,vector<string> &List)
{
sort(List.begin(),List.end());
@@ -440,7 +442,7 @@ bool pkgCdrom::WriteDatabase(Configuration &Cnf)
Out.close();
if (FileExists(DFile) == true)
- rename(DFile.c_str(), string(DFile + '~').c_str());
+ rename(DFile.c_str(), (DFile + '~').c_str());
if (rename(NewFile.c_str(),DFile.c_str()) != 0)
return _error->Errno("rename","Failed to rename %s.new to %s",
DFile.c_str(),DFile.c_str());
@@ -553,7 +555,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source)
Out.close();
- rename(File.c_str(),string(File + '~').c_str());
+ rename(File.c_str(), (File + '~').c_str());
if (rename(NewFile.c_str(),File.c_str()) != 0)
return _error->Errno("rename","Failed to rename %s.new to %s",
File.c_str(),File.c_str());
@@ -561,7 +563,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source)
return true;
}
/*}}}*/
-bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log)/*{{{*/
+bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log, bool const interactive)/*{{{*/
{
// Startup
CDROM = _config->FindDir("Acquire::cdrom::mount");
@@ -579,16 +581,19 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s
// Unmount the CD and get the user to put in the one they want
if (_config->FindB("APT::CDROM::NoMount", false) == false)
{
- if(log != NULL)
- log->Update(_("Unmounting CD-ROM\n"), STEP_UNMOUNT);
- UnmountCdrom(CDROM);
-
- if(log != NULL)
+ if (interactive == true)
{
- log->Update(_("Waiting for disc...\n"), STEP_WAIT);
- if(!log->ChangeCdrom()) {
- // user aborted
- return false;
+ if(log != NULL)
+ log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST);
+ UnmountCdrom(CDROM);
+
+ if(log != NULL)
+ {
+ log->Update(_("Waiting for disc...\n"), STEP_WAIT);
+ if(!log->ChangeCdrom()) {
+ // user aborted
+ return false;
+ }
}
}
@@ -602,7 +607,7 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s
// Hash the CD to get an ID
if (log != NULL)
- log->Update(_("Identifying.. "), STEP_IDENT);
+ log->Update(_("Identifying... "), STEP_IDENT);
if (IdentCdrom(CDROM,ident) == false)
{
@@ -634,7 +639,7 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/
{
Configuration Database;
std::string CDROM;
- if (MountAndIdentCDROM(Database, CDROM, ident, log) == false)
+ if (MountAndIdentCDROM(Database, CDROM, ident, log, false) == false)
return false;
if (log != NULL)
@@ -660,11 +665,11 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
{
Configuration Database;
std::string ID, CDROM;
- if (MountAndIdentCDROM(Database, CDROM, ID, log) == false)
+ if (MountAndIdentCDROM(Database, CDROM, ID, log, true) == false)
return false;
if(log != NULL)
- log->Update(_("Scanning disc for index files..\n"),STEP_SCAN);
+ log->Update(_("Scanning disc for index files...\n"),STEP_SCAN);
// Get the CD structure
vector<string> List;
@@ -737,7 +742,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
if (InfoDir.empty() == false &&
FileExists(InfoDir + "/info") == true)
{
- ifstream F(string(InfoDir + "/info").c_str());
+ ifstream F((InfoDir + "/info").c_str());
if (!F == 0)
getline(F,Name);
@@ -933,10 +938,10 @@ pkgUdevCdromDevices::Dlopen() /*{{{*/
// convenience interface, this will just call ScanForRemovable
vector<CdromDevice>
pkgUdevCdromDevices::Scan()
-{
+{
bool CdromOnly = _config->FindB("APT::cdrom::CdromOnly", true);
- return ScanForRemovable(CdromOnly);
-};
+ return ScanForRemovable(CdromOnly);
+}
/*}}}*/
/*{{{*/
vector<CdromDevice>
@@ -981,7 +986,7 @@ pkgUdevCdromDevices::ScanForRemovable(bool CdromOnly)
cdrom.DeviceName = string(devnode);
if (mountpath != "") {
cdrom.MountPath = mountpath;
- string s = string(mountpath);
+ string s = mountpath;
cdrom.Mounted = IsMounted(s);
} else {
cdrom.Mounted = false;
diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h
index c58593550..0f2c2cd02 100644
--- a/apt-pkg/cdrom.h
+++ b/apt-pkg/cdrom.h
@@ -1,9 +1,13 @@
#ifndef PKGLIB_CDROM_H
#define PKGLIB_CDROM_H
+#include <apt-pkg/macros.h>
+
#include<string>
#include<vector>
+#include <stddef.h>
+
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/init.h>
using namespace std;
@@ -71,8 +75,8 @@ class pkgCdrom /*{{{*/
bool Add(pkgCdromStatus *log);
private:
- bool MountAndIdentCDROM(Configuration &Database, std::string &CDROM,
- std::string &ident, pkgCdromStatus * const log);
+ APT_HIDDEN bool MountAndIdentCDROM(Configuration &Database, std::string &CDROM,
+ std::string &ident, pkgCdromStatus * const log, bool const interactive);
};
/*}}}*/
diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc
index 2dea8ffdd..0ee3b765d 100644
--- a/apt-pkg/clean.cc
+++ b/apt-pkg/clean.cc
@@ -16,7 +16,11 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <string>
+#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
diff --git a/apt-pkg/clean.h b/apt-pkg/clean.h
index ad4049e83..930d54a7f 100644
--- a/apt-pkg/clean.h
+++ b/apt-pkg/clean.h
@@ -10,8 +10,13 @@
#ifndef APTPKG_CLEAN_H
#define APTPKG_CLEAN_H
-
+#ifndef APT_10_CLEANER_HEADERS
#include <apt-pkg/pkgcache.h>
+#endif
+
+#include <string>
+
+class pkgCache;
class pkgArchiveCleaner
{
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index 20210ec0a..936e377fb 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -19,7 +19,11 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/strutl.h>
-#include <sys/wait.h>
+#include <stdlib.h>
+#include <string.h>
+#include <iostream>
+#include <string>
+#include <vector>
#include <sys/statvfs.h>
#include <dirent.h>
#include <fcntl.h>
@@ -42,11 +46,16 @@ bool IsMounted(string &Path)
{
if (Path.empty() == true)
return false;
-
+
// Need that trailing slash for directories
if (Path[Path.length() - 1] != '/')
Path += '/';
-
+
+ // if the path has a ".disk" directory we treat it as mounted
+ // this way even extracted copies of disks are recognized
+ if (DirectoryExists(Path + ".disk/") == true)
+ return true;
+
/* First we check if the path is actually mounted, we do this by
stating the path and the previous directory (careful of links!)
and comparing their device fields. */
@@ -66,7 +75,13 @@ bool IsMounted(string &Path)
leave /etc/mtab inconsitant. We drop all messages this produces. */
bool UnmountCdrom(string Path)
{
- if (IsMounted(Path) == false)
+ // do not generate errors, even if the mountpoint does not exist
+ // the mountpoint might be auto-created by the mount command
+ // and a non-existing mountpoint is surely not mounted
+ _error->PushToStack();
+ bool const mounted = IsMounted(Path);
+ _error->RevertToStack();
+ if (mounted == false)
return true;
for (int i=0;i<3;i++)
@@ -78,8 +93,9 @@ bool UnmountCdrom(string Path)
if (Child == 0)
{
// Make all the fds /dev/null
- for (int I = 0; I != 3; I++)
- dup2(open("/dev/null",O_RDWR),I);
+ int const null_fd = open("/dev/null",O_RDWR);
+ for (int I = 0; I != 3; ++I)
+ dup2(null_fd, I);
if (_config->Exists("Acquire::cdrom::"+Path+"::UMount") == true)
{
@@ -113,19 +129,24 @@ bool UnmountCdrom(string Path)
/* We fork mount and drop all messages */
bool MountCdrom(string Path, string DeviceName)
{
- if (IsMounted(Path) == true)
+ // do not generate errors, even if the mountpoint does not exist
+ // the mountpoint might be auto-created by the mount command
+ _error->PushToStack();
+ bool const mounted = IsMounted(Path);
+ _error->RevertToStack();
+ if (mounted == true)
return true;
-
+
int Child = ExecFork();
// The child
if (Child == 0)
{
// Make all the fds /dev/null
- int null_fd = open("/dev/null",O_RDWR);
- for (int I = 0; I != 3; I++)
+ int const null_fd = open("/dev/null",O_RDWR);
+ for (int I = 0; I != 3; ++I)
dup2(null_fd, I);
-
+
if (_config->Exists("Acquire::cdrom::"+Path+"::Mount") == true)
{
if (system(_config->Find("Acquire::cdrom::"+Path+"::Mount").c_str()) != 0)
@@ -242,37 +263,34 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
return true;
}
/*}}}*/
-
// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/
string FindMountPointForDevice(const char *devnode)
{
- char buf[255];
- char *out[10];
- int i=0;
-
// this is the order that mount uses as well
- const char *mount[] = { "/etc/mtab",
- "/proc/mount",
- NULL };
+ std::vector<std::string> const mounts = _config->FindVector("Dir::state::MountPoints", "/etc/mtab,/proc/mount");
- for (i=0; mount[i] != NULL; i++) {
- if (FileExists(mount[i])) {
- FILE *f=fopen(mount[i], "r");
- while ( fgets(buf, sizeof(buf), f) != NULL) {
- if (strncmp(buf, devnode, strlen(devnode)) == 0) {
- if(TokSplitString(' ', buf, out, 10))
- {
- fclose(f);
- // unescape the \0XXX chars in the path
- string mount_point = out[1];
- return DeEscapeString(mount_point);
- }
- }
- }
- fclose(f);
+ for (std::vector<std::string>::const_iterator m = mounts.begin(); m != mounts.end(); ++m)
+ if (FileExists(*m) == true)
+ {
+ char * line = NULL;
+ size_t line_len = 0;
+ FILE * f = fopen(m->c_str(), "r");
+ while(getline(&line, &line_len, f) != -1)
+ {
+ char * out[] = { NULL, NULL, NULL };
+ TokSplitString(' ', line, out, 3);
+ if (out[2] != NULL || out[1] == NULL || out[0] == NULL)
+ continue;
+ if (strcmp(out[0], devnode) != 0)
+ continue;
+ fclose(f);
+ // unescape the \0XXX chars in the path
+ string mount_point = out[1];
+ return DeEscapeString(mount_point);
+ }
+ fclose(f);
}
- }
-
+
return string();
}
/*}}}*/
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index ed5800007..3799c822d 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -18,6 +18,11 @@
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <string>
+
#include <apti18n.h>
/*}}}*/
using namespace std;
diff --git a/apt-pkg/contrib/cmndline.h b/apt-pkg/contrib/cmndline.h
index 180276633..143df58b2 100644
--- a/apt-pkg/contrib/cmndline.h
+++ b/apt-pkg/contrib/cmndline.h
@@ -44,6 +44,8 @@
#ifndef PKGLIB_CMNDLINE_H
#define PKGLIB_CMNDLINE_H
+#include <apt-pkg/macros.h>
+
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/configuration.h>
#endif
@@ -80,14 +82,14 @@ class CommandLine
bool Parse(int argc,const char **argv);
void ShowHelp();
- unsigned int FileSize() const;
+ unsigned int FileSize() const APT_PURE;
bool DispatchArg(Dispatch *List,bool NoMatch = true);
static char const * GetCommand(Dispatch const * const Map,
- unsigned int const argc, char const * const * const argv);
+ unsigned int const argc, char const * const * const argv) APT_PURE;
static CommandLine::Args MakeArgs(char ShortOpt, char const *LongOpt,
- char const *ConfName, unsigned long Flags);
+ char const *ConfName, unsigned long Flags) APT_CONST;
CommandLine(Args *AList,Configuration *Conf);
~CommandLine();
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 4ef4663c0..00f6ad0f9 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -21,10 +21,18 @@
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
-
+#include <apt-pkg/macros.h>
+
+#include <ctype.h>
+#include <regex.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <algorithm>
+#include <string>
#include <vector>
#include <fstream>
-#include <iostream>
#include <apti18n.h>
@@ -42,8 +50,7 @@ Configuration::Configuration() : ToFree(true)
}
Configuration::Configuration(const Item *Root) : Root((Item *)Root), ToFree(false)
{
-};
-
+}
/*}}}*/
// Configuration::~Configuration - Destructor /*{{{*/
// ---------------------------------------------------------------------
@@ -246,12 +253,18 @@ string Configuration::FindDir(const char *Name,const char *Default) const
// Configuration::FindVector - Find a vector of values /*{{{*/
// ---------------------------------------------------------------------
/* Returns a vector of config values under the given item */
-vector<string> Configuration::FindVector(const char *Name) const
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
+vector<string> Configuration::FindVector(const char *Name) const { return FindVector(Name, ""); }
+#endif
+vector<string> Configuration::FindVector(const char *Name, std::string const &Default) const
{
vector<string> Vec;
const Item *Top = Lookup(Name);
if (Top == NULL)
- return Vec;
+ return VectorizeString(Default, ',');
+
+ if (Top->Value.empty() == false)
+ return VectorizeString(Top->Value, ',');
Item *I = Top->Child;
while(I != NULL)
@@ -259,6 +272,9 @@ vector<string> Configuration::FindVector(const char *Name) const
Vec.push_back(I->Value);
I = I->Next;
}
+ if (Vec.empty() == true)
+ return VectorizeString(Default, ',');
+
return Vec;
}
/*}}}*/
diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h
index 8e09ea0a6..c256139f4 100644
--- a/apt-pkg/contrib/configuration.h
+++ b/apt-pkg/contrib/configuration.h
@@ -74,8 +74,22 @@ class Configuration
std::string Find(std::string const &Name, std::string const &Default) const {return Find(Name.c_str(),Default.c_str());};
std::string FindFile(const char *Name,const char *Default = 0) const;
std::string FindDir(const char *Name,const char *Default = 0) const;
+ /** return a list of child options
+ *
+ * Options like Acquire::Languages are handled as lists which
+ * can be overridden and have a default. For the later two a comma
+ * separated list of values is supported.
+ *
+ * \param Name of the parent node
+ * \param Default list of values separated by commas */
+ std::vector<std::string> FindVector(const char *Name, std::string const &Default) const;
+ std::vector<std::string> FindVector(std::string const &Name, std::string const &Default) const { return FindVector(Name.c_str(), Default); };
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ std::vector<std::string> FindVector(const char *Name) const { return FindVector(Name, ""); };
+#else
std::vector<std::string> FindVector(const char *Name) const;
- std::vector<std::string> FindVector(std::string const &Name) const { return FindVector(Name.c_str()); };
+#endif
+ std::vector<std::string> FindVector(std::string const &Name) const { return FindVector(Name.c_str(), ""); };
int FindI(const char *Name,int const &Default = 0) const;
int FindI(std::string const &Name,int const &Default = 0) const {return FindI(Name.c_str(),Default);};
bool FindB(const char *Name,bool const &Default = false) const;
diff --git a/apt-pkg/contrib/crc-16.h b/apt-pkg/contrib/crc-16.h
index 702de40b2..08acdafb7 100644
--- a/apt-pkg/contrib/crc-16.h
+++ b/apt-pkg/contrib/crc-16.h
@@ -10,8 +10,10 @@
#ifndef APTPKG_CRC16_H
#define APTPKG_CRC16_H
+#include <apt-pkg/macros.h>
+
#define INIT_FCS 0xffff
unsigned short AddCRC16(unsigned short fcs, void const *buf,
- unsigned long long len);
+ unsigned long long len) APT_PURE;
#endif
diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc
index d457781c3..892cd4874 100644
--- a/apt-pkg/contrib/error.cc
+++ b/apt-pkg/contrib/error.cc
@@ -17,12 +17,14 @@
#include <apt-pkg/error.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <list>
#include <iostream>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-
#include <string>
#include <cstring>
@@ -223,7 +225,7 @@ void GlobalError::DumpErrors(std::ostream &out, MsgType const &threshold,
void GlobalError::Discard() {
Messages.clear();
PendingFlag = false;
-};
+}
/*}}}*/
// GlobalError::empty - does our error list include anything? /*{{{*/
bool GlobalError::empty(MsgType const &trashhold) const {
diff --git a/apt-pkg/contrib/error.h b/apt-pkg/contrib/error.h
index bcee70b1a..ed8c19153 100644
--- a/apt-pkg/contrib/error.h
+++ b/apt-pkg/contrib/error.h
@@ -46,6 +46,7 @@
#include <list>
#include <string>
+#include <stddef.h>
#include <stdarg.h>
class GlobalError /*{{{*/
@@ -73,7 +74,7 @@ public: /*{{{*/
*
* \return \b false
*/
- bool FatalE(const char *Function,const char *Description,...) __like_printf(3) __cold;
+ bool FatalE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD;
/** \brief add an Error message with errno to the list
*
@@ -82,7 +83,7 @@ public: /*{{{*/
*
* \return \b false
*/
- bool Errno(const char *Function,const char *Description,...) __like_printf(3) __cold;
+ bool Errno(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD;
/** \brief add a warning message with errno to the list
*
@@ -94,7 +95,7 @@ public: /*{{{*/
*
* \return \b false
*/
- bool WarningE(const char *Function,const char *Description,...) __like_printf(3) __cold;
+ bool WarningE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD;
/** \brief add a notice message with errno to the list
*
@@ -103,7 +104,7 @@ public: /*{{{*/
*
* \return \b false
*/
- bool NoticeE(const char *Function,const char *Description,...) __like_printf(3) __cold;
+ bool NoticeE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD;
/** \brief add a debug message with errno to the list
*
@@ -112,7 +113,7 @@ public: /*{{{*/
*
* \return \b false
*/
- bool DebugE(const char *Function,const char *Description,...) __like_printf(3) __cold;
+ bool DebugE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD;
/** \brief adds an errno message with the given type
*
@@ -121,7 +122,7 @@ public: /*{{{*/
* \param Description of the error
*/
bool InsertErrno(MsgType const &type, const char* Function,
- const char* Description,...) __like_printf(4) __cold;
+ const char* Description,...) APT_PRINTF(4) APT_COLD;
/** \brief adds an errno message with the given type
*
@@ -140,7 +141,7 @@ public: /*{{{*/
*/
bool InsertErrno(MsgType type, const char* Function,
const char* Description, va_list &args,
- int const errsv, size_t &msgSize);
+ int const errsv, size_t &msgSize) APT_COLD;
/** \brief add an fatal error message to the list
*
@@ -155,7 +156,7 @@ public: /*{{{*/
*
* \return \b false
*/
- bool Fatal(const char *Description,...) __like_printf(2) __cold;
+ bool Fatal(const char *Description,...) APT_PRINTF(2) APT_COLD;
/** \brief add an Error message to the list
*
@@ -163,7 +164,7 @@ public: /*{{{*/
*
* \return \b false
*/
- bool Error(const char *Description,...) __like_printf(2) __cold;
+ bool Error(const char *Description,...) APT_PRINTF(2) APT_COLD;
/** \brief add a warning message to the list
*
@@ -174,7 +175,7 @@ public: /*{{{*/
*
* \return \b false
*/
- bool Warning(const char *Description,...) __like_printf(2) __cold;
+ bool Warning(const char *Description,...) APT_PRINTF(2) APT_COLD;
/** \brief add a notice message to the list
*
@@ -187,7 +188,7 @@ public: /*{{{*/
*
* \return \b false
*/
- bool Notice(const char *Description,...) __like_printf(2) __cold;
+ bool Notice(const char *Description,...) APT_PRINTF(2) APT_COLD;
/** \brief add a debug message to the list
*
@@ -195,14 +196,14 @@ public: /*{{{*/
*
* \return \b false
*/
- bool Debug(const char *Description,...) __like_printf(2) __cold;
+ bool Debug(const char *Description,...) APT_PRINTF(2) APT_COLD;
/** \brief adds an error message with the given type
*
* \param type of the error message
* \param Description of the error
*/
- bool Insert(MsgType const &type, const char* Description,...) __like_printf(3) __cold;
+ bool Insert(MsgType const &type, const char* Description,...) APT_PRINTF(3) APT_COLD;
/** \brief adds an error message with the given type
*
@@ -218,13 +219,13 @@ public: /*{{{*/
* should call this method again in that case
*/
bool Insert(MsgType type, const char* Description,
- va_list &args, size_t &msgSize) __cold;
+ va_list &args, size_t &msgSize) APT_COLD;
/** \brief is an error in the list?
*
* \return \b true if an error is included in the list, \b false otherwise
*/
- inline bool PendingError() const {return PendingFlag;};
+ inline bool PendingError() const APT_PURE {return PendingFlag;};
/** \brief is the list empty?
*
@@ -232,11 +233,11 @@ public: /*{{{*/
* if you want to check if also no notices happened set the parameter
* flag to \b false.
*
- * \param WithoutNotice does notices count, default is \b true, so no
+ * \param threshold minimim level considered
*
* \return \b true if an the list is empty, \b false otherwise
*/
- bool empty(MsgType const &trashhold = WARNING) const;
+ bool empty(MsgType const &threshold = WARNING) const APT_PURE;
/** \brief returns and removes the first (or last) message in the list
*
@@ -302,7 +303,7 @@ public: /*{{{*/
void MergeWithStack();
/** \brief return the deep of the stack */
- size_t StackCount() const {
+ size_t StackCount() const APT_PURE {
return Stacks.size();
}
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 52411a762..69a675648 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1,6 +1,5 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: fileutl.cc,v 1.42 2002/09/14 05:29:22 jgg Exp $
/* ######################################################################
File Utilities
@@ -26,16 +25,22 @@
#include <apt-pkg/sptr.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/configuration.h>
-
+#include <apt-pkg/macros.h>
+
+#include <ctype.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <sys/select.h>
+#include <time.h>
+#include <string>
+#include <vector>
#include <cstdlib>
#include <cstring>
#include <cstdio>
-
#include <iostream>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
-#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <dirent.h>
@@ -52,6 +57,10 @@
#ifdef HAVE_BZ2
#include <bzlib.h>
#endif
+#ifdef HAVE_LZMA
+ #include <stdint.h>
+ #include <lzma.h>
+#endif
#ifdef WORDS_BIGENDIAN
#include <inttypes.h>
@@ -62,54 +71,6 @@
using namespace std;
-class FileFdPrivate {
- public:
-#ifdef HAVE_ZLIB
- gzFile gz;
-#else
- void* gz;
-#endif
-#ifdef HAVE_BZ2
- BZFILE* bz2;
-#else
- void* bz2;
-#endif
- int compressed_fd;
- pid_t compressor_pid;
- bool pipe;
- APT::Configuration::Compressor compressor;
- unsigned int openmode;
- unsigned long long seekpos;
- FileFdPrivate() : gz(NULL), bz2(NULL),
- compressed_fd(-1), compressor_pid(-1), pipe(false),
- openmode(0), seekpos(0) {};
- bool CloseDown(std::string const &FileName)
- {
- bool Res = true;
-#ifdef HAVE_ZLIB
- if (gz != NULL) {
- int const e = gzclose(gz);
- gz = NULL;
- // gzdclose() on empty files always fails with "buffer error" here, ignore that
- if (e != 0 && e != Z_BUF_ERROR)
- Res &= _error->Errno("close",_("Problem closing the gzip file %s"), FileName.c_str());
- }
-#endif
-#ifdef HAVE_BZ2
- if (bz2 != NULL) {
- BZ2_bzclose(bz2);
- bz2 = NULL;
- }
-#endif
- if (compressor_pid > 0)
- ExecWait(compressor_pid, "FileFdCompressor", true);
- compressor_pid = -1;
-
- return Res;
- }
- ~FileFdPrivate() { CloseDown(""); }
-};
-
// RunScripts - Run a set of scripts from a configuration subtree /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -143,7 +104,11 @@ bool RunScripts(const char *Cnf)
{
if (Opts->Value.empty() == true)
continue;
-
+
+ if(_config->FindB("Debug::RunScripts", false) == true)
+ std::clog << "Running external script: '"
+ << Opts->Value << "'" << std::endl;
+
if (system(Opts->Value.c_str()) != 0)
_exit(100+Count);
}
@@ -874,13 +839,129 @@ bool ExecWait(pid_t Pid,const char *Name,bool Reap)
}
/*}}}*/
+class FileFdPrivate { /*{{{*/
+ public:
+#ifdef HAVE_ZLIB
+ gzFile gz;
+#endif
+#ifdef HAVE_BZ2
+ BZFILE* bz2;
+#endif
+#ifdef HAVE_LZMA
+ struct LZMAFILE {
+ FILE* file;
+ uint8_t buffer[4096];
+ lzma_stream stream;
+ lzma_ret err;
+ bool eof;
+ bool compressing;
+
+ LZMAFILE() : file(NULL), eof(false), compressing(false) {}
+ ~LZMAFILE() {
+ if (compressing == true)
+ {
+ for (;;) {
+ stream.avail_out = sizeof(buffer)/sizeof(buffer[0]);
+ stream.next_out = buffer;
+ err = lzma_code(&stream, LZMA_FINISH);
+ if (err != LZMA_OK && err != LZMA_STREAM_END)
+ {
+ _error->Error("~LZMAFILE: Compress finalisation failed");
+ break;
+ }
+ size_t const n = sizeof(buffer)/sizeof(buffer[0]) - stream.avail_out;
+ if (n && fwrite(buffer, 1, n, file) != n)
+ {
+ _error->Errno("~LZMAFILE",_("Write error"));
+ break;
+ }
+ if (err == LZMA_STREAM_END)
+ break;
+ }
+ }
+ lzma_end(&stream);
+ fclose(file);
+ }
+ };
+ LZMAFILE* lzma;
+#endif
+ int compressed_fd;
+ pid_t compressor_pid;
+ bool pipe;
+ APT::Configuration::Compressor compressor;
+ unsigned int openmode;
+ unsigned long long seekpos;
+ FileFdPrivate() :
+#ifdef HAVE_ZLIB
+ gz(NULL),
+#endif
+#ifdef HAVE_BZ2
+ bz2(NULL),
+#endif
+#ifdef HAVE_LZMA
+ lzma(NULL),
+#endif
+ compressed_fd(-1), compressor_pid(-1), pipe(false),
+ openmode(0), seekpos(0) {};
+ bool InternalClose(std::string const &FileName)
+ {
+ if (false)
+ /* dummy so that the rest can be 'else if's */;
+#ifdef HAVE_ZLIB
+ else if (gz != NULL) {
+ int const e = gzclose(gz);
+ gz = NULL;
+ // gzdclose() on empty files always fails with "buffer error" here, ignore that
+ if (e != 0 && e != Z_BUF_ERROR)
+ return _error->Errno("close",_("Problem closing the gzip file %s"), FileName.c_str());
+ }
+#endif
+#ifdef HAVE_BZ2
+ else if (bz2 != NULL) {
+ BZ2_bzclose(bz2);
+ bz2 = NULL;
+ }
+#endif
+#ifdef HAVE_LZMA
+ else if (lzma != NULL) {
+ delete lzma;
+ lzma = NULL;
+ }
+#endif
+ return true;
+ }
+ bool CloseDown(std::string const &FileName)
+ {
+ bool const Res = InternalClose(FileName);
+
+ if (compressor_pid > 0)
+ ExecWait(compressor_pid, "FileFdCompressor", true);
+ compressor_pid = -1;
+
+ return Res;
+ }
+ bool InternalStream() const {
+ return false
+#ifdef HAVE_BZ2
+ || bz2 != NULL
+#endif
+#ifdef HAVE_LZMA
+ || lzma != NULL
+#endif
+ ;
+ }
+
+
+ ~FileFdPrivate() { CloseDown(""); }
+};
+ /*}}}*/
// FileFd::Open - Open a file /*{{{*/
// ---------------------------------------------------------------------
/* The most commonly used open mode combinations are given with Mode */
-bool FileFd::Open(string FileName,unsigned int const Mode,CompressMode Compress, unsigned long const Perms)
+bool FileFd::Open(string FileName,unsigned int const Mode,CompressMode Compress, unsigned long const AccessMode)
{
if (Mode == ReadOnlyGzip)
- return Open(FileName, ReadOnly, Gzip, Perms);
+ return Open(FileName, ReadOnly, Gzip, AccessMode);
if (Compress == Auto && (Mode & WriteOnly) == WriteOnly)
return FileFdError("Autodetection on %s only works in ReadOnly openmode!", FileName.c_str());
@@ -891,7 +972,7 @@ bool FileFd::Open(string FileName,unsigned int const Mode,CompressMode Compress,
{
for (; compressor != compressors.end(); ++compressor)
{
- std::string file = std::string(FileName).append(compressor->Extension);
+ std::string file = FileName + compressor->Extension;
if (FileExists(file) == false)
continue;
FileName = file;
@@ -947,9 +1028,9 @@ bool FileFd::Open(string FileName,unsigned int const Mode,CompressMode Compress,
if (compressor == compressors.end())
return FileFdError("Can't find a match for specified compressor mode for file %s", FileName.c_str());
- return Open(FileName, Mode, *compressor, Perms);
+ return Open(FileName, Mode, *compressor, AccessMode);
}
-bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Compressor const &compressor, unsigned long const Perms)
+bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Compressor const &compressor, unsigned long const AccessMode)
{
Close();
Flags = AutoClose;
@@ -986,6 +1067,13 @@ bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Co
if_FLAGGED_SET(Exclusive, O_EXCL);
#undef if_FLAGGED_SET
+ // umask() will always set the umask and return the previous value, so
+ // we first set the umask and then reset it to the old value
+ mode_t CurrentUmask = umask(0);
+ umask(CurrentUmask);
+ // calculate the actual file permissions (just like open/creat)
+ mode_t FilePermissions = (AccessMode & ~CurrentUmask);
+
if ((Mode & Atomic) == Atomic)
{
char *name = strdup((FileName + ".XXXXXX").c_str());
@@ -999,11 +1087,11 @@ bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Co
TemporaryFileName = string(name);
free(name);
- if(Perms != 600 && fchmod(iFd, Perms) == -1)
+ if(FilePermissions != 600 && fchmod(iFd, FilePermissions) == -1)
return FileFdErrno("fchmod", "Could not change permissions for temporary file %s", TemporaryFileName.c_str());
}
else
- iFd = open(FileName.c_str(), fileflags, Perms);
+ iFd = open(FileName.c_str(), fileflags, FilePermissions);
this->FileName = FileName;
if (iFd == -1 || OpenInternDescriptor(Mode, compressor) == false)
@@ -1061,30 +1149,12 @@ bool FileFd::OpenDescriptor(int Fd, unsigned int const Mode, APT::Configuration:
{
Close();
Flags = (AutoClose) ? FileFd::AutoClose : 0;
- if (AutoClose == false && (
-#ifdef HAVE_ZLIB
- compressor.Name == "gzip" ||
-#endif
-#ifdef HAVE_BZ2
- compressor.Name == "bzip2" ||
-#endif
- false))
- {
- // Need to duplicate fd here or gzclose for cleanup will close the fd as well
- iFd = dup(Fd);
- }
- else
- iFd = Fd;
+ iFd = Fd;
this->FileName = "";
- if (Fd == -1 || OpenInternDescriptor(Mode, compressor) == false)
+ if (OpenInternDescriptor(Mode, compressor) == false)
{
if (iFd != -1 && (
-#ifdef HAVE_ZLIB
- compressor.Name == "gzip" ||
-#endif
-#ifdef HAVE_BZ2
- compressor.Name == "bzip2" ||
-#endif
+ (Flags & Compressed) == Compressed ||
AutoClose == true))
{
close (iFd);
@@ -1096,52 +1166,121 @@ bool FileFd::OpenDescriptor(int Fd, unsigned int const Mode, APT::Configuration:
}
bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor)
{
+ if (iFd == -1)
+ return false;
if (compressor.Name == "." || compressor.Binary.empty() == true)
return true;
+#if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA
+ // the API to open files is similar, so setup to avoid code duplicates later
+ // and while at it ensure that we close before opening (if its a reopen)
+ void* (*compress_open)(int, const char *) = NULL;
+ if (false)
+ /* dummy so that the rest can be 'else if's */;
+#define APT_COMPRESS_INIT(NAME,OPEN) \
+ else if (compressor.Name == NAME) \
+ { \
+ compress_open = (void*(*)(int, const char *)) OPEN; \
+ if (d != NULL) d->InternalClose(FileName); \
+ }
+#ifdef HAVE_ZLIB
+ APT_COMPRESS_INIT("gzip", gzdopen)
+#endif
+#ifdef HAVE_BZ2
+ APT_COMPRESS_INIT("bzip2", BZ2_bzdopen)
+#endif
+#ifdef HAVE_LZMA
+ APT_COMPRESS_INIT("xz", fdopen)
+ APT_COMPRESS_INIT("lzma", fdopen)
+#endif
+#undef APT_COMPRESS_INIT
+#endif
+
if (d == NULL)
{
d = new FileFdPrivate();
d->openmode = Mode;
d->compressor = compressor;
+#if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA
+ if ((Flags & AutoClose) != AutoClose && compress_open != NULL)
+ {
+ // Need to duplicate fd here or gz/bz2 close for cleanup will close the fd as well
+ int const internFd = dup(iFd);
+ if (internFd == -1)
+ return FileFdErrno("OpenInternDescriptor", _("Could not open file descriptor %d"), iFd);
+ iFd = internFd;
+ }
+#endif
}
-#ifdef HAVE_ZLIB
- if (compressor.Name == "gzip")
+#if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA
+ if (compress_open != NULL)
{
- if (d->gz != NULL)
- {
- gzclose(d->gz);
- d->gz = NULL;
- }
+ void* compress_struct = NULL;
if ((Mode & ReadWrite) == ReadWrite)
- d->gz = gzdopen(iFd, "r+");
+ compress_struct = compress_open(iFd, "r+");
else if ((Mode & WriteOnly) == WriteOnly)
- d->gz = gzdopen(iFd, "w");
+ compress_struct = compress_open(iFd, "w");
else
- d->gz = gzdopen(iFd, "r");
- if (d->gz == NULL)
+ compress_struct = compress_open(iFd, "r");
+ if (compress_struct == NULL)
return false;
- Flags |= Compressed;
- return true;
- }
+
+ if (false)
+ /* dummy so that the rest can be 'else if's */;
+#ifdef HAVE_ZLIB
+ else if (compressor.Name == "gzip")
+ d->gz = (gzFile) compress_struct;
#endif
#ifdef HAVE_BZ2
- if (compressor.Name == "bzip2")
- {
- if (d->bz2 != NULL)
+ else if (compressor.Name == "bzip2")
+ d->bz2 = (BZFILE*) compress_struct;
+#endif
+#ifdef HAVE_LZMA
+ else if (compressor.Name == "xz" || compressor.Name == "lzma")
{
- BZ2_bzclose(d->bz2);
- d->bz2 = NULL;
+ uint32_t const xzlevel = 6;
+ uint64_t const memlimit = UINT64_MAX;
+ if (d->lzma == NULL)
+ d->lzma = new FileFdPrivate::LZMAFILE;
+ d->lzma->file = (FILE*) compress_struct;
+ d->lzma->stream = LZMA_STREAM_INIT;
+
+ if ((Mode & ReadWrite) == ReadWrite)
+ return FileFdError("ReadWrite mode is not supported for file %s", FileName.c_str());
+
+ if ((Mode & WriteOnly) == WriteOnly)
+ {
+ if (compressor.Name == "xz")
+ {
+ if (lzma_easy_encoder(&d->lzma->stream, xzlevel, LZMA_CHECK_CRC32) != LZMA_OK)
+ return false;
+ }
+ else
+ {
+ lzma_options_lzma options;
+ lzma_lzma_preset(&options, xzlevel);
+ if (lzma_alone_encoder(&d->lzma->stream, &options) != LZMA_OK)
+ return false;
+ }
+ d->lzma->compressing = true;
+ }
+ else
+ {
+ if (compressor.Name == "xz")
+ {
+ if (lzma_auto_decoder(&d->lzma->stream, memlimit, 0) != LZMA_OK)
+ return false;
+ }
+ else
+ {
+ if (lzma_alone_decoder(&d->lzma->stream, memlimit) != LZMA_OK)
+ return false;
+ }
+ d->lzma->compressing = false;
+ }
}
- if ((Mode & ReadWrite) == ReadWrite)
- d->bz2 = BZ2_bzdopen(iFd, "r+");
- else if ((Mode & WriteOnly) == WriteOnly)
- d->bz2 = BZ2_bzdopen(iFd, "w");
- else
- d->bz2 = BZ2_bzdopen(iFd, "r");
- if (d->bz2 == NULL)
- return false;
+#endif
Flags |= Compressed;
return true;
}
@@ -1198,7 +1337,7 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
}
else
{
- if (FileName.empty() == true)
+ if (d->compressed_fd != -1)
dup2(d->compressed_fd,STDIN_FILENO);
dup2(Pipe[1],STDOUT_FILENO);
}
@@ -1267,24 +1406,68 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
*((char *)To) = '\0';
do
{
+ if (false)
+ /* dummy so that the rest can be 'else if's */;
#ifdef HAVE_ZLIB
- if (d != NULL && d->gz != NULL)
+ else if (d != NULL && d->gz != NULL)
Res = gzread(d->gz,To,Size);
- else
#endif
#ifdef HAVE_BZ2
- if (d != NULL && d->bz2 != NULL)
+ else if (d != NULL && d->bz2 != NULL)
Res = BZ2_bzread(d->bz2,To,Size);
- else
#endif
+#ifdef HAVE_LZMA
+ else if (d != NULL && d->lzma != NULL)
+ {
+ if (d->lzma->eof == true)
+ break;
+
+ d->lzma->stream.next_out = (uint8_t *) To;
+ d->lzma->stream.avail_out = Size;
+ if (d->lzma->stream.avail_in == 0)
+ {
+ d->lzma->stream.next_in = d->lzma->buffer;
+ d->lzma->stream.avail_in = fread(d->lzma->buffer, 1, sizeof(d->lzma->buffer)/sizeof(d->lzma->buffer[0]), d->lzma->file);
+ }
+ d->lzma->err = lzma_code(&d->lzma->stream, LZMA_RUN);
+ if (d->lzma->err == LZMA_STREAM_END)
+ {
+ d->lzma->eof = true;
+ Res = Size - d->lzma->stream.avail_out;
+ }
+ else if (d->lzma->err != LZMA_OK)
+ {
+ Res = -1;
+ errno = 0;
+ }
+ else
+ {
+ Res = Size - d->lzma->stream.avail_out;
+ if (Res == 0)
+ {
+ // lzma run was okay, but produced no output…
+ Res = -1;
+ errno = EINTR;
+ }
+ }
+ }
+#endif
+ else
Res = read(iFd,To,Size);
if (Res < 0)
{
if (errno == EINTR)
+ {
+ // trick the while-loop into running again
+ Res = 1;
+ errno = 0;
continue;
+ }
+ if (false)
+ /* dummy so that the rest can be 'else if's */;
#ifdef HAVE_ZLIB
- if (d != NULL && d->gz != NULL)
+ else if (d != NULL && d->gz != NULL)
{
int err;
char const * const errmsg = gzerror(d->gz, &err);
@@ -1293,7 +1476,7 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
}
#endif
#ifdef HAVE_BZ2
- if (d != NULL && d->bz2 != NULL)
+ else if (d != NULL && d->bz2 != NULL)
{
int err;
char const * const errmsg = BZ2_bzerror(d->bz2, &err);
@@ -1301,6 +1484,10 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
return FileFdError("BZ2_bzread: %s (%d: %s)", _("Read error"), err, errmsg);
}
#endif
+#ifdef HAVE_LZMA
+ else if (d != NULL && d->lzma != NULL)
+ return FileFdError("lzma_read: %s (%d)", _("Read error"), d->lzma->err);
+#endif
return FileFdErrno("read",_("Read error"));
}
@@ -1364,23 +1551,45 @@ bool FileFd::Write(const void *From,unsigned long long Size)
errno = 0;
do
{
+ if (false)
+ /* dummy so that the rest can be 'else if's */;
#ifdef HAVE_ZLIB
- if (d != NULL && d->gz != NULL)
- Res = gzwrite(d->gz,From,Size);
- else
+ else if (d != NULL && d->gz != NULL)
+ Res = gzwrite(d->gz,From,Size);
#endif
#ifdef HAVE_BZ2
- if (d != NULL && d->bz2 != NULL)
- Res = BZ2_bzwrite(d->bz2,(void*)From,Size);
- else
+ else if (d != NULL && d->bz2 != NULL)
+ Res = BZ2_bzwrite(d->bz2,(void*)From,Size);
+#endif
+#ifdef HAVE_LZMA
+ else if (d != NULL && d->lzma != NULL)
+ {
+ d->lzma->stream.next_in = (uint8_t *)From;
+ d->lzma->stream.avail_in = Size;
+ d->lzma->stream.next_out = d->lzma->buffer;
+ d->lzma->stream.avail_out = sizeof(d->lzma->buffer)/sizeof(d->lzma->buffer[0]);
+ d->lzma->err = lzma_code(&d->lzma->stream, LZMA_RUN);
+ if (d->lzma->err != LZMA_OK)
+ return false;
+ size_t const n = sizeof(d->lzma->buffer)/sizeof(d->lzma->buffer[0]) - d->lzma->stream.avail_out;
+ size_t const m = (n == 0) ? 0 : fwrite(d->lzma->buffer, 1, n, d->lzma->file);
+ if (m != n)
+ Res = -1;
+ else
+ Res = Size - d->lzma->stream.avail_in;
+ }
#endif
- Res = write(iFd,From,Size);
+ else
+ Res = write(iFd,From,Size);
+
if (Res < 0 && errno == EINTR)
continue;
if (Res < 0)
{
+ if (false)
+ /* dummy so that the rest can be 'else if's */;
#ifdef HAVE_ZLIB
- if (d != NULL && d->gz != NULL)
+ else if (d != NULL && d->gz != NULL)
{
int err;
char const * const errmsg = gzerror(d->gz, &err);
@@ -1389,7 +1598,7 @@ bool FileFd::Write(const void *From,unsigned long long Size)
}
#endif
#ifdef HAVE_BZ2
- if (d != NULL && d->bz2 != NULL)
+ else if (d != NULL && d->bz2 != NULL)
{
int err;
char const * const errmsg = BZ2_bzerror(d->bz2, &err);
@@ -1397,10 +1606,14 @@ bool FileFd::Write(const void *From,unsigned long long Size)
return FileFdError("BZ2_bzwrite: %s (%d: %s)", _("Write error"), err, errmsg);
}
#endif
+#ifdef HAVE_LZMA
+ else if (d != NULL && d->lzma != NULL)
+ return FileFdErrno("lzma_fwrite", _("Write error"));
+#endif
return FileFdErrno("write",_("Write error"));
}
- From = (char *)From + Res;
+ From = (char const *)From + Res;
Size -= Res;
if (d != NULL)
d->seekpos += Res;
@@ -1424,7 +1637,7 @@ bool FileFd::Write(int Fd, const void *From, unsigned long long Size)
if (Res < 0)
return _error->Errno("write",_("Write error"));
- From = (char *)From + Res;
+ From = (char const *)From + Res;
Size -= Res;
}
while (Res > 0 && Size > 0);
@@ -1440,11 +1653,7 @@ bool FileFd::Write(int Fd, const void *From, unsigned long long Size)
/* */
bool FileFd::Seek(unsigned long long To)
{
- if (d != NULL && (d->pipe == true
-#ifdef HAVE_BZ2
- || d->bz2 != NULL
-#endif
- ))
+ if (d != NULL && (d->pipe == true || d->InternalStream() == true))
{
// Our poor man seeking in pipes is costly, so try to avoid it
unsigned long long seekpos = Tell();
@@ -1455,13 +1664,7 @@ bool FileFd::Seek(unsigned long long To)
if ((d->openmode & ReadOnly) != ReadOnly)
return FileFdError("Reopen is only implemented for read-only files!");
-#ifdef HAVE_BZ2
- if (d->bz2 != NULL)
- {
- BZ2_bzclose(d->bz2);
- d->bz2 = NULL;
- }
-#endif
+ d->InternalClose(FileName);
if (iFd != -1)
close(iFd);
iFd = -1;
@@ -1507,11 +1710,7 @@ bool FileFd::Seek(unsigned long long To)
/* */
bool FileFd::Skip(unsigned long long Over)
{
- if (d != NULL && (d->pipe == true
-#ifdef HAVE_BZ2
- || d->bz2 != NULL
-#endif
- ))
+ if (d != NULL && (d->pipe == true || d->InternalStream() == true))
{
d->seekpos += Over;
char buffer[1024];
@@ -1548,8 +1747,12 @@ bool FileFd::Truncate(unsigned long long To)
// truncating /dev/null is always successful - as we get an error otherwise
if (To == 0 && FileName == "/dev/null")
return true;
-#if defined HAVE_ZLIB || defined HAVE_BZ2
- if (d != NULL && (d->gz != NULL || d->bz2 != NULL))
+#if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA
+ if (d != NULL && (d->InternalStream() == true
+#ifdef HAVE_ZLIB
+ || d->gz != NULL
+#endif
+ ))
return FileFdError("Truncating compressed files is not implemented (%s)", FileName.c_str());
#endif
if (ftruncate(iFd,To) != 0)
@@ -1567,11 +1770,7 @@ unsigned long long FileFd::Tell()
// seeking around, but not all users of FileFd use always Seek() and co
// so d->seekpos isn't always true and we can just use it as a hint if
// we have nothing else, but not always as an authority…
- if (d != NULL && (d->pipe == true
-#ifdef HAVE_BZ2
- || d->bz2 != NULL
-#endif
- ))
+ if (d != NULL && (d->pipe == true || d->InternalStream() == true))
return d->seekpos;
off_t Res;
@@ -1646,11 +1845,7 @@ unsigned long long FileFd::Size()
// for compressor pipes st_size is undefined and at 'best' zero,
// so we 'read' the content and 'seek' back - see there
- if (d != NULL && (d->pipe == true
-#ifdef HAVE_BZ2
- || (d->bz2 && size > 0)
-#endif
- ))
+ if (d != NULL && (d->pipe == true || (d->InternalStream() == true && size > 0)))
{
unsigned long long const oldSeek = Tell();
char ignore[1000];
@@ -1793,7 +1988,13 @@ bool FileFd::FileFdError(const char *Description,...) {
}
/*}}}*/
-gzFile FileFd::gzFd() { return (gzFile) d->gz; }
+APT_DEPRECATED gzFile FileFd::gzFd() {
+#ifdef HAVE_ZLIB
+ return d->gz;
+#else
+ return NULL;
+#endif
+}
// Glob - wrapper around "glob()" /*{{{*/
@@ -1841,3 +2042,14 @@ std::string GetTempDir()
return string(tmpdir);
}
+
+bool Rename(std::string From, std::string To)
+{
+ if (rename(From.c_str(),To.c_str()) != 0)
+ {
+ _error->Error(_("rename failed, %s (%s -> %s)."),strerror(errno),
+ From.c_str(),To.c_str());
+ return false;
+ }
+ return true;
+}
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index e752e9621..cc1a98eae 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -27,6 +27,7 @@
#include <string>
#include <vector>
#include <set>
+#include <time.h>
#include <zlib.h>
@@ -94,7 +95,7 @@ class FileFd
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)
+ bool Read(void *To,unsigned long long Size,unsigned long *Actual) APT_DEPRECATED
{
unsigned long long R;
bool const T = Read(To, Size, &R);
@@ -102,10 +103,10 @@ class FileFd
return T;
}
- bool Open(std::string FileName,unsigned int const Mode,CompressMode Compress,unsigned long const Perms = 0666);
- bool Open(std::string FileName,unsigned int const Mode,APT::Configuration::Compressor const &compressor,unsigned long const Perms = 0666);
- inline bool Open(std::string const &FileName,unsigned int const Mode, unsigned long const Perms = 0666) {
- return Open(FileName, Mode, None, Perms);
+ bool Open(std::string FileName,unsigned int const Mode,CompressMode Compress,unsigned long const AccessMode = 0666);
+ bool Open(std::string FileName,unsigned int const Mode,APT::Configuration::Compressor const &compressor,unsigned long const AccessMode = 0666);
+ inline bool Open(std::string const &FileName,unsigned int const Mode, unsigned long const AccessMode = 0666) {
+ return Open(FileName, Mode, None, AccessMode);
};
bool OpenDescriptor(int Fd, unsigned int const Mode, CompressMode Compress, bool AutoClose=false);
bool OpenDescriptor(int Fd, unsigned int const Mode, APT::Configuration::Compressor const &compressor, bool AutoClose=false);
@@ -118,7 +119,7 @@ class FileFd
// Simple manipulators
inline int Fd() {return iFd;};
inline void Fd(int fd) { OpenDescriptor(fd, ReadWrite);};
- __deprecated gzFile gzFd();
+ gzFile gzFd() APT_DEPRECATED APT_PURE;
inline bool IsOpen() {return iFd >= 0;};
inline bool Failed() {return (Flags & Fail) == Fail;};
@@ -128,13 +129,13 @@ class FileFd
inline bool IsCompressed() {return (Flags & Compressed) == Compressed;};
inline std::string &Name() {return FileName;};
- FileFd(std::string FileName,unsigned int const Mode,unsigned long Perms = 0666) : iFd(-1), Flags(0), d(NULL)
+ FileFd(std::string FileName,unsigned int const Mode,unsigned long AccessMode = 0666) : iFd(-1), Flags(0), d(NULL)
{
- Open(FileName,Mode, None, Perms);
+ Open(FileName,Mode, None, AccessMode);
};
- FileFd(std::string FileName,unsigned int const Mode, CompressMode Compress, unsigned long Perms = 0666) : iFd(-1), Flags(0), d(NULL)
+ FileFd(std::string FileName,unsigned int const Mode, CompressMode Compress, unsigned long AccessMode = 0666) : iFd(-1), Flags(0), d(NULL)
{
- Open(FileName,Mode, Compress, Perms);
+ Open(FileName,Mode, Compress, AccessMode);
};
FileFd() : iFd(-1), Flags(AutoClose), d(NULL) {};
FileFd(int const Fd, unsigned int const Mode = ReadWrite, CompressMode Compress = None) : iFd(-1), Flags(0), d(NULL)
@@ -149,11 +150,11 @@ class FileFd
private:
FileFdPrivate* d;
- bool OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor);
+ APT_HIDDEN bool OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor);
// private helpers to set Fail flag and call _error->Error
- bool FileFdErrno(const char* Function, const char* Description,...) __like_printf(3) __cold;
- bool FileFdError(const char* Description,...) __like_printf(2) __cold;
+ APT_HIDDEN bool FileFdErrno(const char* Function, const char* Description,...) APT_PRINTF(3) APT_COLD;
+ APT_HIDDEN bool FileFdError(const char* Description,...) APT_PRINTF(2) APT_COLD;
};
bool RunScripts(const char *Cnf);
@@ -161,9 +162,10 @@ bool CopyFile(FileFd &From,FileFd &To);
int GetLock(std::string File,bool Errors = true);
bool FileExists(std::string File);
bool RealFileExists(std::string File);
-bool DirectoryExists(std::string const &Path) __attrib_const;
+bool DirectoryExists(std::string const &Path) APT_CONST;
bool CreateDirectory(std::string const &Parent, std::string const &Path);
time_t GetModificationTime(std::string const &Path);
+bool Rename(std::string From, std::string To);
std::string GetTempDir();
diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc
index 9de227062..f24dd9640 100644
--- a/apt-pkg/contrib/gpgv.cc
+++ b/apt-pkg/contrib/gpgv.cc
@@ -2,21 +2,23 @@
// 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<apt-pkg/gpgv.h>
+
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
-
-#include<apt-pkg/configuration.h>
-#include<apt-pkg/error.h>
-#include<apt-pkg/strutl.h>
-#include<apt-pkg/fileutl.h>
-#include<apt-pkg/gpgv.h>
+#include <stddef.h>
+#include <iostream>
+#include <string>
+#include <vector>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/contrib/gpgv.h b/apt-pkg/contrib/gpgv.h
index 1d79a52ac..f018893fd 100644
--- a/apt-pkg/contrib/gpgv.h
+++ b/apt-pkg/contrib/gpgv.h
@@ -9,17 +9,17 @@
#ifndef CONTRIB_GPGV_H
#define CONTRIB_GPGV_H
+#include <apt-pkg/macros.h>
+
#include <string>
#include <vector>
+#ifndef APT_10_CLEANER_HEADERS
#include <apt-pkg/fileutl.h>
-
-#if __GNUC__ >= 4
- #define APT_noreturn __attribute__ ((noreturn))
-#else
- #define APT_noreturn /* no support */
#endif
+class FileFd;
+
/** \brief generates and run the command to verify a file with gpgv
*
* If File and FileSig specify the same file it is assumed that we
@@ -40,14 +40,12 @@
* @param FileSig is the signature (detached or clear-signed)
*/
void ExecGPGV(std::string const &File, std::string const &FileSig,
- int const &statusfd, int fd[2]) APT_noreturn;
-inline void ExecGPGV(std::string const &File, std::string const &FileSig,
+ int const &statusfd, int fd[2]) APT_NORETURN;
+inline APT_NORETURN void ExecGPGV(std::string const &File, std::string const &FileSig,
int const &statusfd = -1) {
int fd[2];
ExecGPGV(File, FileSig, statusfd, fd);
-};
-
-#undef APT_noreturn
+}
/** \brief Split an inline signature into message and signature
*
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index 890573d9c..1fce0d75f 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -16,8 +16,12 @@
#include <apt-pkg/hashes.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/macros.h>
+#include <apt-pkg/md5.h>
+#include <apt-pkg/sha1.h>
+#include <apt-pkg/sha2.h>
+#include <stddef.h>
+#include <algorithm>
#include <unistd.h>
#include <string>
#include <iostream>
@@ -112,7 +116,7 @@ const char** HashString::SupportedHashes()
return _SupportedHashes;
}
-bool HashString::empty() const
+APT_PURE bool HashString::empty() const
{
return (Type.empty() || Hash.empty());
}
diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h
index 0a8bcd259..5cd1af03b 100644
--- a/apt-pkg/contrib/hashes.h
+++ b/apt-pkg/contrib/hashes.h
@@ -17,17 +17,22 @@
#include <apt-pkg/md5.h>
#include <apt-pkg/sha1.h>
#include <apt-pkg/sha2.h>
-#include <apt-pkg/fileutl.h>
-#include <algorithm>
-#include <vector>
#include <cstring>
-
+#include <string>
#ifndef APT_8_CLEANER_HEADERS
using std::min;
using std::vector;
#endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/fileutl.h>
+#include <algorithm>
+#include <vector>
+#endif
+
+
+class FileFd;
// helper class that contains hash function name
// and hash
@@ -61,7 +66,7 @@ class HashString
bool empty() const;
// return the list of hashes we support
- static const char** SupportedHashes();
+ static APT_CONST const char** SupportedHashes();
};
class Hashes
@@ -77,7 +82,7 @@ class Hashes
{
return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size) && SHA512.Add(Data,Size);
};
- inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));};
+ inline bool Add(const char *Data) {return Add((unsigned char const *)Data,strlen(Data));};
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 long Size, bool const addMD5,
diff --git a/apt-pkg/contrib/hashsum.cc b/apt-pkg/contrib/hashsum.cc
index d02177724..25ccc187d 100644
--- a/apt-pkg/contrib/hashsum.cc
+++ b/apt-pkg/contrib/hashsum.cc
@@ -1,6 +1,9 @@
// Cryptographic API Base
#include <config.h>
+#include <apt-pkg/fileutl.h>
+
+#include <algorithm>
#include <unistd.h>
#include "hashsum_template.h"
diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h
index 9bf160b2b..869dc5cb7 100644
--- a/apt-pkg/contrib/hashsum_template.h
+++ b/apt-pkg/contrib/hashsum_template.h
@@ -10,36 +10,40 @@
#ifndef APTPKG_HASHSUM_TEMPLATE_H
#define APTPKG_HASHSUM_TEMPLATE_H
-#include <apt-pkg/fileutl.h>
#include <string>
#include <cstring>
-#include <algorithm>
-#include <stdint.h>
#include <apt-pkg/strutl.h>
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/fileutl.h>
+#include <algorithm>
+#include <stdint.h>
+#endif
#ifndef APT_8_CLEANER_HEADERS
using std::string;
using std::min;
#endif
+class FileFd;
+
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;
- };
+ }
bool operator !=(const HashSumValue &rhs) const
{
return memcmp(Sum,rhs.Sum,sizeof(Sum)) != 0;
- };
+ }
std::string Value() const
{
@@ -49,7 +53,7 @@ class HashSumValue
};
char Result[((N/8)*2)+1];
Result[(N/8)*2] = 0;
-
+
// Convert each char into two letters
int J = 0;
int I = 0;
@@ -59,31 +63,31 @@ class HashSumValue
Result[I + 1] = Conv[Sum[J] & 0xF];
}
return std::string(Result);
- };
-
+ }
+
inline void Value(unsigned char S[N/8])
{
- for (int I = 0; I != sizeof(Sum); I++)
+ for (int I = 0; I != sizeof(Sum); ++I)
S[I] = Sum[I];
- };
+ }
- inline operator std::string() const
+ inline operator std::string() const
{
return Value();
- };
+ }
- bool Set(std::string Str)
+ bool Set(std::string Str)
{
return Hex2Num(Str,Sum,sizeof(Sum));
- };
+ }
- inline void Set(unsigned char S[N/8])
+ inline void Set(unsigned char S[N/8])
{
- for (int I = 0; I != sizeof(Sum); I++)
+ for (int I = 0; I != sizeof(Sum); ++I)
Sum[I] = S[I];
- };
+ }
- HashSumValue(std::string Str)
+ HashSumValue(std::string Str)
{
memset(Sum,0,sizeof(Sum));
Set(Str);
@@ -99,17 +103,17 @@ class SummationImplementation
public:
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); };
+ { return Add((const unsigned char *)inbuf, inlen); }
inline bool Add(const unsigned char *Data)
- { return Add(Data, strlen((const char *)Data)); };
+ { return Add(Data, strlen((const char *)Data)); }
inline bool Add(const char *Data)
- { return Add((const unsigned char *)Data, strlen((const char *)Data)); };
+ { return Add((const unsigned char *)Data, strlen(Data)); }
inline bool Add(const unsigned char *Beg, const unsigned char *End)
- { return Add(Beg, End - Beg); };
+ { return Add(Beg, End - Beg); }
inline bool Add(const char *Beg, const char *End)
- { return Add((const unsigned char *)Beg, End - Beg); };
+ { return Add((const unsigned char *)Beg, End - Beg); }
bool AddFD(int Fd, unsigned long long Size = 0);
bool AddFD(FileFd &Fd, unsigned long long Size = 0);
diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h
index e53d01b8f..2d6448e5e 100644
--- a/apt-pkg/contrib/macros.h
+++ b/apt-pkg/contrib/macros.h
@@ -54,37 +54,91 @@
#define CLRFLAG(v,f) ((v) &=~FLAG(f))
#define CHKFLAG(v,f) ((v) & FLAG(f) ? true : false)
-// some nice optional GNUC features
-#if __GNUC__ >= 3
- #define __must_check __attribute__ ((warn_unused_result))
- #define __deprecated __attribute__ ((deprecated))
- #define __attrib_const __attribute__ ((__const__))
- /* likely() and unlikely() can be used to mark boolean expressions
- as (not) likely true which will help the compiler to optimise */
+#ifdef __GNUC__
+#define APT_GCC_VERSION (__GNUC__ << 8 | __GNUC_MINOR__)
+#else
+#define APT_GCC_VERSION 0
+#endif
+
+/* likely() and unlikely() can be used to mark boolean expressions
+ as (not) likely true which will help the compiler to optimise */
+#if APT_GCC_VERSION >= 0x0300
#define likely(x) __builtin_expect (!!(x), 1)
#define unlikely(x) __builtin_expect (!!(x), 0)
#else
- #define __must_check /* no warn_unused_result */
- #define __deprecated /* no deprecated */
- #define __attrib_const /* no const attribute */
#define likely(x) (x)
#define unlikely(x) (x)
#endif
+#if APT_GCC_VERSION >= 0x0300
+ #define APT_DEPRECATED __attribute__ ((deprecated))
+ #define APT_CONST __attribute__((const))
+ #define APT_PURE __attribute__((pure))
+ #define APT_NORETURN __attribute__((noreturn))
+ #define APT_PRINTF(n) __attribute__((format(printf, n, n + 1)))
+#else
+ #define APT_DEPRECATED
+ #define APT_CONST
+ #define APT_PURE
+ #define APT_NORETURN
+ #define APT_PRINTF(n)
+#endif
+
+#if APT_GCC_VERSION > 0x0302
+ #define APT_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
+ #define APT_MUSTCHECK __attribute__((warn_unused_result))
+#else
+ #define APT_NONNULL(...)
+ #define APT_REQRET
+#endif
+
+#if APT_GCC_VERSION >= 0x0400
+ #define APT_SENTINEL __attribute__((sentinel))
+ #define APT_PUBLIC __attribute__ ((visibility ("default")))
+ #define APT_HIDDEN __attribute__ ((visibility ("hidden")))
+#else
+ #define APT_SENTINEL
+ #define APT_PUBLIC
+ #define APT_HIDDEN
+#endif
+
// cold functions are unlikely() to be called
-#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
- #define __cold __attribute__ ((__cold__))
- #define __hot __attribute__ ((__hot__))
+#if APT_GCC_VERSION >= 0x0403
+ #define APT_COLD __attribute__ ((__cold__))
+ #define APT_HOT __attribute__ ((__hot__))
#else
- #define __cold /* no cold marker */
- #define __hot /* no hot marker */
+ #define APT_COLD
+ #define APT_HOT
#endif
-#ifdef __GNUG__
-// Methods have a hidden this parameter that is visible to this attribute
+#ifndef APT_10_CLEANER_HEADERS
+#if APT_GCC_VERSION >= 0x0300
+ #define __must_check __attribute__ ((warn_unused_result))
+ #define __deprecated __attribute__ ((deprecated))
+ #define __attrib_const __attribute__ ((__const__))
#define __like_printf(n) __attribute__((format(printf, n, n + 1)))
#else
+ #define __must_check /* no warn_unused_result */
+ #define __deprecated /* no deprecated */
+ #define __attrib_const /* no const attribute */
#define __like_printf(n) /* no like-printf */
#endif
+#if APT_GCC_VERSION >= 0x0403
+ #define __cold __attribute__ ((__cold__))
+ #define __hot __attribute__ ((__hot__))
+#else
+ #define __cold /* no cold marker */
+ #define __hot /* no hot marker */
+#endif
+#endif
+
+// These lines are extracted by the makefiles and the buildsystem
+// Increasing MAJOR or MINOR results in the need of recompiling all
+// reverse-dependencies of libapt-pkg against the new SONAME.
+// Non-ABI-Breaks should only increase RELEASE number.
+// See also buildlib/libversion.mak
+#define APT_PKG_MAJOR 4
+#define APT_PKG_MINOR 12
+#define APT_PKG_RELEASE 0
#endif
diff --git a/apt-pkg/contrib/md5.cc b/apt-pkg/contrib/md5.cc
index 4351aeb22..b487a96f9 100644
--- a/apt-pkg/contrib/md5.cc
+++ b/apt-pkg/contrib/md5.cc
@@ -38,13 +38,9 @@
#include <config.h>
#include <apt-pkg/md5.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/macros.h>
+#include <stdint.h>
#include <string.h>
-#include <unistd.h>
-#include <netinet/in.h> // For htonl
-#include <inttypes.h>
/*}}}*/
// byteSwap - Swap bytes in a buffer /*{{{*/
diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h
index 195455645..f4992c223 100644
--- a/apt-pkg/contrib/md5.h
+++ b/apt-pkg/contrib/md5.h
@@ -23,14 +23,15 @@
#ifndef APTPKG_MD5_H
#define APTPKG_MD5_H
-
-#include <string>
-#include <cstring>
-#include <algorithm>
#include <stdint.h>
#include "hashsum_template.h"
+#ifndef APT_10_CLEANER_HEADERS
+#include <string>
+#include <cstring>
+#include <algorithm>
+#endif
#ifndef APT_8_CLEANER_HEADERS
using std::string;
using std::min;
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index 51e8eb30f..b2a53a6cb 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -22,11 +22,11 @@
#include <apt-pkg/mmap.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/macros.h>
+#include <string>
#include <sys/mman.h>
-#include <sys/stat.h>
#include <unistd.h>
-#include <fcntl.h>
#include <stdlib.h>
#include <errno.h>
#include <cstring>
@@ -198,7 +198,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
{
#ifdef _POSIX_SYNCHRONIZED_IO
unsigned long long const PSize = sysconf(_SC_PAGESIZE);
- if (msync((char *)Base+(unsigned long long)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0)
+ if (msync((char *)Base+(Start/PSize)*PSize, Stop - Start, MS_SYNC) < 0)
return _error->Errno("msync", _("Unable to synchronize mmap"));
#endif
}
diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc
index de95aa4ab..feaed67c8 100644
--- a/apt-pkg/contrib/netrc.cc
+++ b/apt-pkg/contrib/netrc.cc
@@ -15,14 +15,13 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/strutl.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/fileutl.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <stddef.h>
#include <pwd.h>
#include "netrc.h"
@@ -198,7 +197,7 @@ void maybe_add_auth (URI &Uri, string NetRCFile)
// if host did not work, try Host+Path next, this will trigger
// a lookup uri.startswith(host) in the netrc file parser (because
// of the "/"
- char *hostpath = strdup(string(Uri.Host+Uri.Path).c_str());
+ char *hostpath = strdup((Uri.Host + Uri.Path).c_str());
if (hostpath && parsenetrc_string(hostpath, login, password, netrcfile) == 0)
{
if (_config->FindB("Debug::Acquire::netrc", false) == true)
diff --git a/apt-pkg/contrib/netrc.h b/apt-pkg/contrib/netrc.h
index 6feb5b726..dbeb45386 100644
--- a/apt-pkg/contrib/netrc.h
+++ b/apt-pkg/contrib/netrc.h
@@ -16,6 +16,8 @@
#include <string>
+#include <apt-pkg/macros.h>
+
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/strutl.h>
#endif
@@ -25,9 +27,9 @@
class URI;
-// kill this export on the next ABI break - strongly doubt its in use anyway
+// FIXME: kill this export on the next ABI break - strongly doubt its in use anyway
// outside of the apt itself, its really a internal interface
-__deprecated int parsenetrc (char *host, char *login, char *password, char *filename);
+APT_DEPRECATED int parsenetrc (char *host, char *login, char *password, char *filename);
void maybe_add_auth (URI &Uri, std::string NetRCFile);
#endif
diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc
index 916e1d730..4ff4f181d 100644
--- a/apt-pkg/contrib/progress.cc
+++ b/apt-pkg/contrib/progress.cc
@@ -14,6 +14,8 @@
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
+#include <sys/time.h>
+#include <string>
#include <iostream>
#include <stdio.h>
#include <cstring>
@@ -125,14 +127,14 @@ bool OpProgress::CheckChange(float Interval)
// OpTextProgress::OpTextProgress - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-OpTextProgress::OpTextProgress(Configuration &Config) :
- NoUpdate(false), NoDisplay(false), LastLen(0)
+OpTextProgress::OpTextProgress(Configuration &Config) :
+ NoUpdate(false), NoDisplay(false), LastLen(0)
{
if (Config.FindI("quiet",0) >= 1 || Config.FindB("quiet::NoUpdate", false) == true)
NoUpdate = true;
if (Config.FindI("quiet",0) >= 2)
NoDisplay = true;
-};
+}
/*}}}*/
// OpTextProgress::Done - Clean up the display /*{{{*/
// ---------------------------------------------------------------------
@@ -150,12 +152,12 @@ void OpTextProgress::Done()
cout << endl;
OldOp = string();
}
-
+
if (NoUpdate == true && NoDisplay == false && OldOp.empty() == false)
{
OldOp = string();
- cout << endl;
- }
+ cout << endl;
+ }
}
/*}}}*/
// OpTextProgress::Update - Simple text spinner /*{{{*/
diff --git a/apt-pkg/contrib/sha1.cc b/apt-pkg/contrib/sha1.cc
index b5a6a2440..bf6bc6cb6 100644
--- a/apt-pkg/contrib/sha1.cc
+++ b/apt-pkg/contrib/sha1.cc
@@ -32,12 +32,9 @@
#include <config.h>
#include <apt-pkg/sha1.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/macros.h>
+#include <stdint.h>
#include <string.h>
-#include <unistd.h>
-#include <inttypes.h>
/*}}}*/
// SHA1Transform - Alters an existing SHA-1 hash /*{{{*/
diff --git a/apt-pkg/contrib/sha1.h b/apt-pkg/contrib/sha1.h
index a8d55eb13..5770c315a 100644
--- a/apt-pkg/contrib/sha1.h
+++ b/apt-pkg/contrib/sha1.h
@@ -14,12 +14,13 @@
#ifndef APTPKG_SHA1_H
#define APTPKG_SHA1_H
+#include "hashsum_template.h"
+
+#ifndef APT_10_CLEANER_HEADERS
#include <string>
#include <cstring>
#include <algorithm>
-
-#include "hashsum_template.h"
-
+#endif
#ifndef APT_8_CLEANER_HEADERS
using std::string;
using std::min;
diff --git a/apt-pkg/contrib/sha2.h b/apt-pkg/contrib/sha2.h
index 8e0c99a1b..a25ad4d32 100644
--- a/apt-pkg/contrib/sha2.h
+++ b/apt-pkg/contrib/sha2.h
@@ -14,14 +14,18 @@
#ifndef APTPKG_SHA2_H
#define APTPKG_SHA2_H
-#include <string>
#include <cstring>
-#include <algorithm>
-#include <stdint.h>
#include "sha2_internal.h"
#include "hashsum_template.h"
+#ifndef APT_10_CLEANER_HEADERS
+#include <string>
+#include <algorithm>
+#include <stdint.h>
+#endif
+
+
typedef HashSumValue<512> SHA512SumValue;
typedef HashSumValue<256> SHA256SumValue;
diff --git a/apt-pkg/contrib/sha2_internal.cc b/apt-pkg/contrib/sha2_internal.cc
index bb2560252..131ff5beb 100644
--- a/apt-pkg/contrib/sha2_internal.cc
+++ b/apt-pkg/contrib/sha2_internal.cc
@@ -33,6 +33,7 @@
*/
#include <config.h>
+#include <endian.h>
#include <string.h> /* memcpy()/memset() or bcopy()/bzero() */
#include <assert.h> /* assert() */
#include "sha2_internal.h"
diff --git a/apt-pkg/contrib/sha2_internal.h b/apt-pkg/contrib/sha2_internal.h
index d9d429c92..1b82d965d 100644
--- a/apt-pkg/contrib/sha2_internal.h
+++ b/apt-pkg/contrib/sha2_internal.h
@@ -44,6 +44,7 @@
#ifdef SHA2_USE_INTTYPES_H
+#include <stddef.h>
#include <inttypes.h>
#endif /* SHA2_USE_INTTYPES_H */
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index d4f53ea3a..2100ee47b 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -21,6 +21,11 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <time.h>
+#include <string>
+#include <vector>
#include <ctype.h>
#include <string.h>
#include <sstream>
@@ -33,9 +38,9 @@
#include <iconv.h>
#include <apti18n.h>
-
-using namespace std;
/*}}}*/
+using namespace std;
+
// Strip - Remove white space from the front and back of a string /*{{{*/
// ---------------------------------------------------------------------
namespace APT {
@@ -153,7 +158,7 @@ char *_strrstrip(char *String)
End++;
*End = 0;
return String;
-};
+}
/*}}}*/
// strtabexpand - Converts tabs into 8 spaces /*{{{*/
// ---------------------------------------------------------------------
@@ -1130,9 +1135,11 @@ bool TokSplitString(char Tok,char *Input,char **List,
also, but the advantage is that we have an iteratable vector */
vector<string> VectorizeString(string const &haystack, char const &split)
{
+ vector<string> exploded;
+ if (haystack.empty() == true)
+ return exploded;
string::const_iterator start = haystack.begin();
string::const_iterator end = start;
- vector<string> exploded;
do {
for (; end != haystack.end() && *end != split; ++end);
exploded.push_back(string(start, end));
@@ -1182,7 +1189,7 @@ unsigned long RegexChoice(RxChoiceList *Rxs,const char **ListBegin,
R->Hit = false;
unsigned long Hits = 0;
- for (; ListBegin != ListEnd; ListBegin++)
+ for (; ListBegin < ListEnd; ++ListBegin)
{
// Check if the name is a regex
const char *I;
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index 8d746f10e..185cdc3fc 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -18,15 +18,18 @@
#include <limits>
-#include <stdlib.h>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <time.h>
+#include <stddef.h>
#include "macros.h"
+#ifndef APT_10_CLEANER_HEADERS
+#include <stdlib.h>
+#endif
#ifndef APT_8_CLEANER_HEADERS
using std::string;
using std::vector;
@@ -37,8 +40,8 @@ namespace APT {
namespace String {
std::string Strip(const std::string &s);
bool Endswith(const std::string &s, const std::string &ending);
- };
-};
+ }
+}
bool UTF8ToCodeset(const char *codeset, const std::string &orig, std::string *dest);
@@ -60,9 +63,9 @@ std::string Base64Encode(const std::string &Str);
std::string OutputInDepth(const unsigned long Depth, const char* Separator=" ");
std::string URItoFileName(const std::string &URI);
std::string TimeRFC1123(time_t Date);
-bool RFC1123StrToTime(const char* const str,time_t &time) __must_check;
-bool FTPMDTMStrToTime(const char* const str,time_t &time) __must_check;
-__deprecated bool StrToTime(const std::string &Val,time_t &Result);
+bool RFC1123StrToTime(const char* const str,time_t &time) APT_MUSTCHECK;
+bool FTPMDTMStrToTime(const char* const str,time_t &time) APT_MUSTCHECK;
+APT_DEPRECATED bool StrToTime(const std::string &Val,time_t &Result);
std::string LookupTag(const std::string &Message,const char *Tag,const char *Default = 0);
int StringToBool(const std::string &Text,int Default = -1);
bool ReadMessages(int Fd, std::vector<std::string> &List);
@@ -76,7 +79,7 @@ bool TokSplitString(char Tok,char *Input,char **List,
unsigned long ListMax);
// split a given string by a char
-std::vector<std::string> VectorizeString(std::string const &haystack, char const &split) __attrib_const;
+std::vector<std::string> VectorizeString(std::string const &haystack, char const &split) APT_CONST;
/* \brief Return a vector of strings from string "input" where "sep"
* is used as the delimiter string.
@@ -94,56 +97,56 @@ std::vector<std::string> VectorizeString(std::string const &haystack, char const
*/
std::vector<std::string> StringSplit(std::string const &input,
std::string const &sep,
- unsigned int maxsplit=std::numeric_limits<unsigned int>::max()) __attrib_const;
+ unsigned int maxsplit=std::numeric_limits<unsigned int>::max()) APT_CONST;
-void ioprintf(std::ostream &out,const char *format,...) __like_printf(2);
-void strprintf(std::string &out,const char *format,...) __like_printf(2);
-char *safe_snprintf(char *Buffer,char *End,const char *Format,...) __like_printf(3);
+void ioprintf(std::ostream &out,const char *format,...) APT_PRINTF(2);
+void strprintf(std::string &out,const char *format,...) APT_PRINTF(2);
+char *safe_snprintf(char *Buffer,char *End,const char *Format,...) APT_PRINTF(3);
bool CheckDomainList(const std::string &Host, const std::string &List);
-int tolower_ascii(int const c) __attrib_const __hot;
+int tolower_ascii(int const c) APT_CONST APT_HOT;
std::string StripEpoch(const std::string &VerStr);
#define APT_MKSTRCMP(name,func) \
-inline int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));}; \
-inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \
-inline int name(const std::string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));}; \
-inline int name(const std::string& A,const std::string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());}; \
-inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);};
+inline APT_PURE int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));} \
+inline APT_PURE int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));} \
+inline APT_PURE int name(const std::string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));} \
+inline APT_PURE int name(const std::string& A,const std::string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());} \
+inline APT_PURE int name(const std::string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);}
#define APT_MKSTRCMP2(name,func) \
-inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \
-inline int name(const std::string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));}; \
-inline int name(const std::string& A,const std::string& B) {return func(A.begin(),A.end(),B.begin(),B.end());}; \
-inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);};
+inline APT_PURE int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));} \
+inline APT_PURE int name(const std::string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));} \
+inline APT_PURE int name(const std::string& A,const std::string& B) {return func(A.begin(),A.end(),B.begin(),B.end());} \
+inline APT_PURE int name(const std::string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);}
-int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
-int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
+int APT_PURE stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
+int APT_PURE stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
/* We assume that GCC 3 indicates that libstdc++3 is in use too. In that
case the definition of string::const_iterator is not the same as
const char * and we need these extra functions */
#if __GNUC__ >= 3
-int stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd,
+int APT_PURE stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd,
const char *B,const char *BEnd);
-int stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd,
+int APT_PURE stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd,
std::string::const_iterator B,std::string::const_iterator BEnd);
-int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd,
+int APT_PURE stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd,
const char *B,const char *BEnd);
-int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd,
+int APT_PURE stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd,
std::string::const_iterator B,std::string::const_iterator BEnd);
-inline int stringcmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));};
-inline int stringcasecmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));};
+inline APT_PURE int stringcmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));}
+inline APT_PURE int stringcasecmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));}
#endif
-APT_MKSTRCMP2(stringcmp,stringcmp);
-APT_MKSTRCMP2(stringcasecmp,stringcasecmp);
+APT_MKSTRCMP2(stringcmp,stringcmp)
+APT_MKSTRCMP2(stringcasecmp,stringcasecmp)
// Return the length of a NULL-terminated string array
-size_t strv_length(const char **str_array);
+size_t APT_PURE strv_length(const char **str_array);
-inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);};
+inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);}
class URI
{
@@ -159,13 +162,13 @@ class URI
unsigned int Port;
operator std::string();
- inline void operator =(const std::string &From) {CopyFrom(From);};
+ inline void operator =(const std::string &From) {CopyFrom(From);}
inline bool empty() {return Access.empty();};
static std::string SiteOnly(const std::string &URI);
static std::string NoUserPassword(const std::string &URI);
- URI(std::string Path) {CopyFrom(Path);};
- URI() : Port(0) {};
+ URI(std::string Path) {CopyFrom(Path);}
+ URI() : Port(0) {}
};
struct SubstVar
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index 909dfcf47..eee758b7a 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -15,7 +15,6 @@
#include <apt-pkg/debsrcrecords.h>
#include <apt-pkg/deblistparser.h>
#include <apt-pkg/debrecords.h>
-#include <apt-pkg/sourcelist.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/progress.h>
#include <apt-pkg/error.h>
@@ -23,7 +22,18 @@
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/debmetaindex.h>
#include <apt-pkg/gpgv.h>
-
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/mmap.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcachegen.h>
+#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/srcrecords.h>
+
+#include <stdio.h>
+#include <iostream>
+#include <string>
#include <sys/stat.h>
/*}}}*/
@@ -650,7 +660,7 @@ pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const
// StatusIndex::Exists - Check if the index is available /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool debStatusIndex::Exists() const
+APT_CONST bool debStatusIndex::Exists() const
{
// Abort if the file does not exist.
return true;
diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h
index 9e64d4476..017c69a0a 100644
--- a/apt-pkg/deb/debindexfile.h
+++ b/apt-pkg/deb/debindexfile.h
@@ -16,9 +16,17 @@
#ifndef PKGLIB_DEBINDEXFILE_H
#define PKGLIB_DEBINDEXFILE_H
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/srcrecords.h>
+#include <string>
+
+class OpProgress;
+class pkgAcquire;
+class pkgCacheGenerator;
-#include <apt-pkg/indexfile.h>
class debStatusIndex : public pkgIndexFile
{
@@ -30,10 +38,10 @@ class debStatusIndex : public pkgIndexFile
public:
- virtual const Type *GetType() const;
+ virtual const Type *GetType() const APT_CONST;
// Interface for acquire
- virtual std::string Describe(bool Short) const {return File;};
+ virtual std::string Describe(bool /*Short*/) const {return File;};
// Interface for the Cache Generator
virtual bool Exists() const;
@@ -63,7 +71,7 @@ class debPackagesIndex : public pkgIndexFile
public:
- virtual const Type *GetType() const;
+ virtual const Type *GetType() const APT_CONST;
// Stuff for accessing files on remote items
virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const;
@@ -102,7 +110,7 @@ class debTranslationsIndex : public pkgIndexFile
public:
- virtual const Type *GetType() const;
+ virtual const Type *GetType() const APT_CONST;
// Interface for acquire
virtual std::string Describe(bool Short) const;
@@ -134,7 +142,7 @@ class debSourcesIndex : public pkgIndexFile
public:
- virtual const Type *GetType() const;
+ virtual const Type *GetType() const APT_CONST;
// Stuff for accessing files on remote items
virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index acdcc4554..a1bcfb710 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -21,8 +21,17 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/crc-16.h>
#include <apt-pkg/md5.h>
+#include <apt-pkg/mmap.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/tagfile.h>
#include <apt-pkg/macros.h>
+#include <stddef.h>
+#include <string.h>
+#include <algorithm>
+#include <string>
+#include <vector>
#include <ctype.h>
/*}}}*/
@@ -34,7 +43,7 @@ static debListParser::WordList PrioList[] = {
{"standard",pkgCache::State::Standard},
{"optional",pkgCache::State::Optional},
{"extra",pkgCache::State::Extra},
- {}};
+ {NULL, 0}};
// ListParser::debListParser - Constructor /*{{{*/
// ---------------------------------------------------------------------
@@ -95,44 +104,49 @@ string debListParser::Version()
return Section.FindS("Version");
}
/*}}}*/
-// ListParser::NewVersion - Fill in the version structure /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
+unsigned char debListParser::ParseMultiArch(bool const showErrors) /*{{{*/
{
- // Parse the section
- Ver->Section = UniqFindTagWrite("Section");
-
- // Parse multi-arch
+ unsigned char MA;
string const MultiArch = Section.FindS("Multi-Arch");
if (MultiArch.empty() == true)
- Ver->MultiArch = pkgCache::Version::None;
+ MA = pkgCache::Version::None;
else if (MultiArch == "same") {
- // Parse multi-arch
if (ArchitectureAll() == true)
{
- /* Arch all packages can't be Multi-Arch: same */
- _error->Warning("Architecture: all package '%s' can't be Multi-Arch: same",
- Section.FindS("Package").c_str());
- Ver->MultiArch = pkgCache::Version::None;
+ if (showErrors == true)
+ _error->Warning("Architecture: all package '%s' can't be Multi-Arch: same",
+ Section.FindS("Package").c_str());
+ MA = pkgCache::Version::None;
}
else
- Ver->MultiArch = pkgCache::Version::Same;
+ MA = pkgCache::Version::Same;
}
else if (MultiArch == "foreign")
- Ver->MultiArch = pkgCache::Version::Foreign;
+ MA = pkgCache::Version::Foreign;
else if (MultiArch == "allowed")
- Ver->MultiArch = pkgCache::Version::Allowed;
+ MA = pkgCache::Version::Allowed;
else
{
- _error->Warning("Unknown Multi-Arch type '%s' for package '%s'",
- MultiArch.c_str(), Section.FindS("Package").c_str());
- Ver->MultiArch = pkgCache::Version::None;
+ if (showErrors == true)
+ _error->Warning("Unknown Multi-Arch type '%s' for package '%s'",
+ MultiArch.c_str(), Section.FindS("Package").c_str());
+ MA = pkgCache::Version::None;
}
if (ArchitectureAll() == true)
- Ver->MultiArch |= pkgCache::Version::All;
+ MA |= pkgCache::Version::All;
+ return MA;
+}
+ /*}}}*/
+// ListParser::NewVersion - Fill in the version structure /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
+{
+ // Parse the section
+ Ver->Section = UniqFindTagWrite("Section");
+ Ver->MultiArch = ParseMultiArch(true);
// Archive Size
Ver->Size = Section.FindULL("Size");
// Unpacked Size (in K)
@@ -354,7 +368,7 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
{"hold",pkgCache::State::Hold},
{"deinstall",pkgCache::State::DeInstall},
{"purge",pkgCache::State::Purge},
- {}};
+ {NULL, 0}};
if (GrabWord(string(Start,I-Start),WantList,Pkg->SelectedState) == false)
return _error->Error("Malformed 1st word in the Status line");
@@ -370,7 +384,7 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
{"reinstreq",pkgCache::State::ReInstReq},
{"hold",pkgCache::State::HoldInst},
{"hold-reinstreq",pkgCache::State::HoldReInstReq},
- {}};
+ {NULL, 0}};
if (GrabWord(string(Start,I-Start),FlagList,Pkg->InstState) == false)
return _error->Error("Malformed 2nd word in the Status line");
@@ -392,7 +406,7 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
{"triggers-pending",pkgCache::State::TriggersPending},
{"post-inst-failed",pkgCache::State::HalfConfigured},
{"removal-failed",pkgCache::State::HalfInstalled},
- {}};
+ {NULL, 0}};
if (GrabWord(string(Start,I-Start),StatusList,Pkg->CurrentState) == false)
return _error->Error("Malformed 3rd word in the Status line");
@@ -475,17 +489,30 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op)
/* This parses the dependency elements out of a standard string in place,
bit by bit. */
const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op)
+ { return ParseDepends(Start, Stop, Package, Ver, Op, false, true, false); }
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op,
+ bool const &ParseArchFlags)
+ { return ParseDepends(Start, Stop, Package, Ver, Op, ParseArchFlags, true, false); }
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op,
+ bool const &ParseArchFlags, bool const &StripMultiArch)
+ { return ParseDepends(Start, Stop, Package, Ver, Op, ParseArchFlags, StripMultiArch, false); }
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
string &Package,string &Ver,
unsigned int &Op, bool const &ParseArchFlags,
- bool const &StripMultiArch)
+ bool const &StripMultiArch,
+ bool const &ParseRestrictionsList)
{
// Strip off leading space
- for (;Start != Stop && isspace(*Start) != 0; Start++);
+ for (;Start != Stop && isspace(*Start) != 0; ++Start);
// Parse off the package name
const char *I = Start;
for (;I != Stop && isspace(*I) == 0 && *I != '(' && *I != ')' &&
- *I != ',' && *I != '|' && *I != '[' && *I != ']'; I++);
+ *I != ',' && *I != '|' && *I != '[' && *I != ']' &&
+ *I != '<' && *I != '>'; ++I);
// Malformed, no '('
if (I != Stop && *I == ')')
@@ -602,6 +629,76 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
for (;I != Stop && isspace(*I) != 0; I++);
}
+ if (ParseRestrictionsList == true)
+ {
+ // Parse a restrictions list
+ if (I != Stop && *I == '<')
+ {
+ ++I;
+ // malformed
+ if (unlikely(I == Stop))
+ return 0;
+
+ std::vector<string> const profiles = APT::Configuration::getBuildProfiles();
+
+ const char *End = I;
+ bool Found = false;
+ bool NegRestriction = false;
+ while (I != Stop)
+ {
+ // look for whitespace or ending '>'
+ for (;End != Stop && !isspace(*End) && *End != '>'; ++End);
+
+ if (unlikely(End == Stop))
+ return 0;
+
+ if (*I == '!')
+ {
+ NegRestriction = true;
+ ++I;
+ }
+
+ std::string restriction(I, End);
+
+ std::string prefix = "profile.";
+ // only support for "profile" prefix, ignore others
+ if (restriction.size() > prefix.size() &&
+ restriction.substr(0, prefix.size()) == prefix)
+ {
+ // get the name of the profile
+ restriction = restriction.substr(prefix.size());
+
+ if (restriction.empty() == false && profiles.empty() == false &&
+ std::find(profiles.begin(), profiles.end(), restriction) != profiles.end())
+ {
+ Found = true;
+ if (I[-1] != '!')
+ NegRestriction = false;
+ // we found a match, so fast-forward to the end of the wildcards
+ for (; End != Stop && *End != '>'; ++End);
+ }
+ }
+
+ if (*End++ == '>') {
+ I = End;
+ break;
+ }
+
+ I = End;
+ for (;I != Stop && isspace(*I) != 0; I++);
+ }
+
+ if (NegRestriction == true)
+ Found = !Found;
+
+ if (Found == false)
+ Package = ""; /* not for this restriction */
+ }
+
+ // Skip whitespace
+ for (;I != Stop && isspace(*I) != 0; I++);
+ }
+
if (I != Stop && *I == '|')
Op |= pkgCache::Dep::Or;
@@ -635,7 +732,7 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
string Version;
unsigned int Op;
- Start = ParseDepends(Start, Stop, Package, Version, Op, false, false);
+ Start = ParseDepends(Start, Stop, Package, Version, Op, false, false, false);
if (Start == 0)
return _error->Error("Problem parsing dependency %s",Tag);
size_t const found = Package.rfind(':');
@@ -841,3 +938,24 @@ unsigned char debListParser::GetPrio(string Str)
return Out;
}
/*}}}*/
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+bool debListParser::SameVersion(unsigned short const Hash, /*{{{*/
+ pkgCache::VerIterator const &Ver)
+{
+ if (pkgCacheGenerator::ListParser::SameVersion(Hash, Ver) == false)
+ return false;
+ // status file has no (Download)Size, but all others are fair game
+ // status file is parsed last, so the first version we encounter is
+ // probably also the version we have downloaded
+ unsigned long long const Size = Section.FindULL("Size");
+ if (Size != 0 && Size != Ver->Size)
+ return false;
+ // available everywhere, but easier to check here than to include in VersionHash
+ unsigned char MultiArch = ParseMultiArch(false);
+ if (MultiArch != Ver->MultiArch)
+ return false;
+ // for all practical proposes (we can check): same version
+ return true;
+}
+ /*}}}*/
+#endif
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 386d291a2..baace79fe 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -13,11 +13,19 @@
#include <apt-pkg/pkgcachegen.h>
#include <apt-pkg/tagfile.h>
+#include <apt-pkg/md5.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/macros.h>
+
+#include <string>
+#include <vector>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/indexfile.h>
#endif
+class FileFd;
+
class debListParser : public pkgCacheGenerator::ListParser
{
public:
@@ -63,6 +71,9 @@ class debListParser : public pkgCacheGenerator::ListParser
virtual std::string DescriptionLanguage();
virtual MD5SumValue Description_md5();
virtual unsigned short VersionHash();
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver);
+#endif
virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
pkgCache::VerIterator &Ver);
virtual unsigned long Offset() {return iOffset;};
@@ -72,15 +83,27 @@ class debListParser : public pkgCacheGenerator::ListParser
bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
std::string section);
-
+
+ static const char *ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op);
static const char *ParseDepends(const char *Start,const char *Stop,
- std::string &Package,std::string &Ver,unsigned int &Op,
- bool const &ParseArchFlags = false,
- bool const &StripMultiArch = true);
+ std::string &Package,std::string &Ver,unsigned int &Op,
+ bool const &ParseArchFlags);
+ static const char *ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op,
+ bool const &ParseArchFlags, bool const &StripMultiArch);
+ static const char *ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op,
+ bool const &ParseArchFlags, bool const &StripMultiArch,
+ bool const &ParseRestrictionsList);
+
static const char *ConvertRelation(const char *I,unsigned int &Op);
debListParser(FileFd *File, std::string const &Arch = "");
virtual ~debListParser() {};
+
+ private:
+ APT_HIDDEN unsigned char ParseMultiArch(bool const showErrors);
};
#endif
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index 504877558..6fd12add8 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -9,8 +9,15 @@
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/indexrecords.h>
#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/error.h>
-
+#include <apt-pkg/hashes.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/metaindex.h>
+
+#include <string.h>
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
#include <set>
#include <algorithm>
diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h
index cef8d68f7..2286fa8b2 100644
--- a/apt-pkg/deb/debmetaindex.h
+++ b/apt-pkg/deb/debmetaindex.h
@@ -3,7 +3,7 @@
#define PKGLIB_DEBMETAINDEX_H
#include <apt-pkg/metaindex.h>
-#include <apt-pkg/init.h>
+#include <apt-pkg/macros.h>
#include <map>
#include <string>
@@ -12,6 +12,12 @@
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/sourcelist.h>
#endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/init.h>
+#endif
+
+class pkgAcquire;
+class pkgIndexFile;
class debReleaseIndex : public metaIndex {
public:
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc
index 184c07c33..6063db5a8 100644
--- a/apt-pkg/deb/debrecords.cc
+++ b/apt-pkg/deb/debrecords.cc
@@ -12,10 +12,16 @@
#include <apt-pkg/debrecords.h>
#include <apt-pkg/strutl.h>
-#include <apt-pkg/error.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/tagfile.h>
+#include <string.h>
+#include <algorithm>
+#include <string>
+#include <vector>
#include <langinfo.h>
/*}}}*/
diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h
index b5e3bbdba..bdac6c90b 100644
--- a/apt-pkg/deb/debrecords.h
+++ b/apt-pkg/deb/debrecords.h
@@ -17,6 +17,9 @@
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/pkgcache.h>
+
+#include <string>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/indexfile.h>
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index ce55ccd1f..b09588dd3 100644
--- a/apt-pkg/deb/debsrcrecords.cc
+++ b/apt-pkg/deb/debsrcrecords.cc
@@ -15,12 +15,19 @@
#include <apt-pkg/debsrcrecords.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
-#include <apt-pkg/configuration.h>
#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/srcrecords.h>
+#include <apt-pkg/tagfile.h>
-using std::max;
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <algorithm>
+#include <string>
+#include <vector>
/*}}}*/
+using std::max;
using std::string;
// SrcRecordParser::Binaries - Return the binaries field /*{{{*/
@@ -57,7 +64,7 @@ const char **debSrcRecordParser::Binaries()
} while (*bin != '\0');
StaticBinList.push_back(NULL);
- return (const char **) &StaticBinList[0];
+ return &StaticBinList[0];
}
/*}}}*/
// SrcRecordParser::BuildDepends - Return the Build-Depends information /*{{{*/
@@ -90,7 +97,7 @@ bool debSrcRecordParser::BuildDepends(std::vector<pkgSrcRecords::Parser::BuildDe
while (1)
{
Start = debListParser::ParseDepends(Start, Stop,
- rec.Package,rec.Version,rec.Op,true, StripMultiArch);
+ rec.Package,rec.Version,rec.Op,true,StripMultiArch,true);
if (Start == 0)
return _error->Error("Problem parsing dependency: %s", fields[I]);
diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h
index a8fb465bb..b65d1480b 100644
--- a/apt-pkg/deb/debsrcrecords.h
+++ b/apt-pkg/deb/debsrcrecords.h
@@ -11,11 +11,16 @@
#ifndef PKGLIB_DEBSRCRECORDS_H
#define PKGLIB_DEBSRCRECORDS_H
-
#include <apt-pkg/srcrecords.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/fileutl.h>
+#include <stddef.h>
+#include <string>
+#include <vector>
+
+class pkgIndexFile;
+
class debSrcRecordParser : public pkgSrcRecords::Parser
{
/** \brief dpointer placeholder (for later in case we need it) */
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index b95ff15df..142f3a6e6 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -19,7 +19,14 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <sys/types.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <string>
+#include <vector>
#include <unistd.h>
#include <dirent.h>
#include <errno.h>
@@ -195,7 +202,7 @@ bool debSystem::Initialize(Configuration &Cnf)
// ---------------------------------------------------------------------
/* The standard name for a deb is 'deb'.. There are no separate versions
of .deb to worry about.. */
-bool debSystem::ArchiveSupported(const char *Type)
+APT_PURE bool debSystem::ArchiveSupported(const char *Type)
{
if (strcmp(Type,"deb") == 0)
return true;
diff --git a/apt-pkg/deb/debsystem.h b/apt-pkg/deb/debsystem.h
index 855123516..a945f68fb 100644
--- a/apt-pkg/deb/debsystem.h
+++ b/apt-pkg/deb/debsystem.h
@@ -12,11 +12,19 @@
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <vector>
+class Configuration;
+class pkgIndexFile;
+class pkgPackageManager;
class debSystemPrivate;
-class debStatusIndex;
class pkgDepCache;
+#ifndef APT_10_CLEANER_HEADERS
+class debStatusIndex;
+#endif
+
class debSystem : public pkgSystem
{
// private d-pointer
diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc
index 74e2552ff..a5eacb7f5 100644
--- a/apt-pkg/deb/debversion.cc
+++ b/apt-pkg/deb/debversion.cc
@@ -15,6 +15,8 @@
#include <apt-pkg/debversion.h>
#include <apt-pkg/pkgcache.h>
+#include <string.h>
+#include <string>
#include <stdlib.h>
#include <ctype.h>
/*}}}*/
diff --git a/apt-pkg/deb/debversion.h b/apt-pkg/deb/debversion.h
index f1d6f3cc5..434ff4a2e 100644
--- a/apt-pkg/deb/debversion.h
+++ b/apt-pkg/deb/debversion.h
@@ -12,26 +12,26 @@
#ifndef PKGLIB_DEBVERSION_H
#define PKGLIB_DEBVERSION_H
+#include <apt-pkg/version.h>
+#include <string>
-#include <apt-pkg/version.h>
-
class debVersioningSystem : public pkgVersioningSystem
-{
+{
public:
-
+
static int CmpFragment(const char *A, const char *AEnd, const char *B,
- const char *BEnd);
-
+ const char *BEnd) APT_PURE;
+
// Compare versions..
virtual int DoCmpVersion(const char *A,const char *Aend,
- const char *B,const char *Bend);
- virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer);
- virtual int DoCmpReleaseVer(const char *A,const char *Aend,
+ const char *B,const char *Bend) APT_PURE;
+ virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer) APT_PURE;
+ virtual APT_PURE int DoCmpReleaseVer(const char *A,const char *Aend,
const char *B,const char *Bend)
{
return DoCmpVersion(A,Aend,B,Bend);
- }
+ }
virtual std::string UpstreamVersion(const char *A);
debVersioningSystem();
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 78b777140..c52b83c6e 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -10,40 +10,45 @@
// Includes /*{{{*/
#include <config.h>
-#include <apt-pkg/dpkgpm.h>
-#include <apt-pkg/error.h>
+#include <apt-pkg/cachefile.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/depcache.h>
-#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/strutl.h>
+#include <apt-pkg/dpkgpm.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/cachefile.h>
-#include <apt-pkg/packagemanager.h>
#include <apt-pkg/install-progress.h>
+#include <apt-pkg/packagemanager.h>
+#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
-#include <unistd.h>
-#include <stdlib.h>
+#include <errno.h>
#include <fcntl.h>
+#include <grp.h>
+#include <pty.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/stat.h>
-#include <sys/types.h>
+#include <sys/time.h>
#include <sys/wait.h>
-#include <signal.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <algorithm>
-#include <sstream>
-#include <map>
-#include <pwd.h>
-#include <grp.h>
-#include <iomanip>
-
#include <termios.h>
+#include <time.h>
#include <unistd.h>
-#include <sys/ioctl.h>
-#include <pty.h>
-#include <stdio.h>
+#include <algorithm>
+#include <cstring>
+#include <iostream>
+#include <map>
+#include <set>
+#include <string>
+#include <utility>
+#include <vector>
#include <apti18n.h>
/*}}}*/
@@ -394,10 +399,14 @@ bool pkgDPkgPM::SendPkgsInfo(FILE * const F, unsigned int const &Version)
that are due to be installed. */
bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
{
+ bool result = true;
+
Configuration::Item const *Opts = _config->Tree(Cnf);
if (Opts == 0 || Opts->Child == 0)
return true;
Opts = Opts->Child;
+
+ sighandler_t old_sigpipe = signal(SIGPIPE, SIG_IGN);
unsigned int Count = 1;
for (; Opts != 0; Opts = Opts->Next, Count++)
@@ -405,6 +414,10 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
if (Opts->Value.empty() == true)
continue;
+ if(_config->FindB("Debug::RunScripts", false) == true)
+ std::clog << "Running external script with list of all .deb file: '"
+ << Opts->Value << "'" << std::endl;
+
// Determine the protocol version
string OptSec = Opts->Value;
string::size_type Pos;
@@ -419,8 +432,10 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
std::set<int> KeepFDs;
MergeKeepFdsFromConfiguration(KeepFDs);
int Pipes[2];
- if (pipe(Pipes) != 0)
- return _error->Errno("pipe","Failed to create IPC pipe to subprocess");
+ if (pipe(Pipes) != 0) {
+ result = _error->Errno("pipe","Failed to create IPC pipe to subprocess");
+ break;
+ }
if (InfoFD != (unsigned)Pipes[0])
SetCloseExec(Pipes[0],true);
else
@@ -454,8 +469,10 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
}
close(Pipes[0]);
FILE *F = fdopen(Pipes[1],"w");
- if (F == 0)
- return _error->Errno("fdopen","Faild to open new FD");
+ if (F == 0) {
+ result = _error->Errno("fdopen","Faild to open new FD");
+ break;
+ }
// Feed it the filenames.
if (Version <= 1)
@@ -483,11 +500,14 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
fclose(F);
// Clean up the sub process
- if (ExecWait(Process,Opts->Value.c_str()) == false)
- return _error->Error("Failure running script %s",Opts->Value.c_str());
+ if (ExecWait(Process,Opts->Value.c_str()) == false) {
+ result = _error->Error("Failure running script %s",Opts->Value.c_str());
+ break;
+ }
}
+ signal(SIGPIPE, old_sigpipe);
- return true;
+ return result;
}
/*}}}*/
// DPkgPM::DoStdin - Read stdin and pass to slave pty /*{{{*/
@@ -1570,7 +1590,7 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress)
return d->dpkg_error.empty();
}
-void SigINT(int sig) {
+void SigINT(int /*sig*/) {
pkgPackageManager::SigINTStop = true;
}
/*}}}*/
diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h
index 02e12a6d9..859c74b46 100644
--- a/apt-pkg/deb/dpkgpm.h
+++ b/apt-pkg/deb/dpkgpm.h
@@ -11,11 +11,20 @@
#define PKGLIB_DPKGPM_H
#include <apt-pkg/packagemanager.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/macros.h>
+
#include <vector>
#include <map>
#include <stdio.h>
-#include <apt-pkg/macros.h>
+#include <string>
+
+#ifndef APT_10_CLEANER_HEADERS
#include <apt-pkg/init.h>
+#endif
+
+class pkgDepCache;
+namespace APT { namespace Progress { class PackageManager; } }
#ifndef APT_8_CLEANER_HEADERS
using std::vector;
@@ -82,7 +91,7 @@ class pkgDPkgPM : public pkgPackageManager
// Helpers
bool RunScriptsWithPkgs(const char *Cnf);
- __deprecated bool SendV2Pkgs(FILE *F);
+ APT_DEPRECATED bool SendV2Pkgs(FILE *F);
bool SendPkgsInfo(FILE * const F, unsigned int const &Version);
void WriteHistoryTag(std::string const &tag, std::string value);
std::string ExpandShortPackageName(pkgDepCache &Cache,
@@ -109,10 +118,10 @@ class pkgDPkgPM : public pkgPackageManager
void DoDpkgStatusFd(int statusfd);
void ProcessDpkgStatusLine(char *line);
#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
- void DoDpkgStatusFd(int statusfd, int unused) {
+ void DoDpkgStatusFd(int statusfd, int /*unused*/) {
DoDpkgStatusFd(statusfd);
}
- void ProcessDpkgStatusLine(int unused, char *line) {
+ void ProcessDpkgStatusLine(int /*unused*/, char *line) {
ProcessDpkgStatusLine(line);
}
#endif
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index a12e6963d..19a6e0d7e 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -11,20 +11,26 @@
#include<config.h>
#include <apt-pkg/depcache.h>
-#include <apt-pkg/version.h>
#include <apt-pkg/versionmatch.h>
#include <apt-pkg/error.h>
#include <apt-pkg/sptr.h>
-#include <apt-pkg/algorithms.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/progress.h>
#include <apt-pkg/cacheset.h>
-
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/macros.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <list>
+#include <string>
+#include <utility>
+#include <vector>
#include <algorithm>
#include <iostream>
#include <sstream>
@@ -222,7 +228,7 @@ bool pkgDepCache::readStateFile(OpProgress *Prog) /*{{{*/
return true;
}
/*}}}*/
-bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly) /*{{{*/
+bool pkgDepCache::writeStateFile(OpProgress * /*prog*/, bool InstalledOnly) /*{{{*/
{
bool const debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false);
@@ -868,7 +874,7 @@ bool pkgDepCache::IsDeleteOk(PkgIterator const &Pkg,bool rPurge,
return IsDeleteOkProtectInstallRequests(Pkg, rPurge, Depth, FromUser);
}
bool pkgDepCache::IsDeleteOkProtectInstallRequests(PkgIterator const &Pkg,
- bool const rPurge, unsigned long const Depth, bool const FromUser)
+ bool const /*rPurge*/, unsigned long const Depth, bool const FromUser)
{
if (FromUser == false && Pkg->CurrentVer == 0)
{
@@ -889,7 +895,7 @@ bool pkgDepCache::IsDeleteOkProtectInstallRequests(PkgIterator const &Pkg,
and prevents mode changes for packages on hold for example.
If you want to check Mode specific stuff you can use the virtual public
Is<Mode>Ok methods instead */
-char const* PrintMode(char const mode)
+static char const* PrintMode(char const mode)
{
switch (mode)
{
@@ -1053,10 +1059,9 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
return true;
}
- // check if we are allowed to install the package (if we haven't already)
- if (P.Mode != ModeInstall || P.InstallVer != P.CandidateVer)
- if (IsInstallOk(Pkg,AutoInst,Depth,FromUser) == false)
- return false;
+ // check if we are allowed to install the package
+ if (IsInstallOk(Pkg,AutoInst,Depth,FromUser) == false)
+ return false;
ActionGroup group(*this);
P.iFlags &= ~AutoKept;
@@ -1117,32 +1122,22 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
continue;
/* Check if this dep should be consider for install. If it is a user
- defined important dep and we are installed a new package then
+ defined important dep and we are installed a new package then
it will be installed. Otherwise we only check for important
- deps that have changed from the installed version
- */
+ deps that have changed from the installed version */
if (IsImportantDep(Start) == false)
continue;
- /* If we are in an or group locate the first or that can
- succeed. We have already cached this.. */
+ /* If we are in an or group locate the first or that can
+ succeed. We have already cached this… */
for (; Ors > 1 && (DepState[Start->ID] & DepCVer) != DepCVer; --Ors)
++Start;
+
+ /* unsatisfiable dependency: IsInstallOkDependenciesSatisfiableByCandidates
+ would have prevented us to get here if not overridden, so just skip
+ over the problem here as the frontend will know what it is doing */
if (Ors == 1 && (DepState[Start->ID] &DepCVer) != DepCVer && Start.IsNegative() == false)
- {
- if(DebugAutoInstall == true)
- std::clog << OutputInDepth(Depth) << Start << " can't be satisfied!" << std::endl;
- if (Start.IsCritical() == false)
- continue;
- // if the dependency was critical, we have absolutely no chance to install it,
- // so if it wasn't installed remove it again. If it was, discard the candidate
- // as the problemresolver will trip over it otherwise trying to install it (#735967)
- if (Pkg->CurrentVer == 0)
- MarkDelete(Pkg,false,Depth + 1, false);
- else
- SetCandidateVersion(Pkg.CurrentVer());
- return false;
- }
+ continue;
/* Check if any ImportantDep() (but not Critical) were added
* since we installed the package. Also check for deps that
@@ -1294,14 +1289,20 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
bool pkgDepCache::IsInstallOk(PkgIterator const &Pkg,bool AutoInst,
unsigned long Depth, bool FromUser)
{
- return IsInstallOkMultiArchSameVersionSynced(Pkg,AutoInst, Depth, FromUser);
+ return IsInstallOkMultiArchSameVersionSynced(Pkg,AutoInst, Depth, FromUser) &&
+ IsInstallOkDependenciesSatisfiableByCandidates(Pkg,AutoInst, Depth, FromUser);
}
bool pkgDepCache::IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg,
- bool const AutoInst, unsigned long const Depth, bool const FromUser)
+ bool const /*AutoInst*/, unsigned long const Depth, bool const FromUser)
{
if (FromUser == true) // as always: user is always right
return true;
+ // if we have checked before and it was okay, it will still be okay
+ if (PkgState[Pkg->ID].Mode == ModeInstall &&
+ PkgState[Pkg->ID].InstallVer == PkgState[Pkg->ID].CandidateVer)
+ return true;
+
// ignore packages with none-M-A:same candidates
VerIterator const CandVer = PkgState[Pkg->ID].CandidateVerIter(*this);
if (unlikely(CandVer.end() == true) || CandVer == Pkg.CurrentVer() ||
@@ -1334,6 +1335,53 @@ bool pkgDepCache::IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg,
return true;
}
+bool pkgDepCache::IsInstallOkDependenciesSatisfiableByCandidates(PkgIterator const &Pkg,
+ bool const AutoInst, unsigned long const Depth, bool const /*FromUser*/)
+{
+ if (AutoInst == false)
+ return true;
+
+ VerIterator const CandVer = PkgState[Pkg->ID].CandidateVerIter(*this);
+ if (unlikely(CandVer.end() == true) || CandVer == Pkg.CurrentVer())
+ return true;
+
+ for (DepIterator Dep = CandVer.DependsList(); Dep.end() != true;)
+ {
+ // Grok or groups
+ DepIterator Start = Dep;
+ bool Result = true;
+ unsigned Ors = 0;
+ for (bool LastOR = true; Dep.end() == false && LastOR == true; ++Dep, ++Ors)
+ {
+ LastOR = (Dep->CompareOp & Dep::Or) == Dep::Or;
+
+ if ((DepState[Dep->ID] & DepInstall) == DepInstall)
+ Result = false;
+ }
+
+ if (Start.IsCritical() == false || Start.IsNegative() == true || Result == false)
+ continue;
+
+ /* If we are in an or group locate the first or that can succeed.
+ We have already cached this… */
+ for (; Ors > 1 && (DepState[Start->ID] & DepCVer) != DepCVer; --Ors)
+ ++Start;
+
+ if (Ors == 1 && (DepState[Start->ID] &DepCVer) != DepCVer)
+ {
+ if (DebugAutoInstall == true)
+ std::clog << OutputInDepth(Depth) << Start << " can't be satisfied!" << std::endl;
+
+ // the dependency is critical, but can't be installed, so discard the candidate
+ // as the problemresolver will trip over it otherwise trying to install it (#735967)
+ if (Pkg->CurrentVer != 0)
+ SetCandidateVersion(Pkg.CurrentVer());
+ return false;
+ }
+ }
+
+ return true;
+}
/*}}}*/
// DepCache::SetReInstall - Set the reinstallation flag /*{{{*/
// ---------------------------------------------------------------------
@@ -1685,10 +1733,10 @@ bool pkgDepCache::Policy::IsImportantDep(DepIterator const &Dep)
}
/*}}}*/
// Policy::GetPriority - Get the priority of the package pin /*{{{*/
-signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgIterator const &Pkg)
-{ return 0; };
-signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgFileIterator const &File)
-{ return 0; };
+APT_CONST signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgIterator const &/*Pkg*/)
+{ return 0; }
+APT_CONST signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgFileIterator const &/*File*/)
+{ return 0; }
/*}}}*/
pkgDepCache::InRootSetFunc *pkgDepCache::GetRootSetFunc() /*{{{*/
{
diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h
index f6848f383..bec651279 100644
--- a/apt-pkg/depcache.h
+++ b/apt-pkg/depcache.h
@@ -40,18 +40,27 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/macros.h>
+
+#include <stddef.h>
-#include <vector>
#include <memory>
-#include <set>
#include <list>
+#include <string>
+#include <utility>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/progress.h>
#include <apt-pkg/error.h>
#endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <set>
+#include <vector>
+#endif
class OpProgress;
+class pkgVersioningSystem;
class pkgDepCache : protected pkgCache::Namespace
{
@@ -61,7 +70,7 @@ class pkgDepCache : protected pkgCache::Namespace
class InRootSetFunc
{
public:
- virtual bool InRootSet(const pkgCache::PkgIterator &pkg) {return false;};
+ virtual bool InRootSet(const pkgCache::PkgIterator &/*pkg*/) {return false;};
virtual ~InRootSetFunc() {};
};
@@ -231,7 +240,7 @@ class pkgDepCache : protected pkgCache::Namespace
unsigned char DepState; // DepState Flags
// Update of candidate version
- const char *StripEpoch(const char *Ver);
+ const char *StripEpoch(const char *Ver) APT_PURE;
void Update(PkgIterator Pkg,pkgCache &Cache);
// Various test members for the current status of the package
@@ -381,8 +390,8 @@ class pkgDepCache : protected pkgCache::Namespace
/** \brief Update the Marked and Garbage fields of all packages.
*
* This routine is implicitly invoked after all state manipulators
- * and when an ActionGroup is destroyed. It invokes #MarkRequired
- * and #Sweep to do its dirty work.
+ * and when an ActionGroup is destroyed. It invokes the private
+ * MarkRequired() and Sweep() to do its dirty work.
*
* \param rootFunc A predicate that returns \b true for packages
* that should be added to the root set.
@@ -465,7 +474,7 @@ class pkgDepCache : protected pkgCache::Namespace
*
* The parameters are the same as in the calling MarkDelete:
* \param Pkg the package that MarkDelete wants to remove.
- * \param Purge should we purge instead of "only" remove?
+ * \param MarkPurge should we purge instead of "only" remove?
* \param Depth recursive deep of this Marker call
* \param FromUser was the remove requested by the user?
*/
@@ -497,6 +506,8 @@ class pkgDepCache : protected pkgCache::Namespace
// methods call by IsInstallOk
bool IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg,
bool const AutoInst, unsigned long const Depth, bool const FromUser);
+ bool IsInstallOkDependenciesSatisfiableByCandidates(PkgIterator const &Pkg,
+ bool const AutoInst, unsigned long const Depth, bool const FromUser);
// methods call by IsDeleteOk
bool IsDeleteOkProtectInstallRequests(PkgIterator const &Pkg,
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index e90598392..ee42267bc 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -11,16 +11,25 @@
#include <apt-pkg/error.h>
#include <apt-pkg/cacheset.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/version.h>
-#include <apt-pkg/policy.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/progress.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/strutl.h>
-#include <limits>
+#include <ctype.h>
+#include <stddef.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
#include <stdio.h>
-
+#include <iostream>
+#include <vector>
+#include <limits>
#include <string>
+#include <list>
#include <apti18n.h>
/*}}}*/
@@ -44,7 +53,7 @@ bool EDSP::WriteScenario(pkgDepCache &Cache, FILE* output, OpProgress *Progress)
for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver, ++p)
{
WriteScenarioVersion(Cache, output, Pkg, Ver);
- WriteScenarioDependency(Cache, output, Pkg, Ver);
+ WriteScenarioDependency(output, Ver);
fprintf(output, "\n");
if (Progress != NULL && p % 100 == 0)
Progress->Progress(p);
@@ -64,7 +73,7 @@ bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FILE* output,
for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver)
{
WriteScenarioVersion(Cache, output, Pkg, Ver);
- WriteScenarioLimitedDependency(Cache, output, Pkg, Ver, pkgset);
+ WriteScenarioLimitedDependency(output, Ver, pkgset);
fprintf(output, "\n");
if (Progress != NULL && p % 100 == 0)
Progress->Progress(p);
@@ -111,8 +120,7 @@ void EDSP::WriteScenarioVersion(pkgDepCache &Cache, FILE* output, pkgCache::PkgI
}
/*}}}*/
// EDSP::WriteScenarioDependency /*{{{*/
-void EDSP::WriteScenarioDependency(pkgDepCache &Cache, FILE* output, pkgCache::PkgIterator const &Pkg,
- pkgCache::VerIterator const &Ver)
+void EDSP::WriteScenarioDependency( FILE* output, pkgCache::VerIterator const &Ver)
{
std::string dependencies[pkgCache::Dep::Enhances + 1];
bool orGroup = false;
@@ -148,8 +156,7 @@ void EDSP::WriteScenarioDependency(pkgDepCache &Cache, FILE* output, pkgCache::P
}
/*}}}*/
// EDSP::WriteScenarioLimitedDependency /*{{{*/
-void EDSP::WriteScenarioLimitedDependency(pkgDepCache &Cache, FILE* output,
- pkgCache::PkgIterator const &Pkg,
+void EDSP::WriteScenarioLimitedDependency(FILE* output,
pkgCache::VerIterator const &Ver,
APT::PackageSet const &pkgset)
{
diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h
index fd4436f60..f3092d3c6 100644
--- a/apt-pkg/edsp.h
+++ b/apt-pkg/edsp.h
@@ -9,8 +9,12 @@
#ifndef PKGLIB_EDSP_H
#define PKGLIB_EDSP_H
-#include <apt-pkg/pkgcache.h>
#include <apt-pkg/cacheset.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/macros.h>
+
+#include <stdio.h>
#include <list>
#include <string>
@@ -29,17 +33,15 @@ class EDSP /*{{{*/
static const char * const PrioMap[];
static const char * const DepMap[];
- bool static ReadLine(int const input, std::string &line);
- bool static StringToBool(char const *answer, bool const defValue);
+ APT_HIDDEN bool static ReadLine(int const input, std::string &line);
+ APT_HIDDEN bool static StringToBool(char const *answer, bool const defValue);
- void static WriteScenarioVersion(pkgDepCache &Cache, FILE* output,
+ APT_HIDDEN void static WriteScenarioVersion(pkgDepCache &Cache, FILE* output,
pkgCache::PkgIterator const &Pkg,
pkgCache::VerIterator const &Ver);
- void static WriteScenarioDependency(pkgDepCache &Cache, FILE* output,
- pkgCache::PkgIterator const &Pkg,
+ APT_HIDDEN void static WriteScenarioDependency(FILE* output,
pkgCache::VerIterator const &Ver);
- void static WriteScenarioLimitedDependency(pkgDepCache &Cache, FILE* output,
- pkgCache::PkgIterator const &Pkg,
+ APT_HIDDEN void static WriteScenarioLimitedDependency(FILE* output,
pkgCache::VerIterator const &Ver,
APT::PackageSet const &pkgset);
public:
diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc
index 98ce4497a..10313fd61 100644
--- a/apt-pkg/edsp/edspindexfile.cc
+++ b/apt-pkg/edsp/edspindexfile.cc
@@ -10,15 +10,20 @@
#include <apt-pkg/edspindexfile.h>
#include <apt-pkg/edsplistparser.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/progress.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/acquire-item.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/debindexfile.h>
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/mmap.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcachegen.h>
+#include <apt-pkg/pkgrecords.h>
-#include <sys/stat.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <string>
/*}}}*/
// edspIndex::edspIndex - Constructor /*{{{*/
@@ -63,7 +68,7 @@ bool edspIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
class edspIFType: public pkgIndexFile::Type
{
public:
- virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
+ virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator) const
{
// we don't have a record parser for this type as the file is not presistent
return NULL;
diff --git a/apt-pkg/edsp/edspindexfile.h b/apt-pkg/edsp/edspindexfile.h
index de10f2d2f..609a2cde4 100644
--- a/apt-pkg/edsp/edspindexfile.h
+++ b/apt-pkg/edsp/edspindexfile.h
@@ -9,11 +9,15 @@
#define PKGLIB_EDSPINDEXFILE_H
#include <apt-pkg/debindexfile.h>
+#include <string>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/indexfile.h>
#endif
+class OpProgress;
+class pkgCacheGenerator;
+
class edspIndex : public debStatusIndex
{
/** \brief dpointer placeholder (for later in case we need it) */
@@ -21,7 +25,7 @@ class edspIndex : public debStatusIndex
public:
- virtual const Type *GetType() const;
+ virtual const Type *GetType() const APT_CONST;
virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc
index bcfdb1017..212dc7840 100644
--- a/apt-pkg/edsp/edsplistparser.cc
+++ b/apt-pkg/edsp/edsplistparser.cc
@@ -12,11 +12,13 @@
#include <config.h>
#include <apt-pkg/edsplistparser.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/md5.h>
-#include <apt-pkg/macros.h>
+#include <apt-pkg/deblistparser.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/tagfile.h>
+
+#include <string>
/*}}}*/
// ListParser::edspListParser - Constructor /*{{{*/
@@ -84,8 +86,8 @@ bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
}
/*}}}*/
// ListParser::LoadReleaseInfo - Load the release information /*{{{*/
-bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
- FileFd &File, std::string component)
+APT_CONST bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator & /*FileI*/,
+ FileFd & /*File*/, std::string /*component*/)
{
return true;
}
diff --git a/apt-pkg/edsp/edsplistparser.h b/apt-pkg/edsp/edsplistparser.h
index a7bf9de95..959fb587f 100644
--- a/apt-pkg/edsp/edsplistparser.h
+++ b/apt-pkg/edsp/edsplistparser.h
@@ -12,6 +12,10 @@
#define PKGLIB_EDSPLISTPARSER_H
#include <apt-pkg/deblistparser.h>
+#include <apt-pkg/md5.h>
+#include <apt-pkg/pkgcache.h>
+
+#include <string>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/pkgcachegen.h>
diff --git a/apt-pkg/edsp/edspsystem.cc b/apt-pkg/edsp/edspsystem.cc
index aae969d9d..92edb8d77 100644
--- a/apt-pkg/edsp/edspsystem.cc
+++ b/apt-pkg/edsp/edspsystem.cc
@@ -11,16 +11,17 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/edspsystem.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/debversion.h>
#include <apt-pkg/edspindexfile.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/error.h>
+#include <apt-pkg/edspsystem.h>
#include <apt-pkg/fileutl.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <errno.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <stddef.h>
+#include <string>
+#include <vector>
#include <apti18n.h>
/*}}}*/
@@ -49,7 +50,7 @@ bool edspSystem::Lock()
}
/*}}}*/
// System::UnLock - Drop a lock /*{{{*/
-bool edspSystem::UnLock(bool NoErrors)
+bool edspSystem::UnLock(bool /*NoErrors*/)
{
return true;
}
@@ -58,7 +59,7 @@ bool edspSystem::UnLock(bool NoErrors)
// ---------------------------------------------------------------------
/* we can't use edsp input as input for real installations - just a
simulation can work, but everything else will fail bigtime */
-pkgPackageManager *edspSystem::CreatePM(pkgDepCache *Cache) const
+pkgPackageManager *edspSystem::CreatePM(pkgDepCache * /*Cache*/) const
{
return NULL;
}
@@ -81,7 +82,7 @@ bool edspSystem::Initialize(Configuration &Cnf)
}
/*}}}*/
// System::ArchiveSupported - Is a file format supported /*{{{*/
-bool edspSystem::ArchiveSupported(const char *Type)
+bool edspSystem::ArchiveSupported(const char * /*Type*/)
{
return false;
}
diff --git a/apt-pkg/edsp/edspsystem.h b/apt-pkg/edsp/edspsystem.h
index ca703fa84..65e36d714 100644
--- a/apt-pkg/edsp/edspsystem.h
+++ b/apt-pkg/edsp/edspsystem.h
@@ -11,8 +11,17 @@
#define PKGLIB_EDSPSYSTEM_H
#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcache.h>
+#include <vector>
+
+class Configuration;
+class pkgDepCache;
+class pkgIndexFile;
+class pkgPackageManager;
class edspIndex;
+
class edspSystem : public pkgSystem
{
/** \brief dpointer placeholder (for later in case we need it) */
@@ -22,11 +31,11 @@ class edspSystem : public pkgSystem
public:
- virtual bool Lock();
- virtual bool UnLock(bool NoErrors = false);
- virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const;
+ virtual bool Lock() APT_CONST;
+ virtual bool UnLock(bool NoErrors = false) APT_CONST;
+ virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const APT_CONST;
virtual bool Initialize(Configuration &Cnf);
- virtual bool ArchiveSupported(const char *Type);
+ virtual bool ArchiveSupported(const char *Type) APT_CONST;
virtual signed Score(Configuration const &Cnf);
virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List);
virtual bool FindIndex(pkgCache::PkgFileIterator File,
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index 7694cb1dd..854ba1bd7 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -20,17 +20,17 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/indexrecords.h>
-#include <apt-pkg/md5.h>
#include <apt-pkg/cdrom.h>
+#include <apt-pkg/gpgv.h>
+#include <apt-pkg/hashes.h>
#include <iostream>
#include <sstream>
#include <unistd.h>
#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "indexcopy.h"
#include <apti18n.h>
@@ -65,7 +65,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin();
c != compressor.end(); ++c)
{
- if (stat(std::string(file + c->Extension).c_str(), &Buf) != 0)
+ if (stat((file + c->Extension).c_str(), &Buf) != 0)
continue;
found = true;
break;
@@ -160,7 +160,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
// Get the size
struct stat Buf;
- if (stat(string(CDROM + Prefix + File).c_str(),&Buf) != 0 ||
+ if (stat((CDROM + Prefix + File).c_str(),&Buf) != 0 ||
Buf.st_size == 0)
{
bool Mangled = false;
@@ -175,7 +175,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
}
if (Mangled == false ||
- stat(string(CDROM + Prefix + File).c_str(),&Buf) != 0)
+ stat((CDROM + Prefix + File).c_str(),&Buf) != 0)
{
if (Debug == true)
clog << "Missed(2): " << OrigFile << endl;
@@ -286,7 +286,7 @@ bool IndexCopy::ReconstructPrefix(string &Prefix,string OrigPath,string CD,
while (1)
{
struct stat Buf;
- if (stat(string(CD + MyPrefix + File).c_str(),&Buf) != 0)
+ if (stat((CD + MyPrefix + File).c_str(),&Buf) != 0)
{
if (Debug == true)
cout << "Failed, " << CD + MyPrefix + File << endl;
@@ -315,7 +315,7 @@ bool IndexCopy::ReconstructChop(unsigned long &Chop,string Dir,string File)
while (1)
{
struct stat Buf;
- if (stat(string(Dir + File).c_str(),&Buf) != 0)
+ if (stat((Dir + File).c_str(),&Buf) != 0)
{
File = ChopDirs(File,1);
Depth++;
@@ -436,8 +436,8 @@ bool PackageCopy::GetFile(string &File,unsigned long long &Size)
/* */
bool PackageCopy::RewriteEntry(FILE *Target,string File)
{
- TFRewriteData Changes[] = {{"Filename",File.c_str()},
- {}};
+ TFRewriteData Changes[] = {{ "Filename", File.c_str(), NULL },
+ { NULL, NULL, NULL }};
if (TFRewrite(Target,*Section,TFRewritePackageOrder,Changes) == false)
return false;
@@ -482,8 +482,8 @@ bool SourceCopy::GetFile(string &File,unsigned long long &Size)
bool SourceCopy::RewriteEntry(FILE *Target,string File)
{
string Dir(File,0,File.rfind('/'));
- TFRewriteData Changes[] = {{"Directory",Dir.c_str()},
- {}};
+ TFRewriteData Changes[] = {{ "Directory", Dir.c_str(), NULL },
+ { NULL, NULL, NULL }};
if (TFRewrite(Target,*Section,TFRewriteSourceOrder,Changes) == false)
return false;
@@ -551,7 +551,7 @@ bool SigVerify::CopyMetaIndex(string CDROM, string CDName, /*{{{*/
}
/*}}}*/
bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList, /*{{{*/
- vector<string> PkgList,vector<string> SrcList)
+ vector<string> /*PkgList*/,vector<string> /*SrcList*/)
{
if (SigList.empty() == true)
return true;
@@ -642,16 +642,14 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
}
/*}}}*/
// SigVerify::RunGPGV - deprecated wrapper calling ExecGPGV /*{{{*/
-bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut,
+APT_NORETURN bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut,
int const &statusfd, int fd[2]) {
ExecGPGV(File, FileOut, statusfd, fd);
- return false;
-};
-bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut,
+}
+APT_NORETURN bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut,
int const &statusfd) {
ExecGPGV(File, FileOut, statusfd);
- return false;
-};
+}
/*}}}*/
bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/
vector<string> &List, pkgCdromStatus *log)
@@ -676,7 +674,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/
for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin();
c != compressor.end(); ++c)
{
- if (stat(std::string(file + c->Extension).c_str(), &Buf) != 0)
+ if (stat((file + c->Extension).c_str(), &Buf) != 0)
continue;
found = true;
break;
diff --git a/apt-pkg/indexcopy.h b/apt-pkg/indexcopy.h
index e6a07a887..43cdb3f0a 100644
--- a/apt-pkg/indexcopy.h
+++ b/apt-pkg/indexcopy.h
@@ -14,16 +14,18 @@
#include <string>
#include <stdio.h>
-#include <apt-pkg/gpgv.h>
#include <apt-pkg/macros.h>
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/gpgv.h>
+class FileFd;
+#endif
#ifndef APT_8_CLEANER_HEADERS
using std::string;
using std::vector;
#endif
class pkgTagSection;
-class FileFd;
class indexRecords;
class pkgCdromStatus;
@@ -99,9 +101,9 @@ class SigVerify /*{{{*/
bool CopyAndVerify(std::string CDROM,std::string Name,std::vector<std::string> &SigList,
std::vector<std::string> PkgList,std::vector<std::string> SrcList);
- __deprecated static bool RunGPGV(std::string const &File, std::string const &FileOut,
+ APT_DEPRECATED static bool RunGPGV(std::string const &File, std::string const &FileOut,
int const &statusfd, int fd[2]);
- __deprecated static bool RunGPGV(std::string const &File, std::string const &FileOut,
+ APT_DEPRECATED static bool RunGPGV(std::string const &File, std::string const &FileOut,
int const &statusfd = -1);
};
/*}}}*/
diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc
index 642a750d4..89615cb41 100644
--- a/apt-pkg/indexfile.cc
+++ b/apt-pkg/indexfile.cc
@@ -13,7 +13,13 @@
#include <apt-pkg/indexfile.h>
#include <apt-pkg/error.h>
#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/srcrecords.h>
+#include <apt-pkg/macros.h>
+#include <string>
+#include <vector>
#include <clocale>
#include <cstring>
/*}}}*/
@@ -47,7 +53,7 @@ pkgIndexFile::Type *pkgIndexFile::Type::GetType(const char *Type)
// IndexFile::ArchiveInfo - Stub /*{{{*/
// ---------------------------------------------------------------------
/* */
-std::string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator Ver) const
+std::string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator /*Ver*/) const
{
return std::string();
}
@@ -63,8 +69,8 @@ pkgCache::PkgFileIterator pkgIndexFile::FindInCache(pkgCache &Cache) const
// IndexFile::SourceIndex - Stub /*{{{*/
// ---------------------------------------------------------------------
/* */
-std::string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record,
- pkgSrcRecords::File const &File) const
+std::string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &/*Record*/,
+ pkgSrcRecords::File const &/*File*/) const
{
return std::string();
}
@@ -82,7 +88,7 @@ bool pkgIndexFile::TranslationsAvailable() {
is already done in getLanguages(). Note also that this check is
rather bad (doesn't take three character like ast into account).
TODO: Remove method with next API break */
-__attribute__ ((deprecated)) bool pkgIndexFile::CheckLanguageCode(const char *Lang)
+APT_DEPRECATED bool pkgIndexFile::CheckLanguageCode(const char *Lang)
{
if (strlen(Lang) == 2 || (strlen(Lang) == 5 && Lang[2] == '_'))
return true;
@@ -98,7 +104,7 @@ __attribute__ ((deprecated)) bool pkgIndexFile::CheckLanguageCode(const char *La
/* As we have now possibly more than one LanguageCode this method is
supersided by a) private classmembers or b) getLanguages().
TODO: Remove method with next API break */
-__attribute__ ((deprecated)) std::string pkgIndexFile::LanguageCode() {
+APT_DEPRECATED std::string pkgIndexFile::LanguageCode() {
if (TranslationsAvailable() == false)
return "";
return APT::Configuration::getLanguages()[0];
diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h
index a0096fa34..b5c9ac77e 100644
--- a/apt-pkg/indexfile.h
+++ b/apt-pkg/indexfile.h
@@ -22,18 +22,21 @@
#ifndef PKGLIB_INDEXFILE_H
#define PKGLIB_INDEXFILE_H
-
-#include <string>
-#include <apt-pkg/pkgcache.h>
#include <apt-pkg/srcrecords.h>
#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/macros.h>
+#include <string>
+
#ifndef APT_8_CLEANER_HEADERS
using std::string;
#endif
-
+#ifndef APT_10_CLEANER_HEADERS
class pkgAcquire;
+#endif
+
class pkgCacheGenerator;
class OpProgress;
@@ -51,7 +54,7 @@ class pkgIndexFile
// Global list of Items supported
static Type **GlobalList;
static unsigned long GlobalListLen;
- static Type *GetType(const char *Type);
+ static Type *GetType(const char *Type) APT_PURE;
const char *Label;
@@ -78,11 +81,11 @@ class pkgIndexFile
virtual bool Exists() const = 0;
virtual bool HasPackages() const = 0;
virtual unsigned long Size() const = 0;
- virtual bool Merge(pkgCacheGenerator &Gen, OpProgress* Prog) const { return false; };
- __deprecated virtual bool Merge(pkgCacheGenerator &Gen, OpProgress &Prog) const
+ virtual bool Merge(pkgCacheGenerator &/*Gen*/, OpProgress* /*Prog*/) const { return false; };
+ APT_DEPRECATED virtual bool Merge(pkgCacheGenerator &Gen, OpProgress &Prog) const
{ return Merge(Gen, &Prog); };
- virtual bool MergeFileProvides(pkgCacheGenerator &Gen,OpProgress* Prog) const {return true;};
- __deprecated virtual bool MergeFileProvides(pkgCacheGenerator &Gen, OpProgress &Prog) const
+ virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress* /*Prog*/) const {return true;};
+ APT_DEPRECATED virtual bool MergeFileProvides(pkgCacheGenerator &Gen, OpProgress &Prog) const
{return MergeFileProvides(Gen, &Prog);};
virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc
index f8097c3c6..5353d1098 100644
--- a/apt-pkg/indexrecords.cc
+++ b/apt-pkg/indexrecords.cc
@@ -14,41 +14,46 @@
#include <apt-pkg/hashes.h>
#include <apt-pkg/gpgv.h>
-#include <sys/stat.h>
+#include <stdlib.h>
+#include <time.h>
#include <clocale>
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
#include <apti18n.h>
/*}}}*/
using std::string;
-string indexRecords::GetDist() const
+APT_PURE string indexRecords::GetDist() const
{
return this->Dist;
}
-string indexRecords::GetSuite() const
+APT_PURE string indexRecords::GetSuite() const
{
return this->Suite;
}
-bool indexRecords::CheckDist(const string MaybeDist) const
+APT_PURE bool indexRecords::CheckDist(const string MaybeDist) const
{
return (this->Dist == MaybeDist
|| this->Suite == MaybeDist);
}
-string indexRecords::GetExpectedDist() const
+APT_PURE string indexRecords::GetExpectedDist() const
{
return this->ExpectedDist;
}
-time_t indexRecords::GetValidUntil() const
+APT_PURE time_t indexRecords::GetValidUntil() const
{
return this->ValidUntil;
}
-const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
+APT_PURE const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
{
std::map<std::string, indexRecords::checkSum* >::const_iterator sum = Entries.find(MetaKey);
if (sum == Entries.end())
@@ -56,7 +61,7 @@ const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
return sum->second;
}
-bool indexRecords::Exists(string const &MetaKey) const
+APT_PURE bool indexRecords::Exists(string const &MetaKey) const
{
return Entries.count(MetaKey) == 1;
}
@@ -129,10 +134,10 @@ 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() == false)
- MaxAge = _config->FindI(string("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge);
+ MaxAge = _config->FindI(("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);
+ MinAge = _config->FindI(("Acquire::Min-ValidTime::" + Label).c_str(), MinAge);
if(MaxAge == 0 &&
(MinAge == 0 || ValidUntil == 0)) // No user settings, use the one from the Release file
diff --git a/apt-pkg/indexrecords.h b/apt-pkg/indexrecords.h
index d003ec0fa..e31f889ad 100644
--- a/apt-pkg/indexrecords.h
+++ b/apt-pkg/indexrecords.h
@@ -5,17 +5,19 @@
#ifndef PKGLIB_INDEXRECORDS_H
#define PKGLIB_INDEXRECORDS_H
-
-#include <apt-pkg/pkgcache.h>
#include <apt-pkg/hashes.h>
#include <map>
#include <vector>
#include <ctime>
+#include <string>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/fileutl.h>
#endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/pkgcache.h>
+#endif
class indexRecords
{
diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc
index 5d21b3847..241628632 100644
--- a/apt-pkg/init.cc
+++ b/apt-pkg/init.cc
@@ -15,9 +15,11 @@
#include <apt-pkg/error.h>
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/macros.h>
+#include <string.h>
+#include <string>
#include <cstdlib>
-#include <sys/stat.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/init.h b/apt-pkg/init.h
index b6f3df753..d062392e3 100644
--- a/apt-pkg/init.h
+++ b/apt-pkg/init.h
@@ -1,6 +1,5 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: init.h,v 1.9.2.2 2004/01/02 18:51:00 mdz Exp $
/* ######################################################################
Init - Initialize the package library
@@ -17,19 +16,13 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/pkgsystem.h>
#endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/macros.h>
+#endif
class pkgSystem;
class Configuration;
-// These lines are extracted by the makefiles and the buildsystem
-// Increasing MAJOR or MINOR results in the need of recompiling all
-// reverse-dependencies of libapt-pkg against the new SONAME.
-// Non-ABI-Breaks should only increase RELEASE number.
-// See also buildlib/libversion.mak
-#define APT_PKG_MAJOR 4
-#define APT_PKG_MINOR 12
-#define APT_PKG_RELEASE 0
-
extern const char *pkgVersion;
extern const char *pkgLibVersion;
diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc
index a3a4cc0e1..8bb587f67 100644
--- a/apt-pkg/install-progress.cc
+++ b/apt-pkg/install-progress.cc
@@ -1,17 +1,23 @@
+#include <config.h>
+
#include <apt-pkg/configuration.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/install-progress.h>
-#include <apti18n.h>
-
-#include <termios.h>
+#include <signal.h>
+#include <unistd.h>
+#include <iostream>
+#include <string>
+#include <vector>
#include <sys/ioctl.h>
#include <sstream>
#include <fcntl.h>
#include <algorithm>
#include <stdio.h>
+#include <apti18n.h>
+
namespace APT {
namespace Progress {
@@ -41,10 +47,10 @@ PackageManager* PackageManagerProgressFactory()
return progress;
}
-bool PackageManager::StatusChanged(std::string PackageName,
+bool PackageManager::StatusChanged(std::string /*PackageName*/,
unsigned int StepsDone,
unsigned int TotalSteps,
- std::string HumanReadableAction)
+ std::string /*HumanReadableAction*/)
{
int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1);
percentage = StepsDone/(float)TotalSteps * 100.0;
@@ -87,7 +93,7 @@ void PackageManagerProgressFd::StartDpkg()
WriteToStatusFd(status.str());
}
-void PackageManagerProgressFd::Stop()
+APT_CONST void PackageManagerProgressFd::Stop()
{
}
@@ -170,7 +176,7 @@ void PackageManagerProgressDeb822Fd::StartDpkg()
WriteToStatusFd(status.str());
}
-void PackageManagerProgressDeb822Fd::Stop()
+APT_CONST void PackageManagerProgressDeb822Fd::Stop()
{
}
@@ -246,17 +252,22 @@ void PackageManagerFancy::staticSIGWINCH(int signum)
(*I)->HandleSIGWINCH(signum);
}
-int PackageManagerFancy::GetNumberTerminalRows()
+PackageManagerFancy::TermSize
+PackageManagerFancy::GetTerminalSize()
{
struct winsize win;
+ PackageManagerFancy::TermSize s;
+
// FIXME: get from "child_pty" instead?
if(ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win) != 0)
- return -1;
+ return s;
if(_config->FindB("Debug::InstallProgress::Fancy", false) == true)
- std::cerr << "GetNumberTerminalRows: " << win.ws_row << std::endl;
-
- return win.ws_row;
+ std::cerr << "GetTerminalSize: " << win.ws_row << std::endl;
+
+ s.rows = win.ws_row;
+ s.columns = win.ws_col;
+ return s;
}
void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows)
@@ -292,21 +303,21 @@ void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows)
void PackageManagerFancy::HandleSIGWINCH(int)
{
- int nr_terminal_rows = GetNumberTerminalRows();
+ int nr_terminal_rows = GetTerminalSize().rows;
SetupTerminalScrollArea(nr_terminal_rows);
}
void PackageManagerFancy::Start(int a_child_pty)
{
child_pty = a_child_pty;
- int nr_terminal_rows = GetNumberTerminalRows();
+ int nr_terminal_rows = GetTerminalSize().rows;
if (nr_terminal_rows > 0)
SetupTerminalScrollArea(nr_terminal_rows);
}
void PackageManagerFancy::Stop()
{
- int nr_terminal_rows = GetNumberTerminalRows();
+ int nr_terminal_rows = GetTerminalSize().rows;
if (nr_terminal_rows > 0)
{
SetupTerminalScrollArea(nr_terminal_rows + 1);
@@ -318,6 +329,26 @@ void PackageManagerFancy::Stop()
child_pty = -1;
}
+std::string
+PackageManagerFancy::GetTextProgressStr(float Percent, int OutputSize)
+{
+ std::string output;
+ int i;
+
+ // should we raise a exception here instead?
+ if (Percent < 0.0 || Percent > 1.0 || OutputSize < 3)
+ return output;
+
+ int BarSize = OutputSize - 2; // bar without the leading "[" and trailing "]"
+ output += "[";
+ for(i=0; i < BarSize*Percent; i++)
+ output += "#";
+ for (/*nothing*/; i < BarSize; i++)
+ output += ".";
+ output += "]";
+ return output;
+}
+
bool PackageManagerFancy::StatusChanged(std::string PackageName,
unsigned int StepsDone,
unsigned int TotalSteps,
@@ -327,27 +358,47 @@ bool PackageManagerFancy::StatusChanged(std::string PackageName,
HumanReadableAction))
return false;
- int row = GetNumberTerminalRows();
+ PackageManagerFancy::TermSize size = GetTerminalSize();
+
+ static std::string save_cursor = "\033[s";
+ static std::string restore_cursor = "\033[u";
+
+ // green
+ static std::string set_bg_color = DeQuoteString(
+ _config->Find("Dpkg::Progress-Fancy::Progress-fg", "%1b[42m"));
+ // black
+ static std::string set_fg_color = DeQuoteString(
+ _config->Find("Dpkg::Progress-Fancy::Progress-bg", "%1b[30m"));
+
+ static std::string restore_bg = "\033[49m";
+ static std::string restore_fg = "\033[39m";
- static string save_cursor = "\033[s";
- static string restore_cursor = "\033[u";
-
- static string set_bg_color = "\033[42m"; // green
- static string set_fg_color = "\033[30m"; // black
-
- static string restore_bg = "\033[49m";
- static string restore_fg = "\033[39m";
-
std::cout << save_cursor
// move cursor position to last row
- << "\033[" << row << ";0f"
+ << "\033[" << size.rows << ";0f"
<< set_bg_color
<< set_fg_color
<< progress_str
- << restore_cursor
<< restore_bg
<< restore_fg;
std::flush(std::cout);
+
+ // draw text progress bar
+ if (_config->FindB("Dpkg::Progress-Fancy::Progress-Bar", true))
+ {
+ int padding = 4;
+ float progressbar_size = size.columns - padding - progress_str.size();
+ float current_percent = (float)StepsDone/(float)TotalSteps;
+ std::cout << " "
+ << GetTextProgressStr(current_percent, progressbar_size)
+ << " ";
+ std::flush(std::cout);
+ }
+
+ // restore
+ std::cout << restore_cursor;
+ std::flush(std::cout);
+
last_reported_progress = percentage;
return true;
@@ -371,5 +422,5 @@ bool PackageManagerText::StatusChanged(std::string PackageName,
-}; // namespace progress
-}; // namespace apt
+} // namespace progress
+} // namespace apt
diff --git a/apt-pkg/install-progress.h b/apt-pkg/install-progress.h
index 8a5b68a8f..112b034fb 100644
--- a/apt-pkg/install-progress.h
+++ b/apt-pkg/install-progress.h
@@ -24,16 +24,16 @@ namespace Progress {
int last_reported_progress;
public:
- PackageManager()
+ PackageManager()
: percentage(0.0), last_reported_progress(-1) {};
virtual ~PackageManager() {};
/* Global Start/Stop */
- virtual void Start(int child_pty=-1) {};
+ virtual void Start(int /*child_pty*/=-1) {};
virtual void Stop() {};
- /* When dpkg is invoked (may happen multiple times for each
- * install/remove block
+ /* When dpkg is invoked (may happen multiple times for each
+ * install/remove block
*/
virtual void StartDpkg() {};
@@ -44,18 +44,18 @@ namespace Progress {
return 500000;
};
- virtual bool StatusChanged(std::string PackageName,
+ virtual bool StatusChanged(std::string PackageName,
unsigned int StepsDone,
unsigned int TotalSteps,
- std::string HumanReadableAction) ;
- virtual void Error(std::string PackageName,
- unsigned int StepsDone,
- unsigned int TotalSteps,
- std::string ErrorMessage) {};
- virtual void ConffilePrompt(std::string PackageName,
- unsigned int StepsDone,
- unsigned int TotalSteps,
- std::string ConfMessage) {};
+ std::string HumanReadableAction);
+ virtual void Error(std::string /*PackageName*/,
+ unsigned int /*StepsDone*/,
+ unsigned int /*TotalSteps*/,
+ std::string /*ErrorMessage*/) {}
+ virtual void ConffilePrompt(std::string /*PackageName*/,
+ unsigned int /*StepsDone*/,
+ unsigned int /*TotalSteps*/,
+ std::string /*ConfMessage*/) {}
};
class PackageManagerProgressFd : public PackageManager
@@ -72,11 +72,11 @@ namespace Progress {
virtual void StartDpkg();
virtual void Stop();
- virtual bool StatusChanged(std::string PackageName,
+ virtual bool StatusChanged(std::string PackageName,
unsigned int StepsDone,
unsigned int TotalSteps,
std::string HumanReadableAction);
- virtual void Error(std::string PackageName,
+ virtual void Error(std::string PackageName,
unsigned int StepsDone,
unsigned int TotalSteps,
std::string ErrorMessage);
@@ -101,11 +101,11 @@ namespace Progress {
virtual void StartDpkg();
virtual void Stop();
- virtual bool StatusChanged(std::string PackageName,
+ virtual bool StatusChanged(std::string PackageName,
unsigned int StepsDone,
unsigned int TotalSteps,
std::string HumanReadableAction);
- virtual void Error(std::string PackageName,
+ virtual void Error(std::string PackageName,
unsigned int StepsDone,
unsigned int TotalSteps,
std::string ErrorMessage);
@@ -125,7 +125,12 @@ namespace Progress {
void SetupTerminalScrollArea(int nr_rows);
void HandleSIGWINCH(int);
- int GetNumberTerminalRows();
+ typedef struct {
+ int rows;
+ int columns;
+ } TermSize;
+ TermSize GetTerminalSize();
+
sighandler_t old_SIGWINCH;
int child_pty;
@@ -134,23 +139,27 @@ namespace Progress {
~PackageManagerFancy();
virtual void Start(int child_pty=-1);
virtual void Stop();
- virtual bool StatusChanged(std::string PackageName,
+ virtual bool StatusChanged(std::string PackageName,
unsigned int StepsDone,
unsigned int TotalSteps,
std::string HumanReadableAction);
+
+ // return a progress bar of the given size for the given progress
+ // percent between 0.0 and 1.0 in the form "[####...]"
+ static std::string GetTextProgressStr(float percent, int OutputSize);
};
class PackageManagerText : public PackageManager
{
public:
- virtual bool StatusChanged(std::string PackageName,
+ virtual bool StatusChanged(std::string PackageName,
unsigned int StepsDone,
unsigned int TotalSteps,
std::string HumanReadableAction);
};
-}; // namespace Progress
-}; // namespace APT
+} // namespace Progress
+} // namespace APT
#endif
diff --git a/apt-pkg/makefile b/apt-pkg/makefile
index a90131f80..1d456873b 100644
--- a/apt-pkg/makefile
+++ b/apt-pkg/makefile
@@ -21,6 +21,9 @@ endif
ifeq ($(HAVE_BZ2),yes)
SLIBS+= -lbz2
endif
+ifeq ($(HAVE_LZMA),yes)
+SLIBS+= -llzma
+endif
APT_DOMAIN:=libapt-pkg$(LIBAPTPKG_MAJOR)
# Source code for the contributed non-core things
diff --git a/apt-pkg/metaindex.h b/apt-pkg/metaindex.h
index 18a90a29d..ffabaadbf 100644
--- a/apt-pkg/metaindex.h
+++ b/apt-pkg/metaindex.h
@@ -1,12 +1,19 @@
#ifndef PKGLIB_METAINDEX_H
#define PKGLIB_METAINDEX_H
-
-#include <string>
-#include <apt-pkg/pkgcache.h>
#include <apt-pkg/indexfile.h>
#include <apt-pkg/init.h>
+#include <stddef.h>
+
+#include <string>
+#include <vector>
+
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/pkgcache.h>
+class pkgCacheGenerator;
+class OpProgress;
+#endif
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/srcrecords.h>
#include <apt-pkg/pkgrecords.h>
@@ -15,8 +22,6 @@ using std::string;
#endif
class pkgAcquire;
-class pkgCacheGenerator;
-class OpProgress;
class metaIndex
{
diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc
index 21b5fc4e7..a1fcbcc98 100644
--- a/apt-pkg/orderlist.cc
+++ b/apt-pkg/orderlist.cc
@@ -68,10 +68,14 @@
#include <apt-pkg/orderlist.h>
#include <apt-pkg/depcache.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/version.h>
#include <apt-pkg/sptr.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcache.h>
+#include <stdlib.h>
+#include <string.h>
+#include <string>
#include <iostream>
/*}}}*/
diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h
index a2d7b321b..b8bad81b3 100644
--- a/apt-pkg/orderlist.h
+++ b/apt-pkg/orderlist.h
@@ -16,10 +16,12 @@
#ifndef PKGLIB_ORDERLIST_H
#define PKGLIB_ORDERLIST_H
-
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/macros.h>
+#include <string>
+
class pkgDepCache;
class pkgOrderList : protected pkgCache::Namespace
{
@@ -46,7 +48,7 @@ class pkgOrderList : protected pkgCache::Namespace
bool Debug;
// Main visit function
- __deprecated bool VisitNode(PkgIterator Pkg) { return VisitNode(Pkg, "UNKNOWN"); };
+ APT_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);
@@ -68,9 +70,9 @@ class pkgOrderList : protected pkgCache::Namespace
// For pre sorting
static pkgOrderList *Me;
- static int OrderCompareA(const void *a, const void *b);
- static int OrderCompareB(const void *a, const void *b);
- int FileCmp(PkgIterator A,PkgIterator B);
+ static int OrderCompareA(const void *a, const void *b) APT_PURE;
+ static int OrderCompareB(const void *a, const void *b) APT_PURE;
+ int FileCmp(PkgIterator A,PkgIterator B) APT_PURE;
public:
@@ -100,7 +102,7 @@ class pkgOrderList : protected pkgCache::Namespace
inline void RmFlag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] &= ~F;};
// IsNow will return true if the Pkg has been not been either configured or unpacked
inline bool IsNow(PkgIterator Pkg) {return (Flags[Pkg->ID] & (States & (~Removed))) == 0;};
- bool IsMissing(PkgIterator Pkg);
+ bool IsMissing(PkgIterator Pkg) APT_PURE;
void WipeFlags(unsigned long F);
void SetFileList(std::string *FileList) {this->FileList = FileList;};
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index def35cd5f..5d6bc6bd2 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -13,7 +13,7 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
#include <apt-pkg/packagemanager.h>
#include <apt-pkg/orderlist.h>
@@ -24,7 +24,14 @@
#include <apt-pkg/algorithms.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/sptr.h>
-
+#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/strutl.h>
+
+#include <stddef.h>
+#include <list>
+#include <string>
#include <iostream>
#include <apti18n.h>
diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h
index 853b9bac8..344ed9192 100644
--- a/apt-pkg/packagemanager.h
+++ b/apt-pkg/packagemanager.h
@@ -23,15 +23,17 @@
#ifndef PKGLIB_PACKAGEMANAGER_H
#define PKGLIB_PACKAGEMANAGER_H
-#include <apt-pkg/macros.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/install-progress.h>
#include <apt-pkg/init.h>
+#include <apt-pkg/macros.h>
#include <string>
-#include <iostream>
#include <set>
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/install-progress.h>
+#include <iostream>
+#endif
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/depcache.h>
using std::string;
@@ -73,7 +75,7 @@ class pkgPackageManager : protected pkgCache::Namespace
bool CreateOrderList();
// Analysis helpers
- bool DepAlwaysTrue(DepIterator D);
+ bool DepAlwaysTrue(DepIterator D) APT_PURE;
// Install helpers
bool ConfigureAll();
@@ -89,9 +91,9 @@ class pkgPackageManager : protected pkgCache::Namespace
virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
- virtual bool Go(APT::Progress::PackageManager *progress) {return true;};
+ virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;};
#else
- virtual bool Go(int statusFd=-1) {return true;};
+ virtual bool Go(int /*statusFd*/=-1) {return true;};
#endif
virtual void Reset() {};
@@ -109,7 +111,7 @@ class pkgPackageManager : protected pkgCache::Namespace
#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
OrderResult DoInstall(APT::Progress::PackageManager *progress);
// compat
- __deprecated OrderResult DoInstall(int statusFd=-1);
+ APT_DEPRECATED OrderResult DoInstall(int statusFd=-1);
#else
OrderResult DoInstall(int statusFd=-1);
#endif
@@ -124,7 +126,7 @@ class pkgPackageManager : protected pkgCache::Namespace
// stuff that needs to be done after the fork
OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress);
// compat
- __deprecated OrderResult DoInstallPostFork(int statusFd=-1);
+ APT_DEPRECATED OrderResult DoInstallPostFork(int statusFd=-1);
#else
OrderResult DoInstallPostFork(int statusFd=-1);
#endif
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index 67a2a709d..91b75f52e 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -29,12 +29,15 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/mmap.h>
#include <apt-pkg/macros.h>
+#include <stddef.h>
+#include <string.h>
+#include <ostream>
+#include <vector>
#include <string>
#include <sys/stat.h>
-#include <unistd.h>
-#include <ctype.h>
#include <apti18n.h>
/*}}}*/
@@ -52,7 +55,11 @@ pkgCache::Header::Header()
/* Whenever the structures change the major version should be bumped,
whenever the generator changes the minor version should be bumped. */
MajorVersion = 8;
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ MinorVersion = 2;
+#else
MinorVersion = 1;
+#endif
Dirty = false;
HeaderSz = sizeof(pkgCache::Header);
@@ -414,7 +421,7 @@ pkgCache::PkgIterator pkgCache::GrpIterator::NextPkg(pkgCache::PkgIterator const
// GrpIterator::operator ++ - Postfix incr /*{{{*/
// ---------------------------------------------------------------------
/* This will advance to the next logical group in the hash table. */
-void pkgCache::GrpIterator::operator ++(int)
+void pkgCache::GrpIterator::operator ++(int)
{
// Follow the current links
if (S != Owner->GrpP)
@@ -426,12 +433,12 @@ void pkgCache::GrpIterator::operator ++(int)
HashIndex++;
S = Owner->GrpP + Owner->HeaderP->GrpHashTable[HashIndex];
}
-};
+}
/*}}}*/
// PkgIterator::operator ++ - Postfix incr /*{{{*/
// ---------------------------------------------------------------------
/* This will advance to the next logical package in the hash table. */
-void pkgCache::PkgIterator::operator ++(int)
+void pkgCache::PkgIterator::operator ++(int)
{
// Follow the current links
if (S != Owner->PkgP)
@@ -443,7 +450,7 @@ void pkgCache::PkgIterator::operator ++(int)
HashIndex++;
S = Owner->PkgP + Owner->HeaderP->PkgHashTable[HashIndex];
}
-};
+}
/*}}}*/
// PkgIterator::State - Check the State of the package /*{{{*/
// ---------------------------------------------------------------------
@@ -475,26 +482,26 @@ pkgCache::PkgIterator::OkState pkgCache::PkgIterator::State() const
// ---------------------------------------------------------------------
/* Return string representing of the candidate version. */
const char *
-pkgCache::PkgIterator::CandVersion() const
+pkgCache::PkgIterator::CandVersion() const
{
//TargetVer is empty, so don't use it.
VerIterator version = pkgPolicy(Owner).GetCandidateVer(*this);
if (version.IsGood())
return version.VerStr();
return 0;
-};
+}
/*}}}*/
// PkgIterator::CurVersion - Returns the current version string /*{{{*/
// ---------------------------------------------------------------------
/* Return string representing of the current version. */
const char *
-pkgCache::PkgIterator::CurVersion() const
+pkgCache::PkgIterator::CurVersion() const
{
VerIterator version = CurrentVer();
if (version.IsGood())
return CurrentVer().VerStr();
return 0;
-};
+}
/*}}}*/
// ostream operator to handle string representation of a package /*{{{*/
// ---------------------------------------------------------------------
@@ -695,7 +702,7 @@ void pkgCache::DepIterator::GlobOr(DepIterator &Start,DepIterator &End)
// ---------------------------------------------------------------------
/* Deps like self-conflicts should be ignored as well as implicit conflicts
on virtual packages. */
-bool pkgCache::DepIterator::IsIgnorable(PkgIterator const &Pkg) const
+bool pkgCache::DepIterator::IsIgnorable(PkgIterator const &/*Pkg*/) const
{
if (IsNegative() == false)
return false;
@@ -978,7 +985,7 @@ string pkgCache::PkgFileIterator::RelStr()
/*}}}*/
// VerIterator::TranslatedDescription - Return the a DescIter for locale/*{{{*/
// ---------------------------------------------------------------------
-/* return a DescIter for the current locale or the default if none is
+/* return a DescIter for the current locale or the default if none is
* found
*/
pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const
@@ -1012,7 +1019,7 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const
if (strcmp(Desc.LanguageCode(), "") == 0)
return Desc;
return DescriptionList();
-};
+}
/*}}}*/
// PrvIterator::IsMultiArchImplicit - added by the cache generation /*{{{*/
diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h
index c31c5f30b..5e8a9630a 100644
--- a/apt-pkg/pkgcache.h
+++ b/apt-pkg/pkgcache.h
@@ -74,9 +74,11 @@
#ifndef PKGLIB_PKGCACHE_H
#define PKGLIB_PKGCACHE_H
+#include <apt-pkg/mmap.h>
+#include <apt-pkg/macros.h>
+
#include <string>
#include <time.h>
-#include <apt-pkg/mmap.h>
#ifndef APT_8_CLEANER_HEADERS
using std::string;
@@ -156,8 +158,8 @@ class pkgCache /*{{{*/
std::string CacheFile;
MMap &Map;
- unsigned long sHash(const std::string &S) const;
- unsigned long sHash(const char *S) const;
+ unsigned long sHash(const std::string &S) const APT_PURE;
+ unsigned long sHash(const char *S) const APT_PURE;
public:
@@ -176,13 +178,13 @@ class pkgCache /*{{{*/
char *StrP;
virtual bool ReMap(bool const &Errorchecks = true);
- inline bool Sync() {return Map.Sync();};
- inline MMap &GetMap() {return Map;};
- inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();};
+ inline bool Sync() {return Map.Sync();}
+ inline MMap &GetMap() {return Map;}
+ inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();}
// String hashing function (512 range)
- inline unsigned long Hash(const std::string &S) const {return sHash(S);};
- inline unsigned long Hash(const char *S) const {return sHash(S);};
+ inline unsigned long Hash(const std::string &S) const {return sHash(S);}
+ inline unsigned long Hash(const char *S) const {return sHash(S);}
// Useful transformation things
const char *Priority(unsigned char Priority);
@@ -192,7 +194,7 @@ class pkgCache /*{{{*/
PkgIterator FindPkg(const std::string &Name);
PkgIterator FindPkg(const std::string &Name, const std::string &Arch);
- Header &Head() {return *HeaderP;};
+ Header &Head() {return *HeaderP;}
inline GrpIterator GrpBegin();
inline GrpIterator GrpEnd();
inline PkgIterator PkgBegin();
@@ -200,19 +202,19 @@ class pkgCache /*{{{*/
inline PkgFileIterator FileBegin();
inline PkgFileIterator FileEnd();
- inline bool MultiArchCache() const { return MultiArchEnabled; };
- inline char const * const NativeArch() const;
+ inline bool MultiArchCache() const { return MultiArchEnabled; }
+ inline char const * NativeArch();
// Make me a function
pkgVersioningSystem *VS;
// Converters
- static const char *CompTypeDeb(unsigned char Comp);
- static const char *CompType(unsigned char Comp);
+ static const char *CompTypeDeb(unsigned char Comp) APT_CONST;
+ static const char *CompType(unsigned char Comp) APT_CONST;
static const char *DepType(unsigned char Dep);
pkgCache(MMap *Map,bool DoMap = true);
- virtual ~pkgCache() {};
+ virtual ~pkgCache() {}
private:
bool MultiArchEnabled;
@@ -318,7 +320,7 @@ struct pkgCache::Header
/** \brief Size of the complete cache file */
unsigned long CacheFileSize;
- bool CheckSizes(Header &Against) const;
+ bool CheckSizes(Header &Against) const APT_PURE;
Header();
};
/*}}}*/
@@ -451,7 +453,7 @@ struct pkgCache::PackageFile
/** \brief Modification time for the file */
time_t mtime;
- /* @TODO document PackageFile::Flags */
+ /** @TODO document PackageFile::Flags */
unsigned long Flags;
// Linked list
@@ -474,7 +476,7 @@ struct pkgCache::VerFile
map_ptrloc NextFile; // PkgVerFile
/** \brief position in the package file */
map_ptrloc Offset; // File offset
- /* @TODO document pkgCache::VerFile::Size */
+ /** @TODO document pkgCache::VerFile::Size */
unsigned long Size;
};
/*}}}*/
@@ -488,7 +490,7 @@ struct pkgCache::DescFile
map_ptrloc NextFile; // PkgVerFile
/** \brief position in the file */
map_ptrloc Offset; // File offset
- /* @TODO document pkgCache::DescFile::Size */
+ /** @TODO document pkgCache::DescFile::Size */
unsigned long Size;
};
/*}}}*/
@@ -571,7 +573,7 @@ struct pkgCache::Description
and to check that the Translation is up-to-date. */
map_ptrloc md5sum; // StringItem
- /* @TODO document pkgCache::Description::FileList */
+ /** @TODO document pkgCache::Description::FileList */
map_ptrloc FileList; // DescFile
/** \brief next translation for this description */
map_ptrloc NextDesc; // Description
@@ -661,27 +663,27 @@ struct pkgCache::StringItem
/*}}}*/
-inline char const * const pkgCache::NativeArch() const
- { return StrP + HeaderP->Architecture; };
+inline char const * pkgCache::NativeArch()
+ { return StrP + HeaderP->Architecture; }
#include <apt-pkg/cacheiterators.h>
-inline pkgCache::GrpIterator pkgCache::GrpBegin()
- {return GrpIterator(*this);};
-inline pkgCache::GrpIterator pkgCache::GrpEnd()
- {return GrpIterator(*this,GrpP);};
-inline pkgCache::PkgIterator pkgCache::PkgBegin()
- {return PkgIterator(*this);};
-inline pkgCache::PkgIterator pkgCache::PkgEnd()
- {return PkgIterator(*this,PkgP);};
+inline pkgCache::GrpIterator pkgCache::GrpBegin()
+ {return GrpIterator(*this);}
+inline pkgCache::GrpIterator pkgCache::GrpEnd()
+ {return GrpIterator(*this,GrpP);}
+inline pkgCache::PkgIterator pkgCache::PkgBegin()
+ {return PkgIterator(*this);}
+inline pkgCache::PkgIterator pkgCache::PkgEnd()
+ {return PkgIterator(*this,PkgP);}
inline pkgCache::PkgFileIterator pkgCache::FileBegin()
- {return PkgFileIterator(*this,PkgFileP + HeaderP->FileList);};
+ {return PkgFileIterator(*this,PkgFileP + HeaderP->FileList);}
inline pkgCache::PkgFileIterator pkgCache::FileEnd()
- {return PkgFileIterator(*this,PkgFileP);};
+ {return PkgFileIterator(*this,PkgFileP);}
// Oh I wish for Real Name Space Support
class pkgCache::Namespace /*{{{*/
-{
+{
public:
typedef pkgCache::GrpIterator GrpIterator;
typedef pkgCache::PkgIterator PkgIterator;
@@ -690,7 +692,7 @@ class pkgCache::Namespace /*{{{*/
typedef pkgCache::DepIterator DepIterator;
typedef pkgCache::PrvIterator PrvIterator;
typedef pkgCache::PkgFileIterator PkgFileIterator;
- typedef pkgCache::VerFileIterator VerFileIterator;
+ typedef pkgCache::VerFileIterator VerFileIterator;
typedef pkgCache::Version Version;
typedef pkgCache::Description Description;
typedef pkgCache::Package Package;
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 7ce7aba7b..810f0b022 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -18,20 +18,26 @@
#include <apt-pkg/progress.h>
#include <apt-pkg/sourcelist.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/sptr.h>
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/macros.h>
-#include <apt-pkg/tagfile.h>
#include <apt-pkg/metaindex.h>
#include <apt-pkg/fileutl.h>
-
+#include <apt-pkg/hashsum_template.h>
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/md5.h>
+#include <apt-pkg/mmap.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <stddef.h>
+#include <string.h>
+#include <iostream>
+#include <string>
#include <vector>
#include <sys/stat.h>
#include <unistd.h>
-#include <errno.h>
-#include <stdio.h>
#include <apti18n.h>
/*}}}*/
@@ -118,11 +124,11 @@ void pkgCacheGenerator::ReMap(void const * const oldMap, void const * const newM
Cache.ReMap(false);
- CurrentFile += (pkgCache::PackageFile*) newMap - (pkgCache::PackageFile*) oldMap;
+ CurrentFile += (pkgCache::PackageFile const * const) newMap - (pkgCache::PackageFile const * const) oldMap;
for (size_t i = 0; i < _count(UniqHash); ++i)
if (UniqHash[i] != 0)
- UniqHash[i] += (pkgCache::StringItem*) newMap - (pkgCache::StringItem*) oldMap;
+ UniqHash[i] += (pkgCache::StringItem const * const) newMap - (pkgCache::StringItem const * const) oldMap;
for (std::vector<pkgCache::GrpIterator*>::const_iterator i = Dynamic<pkgCache::GrpIterator>::toReMap.begin();
i != Dynamic<pkgCache::GrpIterator>::toReMap.end(); ++i)
@@ -350,7 +356,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator
map_ptrloc *LastVer = &Pkg->VersionList;
void const * oldMap = Map.Data();
- unsigned long const Hash = List.VersionHash();
+ unsigned short const Hash = List.VersionHash();
if (Ver.end() == false)
{
/* We know the list is sorted so we use that fact in the search.
@@ -363,7 +369,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator
if (Res > 0)
break;
// Versionstrings are equal - is hash also equal?
- if (Res == 0 && Ver->Hash == Hash)
+ if (Res == 0 && List.SameVersion(Hash, Ver) == true)
break;
// proceed with the next till we have either the right
// or we found another version (which will be lower)
@@ -398,7 +404,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator
Pkg.Name(), "NewVersion", 1);
if (oldMap != Map.Data())
- LastVer += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
+ LastVer += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap;
*LastVer = verindex;
if (unlikely(List.NewVersion(Ver) == false))
@@ -552,12 +558,12 @@ bool pkgCacheGenerator::MergeFileProvides(ListParser &List)
if (Counter % 100 == 0 && Progress != 0)
Progress->Progress(List.Offset());
- unsigned long Hash = List.VersionHash();
+ unsigned short Hash = List.VersionHash();
pkgCache::VerIterator Ver = Pkg.VersionList();
Dynamic<pkgCache::VerIterator> DynVer(Ver);
for (; Ver.end() == false; ++Ver)
{
- if (Ver->Hash == Hash && Version == Ver.VerStr())
+ if (List.SameVersion(Hash, Ver) == true && Version == Ver.VerStr())
{
if (List.CollectFileProvides(Cache,Ver) == false)
return _error->Error(_("Error occurred while processing %s (%s%d)"),
@@ -909,7 +915,7 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg,
if (unlikely(index == 0))
return false;
if (OldDepLast != 0 && oldMap != Map.Data())
- OldDepLast += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
+ OldDepLast += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap;
}
}
return NewDepends(Pkg, Ver, index, Op, Type, OldDepLast);
@@ -948,7 +954,7 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg,
for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D)
OldDepLast = &D->NextDepends;
} else if (oldMap != Map.Data())
- OldDepLast += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
+ OldDepLast += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap;
Dep->NextDepends = *OldDepLast;
*OldDepLast = Dep.Index();
@@ -1045,6 +1051,12 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver,
return true;
}
/*}}}*/
+bool pkgCacheGenerator::ListParser::SameVersion(unsigned short const Hash,/*{{{*/
+ pkgCache::VerIterator const &Ver)
+{
+ return Hash == Ver->Hash;
+}
+ /*}}}*/
// CacheGenerator::SelectFile - Select the current file being parsed /*{{{*/
// ---------------------------------------------------------------------
/* This is used to select which file is to be associated with all newly
@@ -1125,8 +1137,8 @@ unsigned long pkgCacheGenerator::WriteUniqString(const char *S,
if (unlikely(idxString == 0))
return 0;
if (oldMap != Map.Data()) {
- Last += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
- I += (pkgCache::StringItem*) Map.Data() - (pkgCache::StringItem*) oldMap;
+ Last += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap;
+ I += (pkgCache::StringItem const * const) Map.Data() - (pkgCache::StringItem const * const) oldMap;
}
*Last = Item;
@@ -1249,10 +1261,10 @@ static bool CheckValidity(const string &CacheFile,
static unsigned long ComputeSize(FileIterator Start,FileIterator End)
{
unsigned long TotalSize = 0;
- for (; Start != End; ++Start)
+ for (; Start < End; ++Start)
{
if ((*Start)->HasPackages() == false)
- continue;
+ continue;
TotalSize += (*Start)->Size();
}
return TotalSize;
@@ -1333,7 +1345,7 @@ DynamicMMap* pkgCacheGenerator::CreateDynamicMMap(FileFd *CacheF, unsigned long
the cache will be stored there. This is pretty much mandetory if you
are using AllowMem. AllowMem lets the function be run as non-root
where it builds the cache 'fast' into a memory buffer. */
-__deprecated bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
+APT_DEPRECATED bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
MMap **OutMap, bool AllowMem)
{ return pkgCacheGenerator::MakeStatusCache(List, &Progress, OutMap, AllowMem); }
bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress,
@@ -1534,7 +1546,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
// CacheGenerator::MakeOnlyStatusCache - Build only a status files cache/*{{{*/
// ---------------------------------------------------------------------
/* */
-__deprecated bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap)
+APT_DEPRECATED bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap)
{ return pkgCacheGenerator::MakeOnlyStatusCache(&Progress, OutMap); }
bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **OutMap)
{
@@ -1580,7 +1592,7 @@ static bool IsDuplicateDescription(pkgCache::DescIterator Desc,
}
/*}}}*/
// CacheGenerator::FinishCache /*{{{*/
-bool pkgCacheGenerator::FinishCache(OpProgress *Progress)
+bool pkgCacheGenerator::FinishCache(OpProgress * /*Progress*/)
{
return true;
}
diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h
index 428e8459b..1e1a71026 100644
--- a/apt-pkg/pkgcachegen.h
+++ b/apt-pkg/pkgcachegen.h
@@ -19,16 +19,18 @@
#ifndef PKGLIB_PKGCACHEGEN_H
#define PKGLIB_PKGCACHEGEN_H
-
-#include <apt-pkg/pkgcache.h>
#include <apt-pkg/md5.h>
+#include <apt-pkg/mmap.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/macros.h>
#include <vector>
+#include <string>
+class FileFd;
class pkgSourceList;
class OpProgress;
-class MMap;
class pkgIndexFile;
class pkgCacheGenerator /*{{{*/
@@ -36,10 +38,10 @@ class pkgCacheGenerator /*{{{*/
private:
pkgCache::StringItem *UniqHash[26];
- map_ptrloc WriteStringInMap(std::string const &String) { return WriteStringInMap(String.c_str()); };
- map_ptrloc WriteStringInMap(const char *String);
- map_ptrloc WriteStringInMap(const char *String, const unsigned long &Len);
- map_ptrloc AllocateInMap(const unsigned long &size);
+ APT_HIDDEN map_ptrloc WriteStringInMap(std::string const &String) { return WriteStringInMap(String.c_str()); };
+ APT_HIDDEN map_ptrloc WriteStringInMap(const char *String);
+ APT_HIDDEN map_ptrloc WriteStringInMap(const char *String, const unsigned long &Len);
+ APT_HIDDEN map_ptrloc AllocateInMap(const unsigned long &size);
public:
@@ -80,7 +82,7 @@ class pkgCacheGenerator /*{{{*/
bool NewDepends(pkgCache::PkgIterator &Pkg, pkgCache::VerIterator &Ver,
map_ptrloc const Version, unsigned int const &Op,
unsigned int const &Type, map_ptrloc* &OldDepLast);
- __deprecated unsigned long NewVersion(pkgCache::VerIterator &Ver,const std::string &VerStr,unsigned long Next)
+ unsigned long NewVersion(pkgCache::VerIterator &Ver,const std::string &VerStr,unsigned long Next) APT_DEPRECATED
{ return NewVersion(Ver, VerStr, 0, 0, Next); }
unsigned long NewVersion(pkgCache::VerIterator &Ver,const std::string &VerStr,
map_ptrloc const ParentPkg, unsigned long const Hash,
@@ -102,7 +104,7 @@ class pkgCacheGenerator /*{{{*/
bool HasFileDeps() {return FoundFileDeps;};
bool MergeFileProvides(ListParser &List);
- __deprecated bool FinishCache(OpProgress *Progress);
+ bool FinishCache(OpProgress *Progress) APT_DEPRECATED APT_CONST;
static bool MakeStatusCache(pkgSourceList &List,OpProgress *Progress,
MMap **OutMap = 0,bool AllowMem = false);
@@ -115,14 +117,14 @@ class pkgCacheGenerator /*{{{*/
~pkgCacheGenerator();
private:
- bool MergeListGroup(ListParser &List, std::string const &GrpName);
- bool MergeListPackage(ListParser &List, pkgCache::PkgIterator &Pkg);
- bool MergeListVersion(ListParser &List, pkgCache::PkgIterator &Pkg,
+ APT_HIDDEN bool MergeListGroup(ListParser &List, std::string const &GrpName);
+ APT_HIDDEN bool MergeListPackage(ListParser &List, pkgCache::PkgIterator &Pkg);
+ APT_HIDDEN bool MergeListVersion(ListParser &List, pkgCache::PkgIterator &Pkg,
std::string const &Version, pkgCache::VerIterator* &OutVer);
- bool AddImplicitDepends(pkgCache::GrpIterator &G, pkgCache::PkgIterator &P,
+ APT_HIDDEN bool AddImplicitDepends(pkgCache::GrpIterator &G, pkgCache::PkgIterator &P,
pkgCache::VerIterator &V);
- bool AddImplicitDepends(pkgCache::VerIterator &V, pkgCache::PkgIterator &D);
+ APT_HIDDEN bool AddImplicitDepends(pkgCache::VerIterator &V, pkgCache::PkgIterator &D);
};
/*}}}*/
// This is the abstract package list parser class. /*{{{*/
@@ -162,6 +164,15 @@ class pkgCacheGenerator::ListParser
virtual std::string DescriptionLanguage() = 0;
virtual MD5SumValue Description_md5() = 0;
virtual unsigned short VersionHash() = 0;
+ /** compare currently parsed version with given version
+ *
+ * \param Hash of the currently parsed version
+ * \param Ver to compare with
+ */
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ virtual
+#endif
+ APT_PURE bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver);
virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
pkgCache::VerIterator &Ver) = 0;
virtual unsigned long Offset() = 0;
@@ -170,8 +181,8 @@ class pkgCacheGenerator::ListParser
virtual bool Step() = 0;
inline bool HasFileDeps() {return FoundFileDeps;};
- virtual bool CollectFileProvides(pkgCache &Cache,
- pkgCache::VerIterator &Ver) {return true;};
+ virtual bool CollectFileProvides(pkgCache &/*Cache*/,
+ pkgCache::VerIterator &/*Ver*/) {return true;};
ListParser() : FoundFileDeps(false) {};
virtual ~ListParser() {};
diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc
index 36dab3480..c403e4dc3 100644
--- a/apt-pkg/pkgrecords.cc
+++ b/apt-pkg/pkgrecords.cc
@@ -14,7 +14,11 @@
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/indexfile.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/configuration.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <stddef.h>
+#include <vector>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h
index 3658435e8..b5237b3a0 100644
--- a/apt-pkg/pkgrecords.h
+++ b/apt-pkg/pkgrecords.h
@@ -17,8 +17,9 @@
#ifndef PKGLIB_PKGRECORDS_H
#define PKGLIB_PKGRECORDS_H
-
#include <apt-pkg/pkgcache.h>
+
+#include <string>
#include <vector>
class pkgRecords /*{{{*/
@@ -70,7 +71,7 @@ class pkgRecords::Parser /*{{{*/
virtual std::string Homepage() {return std::string();}
// An arbitrary custom field
- virtual std::string RecordField(const char *fieldName) { return std::string();};
+ virtual std::string RecordField(const char * /*fieldName*/) { return std::string();};
// The record in binary form
virtual void GetRec(const char *&Start,const char *&Stop) {Start = Stop = 0;};
diff --git a/apt-pkg/pkgsystem.cc b/apt-pkg/pkgsystem.cc
index 05ba6e0e6..14d090c7a 100644
--- a/apt-pkg/pkgsystem.cc
+++ b/apt-pkg/pkgsystem.cc
@@ -13,7 +13,8 @@
#include<config.h>
#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/policy.h>
+#include <apt-pkg/macros.h>
+
#include <cassert>
#include <cstring>
/*}}}*/
@@ -36,7 +37,7 @@ pkgSystem::pkgSystem() : Label(NULL), VS(NULL)
// System::GetSystem - Get the named system /*{{{*/
// ---------------------------------------------------------------------
/* */
-pkgSystem *pkgSystem::GetSystem(const char *Label)
+APT_PURE pkgSystem *pkgSystem::GetSystem(const char *Label)
{
for (unsigned I = 0; I != GlobalListLen; I++)
if (strcmp(SysList[I]->Label,Label) == 0)
diff --git a/apt-pkg/pkgsystem.h b/apt-pkg/pkgsystem.h
index eb75df412..6e33c67ed 100644
--- a/apt-pkg/pkgsystem.h
+++ b/apt-pkg/pkgsystem.h
@@ -38,6 +38,7 @@
#define PKGLIB_PKGSYSTEM_H
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
#include <vector>
@@ -50,7 +51,6 @@ class pkgPackageManager;
class pkgVersioningSystem;
class Configuration;
class pkgIndexFile;
-class PkgFileIterator;
class pkgSystem
{
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index d0f97441d..3cfc32829 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -33,7 +33,15 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/sptr.h>
-
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/versionmatch.h>
+
+#include <ctype.h>
+#include <stddef.h>
+#include <string.h>
+#include <string>
+#include <vector>
#include <iostream>
#include <sstream>
@@ -325,7 +333,7 @@ pkgCache::VerIterator pkgPolicy::GetMatch(pkgCache::PkgIterator const &Pkg)
// Policy::GetPriority - Get the priority of the package pin /*{{{*/
// ---------------------------------------------------------------------
/* */
-signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg)
+APT_PURE signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg)
{
if (Pins[Pkg->ID].Type != pkgVersionMatch::None)
{
@@ -337,7 +345,7 @@ signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg)
return 0;
}
-signed short pkgPolicy::GetPriority(pkgCache::PkgFileIterator const &File)
+APT_PURE signed short pkgPolicy::GetPriority(pkgCache::PkgFileIterator const &File)
{
return PFPriority[File->ID];
}
@@ -349,7 +357,7 @@ signed short pkgPolicy::GetPriority(pkgCache::PkgFileIterator const &File)
all over the place rather than forcing a special format */
class PreferenceSection : public pkgTagSection
{
- void TrimRecord(bool BeforeRecord, const char* &End)
+ void TrimRecord(bool /*BeforeRecord*/, const char* &End)
{
for (; Stop < End && (Stop[0] == '\n' || Stop[0] == '\r' || Stop[0] == '#'); Stop++)
if (Stop[0] == '#')
diff --git a/apt-pkg/policy.h b/apt-pkg/policy.h
index 5172a3c3b..f15d8c0a0 100644
--- a/apt-pkg/policy.h
+++ b/apt-pkg/policy.h
@@ -33,10 +33,13 @@
#ifndef PKGLIB_POLICY_H
#define PKGLIB_POLICY_H
-
#include <apt-pkg/depcache.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/versionmatch.h>
+
#include <vector>
+#include <string>
#ifndef APT_8_CLEANER_HEADERS
using std::vector;
diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc
index 1f5179885..e37899ec6 100644
--- a/apt-pkg/sourcelist.cc
+++ b/apt-pkg/sourcelist.cc
@@ -18,7 +18,16 @@
#include <apt-pkg/metaindex.h>
#include <apt-pkg/indexfile.h>
#include <apt-pkg/tagfile.h>
-
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <ctype.h>
+#include <stddef.h>
+#include <time.h>
+#include <cstring>
+#include <map>
+#include <string>
+#include <vector>
#include <fstream>
#include <algorithm>
diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h
index 0ccb4aa00..9df0c1d74 100644
--- a/apt-pkg/sourcelist.h
+++ b/apt-pkg/sourcelist.h
@@ -27,18 +27,27 @@
#ifndef PKGLIB_SOURCELIST_H
#define PKGLIB_SOURCELIST_H
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/macros.h>
+
+#include <time.h>
+
#include <string>
#include <vector>
#include <map>
-#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/tagfile.h>
#ifndef APT_8_CLEANER_HEADERS
+#include <apt-pkg/tagfile.h>
+#endif
+#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/metaindex.h>
using std::string;
using std::vector;
#endif
+class FileFd;
+class pkgTagSection;
class pkgAcquire;
class pkgIndexFile;
class metaIndex;
@@ -55,7 +64,7 @@ class pkgSourceList
// Global list of Items supported
static Type **GlobalList;
static unsigned long GlobalListLen;
- static Type *GetType(const char *Type);
+ static Type *GetType(const char *Type) APT_PURE;
const char *Name;
const char *Label;
diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc
index 60b62850a..775cf2e5f 100644
--- a/apt-pkg/srcrecords.cc
+++ b/apt-pkg/srcrecords.cc
@@ -16,8 +16,13 @@
#include <apt-pkg/srcrecords.h>
#include <apt-pkg/error.h>
#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/metaindex.h>
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/macros.h>
+
+#include <string.h>
+#include <string>
+#include <vector>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/srcrecords.h b/apt-pkg/srcrecords.h
index ed69d0d72..9915debfe 100644
--- a/apt-pkg/srcrecords.h
+++ b/apt-pkg/srcrecords.h
@@ -13,6 +13,7 @@
#ifndef PKGLIB_SRCRECORDS_H
#define PKGLIB_SRCRECORDS_H
+#include <apt-pkg/macros.h>
#include <string>
#include <vector>
@@ -73,7 +74,7 @@ class pkgSrcRecords
//FIXME: Add a parameter to specify which architecture to use for [wildcard] matching
virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0;
- static const char *BuildDepType(unsigned char const &Type);
+ static const char *BuildDepType(unsigned char const &Type) APT_PURE;
virtual bool Files(std::vector<pkgSrcRecords::File> &F) = 0;
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index 832a40d1e..91d176e3c 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -21,6 +21,8 @@
#include <string>
#include <stdio.h>
#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
#include <apti18n.h>
/*}}}*/
@@ -83,7 +85,7 @@ pkgTagFile::~pkgTagFile()
}
/*}}}*/
// TagFile::Offset - Return the current offset in the buffer /*{{{*/
-unsigned long pkgTagFile::Offset()
+APT_PURE unsigned long pkgTagFile::Offset()
{
return d->iOffset;
}
@@ -471,7 +473,7 @@ bool pkgTagSection::FindFlag(const char *Tag,unsigned long &Flags,
return true;
return FindFlag(Flags, Flag, Start, Stop);
}
-bool const pkgTagSection::FindFlag(unsigned long &Flags, unsigned long Flag,
+bool pkgTagSection::FindFlag(unsigned long &Flags, unsigned long Flag,
char const* Start, char const* Stop)
{
switch (StringToBool(string(Start, Stop)))
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
index 518d3dbcd..d5b62e76d 100644
--- a/apt-pkg/tagfile.h
+++ b/apt-pkg/tagfile.h
@@ -20,6 +20,8 @@
#ifndef PKGLIB_TAGFILE_H
#define PKGLIB_TAGFILE_H
+#include <apt-pkg/macros.h>
+
#include <stdio.h>
#include <string>
@@ -65,7 +67,7 @@ class pkgTagSection
unsigned long long FindULL(const char *Tag, unsigned long long const &Default = 0) const;
bool FindFlag(const char *Tag,unsigned long &Flags,
unsigned long Flag) const;
- bool static const FindFlag(unsigned long &Flags, unsigned long Flag,
+ bool static FindFlag(unsigned long &Flags, unsigned long Flag,
const char* Start, const char* Stop);
bool Scan(const char *Start,unsigned long MaxLength);
inline unsigned long size() const {return Stop - Section;};
@@ -93,9 +95,9 @@ class pkgTagFile
{
pkgTagFilePrivate *d;
- bool Fill();
- bool Resize();
- bool Resize(unsigned long long const newSize);
+ APT_HIDDEN bool Fill();
+ APT_HIDDEN bool Resize();
+ APT_HIDDEN bool Resize(unsigned long long const newSize);
public:
diff --git a/apt-pkg/update.cc b/apt-pkg/update.cc
index 97be5490b..5d5b19626 100644
--- a/apt-pkg/update.cc
+++ b/apt-pkg/update.cc
@@ -1,24 +1,17 @@
-
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/algorithms.h>
-#include <apt-pkg/update.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/version.h>
-#include <apt-pkg/sptr.h>
#include <apt-pkg/acquire-item.h>
-#include <apt-pkg/edsp.h>
-#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/progress.h>
+#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/acquire.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/update.h>
-#include <sys/types.h>
-#include <cstdlib>
-#include <algorithm>
-#include <iostream>
-#include <stdio.h>
+#include <string>
+#include <vector>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/upgrade.cc b/apt-pkg/upgrade.cc
index d6f6933dd..7926845c2 100644
--- a/apt-pkg/upgrade.cc
+++ b/apt-pkg/upgrade.cc
@@ -1,24 +1,17 @@
-
// Include Files /*{{{*/
#include <config.h>
#include <apt-pkg/algorithms.h>
-#include <apt-pkg/upgrade.h>
-#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/version.h>
-#include <apt-pkg/sptr.h>
-#include <apt-pkg/acquire-item.h>
#include <apt-pkg/edsp.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/fileutl.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/progress.h>
+#include <apt-pkg/upgrade.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
-#include <sys/types.h>
-#include <cstdlib>
-#include <algorithm>
-#include <iostream>
-#include <stdio.h>
+#include <string>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/upgrade.h b/apt-pkg/upgrade.h
index c4973472f..aa883df10 100644
--- a/apt-pkg/upgrade.h
+++ b/apt-pkg/upgrade.h
@@ -10,12 +10,14 @@
#ifndef PKGLIB_UPGRADE_H
#define PKGLIB_UPGRADE_H
+class pkgDepCache;
+
namespace APT {
namespace Upgrade {
// FIXME: make this "enum class UpgradeMode {" once we enable c++11
enum UpgradeMode {
FORBID_REMOVE_PACKAGES = 1,
- FORBID_INSTALL_NEW_PACKAGES = 2,
+ FORBID_INSTALL_NEW_PACKAGES = 2
};
bool Upgrade(pkgDepCache &Cache, int UpgradeMode);
}
diff --git a/apt-pkg/vendor.cc b/apt-pkg/vendor.cc
index fc03ec845..d4add560e 100644
--- a/apt-pkg/vendor.cc
+++ b/apt-pkg/vendor.cc
@@ -1,10 +1,14 @@
#include<config.h>
-#include <iostream>
-#include <apt-pkg/error.h>
#include <apt-pkg/vendor.h>
#include <apt-pkg/configuration.h>
+#include <iostream>
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
+
Vendor::Vendor(std::string VendorID,
std::string Origin,
std::vector<struct Vendor::Fingerprint *> *FingerprintList)
@@ -31,7 +35,7 @@ const std::string Vendor::LookupFingerprint(std::string Print) const
return (*Elt).second;
}
-bool Vendor::CheckDist(std::string Dist)
+APT_CONST bool Vendor::CheckDist(std::string /*Dist*/)
{
return true;
}
diff --git a/apt-pkg/vendor.h b/apt-pkg/vendor.h
index 6484adf9b..2d2e2b0ae 100644
--- a/apt-pkg/vendor.h
+++ b/apt-pkg/vendor.h
@@ -11,7 +11,7 @@ using std::string;
#endif
// A class representing a particular software provider.
-class __deprecated Vendor
+class APT_DEPRECATED Vendor
{
public:
struct Fingerprint
diff --git a/apt-pkg/vendorlist.cc b/apt-pkg/vendorlist.cc
index 602425624..fb33ff17d 100644
--- a/apt-pkg/vendorlist.cc
+++ b/apt-pkg/vendorlist.cc
@@ -3,9 +3,16 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
+
+#include <stddef.h>
+#include <iostream>
+#include <string>
+#include <vector>
+
#include <apti18n.h>
#if __GNUC__ >= 4
+ #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
@@ -157,5 +164,5 @@ const Vendor* pkgVendorList::FindVendor(const std::vector<string> GPGVOutput) /*
/*}}}*/
#if __GNUC__ >= 4
- #pragma GCC diagnostic warning "-Wdeprecated-declarations"
+ #pragma GCC diagnostic pop
#endif
diff --git a/apt-pkg/vendorlist.h b/apt-pkg/vendorlist.h
index a86ccde7c..bc3702a93 100644
--- a/apt-pkg/vendorlist.h
+++ b/apt-pkg/vendorlist.h
@@ -27,7 +27,7 @@ using std::vector;
class Vendor;
class Configuration;
-class __deprecated pkgVendorList
+class APT_DEPRECATED pkgVendorList
{
protected:
std::vector<Vendor const *> VendorList;
diff --git a/apt-pkg/version.cc b/apt-pkg/version.cc
index cb2c34c0f..29bee46da 100644
--- a/apt-pkg/version.cc
+++ b/apt-pkg/version.cc
@@ -11,8 +11,8 @@
#include<config.h>
#include <apt-pkg/version.h>
-#include <apt-pkg/pkgcache.h>
+#include <string.h>
#include <stdlib.h>
/*}}}*/
diff --git a/apt-pkg/version.h b/apt-pkg/version.h
index e0e0e6c14..d98809f7e 100644
--- a/apt-pkg/version.h
+++ b/apt-pkg/version.h
@@ -33,7 +33,7 @@ class pkgVersioningSystem
// Global list of VS's
static pkgVersioningSystem **GlobalList;
static unsigned long GlobalListLen;
- static pkgVersioningSystem *GetVS(const char *Label);
+ static pkgVersioningSystem *GetVS(const char *Label) APT_PURE;
const char *Label;
diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc
index 26262a010..284098bdf 100644
--- a/apt-pkg/versionmatch.cc
+++ b/apt-pkg/versionmatch.cc
@@ -16,11 +16,16 @@
#include <apt-pkg/versionmatch.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/error.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <string>
#include <stdio.h>
#include <ctype.h>
#include <fnmatch.h>
-#include <sys/types.h>
#include <regex.h>
/*}}}*/
diff --git a/apt-pkg/versionmatch.h b/apt-pkg/versionmatch.h
index 433396fc9..4c8f704c8 100644
--- a/apt-pkg/versionmatch.h
+++ b/apt-pkg/versionmatch.h
@@ -35,16 +35,17 @@
#ifndef PKGLIB_VERSIONMATCH_H
#define PKGLIB_VERSIONMATCH_H
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
#include <string>
-#include <apt-pkg/pkgcache.h>
#ifndef APT_8_CLEANER_HEADERS
using std::string;
#endif
class pkgVersionMatch
-{
+{
// Version Matching
std::string VerStr;
bool VerPrefixMatch;
@@ -60,20 +61,20 @@ class pkgVersionMatch
std::string RelComponent;
std::string RelArchitecture;
bool MatchAll;
-
+
// Origin Matching
std::string OrSite;
-
+
public:
-
+
enum MatchType {None = 0,Version,Release,Origin} Type;
-
- bool MatchVer(const char *A,std::string B,bool Prefix);
+
+ bool MatchVer(const char *A,std::string B,bool Prefix) APT_PURE;
bool ExpressionMatches(const char *pattern, const char *string);
bool ExpressionMatches(const std::string& pattern, const char *string);
bool FileMatch(pkgCache::PkgFileIterator File);
pkgCache::VerIterator Find(pkgCache::PkgIterator Pkg);
-
+
pkgVersionMatch(std::string Data,MatchType Type);
};