typedef std::vector<pkgIndexFile *>::iterator FileIterator;
template <typename Iter> std::vector<Iter*> pkgCacheGenerator::Dynamic<Iter>::toReMap;
-bool IsDuplicateDescription(pkgCache::DescIterator Desc,
+static bool IsDuplicateDescription(pkgCache::DescIterator Desc,
MD5SumValue const &CurMd5, std::string const &CurLang);
using std::string;
*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;
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;
for (Ver = Pkg.VersionList(); Ver.end() == false; ++Ver)
{
- pkgCache::DescIterator Desc = Ver.DescriptionList();
+ pkgCache::DescIterator VerDesc = Ver.DescriptionList();
// a version can only have one md5 describing it
- if (Desc.end() == true || MD5SumValue(Desc.md5()) != CurMd5)
+ if (VerDesc.end() == true || MD5SumValue(VerDesc.md5()) != CurMd5)
continue;
// don't add a new description if we have one for the given
// md5 && language
- if (IsDuplicateDescription(Desc, CurMd5, CurLang) == true)
+ if (IsDuplicateDescription(VerDesc, CurMd5, CurLang) == true)
continue;
+ pkgCache::DescIterator Desc;
Dynamic<pkgCache::DescIterator> DynDesc(Desc);
- // we add at the end, so that the start is constant as we need
- // that to be able to efficiently share these lists
- map_ptrloc *LastDesc = &Ver->DescriptionList;
- for (;Desc.end() == false && Desc->NextDesc != 0; ++Desc);
- if (Desc.end() == false)
- LastDesc = &Desc->NextDesc;
- void const * const oldMap = Map.Data();
- map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, *LastDesc);
+ map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, VerDesc->md5sum);
if (unlikely(descindex == 0 && _error->PendingError()))
return _error->Error(_("Error occurred while processing %s (%s%d)"),
Pkg.Name(), "NewDescription", 1);
- if (oldMap != Map.Data())
- LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
- *LastDesc = descindex;
+
Desc->ParentPkg = Pkg.Index();
- if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false)
+ // we add at the end, so that the start is constant as we need
+ // that to be able to efficiently share these lists
+ VerDesc = Ver.DescriptionList(); // old value might be invalid after ReMap
+ for (;VerDesc.end() == false && VerDesc->NextDesc != 0; ++VerDesc);
+ map_ptrloc * const LastNextDesc = (VerDesc.end() == true) ? &Ver->DescriptionList : &VerDesc->NextDesc;
+ *LastNextDesc = descindex;
+
+ if (NewFileDesc(Desc,List) == false)
return _error->Error(_("Error occurred while processing %s (%s%d)"),
Pkg.Name(), "NewFileDesc", 1);
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)"),
// We haven't found reusable descriptions, so add the first description
pkgCache::DescIterator Desc = Ver.DescriptionList();
Dynamic<pkgCache::DescIterator> DynDesc(Desc);
- map_ptrloc *LastDesc = &Ver->DescriptionList;
- oldMap = Map.Data();
- map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, *LastDesc);
+ map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, 0);
if (unlikely(descindex == 0 && _error->PendingError()))
return _error->Error(_("Error occurred while processing %s (%s%d)"),
Pkg.Name(), "NewDescription", 2);
- if (oldMap != Map.Data())
- LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
- *LastDesc = descindex;
+
Desc->ParentPkg = Pkg.Index();
+ Ver->DescriptionList = descindex;
- if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false)
+ if (NewFileDesc(Desc,List) == false)
return _error->Error(_("Error occurred while processing %s (%s%d)"),
Pkg.Name(), "NewFileDesc", 2);
// 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);
// ---------------------------------------------------------------------
/* This puts a description structure in the linked list */
map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc,
- const string &Lang,
- const MD5SumValue &md5sum,
- map_ptrloc Next)
+ const string &Lang,
+ const MD5SumValue &md5sum,
+ map_ptrloc idxmd5str)
{
// Get a structure
map_ptrloc const Description = AllocateInMap(sizeof(pkgCache::Description));
// Fill it in
Desc = pkgCache::DescIterator(Cache,Cache.DescP + Description);
- Desc->NextDesc = Next;
Desc->ID = Cache.HeaderP->DescriptionCount++;
- map_ptrloc const idxlanguage_code = WriteStringInMap(Lang);
- map_ptrloc const idxmd5sum = WriteStringInMap(md5sum.Value());
- if (unlikely(idxlanguage_code == 0 || idxmd5sum == 0))
+ map_ptrloc const idxlanguage_code = WriteUniqString(Lang);
+ if (unlikely(idxlanguage_code == 0))
return 0;
Desc->language_code = idxlanguage_code;
- Desc->md5sum = idxmd5sum;
+
+ if (idxmd5str != 0)
+ Desc->md5sum = idxmd5str;
+ else
+ {
+ map_ptrloc const idxmd5sum = WriteStringInMap(md5sum.Value());
+ if (unlikely(idxmd5sum == 0))
+ return 0;
+ Desc->md5sum = idxmd5sum;
+ }
return Description;
}
// 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))
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;
}
_error->RevertToStack();
}
- else if (Debug == true)
+ else
{
_error->MergeWithStack();
- std::clog << "Open filebased MMap" << std::endl;
+ if (Debug == true)
+ std::clog << "Open filebased MMap" << std::endl;
}
}
if (Writeable == false || CacheFile.empty() == true)
}
/*}}}*/
// IsDuplicateDescription /*{{{*/
-bool IsDuplicateDescription(pkgCache::DescIterator Desc,
+static bool IsDuplicateDescription(pkgCache::DescIterator Desc,
MD5SumValue const &CurMd5, std::string const &CurLang)
{
// Descriptions in the same link-list have all the same md5