summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc4
-rw-r--r--apt-pkg/acquire-worker.cc11
-rw-r--r--apt-pkg/acquire.h2
-rw-r--r--apt-pkg/cachefile.cc7
-rw-r--r--apt-pkg/cacheiterators.h2
-rw-r--r--apt-pkg/cacheset.cc10
-rw-r--r--apt-pkg/deb/debmetaindex.cc19
-rw-r--r--apt-pkg/orderlist.cc2
-rw-r--r--apt-pkg/packagemanager.cc41
-rw-r--r--apt-pkg/packagemanager.h1
-rw-r--r--apt-pkg/pkgcachegen.cc50
11 files changed, 106 insertions, 43 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 26c835444..7dcaa25a4 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -2935,6 +2935,10 @@ void pkgAcqChangelog::Init(std::string const &DestDir, std::string const &DestFi
return;
}
DestFile = TemporaryDirectory = tmpname;
+
+ std::string SandboxUser = _config->Find("APT::Sandbox::User");
+ ChangeOwnerAndPermissionOfFile("Item::QueueURI", DestFile.c_str(),
+ SandboxUser.c_str(), "root", 0700);
}
else
DestFile = DestDir;
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index b15340448..176772dde 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -335,9 +335,10 @@ bool pkgAcquire::Worker::RunMessages()
for (pkgAcquire::Queue::QItem::owner_iterator O = Itm->Owners.begin(); O != Itm->Owners.end(); ++O)
Log->Pulse((*O)->GetOwner());
- std::string const filename = LookupTag(Message, "Filename", Itm->Owner->DestFile.c_str());
HashStringList ReceivedHashes;
{
+ std::string const givenfilename = LookupTag(Message, "Filename");
+ std::string const filename = givenfilename.empty() ? Itm->Owner->DestFile : givenfilename;
// see if we got hashes to verify
for (char const * const * type = HashString::SupportedHashes(); *type != NULL; ++type)
{
@@ -358,11 +359,11 @@ bool pkgAcquire::Worker::RunMessages()
ReceivedHashes = calc.GetHashStringList();
}
}
- }
- // only local files can refer other filenames and counting them as fetched would be unfair
- if (Log != NULL && filename != Itm->Owner->DestFile)
- Log->Fetched(ReceivedHashes.FileSize(),atoi(LookupTag(Message,"Resume-Point","0").c_str()));
+ // only local files can refer other filenames and counting them as fetched would be unfair
+ if (Log != NULL && Itm->Owner->Complete == false && Itm->Owner->Local == false && givenfilename == filename)
+ Log->Fetched(ReceivedHashes.FileSize(),atoi(LookupTag(Message,"Resume-Point","0").c_str()));
+ }
std::vector<Item*> const ItmOwners = Itm->Owners;
OwnerQ->ItemDone(Itm);
diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h
index 0d2b21233..10025a6ef 100644
--- a/apt-pkg/acquire.h
+++ b/apt-pkg/acquire.h
@@ -4,7 +4,7 @@
Acquire - File Acquiration
- This module contians the Acquire system. It is responsible for bringing
+ This module contains the Acquire system. It is responsible for bringing
files into the local pathname space. It deals with URIs for files and
URI handlers responsible for downloading or finding the URIs.
diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc
index 214864095..567e0ea9a 100644
--- a/apt-pkg/cachefile.cc
+++ b/apt-pkg/cachefile.cc
@@ -84,17 +84,14 @@ bool pkgCacheFile::BuildCaches(OpProgress *Progress, bool WithLock)
if (WithLock == true)
if (_system->Lock() == false)
return false;
-
- if (_config->FindB("Debug::NoLocking",false) == true)
- WithLock = false;
-
+
if (_error->PendingError() == true)
return false;
BuildSourceList(Progress);
// Read the caches
- bool Res = pkgCacheGenerator::MakeStatusCache(*SrcList,Progress,&Map,!WithLock);
+ bool Res = pkgCacheGenerator::MakeStatusCache(*SrcList,Progress,&Map, true);
if (Progress != NULL)
Progress->Done();
if (Res == false)
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h
index 48547e564..887d2e691 100644
--- a/apt-pkg/cacheiterators.h
+++ b/apt-pkg/cacheiterators.h
@@ -298,7 +298,7 @@ class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
return (S2->CompareOp & pkgCache::Dep::MultiArchImplicit) == pkgCache::Dep::MultiArchImplicit;
}
/* This covers additionally negative dependencies, which aren't arch-specific,
- but change architecture nontheless as a Conflicts: foo does applies for all archs */
+ but change architecture nonetheless as a Conflicts: foo does applies for all archs */
bool IsImplicit() const APT_PURE;
bool IsSatisfied(VerIterator const &Ver) const APT_PURE;
diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc
index af607a197..6a625184e 100644
--- a/apt-pkg/cacheset.cc
+++ b/apt-pkg/cacheset.cc
@@ -696,12 +696,12 @@ bool VersionContainerInterface::FromDependency(VersionContainerInterface * const
pkgCache::VerIterator VersionContainerInterface::getCandidateVer(pkgCacheFile &Cache,
pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) {
pkgCache::VerIterator Cand;
- if (Cache.IsPolicyBuilt() == true || Cache.IsDepCacheBuilt() == false) {
- if (unlikely(Cache.GetPolicy() == 0))
- return pkgCache::VerIterator(Cache);
- Cand = Cache.GetPolicy()->GetCandidateVer(Pkg);
- } else {
+ if (Cache.IsDepCacheBuilt() == true) {
Cand = Cache[Pkg].CandidateVerIter(Cache);
+ } else if (unlikely(Cache.GetPolicy() == nullptr)) {
+ return pkgCache::VerIterator(Cache);
+ } else {
+ Cand = Cache.GetPolicy()->GetCandidateVer(Pkg);
}
if (Cand.end() == true)
return helper.canNotGetVersion(CacheSetHelper::CANDIDATE, Cache, Pkg);
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index b2e9eeb00..69e41a6f4 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -154,7 +154,7 @@ static void GetIndexTargetsFor(char const * const Type, std::string const &URI,
Options.insert(std::make_pair("ARCHITECTURE", *A));
Options.insert(std::make_pair("BASE_URI", baseURI));
Options.insert(std::make_pair("REPO_URI", URI));
- Options.insert(std::make_pair("TARGET_OF", "deb-src"));
+ Options.insert(std::make_pair("TARGET_OF", Type));
Options.insert(std::make_pair("CREATED_BY", *T));
std::string MetaKey = tplMetaKey;
@@ -715,10 +715,25 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/
List.push_back(Deb);
}
+ std::vector<std::string> const alltargets = _config->FindVector(std::string("Acquire::IndexTargets::") + Name, "", true);
+ std::vector<std::string> mytargets = parsePlusMinusOptions("target", Options, alltargets);
+ if (mytargets.empty() == false)
+ for (auto const &target : alltargets)
+ {
+ std::map<std::string, std::string>::const_iterator const opt = Options.find(target);
+ if (opt == Options.end())
+ continue;
+ auto const tarItr = std::find(mytargets.begin(), mytargets.end(), target);
+ bool const optValue = StringToBool(opt->second);
+ if (optValue == true && tarItr == mytargets.end())
+ mytargets.push_back(target);
+ else if (optValue == false && tarItr != mytargets.end())
+ mytargets.erase(std::remove(mytargets.begin(), mytargets.end(), target), mytargets.end());
+ }
Deb->AddComponent(
IsSrc,
Section,
- parsePlusMinusOptions("target", Options, _config->FindVector(std::string("Acquire::IndexTargets::") + Name, "", true)),
+ mytargets,
parsePlusMinusOptions("arch", Options, APT::Configuration::getArchitectures()),
parsePlusMinusOptions("lang", Options, APT::Configuration::getLanguages(true))
);
diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc
index 1e0640422..d1118e319 100644
--- a/apt-pkg/orderlist.cc
+++ b/apt-pkg/orderlist.cc
@@ -257,7 +257,7 @@ bool pkgOrderList::OrderUnpack(string *FileList)
clog << "** Pass C" << endl;
LoopCount = 0;
RevDepends = 0;
- Remove = 0; // Otherwise the libreadline remove problem occures
+ Remove = 0; // Otherwise the libreadline remove problem occurs
if (DoRun() == false)
return false;
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index 06ec986ed..ceeb60a03 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -268,6 +268,33 @@ bool pkgPackageManager::CheckRConflicts(PkgIterator Pkg,DepIterator D,
return true;
}
/*}}}*/
+// PM::CheckRBreaks - Look for reverse breaks /*{{{*/
+bool pkgPackageManager::CheckRBreaks(PkgIterator const &Pkg, DepIterator D,
+ const char * const Ver)
+{
+ for (;D.end() == false; ++D)
+ {
+ if (D->Type != pkgCache::Dep::DpkgBreaks)
+ continue;
+
+ PkgIterator const DP = D.ParentPkg();
+ if (Cache[DP].Delete() == false)
+ continue;
+
+ // Ignore self conflicts, ignore conflicts from irrelevant versions
+ if (D.IsIgnorable(Pkg) || D.ParentVer() != DP.CurrentVer())
+ continue;
+
+ if (Cache.VS().CheckDep(Ver, D->CompareOp, D.TargetVer()) == false)
+ continue;
+
+ // no earlyremove() here as user has already agreed to the permanent removal
+ if (SmartRemove(DP) == false)
+ return _error->Error("Internal Error, Could not early remove %s (%d)",DP.FullName().c_str(), 4);
+ }
+ return true;
+}
+ /*}}}*/
// PM::ConfigureAll - Run the all out configuration /*{{{*/
// ---------------------------------------------------------------------
/* This configures every package. It is assumed they are all unpacked and
@@ -561,6 +588,14 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
if (Bad == true)
return _error->Error(_("Could not configure '%s'. "),Pkg.FullName().c_str());
+ // Check for reverse conflicts.
+ if (CheckRBreaks(Pkg,Pkg.RevDependsList(), instVer.VerStr()) == false)
+ return false;
+
+ for (PrvIterator P = instVer.ProvidesList(); P.end() == false; ++P)
+ if (Pkg->Group != P.OwnerPkg()->Group)
+ CheckRBreaks(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion());
+
if (PkgLoop) return true;
static std::string const conf = _config->Find("PackageManager::Configure","all");
@@ -847,7 +882,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
clog << OutputInDepth(Depth) << "Because of conflict knot, removing " << ConflictPkg.FullName() << " temporarily" << endl;
}
if (EarlyRemove(ConflictPkg, &End) == false)
- return _error->Error("Internal Error, Could not early remove %s (2)",ConflictPkg.FullName().c_str());
+ return _error->Error("Internal Error, Could not early remove %s (%d)",ConflictPkg.FullName().c_str(), 3);
SomethingBad = true;
continue;
}
@@ -889,7 +924,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
if (Debug)
clog << OutputInDepth(Depth) << "So temprorary remove/deconfigure " << ConflictPkg.FullName() << " to satisfy " << End << endl;
if (EarlyRemove(ConflictPkg, &End) == false)
- return _error->Error("Internal Error, Could not early remove %s (2)",ConflictPkg.FullName().c_str());
+ return _error->Error("Internal Error, Could not early remove %s (%d)",ConflictPkg.FullName().c_str(), 2);
}
}
else
@@ -901,7 +936,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
clog << OutputInDepth(Depth) << "Removing " << ConflictPkg.FullName() << " now to avoid " << End << endl;
// no earlyremove() here as user has already agreed to the permanent removal
if (SmartRemove(Pkg) == false)
- return _error->Error("Internal Error, Could not early remove %s (1)",ConflictPkg.FullName().c_str());
+ 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 8de6ab3ad..e4d20fff4 100644
--- a/apt-pkg/packagemanager.h
+++ b/apt-pkg/packagemanager.h
@@ -76,6 +76,7 @@ class pkgPackageManager : protected pkgCache::Namespace
void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0);
virtual OrderResult OrderInstall();
bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
+ bool CheckRBreaks(PkgIterator const &Pkg,DepIterator Dep,const char * const Ver);
bool CreateOrderList();
// Analysis helpers
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 6daebbc2a..802af172c 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -572,21 +572,31 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name
if (APT::Configuration::checkArchitecture(Pkg.Arch()) == true)
{
pkgCache::PkgIterator const M = Grp.FindPreferredPkg(false); // native or any foreign pkg will do
- if (M.end() == false)
- for (pkgCache::PrvIterator Prv = M.ProvidesList(); Prv.end() == false; ++Prv)
+ if (M.end() == false) {
+ pkgCache::PrvIterator Prv;
+ Dynamic<pkgCache::PrvIterator> DynPrv(Prv);
+ for (Prv = M.ProvidesList(); Prv.end() == false; ++Prv)
{
if ((Prv->Flags & pkgCache::Flag::ArchSpecific) != 0)
continue;
pkgCache::VerIterator Ver = Prv.OwnerVer();
+ Dynamic<pkgCache::VerIterator> DynVer(Ver);
if ((Ver->MultiArch & pkgCache::Version::Allowed) == pkgCache::Version::Allowed ||
((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign &&
(Prv->Flags & pkgCache::Flag::MultiArchImplicit) == 0))
if (NewProvides(Ver, Pkg, Prv->ProvideVersion, Prv->Flags) == false)
return false;
}
+ }
+
+
+ pkgCache::PkgIterator P;
+ pkgCache::VerIterator Ver;
+ Dynamic<pkgCache::PkgIterator> DynP(P);
+ Dynamic<pkgCache::VerIterator> DynVer(Ver);
- for (pkgCache::PkgIterator P = Grp.PackageList(); P.end() == false; P = Grp.NextPkg(P))
- for (pkgCache::VerIterator Ver = P.VersionList(); Ver.end() == false; ++Ver)
+ for (P = Grp.PackageList(); P.end() == false; P = Grp.NextPkg(P))
+ for (Ver = P.VersionList(); Ver.end() == false; ++Ver)
if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign)
if (NewProvides(Ver, Pkg, Ver->VerStr, pkgCache::Flag::MultiArchImplicit) == false)
return false;
@@ -594,8 +604,10 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name
// and negative dependencies, don't forget negative dependencies
{
pkgCache::PkgIterator const M = Grp.FindPreferredPkg(false);
- if (M.end() == false)
- for (pkgCache::DepIterator Dep = M.RevDependsList(); Dep.end() == false; ++Dep)
+ if (M.end() == false) {
+ pkgCache::DepIterator Dep;
+ Dynamic<pkgCache::DepIterator> DynDep(Dep);
+ for (Dep = M.RevDependsList(); Dep.end() == false; ++Dep)
{
if ((Dep->CompareOp & (pkgCache::Dep::ArchSpecific | pkgCache::Dep::MultiArchImplicit)) != 0)
continue;
@@ -603,10 +615,12 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name
Dep->Type != pkgCache::Dep::Replaces)
continue;
pkgCache::VerIterator Ver = Dep.ParentVer();
+ Dynamic<pkgCache::VerIterator> DynVer(Ver);
map_pointer_t * unused = NULL;
if (NewDepends(Pkg, Ver, Dep->Version, Dep->CompareOp, Dep->Type, unused) == false)
return false;
}
+ }
}
// this package is the new last package
@@ -1071,7 +1085,9 @@ bool pkgCacheGenerator::NewProvides(pkgCache::VerIterator &Ver,
bool pkgCacheListParser::NewProvidesAllArch(pkgCache::VerIterator &Ver, string const &Package,
string const &Version, uint8_t const Flags) {
pkgCache &Cache = Owner->Cache;
- pkgCache::GrpIterator const Grp = Cache.FindGrp(Package);
+ pkgCache::GrpIterator Grp = Cache.FindGrp(Package);
+ Dynamic<pkgCache::GrpIterator> DynGrp(Grp);
+
if (Grp.end() == true)
return NewProvides(Ver, Package, Cache.NativeArch(), Version, Flags);
else
@@ -1085,8 +1101,11 @@ bool pkgCacheListParser::NewProvidesAllArch(pkgCache::VerIterator &Ver, string c
bool const isImplicit = (Flags & pkgCache::Flag::MultiArchImplicit) == pkgCache::Flag::MultiArchImplicit;
bool const isArchSpecific = (Flags & pkgCache::Flag::ArchSpecific) == pkgCache::Flag::ArchSpecific;
- pkgCache::PkgIterator const OwnerPkg = Ver.ParentPkg();
- for (pkgCache::PkgIterator Pkg = Grp.PackageList(); Pkg.end() == false; Pkg = Grp.NextPkg(Pkg))
+ pkgCache::PkgIterator OwnerPkg = Ver.ParentPkg();
+ Dynamic<pkgCache::PkgIterator> DynOwnerPkg(OwnerPkg);
+ pkgCache::PkgIterator Pkg;
+ Dynamic<pkgCache::PkgIterator> DynPkg(Pkg);
+ for (Pkg = Grp.PackageList(); Pkg.end() == false; Pkg = Grp.NextPkg(Pkg))
{
if (isImplicit && OwnerPkg == Pkg)
continue;
@@ -1497,8 +1516,9 @@ APT_DEPRECATED bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
MMap **OutMap, bool AllowMem)
{ return pkgCacheGenerator::MakeStatusCache(List, &Progress, OutMap, AllowMem); }
bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress,
- MMap **OutMap,bool AllowMem)
+ MMap **OutMap,bool)
{
+ // FIXME: deprecate the ignored AllowMem parameter
bool const Debug = _config->FindB("Debug::pkgCacheGen", false);
std::vector<pkgIndexFile *> Files;
@@ -1563,16 +1583,6 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
if (Debug == true)
std::clog << "Do we have write-access to the cache files? " << (Writeable ? "YES" : "NO") << std::endl;
-
- if (Writeable == false && AllowMem == false)
- {
- if (CacheFile.empty() == false)
- return _error->Error(_("Unable to write to %s"),flNotFile(CacheFile).c_str());
- else if (SrcCacheFile.empty() == false)
- return _error->Error(_("Unable to write to %s"),flNotFile(SrcCacheFile).c_str());
- else
- return _error->Error("Unable to create caches as file usage is disabled, but memory not allowed either!");
- }
}
// At this point we know we need to construct something, so get storage ready