summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/CMakeLists.txt6
-rw-r--r--apt-pkg/acquire-item.cc6
-rw-r--r--apt-pkg/acquire-item.h2
-rw-r--r--apt-pkg/acquire-method.cc2
-rw-r--r--apt-pkg/acquire-worker.cc8
-rw-r--r--apt-pkg/acquire.cc28
-rw-r--r--apt-pkg/acquire.h10
-rw-r--r--apt-pkg/algorithms.cc12
-rw-r--r--apt-pkg/aptconfiguration.cc2
-rw-r--r--apt-pkg/cachefilter.cc95
-rw-r--r--apt-pkg/cacheset.cc4
-rw-r--r--apt-pkg/cacheset.h4
-rw-r--r--apt-pkg/cdrom.cc2
-rw-r--r--apt-pkg/contrib/cmndline.cc14
-rw-r--r--apt-pkg/contrib/configuration.cc168
-rw-r--r--apt-pkg/contrib/error.h2
-rw-r--r--apt-pkg/contrib/fileutl.cc2
-rw-r--r--apt-pkg/contrib/gpgv.cc50
-rw-r--r--apt-pkg/contrib/mmap.cc6
-rw-r--r--apt-pkg/contrib/mmap.h2
-rw-r--r--apt-pkg/contrib/proxy.cc2
-rw-r--r--apt-pkg/contrib/strutl.cc18
-rw-r--r--apt-pkg/contrib/strutl.h2
-rw-r--r--apt-pkg/deb/deblistparser.cc43
-rw-r--r--apt-pkg/deb/deblistparser.h11
-rw-r--r--apt-pkg/deb/debmetaindex.cc20
-rw-r--r--apt-pkg/deb/debrecords.h4
-rw-r--r--apt-pkg/deb/debsrcrecords.cc12
-rw-r--r--apt-pkg/deb/dpkgpm.cc23
-rw-r--r--apt-pkg/depcache.cc6
-rw-r--r--apt-pkg/depcache.h2
-rw-r--r--apt-pkg/edsp.cc8
-rw-r--r--apt-pkg/edsp.h2
-rw-r--r--apt-pkg/indexfile.h2
-rw-r--r--apt-pkg/init.cc92
-rw-r--r--apt-pkg/orderlist.cc8
-rw-r--r--apt-pkg/packagemanager.cc6
-rw-r--r--apt-pkg/packagemanager.h2
-rw-r--r--apt-pkg/pkgcache.cc4
-rw-r--r--apt-pkg/pkgcachegen.cc61
-rw-r--r--apt-pkg/pkgrecords.h2
-rw-r--r--apt-pkg/policy.h2
-rw-r--r--apt-pkg/tagfile-order.c1
-rw-r--r--apt-pkg/tagfile.cc2
-rw-r--r--apt-pkg/tagfile.h2
-rw-r--r--apt-pkg/update.h4
-rw-r--r--apt-pkg/upgrade.cc2
-rw-r--r--apt-pkg/upgrade.h4
48 files changed, 612 insertions, 160 deletions
diff --git a/apt-pkg/CMakeLists.txt b/apt-pkg/CMakeLists.txt
index 3620b66e9..8d7fcd9e6 100644
--- a/apt-pkg/CMakeLists.txt
+++ b/apt-pkg/CMakeLists.txt
@@ -4,7 +4,7 @@ include_directories(${PROJECT_BINARY_DIR}/include/apt-pkg)
add_definitions("-DAPT_PKG_EXPOSE_STRING_VIEW")
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/apt-pkg/)
-execute_process(COMMAND ${PROJECT_SOURCE_DIR}/triehash/triehash.pl
+execute_process(COMMAND ${PERL_EXECUTABLE} ${PROJECT_SOURCE_DIR}/triehash/triehash.pl
--ignore-case
--header ${PROJECT_BINARY_DIR}/include/apt-pkg/tagfile-keys.h
--code ${CMAKE_CURRENT_BINARY_DIR}/tagfile-keys.cc
@@ -29,7 +29,9 @@ execute_process(COMMAND grep "^#define APT_PKG_RELEASE"
message(STATUS "Building libapt-pkg ${MAJOR} (release ${MINOR})")
set(APT_PKG_MAJOR ${MAJOR} PARENT_SCOPE) # exporting for methods/CMakeLists.txt
-# Definition of the C++ files used to build the library
+# Definition of the C++ files used to build the library - note that this
+# is expanded at CMake time, so you have to rerun cmake if you add or remove
+# a file (you can just run cmake . in the build directory)
file(GLOB_RECURSE library "*.cc" "${CMAKE_CURRENT_BINARY_DIR}/tagfile-keys.cc")
file(GLOB_RECURSE headers "*.h")
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 82bf8a1eb..231c5eed9 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -1913,7 +1913,7 @@ void pkgAcqMetaSig::Done(string const &Message, HashStringList const &Hashes,
{
auto const Releasegpg = GetFinalFilename();
auto const Release = MetaIndex->GetFinalFilename();
- // if this is an IMS-Hit on Release ensure we also have the the Release.gpg file stored
+ // if this is an IMS-Hit on Release ensure we also have the Release.gpg file stored
// (previously an unknown pubkey) – but only if the Release file exists locally (unlikely
// event of InRelease removed from the mirror causing fallback but still an IMS-Hit)
if (TransactionManager->IMSHit == false ||
@@ -2898,7 +2898,7 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire * const Owner,
<< TransactionManager << std::endl;
}
/*}}}*/
-// AcqIndex::Init - defered Constructor /*{{{*/
+// AcqIndex::Init - deferred Constructor /*{{{*/
static void NextCompressionExtension(std::string &CurrentCompressionExtension, std::string &CompressionExtensions, bool const preview)
{
size_t const nextExt = CompressionExtensions.find(' ');
@@ -3642,7 +3642,7 @@ std::string pkgAcqChangelog::URI(std::string const &Template,
if (Template.find("@CHANGEPATH@") == std::string::npos)
return "";
- // the path is: COMPONENT/SRC/SRCNAME/SRCNAME_SRCVER, e.g. main/a/apt/1.1 or contrib/liba/libapt/2.0
+ // the path is: COMPONENT/SRC/SRCNAME/SRCNAME_SRCVER, e.g. main/a/apt/apt_1.1 or contrib/liba/libapt/libapt_2.0
std::string Src = SrcName;
std::string path = APT::String::Startswith(SrcName, "lib") ? Src.substr(0, 4) : Src.substr(0,1);
path.append("/").append(Src).append("/");
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index 8be8801bf..7741dbf22 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -114,7 +114,7 @@ class pkgAcquire::Item : public WeakPointable /*{{{*/
/** \brief A client-supplied unique identifier.
*
- * This field is initalized to 0; it is meant to be filled in by
+ * This field is initialized to 0; it is meant to be filled in by
* clients that wish to use it to uniquely identify items.
*
* APT progress reporting will store an ID there as shown in "Get:42 …"
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index 39d5e61f2..ab0908014 100644
--- a/apt-pkg/acquire-method.cc
+++ b/apt-pkg/acquire-method.cc
@@ -239,7 +239,7 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
Dequeue();
}
/*}}}*/
-// AcqMethod::MediaFail - Syncronous request for new media /*{{{*/
+// AcqMethod::MediaFail - Synchronous request for new media /*{{{*/
// ---------------------------------------------------------------------
/* This sends a 403 Media Failure message to the APT and waits for it
to be ackd */
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index 7d6e6f79c..c15e7ab4c 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -664,6 +664,8 @@ bool pkgAcquire::Worker::QueueItem(pkgAcquire::Queue::QItem *Item)
if (isDoomedItem(Item->Owner))
return true;
+ Item->SyncDestinationFiles();
+
string Message = "600 URI Acquire\n";
Message.reserve(300);
Message += "URI: " + Item->URI;
@@ -673,7 +675,9 @@ bool pkgAcquire::Worker::QueueItem(pkgAcquire::Queue::QItem *Item)
for (HashStringList::const_iterator hs = hsl.begin(); hs != hsl.end(); ++hs)
Message += "\nExpected-" + hs->HashType() + ": " + hs->HashValue();
- if (hsl.FileSize() == 0)
+ Message += Item->Custom600Headers();
+
+ if (hsl.FileSize() == 0 && Message.find("\nMaximum-Size: ") == std::string::npos)
{
unsigned long long FileSize = Item->GetMaximumSize();
if(FileSize > 0)
@@ -684,8 +688,6 @@ bool pkgAcquire::Worker::QueueItem(pkgAcquire::Queue::QItem *Item)
}
}
- Item->SyncDestinationFiles();
- Message += Item->Custom600Headers();
Message += "\n\n";
if (RealFileExists(Item->Owner->DestFile))
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 4ccfa2605..3f7f2bbf0 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -117,6 +117,12 @@ static bool SetupAPTPartialDirectory(std::string const &grand, std::string const
if (chmod(partial.c_str(), 0700) != 0)
_error->WarningE("SetupAPTPartialDirectory", "chmod 0700 of directory %s failed", partial.c_str());
+ _error->PushToStack();
+ // remove 'old' FAILED files to stop us from collecting them for no reason
+ for (auto const &Failed: GetListOfFilesInDir(partial, "FAILED", false, false))
+ RemoveFile("SetupAPTPartialDirectory", Failed);
+ _error->RevertToStack();
+
return true;
}
bool pkgAcquire::Setup(pkgAcquireStatus *Progress, string const &Lock)
@@ -640,7 +646,7 @@ static void CheckDropPrivsMustBeDisabled(pkgAcquire const &Fetcher)
// if destination file is inaccessible all hope is lost for privilege dropping
if (IsAccessibleBySandboxUser((*I)->DestFile, true) == false)
{
- _error->WarningE("pkgAcquire::Run", _("Can't drop privileges for downloading as file '%s' couldn't be accessed by user '%s'."),
+ _error->WarningE("pkgAcquire::Run", _("Download is performed unsandboxed as root as file '%s' couldn't be accessed by user '%s'."),
(*I)->DestFile.c_str(), SandboxUser.c_str());
_config->Set("APT::Sandbox::User", "");
break;
@@ -657,7 +663,7 @@ static void CheckDropPrivsMustBeDisabled(pkgAcquire const &Fetcher)
if (IsAccessibleBySandboxUser(source.Path, false) == false)
{
- _error->NoticeE("pkgAcquire::Run", _("Can't drop privileges for downloading as file '%s' couldn't be accessed by user '%s'."),
+ _error->NoticeE("pkgAcquire::Run", _("Download is performed unsandboxed as root as file '%s' couldn't be accessed by user '%s'."),
source.Path.c_str(), SandboxUser.c_str());
_config->CndSet("Binary::file::APT::Sandbox::User", "root");
_config->CndSet("Binary::copy::APT::Sandbox::User", "root");
@@ -912,11 +918,27 @@ pkgAcquire::Queue::~Queue()
/* */
bool pkgAcquire::Queue::Enqueue(ItemDesc &Item)
{
+ // MetaKeysMatch checks whether the two items have no non-matching
+ // meta-keys. If the items are not transaction items, it returns
+ // true, so other items can still be merged.
+ auto MetaKeysMatch = [](pkgAcquire::ItemDesc const &A, pkgAcquire::Queue::QItem const *B) {
+ auto OwnerA = dynamic_cast<pkgAcqTransactionItem*>(A.Owner);
+ if (OwnerA == nullptr)
+ return true;
+
+ for (auto const & OwnerBUncast : B->Owners) {
+ auto OwnerB = dynamic_cast<pkgAcqTransactionItem*>(OwnerBUncast);
+
+ if (OwnerB != nullptr && OwnerA->GetMetaKey() != OwnerB->GetMetaKey())
+ return false;
+ }
+ return true;
+ };
QItem **OptimalI = &Items;
QItem **I = &Items;
// move to the end of the queue and check for duplicates here
for (; *I != 0; ) {
- if (Item.URI == (*I)->URI)
+ if (Item.URI == (*I)->URI && MetaKeysMatch(Item, *I))
{
if (_config->FindB("Debug::pkgAcquire::Worker",false) == true)
std::cerr << " @ Queue: Action combined for " << Item.URI << " and " << (*I)->URI << std::endl;
diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h
index 1fae662f8..5f1212338 100644
--- a/apt-pkg/acquire.h
+++ b/apt-pkg/acquire.h
@@ -10,11 +10,11 @@
Each file to download is represented by an Acquire::Item class subclassed
into a specialization. The Item class can add itself to several URI
- acquire queues each prioritized by the download scheduler. When the
- system is run the proper URI handlers are spawned and the the acquire
+ acquire queues each prioritized by the download scheduler. When the
+ system is run the proper URI handlers are spawned and the acquire
queues are fed into the handlers by the schedular until the queues are
empty. This allows for an Item to be downloaded from an alternate source
- if the first try turns out to fail. It also alows concurrent downloading
+ if the first try turns out to fail. It also allows concurrent downloading
of multiple items from multiple sources as well as dynamic balancing
of load between the sources.
@@ -241,7 +241,7 @@ class pkgAcquire
*/
bool RunFdsSane(fd_set *RSet,fd_set *WSet);
- // just here for compatbility, needs to be removed on the next
+ // just here for compatibility, needs to be removed on the next
// ABI/API break. RunFdsSane() is what should be used as it
// returns if there is an error condition on one of the fds
virtual void RunFds(fd_set *RSet,fd_set *WSet);
@@ -395,7 +395,7 @@ class pkgAcquire
/** \brief Represents a single download source from which an item
* should be downloaded.
*
- * An item may have several assocated ItemDescs over its lifetime.
+ * An item may have several associated ItemDescs over its lifetime.
*/
struct pkgAcquire::ItemDesc : public WeakPointable
{
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 65c5ff85d..95e756c15 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -1051,7 +1051,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
}
}
- // Hm, nothing can possibly satisify this dep. Nuke it.
+ // Hm, nothing can possibly satisfy this dep. Nuke it.
if (VList[0] == 0 &&
Start.IsNegative() == false &&
(Flags[I->ID] & Protected) != Protected)
@@ -1144,7 +1144,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
pkgCache::PkgIterator I = Cache.PkgBegin();
for (;I.end() != true; ++I) {
if (Cache[I].NewInstall() && !(Flags[I->ID] & PreInstalled)) {
- if(_config->FindI("Debug::pkgAutoRemove",false)) {
+ if(_config->FindB("Debug::pkgAutoRemove",false)) {
std::clog << "Resolve installed new pkg: " << I.FullName(false)
<< " (now marking it as auto)" << std::endl;
}
@@ -1189,7 +1189,7 @@ bool pkgProblemResolver::InstOrNewPolicyBroken(pkgCache::PkgIterator I)
/*}}}*/
// ProblemResolver::ResolveByKeep - Resolve problems using keep /*{{{*/
// ---------------------------------------------------------------------
-/* This is the work horse of the soft upgrade routine. It is very gental
+/* This is the work horse of the soft upgrade routine. It is very gentle
in that it does not install or remove any packages. It is assumed that the
system was non-broken previously. */
bool pkgProblemResolver::ResolveByKeep(OpProgress * const Progress)
@@ -1204,7 +1204,7 @@ bool pkgProblemResolver::ResolveByKeep(OpProgress * const Progress)
/*}}}*/
// ProblemResolver::ResolveByKeepInternal - Resolve problems using keep /*{{{*/
// ---------------------------------------------------------------------
-/* This is the work horse of the soft upgrade routine. It is very gental
+/* This is the work horse of the soft upgrade routine. It is very gentle
in that it does not install or remove any packages. It is assumed that the
system was non-broken previously. */
bool pkgProblemResolver::ResolveByKeepInternal()
@@ -1283,7 +1283,7 @@ bool pkgProblemResolver::ResolveByKeepInternal()
continue;
/* Hm, the group is broken.. I suppose the best thing to do is to
- is to try every combination of keep/not-keep for the set, but thats
+ is to try every combination of keep/not-keep for the set, but that's
slow, and this never happens, just be conservative and assume the
list of ors is in preference and keep till it starts to work. */
while (true)
@@ -1373,7 +1373,7 @@ void pkgProblemResolver::InstallProtect()
/*}}}*/
// PrioSortList - Sort a list of versions by priority /*{{{*/
// ---------------------------------------------------------------------
-/* This is ment to be used in conjunction with AllTargets to get a list
+/* This is meant to be used in conjunction with AllTargets to get a list
of versions ordered by preference. */
struct PrioComp {
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index 86c9c6af1..a0ba648b4 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -322,7 +322,7 @@ std::vector<std::string> const Configuration::getArchitectures(bool const &Cache
string const arch = _config->Find("APT::Architecture");
archs = _config->FindVector("APT::Architectures");
- if (archs.empty() == true)
+ if (archs.empty() == true && _system != nullptr)
archs = _system->ArchitecturesSupported();
if (archs.empty() == true ||
diff --git a/apt-pkg/cachefilter.cc b/apt-pkg/cachefilter.cc
index b1adf5de3..cc4cdf73c 100644
--- a/apt-pkg/cachefilter.cc
+++ b/apt-pkg/cachefilter.cc
@@ -14,7 +14,9 @@
#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>
@@ -22,6 +24,9 @@
#include <apti18n.h>
/*}}}*/
namespace APT {
+
+APT_HIDDEN std::unordered_map<std::string, std::vector<std::string>> ArchToTupleMap;
+
namespace CacheFilter {
APT_CONST Matcher::~Matcher() {}
APT_CONST PackageMatcher::~PackageMatcher() {}
@@ -68,38 +73,72 @@ bool PackageNameMatchesFnmatch::operator() (pkgCache::GrpIterator const &Grp) {
return fnmatch(Pattern.c_str(), Grp.Name(), FNM_CASEFOLD) == 0;
}
/*}}}*/
-// Architecture matches <libc>-<kernel>-<cpu> specification /*{{{*/
+// Architecture matches <abi>-<libc>-<kernel>-<cpu> specification /*{{{*/
//----------------------------------------------------------------------
-/* The complete architecture, consisting of <libc>-<kernel>-<cpu>. */
-static std::string CompleteArch(std::string const &arch, bool const isPattern) {
- auto const found = arch.find('-');
- if (found != std::string::npos)
+
+static std::vector<std::string> ArchToTuple(std::string arch) {
+ // Strip leading linux- from arch if present
+ // dpkg says this may disappear in the future
+ if (APT::String::Startswith(arch, std::string("linux-")))
+ arch = arch.substr(6);
+
+ auto it = ArchToTupleMap.find(arch);
+ if (it != ArchToTupleMap.end())
+ {
+ std::vector<std::string> result = it->second;
+ // Hack in support for triplets
+ if (result.size() == 3)
+ result.emplace(result.begin(), "base");
+ return result;
+ } else
{
- // ensure that only -any- is replaced and not something like company-
- std::string complete = std::string("-").append(arch).append("-");
- size_t pos = 0;
- char const * const search = "-any-";
- auto const search_len = strlen(search) - 2;
- while((pos = complete.find(search, pos)) != std::string::npos) {
- complete.replace(pos + 1, search_len, "*");
- pos += 2;
+ return {};
+ }
+}
+
+static std::vector<std::string> PatternToTuple(std::string const &arch) {
+ std::vector<std::string> tuple = VectorizeString(arch, '-');
+ if (std::find(tuple.begin(), tuple.end(), std::string("any")) != tuple.end() ||
+ std::find(arch.begin(), arch.end(), '*') != arch.end()) {
+ while (tuple.size() < 4) {
+ tuple.emplace(tuple.begin(), "any");
+ }
+ return tuple;
+ } else
+ return ArchToTuple(arch);
+}
+
+/* The complete architecture, consisting of <abi>-<libc>-<kernel>-<cpu>. */
+static std::string CompleteArch(std::string const &arch, bool const isPattern) {
+ auto tuple = isPattern ? PatternToTuple(arch) : ArchToTuple(arch);
+
+ // Bah, the commandline will try and pass us stuff like amd64- -- we need
+ // that not to match an architecture, but the code below would turn it into
+ // a valid tuple. Let's just use an invalid tuple here.
+ if (APT::String::Endswith(arch, "-") || APT::String::Startswith(arch, "-"))
+ return "invalid-invalid-invalid-invalid";
+
+ if (tuple.empty()) {
+ // Fallback for unknown architectures
+ // Patterns never fail if they contain wildcards, so by this point, arch
+ // has no wildcards.
+ tuple = VectorizeString(arch, '-');
+ switch (tuple.size()) {
+ case 1:
+ tuple.emplace(tuple.begin(), "linux");
+ /* fall through */
+ case 2:
+ tuple.emplace(tuple.begin(), "gnu");
+ /* fall through */
+ case 3:
+ tuple.emplace(tuple.begin(), "base");
+ /* fall through */
+ break;
}
- complete = complete.substr(1, complete.size()-2);
- if (arch.find('-', found+1) != std::string::npos)
- // <libc>-<kernel>-<cpu> format
- return complete;
- // <kernel>-<cpu> format
- else if (isPattern)
- return "*-" + complete;
- else
- return "gnu-" + complete;
}
- else if (arch == "any")
- return "*-*-*";
- else if (isPattern)
- return "*-linux-" + arch;
- else
- return "gnu-linux-" + arch;
+
+ std::replace(tuple.begin(), tuple.end(), std::string("any"), std::string("*"));
+ return APT::String::Join(tuple, "-");
}
PackageArchitectureMatchesSpecification::PackageArchitectureMatchesSpecification(std::string const &pattern, bool const pisPattern) :
literal(pattern), complete(CompleteArch(pattern, pisPattern)), isPattern(pisPattern) {
diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc
index 816925c4d..f8ab7acb9 100644
--- a/apt-pkg/cacheset.cc
+++ b/apt-pkg/cacheset.cc
@@ -858,7 +858,7 @@ APT_IGNORE_DEPRECATED_PUSH
case TASK: showTaskSelection(pkg, pattern); break;
case FNMATCH: showFnmatchSelection(pkg, pattern); break;
APT_IGNORE_DEPRECATED_POP
- case PACKAGENAME: /* no suprises here */ break;
+ case PACKAGENAME: /* no surprises here */ break;
case STRING: /* handled by the special cases */ break;
case UNKNOWN: break;
}
@@ -898,7 +898,7 @@ APT_IGNORE_DEPRECATED_POP
case INSTCAND:
case ALL:
case CANDANDINST:
- // not really suprises, but in fact: just not implemented
+ // not really surprises, but in fact: just not implemented
break;
}
}
diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h
index 7edeac4af..1ac61af59 100644
--- a/apt-pkg/cacheset.h
+++ b/apt-pkg/cacheset.h
@@ -465,7 +465,7 @@ APT_IGNORE_DEPRECATED_POP
/** \brief returns all packages in the cache who belong to the given task
A simple helper responsible for search for all members of a task
- in the cache. Optional it prints a a notice about the
+ in the cache. Optional it prints a notice about the
packages chosen cause of the given task.
\param Cache the packages are in
\param pattern name of the task
@@ -483,7 +483,7 @@ APT_IGNORE_DEPRECATED_POP
/** \brief returns all packages in the cache whose name matchs a given pattern
A simple helper responsible for executing a regular expression on all
- package names in the cache. Optional it prints a a notice about the
+ package names in the cache. Optional it prints a notice about the
packages chosen cause of the given package.
\param Cache the packages are in
\param pattern regular expression for package names
diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index d83d05f9e..a3248fc17 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -67,7 +67,7 @@ bool pkgCdrom::FindPackages(string CD,
InfoDir = InfoDir + CD + ".disk/";
}
- // Don't look into directories that have been marked to ingore.
+ // Don't look into directories that have been marked to ignore.
if (RealFileExists(".aptignr") == true)
return true;
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index c8a6e2787..029ec3060 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -402,21 +402,27 @@ void CommandLine::SaveInConfig(unsigned int const &argc, char const * const * co
bool closeQuote = false;
for (unsigned int i = 0; i < argc && length < sizeof(cmdline); ++i, ++length)
{
- for (unsigned int j = 0; argv[i][j] != '\0' && length < sizeof(cmdline)-1; ++j, ++length)
+ for (unsigned int j = 0; argv[i][j] != '\0' && length < sizeof(cmdline)-2; ++j)
{
- cmdline[length] = argv[i][j];
+ // we can't really sensibly deal with quoting so skip it
+ if (strchr("\"\'\r\n", argv[i][j]) != nullptr)
+ continue;
+ cmdline[length++] = argv[i][j];
if (lastWasOption == true && argv[i][j] == '=')
{
// That is possibly an option: Quote it if it includes spaces,
// the benefit is that this will eliminate also most false positives
const char* c = strchr(&argv[i][j+1], ' ');
if (c == NULL) continue;
- cmdline[++length] = '"';
+ cmdline[length++] = '\'';
closeQuote = true;
}
}
if (closeQuote == true)
- cmdline[length++] = '"';
+ {
+ cmdline[length++] = '\'';
+ closeQuote = false;
+ }
// Problem: detects also --hello
if (cmdline[length-1] == 'o')
lastWasOption = true;
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 9007bf9ec..78a98d614 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -31,10 +31,13 @@
#include <string.h>
#include <algorithm>
+#include <iterator>
#include <string>
#include <stack>
#include <vector>
#include <fstream>
+#include <sstream>
+#include <unordered_map>
#include <apti18n.h>
@@ -43,6 +46,155 @@ using namespace std;
Configuration *_config = new Configuration;
+/* TODO: This config verification shouldn't be using a static variable
+ but a Cnf-member – but that would need ABI breaks and stuff and for now
+ that really is an apt-dev-only tool, so it isn't that bad that it is
+ unusable and allaround a bit strange */
+enum class APT_HIDDEN ConfigType { UNDEFINED, INT, BOOL, STRING, STRING_OR_BOOL, STRING_OR_LIST, FILE, DIR, LIST, PROGRAM_PATH = FILE };
+APT_HIDDEN std::unordered_map<std::string, ConfigType> apt_known_config {};
+static std::string getConfigTypeString(ConfigType const type) /*{{{*/
+{
+ switch (type)
+ {
+ case ConfigType::UNDEFINED: return "UNDEFINED";
+ case ConfigType::INT: return "INT";
+ case ConfigType::BOOL: return "BOOL";
+ case ConfigType::STRING: return "STRING";
+ case ConfigType::STRING_OR_BOOL: return "STRING_OR_BOOL";
+ case ConfigType::FILE: return "FILE";
+ case ConfigType::DIR: return "DIR";
+ case ConfigType::LIST: return "LIST";
+ case ConfigType::STRING_OR_LIST: return "STRING_OR_LIST";
+ }
+ return "UNKNOWN";
+}
+ /*}}}*/
+static ConfigType getConfigType(std::string const &type) /*{{{*/
+{
+ if (type == "<INT>")
+ return ConfigType::INT;
+ else if (type == "<BOOL>")
+ return ConfigType::BOOL;
+ else if (type == "<STRING>")
+ return ConfigType::STRING;
+ else if (type == "<STRING_OR_BOOL>")
+ return ConfigType::STRING_OR_BOOL;
+ else if (type == "<FILE>")
+ return ConfigType::FILE;
+ else if (type == "<DIR>")
+ return ConfigType::DIR;
+ else if (type == "<LIST>")
+ return ConfigType::LIST;
+ else if (type == "<STRING_OR_LIST>")
+ return ConfigType::STRING_OR_LIST;
+ else if (type == "<PROGRAM_PATH>")
+ return ConfigType::PROGRAM_PATH;
+ return ConfigType::UNDEFINED;
+}
+ /*}}}*/
+// checkFindConfigOptionType - workhorse of option checking /*{{{*/
+static void checkFindConfigOptionTypeInternal(std::string name, ConfigType const type)
+{
+ std::transform(name.begin(), name.end(), name.begin(), ::tolower);
+ auto known = apt_known_config.find(name);
+ if (known == apt_known_config.cend())
+ {
+ auto const rcolon = name.rfind(':');
+ if (rcolon != std::string::npos)
+ {
+ known = apt_known_config.find(name.substr(0, rcolon) + ":*");
+ if (known == apt_known_config.cend())
+ {
+ auto const parts = StringSplit(name, "::");
+ size_t psize = parts.size();
+ if (psize > 1)
+ {
+ for (size_t max = psize; max != 1; --max)
+ {
+ std::ostringstream os;
+ std::copy(parts.begin(), parts.begin() + max, std::ostream_iterator<std::string>(os, "::"));
+ os << "**";
+ known = apt_known_config.find(os.str());
+ if (known != apt_known_config.cend() && known->second == ConfigType::UNDEFINED)
+ return;
+ }
+ for (size_t max = psize - 1; max != 1; --max)
+ {
+ std::ostringstream os;
+ std::copy(parts.begin(), parts.begin() + max - 1, std::ostream_iterator<std::string>(os, "::"));
+ os << "*::";
+ std::copy(parts.begin() + max + 1, parts.end() - 1, std::ostream_iterator<std::string>(os, "::"));
+ os << *(parts.end() - 1);
+ known = apt_known_config.find(os.str());
+ if (known != apt_known_config.cend())
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (known == apt_known_config.cend())
+ _error->Warning("Using unknown config option »%s« of type %s",
+ name.c_str(), getConfigTypeString(type).c_str());
+ else if (known->second != type)
+ {
+ if (known->second == ConfigType::DIR && type == ConfigType::FILE)
+ ; // implementation detail
+ else if (type == ConfigType::STRING && (known->second == ConfigType::FILE || known->second == ConfigType::DIR))
+ ; // TODO: that might be an error or not, we will figure this out later
+ else if (known->second == ConfigType::STRING_OR_BOOL && (type == ConfigType::BOOL || type == ConfigType::STRING))
+ ;
+ else if (known->second == ConfigType::STRING_OR_LIST && (type == ConfigType::LIST || type == ConfigType::STRING))
+ ;
+ else
+ _error->Warning("Using config option »%s« of type %s as a type %s",
+ name.c_str(), getConfigTypeString(known->second).c_str(), getConfigTypeString(type).c_str());
+ }
+}
+static void checkFindConfigOptionType(char const * const name, ConfigType const type)
+{
+ if (apt_known_config.empty())
+ return;
+ checkFindConfigOptionTypeInternal(name, type);
+}
+ /*}}}*/
+static bool LoadConfigurationIndex(std::string const &filename) /*{{{*/
+{
+ apt_known_config.clear();
+ if (filename.empty())
+ return true;
+ Configuration Idx;
+ if (ReadConfigFile(Idx, filename) == false)
+ return false;
+
+ Configuration::Item const * Top = Idx.Tree(nullptr);
+ if (unlikely(Top == nullptr))
+ return false;
+
+ do {
+ if (Top->Value.empty() == false)
+ {
+ std::string fulltag = Top->FullTag();
+ std::transform(fulltag.begin(), fulltag.end(), fulltag.begin(), ::tolower);
+ apt_known_config.emplace(std::move(fulltag), getConfigType(Top->Value));
+ }
+
+ if (Top->Child != nullptr)
+ {
+ Top = Top->Child;
+ continue;
+ }
+
+ while (Top != nullptr && Top->Next == nullptr)
+ Top = Top->Parent;
+ if (Top != nullptr)
+ Top = Top->Next;
+ } while (Top != nullptr);
+
+ return true;
+}
+ /*}}}*/
+
// Configuration::Configuration - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -160,6 +312,7 @@ Configuration::Item *Configuration::Lookup(const char *Name,bool const &Create)
/* */
string Configuration::Find(const char *Name,const char *Default) const
{
+ checkFindConfigOptionType(Name, ConfigType::STRING);
const Item *Itm = Lookup(Name);
if (Itm == 0 || Itm->Value.empty() == true)
{
@@ -179,6 +332,7 @@ string Configuration::Find(const char *Name,const char *Default) const
*/
string Configuration::FindFile(const char *Name,const char *Default) const
{
+ checkFindConfigOptionType(Name, ConfigType::FILE);
const Item *RootItem = Lookup("RootDir");
std::string result = (RootItem == 0) ? "" : RootItem->Value;
if(result.empty() == false && result[result.size() - 1] != '/')
@@ -233,6 +387,7 @@ string Configuration::FindFile(const char *Name,const char *Default) const
/* This is like findfile execept the result is terminated in a / */
string Configuration::FindDir(const char *Name,const char *Default) const
{
+ checkFindConfigOptionType(Name, ConfigType::DIR);
string Res = FindFile(Name,Default);
if (Res.end()[-1] != '/')
{
@@ -249,6 +404,7 @@ string Configuration::FindDir(const char *Name,const char *Default) const
/* Returns a vector of config values under the given item */
vector<string> Configuration::FindVector(const char *Name, std::string const &Default, bool const Keys) const
{
+ checkFindConfigOptionType(Name, ConfigType::LIST);
vector<string> Vec;
const Item *Top = Lookup(Name);
if (Top == NULL)
@@ -274,6 +430,7 @@ vector<string> Configuration::FindVector(const char *Name, std::string const &De
/* */
int Configuration::FindI(const char *Name,int const &Default) const
{
+ checkFindConfigOptionType(Name, ConfigType::INT);
const Item *Itm = Lookup(Name);
if (Itm == 0 || Itm->Value.empty() == true)
return Default;
@@ -291,6 +448,7 @@ int Configuration::FindI(const char *Name,int const &Default) const
/* */
bool Configuration::FindB(const char *Name,bool const &Default) const
{
+ checkFindConfigOptionType(Name, ConfigType::BOOL);
const Item *Itm = Lookup(Name);
if (Itm == 0 || Itm->Value.empty() == true)
return Default;
@@ -774,7 +932,8 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool const &AsSectio
if ((*I == '/' && I + 1 != End && I[1] == '/') ||
(*I == '#' && strcmp(string(I,I+6).c_str(),"#clear") != 0 &&
- strcmp(string(I,I+8).c_str(),"#include") != 0))
+ strcmp(string(I,I+8).c_str(),"#include") != 0 &&
+ strcmp(string(I,I+strlen("#x-apt-configure-index")).c_str(), "#x-apt-configure-index") != 0))
{
End = I;
break;
@@ -889,7 +1048,7 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool const &AsSectio
{
Stack.push(ParentTag);
- /* Make sectional tags incorperate the section into the
+ /* Make sectional tags incorporate the section into the
tag string */
if (AsSectional == true && Word.empty() == false)
{
@@ -939,6 +1098,11 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool const &AsSectio
return _error->Error(_("Syntax error %s:%u: Included from here"),FName.c_str(),CurLine);
}
}
+ else if (Tag == "x-apt-configure-index")
+ {
+ if (LoadConfigurationIndex(Word) == false)
+ return _error->Warning("Loading the configure index %s in file %s:%u failed!", Word.c_str(), FName.c_str(), CurLine);
+ }
else
return _error->Error(_("Syntax error %s:%u: Unsupported directive '%s'"),FName.c_str(),CurLine,Tag.c_str());
}
diff --git a/apt-pkg/contrib/error.h b/apt-pkg/contrib/error.h
index bcaa7c995..5ad408d25 100644
--- a/apt-pkg/contrib/error.h
+++ b/apt-pkg/contrib/error.h
@@ -3,7 +3,7 @@
// $Id: error.h,v 1.8 2001/05/07 05:06:52 jgg Exp $
/* ######################################################################
- Global Erorr Class - Global error mechanism
+ Global Error Class - Global error mechanism
This class has a single global instance. When a function needs to
generate an error condition, such as a read error, it calls a member
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index f3c7b6d3b..a90cd647a 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -2949,7 +2949,7 @@ static std::string APT_NONNULL(1) GetTempDirEnv(char const * const env) /*{{{*/
stat(tmpdir, &st) != 0 || (st.st_mode & S_IFDIR) == 0) // exists and is directory
tmpdir = "/tmp";
else if (geteuid() != 0 && // root can do everything anyway
- faccessat(-1, tmpdir, R_OK | W_OK | X_OK, AT_EACCESS | AT_SYMLINK_NOFOLLOW) != 0) // current user has rwx access to directory
+ faccessat(AT_FDCWD, tmpdir, R_OK | W_OK | X_OK, AT_EACCESS) != 0) // current user has rwx access to directory
tmpdir = "/tmp";
return string(tmpdir);
diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc
index cdf1e7f42..d4ccf47c7 100644
--- a/apt-pkg/contrib/gpgv.cc
+++ b/apt-pkg/contrib/gpgv.cc
@@ -146,7 +146,6 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG,
}
enum { DETACHED, CLEARSIGNED } releaseSignature = (FileGPG != File) ? DETACHED : CLEARSIGNED;
- std::vector<std::string> dataHeader;
char * sig = NULL;
char * data = NULL;
char * conf = nullptr;
@@ -205,7 +204,7 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG,
message.OpenDescriptor(dataFd, FileFd::WriteOnly, true);
if (signature.Failed() == true || message.Failed() == true ||
- SplitClearSignedFile(File, &message, &dataHeader, &signature) == false)
+ SplitClearSignedFile(File, &message, nullptr, &signature) == false)
{
apt_error(std::cerr, statusfd, fd, "Splitting up %s into data and signature failed", File.c_str());
local_exit(112);
@@ -304,6 +303,20 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG,
}
/*}}}*/
// SplitClearSignedFile - split message into data/signature /*{{{*/
+static int GetLineErrno(char **lineptr, size_t *n, FILE *stream, std::string const &InFile)
+{
+ int result;
+
+ errno = 0;
+ result = getline(lineptr, n, stream);
+ if (errno != 0)
+ {
+ _error->Errno("getline", "Could not read from %s", InFile.c_str());
+ return -1;
+ }
+
+ return result;
+}
bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,
std::vector<std::string> * const ContentHeader, FileFd * const SignatureFile)
{
@@ -316,10 +329,13 @@ bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,
bool skip_until_empty_line = false;
bool found_signature = false;
bool first_line = true;
+ bool signed_message_not_on_first_line = false;
+ bool found_garbage = false;
char *buf = NULL;
size_t buf_size = 0;
- while (getline(&buf, &buf_size, in) != -1)
+ _error->PushToStack();
+ while (GetLineErrno(&buf, &buf_size, in, InFile) != -1)
{
_strrstrip(buf);
if (found_message_start == false)
@@ -329,6 +345,8 @@ bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,
found_message_start = true;
skip_until_empty_line = true;
}
+ else
+ signed_message_not_on_first_line = found_garbage = true;
}
else if (skip_until_empty_line == true)
{
@@ -366,6 +384,8 @@ bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,
if (ContentFile != NULL)
ContentFile->Write(dashfree, strlen(dashfree));
}
+ else
+ found_garbage = true;
}
else if (found_signature == true)
{
@@ -378,11 +398,33 @@ bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,
found_signature = false; // look for other signatures
}
// all the rest is whitespace, unsigned garbage or additional message blocks we ignore
+ else
+ found_garbage = true;
}
fclose(in);
if (buf != NULL)
free(buf);
+ // Flush the files. Errors will be checked below.
+ if (SignatureFile != nullptr)
+ SignatureFile->Flush();
+ if (ContentFile != nullptr)
+ ContentFile->Flush();
+
+ if (found_message_start)
+ {
+ if (signed_message_not_on_first_line)
+ _error->Warning("Clearsigned file '%s' does not start with a signed message block.", InFile.c_str());
+ else if (found_garbage)
+ _error->Warning("Clearsigned file '%s' contains unsigned lines.", InFile.c_str());
+ }
+
+ // An error occurred during reading - propagate it up
+ bool const hasErrored = _error->PendingError();
+ _error->MergeWithStack();
+ if (hasErrored)
+ return false;
+
if (found_signature == true)
return _error->Error("Signature in file %s wasn't closed", InFile.c_str());
@@ -406,7 +448,7 @@ bool OpenMaybeClearSignedFile(std::string const &ClearSignedFileName, FileFd &Me
free(message);
return _error->Errno("mkstemp", "Couldn't create temporary file to work with %s", ClearSignedFileName.c_str());
}
- // we have the fd, thats enough for us
+ // we have the fd, that's enough for us
unlink(message);
free(message);
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index f63f2eea1..fa93c91af 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -155,9 +155,9 @@ bool MMap::Close(bool DoSync)
return true;
}
/*}}}*/
-// MMap::Sync - Syncronize the map with the disk /*{{{*/
+// MMap::Sync - Synchronize the map with the disk /*{{{*/
// ---------------------------------------------------------------------
-/* This is done in syncronous mode - the docs indicate that this will
+/* This is done in synchronous mode - the docs indicate that this will
not return till all IO is complete */
bool MMap::Sync()
{
@@ -182,7 +182,7 @@ bool MMap::Sync()
return true;
}
/*}}}*/
-// MMap::Sync - Syncronize a section of the file to disk /*{{{*/
+// MMap::Sync - Synchronize a section of the file to disk /*{{{*/
// ---------------------------------------------------------------------
/* */
bool MMap::Sync(unsigned long Start,unsigned long Stop)
diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h
index 1576cab91..b776959c2 100644
--- a/apt-pkg/contrib/mmap.h
+++ b/apt-pkg/contrib/mmap.h
@@ -10,7 +10,7 @@
from file fd's this function will use read and normal allocated
memory.
- Writing to a public mmap will always fully comit all changes when the
+ Writing to a public mmap will always fully commit all changes when the
class is deleted. Ie it will rewrite the file, unless it is readonly
The DynamicMMap class is used to help the on-disk data structure
diff --git a/apt-pkg/contrib/proxy.cc b/apt-pkg/contrib/proxy.cc
index 62cfba032..1b7a92c68 100644
--- a/apt-pkg/contrib/proxy.cc
+++ b/apt-pkg/contrib/proxy.cc
@@ -2,7 +2,7 @@
// Description /*{{{*/
/* ######################################################################
- Proxy - Proxy releated functions
+ Proxy - Proxy related functions
##################################################################### */
/*}}}*/
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index cf8feb970..88113f7a4 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -27,6 +27,7 @@
#include <locale>
#include <sstream>
#include <string>
+#include <sstream>
#include <vector>
#include <stddef.h>
@@ -85,6 +86,17 @@ bool Startswith(const std::string &s, const std::string &start)
return (s.compare(0, start.size(), start) == 0);
}
+std::string Join(std::vector<std::string> list, const std::string &sep)
+{
+ std::ostringstream oss;
+ for (auto it = list.begin(); it != list.end(); it++)
+ {
+ if (it != list.begin()) oss << sep;
+ oss << *it;
+ }
+ return oss.str();
+}
+
}
}
/*}}}*/
@@ -748,7 +760,7 @@ int StringToBool(const string &Text,int Default)
// TimeRFC1123 - Convert a time_t into RFC1123 format /*{{{*/
// ---------------------------------------------------------------------
/* This converts a time_t into a string time representation that is
- year 2000 complient and timezone neutral */
+ year 2000 compliant and timezone neutral */
string TimeRFC1123(time_t Date)
{
return TimeRFC1123(Date, false);
@@ -1466,7 +1478,7 @@ string StripEpoch(const string &VerStr)
// tolower_ascii - tolower() function that ignores the locale /*{{{*/
// ---------------------------------------------------------------------
/* This little function is the most called method we have and tries
- therefore to do the absolut minimum - and is notable faster than
+ therefore to do the absolute minimum - and is notable faster than
standard tolower/toupper and as a bonus avoids problems with different
locales - we only operate on ascii chars anyway. */
#undef tolower_ascii
@@ -1480,7 +1492,7 @@ int tolower_ascii(int const c)
// isspace_ascii - isspace() function that ignores the locale /*{{{*/
// ---------------------------------------------------------------------
/* This little function is one of the most called methods we have and tries
- therefore to do the absolut minimum - and is notable faster than
+ therefore to do the absolute minimum - and is notable faster than
standard isspace() and as a bonus avoids problems with different
locales - we only operate on ascii chars anyway. */
#undef isspace_ascii
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index b58e69cbd..ba41172fd 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -44,6 +44,8 @@ namespace APT {
std::string Strip(const std::string &s);
bool Endswith(const std::string &s, const std::string &ending);
bool Startswith(const std::string &s, const std::string &starting);
+ std::string Join(std::vector<std::string> list, const std::string &sep);
+
}
}
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 17c283615..3bcd381c0 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -73,8 +73,19 @@ string debListParser::Package() {
string Result = Section.Find(pkgTagSection::Key::Package).to_string();
// Normalize mixed case package names to lower case, like dpkg does
- // See Bug#807012 for details
- std::transform(Result.begin(), Result.end(), Result.begin(), tolower_ascii);
+ // See Bug#807012 for details.
+ // Only do this when the package name does not contain a / - as that
+ // indicates that the package name was derived from a filename given
+ // to install or build-dep or similar (Bug#854794)
+ if (likely(Result.find('/') == string::npos))
+ {
+ for (char &c: Result)
+ {
+ char l = tolower_ascii_inline(c);
+ if (unlikely(l != c))
+ c = l;
+ }
+ }
if(unlikely(Result.empty() == true))
_error->Warning("Encountered a section with no Package: header");
@@ -559,11 +570,23 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
bool const &StripMultiArch,
bool const &ParseRestrictionsList)
{
+ return debListParser::ParseDepends(Start, Stop, Package, Ver, Op, ParseArchFlags,
+ StripMultiArch, ParseRestrictionsList,
+ _config->Find("APT::Architecture"));
+}
+
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+ string &Package,string &Ver,
+ unsigned int &Op, bool const &ParseArchFlags,
+ bool const &StripMultiArch,
+ bool const &ParseRestrictionsList,
+ string const &Arch)
+{
StringView PackageView;
StringView VerView;
auto res = ParseDepends(Start, Stop, PackageView, VerView, Op, (bool)ParseArchFlags,
- (bool) StripMultiArch, (bool) ParseRestrictionsList);
+ (bool) StripMultiArch, (bool) ParseRestrictionsList, Arch);
Package = PackageView.to_string();
Ver = VerView.to_string();
@@ -575,6 +598,17 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
bool StripMultiArch,
bool ParseRestrictionsList)
{
+ return debListParser::ParseDepends(Start, Stop, Package, Ver, Op, ParseArchFlags,
+ StripMultiArch, ParseRestrictionsList,
+ _config->Find("APT::Architecture"));
+}
+
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+ StringView &Package,StringView &Ver,
+ unsigned int &Op, bool ParseArchFlags,
+ bool StripMultiArch,
+ bool ParseRestrictionsList, string const &Arch)
+{
// Strip off leading space
for (;Start != Stop && isspace_ascii(*Start) != 0; ++Start);
@@ -642,8 +676,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
if (unlikely(ParseArchFlags == true))
{
- string const arch = _config->Find("APT::Architecture");
- APT::CacheFilter::PackageArchitectureMatchesSpecification matchesArch(arch, false);
+ APT::CacheFilter::PackageArchitectureMatchesSpecification matchesArch(Arch, false);
// Parse an architecture
if (I != Stop && *I == '[')
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 733ea0542..5e945812d 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -105,6 +105,11 @@ class APT_HIDDEN debListParser : public pkgCacheListParser
std::string &Package,std::string &Ver,unsigned int &Op,
bool const &ParseArchFlags, bool const &StripMultiArch,
bool const &ParseRestrictionsList);
+ APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op,
+ bool const &ParseArchFlags, bool const &StripMultiArch,
+ bool const &ParseRestrictionsList,
+ std::string const &Arch);
#ifdef APT_PKG_EXPOSE_STRING_VIEW
APT_HIDDEN static const char *ParseDepends(const char *Start,const char *Stop,
@@ -112,6 +117,12 @@ class APT_HIDDEN debListParser : public pkgCacheListParser
APT::StringView &Ver,unsigned int &Op,
bool const ParseArchFlags = false, bool StripMultiArch = true,
bool const ParseRestrictionsList = false);
+ APT_HIDDEN static const char *ParseDepends(const char *Start,const char *Stop,
+ APT::StringView &Package,
+ APT::StringView &Ver,unsigned int &Op,
+ bool const ParseArchFlags, bool StripMultiArch,
+ bool const ParseRestrictionsList,
+ std::string const &Arch);
#endif
APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op);
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index 091b187a2..7d2eb313b 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -274,11 +274,14 @@ static void GetIndexTargetsFor(char const * const Type, std::string const &URI,
if (dup != IndexTargets.end())
{
std::string const dupEntry = dup->Option(IndexTarget::SOURCESENTRY);
- //TRANSLATOR: an identifier like Packages; Releasefile key indicating
- // a file like main/binary-amd64/Packages; filename and linenumber of
- // two sources.list entries
- _error->Warning(_("Target %s (%s) is configured multiple times in %s and %s"),
- T->c_str(), MetaKey.c_str(), dupEntry.c_str(), E->sourcesEntry.c_str());
+ if (T->find("legacy") == std::string::npos)
+ {
+ //TRANSLATOR: an identifier like Packages; Releasefile key indicating
+ // a file like main/binary-amd64/Packages; filename and linenumber of
+ // two sources.list entries
+ _error->Warning(_("Target %s (%s) is configured multiple times in %s and %s"),
+ T->c_str(), MetaKey.c_str(), dupEntry.c_str(), E->sourcesEntry.c_str());
+ }
if (tplMetaKey.find(BreakPoint) == std::string::npos)
break;
continue;
@@ -1101,8 +1104,11 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/
UseByHash = _config->Find("Acquire::By-Hash", UseByHash);
{
std::string const host = ::URI(URI).Host;
- UseByHash = _config->Find("APT::Acquire::" + host + "::By-Hash", UseByHash);
- UseByHash = _config->Find("Acquire::" + host + "::By-Hash", UseByHash);
+ if (host.empty() == false)
+ {
+ UseByHash = _config->Find("APT::Acquire::" + host + "::By-Hash", UseByHash);
+ UseByHash = _config->Find("Acquire::" + host + "::By-Hash", UseByHash);
+ }
std::map<std::string, std::string>::const_iterator const opt = Options.find("by-hash");
if (opt != Options.end())
UseByHash = opt->second;
diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h
index b412dbaef..bc800bc89 100644
--- a/apt-pkg/deb/debrecords.h
+++ b/apt-pkg/deb/debrecords.h
@@ -5,8 +5,8 @@
Debian Package Records - Parser for debian package records
- This provides display-type parsing for the Packages file. This is
- different than the the list parser which provides cache generation
+ This provides display-type parsing for the Packages file. This is
+ different than the list parser which provides cache generation
services. There should be no overlap between these two.
##################################################################### */
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index 407b02d39..caaa53063 100644
--- a/apt-pkg/deb/debsrcrecords.cc
+++ b/apt-pkg/deb/debsrcrecords.cc
@@ -129,8 +129,18 @@ bool debSrcRecordParser::BuildDepends(std::vector<pkgSrcRecords::Parser::BuildDe
return _error->Error("Problem parsing dependency: %s", fields[I]);
rec.Type = I;
- if (rec.Package != "")
+ // We parsed a package that was ignored (wrong architecture restriction
+ // or something).
+ if (rec.Package == "") {
+ // If we are in an OR group, we need to set the "Or" flag of the
+ // previous entry to our value.
+ if (BuildDeps.size() > 0 && (BuildDeps[BuildDeps.size() - 1].Op & pkgCache::Dep::Or) == pkgCache::Dep::Or) {
+ BuildDeps[BuildDeps.size() - 1].Op &= ~pkgCache::Dep::Or;
+ BuildDeps[BuildDeps.size() - 1].Op |= (rec.Op & pkgCache::Dep::Or);
+ }
+ } else {
BuildDeps.push_back(rec);
+ }
if (Start == Stop)
break;
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 45ed66996..01282efcc 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -670,7 +670,7 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
if (unlikely(candset.empty()))
{
if (Debug == true)
- std::clog << "unable to figure out which package is dpkg refering to with '" << pkgname << "'! (1)" << std::endl;
+ std::clog << "unable to figure out which package is dpkg referring to with '" << pkgname << "'! (1)" << std::endl;
return;
}
else if (candset.size() == 1) // we are lucky
@@ -760,7 +760,7 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
if (pkgname.find(':') != std::string::npos)
{
if (Debug == true)
- std::clog << "unable to figure out which package is dpkg refering to with '" << pkgname << "'! (2)" << std::endl;
+ std::clog << "unable to figure out which package is dpkg referring to with '" << pkgname << "'! (2)" << std::endl;
return;
}
}
@@ -985,7 +985,8 @@ void pkgDPkgPM::WriteHistoryTag(string const &tag, string value)
// DPkgPM::OpenLog /*{{{*/
bool pkgDPkgPM::OpenLog()
{
- string const logdir = _config->FindDir("Dir::Log");
+ string const logfile_name = _config->FindFile("Dir::Log::Terminal");
+ string logdir = flNotFile(logfile_name);
if(CreateAPTDirectoryIfNeeded(logdir, logdir) == false)
// FIXME: use a better string after freeze
return _error->Error(_("Directory '%s' missing"), logdir.c_str());
@@ -998,8 +999,6 @@ bool pkgDPkgPM::OpenLog()
strftime(timestr, sizeof(timestr), "%F %T", tmp);
// open terminal log
- string const logfile_name = flCombine(logdir,
- _config->Find("Dir::Log::Terminal"));
if (!logfile_name.empty())
{
d->term_out = fopen(logfile_name.c_str(),"a");
@@ -1020,8 +1019,10 @@ bool pkgDPkgPM::OpenLog()
}
// write your history
- string const history_name = flCombine(logdir,
- _config->Find("Dir::Log::History"));
+ string const history_name = _config->FindFile("Dir::Log::History");
+ string logdir2 = flNotFile(logfile_name);
+ if(logdir != logdir2 && CreateAPTDirectoryIfNeeded(logdir2, logdir2) == false)
+ return _error->Error(_("Directory '%s' missing"), logdir.c_str());
if (!history_name.empty())
{
d->history_out = fopen(history_name.c_str(),"a");
@@ -1447,7 +1448,7 @@ bool pkgDPkgPM::ExpandPendingCalls(std::vector<Item> &List, pkgDepCache &Cache)
}
bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
{
- // explicitely remove&configure everything for hookscripts and progress building
+ // explicitly remove&configure everything for hookscripts and progress building
// we need them only temporarily through, so keep the length and erase afterwards
decltype(List)::const_iterator::difference_type explicitIdx =
std::distance(List.cbegin(), List.cend());
@@ -1509,7 +1510,7 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
dpkg_recursive_install = Cache.VS().CmpVersion("1.18.5", dpkgpkg.CurrentVer().VerStr()) <= 0;
}
// no point in doing this dance for a handful of packages only
- unsigned int const dpkg_recursive_install_min = _config->FindB("dpkg::install::recursive::minimum", 5);
+ unsigned int const dpkg_recursive_install_min = _config->FindI("dpkg::install::recursive::minimum", 5);
// FIXME: workaround for dpkg bug, see our ./test-bug-740843-versioned-up-down-breaks test
bool const dpkg_recursive_install_numbered = _config->FindB("dpkg::install::recursive::numbered", true);
@@ -1911,7 +1912,7 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
ADDARG(fullname);
}
}
- // skip configure action if all sheduled packages disappeared
+ // skip configure action if all scheduled packages disappeared
if (oldSize == Size)
continue;
}
@@ -2103,7 +2104,7 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
if (d->dpkg_error.empty() == false)
{
- // no point in reseting packages we already completed removal for
+ // no point in resetting packages we already completed removal for
StripAlreadyDoneFrom(approvedStates.Remove());
StripAlreadyDoneFrom(approvedStates.Purge());
APT::StateChanges undo;
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 3925d2e7c..f3615302e 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -787,7 +787,7 @@ bool pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser,
ActionGroup group(*this);
-#if 0 // reseting the autoflag here means we lose the
+#if 0 // resetting the autoflag here means we lose the
// auto-mark information if a user selects a package for removal
// but changes his mind then and sets it for keep again
// - this makes sense as default when all Garbage dependencies
@@ -1079,7 +1079,7 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
StateCache &P = PkgState[Pkg->ID];
- // See if there is even any possible instalation candidate
+ // See if there is even any possible installation candidate
if (P.CandidateVer == 0)
return false;
@@ -1781,7 +1781,7 @@ bool pkgDepCache::Policy::IsImportantDep(DepIterator const &Dep) const
{
if (InstallRecommends)
return true;
- // we suport a special mode to only install-recommends for certain
+ // we support a special mode to only install-recommends for certain
// sections
// FIXME: this is a meant as a temporarly solution until the
// recommends are cleaned up
diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h
index 03a2cb0a8..1ab86644d 100644
--- a/apt-pkg/depcache.h
+++ b/apt-pkg/depcache.h
@@ -21,7 +21,7 @@
3 dependency results.
Now - Compared using the Currently install version
Install - Compared using the install version (final state)
- CVer - (Candidate Verion) Compared using the Candidate Version
+ CVer - (Candidate Version) Compared using the Candidate Version
The candidate and now results are used to decide wheather a package
should be automatically installed or if it should be left alone.
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index d282a0b59..59c7720c3 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -931,14 +931,18 @@ bool EDSP::WriteProgress(unsigned short const percent, const char* const message
}
/*}}}*/
// EDSP::WriteError - format an error message to be send to file descriptor /*{{{*/
+static std::string formatMessage(std::string const &msg)
+{
+ return SubstVar(SubstVar(APT::String::Strip(msg), "\n\n", "\n.\n"), "\n", "\n ");
+}
bool EDSP::WriteError(char const * const uuid, std::string const &message, FILE* output) {
fprintf(output, "Error: %s\n", uuid);
- fprintf(output, "Message: %s\n\n", SubstVar(SubstVar(message, "\n\n", "\n.\n"), "\n", "\n ").c_str());
+ fprintf(output, "Message: %s\n\n", formatMessage(message).c_str());
return true;
}
bool EDSP::WriteError(char const * const uuid, std::string const &message, FileFd &output) {
return WriteOkay(output, "Error: ", uuid, "\n",
- "Message: ", SubstVar(SubstVar(message, "\n\n", "\n.\n"), "\n", "\n "),
+ "Message: ", formatMessage(message),
"\n\n");
}
/*}}}*/
diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h
index ed49ac28c..2c9082ed3 100644
--- a/apt-pkg/edsp.h
+++ b/apt-pkg/edsp.h
@@ -133,7 +133,7 @@ namespace EDSP /*{{{*/
* \param[out] remove is a list which gets populated with requested removals
* \param[out] upgrade is true if it is a request like apt-get upgrade
* \param[out] distUpgrade is true if it is a request like apt-get dist-upgrade
- * \param[out] autoRemove is true if removal of uneeded packages should be performed
+ * \param[out] autoRemove is true if removal of unneeded packages should be performed
*
* \return true if the request could be found and worked on, otherwise false
*/
diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h
index 68753a40a..046216ab2 100644
--- a/apt-pkg/indexfile.h
+++ b/apt-pkg/indexfile.h
@@ -155,7 +155,7 @@ class pkgIndexFile
rather bad (doesn't take three character like ast into account).*/
APT_DEPRECATED_MSG("These methods make no sense anymore with multi-language support") static bool CheckLanguageCode(const char * const Lang);
/* As we have now possibly more than one LanguageCode this method is
- superseeded by a) private classmembers or b) getLanguages() */
+ superseded by a) private classmembers or b) getLanguages() */
APT_DEPRECATED_MSG("These methods make no sense anymore with multi-language support") static std::string LanguageCode();
bool IsTrusted() const { return Trusted; };
diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc
index 292d75071..00d991027 100644
--- a/apt-pkg/init.cc
+++ b/apt-pkg/init.cc
@@ -20,6 +20,11 @@
#include <string.h>
#include <cstdlib>
+#include <fstream>
+#include <sstream>
+#include <string>
+#include <unordered_map>
+#include <vector>
#include <apti18n.h>
/*}}}*/
@@ -30,6 +35,89 @@ const char *pkgVersion = PACKAGE_VERSION;
const char *pkgLibVersion = Stringfy(APT_PKG_MAJOR) "."
Stringfy(APT_PKG_MINOR) "."
Stringfy(APT_PKG_RELEASE);
+namespace APT {
+ APT_HIDDEN extern std::unordered_map<std::string, std::vector<std::string>> ArchToTupleMap;
+}
+
+// Splits by whitespace. There may be continuous spans of whitespace - they
+// will be considered as one.
+static std::vector<std::string> split(std::string const & s)
+{
+ std::vector<std::string> vec;
+ std::istringstream iss(s);
+ iss.imbue(std::locale::classic());
+ for(std::string current_s; iss >> current_s; )
+ vec.push_back(current_s);
+ return vec;
+}
+
+
+// pkgInitArchTupleMap - Initialize the architecture tuple map /*{{{*/
+// ---------------------------------------------------------------------
+/* This initializes */
+static bool pkgInitArchTupleMap()
+{
+ auto tuplepath = _config->FindFile("Dir::dpkg::tupletable", DPKG_DATADIR "/tupletable");
+ auto tripletpath = _config->FindFile("Dir::dpkg::triplettable", DPKG_DATADIR "/triplettable");
+ auto cpupath = _config->FindFile("Dir::dpkg::cputable", DPKG_DATADIR "/cputable");
+
+ // Load a list of CPUs
+ std::vector<std::string> cpus;
+ std::ifstream cputable(cpupath);
+ for (std::string cpuline; std::getline(cputable, cpuline); )
+ {
+ if (cpuline[0] == '#' || cpuline[0] == '\0')
+ continue;
+ auto cpurow = split(cpuline);
+ auto cpu = APT::String::Strip(cpurow.at(0));
+
+ cpus.push_back(cpu);
+ }
+ if (!cputable.eof())
+ return _error->Error("Error reading the CPU table");
+
+ // Load the architecture tuple
+ std::ifstream tupletable;
+ if (FileExists(tuplepath))
+ tupletable.open(tuplepath);
+ else if (FileExists(tripletpath))
+ tupletable.open(tripletpath);
+ else
+ return _error->Error("Cannot find dpkg tuplet or triplet table");
+
+ APT::ArchToTupleMap.clear();
+ for (std::string tupleline; std::getline(tupletable, tupleline); )
+ {
+ if (tupleline[0] == '#' || tupleline[0] == '\0')
+ continue;
+
+ std::vector<std::string> tuplerow = split(tupleline);
+
+ auto tuple = APT::String::Strip(tuplerow.at(0));
+ auto arch = APT::String::Strip(tuplerow.at(1));
+
+ if (tuple.find("<cpu>") == tuple.npos && arch.find("<cpu>") == arch.npos)
+ {
+ APT::ArchToTupleMap.insert({arch, VectorizeString(tuple, '-')});
+ }
+ else
+ {
+ for (auto && cpu : cpus)
+ {
+ auto mytuple = SubstVar(tuple, std::string("<cpu>"), cpu);
+ auto myarch = SubstVar(arch, std::string("<cpu>"), cpu);
+
+ APT::ArchToTupleMap.insert({myarch, VectorizeString(mytuple, '-')});
+ }
+ }
+ }
+ if (!tupletable.eof())
+ return _error->Error("Error reading the Tuple table");
+
+ return true;
+}
+ /*}}}*/
+
// pkgInitConfig - Initialize the configuration class /*{{{*/
// ---------------------------------------------------------------------
@@ -84,6 +172,7 @@ bool pkgInitConfig(Configuration &Cnf)
Cnf.Set("Dir::Ignore-Files-Silently::", "\\.disabled$");
Cnf.Set("Dir::Ignore-Files-Silently::", "\\.bak$");
Cnf.Set("Dir::Ignore-Files-Silently::", "\\.dpkg-[a-z]+$");
+ Cnf.Set("Dir::Ignore-Files-Silently::", "\\.ucf-[a-z]+$");
Cnf.Set("Dir::Ignore-Files-Silently::", "\\.save$");
Cnf.Set("Dir::Ignore-Files-Silently::", "\\.orig$");
Cnf.Set("Dir::Ignore-Files-Silently::", "\\.distUpgrade$");
@@ -193,6 +282,9 @@ bool pkgInitSystem(Configuration &Cnf,pkgSystem *&Sys)
if (Sys == 0)
return _error->Error(_("Unable to determine a suitable packaging system type"));
}
+
+ if (pkgInitArchTupleMap() == false)
+ return false;
return Sys->Initialize(Cnf);
}
diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc
index bfdc50e6c..0be0cc8df 100644
--- a/apt-pkg/orderlist.cc
+++ b/apt-pkg/orderlist.cc
@@ -57,7 +57,7 @@
There are complications in this algorithm when presented with cycles.
For all known practical cases it works, all cases where it doesn't work
is fixable by tweaking the package descriptions. However, it should be
- possible to impove this further to make some better choices when
+ possible to improve this further to make some better choices when
presented with cycles.
##################################################################### */
@@ -134,7 +134,7 @@ bool pkgOrderList::IsMissing(PkgIterator Pkg)
/*}}}*/
// OrderList::DoRun - Does an order run /*{{{*/
// ---------------------------------------------------------------------
-/* The caller is expeted to have setup the desired probe state */
+/* The caller is expected to have setup the desired probe state */
bool pkgOrderList::DoRun()
{
// Temp list
@@ -587,7 +587,7 @@ bool pkgOrderList::VisitNode(PkgIterator Pkg, char const* from)
DepFunc Old = Primary;
- // Perform immedate configuration of the package if so flagged.
+ // Perform immediate configuration of the package if so flagged.
if (IsFlag(Pkg,Immediate) == true && Primary != &pkgOrderList::DepUnPackPre)
Primary = &pkgOrderList::DepUnPackPreD;
@@ -875,7 +875,7 @@ bool pkgOrderList::DepUnPackDep(DepIterator D)
orders configuration so that when a package comes to be configured it's
dependents are configured.
- Loops are ingored. Depends loop entry points are chaotic. */
+ Loops are ignored. Depends loop entry points are chaotic. */
bool pkgOrderList::DepConfigure(DepIterator D)
{
// Never consider reverse configuration dependencies.
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index 90dd3a3ee..a8537431b 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -135,7 +135,7 @@ bool pkgPackageManager::FixMissing()
return Resolve.ResolveByKeep() == true && Cache.BrokenCount() == 0;
}
/*}}}*/
-// PM::ImmediateAdd - Add the immediate flag recursivly /*{{{*/
+// PM::ImmediateAdd - Add the immediate flag recursively /*{{{*/
// ---------------------------------------------------------------------
/* This adds the immediate flag to the pkg and recursively to the
dependencies
@@ -806,7 +806,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
break;
}
- // check if it needs unpack or if if configure is enough
+ // check if it needs unpack or if configure is enough
if (List->IsFlag(DepPkg,pkgOrderList::UnPacked) == false)
{
// two packages pre-depending on each other can't be handled sanely
@@ -1015,7 +1015,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
return false;
if (Immediate == true) {
- // Perform immedate configuration of the package.
+ // Perform immediate configuration of the package.
if (SmartConfigure(Pkg, Depth + 1) == false)
_error->Error(_("Could not perform immediate configuration on '%s'. "
"Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.FullName().c_str(),2);
diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h
index 5046e2dc0..e4c7a0a0a 100644
--- a/apt-pkg/packagemanager.h
+++ b/apt-pkg/packagemanager.h
@@ -7,7 +7,7 @@
Three steps are
- Aquiration of archives (stores the list of final file names)
- Sorting of operations
- - Invokation of package manager
+ - Invocation of package manager
This is the final stage when the package cache entities get converted
into file names and the state stored in a DepCache is transformed
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index 1705f836b..c5ed1b916 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -613,8 +613,8 @@ bool pkgCache::DepIterator::IsNegative() const
/* This intellegently looks at dep target packages and tries to figure
out which package should be used. This is needed to nicely handle
provide mapping. If the target package has no other providing packages
- then it returned. Otherwise the providing list is looked at to
- see if there is one one unique providing package if so it is returned.
+ then it returned. Otherwise the providing list is looked at to
+ see if there is one unique providing package if so it is returned.
Otherwise true is returned and the target package is set. The return
result indicates whether the node should be expandable
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 1b4c89f84..678b5f660 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -1402,24 +1402,27 @@ public:
ScopedErrorRevert() { _error->PushToStack(); }
~ScopedErrorRevert() { _error->RevertToStack(); }
};
-static bool CheckValidity(const string &CacheFile,
+static bool CheckValidity(FileFd &CacheFile, std::string const &CacheFileName,
pkgSourceList &List,
FileIterator const Start,
FileIterator const End,
MMap **OutMap = 0,
pkgCache **OutCache = 0)
{
+ if (CacheFileName.empty())
+ return false;
ScopedErrorRevert ser;
+
bool const Debug = _config->FindB("Debug::pkgCacheGen", false);
// No file, certainly invalid
- if (CacheFile.empty() == true || FileExists(CacheFile) == false)
+ if (CacheFile.Open(CacheFileName, FileFd::ReadOnly, FileFd::None) == false)
{
if (Debug == true)
- std::clog << "CacheFile " << CacheFile << " doesn't exist" << std::endl;
+ std::clog << "CacheFile " << CacheFileName << " doesn't exist" << std::endl;
return false;
}
- if (List.GetLastModifiedTime() > GetModificationTime(CacheFile))
+ if (List.GetLastModifiedTime() > CacheFile.ModificationTime())
{
if (Debug == true)
std::clog << "sources.list is newer than the cache" << std::endl;
@@ -1427,8 +1430,7 @@ static bool CheckValidity(const string &CacheFile,
}
// Map it
- FileFd CacheF(CacheFile,FileFd::ReadOnly);
- std::unique_ptr<MMap> Map(new MMap(CacheF,0));
+ std::unique_ptr<MMap> Map(new MMap(CacheFile,0));
if (unlikely(Map->validData()) == false)
return false;
std::unique_ptr<pkgCache> CacheP(new pkgCache(Map.get()));
@@ -1436,8 +1438,8 @@ static bool CheckValidity(const string &CacheFile,
if (_error->PendingError() || Map->Size() == 0)
{
if (Debug == true)
- std::clog << "Errors are pending or Map is empty() for " << CacheFile << std::endl;
- return _error->ReturnError();
+ std::clog << "Errors are pending or Map is empty() for " << CacheFileName << std::endl;
+ return false;
}
std::unique_ptr<bool[]> RlsVisited(new bool[Cache.HeaderP->ReleaseFileCount]);
@@ -1659,13 +1661,12 @@ static bool writeBackMMapToFile(pkgCacheGenerator * const Gen, DynamicMMap * con
return true;
}
static bool loadBackMMapFromFile(std::unique_ptr<pkgCacheGenerator> &Gen,
- std::unique_ptr<DynamicMMap> &Map, OpProgress * const Progress, std::string const &FileName)
+ std::unique_ptr<DynamicMMap> &Map, OpProgress * const Progress, FileFd &CacheF)
{
Map.reset(CreateDynamicMMap(NULL, 0));
if (unlikely(Map->validData()) == false)
return false;
- FileFd CacheF(FileName, FileFd::ReadOnly);
- if (CacheF.IsOpen() == false || CacheF.Failed())
+ if (CacheF.IsOpen() == false || CacheF.Seek(0) == false || CacheF.Failed())
return false;
_error->PushToStack();
map_pointer_t const alloc = Map->RawAllocate(CacheF.Size());
@@ -1697,20 +1698,20 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
return false;
// Decide if we can write to the files..
- string const CacheFile = _config->FindFile("Dir::Cache::pkgcache");
- string const SrcCacheFile = _config->FindFile("Dir::Cache::srcpkgcache");
+ string const CacheFileName = _config->FindFile("Dir::Cache::pkgcache");
+ string const SrcCacheFileName = _config->FindFile("Dir::Cache::srcpkgcache");
// ensure the cache directory exists
- if (CacheFile.empty() == false || SrcCacheFile.empty() == false)
+ if (CacheFileName.empty() == false || SrcCacheFileName.empty() == false)
{
string dir = _config->FindDir("Dir::Cache");
size_t const len = dir.size();
if (len > 5 && dir.find("/apt/", len - 6, 5) == len - 5)
dir = dir.substr(0, len - 5);
- if (CacheFile.empty() == false)
- CreateDirectory(dir, flNotFile(CacheFile));
- if (SrcCacheFile.empty() == false)
- CreateDirectory(dir, flNotFile(SrcCacheFile));
+ if (CacheFileName.empty() == false)
+ CreateDirectory(dir, flNotFile(CacheFileName));
+ if (SrcCacheFileName.empty() == false)
+ CreateDirectory(dir, flNotFile(SrcCacheFileName));
}
if (Progress != NULL)
@@ -1719,8 +1720,8 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
bool pkgcache_fine = false;
bool srcpkgcache_fine = false;
bool volatile_fine = List.GetVolatileFiles().empty();
-
- if (CheckValidity(CacheFile, List, Files.begin(), Files.end(), volatile_fine ? OutMap : NULL,
+ FileFd CacheFile;
+ if (CheckValidity(CacheFile, CacheFileName, List, Files.begin(), Files.end(), volatile_fine ? OutMap : NULL,
volatile_fine ? OutCache : NULL) == true)
{
if (Debug == true)
@@ -1728,9 +1729,11 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
pkgcache_fine = true;
srcpkgcache_fine = true;
}
+
+ FileFd SrcCacheFile;
if (pkgcache_fine == false)
{
- if (CheckValidity(SrcCacheFile, List, Files.end(), Files.end()) == true)
+ if (CheckValidity(SrcCacheFile, SrcCacheFileName, List, Files.end(), Files.end()) == true)
{
if (Debug == true)
std::clog << "srcpkgcache.bin is valid - it can be reused" << std::endl;
@@ -1748,10 +1751,10 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
bool Writeable = false;
if (srcpkgcache_fine == false || pkgcache_fine == false)
{
- if (CacheFile.empty() == false)
- Writeable = access(flNotFile(CacheFile).c_str(),W_OK) == 0;
- else if (SrcCacheFile.empty() == false)
- Writeable = access(flNotFile(SrcCacheFile).c_str(),W_OK) == 0;
+ if (CacheFileName.empty() == false)
+ Writeable = access(flNotFile(CacheFileName).c_str(),W_OK) == 0;
+ else if (SrcCacheFileName.empty() == false)
+ Writeable = access(flNotFile(SrcCacheFileName).c_str(),W_OK) == 0;
if (Debug == true)
std::clog << "Do we have write-access to the cache files? " << (Writeable ? "YES" : "NO") << std::endl;
@@ -1789,8 +1792,8 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
BuildCache(*Gen, Progress, CurrentSize, TotalSize, &List,
Files.end(),Files.end());
- if (Writeable == true && SrcCacheFile.empty() == false)
- if (writeBackMMapToFile(Gen.get(), Map.get(), SrcCacheFile) == false)
+ if (Writeable == true && SrcCacheFileName.empty() == false)
+ if (writeBackMMapToFile(Gen.get(), Map.get(), SrcCacheFileName) == false)
return false;
}
@@ -1801,8 +1804,8 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
BuildCache(*Gen, Progress, CurrentSize, TotalSize, NULL,
Files.begin(), Files.end());
- if (Writeable == true && CacheFile.empty() == false)
- if (writeBackMMapToFile(Gen.get(), Map.get(), CacheFile) == false)
+ if (Writeable == true && CacheFileName.empty() == false)
+ if (writeBackMMapToFile(Gen.get(), Map.get(), CacheFileName) == false)
return false;
}
diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h
index b5eec305e..5d4ba37d7 100644
--- a/apt-pkg/pkgrecords.h
+++ b/apt-pkg/pkgrecords.h
@@ -10,7 +10,7 @@
package files. This is different than the generators parser in that
it is used to access information not generate information. No
information touched by the generator should be parable from here as
- it can always be retreived directly from the cache.
+ it can always be retrieved directly from the cache.
##################################################################### */
/*}}}*/
diff --git a/apt-pkg/policy.h b/apt-pkg/policy.h
index 04747c5a1..943332bbb 100644
--- a/apt-pkg/policy.h
+++ b/apt-pkg/policy.h
@@ -8,7 +8,7 @@
standard 'Version 0' engine is included inside the DepCache which is
it's historical location.
- The V4 engine allows the user to completly control all aspects of
+ The V4 engine allows the user to completely control all aspects of
version selection. There are three primary means to choose a version
* Selection by version match
* Selection by Release file match
diff --git a/apt-pkg/tagfile-order.c b/apt-pkg/tagfile-order.c
index a7625b501..0347d8b76 100644
--- a/apt-pkg/tagfile-order.c
+++ b/apt-pkg/tagfile-order.c
@@ -17,6 +17,7 @@ static const char *iTFRewritePackageOrder[] = {
"Kernel-Version", // Used only by d-i
"Built-Using",
"Built-For-Profiles",
+ "Auto-Built-Package",
"Multi-Arch",
"Status",
"Priority",
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index 4c2a8b6b8..943575956 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -805,7 +805,7 @@ bool TFRewrite(FILE *Output,pkgTagSection const &Tags,const char *Order[],
Rewrite[J].NewTag = Rewrite[J].Tag;
}
- // Write all all of the tags, in order.
+ // Write all of the tags, in order.
if (Order != NULL)
{
for (unsigned int I = 0; Order[I] != 0; I++)
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
index a788e1044..04e20a5e8 100644
--- a/apt-pkg/tagfile.h
+++ b/apt-pkg/tagfile.h
@@ -146,7 +146,7 @@ class pkgTagSection
/** \brief amount of Tags in the current section
*
- * Note: if a Tag is mentioned repeatly it will be counted multiple
+ * Note: if a Tag is mentioned repeatedly it will be counted multiple
* times, but only the last occurrence is available via Find methods.
*/
unsigned int Count() const;
diff --git a/apt-pkg/update.h b/apt-pkg/update.h
index e35cd14f6..559516f1b 100644
--- a/apt-pkg/update.h
+++ b/apt-pkg/update.h
@@ -2,8 +2,8 @@
// Description /*{{{*/
/* ######################################################################
- Update - ListUpdate releated code
-
+ Update - ListUpdate related code
+
##################################################################### */
/*}}}*/
diff --git a/apt-pkg/upgrade.cc b/apt-pkg/upgrade.cc
index afc9ad613..a61789c11 100644
--- a/apt-pkg/upgrade.cc
+++ b/apt-pkg/upgrade.cc
@@ -210,7 +210,7 @@ static bool pkgAllUpgradeWithNewPackages(pkgDepCache &Cache, OpProgress * const
if (Progress != NULL)
Progress->Progress(50);
- // ... but it may remove stuff, we we need to clean up afterwards again
+ // ... but it may remove stuff, we need to clean up afterwards again
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
if (Cache[I].Delete() == true)
Cache.MarkKeep(I, false, false);
diff --git a/apt-pkg/upgrade.h b/apt-pkg/upgrade.h
index 71dbb4fd3..2d9c0fa36 100644
--- a/apt-pkg/upgrade.h
+++ b/apt-pkg/upgrade.h
@@ -2,8 +2,8 @@
// Description /*{{{*/
/* ######################################################################
- Upgrade - Upgrade/DistUpgrade releated code
-
+ Upgrade - Upgrade/DistUpgrade related code
+
##################################################################### */
/*}}}*/