X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/5c6ceb4557cb6497dea827d1ec4e2615ccd53e50..e8a7b0b28ca01cd8c2c1bee0d83e5997b40de689:/apt-pkg/pkgcachegen.cc diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index ec072fddd..360f19736 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -18,27 +18,33 @@ #include #include #include -#include #include #include #include #include -#include #include #include - +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #include #include #include -#include -#include #include /*}}}*/ typedef std::vector::iterator FileIterator; template std::vector pkgCacheGenerator::Dynamic::toReMap; -bool IsDuplicateDescription(pkgCache::DescIterator Desc, +static bool IsDuplicateDescription(pkgCache::DescIterator Desc, MD5SumValue const &CurMd5, std::string const &CurLang); using std::string; @@ -67,12 +73,37 @@ pkgCacheGenerator::pkgCacheGenerator(DynamicMMap *pMap,OpProgress *Prog) : // Starting header *Cache.HeaderP = pkgCache::Header(); + + // make room for the hashtables for packages and groups + if (Map.RawAllocate(2 * (Cache.HeaderP->HashTableSize * sizeof(map_ptrloc))) == 0) + return; + map_ptrloc const idxVerSysName = WriteStringInMap(_system->VS->Label); + if (unlikely(idxVerSysName == 0)) + return; Cache.HeaderP->VerSysName = idxVerSysName; - map_ptrloc const idxArchitecture = WriteStringInMap(_config->Find("APT::Architecture")); - Cache.HeaderP->Architecture = idxArchitecture; - if (unlikely(idxVerSysName == 0 || idxArchitecture == 0)) + // 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")); + if (unlikely(idxArchitecture == 0)) return; + Cache.HeaderP->Architecture = idxArchitecture; + + std::vector archs = APT::Configuration::getArchitectures(); + if (archs.size() > 1) + { + std::vector::const_iterator a = archs.begin(); + std::string list = *a; + for (++a; a != archs.end(); ++a) + list.append(",").append(*a); + map_ptrloc const idxArchitectures = WriteStringInMap(list); + if (unlikely(idxArchitectures == 0)) + return; + Cache.HeaderP->Architectures = idxArchitectures; + } + else + Cache.HeaderP->Architectures = idxArchitecture; + Cache.ReMap(); } else @@ -84,9 +115,9 @@ pkgCacheGenerator::pkgCacheGenerator(DynamicMMap *pMap,OpProgress *Prog) : { _error->Error(_("Cache has an incompatible versioning system")); return; - } + } } - + Cache.HeaderP->Dirty = true; Map.Sync(0,sizeof(pkgCache::Header)); } @@ -116,11 +147,11 @@ void pkgCacheGenerator::ReMap(void const * const oldMap, void const * const newM Cache.ReMap(false); - CurrentFile += (pkgCache::PackageFile*) newMap - (pkgCache::PackageFile*) oldMap; + CurrentFile += (pkgCache::PackageFile const * const) newMap - (pkgCache::PackageFile const * const) oldMap; for (size_t i = 0; i < _count(UniqHash); ++i) if (UniqHash[i] != 0) - UniqHash[i] += (pkgCache::StringItem*) newMap - (pkgCache::StringItem*) oldMap; + UniqHash[i] += (pkgCache::StringItem const * const) newMap - (pkgCache::StringItem const * const) oldMap; for (std::vector::const_iterator i = Dynamic::toReMap.begin(); i != Dynamic::toReMap.end(); ++i) @@ -195,12 +226,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 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; @@ -279,39 +325,27 @@ bool pkgCacheGenerator::MergeListPackage(ListParser &List, pkgCache::PkgIterator // Find the right version to write the description MD5SumValue CurMd5 = List.Description_md5(); - std::string CurLang = List.DescriptionLanguage(); - + if (CurMd5.Value().empty() == true && List.Description("").empty() == true) + return true; + std::vector availDesc = List.AvailableDescriptionLanguages(); 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 (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) - continue; + map_ptrloc md5idx = VerDesc->md5sum; + for (std::vector::const_iterator CurLang = availDesc.begin(); CurLang != availDesc.end(); ++CurLang) + { + // don't add a new description if we have one for the given + // md5 && language + if (IsDuplicateDescription(VerDesc, CurMd5, *CurLang) == true) + continue; - Dynamic 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); - 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) - return _error->Error(_("Error occurred while processing %s (%s%d)"), - Pkg.Name(), "NewFileDesc", 1); + AddNewDescription(List, Ver, *CurLang, CurMd5, md5idx); + } // we can stop here as all "same" versions will share the description break; @@ -329,7 +363,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator map_ptrloc *LastVer = &Pkg->VersionList; void const * oldMap = Map.Data(); - unsigned long const Hash = List.VersionHash(); + unsigned short const Hash = List.VersionHash(); if (Ver.end() == false) { /* We know the list is sorted so we use that fact in the search. @@ -342,7 +376,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator if (Res > 0) break; // Versionstrings are equal - is hash also equal? - if (Res == 0 && Ver->Hash == Hash) + if (Res == 0 && List.SameVersion(Hash, Ver) == true) break; // proceed with the next till we have either the right // or we found another version (which will be lower) @@ -371,16 +405,14 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator } // Add a new version - map_ptrloc const verindex = NewVersion(Ver,Version,*LastVer); + map_ptrloc const verindex = NewVersion(Ver, Version, Pkg.Index(), Hash, *LastVer); if (verindex == 0 && _error->PendingError()) return _error->Error(_("Error occurred while processing %s (%s%d)"), Pkg.Name(), "NewVersion", 1); if (oldMap != Map.Data()) - LastVer += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; + LastVer += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap; *LastVer = verindex; - Ver->ParentPkg = Pkg.Index(); - Ver->Hash = Hash; if (unlikely(List.NewVersion(Ver) == false)) return _error->Error(_("Error occurred while processing %s (%s%d)"), @@ -415,6 +447,40 @@ 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 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 DynV(ConVersion); + // duplicate the Conflicts/Breaks/Replaces for :none arch + NewDepends(Pkg, ConVersion, D->Version, + D->CompareOp, D->Type, OldDepLast); + } + } + } } if (unlikely(AddImplicitDepends(Grp, Pkg, Ver) == false)) return _error->Error(_("Error occurred while processing %s (%s%d)"), @@ -427,11 +493,10 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator return true; } - /* Record the Description (it is not translated) */ + /* Record the Description(s) based on their master md5sum */ MD5SumValue CurMd5 = List.Description_md5(); - if (CurMd5.Value().empty() == true) + if (CurMd5.Value().empty() == true && List.Description("").empty() == true) return true; - std::string CurLang = List.DescriptionLanguage(); /* Before we add a new description we first search in the group for a version with a description of the same MD5 - if so we reuse this @@ -442,28 +507,44 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V) { - if (IsDuplicateDescription(V.DescriptionList(), CurMd5, "") == false) + if (V->DescriptionList == 0 || MD5SumValue(V.DescriptionList().md5()) != CurMd5) continue; Ver->DescriptionList = V->DescriptionList; - return true; } } - // We haven't found reusable descriptions, so add the first description - pkgCache::DescIterator Desc = Ver.DescriptionList(); + // We haven't found reusable descriptions, so add the first description(s) + map_ptrloc md5idx = Ver->DescriptionList == 0 ? 0 : Ver.DescriptionList()->md5sum; + std::vector availDesc = List.AvailableDescriptionLanguages(); + for (std::vector::const_iterator CurLang = availDesc.begin(); CurLang != availDesc.end(); ++CurLang) + if (AddNewDescription(List, Ver, *CurLang, CurMd5, md5idx) == false) + return false; + return true; +} + /*}}}*/ +bool pkgCacheGenerator::AddNewDescription(ListParser &List, pkgCache::VerIterator &Ver, std::string const &lang, MD5SumValue const &CurMd5, map_ptrloc &md5idx) /*{{{*/ +{ + pkgCache::DescIterator Desc; Dynamic DynDesc(Desc); - map_ptrloc *LastDesc = &Ver->DescriptionList; - oldMap = Map.Data(); - map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, *LastDesc); - if (oldMap != Map.Data()) - LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; - *LastDesc = descindex; - Desc->ParentPkg = Pkg.Index(); + map_ptrloc const descindex = NewDescription(Desc, lang, CurMd5, md5idx); + if (unlikely(descindex == 0 && _error->PendingError())) + return _error->Error(_("Error occurred while processing %s (%s%d)"), + Ver.ParentPkg().Name(), "NewDescription", 1); - if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false) + md5idx = Desc->md5sum; + Desc->ParentPkg = Ver.ParentPkg().Index(); + + // we add at the end, so that the start is constant as we need + // that to be able to efficiently share these lists + pkgCache::DescIterator 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", 2); + Ver.ParentPkg().Name(), "NewFileDesc", 1); return true; } @@ -499,12 +580,12 @@ bool pkgCacheGenerator::MergeFileProvides(ListParser &List) if (Counter % 100 == 0 && Progress != 0) Progress->Progress(List.Offset()); - unsigned long Hash = List.VersionHash(); + unsigned short Hash = List.VersionHash(); pkgCache::VerIterator Ver = Pkg.VersionList(); Dynamic DynVer(Ver); for (; Ver.end() == false; ++Ver) { - if (Ver->Hash == Hash && Version.c_str() == Ver.VerStr()) + if (List.SameVersion(Hash, Ver) == true && Version == Ver.VerStr()) { if (List.CollectFileProvides(Cache,Ver) == false) return _error->Error(_("Error occurred while processing %s (%s%d)"), @@ -542,8 +623,11 @@ bool pkgCacheGenerator::NewGroup(pkgCache::GrpIterator &Grp, const string &Name) // Insert it into the hash table unsigned long const Hash = Cache.Hash(Name); - Grp->Next = Cache.HeaderP->GrpHashTable[Hash]; - Cache.HeaderP->GrpHashTable[Hash] = Group; + map_ptrloc *insertAt = &Cache.HeaderP->GrpHashTable()[Hash]; + while (*insertAt != 0 && strcasecmp(Name.c_str(), Cache.StrP + (Cache.GrpP + *insertAt)->Name) > 0) + insertAt = &(Cache.GrpP + *insertAt)->Next; + Grp->Next = *insertAt; + *insertAt = Group; Grp->ID = Cache.HeaderP->GroupCount++; return true; @@ -572,18 +656,21 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name // Insert the package into our package list if (Grp->FirstPackage == 0) // the group is new { + Grp->FirstPackage = Package; // Insert it into the hash table unsigned long const Hash = Cache.Hash(Name); - Pkg->NextPackage = Cache.HeaderP->PkgHashTable[Hash]; - Cache.HeaderP->PkgHashTable[Hash] = Package; - Grp->FirstPackage = Package; + map_ptrloc *insertAt = &Cache.HeaderP->PkgHashTable()[Hash]; + while (*insertAt != 0 && strcasecmp(Name.c_str(), Cache.StrP + (Cache.PkgP + *insertAt)->Name) > 0) + insertAt = &(Cache.PkgP + *insertAt)->Next; + Pkg->Next = *insertAt; + *insertAt = Package; } else // Group the Packages together { // this package is the new last package pkgCache::PkgIterator LastPkg(Cache, Cache.PkgP + Grp->LastPackage); - Pkg->NextPackage = LastPkg->NextPackage; - LastPkg->NextPackage = Package; + Pkg->Next = LastPkg->Next; + LastPkg->Next = Package; } Grp->LastPackage = Package; @@ -615,6 +702,7 @@ bool pkgCacheGenerator::AddImplicitDepends(pkgCache::GrpIterator &G, bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same); pkgCache::PkgIterator D = G.PackageList(); Dynamic DynD(D); + map_ptrloc const VerStrIdx = V->VerStr; for (; D.end() != true; D = G.NextPkg(D)) { if (Arch == D.Arch() || D->VersionList == 0) @@ -625,16 +713,16 @@ bool pkgCacheGenerator::AddImplicitDepends(pkgCache::GrpIterator &G, 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); } @@ -651,17 +739,18 @@ bool pkgCacheGenerator::AddImplicitDepends(pkgCache::VerIterator &V, 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); } @@ -707,6 +796,8 @@ bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver, /* This puts a version structure in the linked list */ unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver, const string &VerStr, + map_ptrloc const ParentPkg, + unsigned long const Hash, unsigned long Next) { // Get a structure @@ -716,13 +807,39 @@ unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver, // Fill it in Ver = pkgCache::VerIterator(Cache,Cache.VerP + Version); + //Dynamic DynV(Ver); // caller MergeListVersion already takes care of it Ver->NextVer = Next; + Ver->ParentPkg = ParentPkg; + Ver->Hash = Hash; Ver->ID = Cache.HeaderP->VersionCount++; + + // try to find the version string in the group for reuse + pkgCache::PkgIterator Pkg = Ver.ParentPkg(); + pkgCache::GrpIterator Grp = Pkg.Group(); + if (Pkg.end() == false && Grp.end() == false) + { + for (pkgCache::PkgIterator P = Grp.PackageList(); P.end() == false; P = Grp.NextPkg(P)) + { + if (Pkg == P) + continue; + for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V) + { + int const cmp = strcmp(V.VerStr(), VerStr.c_str()); + if (cmp == 0) + { + Ver->VerStr = V->VerStr; + return Version; + } + else if (cmp < 0) + break; + } + } + } + // haven't found the version string, so create map_ptrloc const idxVerStr = WriteStringInMap(VerStr); if (unlikely(idxVerStr == 0)) return 0; Ver->VerStr = idxVerStr; - return Version; } /*}}}*/ @@ -764,9 +881,9 @@ bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc, // --------------------------------------------------------------------- /* 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)); @@ -775,14 +892,21 @@ map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc, // 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; } @@ -797,35 +921,49 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg, unsigned int const &Op, unsigned int const &Type, map_ptrloc* &OldDepLast) +{ + map_ptrloc index = 0; + if (Version.empty() == false) + { + int const CmpOp = Op & 0x0F; + // =-deps are used (79:1) for lockstep on same-source packages (e.g. data-packages) + if (CmpOp == pkgCache::Dep::Equals && strcmp(Version.c_str(), Ver.VerStr()) == 0) + index = Ver->VerStr; + + if (index == 0) + { + void const * const oldMap = Map.Data(); + index = WriteStringInMap(Version); + if (unlikely(index == 0)) + return false; + if (OldDepLast != 0 && oldMap != Map.Data()) + OldDepLast += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) 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 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; @@ -838,7 +976,7 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg, for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D) OldDepLast = &D->NextDepends; } else if (oldMap != Map.Data()) - OldDepLast += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; + OldDepLast += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap; Dep->NextDepends = *OldDepLast; *OldDepLast = Dep.Index(); @@ -865,6 +1003,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 DynPkg(Pkg); if (Pkg.end() == true) { if (unlikely(Owner->NewPackage(Pkg, PackageName, Arch) == false)) @@ -911,8 +1052,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; @@ -928,6 +1073,12 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver, return true; } /*}}}*/ +bool pkgCacheGenerator::ListParser::SameVersion(unsigned short const Hash,/*{{{*/ + pkgCache::VerIterator const &Ver) +{ + return Hash == Ver->Hash; +} + /*}}}*/ // CacheGenerator::SelectFile - Select the current file being parsed /*{{{*/ // --------------------------------------------------------------------- /* This is used to select which file is to be associated with all newly @@ -1008,8 +1159,8 @@ unsigned long pkgCacheGenerator::WriteUniqString(const char *S, if (unlikely(idxString == 0)) return 0; if (oldMap != Map.Data()) { - Last += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; - I += (pkgCache::StringItem*) Map.Data() - (pkgCache::StringItem*) oldMap; + Last += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap; + I += (pkgCache::StringItem const * const) Map.Data() - (pkgCache::StringItem const * const) oldMap; } *Last = Item; @@ -1132,10 +1283,10 @@ static bool CheckValidity(const string &CacheFile, static unsigned long ComputeSize(FileIterator Start,FileIterator End) { unsigned long TotalSize = 0; - for (; Start != End; ++Start) + for (; Start < End; ++Start) { if ((*Start)->HasPackages() == false) - continue; + continue; TotalSize += (*Start)->Size(); } return TotalSize; @@ -1216,7 +1367,7 @@ DynamicMMap* pkgCacheGenerator::CreateDynamicMMap(FileFd *CacheF, unsigned long the cache will be stored there. This is pretty much mandetory if you are using AllowMem. AllowMem lets the function be run as non-root where it builds the cache 'fast' into a memory buffer. */ -__deprecated bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, +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, @@ -1310,10 +1461,11 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress } _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) @@ -1416,7 +1568,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress // CacheGenerator::MakeOnlyStatusCache - Build only a status files cache/*{{{*/ // --------------------------------------------------------------------- /* */ -__deprecated bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap) +APT_DEPRECATED bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap) { return pkgCacheGenerator::MakeOnlyStatusCache(&Progress, OutMap); } bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **OutMap) { @@ -1449,11 +1601,11 @@ bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **O } /*}}}*/ // 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 - if (MD5SumValue(Desc.md5()) != CurMd5) + if (Desc.end() == true || MD5SumValue(Desc.md5()) != CurMd5) return false; for (; Desc.end() == false; ++Desc) if (Desc.LanguageCode() == CurLang) @@ -1462,7 +1614,7 @@ bool IsDuplicateDescription(pkgCache::DescIterator Desc, } /*}}}*/ // CacheGenerator::FinishCache /*{{{*/ -bool pkgCacheGenerator::FinishCache(OpProgress *Progress) +bool pkgCacheGenerator::FinishCache(OpProgress * /*Progress*/) { return true; }