summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc258
-rw-r--r--apt-pkg/acquire-item.h119
-rw-r--r--apt-pkg/acquire-method.cc12
-rw-r--r--apt-pkg/acquire-method.h5
-rw-r--r--apt-pkg/acquire-worker.cc16
-rw-r--r--apt-pkg/acquire-worker.h7
-rw-r--r--apt-pkg/acquire.cc20
-rw-r--r--apt-pkg/acquire.h15
-rw-r--r--apt-pkg/algorithms.cc79
-rw-r--r--apt-pkg/algorithms.h11
-rw-r--r--apt-pkg/aptconfiguration.cc131
-rw-r--r--apt-pkg/aptconfiguration.h19
-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.h273
-rw-r--r--apt-pkg/cacheset.cc75
-rw-r--r--apt-pkg/cacheset.h196
-rw-r--r--apt-pkg/cdrom.cc210
-rw-r--r--apt-pkg/cdrom.h10
-rw-r--r--apt-pkg/clean.cc6
-rw-r--r--apt-pkg/clean.h7
-rw-r--r--apt-pkg/contrib/cdromutl.cc94
-rw-r--r--apt-pkg/contrib/cmndline.cc7
-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.cc2
-rw-r--r--apt-pkg/contrib/crc-16.h4
-rw-r--r--apt-pkg/contrib/error.cc6
-rw-r--r--apt-pkg/contrib/error.h39
-rw-r--r--apt-pkg/contrib/fileutl.cc584
-rw-r--r--apt-pkg/contrib/fileutl.h14
-rw-r--r--apt-pkg/contrib/gpgv.cc29
-rw-r--r--apt-pkg/contrib/gpgv.h20
-rw-r--r--apt-pkg/contrib/hashes.cc13
-rw-r--r--apt-pkg/contrib/hashes.h17
-rw-r--r--apt-pkg/contrib/hashsum.cc10
-rw-r--r--apt-pkg/contrib/hashsum_template.h52
-rw-r--r--apt-pkg/contrib/macros.h90
-rw-r--r--apt-pkg/contrib/md5.cc6
-rw-r--r--apt-pkg/contrib/md5.h11
-rw-r--r--apt-pkg/contrib/mmap.cc14
-rw-r--r--apt-pkg/contrib/mmap.h4
-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/progress.h2
-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.cc3
-rw-r--r--apt-pkg/contrib/sha2_internal.h1
-rw-r--r--apt-pkg/contrib/strutl.cc27
-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.cc178
-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.h13
-rw-r--r--apt-pkg/deb/debsystem.cc13
-rw-r--r--apt-pkg/deb/debsystem.h10
-rw-r--r--apt-pkg/deb/debversion.cc6
-rw-r--r--apt-pkg/deb/debversion.h20
-rw-r--r--apt-pkg/deb/dpkgpm.cc115
-rw-r--r--apt-pkg/deb/dpkgpm.h17
-rw-r--r--apt-pkg/depcache.cc126
-rw-r--r--apt-pkg/depcache.h27
-rw-r--r--apt-pkg/edsp.cc27
-rw-r--r--apt-pkg/edsp.h24
-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.h25
-rw-r--r--apt-pkg/indexrecords.cc25
-rw-r--r--apt-pkg/indexrecords.h6
-rw-r--r--apt-pkg/init.cc6
-rw-r--r--apt-pkg/init.h13
-rw-r--r--apt-pkg/install-progress.cc44
-rw-r--r--apt-pkg/install-progress.h44
-rw-r--r--apt-pkg/makefile3
-rw-r--r--apt-pkg/metaindex.h15
-rw-r--r--apt-pkg/orderlist.cc14
-rw-r--r--apt-pkg/orderlist.h14
-rw-r--r--apt-pkg/packagemanager.cc47
-rw-r--r--apt-pkg/packagemanager.h18
-rw-r--r--apt-pkg/pkgcache.cc37
-rw-r--r--apt-pkg/pkgcache.h70
-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.h6
-rw-r--r--apt-pkg/policy.cc16
-rw-r--r--apt-pkg/policy.h5
-rw-r--r--apt-pkg/sourcelist.cc152
-rw-r--r--apt-pkg/sourcelist.h23
-rw-r--r--apt-pkg/srcrecords.cc12
-rw-r--r--apt-pkg/srcrecords.h3
-rw-r--r--apt-pkg/tagfile.cc96
-rw-r--r--apt-pkg/tagfile.h10
-rw-r--r--apt-pkg/update.cc23
-rw-r--r--apt-pkg/upgrade.cc21
-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
125 files changed, 2879 insertions, 1591 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index b76921312..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");
@@ -129,7 +138,7 @@ void pkgAcquire::Item::Done(string Message,unsigned long long Size,string Hash,
/*}}}*/
// Acquire::Item::Rename - Rename a file /*{{{*/
// ---------------------------------------------------------------------
-/* This helper function is used by alot of item methods as thier final
+/* This helper function is used by a lot of item methods as their final
step */
void pkgAcquire::Item::Rename(string From,string To)
{
@@ -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;
@@ -299,7 +308,7 @@ void pkgAcqSubIndex::Done(string Message,unsigned long long Size,string Md5Hash,
return;
}
- // sucess in downloading the index
+ // success in downloading the index
// rename the index
if(Debug)
std::clog << "Renaming: " << DestFile << " -> " << FinalFile << std::endl;
@@ -327,7 +336,7 @@ bool pkgAcqSubIndex::ParseIndex(string const &IndexFile) /*{{{*/
/*}}}*/
// AcqDiffIndex::AcqDiffIndex - Constructor /*{{{*/
// ---------------------------------------------------------------------
-/* Get the DiffIndex file first and see if there are patches availabe
+/* Get the DiffIndex file first and see if there are patches available
* If so, create a pkgAcqIndexDiffs fetcher that will get and apply the
* patches. If anything goes wrong in that process, it will fall back to
* the original packages file
@@ -369,10 +378,10 @@ pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner,
return;
}
- if(Debug)
- std::clog << "pkgAcqIndexDiffs::pkgAcqIndexDiffs(): "
- << CurrentPackagesFile << std::endl;
-
+ if(Debug)
+ std::clog << "pkgAcqDiffIndex::pkgAcqDiffIndex(): "
+ << CurrentPackagesFile << std::endl;
+
QueueURI(Desc);
}
@@ -398,8 +407,8 @@ string pkgAcqDiffIndex::Custom600Headers()
bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile) /*{{{*/
{
if(Debug)
- std::clog << "pkgAcqIndexDiffs::ParseIndexDiff() " << IndexDiffFile
- << std::endl;
+ std::clog << "pkgAcqDiffIndex::ParseIndexDiff() " << IndexDiffFile
+ << std::endl;
pkgTagSection Tags;
string ServerSha1;
@@ -426,16 +435,18 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile) /*{{{*/
SHA1.AddFD(fd);
string const local_sha1 = SHA1.Result();
- if(local_sha1 == ServerSha1)
+ if(local_sha1 == ServerSha1)
{
- // we have the same sha1 as the server
+ // we have the same sha1 as the server so we are done here
if(Debug)
std::clog << "Package file is up-to-date" << std::endl;
- // set found to true, this will queue a pkgAcqIndexDiffs with
- // a empty availabe_patches
- found = true;
- }
- else
+ // list cleanup needs to know that this file as well as the already
+ // present index is ours, so we create an empty diff to save it for us
+ new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
+ ExpectedHash, ServerSha1, available_patches);
+ return true;
+ }
+ else
{
if(Debug)
std::clog << "SHA1-Current: " << ServerSha1 << " and we start at "<< fd.Name() << " " << fd.Size() << " " << local_sha1 << std::endl;
@@ -460,7 +471,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile) /*{{{*/
if (available_patches.empty() == false)
{
// patching with too many files is rather slow compared to a fast download
- unsigned long const fileLimit = _config->FindI("Acquire::PDiffs::FileLimit", 20);
+ unsigned long const fileLimit = _config->FindI("Acquire::PDiffs::FileLimit", 0);
if (fileLimit != 0 && fileLimit < available_patches.size())
{
if (Debug)
@@ -496,14 +507,37 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile) /*{{{*/
}
// we have something, queue the next diff
- if(found)
+ if(found)
{
// queue the diffs
string::size_type const last_space = Description.rfind(" ");
if(last_space != string::npos)
Description.erase(last_space, Description.size()-last_space);
- new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
- ExpectedHash, ServerSha1, available_patches);
+
+ /* decide if we should download patches one by one or in one go:
+ The first is good if the server merges patches, but many don't so client
+ based merging can be attempt in which case the second is better.
+ "bad things" will happen if patches are merged on the server,
+ but client side merging is attempt as well */
+ bool pdiff_merge = _config->FindB("Acquire::PDiffs::Merge", true);
+ if (pdiff_merge == true)
+ {
+ // reprepro adds this flag if it has merged patches on the server
+ std::string const precedence = Tags.FindS("X-Patch-Precedence");
+ pdiff_merge = (precedence != "merged");
+ }
+
+ if (pdiff_merge == false)
+ new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
+ ExpectedHash, ServerSha1, available_patches);
+ else
+ {
+ std::vector<pkgAcqIndexMergeDiffs*> *diffs = new std::vector<pkgAcqIndexMergeDiffs*>(available_patches.size());
+ for(size_t i = 0; i < available_patches.size(); ++i)
+ (*diffs)[i] = new pkgAcqIndexMergeDiffs(Owner, RealURI, Description, Desc.ShortDesc, ExpectedHash,
+ available_patches[i], diffs);
+ }
+
Complete = false;
Status = StatDone;
Dequeue();
@@ -519,11 +553,11 @@ 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
- << "Falling back to normal index file aquire" << 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,
ExpectedHash);
@@ -544,7 +578,7 @@ void pkgAcqDiffIndex::Done(string Message,unsigned long long Size,string Md5Hash
string FinalFile;
FinalFile = _config->FindDir("Dir::State::lists")+URItoFileName(RealURI);
- // sucess in downloading the index
+ // success in downloading the index
// rename the index
FinalFile += string(".IndexDiff");
if(Debug)
@@ -599,11 +633,11 @@ 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
- << "Falling back to normal index file aquire" << 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);
Finish();
@@ -684,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);
@@ -708,7 +742,7 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long long Size,string Md5Has
string FinalFile;
FinalFile = _config->FindDir("Dir::State::lists")+URItoFileName(RealURI);
- // sucess in downloading a diff, enter ApplyDiff state
+ // success in downloading a diff, enter ApplyDiff state
if(State == StateFetchDiff)
{
@@ -732,6 +766,7 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long long Size,string Md5Has
{
// remove the just applied patch
available_patches.erase(available_patches.begin());
+ unlink((FinalFile + ".ed").c_str());
// move into place
if(Debug)
@@ -752,6 +787,131 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long long Size,string Md5Has
}
}
/*}}}*/
+// AcqIndexMergeDiffs::AcqIndexMergeDiffs - Constructor /*{{{*/
+pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire *Owner,
+ string const &URI, string const &URIDesc,
+ string const &ShortDesc, HashString const &ExpectedHash,
+ DiffInfo const &patch,
+ std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches)
+ : Item(Owner), RealURI(URI), ExpectedHash(ExpectedHash),
+ patch(patch),allPatches(allPatches), State(StateFetchDiff)
+{
+
+ DestFile = _config->FindDir("Dir::State::lists") + "partial/";
+ DestFile += URItoFileName(URI);
+
+ Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
+
+ Description = URIDesc;
+ Desc.Owner = this;
+ Desc.ShortDesc = ShortDesc;
+
+ 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);
+
+ if(Debug)
+ std::clog << "pkgAcqIndexMergeDiffs: " << Desc.URI << std::endl;
+
+ QueueURI(Desc);
+}
+ /*}}}*/
+void pkgAcqIndexMergeDiffs::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)/*{{{*/
+{
+ if(Debug)
+ std::clog << "pkgAcqIndexMergeDiffs failed: " << Desc.URI << " with " << Message << std::endl;
+ Complete = false;
+ Status = StatDone;
+ Dequeue();
+
+ // check if we are the first to fail, otherwise we are done here
+ State = StateDoneDiff;
+ for (std::vector<pkgAcqIndexMergeDiffs *>::const_iterator I = allPatches->begin();
+ I != allPatches->end(); ++I)
+ if ((*I)->State == StateErrorDiff)
+ return;
+
+ // first failure means we should fallback
+ State = StateErrorDiff;
+ std::clog << "Falling back to normal index file acquire" << std::endl;
+ new pkgAcqIndex(Owner, RealURI, Description,Desc.ShortDesc,
+ ExpectedHash);
+}
+ /*}}}*/
+void pkgAcqIndexMergeDiffs::Done(string Message,unsigned long long Size,string Md5Hash, /*{{{*/
+ pkgAcquire::MethodConfig *Cnf)
+{
+ if(Debug)
+ std::clog << "pkgAcqIndexMergeDiffs::Done(): " << Desc.URI << std::endl;
+
+ Item::Done(Message,Size,Md5Hash,Cnf);
+
+ string const FinalFile = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI);
+
+ if (State == StateFetchDiff)
+ {
+ // rred expects the patch as $FinalFile.ed.$patchname.gz
+ Rename(DestFile, FinalFile + ".ed." + patch.file + ".gz");
+
+ // check if this is the last completed diff
+ State = StateDoneDiff;
+ for (std::vector<pkgAcqIndexMergeDiffs *>::const_iterator I = allPatches->begin();
+ I != allPatches->end(); ++I)
+ if ((*I)->State != StateDoneDiff)
+ {
+ if(Debug)
+ std::clog << "Not the last done diff in the batch: " << Desc.URI << std::endl;
+ return;
+ }
+
+ // this is the last completed diff, so we are ready to apply now
+ State = StateApplyDiff;
+
+ if(Debug)
+ std::clog << "Sending to rred method: " << FinalFile << std::endl;
+
+ Local = true;
+ Desc.URI = "rred:" + FinalFile;
+ QueueURI(Desc);
+ Mode = "rred";
+ return;
+ }
+ // success in download/apply all diffs, clean up
+ else if (State == StateApplyDiff)
+ {
+ // see if we really got the expected file
+ if(!ExpectedHash.empty() && !ExpectedHash.VerifyFile(DestFile))
+ {
+ RenameOnError(HashSumMismatch);
+ return;
+ }
+
+ // move the result into place
+ if(Debug)
+ std::clog << "Moving patched file in place: " << std::endl
+ << DestFile << " -> " << FinalFile << std::endl;
+ Rename(DestFile, FinalFile);
+ chmod(FinalFile.c_str(), 0644);
+
+ // otherwise lists cleanup will eat the file
+ DestFile = FinalFile;
+
+ // ensure the ed's are gone regardless of list-cleanup
+ for (std::vector<pkgAcqIndexMergeDiffs *>::const_iterator I = allPatches->begin();
+ I != allPatches->end(); ++I)
+ {
+ std::string patch = FinalFile + ".ed." + (*I)->patch.file + ".gz";
+ unlink(patch.c_str());
+ }
+
+ // all set and done
+ Complete = true;
+ if(Debug)
+ std::clog << "allDone: " << DestFile << "\n" << std::endl;
+ }
+}
+ /*}}}*/
// AcqIndex::AcqIndex - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* The package file is added to the queue and a second class is
@@ -1089,7 +1249,7 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner, /*{{{*/
if (RealFileExists(Final) == true)
{
// File was already in place. It needs to be re-downloaded/verified
- // because Release might have changed, we do give it a differnt
+ // because Release might have changed, we do give it a different
// name than DestFile because otherwise the http method will
// send If-Range requests and there are too many broken servers
// out there that do not understand them
@@ -1407,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;
@@ -1445,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
@@ -1459,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
@@ -1484,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();
@@ -1547,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)
{
@@ -1705,7 +1865,7 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
_error->Error(_("I wasn't able to locate a file for the %s package. "
"This might mean you need to manually fix this package. "
"(due to missing arch)"),
- Version.ParentPkg().Name());
+ Version.ParentPkg().FullName().c_str());
return;
}
@@ -1833,7 +1993,7 @@ bool pkgAcqArchive::QueueNext()
Desc.URI = Index->ArchiveURI(PkgFile);
Desc.Description = Index->ArchiveInfo(Version);
Desc.Owner = this;
- Desc.ShortDesc = Version.ParentPkg().Name();
+ Desc.ShortDesc = Version.ParentPkg().FullName(true);
// See if we already have the file. (Legacy filenames)
FileSize = Version->Size;
@@ -1870,7 +2030,7 @@ bool pkgAcqArchive::QueueNext()
return true;
}
- /* Hmm, we have a file and its size does not match, this shouldnt
+ /* Hmm, we have a file and its size does not match, this shouldn't
happen.. */
unlink(FinalFile.c_str());
}
@@ -1900,10 +2060,6 @@ bool pkgAcqArchive::QueueNext()
// Create the item
Local = false;
- Desc.URI = Index->ArchiveURI(PkgFile);
- Desc.Description = Index->ArchiveInfo(Version);
- Desc.Owner = this;
- Desc.ShortDesc = Version.ParentPkg().Name();
QueueURI(Desc);
++Vf;
@@ -2002,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;
}
@@ -2050,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 6b4f73708..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);
};
@@ -429,7 +432,105 @@ class pkgAcqDiffIndex : public pkgAcquire::Item
std::string ShortDesc, HashString ExpectedHash);
};
/*}}}*/
-/** \brief An item that is responsible for fetching all the patches {{{
+/** \brief An item that is responsible for fetching client-merge patches {{{
+ * that need to be applied to a given package index file.
+ *
+ * Instead of downloading and applying each patch one by one like its
+ * sister #pkgAcqIndexDiffs this class will download all patches at once
+ * and call rred with all the patches downloaded once. Rred will then
+ * merge and apply them in one go, which should be a lot faster – but is
+ * incompatible with server-based merges of patches like reprepro can do.
+ *
+ * \sa pkgAcqDiffIndex, pkgAcqIndex
+ */
+class pkgAcqIndexMergeDiffs : public pkgAcquire::Item
+{
+ protected:
+
+ /** \brief If \b true, debugging output will be written to
+ * std::clog.
+ */
+ bool Debug;
+
+ /** \brief description of the item that is currently being
+ * downloaded.
+ */
+ pkgAcquire::ItemDesc Desc;
+
+ /** \brief URI of the package index file that is being
+ * reconstructed.
+ */
+ std::string RealURI;
+
+ /** \brief HashSum of the package index file that is being
+ * reconstructed.
+ */
+ HashString ExpectedHash;
+
+ /** \brief description of the file being downloaded. */
+ std::string Description;
+
+ /** \brief information about the current patch */
+ struct DiffInfo const patch;
+
+ /** \brief list of all download items for the patches */
+ std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches;
+
+ /** The current status of this patch. */
+ enum DiffState
+ {
+ /** \brief The diff is currently being fetched. */
+ StateFetchDiff,
+
+ /** \brief The diff is currently being applied. */
+ StateApplyDiff,
+
+ /** \brief the work with this diff is done */
+ StateDoneDiff,
+
+ /** \brief something bad happened and fallback was triggered */
+ StateErrorDiff
+ } State;
+
+ public:
+ /** \brief Called when the patch file failed to be downloaded.
+ *
+ * This method will fall back to downloading the whole index file
+ * outright; its arguments are ignored.
+ */
+ virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
+
+ virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash,
+ pkgAcquire::MethodConfig *Cnf);
+ virtual std::string DescURI() {return RealURI + "Index";};
+
+ /** \brief Create an index merge-diff item.
+ *
+ * \param Owner The pkgAcquire object that owns this item.
+ *
+ * \param URI The URI of the package index file being
+ * reconstructed.
+ *
+ * \param URIDesc A long description of this item.
+ *
+ * \param ShortDesc A brief description of this item.
+ *
+ * \param ExpectedHash The expected md5sum of the completely
+ * reconstructed package index file; the index file will be tested
+ * against this value when it is entirely reconstructed.
+ *
+ * \param patch contains infos about the patch this item is supposed
+ * to download which were read from the index
+ *
+ * \param allPatches contains all related items so that each item can
+ * check if it was the last one to complete the download step
+ */
+ pkgAcqIndexMergeDiffs(pkgAcquire *Owner,std::string const &URI,std::string const &URIDesc,
+ std::string const &ShortDesc, HashString const &ExpectedHash,
+ DiffInfo const &patch, std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches);
+};
+ /*}}}*/
+/** \brief An item that is responsible for fetching server-merge patches {{{
* that need to be applied to a given package index file.
*
* After downloading and applying a single patch, this item will
@@ -538,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.
*
@@ -553,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.
@@ -1064,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 44a84216a..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>
@@ -109,7 +112,12 @@ bool pkgAcquire::Worker::Start()
// Get the method path
string Method = _config->FindDir("Dir::Bin::Methods") + Access;
if (FileExists(Method) == false)
- return _error->Error(_("The method driver %s could not be found."),Method.c_str());
+ {
+ _error->Error(_("The method driver %s could not be found."),Method.c_str());
+ if (Access == "https")
+ _error->Notice(_("Is the package %s installed?"), "apt-transport-https");
+ return false;
+ }
if (Debug == true)
clog << "Starting method '" << Method << '\'' << endl;
@@ -563,7 +571,7 @@ bool pkgAcquire::Worker::InFdReady()
/*}}}*/
// Worker::MethodFailure - Called when the method fails /*{{{*/
// ---------------------------------------------------------------------
-/* This is called when the method is belived to have failed, probably because
+/* This is called when the method is believed to have failed, probably because
read returned -1. */
bool pkgAcquire::Worker::MethodFailure()
{
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 a8a5abd34..a187a00ae 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -5,9 +5,9 @@
Acquire - File Acquiration
- The core element for the schedual system is the concept of a named
+ The core element for the schedule system is the concept of a named
queue. Each queue is unique and each queue has a name derived from the
- URI. The degree of paralization can be controled by how the queue
+ URI. The degree of paralization can be controlled by how the queue
name is derived from the URI.
##################################################################### */
@@ -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>
@@ -175,7 +181,7 @@ void pkgAcquire::Add(Worker *Work)
// ---------------------------------------------------------------------
/* A worker has died. This can not be done while the select loop is running
as it would require that RunFds could handling a changing list state and
- it cant.. */
+ it can't.. */
void pkgAcquire::Remove(Worker *Work)
{
if (Running == true)
@@ -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 8644a8138..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;
@@ -424,7 +440,7 @@ void pkgProblemResolver::MakeScores()
/* This is arbitrary, it should be high enough to elevate an
essantial package above most other packages but low enough
to allow an obsolete essential packages to be removed by
- a conflicts on a powerfull normal package (ie libc6) */
+ a conflicts on a powerful normal package (ie libc6) */
if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential
|| (I->Flags & pkgCache::Flag::Important) == pkgCache::Flag::Important)
Score += PrioEssentials;
@@ -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 propogate 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);
@@ -485,7 +500,7 @@ void pkgProblemResolver::MakeScores()
}
}
- /* Now we propogate along provides. This makes the packages that
+ /* Now we propagate along provides. This makes the packages that
provide important packages extremely important */
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
@@ -640,7 +655,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
adjusting the package will inflict.
It goes from highest score to lowest and corrects all of the breaks by
- keeping or removing the dependant packages. If that fails then it removes
+ keeping or removing the dependent packages. If that fails then it removes
the package itself and goes on. The routine should be able to intelligently
go from any broken state to a fixed state.
@@ -830,7 +845,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
/* Look across the version list. If there are no possible
targets then we keep the package and bail. This is necessary
- if a package has a dep on another package that cant be found */
+ if a package has a dep on another package that can't be found */
SPtrArray<pkgCache::Version *> VList = Start.AllTargets();
if (*VList == 0 && (Flags[I->ID] & Protected) != Protected &&
Start.IsNegative() == false &&
@@ -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 */
@@ -1183,7 +1198,7 @@ bool pkgProblemResolver::ResolveByKeepInternal()
continue;
/* Keep the package. If this works then great, otherwise we have
- to be significantly more agressive and manipulate its dependencies */
+ to be significantly more aggressive and manipulate its dependencies */
if ((Flags[I->ID] & Protected) == 0)
{
if (Debug == true)
diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h
index 5a9a77415..f35bd9a13 100644
--- a/apt-pkg/algorithms.h
+++ b/apt-pkg/algorithms.h
@@ -10,7 +10,7 @@
see all of the effects of an upgrade run.
pkgDistUpgrade computes an upgrade that causes as many packages as
- possible to move to the newest verison.
+ possible to move to the newest version.
pkgApplyStatus sets the target state based on the content of the status
field in the status file. It is important to get proper crash recovery.
@@ -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>
@@ -44,7 +47,7 @@ using std::ostream;
#endif
#ifndef APT_9_CLEANER_HEADERS
-// include pkg{DistUpgrade,AllUpgrade,MiniizeUpgrade} here for compatiblity
+// include pkg{DistUpgrade,AllUpgrade,MiniizeUpgrade} here for compatibility
#include <apt-pkg/upgrade.h>
#include <apt-pkg/update.h>
#endif
@@ -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 115d11616..6ba047560 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -17,19 +17,24 @@
#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 usbale compressiontypes /*{{{*/
+// getCompressionTypes - Return Vector of usable compressiontypes /*{{{*/
// ---------------------------------------------------------------------
-/* return a vector of compression types in the prefered order. */
+/* return a vector of compression types in the preferred order. */
std::vector<std::string>
const Configuration::getCompressionTypes(bool const &Cached) {
static std::vector<std::string> types;
@@ -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();
@@ -109,7 +109,7 @@ const Configuration::getCompressionTypes(bool const &Cached) {
/*}}}*/
// GetLanguages - Return Vector of Language Codes /*{{{*/
// ---------------------------------------------------------------------
-/* return a vector of language codes in the prefered order.
+/* return a vector of language codes in the preferred order.
the special word "environment" will be replaced with the long and the short
code of the local settings and it will be insured that this will not add
duplicates. So in an german local the setting "environment, de_DE, en, de"
@@ -141,7 +141,7 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
// so they will be all included in the Cache.
std::vector<string> builtin;
DIR *D = opendir(_config->FindDir("Dir::State::lists").c_str());
- if (D != 0) {
+ if (D != NULL) {
builtin.push_back("none");
for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D)) {
string const name = SubstVar(Ent->d_name, "%5f", "_");
@@ -166,8 +166,8 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
continue;
builtin.push_back(c);
}
+ closedir(D);
}
- closedir(D);
// FIXME: Remove support for the old APT::Acquire::Translation
// it was undocumented and so it should be not very widthly used
@@ -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;
@@ -330,7 +285,7 @@ bool const Configuration::checkLanguage(std::string Lang, bool const All) {
return (std::find(langs.begin(), langs.end(), Lang) != langs.end());
}
/*}}}*/
-// getArchitectures - Return Vector of prefered Architectures /*{{{*/
+// getArchitectures - Return Vector of preferred Architectures /*{{{*/
std::vector<std::string> const Configuration::getArchitectures(bool const &Cached) {
using std::string;
@@ -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 d22b675c0..dfed194ae 100644
--- a/apt-pkg/aptconfiguration.h
+++ b/apt-pkg/aptconfiguration.h
@@ -37,14 +37,14 @@ public: /*{{{*/
* \param Cached saves the result so we need to calculated it only once
* this parameter should ony be used for testing purposes.
*
- * \return a vector of the compression types in the prefered usage order
+ * \return a vector of the compression types in the preferred usage order
*/
std::vector<std::string> static const getCompressionTypes(bool const &Cached = true);
/** \brief Returns a vector of Language Codes
*
* Languages can be defined with their two or five chars long code.
- * This methods handles the various ways to set the prefered codes,
+ * This methods handles the various ways to set the preferred codes,
* honors the environment and ensures that the codes are not listed twice.
*
* The special word "environment" will be replaced with the long and the short
@@ -52,7 +52,7 @@ public: /*{{{*/
* duplicates. So in an german local the setting "environment, de_DE, en, de"
* will result in "de_DE, de, en".
*
- * Another special word is "none" which separates the prefered from all codes
+ * Another special word is "none" which separates the preferred from all codes
* in this setting. So setting and method can be used to get codes the user want
* to see or to get all language codes APT (should) have Translations available.
*
@@ -62,7 +62,7 @@ public: /*{{{*/
* \param Locale don't get the locale from the system but use this one instead
* this parameter should ony be used for testing purposes.
*
- * \return a vector of (all) Language Codes in the prefered usage order
+ * \return a vector of (all) Language Codes in the preferred usage order
*/
std::vector<std::string> static const getLanguages(bool const &All = false,
bool const &Cached = true, char const ** const Locale = 0);
@@ -73,14 +73,14 @@ 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
*
* \param Cached saves the result so we need to calculated it only once
* this parameter should ony be used for testing purposes.
*
- * \return a vector of Architectures in prefered order
+ * \return a vector of Architectures in preferred order
*/
std::vector<std::string> static const getArchitectures(bool const &Cached = true);
@@ -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 886d84838..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>
@@ -46,7 +51,7 @@ template<typename Str, typename Itr> class pkgCache::Iterator :
* The implementation of this method should be pretty short
* as it will only return the Pointer into the mmap stored
* in the owner but the name of this pointer is different for
- * each stucture and we want to abstract here at least for the
+ * each structure and we want to abstract here at least for the
* basic methods from the actual structure.
* \return Pointer to the first structure of this type
*/
@@ -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,32 +191,32 @@ 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;
/** \brief compares two version and returns if they are similar
This method should be used to identify if two pseudo versions are
- refering to the same "real" version */
+ 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 cant be in the class because of order problems /*{{{*/
+// 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 0147f7e86..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>
/*}}}*/
@@ -73,6 +81,8 @@ bool PackageContainerInterface::FromTask(PackageContainerInterface * const pci,
const char *start, *end;
parser.GetRec(start,end);
unsigned int const length = end - start;
+ if (unlikely(length == 0))
+ continue;
char buf[length];
strncpy(buf, start, length);
buf[length-1] = '\0';
@@ -202,12 +212,20 @@ PackageContainerInterface::FromFnmatch(PackageContainerInterface * const pci,
}
pci->insert(Pkg);
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ helper.showFnmatchSelection(Pkg, pattern);
+#else
helper.showRegExSelection(Pkg, pattern);
+#endif
found = true;
}
if (found == false) {
- helper.canNotFindRegEx(pci, Cache, pattern);
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ helper.canNotFindFnmatch(pci, Cache, pattern);
+#else
+ helper.canNotFindRegEx(pci, Cache, pattern);
+#endif
pci->setConstructor(UNKNOWN);
return false;
}
@@ -302,7 +320,9 @@ bool PackageContainerInterface::FromString(PackageContainerInterface * const pci
if (FromGroup(pci, Cache, str, helper) == false &&
FromTask(pci, Cache, str, helper) == false &&
- FromFnmatch(pci, Cache, str, helper) == false &&
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ FromFnmatch(pci, Cache, str, helper) == false)
+#endif
FromRegEx(pci, Cache, str, helper) == false)
{
helper.canNotFindPackage(pci, Cache, str);
@@ -576,37 +596,43 @@ 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());
}
- /*}}}*/
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+// canNotFindFnmatch - handle the case no package is found by a fnmatch /*{{{*/
+void CacheSetHelper::canNotFindFnmatch(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) {
+ if (ShowError == true)
+ _error->Insert(ErrorType, _("Couldn't find any package by glob '%s'"), pattern.c_str());
+}
+#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());
@@ -637,20 +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 /*{{{*/
+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 29103aad9..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,16 +48,22 @@ 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);
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ virtual void showFnmatchSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern);
+#endif
virtual void showSelectedVersion(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const Ver,
std::string const &ver, bool const verIsRel);
virtual void canNotFindTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern);
virtual void canNotFindRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern);
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ virtual void canNotFindFnmatch(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern);
+#endif
virtual void canNotFindPackage(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &str);
virtual void canNotFindAllVer(VersionContainerInterface * const vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg);
@@ -70,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;
@@ -81,7 +92,7 @@ public: /*{{{*/
ErrorType = newValue;
return oldValue;
}
- };
+ }
/*}}}*/
protected:
@@ -118,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();}
};
/*}}}*/
@@ -148,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,
@@ -171,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,
@@ -185,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
@@ -359,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) {
@@ -367,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;
@@ -386,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(); }
};
/*}}}*/
@@ -440,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,
@@ -473,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);
/*}}}*/
@@ -501,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,
@@ -515,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
@@ -552,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) {
@@ -650,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) {
@@ -658,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 a5668a50a..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,45 +563,68 @@ bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source)
return true;
}
/*}}}*/
-bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/
+bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log, bool const interactive)/*{{{*/
{
- stringstream msg;
-
// Startup
- string CDROM = _config->FindDir("Acquire::cdrom::mount");
+ CDROM = _config->FindDir("Acquire::cdrom::mount");
if (CDROM[0] == '.')
CDROM= SafeGetCWD() + '/' + CDROM;
if (log != NULL)
{
- msg.str("");
- ioprintf(msg, _("Using CD-ROM mount point %s\nMounting CD-ROM\n"),
- CDROM.c_str());
- log->Update(msg.str());
+ string msg;
+ log->SetTotal(STEP_LAST);
+ strprintf(msg, _("Using CD-ROM mount point %s\n"), CDROM.c_str());
+ log->Update(msg, STEP_PREPARE);
+ }
+
+ // Unmount the CD and get the user to put in the one they want
+ if (_config->FindB("APT::CDROM::NoMount", false) == false)
+ {
+ if (interactive == true)
+ {
+ 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;
+ }
+ }
+ }
+
+ // Mount the new CDROM
+ if(log != NULL)
+ log->Update(_("Mounting CD-ROM...\n"), STEP_MOUNT);
+
+ if (MountCdrom(CDROM) == false)
+ return _error->Error("Failed to mount the cdrom.");
}
- if (MountCdrom(CDROM) == false)
- return _error->Error("Failed to mount the cdrom.");
// Hash the CD to get an ID
if (log != NULL)
- log->Update(_("Identifying.. "));
-
+ log->Update(_("Identifying... "), STEP_IDENT);
if (IdentCdrom(CDROM,ident) == false)
{
ident = "";
+ if (log != NULL)
+ log->Update("\n");
return false;
}
if (log != NULL)
{
- msg.str("");
- ioprintf(msg, "[%s]\n",ident.c_str());
- log->Update(msg.str());
+ string msg;
+ strprintf(msg, "[%s]\n", ident.c_str());
+ log->Update(msg);
}
// Read the database
- Configuration Database;
string DFile = _config->FindFile("Dir::State::cdroms");
if (FileExists(DFile) == true)
{
@@ -607,12 +632,22 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/
return _error->Error("Unable to read the cdrom database %s",
DFile.c_str());
}
+ return true;
+}
+ /*}}}*/
+bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/
+{
+ Configuration Database;
+ std::string CDROM;
+ if (MountAndIdentCDROM(Database, CDROM, ident, log, false) == false)
+ return false;
+
if (log != NULL)
{
- msg.str("");
- ioprintf(msg, _("Stored label: %s\n"),
- Database.Find("CD::"+ident).c_str());
- log->Update(msg.str());
+ string msg;
+ strprintf(msg, _("Stored label: %s\n"),
+ Database.Find("CD::"+ident).c_str());
+ log->Update(msg);
}
// Unmount and finish
@@ -628,70 +663,13 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/
/*}}}*/
bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
{
- stringstream msg;
-
- // Startup
- string CDROM = _config->FindDir("Acquire::cdrom::mount");
- if (CDROM[0] == '.')
- CDROM= SafeGetCWD() + '/' + CDROM;
-
- if(log != NULL)
- {
- log->SetTotal(STEP_LAST);
- msg.str("");
- ioprintf(msg, _("Using CD-ROM mount point %s\n"), CDROM.c_str());
- log->Update(msg.str(), STEP_PREPARE);
- }
-
- // Read the database
Configuration Database;
- string DFile = _config->FindFile("Dir::State::cdroms");
- if (FileExists(DFile) == true)
- {
- if (ReadConfigFile(Database,DFile) == false)
- return _error->Error("Unable to read the cdrom database %s",
- DFile.c_str());
- }
-
- // 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)
- {
- log->Update(_("Waiting for disc...\n"), STEP_WAIT);
- if(!log->ChangeCdrom()) {
- // user aborted
- return false;
- }
- }
-
- // Mount the new CDROM
- if(log != NULL)
- log->Update(_("Mounting CD-ROM...\n"), STEP_MOUNT);
-
- if (MountCdrom(CDROM) == false)
- return _error->Error("Failed to mount the cdrom.");
- }
-
- // Hash the CD to get an ID
- if(log != NULL)
- log->Update(_("Identifying.. "), STEP_IDENT);
- string ID;
- if (IdentCdrom(CDROM,ID) == false)
- {
- if (log != NULL)
- log->Update("\n");
+ std::string ID, CDROM;
+ if (MountAndIdentCDROM(Database, CDROM, ID, log, true) == false)
return false;
- }
+
if(log != NULL)
- {
- log->Update("["+ID+"]\n");
- 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;
@@ -740,12 +718,12 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
if (_config->FindB("APT::CDROM::DropTranslation", true) == true)
DropTranslation(TransList);
if(log != NULL) {
- msg.str("");
- ioprintf(msg, _("Found %zu package indexes, %zu source indexes, "
+ string msg;
+ strprintf(msg, _("Found %zu package indexes, %zu source indexes, "
"%zu translation indexes and %zu signatures\n"),
List.size(), SourceList.size(), TransList.size(),
SigList.size());
- log->Update(msg.str(), STEP_SCAN);
+ log->Update(msg, STEP_SCAN);
}
if (List.empty() == true && SourceList.empty() == true)
@@ -764,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);
@@ -778,9 +756,9 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
if(log != NULL)
{
- msg.str("");
- ioprintf(msg, _("Found label '%s'\n"), Name.c_str());
- log->Update(msg.str());
+ string msg;
+ strprintf(msg, _("Found label '%s'\n"), Name.c_str());
+ log->Update(msg);
}
Database.Set("CD::" + ID + "::Label",Name);
}
@@ -824,9 +802,9 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
Database.Set("CD::" + ID,Name);
if(log != NULL)
{
- msg.str("");
- ioprintf(msg, _("This disc is called: \n'%s'\n"), Name.c_str());
- log->Update(msg.str());
+ string msg;
+ strprintf(msg, _("This disc is called: \n'%s'\n"), Name.c_str());
+ log->Update(msg);
log->Update(_("Copying package lists..."), STEP_COPY);
}
@@ -884,7 +862,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
if(log != NULL)
{
- msg.str("");
+ stringstream msg;
msg << "deb cdrom:[" << Name << "]/" << string(*I,0,Space) <<
" " << string(*I,Space+1) << endl;
log->Update(msg.str());
@@ -902,7 +880,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
}
if(log != NULL) {
- msg.str("");
+ stringstream msg;
msg << "deb-src cdrom:[" << Name << "]/" << string(*I,0,Space) <<
" " << string(*I,Space+1) << endl;
log->Update(msg.str());
@@ -960,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>
@@ -1008,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 7d19eb813..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;
@@ -69,6 +73,10 @@ class pkgCdrom /*{{{*/
public:
bool Ident(std::string &ident, pkgCdromStatus *log);
bool Add(pkgCdromStatus *log);
+
+ private:
+ APT_HIDDEN bool MountAndIdentCDROM(Configuration &Database, std::string &CDROM,
+ std::string &ident, pkgCdromStatus * const log, bool const interactive);
};
/*}}}*/
@@ -84,7 +92,7 @@ struct CdromDevice /*{{{*/
class pkgUdevCdromDevices /*{{{*/
{
protected:
- // libudev dlopen stucture
+ // libudev dlopen structure
void *libudev_handle;
struct udev* (*udev_new)(void);
int (*udev_enumerate_add_match_property)(struct udev_enumerate *udev_enumerate, const char *property, const char *value);
diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc
index eae419e34..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>
@@ -105,7 +109,7 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache)
break;
}
- // See if this verison matches the file
+ // See if this version matches the file
if (IsFetchable == true && Ver == V.VerStr())
break;
}
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 afa01a562..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,13 +46,18 @@ bool IsMounted(string &Path)
{
if (Path.empty() == true)
return false;
-
+
// Need that trailing slash for directories
if (Path[Path.length() - 1] != '/')
Path += '/';
-
- /* First we check if the path is actualy mounted, we do this by
- stating the path and the previous directory (carefull of links!)
+
+ // 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. */
struct stat Buf,Buf2;
if (stat(Path.c_str(),&Buf) != 0 ||
@@ -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 2086d91ca..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;
@@ -293,7 +298,7 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
// Look for an argument.
while (1)
{
- // Look at preceeding text
+ // Look at preceding text
char Buffer[300];
if (Argument == 0)
{
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.cc b/apt-pkg/contrib/crc-16.cc
index 4058821f9..f5df2d8b1 100644
--- a/apt-pkg/contrib/crc-16.cc
+++ b/apt-pkg/contrib/crc-16.cc
@@ -10,7 +10,7 @@
Al Longyear <longyear@netcom.com>
Modified by Jason Gunthorpe <jgg@debian.org> to fit the local coding
- style, this code is belived to be in the Public Domain.
+ style, this code is believed to be in the Public Domain.
##################################################################### */
/*}}}*/
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 7d09b2d4a..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,25 +219,25 @@ 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?
*
* The default checks if the list is empty or contains only notices,
- * if you want to check if also no notices happend set the parameter
+ * 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 efbf7aaf4..69406a9bf 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 /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -222,7 +183,7 @@ int GetLock(string File,bool Errors)
int FD = open(File.c_str(),O_RDWR | O_CREAT | O_NOFOLLOW,0640);
if (FD < 0)
{
- // Read only .. cant have locking problems there.
+ // Read only .. can't have locking problems there.
if (errno == EROFS)
{
_error->Warning(_("Not using locking for read only lock file %s"),File.c_str());
@@ -238,7 +199,7 @@ int GetLock(string File,bool Errors)
}
SetCloseExec(FD,true);
- // Aquire a write lock
+ // Acquire a write lock
struct flock fl;
fl.l_type = F_WRLCK;
fl.l_whence = SEEK_SET;
@@ -319,7 +280,7 @@ bool CreateDirectory(string const &Parent, string const &Path)
return false;
// we are not going to create directories "into the blue"
- if (Path.find(Parent, 0) != 0)
+ if (Path.compare(0, Parent.length(), Parent) != 0)
return false;
vector<string> const dirs = VectorizeString(Path.substr(Parent.size()), '/');
@@ -465,7 +426,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
const char *C = Ent->d_name;
for (; *C != 0; ++C)
if (isalpha(*C) == 0 && isdigit(*C) == 0
- && *C != '_' && *C != '-') {
+ && *C != '_' && *C != '-' && *C != ':') {
// no required extension -> dot is a bad character
if (*C == '.' && Ext.empty() == false)
continue;
@@ -874,6 +835,122 @@ 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 */
@@ -891,7 +968,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;
@@ -1061,30 +1138,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 +1155,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 +1326,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);
}
@@ -1256,7 +1384,7 @@ FileFd::~FileFd()
/*}}}*/
// FileFd::Read - Read a bit of the file /*{{{*/
// ---------------------------------------------------------------------
-/* We are carefull to handle interruption by a signal while reading
+/* We are careful to handle interruption by a signal while reading
gracefully. */
bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
{
@@ -1267,24 +1395,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 +1465,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 +1473,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 +1540,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
- Res = write(iFd,From,Size);
+#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
+ 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 +1587,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 +1595,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 +1626,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 +1642,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 +1653,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 +1699,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 +1736,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 +1759,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;
@@ -1588,29 +1776,55 @@ unsigned long long FileFd::Tell()
return Res;
}
/*}}}*/
-// FileFd::FileSize - Return the size of the file /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-unsigned long long FileFd::FileSize()
+static bool StatFileFd(char const * const msg, int const iFd, std::string const &FileName, struct stat &Buf, FileFdPrivate * const d) /*{{{*/
{
- struct stat Buf;
- if ((d == NULL || d->pipe == false) && fstat(iFd,&Buf) != 0)
- return FileFdErrno("fstat","Unable to determine the file size");
+ bool ispipe = (d != NULL && d->pipe == true);
+ if (ispipe == false)
+ {
+ if (fstat(iFd,&Buf) != 0)
+ // higher-level code will generate more meaningful messages,
+ // even translated this would be meaningless for users
+ return _error->Errno("fstat", "Unable to determine %s for fd %i", msg, iFd);
+ ispipe = S_ISFIFO(Buf.st_mode);
+ }
// for compressor pipes st_size is undefined and at 'best' zero
- if ((d != NULL && d->pipe == true) || S_ISFIFO(Buf.st_mode))
+ if (ispipe == true)
{
// we set it here, too, as we get the info here for free
// in theory the Open-methods should take care of it already
if (d != NULL)
d->pipe = true;
if (stat(FileName.c_str(), &Buf) != 0)
- return FileFdErrno("stat","Unable to determine the file size");
+ return _error->Errno("fstat", "Unable to determine %s for file %s", msg, FileName.c_str());
+ }
+ return true;
+}
+ /*}}}*/
+// FileFd::FileSize - Return the size of the file /*{{{*/
+unsigned long long FileFd::FileSize()
+{
+ struct stat Buf;
+ if (StatFileFd("file size", iFd, FileName, Buf, d) == false)
+ {
+ Flags |= Fail;
+ return 0;
}
-
return Buf.st_size;
}
/*}}}*/
+// FileFd::ModificationTime - Return the time of last touch /*{{{*/
+time_t FileFd::ModificationTime()
+{
+ struct stat Buf;
+ if (StatFileFd("modification time", iFd, FileName, Buf, d) == false)
+ {
+ Flags |= Fail;
+ return 0;
+ }
+ return Buf.st_mtime;
+}
+ /*}}}*/
// FileFd::Size - Return the size of the content in the file /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -1620,11 +1834,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];
@@ -1682,35 +1892,6 @@ unsigned long long FileFd::Size()
return size;
}
/*}}}*/
-// FileFd::ModificationTime - Return the time of last touch /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-time_t FileFd::ModificationTime()
-{
- struct stat Buf;
- if ((d == NULL || d->pipe == false) && fstat(iFd,&Buf) != 0)
- {
- FileFdErrno("fstat","Unable to determine the modification time of file %s", FileName.c_str());
- return 0;
- }
-
- // for compressor pipes st_size is undefined and at 'best' zero
- if ((d != NULL && d->pipe == true) || S_ISFIFO(Buf.st_mode))
- {
- // we set it here, too, as we get the info here for free
- // in theory the Open-methods should take care of it already
- if (d != NULL)
- d->pipe = true;
- if (stat(FileName.c_str(), &Buf) != 0)
- {
- FileFdErrno("fstat","Unable to determine the modification time of file %s", FileName.c_str());
- return 0;
- }
- }
-
- return Buf.st_mtime;
-}
- /*}}}*/
// FileFd::Close - Close the file if the close flag is set /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -1796,7 +1977,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()" /*{{{*/
@@ -1844,3 +2031,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..f25ed3622 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);
@@ -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;};
@@ -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 f57a72d86..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>
/*}}}*/
@@ -103,12 +105,12 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG,
}
}
+ enum { DETACHED, CLEARSIGNED } releaseSignature = (FileGPG != File) ? DETACHED : CLEARSIGNED;
std::vector<std::string> dataHeader;
char * sig = NULL;
char * data = NULL;
- // file with detached signature
- if (FileGPG != File)
+ if (releaseSignature == DETACHED)
{
Args.push_back(FileGPG.c_str());
Args.push_back(File.c_str());
@@ -181,7 +183,7 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG,
putenv((char *)"LC_MESSAGES=");
}
- if (FileGPG != File)
+ if (releaseSignature == DETACHED)
{
execvp(gpgvpath.c_str(), (char **) &Args[0]);
ioprintf(std::cerr, "Couldn't execute %s to check %s", Args[0], File.c_str());
@@ -260,8 +262,7 @@ bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,
char *buf = NULL;
size_t buf_size = 0;
- ssize_t line_len = 0;
- while ((line_len = getline(&buf, &buf_size, in)) != -1)
+ while (getline(&buf, &buf_size, in) != -1)
{
_strrstrip(buf);
if (found_message_start == false)
@@ -355,7 +356,7 @@ bool OpenMaybeClearSignedFile(std::string const &ClearSignedFileName, FileFd &Me
return _error->Error("Couldn't open temporary file to work with %s", ClearSignedFileName.c_str());
_error->PushToStack();
- bool const splitDone = SplitClearSignedFile(ClearSignedFileName.c_str(), &MessageFile, NULL, NULL);
+ bool const splitDone = SplitClearSignedFile(ClearSignedFileName, &MessageFile, NULL, NULL);
bool const errorDone = _error->PendingError();
_error->MergeWithStack();
if (splitDone == false)
diff --git a/apt-pkg/contrib/gpgv.h b/apt-pkg/contrib/gpgv.h
index 45f069058..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
@@ -29,7 +29,7 @@
* for reading. Use #OpenMaybeClearSignedFile to access the message
* instead to ensure you are only reading signed data.
*
- * The method does not return, but has some noteable exit-codes:
+ * The method does not return, but has some notable exit-codes:
* 111 signals an internal error like the inability to execute gpgv,
* 112 indicates a clear-signed file which doesn't include a message,
* which can happen if APT is run while on a network requiring
@@ -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 b4c768db9..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());
}
@@ -129,13 +133,12 @@ bool Hashes::AddFD(int const Fd,unsigned long long Size, bool const addMD5,
bool const addSHA1, bool const addSHA256, bool const addSHA512)
{
unsigned char Buf[64*64];
- ssize_t Res = 0;
- int ToEOF = (Size == 0);
+ bool const ToEOF = (Size == 0);
while (Size != 0 || ToEOF)
{
unsigned long long n = sizeof(Buf);
if (!ToEOF) n = std::min(Size, n);
- Res = read(Fd,Buf,n);
+ ssize_t const Res = read(Fd,Buf,n);
if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read
return false;
if (ToEOF && Res == 0) // EOF
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 289e43aa4..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"
@@ -9,13 +12,12 @@
/* */
bool SummationImplementation::AddFD(int const Fd, unsigned long long Size) {
unsigned char Buf[64 * 64];
- ssize_t Res = 0;
- int ToEOF = (Size == 0);
+ bool const ToEOF = (Size == 0);
while (Size != 0 || ToEOF)
{
unsigned long long n = sizeof(Buf);
if (!ToEOF) n = std::min(Size, n);
- Res = read(Fd, Buf, n);
+ ssize_t const Res = read(Fd, Buf, n);
if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read
return false;
if (ToEOF && Res == 0) // EOF
@@ -27,7 +29,7 @@ bool SummationImplementation::AddFD(int const Fd, unsigned long long Size) {
}
bool SummationImplementation::AddFD(FileFd &Fd, unsigned long long Size) {
unsigned char Buf[64 * 64];
- bool ToEOF = (Size == 0);
+ bool const ToEOF = (Size == 0);
while (Size != 0 || ToEOF)
{
unsigned long long n = sizeof(Buf);
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 62e7b65db..2d6448e5e 100644
--- a/apt-pkg/contrib/macros.h
+++ b/apt-pkg/contrib/macros.h
@@ -44,7 +44,7 @@
#define _boundv(a,b,c) b = _bound(a,b,c)
#define ABS(a) (((a) < (0)) ?-(a) : (a))
-/* Usefull count macro, use on an array of things and it will return the
+/* Useful count macro, use on an array of things and it will return the
number of items in the array */
#define _count(a) (sizeof(a)/sizeof(a[0]))
@@ -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 25631b166..f4992c223 100644
--- a/apt-pkg/contrib/md5.h
+++ b/apt-pkg/contrib/md5.h
@@ -10,7 +10,7 @@
store a MD5Sum in 16 bytes of memory.
A MD5Sum is used to generate a (hopefully) unique 16 byte number for a
- block of data. This can be used to gaurd against corruption of a file.
+ block of data. This can be used to guard against corruption of a file.
MD5 should not be used for tamper protection, use SHA or something more
secure.
@@ -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 a176da636..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
}
@@ -352,6 +352,12 @@ unsigned long DynamicMMap::RawAllocate(unsigned long long Size,unsigned long Aln
size in the file. */
unsigned long DynamicMMap::Allocate(unsigned long ItemSize)
{
+ if (unlikely(ItemSize == 0))
+ {
+ _error->Fatal("Can't allocate an item of size zero");
+ return 0;
+ }
+
// Look for a matching pool entry
Pool *I;
Pool *Empty = 0;
@@ -412,7 +418,7 @@ unsigned long DynamicMMap::WriteString(const char *String,
unsigned long const Result = RawAllocate(Len+1,0);
- if (Result == 0 && _error->PendingError())
+ if (Base == NULL || (Result == 0 && _error->PendingError()))
return 0;
memcpy((char *)Base + Result,String,Len);
diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h
index 6bd4a2d86..c1dfedf6d 100644
--- a/apt-pkg/contrib/mmap.h
+++ b/apt-pkg/contrib/mmap.h
@@ -6,7 +6,7 @@
MMap Class - Provides 'real' mmap or a faked mmap using read().
The purpose of this code is to provide a generic way for clients to
- access the mmap function. In enviroments that do not support mmap
+ access the mmap function. In environments that do not support mmap
from file fd's this function will use read and normal allocated
memory.
@@ -15,7 +15,7 @@
The DynamicMMap class is used to help the on-disk data structure
generators. It provides a large allocated workspace and members
- to allocate space from the workspace in an effecient fashion.
+ to allocate space from the workspace in an efficient fashion.
This source is placed in the Public Domain, do with it what you will
It was originally written by Jason Gunthorpe.
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/progress.h b/apt-pkg/contrib/progress.h
index 3a6943aee..f7fbc9ccf 100644
--- a/apt-pkg/contrib/progress.h
+++ b/apt-pkg/contrib/progress.h
@@ -7,7 +7,7 @@
This class allows lengthy operations to communicate their progress
to the GUI. The progress model is simple and is not designed to handle
- the complex case of the multi-activity aquire class.
+ the complex case of the multi-activity acquire class.
The model is based on the concept of an overall operation consisting
of a series of small sub operations. Each sub operation has it's own
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 f84fb761c..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"
@@ -65,7 +66,7 @@
* Please make sure that your system defines BYTE_ORDER. If your
* architecture is little-endian, make sure it also defines
* LITTLE_ENDIAN and that the two (BYTE_ORDER and LITTLE_ENDIAN) are
- * equivilent.
+ * equivalent.
*
* If your system does not define the above, then you can do so by
* hand like this:
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 962112854..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 /*{{{*/
// ---------------------------------------------------------------------
@@ -426,7 +431,7 @@ string TimeToStr(unsigned long Sec)
/*}}}*/
// SubstVar - Substitute a string for another string /*{{{*/
// ---------------------------------------------------------------------
-/* This replaces all occurances of Subst with Contents in Str. */
+/* This replaces all occurrences of Subst with Contents in Str. */
string SubstVar(const string &Str,const string &Subst,const string &Contents)
{
string::size_type Pos = 0;
@@ -926,7 +931,7 @@ bool FTPMDTMStrToTime(const char* const str,time_t &time)
/*}}}*/
// StrToTime - Converts a string into a time_t /*{{{*/
// ---------------------------------------------------------------------
-/* This handles all 3 populare time formats including RFC 1123, RFC 1036
+/* This handles all 3 popular time formats including RFC 1123, RFC 1036
and the C library asctime format. It requires the GNU library function
'timegm' to convert a struct tm in UTC to a time_t. For some bizzar
reason the C library does not provide any such function :< This also
@@ -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;
@@ -1313,7 +1320,7 @@ string StripEpoch(const string &VerStr)
// tolower_ascii - tolower() function that ignores the locale /*{{{*/
// ---------------------------------------------------------------------
/* This little function is the most called method we have and tries
- therefore to do the absolut minimum - and is noteable faster than
+ therefore to do the absolut minimum - and is notable faster than
standard tolower/toupper and as a bonus avoids problems with different
locales - we only operate on ascii chars anyway. */
int tolower_ascii(int const c)
@@ -1324,9 +1331,9 @@ int tolower_ascii(int const c)
}
/*}}}*/
-// CheckDomainList - See if Host is in a , seperate list /*{{{*/
+// CheckDomainList - See if Host is in a , separate list /*{{{*/
// ---------------------------------------------------------------------
-/* The domain list is a comma seperate list of domains that are suffix
+/* The domain list is a comma separate list of domains that are suffix
matched against the argument */
bool CheckDomainList(const string &Host,const string &List)
{
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 68d544e1f..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(':');
@@ -758,7 +855,7 @@ bool debListParser::GrabWord(string Word,WordList *List,unsigned char &Out)
/*}}}*/
// ListParser::Step - Move to the next section in the file /*{{{*/
// ---------------------------------------------------------------------
-/* This has to be carefull to only process the correct architecture */
+/* This has to be careful to only process the correct architecture */
bool debListParser::Step()
{
iOffset = Tags.Offset();
@@ -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 5d2a67f4f..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) */
@@ -30,7 +35,7 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
public:
- virtual bool Restart() {return Tags.Jump(Sect,0);};
+ virtual bool Restart() {return Jump(0);};
virtual bool Step() {iOffset = Tags.Offset(); return Tags.Step(Sect);};
virtual bool Jump(unsigned long const &Off) {iOffset = Off; return Tags.Jump(Sect,Off);};
@@ -50,8 +55,8 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
virtual bool Files(std::vector<pkgSrcRecords::File> &F);
debSrcRecordParser(std::string const &File,pkgIndexFile const *Index)
- : Parser(Index), Fd(File,FileFd::ReadOnly, FileFd::Extension), Tags(&Fd,102400),
- Buffer(NULL) {}
+ : Parser(Index), Fd(File,FileFd::ReadOnly, FileFd::Extension), Tags(&Fd,102400),
+ iOffset(0), Buffer(NULL) {}
virtual ~debSrcRecordParser();
};
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index 7ed6936c3..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>
@@ -193,9 +200,9 @@ bool debSystem::Initialize(Configuration &Cnf)
/*}}}*/
// System::ArchiveSupported - Is a file format supported /*{{{*/
// ---------------------------------------------------------------------
-/* The standard name for a deb is 'deb'.. There are no seperate versions
+/* 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 140561262..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>
/*}}}*/
@@ -116,7 +118,7 @@ int debVersioningSystem::CmpFragment(const char *A,const char *AEnd,
return 1;
}
- // Shouldnt happen
+ // Shouldn't happen
return 1;
}
/*}}}*/
@@ -221,7 +223,7 @@ bool debVersioningSystem::CheckDep(const char *PkgVer,
if (PkgVer == DepVer)
return Op == pkgCache::Dep::Equals || Op == pkgCache::Dep::LessEq || Op == pkgCache::Dep::GreaterEq;
- // Perform the actual comparision.
+ // Perform the actual comparison.
int const Res = CmpVersion(PkgVer, DepVer);
switch (Op)
{
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 14ce133cf..5a5fff13b 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -10,41 +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 <string.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>
/*}}}*/
@@ -568,7 +572,6 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
std::string prefix = APT::String::Strip(list[0]);
std::string pkgname;
std::string action;
- ostringstream status;
// "processing" has the form "processing: action: pkg or trigger"
// with action = ["install", "configure", "remove", "purge", "disappear",
@@ -1028,6 +1031,12 @@ bool pkgDPkgPM::Go(int StatusFd)
void pkgDPkgPM::StartPtyMagic()
{
+ if (_config->FindB("Dpkg::Use-Pty", true) == false)
+ {
+ d->master = d->slave = -1;
+ return;
+ }
+
// setup the pty and stuff
struct winsize win;
@@ -1036,10 +1045,9 @@ void pkgDPkgPM::StartPtyMagic()
_error->PushToStack();
if (tcgetattr(STDOUT_FILENO, &d->tt) == 0)
{
- ioctl(1, TIOCGWINSZ, (char *)&win);
- if (_config->FindB("Dpkg::Use-Pty", true) == false)
+ if (ioctl(1, TIOCGWINSZ, (char *)&win) < 0)
{
- d->master = d->slave = -1;
+ _error->Errno("ioctl", _("ioctl(TIOCGWINSZ) failed"));
} else if (openpty(&d->master, &d->slave, NULL, &d->tt, &win) < 0)
{
_error->Errno("openpty", _("Can not write log (%s)"), _("Is /dev/pts mounted?"));
@@ -1393,12 +1401,17 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress)
if(d->slave >= 0 && d->master >= 0)
{
setsid();
- ioctl(d->slave, TIOCSCTTY, 0);
- close(d->master);
- dup2(d->slave, 0);
- dup2(d->slave, 1);
- dup2(d->slave, 2);
- close(d->slave);
+ int res = ioctl(d->slave, TIOCSCTTY, 0);
+ if (res < 0) {
+ std::cerr << "ioctl(TIOCSCTTY) failed for fd: "
+ << d->slave << std::endl;
+ } else {
+ close(d->master);
+ dup2(d->slave, 0);
+ dup2(d->slave, 1);
+ dup2(d->slave, 2);
+ close(d->slave);
+ }
}
close(fd[0]); // close the read end of the pipe
@@ -1517,28 +1530,18 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress)
// here but keep the loop going and just report it as a error
// for later
bool const stopOnError = _config->FindB("Dpkg::StopOnError",true);
-
- if(stopOnError)
- RunScripts("DPkg::Post-Invoke");
- if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV)
+ if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV)
strprintf(d->dpkg_error, "Sub-process %s received a segmentation fault.",Args[0]);
else if (WIFEXITED(Status) != 0)
strprintf(d->dpkg_error, "Sub-process %s returned an error code (%u)",Args[0],WEXITSTATUS(Status));
- else
+ else
strprintf(d->dpkg_error, "Sub-process %s exited unexpectedly",Args[0]);
+ _error->Error("%s", d->dpkg_error.c_str());
- if(d->dpkg_error.size() > 0)
- _error->Error("%s", d->dpkg_error.c_str());
-
- if(stopOnError)
- {
- CloseLog();
- StopPtyMagic();
- d->progress->Stop();
- return false;
- }
- }
+ if(stopOnError)
+ break;
+ }
}
// dpkg is done at this point
d->progress->Stop();
@@ -1569,10 +1572,10 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress)
}
Cache.writeStateFile(NULL);
- return true;
+ return d->dpkg_error.empty();
}
-void SigINT(int sig) {
+void SigINT(int /*sig*/) {
pkgPackageManager::SigINTStop = true;
}
/*}}}*/
@@ -1652,7 +1655,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
io_errors.push_back(string("failed in write on buffer copy for %s"));
io_errors.push_back(string("short read on buffer copy for %s"));
- for (vector<string>::iterator I = io_errors.begin(); I != io_errors.end(); I++)
+ for (vector<string>::iterator I = io_errors.begin(); I != io_errors.end(); ++I)
{
vector<string> list = VectorizeString(dgettext("dpkg", (*I).c_str()), '%');
if (list.size() > 1) {
@@ -1767,13 +1770,11 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
string histfile_name = _config->FindFile("Dir::Log::History");
if (!histfile_name.empty())
{
- FILE *log = NULL;
- char buf[1024];
-
fprintf(report, "DpkgHistoryLog:\n");
- log = fopen(histfile_name.c_str(),"r");
+ FILE* log = fopen(histfile_name.c_str(),"r");
if(log != NULL)
{
+ char buf[1024];
while( fgets(buf, sizeof(buf), log) != NULL)
fprintf(report, " %s", buf);
fclose(log);
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 f9c891c86..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);
@@ -789,7 +795,7 @@ bool pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser,
// - this makes sense as default when all Garbage dependencies
// are automatically marked for removal (as aptitude does).
// setting a package for keep then makes it no longer autoinstalled
- // for all other use-case this action is rather suprising
+ // for all other use-case this action is rather surprising
if(FromUser && !P.Marked)
P.Flags &= ~Flag::Auto;
#endif
@@ -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,27 +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 can't install it, so remove it again
- MarkDelete(Pkg,false,Depth + 1, false);
- return false;
- }
+ continue;
/* Check if any ImportantDep() (but not Critical) were added
* since we installed the package. Also check for deps that
@@ -1190,7 +1190,7 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
}
}
- /* This bit is for processing the possibilty of an install/upgrade
+ /* This bit is for processing the possibility of an install/upgrade
fixing the problem for "positive" dependencies */
if (Start.IsNegative() == false && (DepState[Start->ID] & DepCVer) == DepCVer)
{
@@ -1253,6 +1253,11 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
if (PkgState[Pkg->ID].InstallVer == 0)
continue;
+ /* Ignore negative dependencies that we are not going to
+ get installed */
+ if (PkgState[Pkg->ID].InstallVer != *I)
+ continue;
+
if ((Start->Version != 0 || TrgPkg != Pkg) &&
PkgState[Pkg->ID].CandidateVer != PkgState[Pkg->ID].InstallVer &&
PkgState[Pkg->ID].CandidateVer != *I &&
@@ -1284,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() ||
@@ -1305,7 +1316,7 @@ bool pkgDepCache::IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg,
// (simple string-compare as stuff like '1' == '0:1-0' can't happen here)
if (P->CurrentVer == 0 || strcmp(Pkg.CandVersion(), P.CandVersion()) == 0)
continue;
- // packages loosing M-A:same can be out-of-sync
+ // packages losing M-A:same can be out-of-sync
VerIterator CV = PkgState[P->ID].CandidateVerIter(*this);
if (unlikely(CV.end() == true) ||
(CV->MultiArch & pkgCache::Version::Same) != pkgCache::Version::Same)
@@ -1324,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 /*{{{*/
// ---------------------------------------------------------------------
@@ -1675,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 61c9aa559..bec651279 100644
--- a/apt-pkg/depcache.h
+++ b/apt-pkg/depcache.h
@@ -15,7 +15,7 @@
This structure is important to support the readonly status of the cache
file. When the data is saved the cache will be refereshed from our
- internal rep and written to disk. Then the actual persistant data
+ internal rep and written to disk. Then the actual persistent data
files will be put on the disk.
Each dependency is compared against 3 target versions to produce to
@@ -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 12b06d143..f3092d3c6 100644
--- a/apt-pkg/edsp.h
+++ b/apt-pkg/edsp.h
@@ -2,15 +2,19 @@
/** Description \file edsp.h {{{
######################################################################
Set of methods to help writing and reading everything needed for EDSP
- with the noteable exception of reading a scenario for conversion into
+ with the notable exception of reading a scenario for conversion into
a Cache as this is handled by edsp interface for listparser and friends
##################################################################### */
/*}}}*/
#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:
@@ -182,13 +184,13 @@ public:
* they were unable to calculate a solution for a given task.
* Obviously they can't send a solution through, so this
* methods deals with formatting an error message correctly
- * so that the front-ends can recieve and display it.
+ * so that the front-ends can receive and display it.
*
* The first line of the message should be a short description
* of the error so it can be used for dialog titles or alike
*
* \param uuid of this error message
- * \param message is free form text to discribe the error
+ * \param message is free form text to describe the error
* \param output the front-end listens for error messages
*/
bool static WriteError(char const * const uuid, std::string const &message, FILE* output);
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 2d433b60a..b5c9ac77e 100644
--- a/apt-pkg/indexfile.h
+++ b/apt-pkg/indexfile.h
@@ -10,30 +10,33 @@
Binary index files
Binary translation files
- Bianry index files decribing the local system
+ Binary index files describing the local system
Source index files
They are all bundled together here, and the interfaces for
sources.list, acquire, cache gen and record parsing all use this class
- to acess the underlying representation.
+ to access the underlying representation.
##################################################################### */
/*}}}*/
#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 81b601a7f..3a35f852e 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>
/*}}}*/
@@ -92,7 +94,7 @@ bool pkgInitConfig(Configuration &Cnf)
// Read an alternate config file
const char *Cfg = getenv("APT_CONFIG");
- if (Cfg != 0)
+ if (Cfg != 0 && strlen(Cfg) != 0)
{
if (RealFileExists(Cfg) == true)
Res &= ReadConfigFile(Cnf,Cfg);
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 fe065da4f..dfe4fb18c 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()
{
}
@@ -242,7 +248,7 @@ PackageManagerFancy::~PackageManagerFancy()
void PackageManagerFancy::staticSIGWINCH(int signum)
{
std::vector<PackageManagerFancy *>::const_iterator I;
- for(I = instances.begin(); I != instances.end(); I++)
+ for(I = instances.begin(); I != instances.end(); ++I)
(*I)->HandleSIGWINCH(signum);
}
@@ -329,15 +335,15 @@ bool PackageManagerFancy::StatusChanged(std::string PackageName,
int row = GetNumberTerminalRows();
- 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";
-
+ static std::string save_cursor = "\033[s";
+ static std::string restore_cursor = "\033[u";
+
+ static std::string set_bg_color = "\033[42m"; // green
+ static std::string set_fg_color = "\033[30m"; // black
+
+ static std::string restore_bg = "\033[49m";
+ static std::string restore_fg = "\033[39m";
+
std::cout << save_cursor
// move cursor position to last row
<< "\033[" << row << ";0f"
@@ -371,5 +377,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..baf245376 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);
@@ -134,7 +134,7 @@ 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);
@@ -143,14 +143,14 @@ namespace Progress {
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 984ae1d10..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>
/*}}}*/
@@ -566,10 +570,10 @@ bool pkgOrderList::VisitProvides(DepIterator D,bool Critical)
// ---------------------------------------------------------------------
/* This is the core ordering routine. It calls the set dependency
consideration functions which then potentialy call this again. Finite
- depth is achived through the colouring mechinism. */
+ depth is achieved through the colouring mechinism. */
bool pkgOrderList::VisitNode(PkgIterator Pkg, char const* from)
{
- // Looping or irrelevent.
+ // Looping or irrelevant.
// This should probably trancend not installed packages
if (Pkg.end() == true || IsFlag(Pkg,Added) == true ||
IsFlag(Pkg,AddPending) == true || IsFlag(Pkg,InList) == false)
@@ -824,7 +828,7 @@ bool pkgOrderList::DepUnPackPre(DepIterator D)
The forwards depends loop is designed to bring the packages dependents
close to the package. This helps reduce deconfigure time.
- Loops are irrelevent to this. */
+ Loops are irrelevant to this. */
bool pkgOrderList::DepUnPackDep(DepIterator D)
{
@@ -840,7 +844,7 @@ bool pkgOrderList::DepUnPackDep(DepIterator D)
D.ParentPkg().CurrentVer() != D.ParentVer())
continue;
- // The dep will not break so it is irrelevent.
+ // The dep will not break so it is irrelevant.
if (CheckDep(D) == true)
continue;
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 3fdd9b637..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>
@@ -215,7 +222,7 @@ bool pkgPackageManager::CreateOrderList()
return true;
}
/*}}}*/
-// PM::DepAlwaysTrue - Returns true if this dep is irrelevent /*{{{*/
+// PM::DepAlwaysTrue - Returns true if this dep is irrelevant /*{{{*/
// ---------------------------------------------------------------------
/* The restriction on provides is to eliminate the case when provides
are transitioning between valid states [ie exim to smail] */
@@ -243,11 +250,11 @@ bool pkgPackageManager::CheckRConflicts(PkgIterator Pkg,DepIterator D,
D->Type != pkgCache::Dep::Obsoletes)
continue;
- // The package hasnt been changed
+ // The package hasn't been changed
if (List->IsNow(Pkg) == false)
continue;
- // Ignore self conflicts, ignore conflicts from irrelevent versions
+ // Ignore self conflicts, ignore conflicts from irrelevant versions
if (D.IsIgnorable(Pkg) || D.ParentVer() != D.ParentPkg().CurrentVer())
continue;
@@ -314,7 +321,7 @@ bool pkgPackageManager::ConfigureAll()
Note on failure: This method can fail, without causing any problems.
This can happen when using Immediate-Configure-All, SmartUnPack may call
- SmartConfigure, it may fail because of a complex dependancy situation, but
+ SmartConfigure, it may fail because of a complex dependency situation, but
a error will only be reported if ConfigureAll fails. This is why some of the
messages this function reports on failure (return false;) as just warnings
only shown when debuging*/
@@ -596,7 +603,7 @@ bool pkgPackageManager::SmartRemove(PkgIterator Pkg)
/*}}}*/
// PM::SmartUnPack - Install helper /*{{{*/
// ---------------------------------------------------------------------
-/* This puts the system in a state where it can Unpack Pkg, if Pkg is allready
+/* This puts the system in a state where it can Unpack Pkg, if Pkg is already
unpacked, or when it has been unpacked, if Immediate==true it configures it. */
bool pkgPackageManager::SmartUnPack(PkgIterator Pkg)
{
@@ -615,6 +622,8 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
clog << " (replace version " << Pkg.CurrentVer().VerStr() << " with " << InstallVer.VerStr() << ")";
if (PkgLoop)
clog << " (Only Perform PreUnpack Checks)";
+ if (Immediate)
+ clog << " immediately";
clog << endl;
}
@@ -623,7 +632,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
/* PreUnpack Checks: This loop checks and attempts to rectify and problems that would prevent the package being unpacked.
It addresses: PreDepends, Conflicts, Obsoletes and Breaks (DpkgBreaks). Any resolutions that do not require it should
avoid configuration (calling SmartUnpack with Immediate=true), this is because when unpacking some packages with
- complex dependancy structures, trying to configure some packages while breaking the loops can complicate things .
+ complex dependency structures, trying to configure some packages while breaking the loops can complicate things .
This will be either dealt with if the package is configured as a dependency of Pkg (if and when Pkg is configured),
or by the ConfigureAll call at the end of the for loop in OrderInstall. */
bool Changed = false;
@@ -741,7 +750,8 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
// See if the current version is conflicting
if (ConflictPkg.CurrentVer() == Ver && List->IsNow(ConflictPkg))
{
- clog << OutputInDepth(Depth) << Pkg.FullName() << " conflicts with " << ConflictPkg.FullName() << endl;
+ if (Debug)
+ clog << OutputInDepth(Depth) << Pkg.FullName() << " conflicts with " << ConflictPkg.FullName() << endl;
/* If a loop is not present or has not yet been detected, attempt to unpack packages
to resolve this conflict. If there is a loop present, remove packages to resolve this conflict */
if (List->IsFlag(ConflictPkg,pkgOrderList::Loop) == false)
@@ -790,7 +800,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
{
if (List->IsFlag(BrokenPkg,pkgOrderList::Loop) && PkgLoop)
{
- // This dependancy has already been dealt with by another SmartUnPack on Pkg
+ // This dependency has already been dealt with by another SmartUnPack on Pkg
break;
}
else
@@ -955,21 +965,14 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
{
PkgIterator Pkg(Cache,*I);
-
+
if (List->IsNow(Pkg) == false)
{
- if (!List->IsFlag(Pkg,pkgOrderList::Configured) && !NoImmConfigure) {
- if (SmartConfigure(Pkg, 0) == false && Debug)
- _error->Warning("Internal Error, Could not configure %s",Pkg.FullName().c_str());
- // FIXME: The above warning message might need changing
- } else {
- if (Debug == true)
- clog << "Skipping already done " << Pkg.FullName() << endl;
- }
+ if (Debug == true)
+ clog << "Skipping already done " << Pkg.FullName() << endl;
continue;
-
}
-
+
if (List->IsMissing(Pkg) == true)
{
if (Debug == true)
@@ -1003,7 +1006,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
DoneSomething = true;
if (ImmConfigureAll) {
- /* ConfigureAll here to pick up and packages left unconfigured becuase they were unpacked in the
+ /* ConfigureAll here to pick up and packages left unconfigured because they were unpacked in the
"PreUnpack Checks" section */
if (!ConfigureAll())
return Failed;
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 52e814c0b..91b75f52e 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -8,7 +8,7 @@
Please see doc/apt-pkg/cache.sgml for a more detailed description of
this format. Also be sure to keep that file up-to-date!!
- This is the general utility functions for cache managment. They provide
+ This is the general utility functions for cache management. They provide
a complete set of accessor functions for the cache. The cacheiterators
header contains the STL-like iterators that can be used to easially
navigate the cache as well as seemlessly dereference the mmap'd
@@ -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,31 +482,31 @@ 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 /*{{{*/
// ---------------------------------------------------------------------
/* Output name < cur.rent.version -> candid.ate.version | new.est.version > (section)
- Note that the characters <|>() are all literal above. Versions will be ommited
+ Note that the characters <|>() are all literal above. Versions will be omitted
if they provide no new information (e.g. there is no newer version than candidate)
If no version and/or section can be found "none" is used. */
std::ostream&
@@ -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 1a7013551..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();
};
/*}}}*/
@@ -354,7 +356,7 @@ struct pkgCache::Group
the hash index of the name in the pkgCache::Header::PkgHashTable
A package can be created for every architecture so package names are
- not unique, but it is garanteed that packages with the same name
+ not unique, but it is guaranteed that packages with the same name
are sequencel ordered in the list. Packages with the same name can be
accessed with the Group.
*/
@@ -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 75f7b9fcc..6e33c67ed 100644
--- a/apt-pkg/pkgsystem.h
+++ b/apt-pkg/pkgsystem.h
@@ -7,7 +7,7 @@
Instances of this class can be thought of as factories or meta-classes
for a variety of more specialized classes. Together this class and
- it's speciallized offspring completely define the environment and how
+ it's specialized offspring completely define the environment and how
to access resources for a specific system. There are several sub
areas that are all orthogonal - each system has a unique combination of
these sub areas:
@@ -23,7 +23,7 @@
- Selection of local 'status' indexes that make up the pkgCache.
It is important to note that the handling of index files is not a
- function of the system. Index files are handled through a seperate
+ function of the system. Index files are handled through a separate
abstraction - the only requirement is that the index files have the
same idea of versioning as the target system.
@@ -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 0fd237cad..e37899ec6 100644
--- a/apt-pkg/sourcelist.cc
+++ b/apt-pkg/sourcelist.cc
@@ -17,8 +17,19 @@
#include <apt-pkg/configuration.h>
#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>
#include <apti18n.h>
/*}}}*/
@@ -70,6 +81,69 @@ bool pkgSourceList::Type::FixupURI(string &URI) const
return true;
}
/*}}}*/
+bool pkgSourceList::Type::ParseStanza(vector<metaIndex *> &List,
+ pkgTagSection &Tags,
+ int i,
+ FileFd &Fd)
+{
+ map<string, string> Options;
+
+ string Enabled = Tags.FindS("Enabled");
+ if (Enabled.size() > 0 && StringToBool(Enabled) == false)
+ return true;
+
+ // Define external/internal options
+ const char* option_deb822[] = {
+ "Architectures", "Architectures-Add", "Architectures-Remove", "Trusted",
+ };
+ const char* option_internal[] = {
+ "arch", "arch+", "arch-", "trusted",
+ };
+ for (unsigned int j=0; j < sizeof(option_deb822)/sizeof(char*); j++)
+ if (Tags.Exists(option_deb822[j]))
+ {
+ // for deb822 the " " is the delimiter, but the backend expects ","
+ std::string option = Tags.FindS(option_deb822[j]);
+ std::replace(option.begin(), option.end(), ' ', ',');
+ Options[option_internal[j]] = option;
+ }
+
+ // now create one item per suite/section
+ string Suite = Tags.FindS("Suites");
+ Suite = SubstVar(Suite,"$(ARCH)",_config->Find("APT::Architecture"));
+ string const Section = Tags.FindS("Sections");
+ string URIS = Tags.FindS("URIs");
+
+ std::vector<std::string> list_uris = StringSplit(URIS, " ");
+ std::vector<std::string> list_dist = StringSplit(Suite, " ");
+ std::vector<std::string> list_section = StringSplit(Section, " ");
+
+ for (std::vector<std::string>::const_iterator U = list_uris.begin();
+ U != list_uris.end(); U++)
+ {
+ std::string URI = (*U);
+ if (!FixupURI(URI))
+ {
+ _error->Error(_("Malformed stanza %u in source list %s (URI parse)"),i,Fd.Name().c_str());
+ return false;
+ }
+
+ for (std::vector<std::string>::const_iterator I = list_dist.begin();
+ I != list_dist.end(); I++)
+ {
+ for (std::vector<std::string>::const_iterator J = list_section.begin();
+ J != list_section.end(); J++)
+ {
+ if (CreateItem(List, URI, (*I), (*J), Options) == false)
+ {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+}
+
// Type::ParseLine - Parse a single line /*{{{*/
// ---------------------------------------------------------------------
/* This is a generic one that is the 'usual' format for sources.list
@@ -159,7 +233,6 @@ bool pkgSourceList::Type::ParseLine(vector<metaIndex *> &List,
return true;
}
/*}}}*/
-
// SourceList::pkgSourceList - Constructors /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -181,7 +254,6 @@ pkgSourceList::~pkgSourceList()
delete *I;
}
/*}}}*/
- /*}}}*/
// SourceList::ReadMainList - Read the main source list from etc /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -216,7 +288,6 @@ bool pkgSourceList::ReadMainList()
return Res;
}
/*}}}*/
-// CNC:2003-03-03 - Needed to preserve backwards compatibility.
// SourceList::Reset - Clear the sourcelist contents /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -227,7 +298,6 @@ void pkgSourceList::Reset()
SrcList.erase(SrcList.begin(),SrcList.end());
}
/*}}}*/
-// CNC:2003-03-03 - Function moved to ReadAppend() and Reset().
// SourceList::Read - Parse the sourcelist file /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -242,16 +312,28 @@ bool pkgSourceList::Read(string File)
/* */
bool pkgSourceList::ReadAppend(string File)
{
+ if (_config->FindB("APT::Sources::Use-Deb822", false) == true)
+ {
+ int lines_parsed =ParseFileDeb822(File);
+ if (lines_parsed < 0)
+ return false;
+ else if (lines_parsed > 0)
+ return true;
+ // no lines parsed ... fall through and use old style parser
+ }
+ return ParseFileOldStyle(File);
+}
+
+// SourceList::ReadFileOldStyle - Read Traditional style sources.list /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgSourceList::ParseFileOldStyle(string File)
+{
// Open the stream for reading
ifstream F(File.c_str(),ios::in /*| ios::nocreate*/);
if (!F != 0)
return _error->Errno("ifstream::ifstream",_("Opening %s"),File.c_str());
-
-#if 0 // Now Reset() does this.
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
- delete *I;
- SrcList.erase(SrcList.begin(),SrcList.end());
-#endif
+
// CNC:2003-12-10 - 300 is too short.
char Buffer[1024];
@@ -298,6 +380,54 @@ bool pkgSourceList::ReadAppend(string File)
return true;
}
/*}}}*/
+// SourceList::ParseFileDeb822 - Parse deb822 style sources.list /*{{{*/
+// ---------------------------------------------------------------------
+/* Returns: the number of stanzas parsed*/
+int pkgSourceList::ParseFileDeb822(string File)
+{
+ pkgTagSection Tags;
+ unsigned int i=0;
+
+ // see if we can read the file
+ _error->PushToStack();
+ FileFd Fd(File, FileFd::ReadOnly);
+ pkgTagFile Sources(&Fd);
+ if (_error->PendingError() == true)
+ {
+ _error->RevertToStack();
+ return 0;
+ }
+ _error->MergeWithStack();
+
+ // read step by step
+ while (Sources.Step(Tags) == true)
+ {
+ if(!Tags.Exists("Types"))
+ continue;
+
+ string const types = Tags.FindS("Types");
+ std::vector<std::string> list_types = StringSplit(types, " ");
+ for (std::vector<std::string>::const_iterator I = list_types.begin();
+ I != list_types.end(); I++)
+ {
+ Type *Parse = Type::GetType((*I).c_str());
+ if (Parse == 0)
+ {
+ _error->Error(_("Type '%s' is not known on stanza %u in source list %s"), (*I).c_str(),i,Fd.Name().c_str());
+ return -1;
+ }
+
+ if (!Parse->ParseStanza(SrcList, Tags, i, Fd))
+ return -1;
+
+ i++;
+ }
+ }
+
+ // we are done, return the number of stanzas read
+ return i;
+}
+ /*}}}*/
// SourceList::FindIndex - Get the index associated with a file /*{{{*/
// ---------------------------------------------------------------------
/* */
diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h
index 02e27101a..9df0c1d74 100644
--- a/apt-pkg/sourcelist.h
+++ b/apt-pkg/sourcelist.h
@@ -27,17 +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>
#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;
@@ -54,12 +64,16 @@ 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;
bool FixupURI(std::string &URI) const;
+ virtual bool ParseStanza(std::vector<metaIndex *> &List,
+ pkgTagSection &Tags,
+ int stanza_n,
+ FileFd &Fd);
virtual bool ParseLine(std::vector<metaIndex *> &List,
const char *Buffer,
unsigned long const &CurLine,std::string const &File) const;
@@ -75,7 +89,10 @@ class pkgSourceList
protected:
std::vector<metaIndex *> SrcList;
-
+
+ int ParseFileDeb822(std::string File);
+ bool ParseFileOldStyle(std::string File);
+
public:
bool ReadMainList();
diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc
index 297559957..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>
/*}}}*/
@@ -70,8 +75,9 @@ bool pkgSrcRecords::Restart()
Current = Files.begin();
for (std::vector<Parser*>::iterator I = Files.begin();
I != Files.end(); ++I)
- (*I)->Restart();
-
+ if ((*I)->Offset() != 0)
+ (*I)->Restart();
+
return true;
}
/*}}}*/
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 bef3c76ba..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;
}
@@ -207,7 +209,11 @@ bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long long Offset)
unsigned long long Dist = Offset - d->iOffset;
d->Start += Dist;
d->iOffset += Dist;
- return Step(Tag);
+ // if we have seen the end, don't ask for more
+ if (d->Done == true)
+ return Tag.Scan(d->Start, d->End - d->Start);
+ else
+ return Step(Tag);
}
// Reposition and reload..
@@ -467,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)))
@@ -567,52 +573,54 @@ bool TFRewrite(FILE *Output,pkgTagSection const &Tags,const char *Order[],
}
// Write all all of the tags, in order.
- for (unsigned int I = 0; Order[I] != 0; I++)
+ if (Order != NULL)
{
- bool Rewritten = false;
-
- // See if this is a field that needs to be rewritten
- for (unsigned int J = 0; Rewrite != 0 && Rewrite[J].Tag != 0; J++)
+ for (unsigned int I = 0; Order[I] != 0; I++)
{
- if (strcasecmp(Rewrite[J].Tag,Order[I]) == 0)
- {
- Visited[J] |= 2;
- if (Rewrite[J].Rewrite != 0 && Rewrite[J].Rewrite[0] != 0)
- {
- if (isspace(Rewrite[J].Rewrite[0]))
- fprintf(Output,"%s:%s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
- else
- fprintf(Output,"%s: %s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
- }
-
- Rewritten = true;
- break;
- }
- }
+ bool Rewritten = false;
+
+ // See if this is a field that needs to be rewritten
+ for (unsigned int J = 0; Rewrite != 0 && Rewrite[J].Tag != 0; J++)
+ {
+ if (strcasecmp(Rewrite[J].Tag,Order[I]) == 0)
+ {
+ Visited[J] |= 2;
+ if (Rewrite[J].Rewrite != 0 && Rewrite[J].Rewrite[0] != 0)
+ {
+ if (isspace(Rewrite[J].Rewrite[0]))
+ fprintf(Output,"%s:%s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
+ else
+ fprintf(Output,"%s: %s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite);
+ }
+ Rewritten = true;
+ break;
+ }
+ }
- // See if it is in the fragment
- unsigned Pos;
- if (Tags.Find(Order[I],Pos) == false)
- continue;
- Visited[Pos] |= 1;
-
- if (Rewritten == true)
- continue;
+ // See if it is in the fragment
+ unsigned Pos;
+ if (Tags.Find(Order[I],Pos) == false)
+ continue;
+ Visited[Pos] |= 1;
+
+ if (Rewritten == true)
+ continue;
- /* Write out this element, taking a moment to rewrite the tag
- in case of changes of case. */
- const char *Start;
- const char *Stop;
- Tags.Get(Start,Stop,Pos);
+ /* Write out this element, taking a moment to rewrite the tag
+ in case of changes of case. */
+ const char *Start;
+ const char *Stop;
+ Tags.Get(Start,Stop,Pos);
- if (fputs(Order[I],Output) < 0)
- return _error->Errno("fputs","IO Error to output");
- Start += strlen(Order[I]);
- if (fwrite(Start,Stop - Start,1,Output) != 1)
- return _error->Errno("fwrite","IO Error to output");
- if (Stop[-1] != '\n')
- fprintf(Output,"\n");
- }
+ if (fputs(Order[I],Output) < 0)
+ return _error->Errno("fputs","IO Error to output");
+ Start += strlen(Order[I]);
+ if (fwrite(Start,Stop - Start,1,Output) != 1)
+ return _error->Errno("fwrite","IO Error to output");
+ if (Stop[-1] != '\n')
+ fprintf(Output,"\n");
+ }
+ }
// Now write all the old tags that were missed.
for (unsigned int I = 0; I != Tags.Count(); I++)
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 f06f6d40d..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>
/*}}}*/
@@ -225,7 +218,7 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache)
Cache.MarkInstall(I, false, 0, false);
else
{
- // If keep didnt actually do anything then there was no change..
+ // If keep didn't actually do anything then there was no change..
if (Cache[I].Upgrade() == false)
Change = true;
}
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);
};