summaryrefslogtreecommitdiff
path: root/apt-pkg/pkgcachegen.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/pkgcachegen.cc')
-rw-r--r--apt-pkg/pkgcachegen.cc70
1 files changed, 66 insertions, 4 deletions
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index f70cbd02a..373f6625c 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -69,7 +69,9 @@ pkgCacheGenerator::pkgCacheGenerator(DynamicMMap *pMap,OpProgress *Prog) :
*Cache.HeaderP = pkgCache::Header();
map_ptrloc const idxVerSysName = WriteStringInMap(_system->VS->Label);
Cache.HeaderP->VerSysName = idxVerSysName;
- map_ptrloc const idxArchitecture = WriteStringInMap(_config->Find("APT::Architecture"));
+ // this pointer is set in ReMap, but we need it now for WriteUniqString
+ Cache.StringItemP = (pkgCache::StringItem *)Map.Data();
+ map_ptrloc const idxArchitecture = WriteUniqString(_config->Find("APT::Architecture"));
Cache.HeaderP->Architecture = idxArchitecture;
if (unlikely(idxVerSysName == 0 || idxArchitecture == 0))
return;
@@ -195,12 +197,27 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
string const Version = List.Version();
if (Version.empty() == true && Arch.empty() == true)
{
+ // package descriptions
if (MergeListGroup(List, PackageName) == false)
return false;
+ continue;
}
if (Arch.empty() == true)
- Arch = _config->Find("APT::Architecture");
+ {
+ // use the pseudo arch 'none' for arch-less packages
+ Arch = "none";
+ /* We might built a SingleArchCache here, which we don't want to blow up
+ just for these :none packages to a proper MultiArchCache, so just ensure
+ that we have always a native package structure first for SingleArch */
+ pkgCache::PkgIterator NP;
+ Dynamic<pkgCache::PkgIterator> DynPkg(NP);
+ if (NewPackage(NP, PackageName, _config->Find("APT::Architecture")) == false)
+ // TRANSLATOR: The first placeholder is a package name,
+ // the other two should be copied verbatim as they include debug info
+ return _error->Error(_("Error occurred while processing %s (%s%d)"),
+ PackageName.c_str(), "NewPackage", 0);
+ }
// Get a pointer to the package structure
pkgCache::PkgIterator Pkg;
@@ -418,6 +435,43 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator
return _error->Error(_("Error occurred while processing %s (%s%d)"),
Pkg.Name(), "AddImplicitDepends", 1);
}
+ /* :none packages are packages without an architecture. They are forbidden by
+ debian-policy, so usually they will only be in (old) dpkg status files -
+ and dpkg will complain about them - and are pretty rare. We therefore do
+ usually not create conflicts while the parent is created, but only if a :none
+ package (= the target) appears. This creates incorrect dependencies on :none
+ for architecture-specific dependencies on the package we copy from, but we
+ will ignore this bug as architecture-specific dependencies are only allowed
+ in jessie and until then the :none packages should be extinct (hopefully).
+ In other words: This should work long enough to allow graceful removal of
+ these packages, it is not supposed to allow users to keep using them … */
+ if (strcmp(Pkg.Arch(), "none") == 0)
+ {
+ pkgCache::PkgIterator M = Grp.FindPreferredPkg();
+ if (M.end() == false && Pkg != M)
+ {
+ pkgCache::DepIterator D = M.RevDependsList();
+ Dynamic<pkgCache::DepIterator> DynD(D);
+ for (; D.end() == false; ++D)
+ {
+ if ((D->Type != pkgCache::Dep::Conflicts &&
+ D->Type != pkgCache::Dep::DpkgBreaks &&
+ D->Type != pkgCache::Dep::Replaces) ||
+ D.ParentPkg().Group() == Grp)
+ continue;
+
+ map_ptrloc *OldDepLast = NULL;
+ pkgCache::VerIterator ConVersion = D.ParentVer();
+ Dynamic<pkgCache::VerIterator> DynV(ConVersion);
+ // duplicate the Conflicts/Breaks/Replaces for :none arch
+ if (D->Version == 0)
+ NewDepends(Pkg, ConVersion, "", 0, D->Type, OldDepLast);
+ else
+ NewDepends(Pkg, ConVersion, D.TargetVer(),
+ D->CompareOp, D->Type, OldDepLast);
+ }
+ }
+ }
}
if (unlikely(AddImplicitDepends(Grp, Pkg, Ver) == false))
return _error->Error(_("Error occurred while processing %s (%s%d)"),
@@ -722,6 +776,7 @@ unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
// Fill it in
Ver = pkgCache::VerIterator(Cache,Cache.VerP + Version);
+ //Dynamic<pkgCache::VerIterator> DynV(Ver); // caller MergeListVersion already takes care of it
Ver->NextVer = Next;
Ver->ID = Cache.HeaderP->VersionCount++;
map_ptrloc const idxVerStr = WriteStringInMap(VerStr);
@@ -871,6 +926,9 @@ bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator &Ver,
// Locate the target package
pkgCache::PkgIterator Pkg = Grp.FindPkg(Arch);
+ // we don't create 'none' packages and their dependencies if we can avoid it …
+ if (Pkg.end() == true && Arch == "none" && strcmp(Ver.ParentPkg().Arch(), "none") != 0)
+ return true;
Dynamic<pkgCache::PkgIterator> DynPkg(Pkg);
if (Pkg.end() == true) {
if (unlikely(Owner->NewPackage(Pkg, PackageName, Arch) == false))
@@ -917,8 +975,12 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver,
Prv->Version = Ver.Index();
Prv->NextPkgProv = Ver->ProvidesList;
Ver->ProvidesList = Prv.Index();
- if (Version.empty() == false && unlikely((Prv->ProvideVersion = WriteString(Version)) == 0))
- return false;
+ if (Version.empty() == false) {
+ map_ptrloc const idxProvideVersion = WriteString(Version);
+ Prv->ProvideVersion = idxProvideVersion;
+ if (unlikely(idxProvideVersion == 0))
+ return false;
+ }
// Locate the target package
pkgCache::PkgIterator Pkg;