*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;
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
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);
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);
+ NewDepends(Pkg, ConVersion, D->Version,
+ D->CompareOp, D->Type, OldDepLast);
}
}
}
// 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);
bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same);
pkgCache::PkgIterator D = G.PackageList();
Dynamic<pkgCache::PkgIterator> DynD(D);
+ map_ptrloc const VerStrIdx = V->VerStr;
for (; D.end() != true; D = G.NextPkg(D))
{
if (Arch == D.Arch() || D->VersionList == 0)
if (coInstall == true)
{
// Replaces: ${self}:other ( << ${binary:Version})
- NewDepends(D, V, V.VerStr(),
+ NewDepends(D, V, VerStrIdx,
pkgCache::Dep::Less, pkgCache::Dep::Replaces,
OldDepLast);
// Breaks: ${self}:other (!= ${binary:Version})
- NewDepends(D, V, V.VerStr(),
+ NewDepends(D, V, VerStrIdx,
pkgCache::Dep::NotEquals, pkgCache::Dep::DpkgBreaks,
OldDepLast);
} else {
// Conflicts: ${self}:other
- NewDepends(D, V, "",
+ NewDepends(D, V, 0,
pkgCache::Dep::NoOp, pkgCache::Dep::Conflicts,
OldDepLast);
}
bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same);
if (coInstall == true)
{
+ map_ptrloc const VerStrIdx = V->VerStr;
// Replaces: ${self}:other ( << ${binary:Version})
- NewDepends(D, V, V.VerStr(),
+ NewDepends(D, V, VerStrIdx,
pkgCache::Dep::Less, pkgCache::Dep::Replaces,
OldDepLast);
// Breaks: ${self}:other (!= ${binary:Version})
- NewDepends(D, V, V.VerStr(),
+ NewDepends(D, V, VerStrIdx,
pkgCache::Dep::NotEquals, pkgCache::Dep::DpkgBreaks,
OldDepLast);
} else {
// Conflicts: ${self}:other
- NewDepends(D, V, "",
+ NewDepends(D, V, 0,
pkgCache::Dep::NoOp, pkgCache::Dep::Conflicts,
OldDepLast);
}
// 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;
}
unsigned int const &Op,
unsigned int const &Type,
map_ptrloc* &OldDepLast)
+{
+ map_ptrloc index = 0;
+ if (Version.empty() == false)
+ {
+ void const * const oldMap = Map.Data();
+ index = WriteStringInMap(Version);
+ if (unlikely(index == 0))
+ return false;
+ if (oldMap != Map.Data())
+ OldDepLast += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
+ }
+ return NewDepends(Pkg, Ver, index, Op, Type, OldDepLast);
+}
+bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg,
+ pkgCache::VerIterator &Ver,
+ map_ptrloc const Version,
+ unsigned int const &Op,
+ unsigned int const &Type,
+ map_ptrloc* &OldDepLast)
{
void const * const oldMap = Map.Data();
// Get a structure
map_ptrloc const Dependency = AllocateInMap(sizeof(pkgCache::Dependency));
if (unlikely(Dependency == 0))
return false;
-
+
// Fill it in
pkgCache::DepIterator Dep(Cache,Cache.DepP + Dependency);
Dynamic<pkgCache::DepIterator> DynDep(Dep);
Dep->ParentVer = Ver.Index();
Dep->Type = Type;
Dep->CompareOp = Op;
+ Dep->Version = Version;
Dep->ID = Cache.HeaderP->DependsCount++;
- // Probe the reverse dependency list for a version string that matches
- if (Version.empty() == false)
- {
-/* for (pkgCache::DepIterator I = Pkg.RevDependsList(); I.end() == false; I++)
- if (I->Version != 0 && I.TargetVer() == Version)
- Dep->Version = I->Version;*/
- if (Dep->Version == 0) {
- map_ptrloc const index = WriteStringInMap(Version);
- if (unlikely(index == 0))
- return false;
- Dep->Version = index;
- }
- }
-
// Link it to the package
Dep->Package = Pkg.Index();
Dep->NextRevDepends = Pkg->RevDepends;
// 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")
+ if (Pkg.end() == true && Arch == "none" && strcmp(Ver.ParentPkg().Arch(), "none") != 0)
return true;
Dynamic<pkgCache::PkgIterator> DynPkg(Pkg);
if (Pkg.end() == true) {
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;