summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc304
-rw-r--r--apt-pkg/acquire-item.h40
-rw-r--r--apt-pkg/acquire-method.cc12
-rw-r--r--apt-pkg/acquire-worker.cc18
-rw-r--r--apt-pkg/acquire-worker.h2
-rw-r--r--apt-pkg/acquire.cc113
-rw-r--r--apt-pkg/acquire.h47
-rw-r--r--apt-pkg/algorithms.cc33
-rw-r--r--apt-pkg/algorithms.h6
-rw-r--r--apt-pkg/aptconfiguration.cc12
-rw-r--r--apt-pkg/aptconfiguration.h2
-rw-r--r--apt-pkg/cachefile.cc22
-rw-r--r--apt-pkg/cachefile.h1
-rw-r--r--apt-pkg/cachefilter.cc7
-rw-r--r--apt-pkg/cachefilter.h1
-rw-r--r--apt-pkg/cacheiterators.h10
-rw-r--r--apt-pkg/cacheset.cc19
-rw-r--r--apt-pkg/cacheset.h13
-rw-r--r--apt-pkg/cdrom.cc27
-rw-r--r--apt-pkg/cdrom.h4
-rw-r--r--apt-pkg/clean.cc67
-rw-r--r--apt-pkg/clean.h14
-rw-r--r--apt-pkg/contrib/cdromutl.cc60
-rw-r--r--apt-pkg/contrib/cmndline.cc6
-rw-r--r--apt-pkg/contrib/configuration.cc10
-rw-r--r--apt-pkg/contrib/configuration.h2
-rw-r--r--apt-pkg/contrib/error.cc35
-rw-r--r--apt-pkg/contrib/error.h2
-rw-r--r--apt-pkg/contrib/fileutl.cc73
-rw-r--r--apt-pkg/contrib/fileutl.h5
-rw-r--r--apt-pkg/contrib/gpgv.cc18
-rw-r--r--apt-pkg/contrib/hashes.cc18
-rw-r--r--apt-pkg/contrib/hashes.h3
-rw-r--r--apt-pkg/contrib/hashsum.cc2
-rw-r--r--apt-pkg/contrib/hashsum_template.h3
-rw-r--r--apt-pkg/contrib/macros.h2
-rw-r--r--apt-pkg/contrib/md5.h4
-rw-r--r--apt-pkg/contrib/mmap.cc8
-rw-r--r--apt-pkg/contrib/mmap.h1
-rw-r--r--apt-pkg/contrib/netrc.cc4
-rw-r--r--apt-pkg/contrib/progress.cc10
-rw-r--r--apt-pkg/contrib/progress.h3
-rw-r--r--apt-pkg/contrib/proxy.cc31
-rw-r--r--apt-pkg/contrib/sha1.h4
-rw-r--r--apt-pkg/contrib/sha2.h4
-rw-r--r--apt-pkg/contrib/sha2_internal.cc8
-rw-r--r--apt-pkg/contrib/sha2_internal.h2
-rw-r--r--apt-pkg/contrib/srvrec.cc4
-rw-r--r--apt-pkg/contrib/srvrec.h4
-rw-r--r--apt-pkg/contrib/string_view.h4
-rw-r--r--apt-pkg/contrib/strutl.cc22
-rw-r--r--apt-pkg/contrib/strutl.h7
-rw-r--r--apt-pkg/deb/debindexfile.cc42
-rw-r--r--apt-pkg/deb/debindexfile.h1
-rw-r--r--apt-pkg/deb/deblistparser.cc24
-rw-r--r--apt-pkg/deb/deblistparser.h6
-rw-r--r--apt-pkg/deb/debmetaindex.cc61
-rw-r--r--apt-pkg/deb/debmetaindex.h3
-rw-r--r--apt-pkg/deb/debrecords.cc11
-rw-r--r--apt-pkg/deb/debrecords.h4
-rw-r--r--apt-pkg/deb/debsrcrecords.cc14
-rw-r--r--apt-pkg/deb/debsrcrecords.h4
-rw-r--r--apt-pkg/deb/debsystem.cc17
-rw-r--r--apt-pkg/deb/debsystem.h3
-rw-r--r--apt-pkg/deb/debversion.cc4
-rw-r--r--apt-pkg/deb/dpkgpm.cc19
-rw-r--r--apt-pkg/deb/dpkgpm.h6
-rw-r--r--apt-pkg/depcache.cc35
-rw-r--r--apt-pkg/depcache.h7
-rw-r--r--apt-pkg/edsp.cc51
-rw-r--r--apt-pkg/edsp.h3
-rw-r--r--apt-pkg/edsp/edspindexfile.cc15
-rw-r--r--apt-pkg/edsp/edsplistparser.cc7
-rw-r--r--apt-pkg/edsp/edsplistparser.h4
-rw-r--r--apt-pkg/edsp/edspsystem.cc3
-rw-r--r--apt-pkg/edsp/edspsystem.h3
-rw-r--r--apt-pkg/indexcopy.cc24
-rw-r--r--apt-pkg/indexfile.cc27
-rw-r--r--apt-pkg/indexfile.h7
-rw-r--r--apt-pkg/init.cc12
-rw-r--r--apt-pkg/install-progress.cc14
-rw-r--r--apt-pkg/install-progress.h4
-rw-r--r--apt-pkg/metaindex.cc47
-rw-r--r--apt-pkg/metaindex.h18
-rw-r--r--apt-pkg/orderlist.cc17
-rw-r--r--apt-pkg/orderlist.h3
-rw-r--r--apt-pkg/packagemanager.cc23
-rw-r--r--apt-pkg/packagemanager.h6
-rw-r--r--apt-pkg/pkgcache.cc26
-rw-r--r--apt-pkg/pkgcache.h18
-rw-r--r--apt-pkg/pkgcachegen.cc25
-rw-r--r--apt-pkg/pkgcachegen.h5
-rw-r--r--apt-pkg/pkgrecords.cc9
-rw-r--r--apt-pkg/pkgrecords.h2
-rw-r--r--apt-pkg/pkgsystem.cc6
-rw-r--r--apt-pkg/pkgsystem.h1
-rw-r--r--apt-pkg/policy.cc31
-rw-r--r--apt-pkg/policy.h3
-rw-r--r--apt-pkg/prettyprinters.h2
-rw-r--r--apt-pkg/sourcelist.cc27
-rw-r--r--apt-pkg/sourcelist.h5
-rw-r--r--apt-pkg/srcrecords.cc10
-rw-r--r--apt-pkg/srcrecords.h2
-rw-r--r--apt-pkg/statechanges.cc4
-rw-r--r--apt-pkg/statechanges.h2
-rw-r--r--apt-pkg/tagfile-compat.cc2
-rw-r--r--apt-pkg/tagfile.cc10
-rw-r--r--apt-pkg/tagfile.h4
-rw-r--r--apt-pkg/update.cc2
-rw-r--r--apt-pkg/upgrade.cc5
-rw-r--r--apt-pkg/upgrade.h2
-rw-r--r--apt-pkg/version.cc4
-rw-r--r--apt-pkg/versionmatch.cc15
-rw-r--r--apt-pkg/versionmatch.h1
114 files changed, 1063 insertions, 842 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index a7386da71..53dc08160 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -16,55 +16,42 @@
#include <config.h>
#include <apt-pkg/acquire-item.h>
-#include <apt-pkg/configuration.h>
+#include <apt-pkg/acquire.h>
#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/tagfile.h>
-#include <apt-pkg/metaindex.h>
-#include <apt-pkg/acquire.h>
+#include <apt-pkg/gpgv.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/indexfile.h>
+#include <apt-pkg/metaindex.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/gpgv.h>
+#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/tagfile.h>
#include <algorithm>
+#include <ctime>
+#include <iostream>
+#include <numeric>
+#include <random>
+#include <sstream>
+#include <string>
+#include <vector>
+#include <errno.h>
#include <stddef.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <iostream>
-#include <vector>
#include <sys/stat.h>
#include <unistd.h>
-#include <errno.h>
-#include <string>
-#include <stdio.h>
-#include <ctime>
-#include <sstream>
-#include <numeric>
-#include <random>
#include <apti18n.h>
/*}}}*/
using namespace std;
-static void printHashSumComparison(std::string const &URI, HashStringList const &Expected, HashStringList const &Actual) /*{{{*/
-{
- if (_config->FindB("Debug::Acquire::HashSumMismatch", false) == false)
- return;
- std::cerr << std::endl << URI << ":" << std::endl << " Expected Hash: " << std::endl;
- for (HashStringList::const_iterator hs = Expected.begin(); hs != Expected.end(); ++hs)
- std::cerr << "\t- " << hs->toStr() << std::endl;
- std::cerr << " Actual Hash: " << std::endl;
- for (HashStringList::const_iterator hs = Actual.begin(); hs != Actual.end(); ++hs)
- std::cerr << "\t- " << hs->toStr() << std::endl;
-}
- /*}}}*/
static std::string GetPartialFileName(std::string const &file) /*{{{*/
{
std::string DestFile = _config->FindDir("Dir::State::lists") + "partial/";
@@ -1114,11 +1101,13 @@ void pkgAcqMetaBase::AbortTransaction()
case TransactionCommit: _error->Fatal("Transaction %s was already aborted and is now committed", TransactionManager->Target.URI.c_str()); return;
}
TransactionManager->State = TransactionAbort;
+ TransactionManager->ExpectedAdditionalItems = 0;
// ensure the toplevel is in error state too
for (std::vector<pkgAcqTransactionItem*>::iterator I = Transaction.begin();
I != Transaction.end(); ++I)
{
+ (*I)->ExpectedAdditionalItems = 0;
if ((*I)->Status != pkgAcquire::Item::StatFetching)
Owner->Dequeue(*I);
(*I)->TransactionState(TransactionAbort);
@@ -1411,6 +1400,16 @@ void pkgAcqMetaClearSig::QueueIndexes(bool const verify) /*{{{*/
{
if (TransactionManager->MetaIndexParser->Exists(Target.MetaKey) == false)
{
+ auto const component = Target.Option(IndexTarget::COMPONENT);
+ if (component.empty() == false && TransactionManager->MetaIndexParser->HasSupportForComponent(component) == false)
+ {
+ new CleanupItem(Owner, TransactionManager, Target);
+ _error->Warning(_("Skipping acquire of configured file '%s' as repository '%s' doesn't have the component '%s' (component misspelt in sources.list?)"),
+ Target.MetaKey.c_str(), TransactionManager->Target.Description.c_str(), component.c_str());
+ continue;
+
+ }
+
// optional targets that we do not have in the Release file are skipped
if (hasHashes == true && Target.IsOptional)
{
@@ -1440,9 +1439,10 @@ void pkgAcqMetaClearSig::QueueIndexes(bool const verify) /*{{{*/
if (hasHashes == true)
{
- Status = StatAuthError;
- strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), Target.MetaKey.c_str());
- return;
+ new CleanupItem(Owner, TransactionManager, Target);
+ _error->Warning(_("Skipping acquire of configured file '%s' as repository '%s' does not seem to provide it (sources.list entry misspelt?)"),
+ Target.MetaKey.c_str(), TransactionManager->Target.Description.c_str());
+ continue;
}
else
{
@@ -1606,13 +1606,79 @@ bool pkgAcqMetaBase::VerifyVendor(string const &) /*{{{*/
if (TransactionManager->MetaIndexParser->CheckDist(ExpectedDist) == false)
_error->Warning(_("Conflicting distribution: %s (expected %s but got %s)"),
Desc.Description.c_str(), ExpectedDist.c_str(), NowCodename.c_str());
- // might be okay, might be not
+
+ // changed info potentially breaks user config like pinning
if (TransactionManager->LastMetaIndexParser != nullptr)
{
- auto const LastCodename = TransactionManager->LastMetaIndexParser->GetCodename();
- if (LastCodename.empty() == false && NowCodename.empty() == false && LastCodename != NowCodename)
- _error->Warning(_("Conflicting distribution: %s (expected %s but got %s)"),
- Desc.Description.c_str(), LastCodename.c_str(), NowCodename.c_str());
+ std::vector<pkgAcquireStatus::ReleaseInfoChange> Changes;
+ auto const AllowInfoChange = _config->FindB("Acquire::AllowReleaseInfoChange", false);
+ auto const quietInfoChange = _config->FindB("quiet::ReleaseInfoChange", false);
+ struct {
+ char const * const Type;
+ bool const Allowed;
+ decltype(&metaIndex::GetOrigin) const Getter;
+ } checkers[] = {
+ { "Origin", AllowInfoChange, &metaIndex::GetOrigin },
+ { "Label", AllowInfoChange, &metaIndex::GetLabel },
+ { "Version", true, &metaIndex::GetVersion }, // numbers change all the time, that is okay
+ { "Suite", AllowInfoChange, &metaIndex::GetSuite },
+ { "Codename", AllowInfoChange, &metaIndex::GetCodename },
+ { nullptr, false, nullptr }
+ };
+ auto const CheckReleaseInfo = [&](char const * const Type, bool const AllowChange, decltype(checkers[0].Getter) const Getter) {
+ std::string const Last = (TransactionManager->LastMetaIndexParser->*Getter)();
+ std::string const Now = (TransactionManager->MetaIndexParser->*Getter)();
+ if (Last == Now)
+ return;
+ auto const Allow = _config->FindB(std::string("Acquire::AllowReleaseInfoChange::").append(Type), AllowChange);
+ if (Allow == true && _config->FindB(std::string("quiet::ReleaseInfoChange::").append(Type), quietInfoChange) == true)
+ return;
+ std::string msg;
+ strprintf(msg, _("Repository '%s' changed its '%s' value from '%s' to '%s'"),
+ Desc.Description.c_str(), Type, Last.c_str(), Now.c_str());
+ Changes.push_back({Type, std::move(Last), std::move(Now), std::move(msg), Allow});
+ };
+ for (short i = 0; checkers[i].Type != nullptr; ++i)
+ CheckReleaseInfo(checkers[i].Type, checkers[i].Allowed, checkers[i].Getter);
+
+ {
+ auto const Last = TransactionManager->LastMetaIndexParser->GetDefaultPin();
+ auto const Now = TransactionManager->MetaIndexParser->GetDefaultPin();
+ if (Last != Now)
+ {
+ auto const Allow = _config->FindB("Acquire::AllowReleaseInfoChange::DefaultPin", AllowInfoChange);
+ if (Allow == false || _config->FindB("quiet::ReleaseInfoChange::DefaultPin", quietInfoChange) == false)
+ {
+ std::string msg;
+ strprintf(msg, _("Repository '%s' changed its default priority for %s from %hi to %hi."),
+ Desc.Description.c_str(), "apt_preferences(5)", Last, Now);
+ Changes.push_back({"DefaultPin", std::to_string(Last), std::to_string(Now), std::move(msg), Allow});
+ }
+ }
+ }
+ if (Changes.empty() == false)
+ {
+ auto const notes = TransactionManager->MetaIndexParser->GetReleaseNotes();
+ if (notes.empty() == false)
+ {
+ std::string msg;
+ // TRANSLATOR: the "this" refers to changes in the repository like a new release or owner change
+ strprintf(msg, _("More information about this can be found online in the Release notes at: %s"), notes.c_str());
+ Changes.push_back({"Release-Notes", "", std::move(notes), std::move(msg), true});
+ }
+ if (std::any_of(Changes.begin(),Changes.end(),[](pkgAcquireStatus::ReleaseInfoChange const &c) { return c.DefaultAction == false; }))
+ {
+ std::string msg;
+ // TRANSLATOR: %s is the name of the manpage in question, e.g. apt-secure(8)
+ strprintf(msg, _("This must be accepted explicitly before updates for "
+ "this repository can be applied. See %s manpage for details."), "apt-secure(8)");
+ Changes.push_back({"Confirmation", "", "", std::move(msg), true});
+ }
+
+ }
+ if (Owner->Log == nullptr)
+ return pkgAcquireStatus::ReleaseInfoChangesAsGlobalErrors(std::move(Changes));
+ return Owner->Log->ReleaseInfoChanges(TransactionManager->LastMetaIndexParser, TransactionManager->MetaIndexParser, std::move(Changes));
}
return true;
}
@@ -1664,7 +1730,8 @@ void pkgAcqMetaClearSig::Finished() /*{{{*/
bool pkgAcqMetaClearSig::VerifyDone(std::string const &Message, /*{{{*/
pkgAcquire::MethodConfig const * const Cnf)
{
- Item::VerifyDone(Message, Cnf);
+ if (Item::VerifyDone(Message, Cnf) == false)
+ return false;
if (FileExists(DestFile) && !StartsWithGPGClearTextSignature(DestFile))
return RenameOnError(NotClearsigned);
@@ -1717,7 +1784,11 @@ void pkgAcqMetaClearSig::Failed(string const &Message,pkgAcquire::MethodConfig c
if (AuthPass == false)
{
- if (Status == StatAuthError || Status == StatTransientNetworkError)
+ auto const failreason = LookupTag(Message, "FailReason");
+ auto const httperror = "HttpError";
+ if (Status == StatAuthError || Status == StatTransientNetworkError ||
+ (strncmp(failreason.c_str(), httperror, strlen(httperror)) == 0 &&
+ failreason != "HttpError404"))
{
// if we expected a ClearTextSignature (InRelease) but got a network
// error or got a file, but it wasn't valid, we end up here (see VerifyDone).
@@ -2040,13 +2111,11 @@ void pkgAcqDiffIndex::QueueOnIMSHit() const /*{{{*/
new pkgAcqIndexDiffs(Owner, TransactionManager, Target, UsedMirror, Target.URI);
}
/*}}}*/
-static bool RemoveFileForBootstrapLinking(bool const Debug, std::string const &For, std::string const &Boot)/*{{{*/
+static bool RemoveFileForBootstrapLinking(std::string &ErrorText, std::string const &For, std::string const &Boot)/*{{{*/
{
if (FileExists(Boot) && RemoveFile("Bootstrap-linking", Boot) == false)
{
- if (Debug)
- std::clog << "Bootstrap-linking for patching " << For
- << " by removing stale " << Boot << " failed!" << std::endl;
+ strprintf(ErrorText, "Bootstrap for patching %s by removing stale %s failed!", For.c_str(), Boot.c_str());
return false;
}
return true;
@@ -2054,6 +2123,7 @@ static bool RemoveFileForBootstrapLinking(bool const Debug, std::string const &F
/*}}}*/
bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
{
+ available_patches.clear();
ExpectedAdditionalItems = 0;
// failing here is fine: our caller will take care of trying to
// get the complete file if patching fails
@@ -2097,8 +2167,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
if (ServerHashes.usable() == false)
{
- if (Debug == true)
- std::clog << "pkgAcqDiffIndex: " << IndexDiffFile << ": Did not find a good hashsum in the index" << std::endl;
+ ErrorText = "Did not find a good hashsum in the index";
return false;
}
@@ -2106,11 +2175,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
HashStringList const TargetFileHashes = GetExpectedHashesFor(Target.MetaKey);
if (TargetFileHashes.usable() == false || ServerHashes != TargetFileHashes)
{
- if (Debug == true)
- {
- std::clog << "pkgAcqDiffIndex: " << IndexDiffFile << ": Index has different hashes than parser, probably older, so fail pdiffing" << std::endl;
- printHashSumComparison(CurrentPackagesFile, ServerHashes, TargetFileHashes);
- }
+ ErrorText = "Index has different hashes than parser (probably older)";
return false;
}
@@ -2128,10 +2193,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
if (ServerHashes == LocalHashes)
{
- // we have the same sha1 as the server so we are done here
- if(Debug)
- std::clog << "pkgAcqDiffIndex: Package file " << CurrentPackagesFile << " is up-to-date" << std::endl;
- QueueOnIMSHit();
+ available_patches.clear();
return true;
}
@@ -2148,7 +2210,6 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
types.push_back(*type);
// parse all of (provided) history
- vector<DiffInfo> available_patches;
bool firstAcceptedHashes = true;
for (auto type = types.crbegin(); type != types.crend(); ++type)
{
@@ -2203,9 +2264,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
if (unlikely(available_patches.empty() == true))
{
- if (Debug)
- std::clog << "pkgAcqDiffIndex: " << IndexDiffFile << ": "
- << "Couldn't find any patches for the patch series." << std::endl;
+ ErrorText = "Couldn't find any patches for the patch series";
return false;
}
@@ -2307,9 +2366,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
if (foundStart == false || unlikely(available_patches.empty() == true))
{
- if (Debug)
- std::clog << "pkgAcqDiffIndex: " << IndexDiffFile << ": "
- << "Couldn't find the start of the patch series." << std::endl;
+ ErrorText = "Couldn't find the start of the patch series";
return false;
}
@@ -2318,9 +2375,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
patch.patch_hashes.usable() == false ||
patch.download_hashes.usable() == false)
{
- if (Debug)
- std::clog << "pkgAcqDiffIndex: " << IndexDiffFile << ": provides no usable hashes for " << patch.file
- << " so fallback to complete download" << std::endl;
+ strprintf(ErrorText, "Provides no usable hashes for %s", patch.file.c_str());
return false;
}
@@ -2328,9 +2383,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
unsigned long const fileLimit = _config->FindI("Acquire::PDiffs::FileLimit", 0);
if (fileLimit != 0 && fileLimit < available_patches.size())
{
- if (Debug)
- std::clog << "Need " << available_patches.size() << " diffs (Limit is " << fileLimit
- << ") so fallback to complete download" << std::endl;
+ strprintf(ErrorText, "Need %lu diffs, but limit is %lu", available_patches.size(), fileLimit);
return false;
}
@@ -2360,25 +2413,18 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
unsigned long long const sizeLimit = downloadSizeIdx * sizeLimitPercent;
if ((sizeLimit/100) < downloadSize)
{
- if (Debug)
- std::clog << "Need " << downloadSize << " compressed bytes (Limit is " << (sizeLimit/100) << ", "
- << "original is " << downloadSizeIdx << ") so fallback to complete download" << std::endl;
+ strprintf(ErrorText, "Need %llu compressed bytes, but limit is %llu and original is %llu", downloadSize, (sizeLimit/100), downloadSizeIdx);
return false;
}
}
}
- // we have something, queue the diffs
- string::size_type const last_space = Description.rfind(" ");
- if(last_space != string::npos)
- Description.erase(last_space, Description.size()-last_space);
-
/* 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);
+ pdiff_merge = _config->FindB("Acquire::PDiffs::Merge", true);
if (pdiff_merge == true)
{
// reprepro adds this flag if it has merged patches on the server
@@ -2393,53 +2439,24 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
return false;
std::string const PartialFile = GetPartialFileNameFromURI(Target.URI);
std::string const PatchedFile = GetKeepCompressedFileName(PartialFile + "-patched", Target);
- if (RemoveFileForBootstrapLinking(Debug, CurrentPackagesFile, PartialFile) == false ||
- RemoveFileForBootstrapLinking(Debug, CurrentPackagesFile, PatchedFile) == false)
+ if (RemoveFileForBootstrapLinking(ErrorText, CurrentPackagesFile, PartialFile) == false ||
+ RemoveFileForBootstrapLinking(ErrorText, CurrentPackagesFile, PatchedFile) == false)
return false;
for (auto const &ext : APT::Configuration::getCompressorExtensions())
{
- if (RemoveFileForBootstrapLinking(Debug, CurrentPackagesFile, PartialFile + ext) == false ||
- RemoveFileForBootstrapLinking(Debug, CurrentPackagesFile, PatchedFile + ext) == false)
+ if (RemoveFileForBootstrapLinking(ErrorText, CurrentPackagesFile, PartialFile + ext) == false ||
+ RemoveFileForBootstrapLinking(ErrorText, CurrentPackagesFile, PatchedFile + ext) == false)
return false;
}
std::string const Ext = Final.substr(CurrentPackagesFile.length());
std::string const Partial = PartialFile + Ext;
if (symlink(Final.c_str(), Partial.c_str()) != 0)
{
- if (Debug)
- std::clog << "Bootstrap-linking for patching " << CurrentPackagesFile
- << " by linking " << Final << " to " << Partial << " failed!" << std::endl;
+ strprintf(ErrorText, "Bootstrap for patching by linking %s to %s failed!", Final.c_str(), Partial.c_str());
return false;
}
}
- std::string indexURI = Desc.URI;
- auto const byhashidx = indexURI.find("/by-hash/");
- if (byhashidx != std::string::npos)
- indexURI = indexURI.substr(0, byhashidx - strlen(".diff"));
- else
- {
- auto end = indexURI.length() - strlen(".diff/Index");
- if (CurrentCompressionExtension != "uncompressed")
- end -= (1 + CurrentCompressionExtension.length());
- indexURI = indexURI.substr(0, end);
- }
-
- if (pdiff_merge == false)
- new pkgAcqIndexDiffs(Owner, TransactionManager, Target, UsedMirror, indexURI, available_patches);
- else
- {
- diffs = new std::vector<pkgAcqIndexMergeDiffs*>(available_patches.size());
- for(size_t i = 0; i < available_patches.size(); ++i)
- (*diffs)[i] = new pkgAcqIndexMergeDiffs(Owner, TransactionManager,
- Target, UsedMirror, indexURI,
- available_patches[i],
- diffs);
- }
-
- Complete = false;
- Status = StatDone;
- Dequeue();
return true;
}
/*}}}*/
@@ -2451,6 +2468,10 @@ void pkgAcqDiffIndex::Failed(string const &Message,pkgAcquire::MethodConfig cons
Status = StatDone;
ExpectedAdditionalItems = 0;
+ // queue for final move - this should happen even if we fail
+ // while parsing (e.g. on sizelimit) and download the complete file.
+ TransactionManager->TransactionStageCopy(this, DestFile, GetFinalFilename());
+
if(Debug)
std::clog << "pkgAcqDiffIndex failed: " << Desc.URI << " with " << Message << std::endl
<< "Falling back to normal index file acquire" << std::endl;
@@ -2458,6 +2479,21 @@ void pkgAcqDiffIndex::Failed(string const &Message,pkgAcquire::MethodConfig cons
new pkgAcqIndex(Owner, TransactionManager, Target);
}
/*}}}*/
+bool pkgAcqDiffIndex::VerifyDone(std::string const &Message, pkgAcquire::MethodConfig const * const)/*{{{*/
+{
+ string const FinalFile = GetFinalFilename();
+ if(StringToBool(LookupTag(Message,"IMS-Hit"),false))
+ DestFile = FinalFile;
+
+ if (ParseDiffIndex(DestFile))
+ return true;
+
+ Status = StatError;
+ if (ErrorText.empty())
+ ErrorText = "Couldn't parse pdiff index";
+ return false;
+}
+ /*}}}*/
void pkgAcqDiffIndex::Done(string const &Message,HashStringList const &Hashes, /*{{{*/
pkgAcquire::MethodConfig const * const Cnf)
{
@@ -2466,20 +2502,46 @@ void pkgAcqDiffIndex::Done(string const &Message,HashStringList const &Hashes, /
Item::Done(Message, Hashes, Cnf);
- string const FinalFile = GetFinalFilename();
- if(StringToBool(LookupTag(Message,"IMS-Hit"),false))
- DestFile = FinalFile;
-
- if(ParseDiffIndex(DestFile) == false)
+ if (available_patches.empty())
{
- Failed("Message: Couldn't parse pdiff index", Cnf);
- // queue for final move - this should happen even if we fail
- // while parsing (e.g. on sizelimit) and download the complete file.
- TransactionManager->TransactionStageCopy(this, DestFile, FinalFile);
- return;
+ // we have the same sha1 as the server so we are done here
+ if(Debug)
+ std::clog << "pkgAcqDiffIndex: Package file is up-to-date" << std::endl;
+ QueueOnIMSHit();
+ }
+ else
+ {
+ // we have something, queue the diffs
+ string::size_type const last_space = Description.rfind(" ");
+ if(last_space != string::npos)
+ Description.erase(last_space, Description.size()-last_space);
+
+ std::string indexURI = Desc.URI;
+ auto const byhashidx = indexURI.find("/by-hash/");
+ if (byhashidx != std::string::npos)
+ indexURI = indexURI.substr(0, byhashidx - strlen(".diff"));
+ else
+ {
+ auto end = indexURI.length() - strlen(".diff/Index");
+ if (CurrentCompressionExtension != "uncompressed")
+ end -= (1 + CurrentCompressionExtension.length());
+ indexURI = indexURI.substr(0, end);
+ }
+
+ if (pdiff_merge == false)
+ new pkgAcqIndexDiffs(Owner, TransactionManager, Target, UsedMirror, indexURI, available_patches);
+ else
+ {
+ diffs = new std::vector<pkgAcqIndexMergeDiffs*>(available_patches.size());
+ for(size_t i = 0; i < available_patches.size(); ++i)
+ (*diffs)[i] = new pkgAcqIndexMergeDiffs(Owner, TransactionManager,
+ Target, UsedMirror, indexURI,
+ available_patches[i],
+ diffs);
+ }
}
- TransactionManager->TransactionStageCopy(this, DestFile, FinalFile);
+ TransactionManager->TransactionStageCopy(this, DestFile, GetFinalFilename());
Complete = true;
Status = StatDone;
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index 7741dbf22..a5c7d848a 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -20,19 +20,18 @@
#define PKGLIB_ACQUIRE_ITEM_H
#include <apt-pkg/acquire.h>
-#include <apt-pkg/indexfile.h>
#include <apt-pkg/hashes.h>
-#include <apt-pkg/weakptr.h>
+#include <apt-pkg/indexfile.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/weakptr.h>
+#include <map>
#include <string>
#include <vector>
-#include <map>
#ifndef APT_8_CLEANER_HEADERS
-#include <apt-pkg/sourcelist.h>
#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/sourcelist.h>
#endif
/** \addtogroup acquire
@@ -686,6 +685,20 @@ class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex
std::string const &Message, pkgAcquire::MethodConfig const * const Cnf);
};
/*}}}*/
+struct APT_HIDDEN DiffInfo { /*{{{*/
+ /** The filename of the diff. */
+ std::string file;
+
+ /** The hashes of the file after the diff is applied */
+ HashStringList result_hashes;
+
+ /** The hashes of the diff */
+ HashStringList patch_hashes;
+
+ /** The hashes of the compressed diff */
+ HashStringList download_hashes;
+};
+ /*}}}*/
/** \brief An item that is responsible for fetching an index file of {{{
* package list diffs and starting the package list's download.
*
@@ -699,6 +712,8 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqIndex
{
void * const d;
std::vector<pkgAcqIndexMergeDiffs*> * diffs;
+ std::vector<DiffInfo> available_patches;
+ bool pdiff_merge;
protected:
/** \brief If \b true, debugging information will be written to std::clog. */
@@ -718,6 +733,7 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqIndex
public:
// Specialized action members
virtual void Failed(std::string const &Message, pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
+ virtual bool VerifyDone(std::string const &Message, pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
virtual void Done(std::string const &Message, HashStringList const &Hashes,
pkgAcquire::MethodConfig const * const Cnf) APT_OVERRIDE;
virtual std::string DescURI() const APT_OVERRIDE {return Target.URI + "Index";};
@@ -752,20 +768,6 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqIndex
APT_HIDDEN void QueueOnIMSHit() const;
};
/*}}}*/
-struct APT_HIDDEN DiffInfo { /*{{{*/
- /** The filename of the diff. */
- std::string file;
-
- /** The hashes of the file after the diff is applied */
- HashStringList result_hashes;
-
- /** The hashes of the diff */
- HashStringList patch_hashes;
-
- /** The hashes of the compressed diff */
- HashStringList download_hashes;
-};
- /*}}}*/
/** \brief An item that is responsible for fetching client-merge patches {{{
* that need to be applied to a given package index file.
*
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index ab0908014..058ec7945 100644
--- a/apt-pkg/acquire-method.cc
+++ b/apt-pkg/acquire-method.cc
@@ -18,23 +18,23 @@
#include <config.h>
#include <apt-pkg/acquire-method.h>
-#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/strutl.h>
+#include <apt-pkg/error.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 <apt-pkg/strutl.h>
+#include <iostream>
+#include <string>
+#include <vector>
#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <string>
-#include <vector>
-#include <iostream>
-#include <stdio.h>
/*}}}*/
using namespace std;
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index c15e7ab4c..4aa55a743 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -14,27 +14,27 @@
// 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/acquire-worker.h>
+#include <apt-pkg/acquire.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 <apt-pkg/strutl.h>
#include <algorithm>
+#include <iostream>
#include <string>
#include <vector>
-#include <iostream>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <unistd.h>
+#include <sstream>
+#include <errno.h>
#include <signal.h>
#include <stdio.h>
-#include <errno.h>
-#include <sstream>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/acquire-worker.h b/apt-pkg/acquire-worker.h
index 42762abe0..8fc686880 100644
--- a/apt-pkg/acquire-worker.h
+++ b/apt-pkg/acquire-worker.h
@@ -21,9 +21,9 @@
#include <apt-pkg/acquire.h>
#include <apt-pkg/weakptr.h>
-#include <sys/types.h>
#include <string>
#include <vector>
+#include <sys/types.h>
/** \brief A fetch subprocess.
*
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index b62c50c00..05f22f243 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -15,35 +15,35 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/acquire.h>
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/acquire-worker.h>
+#include <apt-pkg/acquire.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/strutl.h>
#include <algorithm>
+#include <iomanip>
+#include <iostream>
+#include <memory>
#include <numeric>
+#include <sstream>
#include <string>
#include <vector>
-#include <iostream>
-#include <sstream>
-#include <iomanip>
-#include <memory>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <grp.h>
+#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <pwd.h>
-#include <grp.h>
-#include <dirent.h>
-#include <sys/time.h>
#include <sys/select.h>
-#include <errno.h>
#include <sys/stat.h>
+#include <sys/time.h>
+#include <unistd.h>
#include <apti18n.h>
/*}}}*/
@@ -770,42 +770,34 @@ bool pkgAcquire::Clean(string Dir)
if(Dir == "/")
return _error->Error(_("Clean of %s is not supported"), Dir.c_str());
- DIR *D = opendir(Dir.c_str());
- if (D == 0)
+ int const dirfd = open(Dir.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC);
+ if (dirfd == -1)
+ return _error->Errno("open",_("Unable to read %s"),Dir.c_str());
+ DIR * const D = fdopendir(dirfd);
+ if (D == nullptr)
return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
-
- string StartDir = SafeGetCWD();
- if (chdir(Dir.c_str()) != 0)
- {
- closedir(D);
- return _error->Errno("chdir",_("Unable to change to %s"),Dir.c_str());
- }
-
- for (struct dirent *Dir = readdir(D); Dir != 0; Dir = readdir(D))
+
+ for (struct dirent *E = readdir(D); E != nullptr; E = readdir(D))
{
- // Skip some files..
- if (strcmp(Dir->d_name,"lock") == 0 ||
- strcmp(Dir->d_name,"partial") == 0 ||
- strcmp(Dir->d_name,"lost+found") == 0 ||
- strcmp(Dir->d_name,".") == 0 ||
- strcmp(Dir->d_name,"..") == 0)
+ // Skip some entries
+ if (strcmp(E->d_name,"lock") == 0 ||
+ strcmp(E->d_name,"partial") == 0 ||
+ strcmp(E->d_name,"lost+found") == 0 ||
+ strcmp(E->d_name,".") == 0 ||
+ strcmp(E->d_name,"..") == 0)
continue;
-
- // Look in the get list
- ItemCIterator I = Items.begin();
- for (; I != Items.end(); ++I)
- if (flNotDir((*I)->DestFile) == Dir->d_name)
- break;
-
- // Nothing found, nuke it
- if (I == Items.end())
- RemoveFile("Clean", Dir->d_name);
- };
-
+
+ // Look in the get list and if not found nuke
+ if (std::any_of(Items.cbegin(), Items.cend(),
+ [&E](pkgAcquire::Item const * const I) {
+ return flNotDir(I->DestFile) == E->d_name;
+ }) == false)
+ {
+ RemoveFileAt("pkgAcquire::Clean", dirfd, E->d_name);
+ }
+ }
closedir(D);
- if (chdir(StartDir.c_str()) != 0)
- return _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str());
- return true;
+ return true;
}
/*}}}*/
// Acquire::TotalNeeded - Number of bytes to fetch /*{{{*/
@@ -1414,10 +1406,39 @@ void pkgAcquireStatus::Stop()
// ---------------------------------------------------------------------
/* This is used to get accurate final transfer rate reporting. */
void pkgAcquireStatus::Fetched(unsigned long long Size,unsigned long long Resume)
-{
+{
FetchedBytes += Size - Resume;
}
/*}}}*/
+bool pkgAcquireStatus::ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector<ReleaseInfoChange> &&Changes)/*{{{*/
+{
+ auto const virt = dynamic_cast<pkgAcquireStatus2*>(this);
+ if (virt != nullptr)
+ return virt->ReleaseInfoChanges(LastRelease, CurrentRelease, std::move(Changes));
+ return ReleaseInfoChangesAsGlobalErrors(std::move(Changes));
+}
+ /*}}}*/
+bool pkgAcquireStatus::ReleaseInfoChangesAsGlobalErrors(std::vector<ReleaseInfoChange> &&Changes)/*{{{*/
+{
+ bool AllOkay = true;
+ for (auto const &c: Changes)
+ if (c.DefaultAction)
+ _error->Notice("%s", c.Message.c_str());
+ else
+ {
+ _error->Error("%s", c.Message.c_str());
+ AllOkay = false;
+ }
+ return AllOkay;
+}
+ /*}}}*/
+bool pkgAcquireStatus2::ReleaseInfoChanges(metaIndex const * const, metaIndex const * const, std::vector<ReleaseInfoChange> &&Changes)
+{
+ return ReleaseInfoChangesAsGlobalErrors(std::move(Changes));
+}
+pkgAcquireStatus2::pkgAcquireStatus2() : pkgAcquireStatus() {}
+pkgAcquireStatus2::~pkgAcquireStatus2() {}
+
pkgAcquire::UriIterator::UriIterator(pkgAcquire::Queue *Q) : d(NULL), CurQ(Q), CurItem(0)
{
diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h
index 5f1212338..e58aeef65 100644
--- a/apt-pkg/acquire.h
+++ b/apt-pkg/acquire.h
@@ -65,16 +65,16 @@
#ifndef PKGLIB_ACQUIRE_H
#define PKGLIB_ACQUIRE_H
+#include <apt-pkg/hashes.h>
#include <apt-pkg/macros.h>
#include <apt-pkg/weakptr.h>
-#include <apt-pkg/hashes.h>
#include <string>
#include <vector>
#include <stddef.h>
-#include <sys/time.h>
#include <sys/select.h>
+#include <sys/time.h>
#ifndef APT_10_CLEANER_HEADERS
#include <unistd.h>
@@ -86,6 +86,7 @@ using std::string;
#endif
class pkgAcquireStatus;
+class metaIndex;
/** \brief The core download scheduler. {{{
*
@@ -794,7 +795,39 @@ class pkgAcquireStatus
* with prejudice.
*/
virtual bool MediaChange(std::string Media,std::string Drive) = 0;
-
+
+ struct ReleaseInfoChange
+ {
+ std::string Type; /*!< Type of the change like "Origin", "Codename", "Version", … */
+ std::string From; /*!< old value */
+ std::string To; /*!< new value */
+ std::string Message; /*!< translated message describing the change */
+ bool DefaultAction; /*!< true if the change is informational, false if it must be explicitly confirmed */
+ };
+ /** \brief ask the user for confirmation of changes to infos about a repository
+ *
+ * This method should present the user with a choice of accepting the change
+ * or not and indicate the user opinion via the return value. If DefaultAction is true
+ * it is acceptable to only notify the user about the change, but to accept the change
+ * automatically on behalf of the user.
+ *
+ * The default implementation will fail if any Change has DefaultAction == false. Regardless of
+ * success it will print for each change the message attached to it via GlobalError either as an
+ * error (if DefaultAction == false) or as a notice otherwise.
+ *
+ * \b Note: To keep ABI compatibility for now this method isn't marked as
+ * virtual, but you can derive your class from #pkgAcquireStatus2 which has it
+ * marked as virtual. TODO on next ABI break: merge both classes.
+ *
+ * @param LastRelease can be used to extract further information from the previous Release file
+ * @param CurrentRelease can be used to extract further information from the current Release file
+ * @param Changes is an array of changes alongside explanatory messages
+ * which should be presented in some way to the user.
+ * @return \b true if all changes are accepted by user, otherwise or if user can't be asked \b false
+ */
+ bool ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector<ReleaseInfoChange> &&Changes);
+ APT_HIDDEN static bool ReleaseInfoChangesAsGlobalErrors(std::vector<ReleaseInfoChange> &&Changes);
+
/** \brief Invoked when an item is confirmed to be up-to-date.
* For instance, when an HTTP download is informed that the file on
@@ -835,6 +868,14 @@ class pkgAcquireStatus
pkgAcquireStatus();
virtual ~pkgAcquireStatus();
};
+class pkgAcquireStatus2: public pkgAcquireStatus
+{
+public:
+ virtual bool ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector<ReleaseInfoChange> &&Changes);
+
+ pkgAcquireStatus2();
+ virtual ~pkgAcquireStatus2();
+};
/*}}}*/
/** @} */
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 95e756c15..643ff8afd 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -17,21 +17,20 @@
#include <config.h>
#include <apt-pkg/algorithms.h>
-#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/edsp.h>
#include <apt-pkg/depcache.h>
+#include <apt-pkg/dpkgpm.h>
+#include <apt-pkg/edsp.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/packagemanager.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/prettyprinters.h>
-#include <apt-pkg/dpkgpm.h>
-#include <string.h>
-#include <string>
#include <cstdlib>
#include <iostream>
+#include <string>
#include <utility>
+#include <string.h>
#include <apti18n.h>
/*}}}*/
@@ -52,12 +51,13 @@ pkgSimulate::pkgSimulate(pkgDepCache *Cache) : pkgPackageManager(Cache),
group(Sim)
{
Sim.Init(0);
- Flags = new unsigned char[Cache->Head().PackageCount];
- memset(Flags,0,sizeof(*Flags)*Cache->Head().PackageCount);
+ auto PackageCount = Cache->Head().PackageCount;
+ Flags = new unsigned char[PackageCount];
+ memset(Flags,0,sizeof(*Flags)*PackageCount);
// Fake a filename so as not to activate the media swapping
string Jnk = "SIMULATE";
- for (unsigned int I = 0; I != Cache->Head().PackageCount; I++)
+ for (decltype(PackageCount) I = 0; I != PackageCount; ++I)
FileNames[I] = Jnk;
}
/*}}}*/
@@ -399,7 +399,7 @@ bool pkgFixBroken(pkgDepCache &Cache)
pkgProblemResolver::pkgProblemResolver(pkgDepCache *pCache) : d(NULL), Cache(*pCache)
{
// Allocate memory
- unsigned long Size = Cache.Head().PackageCount;
+ auto const Size = Cache.Head().PackageCount;
Scores = new int[Size];
Flags = new unsigned char[Size];
memset(Flags,0,sizeof(*Flags)*Size);
@@ -434,7 +434,7 @@ int pkgProblemResolver::ScoreSort(Package const *A,Package const *B)
/* */
void pkgProblemResolver::MakeScores()
{
- unsigned long Size = Cache.Head().PackageCount;
+ auto const Size = Cache.Head().PackageCount;
memset(Scores,0,sizeof(*Scores)*Size);
// maps to pkgCache::State::VerPriority:
@@ -753,7 +753,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
MakeScores();
- unsigned long const Size = Cache.Head().PackageCount;
+ auto const Size = Cache.Head().PackageCount;
/* We have to order the packages so that the broken fixing pass
operates from highest score to lowest. This prevents problems when
@@ -806,7 +806,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
{
if (Debug == true)
clog << " Try to Re-Instate (" << Counter << ") " << I.FullName(false) << endl;
- unsigned long OldBreaks = Cache.BrokenCount();
+ auto const OldBreaks = Cache.BrokenCount();
pkgCache::Version *OldVer = Cache[I].InstallVer;
Flags[I->ID] &= ReInstateTried;
@@ -1006,7 +1006,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
dangerous as it could trigger new breaks/conflicts… */
if (Debug == true)
clog << " Try Installing " << APT::PrettyPkg(&Cache, Start.TargetPkg()) << " before changing " << I.FullName(false) << std::endl;
- unsigned long const OldBroken = Cache.BrokenCount();
+ auto const OldBroken = Cache.BrokenCount();
Cache.MarkInstall(Start.TargetPkg(), true, 1, false);
// FIXME: we should undo the complete MarkInstall process here
if (Cache[Start.TargetPkg()].InstBroken() == true || Cache.BrokenCount() > OldBroken)
@@ -1211,14 +1211,13 @@ bool pkgProblemResolver::ResolveByKeepInternal()
{
pkgDepCache::ActionGroup group(Cache);
- unsigned long Size = Cache.Head().PackageCount;
-
MakeScores();
-
+
/* We have to order the packages so that the broken fixing pass
operates from highest score to lowest. This prevents problems when
high score packages cause the removal of lower score packages that
would cause the removal of even lower score packages. */
+ auto Size = Cache.Head().PackageCount;
pkgCache::Package **PList = new pkgCache::Package *[Size];
pkgCache::Package **PEnd = PList;
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h
index 5148ff19d..c5c9f4c69 100644
--- a/apt-pkg/algorithms.h
+++ b/apt-pkg/algorithms.h
@@ -29,11 +29,9 @@
#ifndef PKGLIB_ALGORITHMS_H
#define PKGLIB_ALGORITHMS_H
-
-#include <apt-pkg/packagemanager.h>
#include <apt-pkg/depcache.h>
+#include <apt-pkg/packagemanager.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <iostream>
#include <string>
@@ -47,8 +45,8 @@ using std::ostream;
#ifndef APT_9_CLEANER_HEADERS
// include pkg{DistUpgrade,AllUpgrade,MiniizeUpgrade} here for compatibility
-#include <apt-pkg/upgrade.h>
#include <apt-pkg/update.h>
+#include <apt-pkg/upgrade.h>
#endif
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index 0035f70df..405472a72 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -15,20 +15,20 @@
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/macros.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/strutl.h>
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <ctype.h>
#include <dirent.h>
-#include <stdio.h>
#include <fcntl.h>
-#include <ctype.h>
#include <stddef.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <algorithm>
-#include <string>
-#include <vector>
/*}}}*/
namespace APT {
diff --git a/apt-pkg/aptconfiguration.h b/apt-pkg/aptconfiguration.h
index fbd9b02e6..6776f96ef 100644
--- a/apt-pkg/aptconfiguration.h
+++ b/apt-pkg/aptconfiguration.h
@@ -11,9 +11,9 @@
#ifndef APT_CONFIGURATION_H
#define APT_CONFIGURATION_H
// Include Files /*{{{*/
+#include <limits>
#include <string>
#include <vector>
-#include <limits>
/*}}}*/
namespace APT {
namespace Configuration { /*{{{*/
diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc
index b5f32fc29..0116308e5 100644
--- a/apt-pkg/cachefile.cc
+++ b/apt-pkg/cachefile.cc
@@ -15,24 +15,24 @@
#include <config.h>
#include <apt-pkg/cachefile.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/pkgcachegen.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/policy.h>
-#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/fileutl.h>
-#include <apt-pkg/progress.h>
#include <apt-pkg/depcache.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/indexfile.h>
#include <apt-pkg/mmap.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/indexfile.h>
+#include <apt-pkg/pkgcachegen.h>
+#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/policy.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/sourcelist.h>
-#include <string.h>
-#include <unistd.h>
+#include <memory>
#include <string>
#include <vector>
-#include <memory>
+#include <string.h>
+#include <unistd.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/cachefile.h b/apt-pkg/cachefile.h
index e23f37675..097876b3a 100644
--- a/apt-pkg/cachefile.h
+++ b/apt-pkg/cachefile.h
@@ -21,7 +21,6 @@
#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>
diff --git a/apt-pkg/cachefilter.cc b/apt-pkg/cachefilter.cc
index cc4cdf73c..4cbe162e9 100644
--- a/apt-pkg/cachefilter.cc
+++ b/apt-pkg/cachefilter.cc
@@ -9,17 +9,16 @@
#include <apt-pkg/cachefile.h>
#include <apt-pkg/cachefilter.h>
#include <apt-pkg/error.h>
+#include <apt-pkg/macros.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/strutl.h>
-#include <apt-pkg/macros.h>
#include <algorithm>
#include <string>
#include <unordered_map>
-#include <string.h>
-#include <regex.h>
#include <fnmatch.h>
+#include <regex.h>
+#include <string.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/cachefilter.h b/apt-pkg/cachefilter.h
index 30a3368e5..8a6c01341 100644
--- a/apt-pkg/cachefilter.h
+++ b/apt-pkg/cachefilter.h
@@ -7,7 +7,6 @@
#define APT_CACHEFILTER_H
// Include Files /*{{{*/
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <string>
#include <vector>
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h
index 62d0ab59c..0cb684382 100644
--- a/apt-pkg/cacheiterators.h
+++ b/apt-pkg/cacheiterators.h
@@ -29,17 +29,19 @@
/*}}}*/
#ifndef PKGLIB_CACHEITERATORS_H
#define PKGLIB_CACHEITERATORS_H
-#include<apt-pkg/pkgcache.h>
-#include<apt-pkg/macros.h>
+#ifndef __PKGLIB_IN_PKGCACHE_H
+#warning apt-pkg/cacheiterators.h should not be included directly, include apt-pkg/pkgcache.h instead
+#endif
+#include <apt-pkg/macros.h>
-#include<iterator>
#include <iosfwd>
+#include <iterator>
#include <string>
#ifdef APT_PKG_EXPOSE_STRING_VIEW
#include <apt-pkg/string_view.h>
#endif
-#include<string.h>
+#include <string.h>
// abstract Iterator template /*{{{*/
/* This template provides the very basic iterator methods we
diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc
index f8ab7acb9..92f707cba 100644
--- a/apt-pkg/cacheset.cc
+++ b/apt-pkg/cacheset.cc
@@ -15,24 +15,23 @@
#include <apt-pkg/cachefile.h>
#include <apt-pkg/cachefilter.h>
#include <apt-pkg/cacheset.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/versionmatch.h>
-#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/policy.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/depcache.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
#include <apt-pkg/macros.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/fileutl.h>
+#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/policy.h>
+#include <apt-pkg/versionmatch.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
-#include <regex.h>
#include <list>
#include <string>
#include <vector>
+#include <regex.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h
index 1ac61af59..157f6139e 100644
--- a/apt-pkg/cacheset.h
+++ b/apt-pkg/cacheset.h
@@ -13,23 +13,22 @@
#include <map>
#include <set>
#if __cplusplus >= 201103L
-#include <unordered_set>
#include <forward_list>
#include <initializer_list>
+#include <unordered_set>
#endif
-#include <list>
+#include <algorithm>
#include <deque>
-#include <vector>
-#include <string>
#include <iterator>
-#include <algorithm>
+#include <list>
+#include <string>
+#include <vector>
#include <stddef.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/cachefile.h>
diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index a3248fc17..2dccc6d12 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -2,31 +2,30 @@
*/
#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/cdrom.h>
+#include <apt-pkg/cdromutl.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/indexcopy.h>
+#include <apt-pkg/strutl.h>
-
-#include <string.h>
+#include <algorithm>
+#include <fstream>
+#include <iostream>
#include <iostream>
+#include <sstream>
#include <string>
#include <vector>
-#include <sys/stat.h>
#include <dirent.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <algorithm>
#include <dlfcn.h>
-#include <iostream>
-#include <sstream>
-#include <fstream>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
-#include<apti18n.h>
+#include <apti18n.h>
using namespace std;
diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h
index ab1e046bf..7425c09c1 100644
--- a/apt-pkg/cdrom.h
+++ b/apt-pkg/cdrom.h
@@ -3,8 +3,8 @@
#include <apt-pkg/macros.h>
-#include<string>
-#include<vector>
+#include <string>
+#include <vector>
#include <stddef.h>
diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc
index fe57c26a2..e9bf73b6c 100644
--- a/apt-pkg/clean.cc
+++ b/apt-pkg/clean.cc
@@ -8,21 +8,22 @@
##################################################################### */
/*}}}*/
// Includes /*{{{*/
-#include<config.h>
+#include <config.h>
+#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/clean.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/strutl.h>
#include <string>
-#include <string.h>
#include <dirent.h>
+#include <fcntl.h>
+#include <string.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#include <apti18n.h>
@@ -43,17 +44,21 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache)
if (FileExists(Dir) == false)
return true;
- DIR *D = opendir(Dir.c_str());
- if (D == 0)
- return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
-
- std::string StartDir = SafeGetCWD();
- if (chdir(Dir.c_str()) != 0)
+ auto const withoutChangingDir = dynamic_cast<pkgArchiveCleaner2*>(this);
+ int const dirfd = open(Dir.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC);
+ if (dirfd == -1)
+ return _error->Errno("open",_("Unable to read %s"),Dir.c_str());
+ std::string CWD;
+ if (withoutChangingDir == nullptr)
{
- closedir(D);
- return _error->Errno("chdir",_("Unable to change to %s"),Dir.c_str());
+ CWD = SafeGetCWD();
+ if (fchdir(dirfd) != 0)
+ return _error->Errno("fchdir",_("Unable to change to %s"),Dir.c_str());
}
-
+ DIR * const D = fdopendir(dirfd);
+ if (D == nullptr)
+ return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
+
for (struct dirent *Dir = readdir(D); Dir != 0; Dir = readdir(D))
{
// Skip some files..
@@ -65,15 +70,13 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache)
continue;
struct stat St;
- if (stat(Dir->d_name,&St) != 0)
+ if (fstatat(dirfd, Dir->d_name,&St, 0) != 0)
{
_error->Errno("stat",_("Unable to stat %s."),Dir->d_name);
closedir(D);
- if (chdir(StartDir.c_str()) != 0)
- return _error->Errno("chdir", _("Unable to change to %s"), StartDir.c_str());
return false;
}
-
+
// Grab the package name
const char *I = Dir->d_name;
for (; *I != 0 && *I != '_';I++);
@@ -87,7 +90,7 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache)
if (*I != '_')
continue;
std::string Ver = DeQuoteString(std::string(Start,I-Start));
-
+
// Grab the arch
Start = I + 1;
for (I = Start; *I != 0 && *I != '.' ;I++);
@@ -98,7 +101,7 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache)
// ignore packages of unconfigured architectures
if (APT::Configuration::checkArchitecture(Arch) == false)
continue;
-
+
// Lookup the package
pkgCache::PkgIterator P = Cache.FindPkg(Pkg, Arch);
if (P.end() != true)
@@ -117,23 +120,29 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache)
IsFetchable = true;
break;
}
-
+
// See if this version matches the file
if (IsFetchable == true && Ver == V.VerStr())
break;
}
-
+
// We found a match, keep the file
if (V.end() == false)
continue;
}
-
- Erase(Dir->d_name,Pkg,Ver,St);
- };
-
+
+ if (withoutChangingDir == nullptr)
+ {
+ APT_IGNORE_DEPRECATED_PUSH
+ Erase(Dir->d_name, Pkg, Ver, St);
+ APT_IGNORE_DEPRECATED_POP
+ }
+ else
+ withoutChangingDir->Erase(dirfd, Dir->d_name, Pkg, Ver, St);
+ }
closedir(D);
- if (chdir(StartDir.c_str()) != 0)
- return _error->Errno("chdir", _("Unable to change to %s"), StartDir.c_str());
+ if (withoutChangingDir == nullptr && chdir(CWD.c_str()) != 0)
+ return _error->Errno("chdir", _("Unable to change to %s"),Dir.c_str());
return true;
}
/*}}}*/
diff --git a/apt-pkg/clean.h b/apt-pkg/clean.h
index 6cedae086..2ba3932a0 100644
--- a/apt-pkg/clean.h
+++ b/apt-pkg/clean.h
@@ -16,6 +16,8 @@
#include <string>
+#include <apt-pkg/macros.h>
+
class pkgCache;
class pkgArchiveCleaner
@@ -25,7 +27,7 @@ class pkgArchiveCleaner
protected:
- virtual void Erase(const char * /*File*/,std::string /*Pkg*/,std::string /*Ver*/,struct stat & /*St*/) {};
+ APT_DEPRECATED_MSG("Use pkgArchiveCleaner2 to avoid CWD expectations and chdir") virtual void Erase(const char * /*File*/,std::string /*Pkg*/,std::string /*Ver*/,struct stat & /*St*/) {};
public:
@@ -34,5 +36,15 @@ class pkgArchiveCleaner
pkgArchiveCleaner();
virtual ~pkgArchiveCleaner();
};
+// TODO: merge classes and "erase" the old way
+class pkgArchiveCleaner2: public pkgArchiveCleaner
+{
+ friend class pkgArchiveCleaner;
+protected:
+ using pkgArchiveCleaner::Erase;
+ virtual void Erase(int const dirfd, char const * const File,
+ std::string const &Pkg,std::string const &Ver,
+ struct stat const &St) = 0;
+};
#endif
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index 428ef0161..93bfb9f42 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -10,26 +10,26 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
#include <apt-pkg/cdromutl.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/md5.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/configuration.h>
+#include <apt-pkg/md5.h>
#include <apt-pkg/strutl.h>
-#include <stdlib.h>
-#include <string.h>
#include <iostream>
#include <string>
#include <vector>
-#include <sys/statvfs.h>
#include <dirent.h>
#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/stat.h>
+#include <sys/statvfs.h>
#include <unistd.h>
-#include <stdio.h>
#include <apti18n.h>
/*}}}*/
@@ -184,26 +184,32 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
MD5Summation Hash;
bool writable_media = false;
+ int dirfd = open(CD.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC);
+ if (dirfd == -1)
+ return _error->Errno("open",_("Unable to read %s"),CD.c_str());
+
// if we are on a writable medium (like a usb-stick) that is just
// used like a cdrom don't use "." as it will constantly change,
// use .disk instead
- if (access(CD.c_str(), W_OK) == 0 && DirectoryExists(CD+string("/.disk")))
+ if (faccessat(dirfd, ".", W_OK, 0) == 0)
{
- writable_media = true;
- CD = CD.append("/.disk");
- if (_config->FindB("Debug::aptcdrom",false) == true)
- std::clog << "Found writable cdrom, using alternative path: " << CD
- << std::endl;
+ int diskfd = openat(dirfd, "./.disk", O_RDONLY | O_DIRECTORY | O_CLOEXEC, 0);
+ if (diskfd != -1)
+ {
+ close(dirfd);
+ dirfd = diskfd;
+ writable_media = true;
+ CD = CD.append("/.disk");
+ if (_config->FindB("Debug::aptcdrom",false) == true)
+ std::clog << "Found writable cdrom, using alternative path: " << CD
+ << std::endl;
+ }
}
- string StartDir = SafeGetCWD();
- if (chdir(CD.c_str()) != 0)
- return _error->Errno("chdir",_("Unable to change to %s"),CD.c_str());
-
- DIR *D = opendir(".");
- if (D == 0)
+ DIR * const D = fdopendir(dirfd);
+ if (D == nullptr)
return _error->Errno("opendir",_("Unable to read %s"),CD.c_str());
-
+
/* Run over the directory, we assume that the reader order will never
change as the media is read-only. In theory if the kernel did
some sort of wacked caching this might not be true.. */
@@ -222,31 +228,24 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
else
{
struct stat Buf;
- if (stat(Dir->d_name,&Buf) != 0)
+ if (fstatat(dirfd, Dir->d_name, &Buf, 0) != 0)
continue;
strprintf(S, "%lu", (unsigned long)Buf.st_mtime);
}
Hash.Add(S.c_str());
Hash.Add(Dir->d_name);
- };
-
- if (chdir(StartDir.c_str()) != 0) {
- _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str());
- closedir(D);
- return false;
}
- closedir(D);
// Some stats from the fsys
std::string S;
if (_config->FindB("Debug::identcdrom",false) == false)
{
struct statvfs Buf;
- if (statvfs(CD.c_str(),&Buf) != 0)
+ if (fstatvfs(dirfd, &Buf) != 0)
return _error->Errno("statfs",_("Failed to stat the cdrom"));
- // We use a kilobyte block size to advoid overflow
+ // We use a kilobyte block size to avoid overflow
if (writable_media)
{
strprintf(S, "%lu", (unsigned long)(Buf.f_blocks*(Buf.f_bsize/1024)));
@@ -260,6 +259,7 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
else
strprintf(S, "-%u.debug", Version);
+ closedir(D);
Res = Hash.Result().Value() + S;
return true;
}
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index 029ec3060..2b8bef2c5 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -11,17 +11,17 @@
##################################################################### */
/*}}}*/
// Include files /*{{{*/
-#include<config.h>
+#include <config.h>
-#include <apt-pkg/configuration.h>
#include <apt-pkg/cmndline.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
+#include <string>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
-#include <string>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 78a98d614..442e31dff 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -19,9 +19,9 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/strutl.h>
#include <ctype.h>
#include <regex.h>
@@ -31,13 +31,13 @@
#include <string.h>
#include <algorithm>
-#include <iterator>
-#include <string>
-#include <stack>
-#include <vector>
#include <fstream>
+#include <iterator>
#include <sstream>
+#include <stack>
+#include <string>
#include <unordered_map>
+#include <vector>
#include <apti18n.h>
diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h
index 97a01e4cf..8d0835cf5 100644
--- a/apt-pkg/contrib/configuration.h
+++ b/apt-pkg/contrib/configuration.h
@@ -30,9 +30,9 @@
#include <regex.h>
+#include <iostream>
#include <string>
#include <vector>
-#include <iostream>
#include <apt-pkg/macros.h>
diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc
index c06ea8364..0233dfd59 100644
--- a/apt-pkg/contrib/error.cc
+++ b/apt-pkg/contrib/error.cc
@@ -17,17 +17,17 @@
#include <apt-pkg/error.h>
-#include <stdarg.h>
-#include <stddef.h>
-#include <list>
+#include <algorithm>
+#include <cstring>
#include <iostream>
+#include <list>
+#include <string>
#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <string>
-#include <cstring>
-#include <algorithm>
/*}}}*/
@@ -37,20 +37,21 @@
Per-Thread error object is maintained in much the same manner as libc
manages errno */
#if defined(_POSIX_THREADS) && defined(HAVE_PTHREAD)
- #include <pthread.h>
+#include <pthread.h>
- static pthread_key_t ErrorKey;
- static void ErrorDestroy(void *Obj) {delete (GlobalError *)Obj;};
- static void KeyAlloc() {pthread_key_create(&ErrorKey,ErrorDestroy);};
+static pthread_key_t ErrorKey;
+static void ErrorDestroy(void *Obj) { delete (GlobalError *)Obj; };
+static void KeyAlloc() { pthread_key_create(&ErrorKey, ErrorDestroy); };
- GlobalError *_GetErrorObj() {
- static pthread_once_t Once = PTHREAD_ONCE_INIT;
- pthread_once(&Once,KeyAlloc);
+GlobalError *_GetErrorObj()
+{
+ static pthread_once_t Once = PTHREAD_ONCE_INIT;
+ pthread_once(&Once, KeyAlloc);
- void *Res = pthread_getspecific(ErrorKey);
- if (Res == 0)
- pthread_setspecific(ErrorKey,Res = new GlobalError);
- return (GlobalError *)Res;
+ void *Res = pthread_getspecific(ErrorKey);
+ if (Res == 0)
+ pthread_setspecific(ErrorKey, Res = new GlobalError);
+ return (GlobalError *)Res;
}
#else
GlobalError *_GetErrorObj() {
diff --git a/apt-pkg/contrib/error.h b/apt-pkg/contrib/error.h
index b01a5fc1b..74b5cd5cf 100644
--- a/apt-pkg/contrib/error.h
+++ b/apt-pkg/contrib/error.h
@@ -46,8 +46,8 @@
#include <list>
#include <string>
-#include <stddef.h>
#include <stdarg.h>
+#include <stddef.h>
class GlobalError /*{{{*/
{
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index e4c40fb4f..630a98ce4 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -19,52 +19,52 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/fileutl.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/sptr.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/sptr.h>
+#include <apt-pkg/strutl.h>
-#include <ctype.h>
-#include <stdarg.h>
-#include <stddef.h>
-#include <sys/select.h>
-#include <time.h>
-#include <string>
-#include <vector>
+#include <cstdio>
#include <cstdlib>
#include <cstring>
-#include <cstdio>
#include <iostream>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/wait.h>
+#include <string>
+#include <vector>
+#include <ctype.h>
#include <dirent.h>
-#include <signal.h>
#include <errno.h>
+#include <fcntl.h>
#include <glob.h>
-#include <pwd.h>
#include <grp.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <sys/select.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
-#include <set>
#include <algorithm>
#include <memory>
+#include <set>
#ifdef HAVE_ZLIB
- #include <zlib.h>
+#include <zlib.h>
#endif
#ifdef HAVE_BZ2
- #include <bzlib.h>
+#include <bzlib.h>
#endif
#ifdef HAVE_LZMA
- #include <lzma.h>
+#include <lzma.h>
#endif
#ifdef HAVE_LZ4
- #include <lz4frame.h>
+#include <lz4frame.h>
#endif
#include <endian.h>
#include <stdint.h>
@@ -178,6 +178,21 @@ bool CopyFile(FileFd &From,FileFd &To)
return true;
}
/*}}}*/
+bool RemoveFileAt(char const * const Function, int const dirfd, std::string const &FileName)/*{{{*/
+{
+ if (FileName == "/dev/null")
+ return true;
+ errno = 0;
+ if (unlinkat(dirfd, FileName.c_str(), 0) != 0)
+ {
+ if (errno == ENOENT)
+ return true;
+
+ return _error->WarningE(Function,_("Problem unlinking the file %s"), FileName.c_str());
+ }
+ return true;
+}
+ /*}}}*/
bool RemoveFile(char const * const Function, std::string const &FileName)/*{{{*/
{
if (FileName == "/dev/null")
@@ -2832,7 +2847,7 @@ std::string GetTempDir(std::string const &User)
FileFd* GetTempFile(std::string const &Prefix, bool ImmediateUnlink, FileFd * const TmpFd) /*{{{*/
{
char fn[512];
- FileFd * const Fd = TmpFd == NULL ? new FileFd() : TmpFd;
+ FileFd * const Fd = TmpFd == nullptr ? new FileFd() : TmpFd;
std::string const tempdir = GetTempDir();
snprintf(fn, sizeof(fn), "%s/%s.XXXXXX",
@@ -2843,12 +2858,16 @@ FileFd* GetTempFile(std::string const &Prefix, bool ImmediateUnlink, FileFd * co
if (fd < 0)
{
_error->Errno("GetTempFile",_("Unable to mkstemp %s"), fn);
- return NULL;
+ if (TmpFd == nullptr)
+ delete Fd;
+ return nullptr;
}
if (!Fd->OpenDescriptor(fd, FileFd::ReadWrite, FileFd::None, true))
{
_error->Errno("GetTempFile",_("Unable to write to %s"),fn);
- return NULL;
+ if (TmpFd == nullptr)
+ delete Fd;
+ return nullptr;
}
return Fd;
}
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index dddeb70f5..5e857b5c8 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -21,12 +21,12 @@
#ifndef PKGLIB_FILEUTL_H
#define PKGLIB_FILEUTL_H
-#include <apt-pkg/macros.h>
#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/macros.h>
+#include <set>
#include <string>
#include <vector>
-#include <set>
#include <time.h>
#include <zlib.h>
@@ -161,6 +161,7 @@ class FileFd
bool RunScripts(const char *Cnf);
bool CopyFile(FileFd &From,FileFd &To);
bool RemoveFile(char const * const Function, std::string const &FileName);
+bool RemoveFileAt(char const * const Function, int const dirfd, std::string const &FileName);
int GetLock(std::string File,bool Errors = true);
bool FileExists(std::string File);
bool RealFileExists(std::string File);
diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc
index cdf9481cb..cc1fbc5aa 100644
--- a/apt-pkg/contrib/gpgv.cc
+++ b/apt-pkg/contrib/gpgv.cc
@@ -1,21 +1,21 @@
// -*- mode: cpp; mode: fold -*-
// Include Files /*{{{*/
-#include<config.h>
+#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 <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/gpgv.h>
+#include <apt-pkg/strutl.h>
#include <errno.h>
+#include <fcntl.h>
+#include <stddef.h>
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
-#include <fcntl.h>
+#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
-#include <stddef.h>
#include <algorithm>
#include <fstream>
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index 662c2bf8b..5a1d356f1 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -13,19 +13,19 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/hashes.h>
-#include <apt-pkg/fileutl.h>
#include <apt-pkg/configuration.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 <stddef.h>
#include <algorithm>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string>
#include <iostream>
+#include <string>
+#include <stddef.h>
+#include <stdlib.h>
+#include <unistd.h>
/*}}}*/
const char * HashString::_SupportedHashes[] =
@@ -339,7 +339,7 @@ bool Hashes::AddFD(int const Fd,unsigned long long Size)
bool const ToEOF = (Size == UntilEOF);
while (Size != 0 || ToEOF)
{
- unsigned long long n = sizeof(Buf);
+ decltype(Size) n = sizeof(Buf);
if (!ToEOF) n = std::min(Size, n);
ssize_t const Res = read(Fd,Buf,n);
if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read
@@ -363,9 +363,9 @@ bool Hashes::AddFD(FileFd &Fd,unsigned long long Size)
bool const ToEOF = (Size == 0);
while (Size != 0 || ToEOF)
{
- unsigned long long n = sizeof(Buf);
+ decltype(Size) n = sizeof(Buf);
if (!ToEOF) n = std::min(Size, n);
- unsigned long long a = 0;
+ decltype(Size) a = 0;
if (Fd.Read(Buf, n, &a) == false) // error
return false;
if (ToEOF == false)
diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h
index 1fe0afc00..1f8f45cb1 100644
--- a/apt-pkg/contrib/hashes.h
+++ b/apt-pkg/contrib/hashes.h
@@ -13,11 +13,10 @@
#ifndef APTPKG_HASHES_H
#define APTPKG_HASHES_H
-
+#include <apt-pkg/macros.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/sha1.h>
#include <apt-pkg/sha2.h>
-#include <apt-pkg/macros.h>
#include <cstring>
#include <string>
diff --git a/apt-pkg/contrib/hashsum.cc b/apt-pkg/contrib/hashsum.cc
index 25ccc187d..e8e86e92c 100644
--- a/apt-pkg/contrib/hashsum.cc
+++ b/apt-pkg/contrib/hashsum.cc
@@ -3,9 +3,9 @@
#include <apt-pkg/fileutl.h>
+#include "hashsum_template.h"
#include <algorithm>
#include <unistd.h>
-#include "hashsum_template.h"
// Summation::AddFD - Add content of file into the checksum /*{{{*/
// ---------------------------------------------------------------------
diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h
index e5032d02f..2594f6aeb 100644
--- a/apt-pkg/contrib/hashsum_template.h
+++ b/apt-pkg/contrib/hashsum_template.h
@@ -10,9 +10,8 @@
#ifndef APTPKG_HASHSUM_TEMPLATE_H
#define APTPKG_HASHSUM_TEMPLATE_H
-
-#include <string>
#include <cstring>
+#include <string>
#ifdef APT_PKG_EXPOSE_STRING_VIEW
#include <apt-pkg/string_view.h>
#endif
diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h
index bc1f523ea..5e22a195d 100644
--- a/apt-pkg/contrib/macros.h
+++ b/apt-pkg/contrib/macros.h
@@ -165,7 +165,7 @@
// See also buildlib/libversion.mak
#define APT_PKG_MAJOR 5
#define APT_PKG_MINOR 0
-#define APT_PKG_RELEASE 1
+#define APT_PKG_RELEASE 2
#define APT_PKG_ABI ((APT_PKG_MAJOR * 100) + APT_PKG_MINOR)
#endif
diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h
index a286f092a..ad0d31374 100644
--- a/apt-pkg/contrib/md5.h
+++ b/apt-pkg/contrib/md5.h
@@ -28,9 +28,9 @@
#include "hashsum_template.h"
#ifndef APT_10_CLEANER_HEADERS
-#include <string>
-#include <cstring>
#include <algorithm>
+#include <cstring>
+#include <string>
#endif
#ifndef APT_8_CLEANER_HEADERS
using std::string;
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index cd24a2808..100796cdf 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -19,17 +19,17 @@
#define _DEFAULT_SOURCE
#include <config.h>
-#include <apt-pkg/mmap.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/mmap.h>
+#include <cstring>
#include <string>
+#include <errno.h>
+#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <cstring>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h
index 62e64b95e..df02b1b85 100644
--- a/apt-pkg/contrib/mmap.h
+++ b/apt-pkg/contrib/mmap.h
@@ -25,7 +25,6 @@
#ifndef PKGLIB_MMAP_H
#define PKGLIB_MMAP_H
-
#include <string>
#ifndef APT_8_CLEANER_HEADERS
diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc
index 8840de72c..88027c989 100644
--- a/apt-pkg/contrib/netrc.cc
+++ b/apt-pkg/contrib/netrc.cc
@@ -17,12 +17,12 @@
#include <apt-pkg/strutl.h>
#include <iostream>
+#include <pwd.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <stddef.h>
-#include <pwd.h>
#include "netrc.h"
diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc
index b93018154..7c5b15e6b 100644
--- a/apt-pkg/contrib/progress.cc
+++ b/apt-pkg/contrib/progress.cc
@@ -10,15 +10,15 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/progress.h>
-#include <sys/time.h>
-#include <string>
+#include <cstring>
#include <iostream>
+#include <string>
#include <stdio.h>
-#include <cstring>
+#include <sys/time.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/contrib/progress.h b/apt-pkg/contrib/progress.h
index 427b1bd35..43c84da71 100644
--- a/apt-pkg/contrib/progress.h
+++ b/apt-pkg/contrib/progress.h
@@ -21,10 +21,9 @@
#ifndef PKGLIB_PROGRESS_H
#define PKGLIB_PROGRESS_H
-
+#include <apt-pkg/macros.h>
#include <string>
#include <sys/time.h>
-#include <apt-pkg/macros.h>
#ifndef APT_8_CLEANER_HEADERS
using std::string;
diff --git a/apt-pkg/contrib/proxy.cc b/apt-pkg/contrib/proxy.cc
index 1b7a92c68..86582e1aa 100644
--- a/apt-pkg/contrib/proxy.cc
+++ b/apt-pkg/contrib/proxy.cc
@@ -7,12 +7,14 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<apt-pkg/configuration.h>
-#include<apt-pkg/error.h>
-#include<apt-pkg/fileutl.h>
-#include<apt-pkg/strutl.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/strutl.h>
-#include<iostream>
+#include <algorithm>
+#include <iostream>
+#include <fcntl.h>
#include <unistd.h>
#include "proxy.h"
@@ -21,6 +23,13 @@
// AutoDetectProxy - auto detect proxy /*{{{*/
// ---------------------------------------------------------------------
/* */
+static std::vector<std::string> CompatibleProxies(URI const &URL)
+{
+ if (URL.Access == "http" || URL.Access == "https")
+ return {"http", "https", "socks5h"};
+ return {URL.Access};
+}
+
bool AutoDetectProxy(URI &URL)
{
// we support both http/https debug options
@@ -41,6 +50,9 @@ bool AutoDetectProxy(URI &URL)
if (Debug)
std::clog << "Using auto proxy detect command: " << AutoDetectProxyCmd << std::endl;
+ if (faccessat(AT_FDCWD, AutoDetectProxyCmd.c_str(), R_OK | X_OK, AT_EACCESS) != 0)
+ return _error->Errno("access", "ProxyAutoDetect command '%s' can not be executed!", AutoDetectProxyCmd.c_str());
+
std::string const urlstring = URL;
std::vector<const char *> Args;
Args.push_back(AutoDetectProxyCmd.c_str());
@@ -70,7 +82,14 @@ bool AutoDetectProxy(URI &URL)
if (Debug)
std::clog << "auto detect command returned: '" << cleanedbuf << "'" << std::endl;
- if (strstr(cleanedbuf, URL.Access.c_str()) == cleanedbuf || strcmp(cleanedbuf, "DIRECT") == 0)
+ auto compatibleTypes = CompatibleProxies(URL);
+ bool compatible = strcmp(cleanedbuf, "DIRECT") == 0 ||
+ compatibleTypes.end() != std::find_if(compatibleTypes.begin(),
+ compatibleTypes.end(), [cleanedbuf](std::string &compat) {
+ return strstr(cleanedbuf, compat.c_str()) == cleanedbuf;
+ });
+
+ if (compatible)
_config->Set("Acquire::"+URL.Access+"::proxy::"+URL.Host, cleanedbuf);
return true;
diff --git a/apt-pkg/contrib/sha1.h b/apt-pkg/contrib/sha1.h
index 3387c1cfd..967e2eae0 100644
--- a/apt-pkg/contrib/sha1.h
+++ b/apt-pkg/contrib/sha1.h
@@ -17,9 +17,9 @@
#include "hashsum_template.h"
#ifndef APT_10_CLEANER_HEADERS
-#include <string>
-#include <cstring>
#include <algorithm>
+#include <cstring>
+#include <string>
#endif
#ifndef APT_8_CLEANER_HEADERS
using std::string;
diff --git a/apt-pkg/contrib/sha2.h b/apt-pkg/contrib/sha2.h
index 164840d3b..d8127c66b 100644
--- a/apt-pkg/contrib/sha2.h
+++ b/apt-pkg/contrib/sha2.h
@@ -16,12 +16,12 @@
#include <cstring>
-#include "sha2_internal.h"
#include "hashsum_template.h"
+#include "sha2_internal.h"
#ifndef APT_10_CLEANER_HEADERS
-#include <string>
#include <algorithm>
+#include <string>
#include <stdint.h>
#endif
diff --git a/apt-pkg/contrib/sha2_internal.cc b/apt-pkg/contrib/sha2_internal.cc
index f70b7b17d..419b92aca 100644
--- a/apt-pkg/contrib/sha2_internal.cc
+++ b/apt-pkg/contrib/sha2_internal.cc
@@ -33,10 +33,10 @@
*/
#include <config.h>
-#include <endian.h>
-#include <string.h> /* memcpy()/memset() or bcopy()/bzero() */
-#include <assert.h> /* assert() */
#include "sha2_internal.h"
+#include <assert.h> /* assert() */
+#include <endian.h>
+#include <string.h> /* memcpy()/memset() or bcopy()/bzero() */
/*
* ASSERT NOTE:
@@ -93,7 +93,7 @@
/*
* Define the followingsha2_* types to types of the correct length on
- * the native archtecture. Most BSD systems and Linux define u_intXX_t
+ * the native architecture. Most BSD systems and Linux define u_intXX_t
* types. Machines with very recent ANSI C headers, can use the
* uintXX_t definintions from inttypes.h by defining SHA2_USE_INTTYPES_H
* during compile or in the sha.h header file.
diff --git a/apt-pkg/contrib/sha2_internal.h b/apt-pkg/contrib/sha2_internal.h
index 1b82d965d..fa4bfc4df 100644
--- a/apt-pkg/contrib/sha2_internal.h
+++ b/apt-pkg/contrib/sha2_internal.h
@@ -44,8 +44,8 @@
#ifdef SHA2_USE_INTTYPES_H
-#include <stddef.h>
#include <inttypes.h>
+#include <stddef.h>
#endif /* SHA2_USE_INTTYPES_H */
diff --git a/apt-pkg/contrib/srvrec.cc b/apt-pkg/contrib/srvrec.cc
index 327e59937..930989bfc 100644
--- a/apt-pkg/contrib/srvrec.cc
+++ b/apt-pkg/contrib/srvrec.cc
@@ -10,8 +10,8 @@
#include <netdb.h>
-#include <netinet/in.h>
#include <arpa/nameser.h>
+#include <netinet/in.h>
#include <resolv.h>
#include <time.h>
@@ -22,10 +22,8 @@
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
-
#include "srvrec.h"
-
bool SrvRec::operator==(SrvRec const &other) const
{
return (std::tie(target, priority, weight, port) ==
diff --git a/apt-pkg/contrib/srvrec.h b/apt-pkg/contrib/srvrec.h
index 01b810281..e22b7a1c6 100644
--- a/apt-pkg/contrib/srvrec.h
+++ b/apt-pkg/contrib/srvrec.h
@@ -9,9 +9,9 @@
#ifndef SRVREC_H
#define SRVREC_H
-#include <arpa/nameser.h>
-#include <vector>
#include <string>
+#include <vector>
+#include <arpa/nameser.h>
class SrvRec
{
diff --git a/apt-pkg/contrib/string_view.h b/apt-pkg/contrib/string_view.h
index c504edd27..536744e32 100644
--- a/apt-pkg/contrib/string_view.h
+++ b/apt-pkg/contrib/string_view.h
@@ -11,9 +11,9 @@
#if !defined(APT_STRINGVIEW_H) && defined(APT_PKG_EXPOSE_STRING_VIEW)
#define APT_STRINGVIEW_H
-#include <string.h>
-#include <string>
#include <apt-pkg/macros.h>
+#include <string>
+#include <string.h>
namespace APT {
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 88113f7a4..964f0d6c6 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -17,30 +17,30 @@
// Includes /*{{{*/
#include <config.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/strutl.h>
-#include <array>
#include <algorithm>
+#include <array>
#include <iomanip>
#include <locale>
#include <sstream>
-#include <string>
#include <sstream>
+#include <string>
#include <vector>
+#include <ctype.h>
+#include <errno.h>
+#include <iconv.h>
+#include <regex.h>
+#include <stdarg.h>
#include <stddef.h>
+#include <stdio.h>
#include <stdlib.h>
-#include <time.h>
-#include <ctype.h>
#include <string.h>
-#include <stdio.h>
+#include <time.h>
#include <unistd.h>
-#include <regex.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <iconv.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index 73f27aa6c..cc39521da 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -16,17 +16,16 @@
#ifndef STRUTL_H
#define STRUTL_H
-
+#include <cstring>
+#include <iostream>
#include <limits>
#include <string>
-#include <cstring>
#include <vector>
-#include <iostream>
#ifdef APT_PKG_EXPOSE_STRING_VIEW
#include <apt-pkg/string_view.h>
#endif
-#include <time.h>
#include <stddef.h>
+#include <time.h>
#include "macros.h"
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index c55847305..6aa3af162 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -11,23 +11,23 @@
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/debindexfile.h>
-#include <apt-pkg/debsrcrecords.h>
#include <apt-pkg/deblistparser.h>
#include <apt-pkg/debrecords.h>
-#include <apt-pkg/configuration.h>
+#include <apt-pkg/debsrcrecords.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/indexfile.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/srcrecords.h>
-#include <stdio.h>
#include <iostream>
-#include <string>
+#include <memory>
#include <sstream>
+#include <string>
+#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -66,7 +66,7 @@ bool debSourcesIndex::OpenListFile(FileFd &, std::string const &)
}
pkgCacheListParser * debSourcesIndex::CreateListParser(FileFd &)
{
- return NULL;
+ return nullptr;
}
uint8_t debSourcesIndex::GetIndexFlags() const
{
@@ -128,16 +128,10 @@ pkgCacheListParser * debTranslationsIndex::CreateListParser(FileFd &Pkg)
if (Pkg.IsOpen() == false)
return nullptr;
_error->PushToStack();
- pkgCacheListParser * const Parser = new debTranslationsParser(&Pkg);
+ std::unique_ptr<pkgCacheListParser> Parser(new debTranslationsParser(&Pkg));
bool const newError = _error->PendingError();
_error->MergeWithStack();
- if (newError)
- {
- delete Parser;
- return nullptr;
- }
- else
- return Parser;
+ return newError ? nullptr : Parser.release();
}
/*}}}*/
// dpkg/status Index /*{{{*/
@@ -162,16 +156,10 @@ pkgCacheListParser * debStatusIndex::CreateListParser(FileFd &Pkg)
if (Pkg.IsOpen() == false)
return nullptr;
_error->PushToStack();
- pkgCacheListParser * const Parser = new debStatusListParser(&Pkg);
+ std::unique_ptr<pkgCacheListParser> Parser(new debStatusListParser(&Pkg));
bool const newError = _error->PendingError();
_error->MergeWithStack();
- if (newError)
- {
- delete Parser;
- return nullptr;
- }
- else
- return Parser;
+ return newError ? nullptr : Parser.release();
}
/*}}}*/
// DebPkgFile Index - a single .deb file as an index /*{{{*/
@@ -244,16 +232,10 @@ pkgCacheListParser * debDebPkgFileIndex::CreateListParser(FileFd &Pkg)
if (Pkg.IsOpen() == false)
return nullptr;
_error->PushToStack();
- pkgCacheListParser * const Parser = new debDebFileParser(&Pkg, DebFile);
+ std::unique_ptr<pkgCacheListParser> Parser(new debDebFileParser(&Pkg, DebFile));
bool const newError = _error->PendingError();
_error->MergeWithStack();
- if (newError)
- {
- delete Parser;
- return nullptr;
- }
- else
- return Parser;
+ return newError ? nullptr : Parser.release();
}
uint8_t debDebPkgFileIndex::GetIndexFlags() const
{
diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h
index 3652f631c..40a9e4bbc 100644
--- a/apt-pkg/deb/debindexfile.h
+++ b/apt-pkg/deb/debindexfile.h
@@ -16,7 +16,6 @@
#define PKGLIB_DEBINDEXFILE_H
#include <apt-pkg/indexfile.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/srcrecords.h>
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 4e61f0fc2..378988a1c 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -12,26 +12,25 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/deblistparser.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/cachefilter.h>
#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/strutl.h>
+#include <apt-pkg/cachefilter.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/crc-16.h>
+#include <apt-pkg/deblistparser.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/macros.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
-#include <apt-pkg/tagfile.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/tagfile-keys.h>
-#include <apt-pkg/macros.h>
+#include <apt-pkg/tagfile.h>
-#include <stddef.h>
-#include <string.h>
#include <algorithm>
#include <string>
#include <vector>
#include <ctype.h>
+#include <stddef.h>
+#include <string.h>
/*}}}*/
using std::string;
@@ -372,6 +371,11 @@ unsigned short debListParser::VersionHash()
string to make that not matter. */
for (; Start != End; ++Start)
{
+ // Strip away 0: epochs from input
+ if (*Start == '0' && Start[1] == ':') {
+ Start++; // Skip the :
+ continue; // Skip the 0
+ }
if (isspace_ascii(*Start) != 0 || *Start == '=')
continue;
Result = AddCRC16Byte(Result, tolower_ascii_unsafe(*Start));
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 39f42915c..8d7efc746 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -11,11 +11,11 @@
#ifndef PKGLIB_DEBLISTPARSER_H
#define PKGLIB_DEBLISTPARSER_H
-#include <apt-pkg/pkgcachegen.h>
-#include <apt-pkg/tagfile.h>
+#include <apt-pkg/macros.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcachegen.h>
+#include <apt-pkg/tagfile.h>
#include <string>
#include <vector>
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index cba00aa8e..a0adf85be 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -1,30 +1,30 @@
#include <config.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/debmetaindex.h>
-#include <apt-pkg/debindexfile.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-item.h>
-#include <apt-pkg/configuration.h>
#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/debindexfile.h>
+#include <apt-pkg/debmetaindex.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/gpgv.h>
#include <apt-pkg/hashes.h>
+#include <apt-pkg/macros.h>
#include <apt-pkg/metaindex.h>
#include <apt-pkg/pkgcachegen.h>
+#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/tagfile.h>
-#include <apt-pkg/gpgv.h>
-#include <apt-pkg/macros.h>
+#include <algorithm>
#include <map>
+#include <sstream>
#include <string>
#include <utility>
#include <vector>
-#include <algorithm>
-#include <sstream>
-#include <sys/stat.h>
#include <string.h>
+#include <sys/stat.h>
#include <apti18n.h>
@@ -51,6 +51,7 @@ class APT_HIDDEN debReleaseIndexPrivate /*{{{*/
std::vector<std::string> Architectures;
std::vector<std::string> NoSupportForAll;
+ std::vector<std::string> SupportedComponents;
std::map<std::string, std::string> const ReleaseOptions;
debReleaseIndexPrivate(std::map<std::string, std::string> const &Options) : CheckValidUntil(metaIndex::TRI_UNSET), ValidUntilMin(0), ValidUntilMax(0), ReleaseOptions(Options) {}
@@ -392,8 +393,12 @@ bool debReleaseIndex::Load(std::string const &Filename, std::string * const Erro
// FIXME: find better tag name
SupportsAcquireByHash = Section.FindB("Acquire-By-Hash", false);
+ SetOrigin(Section.FindS("Origin"));
+ SetLabel(Section.FindS("Label"));
+ SetVersion(Section.FindS("Version"));
Suite = Section.FindS("Suite");
Codename = Section.FindS("Codename");
+ SetReleaseNotes(Section.FindS("Release-Notes"));
{
std::string const archs = Section.FindS("Architectures");
if (archs.empty() == false)
@@ -404,6 +409,29 @@ bool debReleaseIndex::Load(std::string const &Filename, std::string * const Erro
if (targets.empty() == false)
d->NoSupportForAll = VectorizeString(targets, ' ');
}
+ for (auto const &comp: VectorizeString(Section.FindS("Components"), ' '))
+ {
+ if (comp.empty())
+ continue;
+ auto const pos = comp.find_last_of('/');
+ if (pos != std::string::npos) // e.g. security.debian.org uses this style
+ d->SupportedComponents.push_back(comp.substr(pos + 1));
+ d->SupportedComponents.push_back(std::move(comp));
+ }
+ {
+ decltype(pkgCache::ReleaseFile::Flags) flags = 0;
+ Section.FindFlag("NotAutomatic", flags, pkgCache::Flag::NotAutomatic);
+ signed short defaultpin = 500;
+ if ((flags & pkgCache::Flag::NotAutomatic) == pkgCache::Flag::NotAutomatic)
+ {
+ Section.FindFlag("ButAutomaticUpgrades", flags, pkgCache::Flag::ButAutomaticUpgrades);
+ if ((flags & pkgCache::Flag::ButAutomaticUpgrades) == pkgCache::Flag::ButAutomaticUpgrades)
+ defaultpin = 100;
+ else
+ defaultpin = 1;
+ }
+ SetDefaultPin(defaultpin);
+ }
bool FoundHashSum = false;
bool FoundStrongHashSum = false;
@@ -461,7 +489,6 @@ bool debReleaseIndex::Load(std::string const &Filename, std::string * const Erro
if (CheckValidUntil == true)
{
- std::string const Label = Section.FindS("Label");
std::string const StrValidUntil = Section.FindS("Valid-Until");
// if we have a Valid-Until header in the Release file, use it as default
@@ -474,6 +501,7 @@ bool debReleaseIndex::Load(std::string const &Filename, std::string * const Erro
return false;
}
}
+ auto const Label = GetLabel();
// get the user settings for this archive and use what expires earlier
time_t MaxAge = d->ValidUntilMax;
if (MaxAge == 0)
@@ -733,6 +761,13 @@ bool debReleaseIndex::IsArchitectureAllSupportedFor(IndexTarget const &target) c
return std::find(d->NoSupportForAll.begin(), d->NoSupportForAll.end(), target.Option(IndexTarget::CREATED_BY)) == d->NoSupportForAll.end();
}
/*}}}*/
+bool debReleaseIndex::HasSupportForComponent(std::string const &component) const/*{{{*/
+{
+ if (d->SupportedComponents.empty())
+ return true;
+ return std::find(d->SupportedComponents.begin(), d->SupportedComponents.end(), component) != d->SupportedComponents.end();
+}
+ /*}}}*/
std::vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles() /*{{{*/
{
if (Indexes != NULL)
diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h
index f903617f7..5a97cfc78 100644
--- a/apt-pkg/deb/debmetaindex.h
+++ b/apt-pkg/deb/debmetaindex.h
@@ -1,8 +1,8 @@
#ifndef PKGLIB_DEBMETAINDEX_H
#define PKGLIB_DEBMETAINDEX_H
-#include <apt-pkg/metaindex.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/metaindex.h>
#include <map>
#include <string>
@@ -61,6 +61,7 @@ class APT_HIDDEN debReleaseIndex : public metaIndex
virtual bool IsTrusted() const APT_OVERRIDE;
bool IsArchitectureSupported(std::string const &arch) const;
bool IsArchitectureAllSupportedFor(IndexTarget const &target) const;
+ bool HasSupportForComponent(std::string const &component) const;
void AddComponent(std::string const &sourcesEntry,
bool const isSrc, std::string const &Name,
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc
index a132f34a6..bc4a378eb 100644
--- a/apt-pkg/deb/debrecords.cc
+++ b/apt-pkg/deb/debrecords.cc
@@ -10,22 +10,21 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/debrecords.h>
-#include <apt-pkg/debindexfile.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/debindexfile.h>
+#include <apt-pkg/debrecords.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/tagfile.h>
-#include <apt-pkg/error.h>
-#include <string.h>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <langinfo.h>
+#include <string.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h
index ae75a2b78..828c2b93b 100644
--- a/apt-pkg/deb/debrecords.h
+++ b/apt-pkg/deb/debrecords.h
@@ -14,10 +14,10 @@
#ifndef PKGLIB_DEBRECORDS_H
#define PKGLIB_DEBRECORDS_H
-#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/tagfile.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/tagfile.h>
#include <string>
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index d664b609e..0368817c2 100644
--- a/apt-pkg/deb/debsrcrecords.cc
+++ b/apt-pkg/deb/debsrcrecords.cc
@@ -11,22 +11,22 @@
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/deblistparser.h>
#include <apt-pkg/debsrcrecords.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/gpgv.h>
+#include <apt-pkg/hashes.h>
#include <apt-pkg/srcrecords.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/tagfile.h>
-#include <apt-pkg/hashes.h>
-#include <apt-pkg/gpgv.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
#include <algorithm>
#include <string>
#include <vector>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
/*}}}*/
using std::max;
diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h
index 850040cf5..349e66ba2 100644
--- a/apt-pkg/deb/debsrcrecords.h
+++ b/apt-pkg/deb/debsrcrecords.h
@@ -11,13 +11,13 @@
#ifndef PKGLIB_DEBSRCRECORDS_H
#define PKGLIB_DEBSRCRECORDS_H
+#include <apt-pkg/fileutl.h>
#include <apt-pkg/srcrecords.h>
#include <apt-pkg/tagfile.h>
-#include <apt-pkg/fileutl.h>
-#include <stddef.h>
#include <string>
#include <vector>
+#include <stddef.h>
class pkgIndexFile;
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index 899f7328b..3ad25ba05 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -12,30 +12,29 @@
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/debindexfile.h>
#include <apt-pkg/debsystem.h>
#include <apt-pkg/debversion.h>
-#include <apt-pkg/debindexfile.h>
#include <apt-pkg/dpkgpm.h>
-#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <algorithm>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
#include <string>
#include <vector>
-#include <unistd.h>
+#include <ctype.h>
#include <dirent.h>
#include <errno.h>
-#include <sys/types.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <sys/wait.h>
-#include <fcntl.h>
+#include <unistd.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/deb/debsystem.h b/apt-pkg/deb/debsystem.h
index 5185c92d8..9fdecb42f 100644
--- a/apt-pkg/deb/debsystem.h
+++ b/apt-pkg/deb/debsystem.h
@@ -10,9 +10,8 @@
#ifndef PKGLIB_DEBSYSTEM_H
#define PKGLIB_DEBSYSTEM_H
-#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgsystem.h>
#include <vector>
class Configuration;
diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc
index 48462c6a2..9fe2fd6b3 100644
--- a/apt-pkg/deb/debversion.cc
+++ b/apt-pkg/deb/debversion.cc
@@ -15,9 +15,9 @@
#include <apt-pkg/debversion.h>
#include <apt-pkg/pkgcache.h>
-#include <string.h>
-#include <stdlib.h>
#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
/*}}}*/
debVersioningSystem debVS;
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 80bee03dd..58599193e 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -11,20 +11,20 @@
#include <apt-pkg/cachefile.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/debsystem.h>
#include <apt-pkg/depcache.h>
#include <apt-pkg/dpkgpm.h>
-#include <apt-pkg/debsystem.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/install-progress.h>
-#include <apt-pkg/packagemanager.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/statechanges.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/packagemanager.h>
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/statechanges.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/version.h>
+#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
@@ -37,9 +37,8 @@
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/time.h>
-#include <sys/wait.h>
#include <sys/types.h>
-#include <dirent.h>
+#include <sys/wait.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
@@ -49,14 +48,14 @@
#include <cstring>
#include <iostream>
#include <map>
+#include <numeric>
#include <set>
+#include <sstream>
#include <string>
#include <type_traits>
-#include <utility>
#include <unordered_set>
+#include <utility>
#include <vector>
-#include <sstream>
-#include <numeric>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h
index d1c2bcf41..324551387 100644
--- a/apt-pkg/deb/dpkgpm.h
+++ b/apt-pkg/deb/dpkgpm.h
@@ -10,14 +10,14 @@
#ifndef PKGLIB_DPKGPM_H
#define PKGLIB_DPKGPM_H
+#include <apt-pkg/macros.h>
#include <apt-pkg/packagemanager.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/macros.h>
-#include <vector>
#include <map>
-#include <stdio.h>
#include <string>
+#include <vector>
+#include <stdio.h>
#ifndef APT_10_CLEANER_HEADERS
#include <apt-pkg/init.h>
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index f3615302e..efe26dee3 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -8,34 +8,33 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
+#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/cachefile.h>
+#include <apt-pkg/cacheset.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/depcache.h>
-#include <apt-pkg/versionmatch.h>
-#include <apt-pkg/version.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/tagfile.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/cacheset.h>
+#include <apt-pkg/macros.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/prettyprinters.h>
-#include <apt-pkg/cachefile.h>
-#include <apt-pkg/macros.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/tagfile.h>
+#include <apt-pkg/version.h>
+#include <apt-pkg/versionmatch.h>
-#include <stdio.h>
-#include <string.h>
+#include <algorithm>
+#include <iostream>
#include <list>
+#include <set>
#include <string>
#include <utility>
#include <vector>
-#include <algorithm>
-#include <iostream>
-#include <set>
+#include <stdio.h>
+#include <string.h>
#include <sys/stat.h>
@@ -1783,7 +1782,7 @@ bool pkgDepCache::Policy::IsImportantDep(DepIterator const &Dep) const
return true;
// we support a special mode to only install-recommends for certain
// sections
- // FIXME: this is a meant as a temporarly solution until the
+ // FIXME: this is a meant as a temporary solution until the
// recommends are cleaned up
const char *sec = Dep.ParentVer().Section();
if (sec && ConfigValueInSubTree("APT::Install-Recommends-Sections", sec))
diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h
index 1ab86644d..87b42b7ca 100644
--- a/apt-pkg/depcache.h
+++ b/apt-pkg/depcache.h
@@ -38,20 +38,19 @@
#define PKGLIB_DEPCACHE_H
#include <apt-pkg/configuration.h>
-#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
#include <stddef.h>
-#include <memory>
#include <list>
+#include <memory>
#include <string>
#include <utility>
#ifndef APT_8_CLEANER_HEADERS
-#include <apt-pkg/progress.h>
#include <apt-pkg/error.h>
+#include <apt-pkg/progress.h>
#endif
#ifndef APT_10_CLEANER_HEADERS
#include <set>
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index a2520441b..2e39be377 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -8,27 +8,26 @@
#include <config.h>
#include <apt-pkg/algorithms.h>
-#include <apt-pkg/error.h>
#include <apt-pkg/cacheset.h>
#include <apt-pkg/depcache.h>
+#include <apt-pkg/edsp.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/packagemanager.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/prettyprinters.h>
-#include <apt-pkg/packagemanager.h>
#include <apt-pkg/progress.h>
-#include <apt-pkg/fileutl.h>
-#include <apt-pkg/edsp.h>
-#include <apt-pkg/tagfile.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/string_view.h>
-#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/tagfile.h>
-#include <sys/stat.h>
#include <ctype.h>
#include <stddef.h>
+#include <stdio.h>
#include <string.h>
+#include <sys/stat.h>
#include <unistd.h>
-#include <stdio.h>
#include <array>
#include <limits>
@@ -396,7 +395,7 @@ bool EDSP::WriteScenario(pkgDepCache &Cache, FILE* output, OpProgress *Progress)
{
if (Progress != NULL)
Progress->SubProgress(Cache.Head().VersionCount, _("Send scenario to solver"));
- unsigned long p = 0;
+ decltype(Cache.Head().VersionCount) p = 0;
std::vector<std::string> archs = APT::Configuration::getArchitectures();
for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg)
{
@@ -420,7 +419,7 @@ bool EDSP::WriteScenario(pkgDepCache &Cache, FileFd &output, OpProgress *Progres
{
if (Progress != NULL)
Progress->SubProgress(Cache.Head().VersionCount, _("Send scenario to solver"));
- unsigned long p = 0;
+ decltype(Cache.Head().VersionCount) p = 0;
bool Okay = output.Failed() == false;
std::vector<std::string> archs = APT::Configuration::getArchitectures();
for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false && likely(Okay); ++Pkg)
@@ -450,7 +449,7 @@ bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FILE* output,
{
if (Progress != NULL)
Progress->SubProgress(Cache.Head().VersionCount, _("Send scenario to solver"));
- unsigned long p = 0;
+ decltype(Cache.Head().PackageCount) p = 0;
for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg, ++p)
for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver)
{
@@ -472,7 +471,7 @@ bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FileFd &output,
{
if (Progress != NULL)
Progress->SubProgress(Cache.Head().VersionCount, _("Send scenario to solver"));
- unsigned long p = 0;
+ decltype(Cache.Head().PackageCount) p = 0;
bool Okay = output.Failed() == false;
for (auto Pkg = Cache.PkgBegin(); Pkg.end() == false && likely(Okay); ++Pkg, ++p)
{
@@ -502,7 +501,7 @@ bool EDSP::WriteRequest(pkgDepCache &Cache, FILE* output, bool const Upgrade,
{
if (Progress != NULL)
Progress->SubProgress(Cache.Head().PackageCount, _("Send request to solver"));
- unsigned long p = 0;
+ decltype(Cache.Head().PackageCount) p = 0;
string del, inst;
for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg, ++p)
{
@@ -556,7 +555,7 @@ bool EDSP::WriteRequest(pkgDepCache &Cache, FileFd &output,
{
if (Progress != NULL)
Progress->SubProgress(Cache.Head().PackageCount, _("Send request to solver"));
- unsigned long p = 0;
+ decltype(Cache.Head().PackageCount) p = 0;
string del, inst;
for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg, ++p)
{
@@ -618,8 +617,8 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache, OpProgress *Progres
In theory we could use the offset as ID, but then VersionCount
couldn't be used to create other versionmappings anymore and it
would be too easy for a (buggy) solver to segfault APT… */
- unsigned long long const VersionCount = Cache.Head().VersionCount;
- unsigned long VerIdx[VersionCount];
+ auto VersionCount = Cache.Head().VersionCount;
+ decltype(VersionCount) VerIdx[VersionCount];
for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; ++P) {
for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V)
VerIdx[V->ID] = V.Index();
@@ -675,11 +674,11 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache, OpProgress *Progres
continue;
}
- size_t const id = section.FindULL(type.c_str(), VersionCount);
+ decltype(VersionCount) const id = section.FindULL(type.c_str(), VersionCount);
if (id == VersionCount) {
_error->Warning("Unable to parse %s request with id value '%s'!", type.c_str(), section.FindS(type.c_str()).c_str());
continue;
- } else if (id > Cache.Head().VersionCount) {
+ } else if (id > VersionCount) {
_error->Warning("ID value '%s' in %s request stanza is to high to refer to a known version!", section.FindS(type.c_str()).c_str(), type.c_str());
continue;
}
@@ -1163,7 +1162,7 @@ bool EIPP::WriteRequest(pkgDepCache &Cache, FileFd &output, /*{{{*/
{
if (Progress != NULL)
Progress->SubProgress(Cache.Head().PackageCount, _("Send request to planner"));
- unsigned long p = 0;
+ decltype(Cache.Head().PackageCount) p = 0;
string del, inst, reinst;
for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg, ++p)
{
@@ -1253,7 +1252,7 @@ bool EIPP::WriteScenario(pkgDepCache &Cache, FileFd &output, OpProgress * const
{
if (Progress != NULL)
Progress->SubProgress(Cache.Head().PackageCount, _("Send scenario to planner"));
- unsigned long p = 0;
+ decltype(Cache.Head().PackageCount) p = 0;
bool Okay = output.Failed() == false;
std::vector<std::string> archs = APT::Configuration::getArchitectures();
std::vector<bool> pkgset(Cache.Head().PackageCount, false);
@@ -1328,8 +1327,8 @@ bool EIPP::ReadResponse(int const input, pkgPackageManager * const PM, OpProgres
In theory we could use the offset as ID, but then VersionCount
couldn't be used to create other versionmappings anymore and it
would be too easy for a (buggy) solver to segfault APT… */
- unsigned long long const VersionCount = PM->Cache.Head().VersionCount;
- unsigned long VerIdx[VersionCount];
+ auto VersionCount = PM->Cache.Head().VersionCount;
+ decltype(VersionCount) VerIdx[VersionCount];
for (pkgCache::PkgIterator P = PM->Cache.PkgBegin(); P.end() == false; ++P) {
for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V)
VerIdx[V->ID] = V.Index();
@@ -1384,11 +1383,11 @@ bool EIPP::ReadResponse(int const input, pkgPackageManager * const PM, OpProgres
if (type == nullptr)
continue;
- size_t const id = section.FindULL(type, VersionCount);
+ decltype(VersionCount) const id = section.FindULL(type, VersionCount);
if (id == VersionCount) {
_error->Warning("Unable to parse %s request with id value '%s'!", type, section.FindS(type).c_str());
continue;
- } else if (id > PM->Cache.Head().VersionCount) {
+ } else if (id > VersionCount) {
_error->Warning("ID value '%s' in %s request stanza is to high to refer to a known version!", section.FindS(type).c_str(), type);
continue;
}
diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h
index 2c9082ed3..2f18d76eb 100644
--- a/apt-pkg/edsp.h
+++ b/apt-pkg/edsp.h
@@ -10,9 +10,8 @@
#define PKGLIB_EDSP_H
#include <apt-pkg/cacheset.h>
-#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
#include <stdio.h>
diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc
index 042a88cf9..1a8af89f0 100644
--- a/apt-pkg/edsp/edspindexfile.cc
+++ b/apt-pkg/edsp/edspindexfile.cc
@@ -16,9 +16,10 @@
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/pkgrecords.h>
+#include <memory>
+#include <string>
#include <stddef.h>
#include <unistd.h>
-#include <string>
/*}}}*/
// EDSP-like Index /*{{{*/
@@ -61,12 +62,12 @@ std::string edspIndex::GetComponent() const
pkgCacheListParser * edspIndex::CreateListParser(FileFd &Pkg)
{
if (Pkg.IsOpen() == false)
- return NULL;
+ return nullptr;
_error->PushToStack();
- pkgCacheListParser * const Parser = new edspListParser(&Pkg);
+ std::unique_ptr<pkgCacheListParser> Parser(new edspListParser(&Pkg));
bool const newError = _error->PendingError();
_error->MergeWithStack();
- return newError ? NULL : Parser;
+ return newError ? nullptr : Parser.release();
}
/*}}}*/
// EIPP Index /*{{{*/
@@ -80,12 +81,12 @@ std::string eippIndex::GetComponent() const
pkgCacheListParser * eippIndex::CreateListParser(FileFd &Pkg)
{
if (Pkg.IsOpen() == false)
- return NULL;
+ return nullptr;
_error->PushToStack();
- pkgCacheListParser * const Parser = new eippListParser(&Pkg);
+ std::unique_ptr<pkgCacheListParser> Parser(new eippListParser(&Pkg));
bool const newError = _error->PendingError();
_error->MergeWithStack();
- return newError ? NULL : Parser;
+ return newError ? nullptr : Parser.release();
}
/*}}}*/
diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc
index 4119639a6..b118e127d 100644
--- a/apt-pkg/edsp/edsplistparser.cc
+++ b/apt-pkg/edsp/edsplistparser.cc
@@ -12,15 +12,14 @@
#include <config.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/deblistparser.h>
#include <apt-pkg/edsplistparser.h>
+#include <apt-pkg/fileutl.h>
#include <apt-pkg/md5.h>
-#include <apt-pkg/deblistparser.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
-#include <apt-pkg/tagfile.h>
-#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/string_view.h>
+#include <apt-pkg/tagfile.h>
#include <array>
diff --git a/apt-pkg/edsp/edsplistparser.h b/apt-pkg/edsp/edsplistparser.h
index 4904b6567..0fcc3f5fd 100644
--- a/apt-pkg/edsp/edsplistparser.h
+++ b/apt-pkg/edsp/edsplistparser.h
@@ -12,15 +12,15 @@
#define PKGLIB_EDSPLISTPARSER_H
#include <apt-pkg/deblistparser.h>
+#include <apt-pkg/fileutl.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/fileutl.h>
#include <string>
#ifndef APT_8_CLEANER_HEADERS
-#include <apt-pkg/pkgcachegen.h>
#include <apt-pkg/indexfile.h>
+#include <apt-pkg/pkgcachegen.h>
#include <apt-pkg/tagfile.h>
#endif
diff --git a/apt-pkg/edsp/edspsystem.cc b/apt-pkg/edsp/edspsystem.cc
index 1ceb21a17..47f5e06d5 100644
--- a/apt-pkg/edsp/edspsystem.cc
+++ b/apt-pkg/edsp/edspsystem.cc
@@ -15,9 +15,8 @@
#include <apt-pkg/debversion.h>
#include <apt-pkg/edspindexfile.h>
#include <apt-pkg/edspsystem.h>
-#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/pkgcache.h>
#include <stddef.h>
#include <stdlib.h>
diff --git a/apt-pkg/edsp/edspsystem.h b/apt-pkg/edsp/edspsystem.h
index c0c9526b5..af8bcf128 100644
--- a/apt-pkg/edsp/edspsystem.h
+++ b/apt-pkg/edsp/edspsystem.h
@@ -10,9 +10,8 @@
#ifndef PKGLIB_EDSPSYSTEM_H
#define PKGLIB_EDSPSYSTEM_H
-#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/pkgsystem.h>
#include <memory>
#include <vector>
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index ca5c42cb7..11d2e934e 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -10,28 +10,28 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/fileutl.h>
#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/tagfile.h>
-#include <apt-pkg/metaindex.h>
#include <apt-pkg/cdrom.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/debmetaindex.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
#include <apt-pkg/gpgv.h>
#include <apt-pkg/hashes.h>
-#include <apt-pkg/debmetaindex.h>
+#include <apt-pkg/metaindex.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/tagfile.h>
#include <iostream>
-#include <unistd.h>
-#include <sys/stat.h>
+#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sstream>
+#include <sys/stat.h>
+#include <unistd.h>
#include "indexcopy.h"
#include <apti18n.h>
diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc
index 934943205..492f29c5a 100644
--- a/apt-pkg/indexfile.cc
+++ b/apt-pkg/indexfile.cc
@@ -8,31 +8,30 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
+#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/indexfile.h>
+#include <apt-pkg/deblistparser.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/macros.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/pkgcachegen.h>
-#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/progress.h>
#include <apt-pkg/srcrecords.h>
#include <apt-pkg/strutl.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/deblistparser.h>
-#include <apt-pkg/macros.h>
#include <apt-pkg/debindexfile.h>
#include <sys/stat.h>
-#include <string>
-#include <vector>
#include <clocale>
#include <cstring>
#include <memory>
+#include <string>
+#include <vector>
/*}}}*/
// Global list of Item supported
@@ -338,16 +337,10 @@ pkgCacheListParser * pkgDebianIndexFile::CreateListParser(FileFd &Pkg)
if (Pkg.IsOpen() == false)
return nullptr;
_error->PushToStack();
- pkgCacheListParser * const Parser = new debListParser(&Pkg);
+ std::unique_ptr<pkgCacheListParser> Parser(new debListParser(&Pkg));
bool const newError = _error->PendingError();
_error->MergeWithStack();
- if (newError)
- {
- delete Parser;
- return nullptr;
- }
- else
- return Parser;
+ return newError ? nullptr : Parser.release();
}
bool pkgDebianIndexFile::Merge(pkgCacheGenerator &Gen,OpProgress * const Prog)
{
diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h
index 046216ab2..10b15fde4 100644
--- a/apt-pkg/indexfile.h
+++ b/apt-pkg/indexfile.h
@@ -21,11 +21,10 @@
#ifndef PKGLIB_INDEXFILE_H
#define PKGLIB_INDEXFILE_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 <apt-pkg/pkgcache.h>
+#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/srcrecords.h>
#include <map>
#include <string>
diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc
index 00d991027..af4e6faa0 100644
--- a/apt-pkg/init.cc
+++ b/apt-pkg/init.cc
@@ -8,23 +8,23 @@
##################################################################### */
/*}}}*/
// Include files /*{{{*/
-#include<config.h>
+#include <config.h>
-#include <apt-pkg/init.h>
-#include <apt-pkg/fileutl.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/init.h>
+#include <apt-pkg/macros.h>
#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/configuration.h>
#include <apt-pkg/strutl.h>
-#include <apt-pkg/macros.h>
-#include <string.h>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>
+#include <string.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc
index 6c3e51b2c..913068a66 100644
--- a/apt-pkg/install-progress.cc
+++ b/apt-pkg/install-progress.cc
@@ -2,19 +2,19 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/install-progress.h>
+#include <apt-pkg/strutl.h>
-#include <signal.h>
-#include <unistd.h>
+#include <algorithm>
+#include <cmath>
#include <iostream>
+#include <sstream>
#include <vector>
-#include <sys/ioctl.h>
#include <fcntl.h>
-#include <algorithm>
+#include <signal.h>
#include <stdio.h>
-#include <sstream>
-#include <cmath>
+#include <sys/ioctl.h>
+#include <unistd.h>
#include <apti18n.h>
diff --git a/apt-pkg/install-progress.h b/apt-pkg/install-progress.h
index b5c133676..bcc0b615a 100644
--- a/apt-pkg/install-progress.h
+++ b/apt-pkg/install-progress.h
@@ -4,9 +4,9 @@
#include <apt-pkg/macros.h>
#include <string>
-#include <unistd.h>
-#include <signal.h>
#include <vector>
+#include <signal.h>
+#include <unistd.h>
namespace APT {
namespace Progress {
diff --git a/apt-pkg/metaindex.cc b/apt-pkg/metaindex.cc
index 8b31051fb..bdae6dcc9 100644
--- a/apt-pkg/metaindex.cc
+++ b/apt-pkg/metaindex.cc
@@ -1,13 +1,24 @@
// Include Files /*{{{*/
-#include <apt-pkg/pkgcachegen.h>
#include <apt-pkg/indexfile.h>
#include <apt-pkg/metaindex.h>
+#include <apt-pkg/pkgcachegen.h>
#include <apt-pkg/debmetaindex.h>
#include <string>
#include <vector>
- /*}}}*/
+ /*}}}*/
+
+class metaIndexPrivate /*{{{*/
+{
+ public:
+ std::string Origin;
+ std::string Label;
+ std::string Version;
+ signed short DefaultPin;
+ std::string ReleaseNotes;
+};
+ /*}}}*/
std::string metaIndex::Describe() const
{
@@ -26,7 +37,7 @@ bool metaIndex::Merge(pkgCacheGenerator &Gen,OpProgress *) const
metaIndex::metaIndex(std::string const &URI, std::string const &Dist,
char const * const Type)
-: d(NULL), Indexes(NULL), Type(Type), URI(URI), Dist(Dist), Trusted(TRI_UNSET),
+: d(new metaIndexPrivate()), Indexes(NULL), Type(Type), URI(URI), Dist(Dist), Trusted(TRI_UNSET),
Date(0), ValidUntil(0), SupportsAcquireByHash(false), LoadedSuccessfully(TRI_UNSET)
{
/* nothing */
@@ -43,6 +54,7 @@ metaIndex::~metaIndex()
}
for (auto const &E: Entries)
delete E.second;
+ delete d;
}
// one line Getters for public fields /*{{{*/
@@ -51,8 +63,13 @@ APT_PURE std::string metaIndex::GetDist() const { return Dist; }
APT_PURE const char* metaIndex::GetType() const { return Type; }
APT_PURE metaIndex::TriState metaIndex::GetTrusted() const { return Trusted; }
APT_PURE std::string metaIndex::GetSignedBy() const { return SignedBy; }
+APT_PURE std::string metaIndex::GetOrigin() const { return d->Origin; }
+APT_PURE std::string metaIndex::GetLabel() const { return d->Label; }
+APT_PURE std::string metaIndex::GetVersion() const { return d->Version; }
APT_PURE std::string metaIndex::GetCodename() const { return Codename; }
APT_PURE std::string metaIndex::GetSuite() const { return Suite; }
+APT_PURE std::string metaIndex::GetReleaseNotes() const { return d->ReleaseNotes; }
+APT_PURE signed short metaIndex::GetDefaultPin() const { return d->DefaultPin; }
APT_PURE bool metaIndex::GetSupportsAcquireByHash() const { return SupportsAcquireByHash; }
APT_PURE time_t metaIndex::GetValidUntil() const { return ValidUntil; }
APT_PURE time_t metaIndex::GetDate() const { return this->Date; }
@@ -104,11 +121,19 @@ std::vector<std::string> metaIndex::MetaKeys() const /*{{{*/
/*}}}*/
void metaIndex::swapLoad(metaIndex * const OldMetaIndex) /*{{{*/
{
- std::swap(Entries, OldMetaIndex->Entries);
+ std::swap(SignedBy, OldMetaIndex->SignedBy);
+ std::swap(Suite, OldMetaIndex->Suite);
+ std::swap(Codename, OldMetaIndex->Codename);
std::swap(Date, OldMetaIndex->Date);
std::swap(ValidUntil, OldMetaIndex->ValidUntil);
std::swap(SupportsAcquireByHash, OldMetaIndex->SupportsAcquireByHash);
+ std::swap(Entries, OldMetaIndex->Entries);
std::swap(LoadedSuccessfully, OldMetaIndex->LoadedSuccessfully);
+
+ OldMetaIndex->SetOrigin(d->Origin);
+ OldMetaIndex->SetLabel(d->Label);
+ OldMetaIndex->SetVersion(d->Version);
+ OldMetaIndex->SetDefaultPin(d->DefaultPin);
}
/*}}}*/
@@ -128,3 +153,17 @@ bool metaIndex::IsArchitectureAllSupportedFor(IndexTarget const &target) const/*
return true;
}
/*}}}*/
+bool metaIndex::HasSupportForComponent(std::string const &component) const/*{{{*/
+{
+ debReleaseIndex const * const deb = dynamic_cast<debReleaseIndex const *>(this);
+ if (deb != NULL)
+ return deb->HasSupportForComponent(component);
+ return true;
+}
+ /*}}}*/
+
+void metaIndex::SetOrigin(std::string const &origin) { d->Origin = origin; }
+void metaIndex::SetLabel(std::string const &label) { d->Label = label; }
+void metaIndex::SetVersion(std::string const &version) { d->Version = version; }
+void metaIndex::SetDefaultPin(signed short const defaultpin) { d->DefaultPin = defaultpin; }
+void metaIndex::SetReleaseNotes(std::string const &notes) { d->ReleaseNotes = notes; }
diff --git a/apt-pkg/metaindex.h b/apt-pkg/metaindex.h
index 3a624e86d..91cfce59b 100644
--- a/apt-pkg/metaindex.h
+++ b/apt-pkg/metaindex.h
@@ -15,8 +15,8 @@ class pkgCacheGenerator;
class OpProgress;
#endif
#ifndef APT_8_CLEANER_HEADERS
-#include <apt-pkg/srcrecords.h>
#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/srcrecords.h>
using std::string;
#endif
@@ -25,6 +25,8 @@ class IndexTarget;
class pkgCacheGenerator;
class OpProgress;
+class metaIndexPrivate;
+
class metaIndex
{
public:
@@ -43,7 +45,7 @@ public:
TRI_YES, TRI_DONTCARE, TRI_NO, TRI_UNSET
};
private:
- void * const d;
+ metaIndexPrivate * const d;
protected:
std::vector <pkgIndexFile *> *Indexes;
// parsed from the sources.list
@@ -70,8 +72,13 @@ public:
TriState GetTrusted() const;
std::string GetSignedBy() const;
+ std::string GetOrigin() const;
+ std::string GetLabel() const;
+ std::string GetVersion() const;
std::string GetCodename() const;
std::string GetSuite() const;
+ std::string GetReleaseNotes() const;
+ signed short GetDefaultPin() const;
bool GetSupportsAcquireByHash() const;
time_t GetValidUntil() const;
time_t GetDate() const;
@@ -111,6 +118,13 @@ public:
// FIXME: make virtual on next abi break
bool IsArchitectureSupported(std::string const &arch) const;
bool IsArchitectureAllSupportedFor(IndexTarget const &target) const;
+ bool HasSupportForComponent(std::string const &component) const;
+ // FIXME: should be members of the class on abi break
+ APT_HIDDEN void SetOrigin(std::string const &origin);
+ APT_HIDDEN void SetLabel(std::string const &label);
+ APT_HIDDEN void SetVersion(std::string const &version);
+ APT_HIDDEN void SetDefaultPin(signed short const defaultpin);
+ APT_HIDDEN void SetReleaseNotes(std::string const &notes);
};
#endif
diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc
index 0be0cc8df..c968845ce 100644
--- a/apt-pkg/orderlist.cc
+++ b/apt-pkg/orderlist.cc
@@ -63,19 +63,18 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
-#include <apt-pkg/orderlist.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/depcache.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/orderlist.h>
#include <apt-pkg/pkgcache.h>
-#include <stdlib.h>
-#include <string.h>
#include <algorithm>
#include <iostream>
+#include <stdlib.h>
+#include <string.h>
/*}}}*/
using namespace std;
@@ -93,7 +92,7 @@ pkgOrderList::pkgOrderList(pkgDepCache *pCache) : d(NULL), Cache(*pCache),
/* Construct the arrays, egcs 1.0.1 bug requires the package count
hack */
- unsigned long Size = Cache.Head().PackageCount;
+ auto const Size = Cache.Head().PackageCount;
Flags = new unsigned short[Size];
End = List = new Package *[Size];
memset(Flags,0,sizeof(*Flags)*Size);
@@ -1056,8 +1055,8 @@ bool pkgOrderList::AddLoop(DepIterator D)
/* */
void pkgOrderList::WipeFlags(unsigned long F)
{
- unsigned long Size = Cache.Head().PackageCount;
- for (unsigned long I = 0; I != Size; I++)
+ auto Size = Cache.Head().PackageCount;
+ for (decltype(Size) I = 0; I != Size; ++I)
Flags[I] &= ~F;
}
/*}}}*/
diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h
index 9171c45d6..3fa02342b 100644
--- a/apt-pkg/orderlist.h
+++ b/apt-pkg/orderlist.h
@@ -15,9 +15,8 @@
#ifndef PKGLIB_ORDERLIST_H
#define PKGLIB_ORDERLIST_H
-#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
#include <string>
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index a8537431b..d5a8275c3 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -15,26 +15,25 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/packagemanager.h>
-#include <apt-pkg/orderlist.h>
-#include <apt-pkg/depcache.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/edsp.h>
-#include <apt-pkg/version.h>
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/algorithms.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/edsp.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/install-progress.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/orderlist.h>
+#include <apt-pkg/packagemanager.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/install-progress.h>
#include <apt-pkg/prettyprinters.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/version.h>
-#include <stddef.h>
+#include <iostream>
#include <list>
#include <string>
-#include <iostream>
+#include <stddef.h>
#include <apti18n.h>
/*}}}*/
@@ -937,7 +936,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
if (Debug)
clog << OutputInDepth(Depth) << "Removing " << ConflictPkg.FullName() << " now to avoid " << APT::PrettyDep(&Cache, End) << endl;
// no earlyremove() here as user has already agreed to the permanent removal
- if (SmartRemove(Pkg) == false)
+ if (SmartRemove(ConflictPkg) == false)
return _error->Error("Internal Error, Could not early remove %s (%d)",ConflictPkg.FullName().c_str(), 1);
}
}
diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h
index e4c7a0a0a..d9443443d 100644
--- a/apt-pkg/packagemanager.h
+++ b/apt-pkg/packagemanager.h
@@ -22,13 +22,13 @@
#ifndef PKGLIB_PACKAGEMANAGER_H
#define PKGLIB_PACKAGEMANAGER_H
-#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/init.h>
#include <apt-pkg/edsp.h>
+#include <apt-pkg/init.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
-#include <string>
#include <set>
+#include <string>
#ifndef APT_10_CLEANER_HEADERS
#include <apt-pkg/install-progress.h>
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index c4bf34022..ea34db469 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -20,26 +20,26 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
+#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/mmap.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/policy.h>
-#include <apt-pkg/version.h>
-#include <apt-pkg/error.h>
#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 <apt-pkg/version.h>
-#include <stddef.h>
-#include <string.h>
-#include <sstream>
+#include <zlib.h>
#include <algorithm>
-#include <vector>
+#include <sstream>
#include <string>
+#include <vector>
+#include <stddef.h>
+#include <string.h>
#include <sys/stat.h>
-#include <zlib.h>
#include <apti18n.h>
/*}}}*/
@@ -58,7 +58,7 @@ pkgCache::Header::Header()
/* Whenever the structures change the major version should be bumped,
whenever the generator changes the minor version should be bumped. */
- APT_HEADER_SET(MajorVersion, 11);
+ APT_HEADER_SET(MajorVersion, 12);
APT_HEADER_SET(MinorVersion, 0);
APT_HEADER_SET(Dirty, false);
diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h
index 91228f713..e1597c1b1 100644
--- a/apt-pkg/pkgcache.h
+++ b/apt-pkg/pkgcache.h
@@ -73,13 +73,13 @@
/*}}}*/
#ifndef PKGLIB_PKGCACHE_H
#define PKGLIB_PKGCACHE_H
-
-#include <apt-pkg/mmap.h>
+#define __PKGLIB_IN_PKGCACHE_H
#include <apt-pkg/macros.h>
+#include <apt-pkg/mmap.h>
#include <string>
-#include <time.h>
#include <stdint.h>
+#include <time.h>
#ifdef APT_PKG_EXPOSE_STRING_VIEW
#include <apt-pkg/string_view.h>
@@ -783,10 +783,13 @@ inline char const * pkgCache::NativeArch()
#include <apt-pkg/cacheiterators.h>
-inline pkgCache::GrpIterator pkgCache::GrpBegin()
- {return GrpIterator(*this);}
-inline pkgCache::GrpIterator pkgCache::GrpEnd()
- {return GrpIterator(*this,GrpP);}
+ 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()
@@ -822,4 +825,5 @@ class pkgCache::Namespace /*{{{*/
typedef pkgCache::Flag Flag;
};
/*}}}*/
+#undef __PKGLIB_IN_PKGCACHE_H
#endif
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index e52667fbc..bde0ea122 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -12,30 +12,29 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/pkgcachegen.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/version.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/sourcelist.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/macros.h>
-#include <apt-pkg/metaindex.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/hashsum_template.h>
#include <apt-pkg/indexfile.h>
+#include <apt-pkg/macros.h>
#include <apt-pkg/md5.h>
+#include <apt-pkg/metaindex.h>
#include <apt-pkg/mmap.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcachegen.h>
+#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/version.h>
-#include <stddef.h>
-#include <string.h>
+#include <algorithm>
#include <iostream>
+#include <memory>
#include <string>
#include <vector>
-#include <memory>
-#include <algorithm>
+#include <stddef.h>
+#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h
index cb51c113a..e11e97e09 100644
--- a/apt-pkg/pkgcachegen.h
+++ b/apt-pkg/pkgcachegen.h
@@ -18,14 +18,13 @@
#ifndef PKGLIB_PKGCACHEGEN_H
#define PKGLIB_PKGCACHEGEN_H
+#include <apt-pkg/macros.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>
+#include <vector>
#if __cplusplus >= 201103L
#include <unordered_set>
#endif
diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc
index ef4c17cd2..8a5089d8a 100644
--- a/apt-pkg/pkgrecords.cc
+++ b/apt-pkg/pkgrecords.cc
@@ -9,16 +9,15 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
-#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/indexfile.h>
#include <apt-pkg/error.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 <vector>
+#include <stddef.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h
index 7c50c5d41..bdbd31a78 100644
--- a/apt-pkg/pkgrecords.h
+++ b/apt-pkg/pkgrecords.h
@@ -17,9 +17,9 @@
#ifndef PKGLIB_PKGRECORDS_H
#define PKGLIB_PKGRECORDS_H
-#include <apt-pkg/pkgcache.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
#include <string>
#include <vector>
diff --git a/apt-pkg/pkgsystem.cc b/apt-pkg/pkgsystem.cc
index b1c6cc1ea..aa94418c6 100644
--- a/apt-pkg/pkgsystem.cc
+++ b/apt-pkg/pkgsystem.cc
@@ -10,15 +10,15 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
#include <apt-pkg/debsystem.h>
-#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgsystem.h>
-#include <map>
#include <cassert>
#include <cstring>
+#include <map>
/*}}}*/
pkgSystem *_system = 0;
diff --git a/apt-pkg/pkgsystem.h b/apt-pkg/pkgsystem.h
index affaa5c9a..4b13072e2 100644
--- a/apt-pkg/pkgsystem.h
+++ b/apt-pkg/pkgsystem.h
@@ -37,7 +37,6 @@
#define PKGLIB_PKGSYSTEM_H
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <vector>
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index 3dd6ddac4..008c98ecb 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -13,27 +13,26 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
-#include <apt-pkg/policy.h>
-#include <apt-pkg/configuration.h>
#include <apt-pkg/cachefilter.h>
-#include <apt-pkg/tagfile.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/fileutl.h>
+#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/versionmatch.h>
+#include <apt-pkg/policy.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/tagfile.h>
#include <apt-pkg/version.h>
+#include <apt-pkg/versionmatch.h>
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <vector>
#include <ctype.h>
#include <stddef.h>
#include <string.h>
-#include <string>
-#include <vector>
-#include <iostream>
-#include <sstream>
#include <apti18n.h>
/*}}}*/
@@ -50,12 +49,14 @@ pkgPolicy::pkgPolicy(pkgCache *Owner) : Pins(nullptr), VerPins(nullptr),
if (Owner == 0)
return;
PFPriority = new signed short[Owner->Head().PackageFileCount];
- Pins = new Pin[Owner->Head().PackageCount];
+ auto PackageCount = Owner->Head().PackageCount;
+ Pins = new Pin[PackageCount];
VerPins = new Pin[Owner->Head().VersionCount];
- for (unsigned long I = 0; I != Owner->Head().PackageCount; I++)
+ for (decltype(PackageCount) I = 0; I != PackageCount; ++I)
Pins[I].Type = pkgVersionMatch::None;
- for (unsigned long I = 0; I != Owner->Head().VersionCount; I++)
+ auto VersionCount = Owner->Head().VersionCount;
+ for (decltype(VersionCount) I = 0; I != VersionCount; ++I)
VerPins[I].Type = pkgVersionMatch::None;
// The config file has a master override.
diff --git a/apt-pkg/policy.h b/apt-pkg/policy.h
index 943332bbb..bcd1daf3e 100644
--- a/apt-pkg/policy.h
+++ b/apt-pkg/policy.h
@@ -34,11 +34,10 @@
#include <apt-pkg/depcache.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/versionmatch.h>
-#include <vector>
#include <string>
+#include <vector>
#ifndef APT_8_CLEANER_HEADERS
using std::vector;
diff --git a/apt-pkg/prettyprinters.h b/apt-pkg/prettyprinters.h
index 51d9f81a0..40f9d6628 100644
--- a/apt-pkg/prettyprinters.h
+++ b/apt-pkg/prettyprinters.h
@@ -1,7 +1,7 @@
#ifndef APT_PRETTYPRINTERS_H
#define APT_PRETTYPRINTERS_H
-#include <apt-pkg/pkgcache.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
class pkgDepCache;
diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc
index df2e0b46d..17c5c7a11 100644
--- a/apt-pkg/sourcelist.cc
+++ b/apt-pkg/sourcelist.cc
@@ -8,31 +8,30 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
-#include <apt-pkg/sourcelist.h>
#include <apt-pkg/cmndline.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/debindexfile.h>
+#include <apt-pkg/debsrcrecords.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/metaindex.h>
#include <apt-pkg/indexfile.h>
-#include <apt-pkg/tagfile.h>
+#include <apt-pkg/metaindex.h>
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
-#include <apt-pkg/debindexfile.h>
-#include <apt-pkg/debsrcrecords.h>
+#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/tagfile.h>
-#include <ctype.h>
-#include <stddef.h>
-#include <time.h>
+#include <algorithm>
#include <cstring>
+#include <fstream>
#include <map>
#include <string>
#include <vector>
-#include <fstream>
-#include <algorithm>
+#include <ctype.h>
+#include <stddef.h>
+#include <time.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h
index 65f9c2b89..fedf90fa6 100644
--- a/apt-pkg/sourcelist.h
+++ b/apt-pkg/sourcelist.h
@@ -22,15 +22,14 @@
#ifndef PKGLIB_SOURCELIST_H
#define PKGLIB_SOURCELIST_H
-#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
#include <time.h>
+#include <map>
#include <string>
#include <vector>
-#include <map>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/tagfile.h>
diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc
index a76604a8d..0c0c7a9fc 100644
--- a/apt-pkg/srcrecords.cc
+++ b/apt-pkg/srcrecords.cc
@@ -11,19 +11,19 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
-#include <apt-pkg/srcrecords.h>
#include <apt-pkg/debsrcrecords.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/metaindex.h>
#include <apt-pkg/indexfile.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/metaindex.h>
+#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/srcrecords.h>
-#include <string.h>
#include <string>
#include <vector>
+#include <string.h>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-pkg/srcrecords.h b/apt-pkg/srcrecords.h
index a3c8444de..8c52f5683 100644
--- a/apt-pkg/srcrecords.h
+++ b/apt-pkg/srcrecords.h
@@ -12,8 +12,8 @@
#ifndef PKGLIB_SRCRECORDS_H
#define PKGLIB_SRCRECORDS_H
-#include <apt-pkg/macros.h>
#include <apt-pkg/hashes.h>
+#include <apt-pkg/macros.h>
#include <string>
#include <vector>
diff --git a/apt-pkg/statechanges.cc b/apt-pkg/statechanges.cc
index 35af45538..258c84885 100644
--- a/apt-pkg/statechanges.cc
+++ b/apt-pkg/statechanges.cc
@@ -1,9 +1,9 @@
-#include <apt-pkg/pkgcache.h>
#include <apt-pkg/cacheset.h>
#include <apt-pkg/debsystem.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/statechanges.h>
+#include <apt-pkg/pkgcache.h>
#include <apt-pkg/prettyprinters.h>
+#include <apt-pkg/statechanges.h>
#include <algorithm>
#include <memory>
diff --git a/apt-pkg/statechanges.h b/apt-pkg/statechanges.h
index 1eaf21a3a..2f63d516d 100644
--- a/apt-pkg/statechanges.h
+++ b/apt-pkg/statechanges.h
@@ -1,6 +1,6 @@
-#include <apt-pkg/pkgcache.h>
#include <apt-pkg/cacheset.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
#include <memory>
diff --git a/apt-pkg/tagfile-compat.cc b/apt-pkg/tagfile-compat.cc
index fe53e2974..e2cab474e 100644
--- a/apt-pkg/tagfile-compat.cc
+++ b/apt-pkg/tagfile-compat.cc
@@ -13,7 +13,7 @@
##################################################################### */
/*}}}*/
-#include<config.h>
+#include <config.h>
#define APT_COMPILING_TAGFILE_COMPAT_CC
#include <apt-pkg/tagfile.h>
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index d9519175e..7de5c055b 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -11,20 +11,20 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
-#include <apt-pkg/tagfile.h>
-#include <apt-pkg/tagfile-keys.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/string_view.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/tagfile-keys.h>
+#include <apt-pkg/tagfile.h>
#include <list>
#include <string>
-#include <stdio.h>
#include <ctype.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
index e02e7332e..c4dc50a10 100644
--- a/apt-pkg/tagfile.h
+++ b/apt-pkg/tagfile.h
@@ -21,12 +21,12 @@
#include <apt-pkg/macros.h>
-#include <stdio.h>
#include <stdint.h>
+#include <stdio.h>
+#include <list>
#include <string>
#include <vector>
-#include <list>
#ifdef APT_PKG_EXPOSE_STRING_VIEW
#include <apt-pkg/string_view.h>
#endif
diff --git a/apt-pkg/update.cc b/apt-pkg/update.cc
index f7075c446..4c64eeb5d 100644
--- a/apt-pkg/update.cc
+++ b/apt-pkg/update.cc
@@ -2,11 +2,11 @@
#include <config.h>
#include <apt-pkg/acquire-item.h>
+#include <apt-pkg/acquire.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/acquire.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/update.h>
diff --git a/apt-pkg/upgrade.cc b/apt-pkg/upgrade.cc
index a61789c11..c9432aa64 100644
--- a/apt-pkg/upgrade.cc
+++ b/apt-pkg/upgrade.cc
@@ -3,13 +3,12 @@
#include <apt-pkg/algorithms.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/depcache.h>
#include <apt-pkg/edsp.h>
#include <apt-pkg/error.h>
+#include <apt-pkg/pkgcache.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 <string>
diff --git a/apt-pkg/upgrade.h b/apt-pkg/upgrade.h
index 2d9c0fa36..5612acfcb 100644
--- a/apt-pkg/upgrade.h
+++ b/apt-pkg/upgrade.h
@@ -10,8 +10,8 @@
#ifndef PKGLIB_UPGRADE_H
#define PKGLIB_UPGRADE_H
-#include <stddef.h>
#include <apt-pkg/macros.h>
+#include <stddef.h>
class pkgDepCache;
class OpProgress;
diff --git a/apt-pkg/version.cc b/apt-pkg/version.cc
index f32d39a69..8db311179 100644
--- a/apt-pkg/version.cc
+++ b/apt-pkg/version.cc
@@ -8,12 +8,12 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
#include <apt-pkg/version.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
/*}}}*/
static pkgVersioningSystem *VSList[10];
diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc
index 2376ca8fd..8106a150e 100644
--- a/apt-pkg/versionmatch.cc
+++ b/apt-pkg/versionmatch.cc
@@ -11,22 +11,21 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include<config.h>
+#include <config.h>
-#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 <apt-pkg/strutl.h>
+#include <apt-pkg/versionmatch.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
#include <string>
-#include <stdio.h>
#include <ctype.h>
#include <fnmatch.h>
#include <regex.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
/*}}}*/
using std::string;
diff --git a/apt-pkg/versionmatch.h b/apt-pkg/versionmatch.h
index 156ad61cb..ce8f95de5 100644
--- a/apt-pkg/versionmatch.h
+++ b/apt-pkg/versionmatch.h
@@ -36,7 +36,6 @@
#define PKGLIB_VERSIONMATCH_H
#include <apt-pkg/pkgcache.h>
-#include <apt-pkg/cacheiterators.h>
#include <string>