X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/f378b41f9ab2493bcbc5892d482b18826b0b84c0..9fa247dc9ba2aa28ae564e96cba5b2b23bcac91b:/apt-pkg/pkgcachegen.cc diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 1d997678c..51bb9ec7b 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -45,8 +45,8 @@ template using Dynamic = pkgCacheGenerator::Dynamic; typedef std::vector::iterator FileIterator; template std::vector pkgCacheGenerator::Dynamic::toReMap; -static bool IsDuplicateDescription(pkgCache::DescIterator Desc, - MD5SumValue const &CurMd5, std::string const &CurLang); +static bool IsDuplicateDescription(pkgCache &Cache, pkgCache::DescIterator Desc, + APT::StringView CurMd5, std::string const &CurLang); using std::string; using APT::StringView; @@ -249,8 +249,10 @@ bool pkgCacheGenerator::MergeList(ListParser &List, while (List.Step() == true) { string const PackageName = List.Package(); - if (PackageName.empty() == true) - return false; + if (PackageName.empty() == true) { + _error->Warning("Encountered a section with no Package: header"); + continue; + } Counter++; if (Counter % 100 == 0 && Progress != 0) @@ -264,24 +266,26 @@ bool pkgCacheGenerator::MergeList(ListParser &List, { // package descriptions if (MergeListGroup(List, PackageName) == false) - return false; + continue; continue; } // Get a pointer to the package structure pkgCache::PkgIterator Pkg; Dynamic DynPkg(Pkg); - if (NewPackage(Pkg, PackageName, Arch) == false) + if (NewPackage(Pkg, PackageName, Arch) == 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)"), + _error->Warning(_("Error occurred while processing %s (%s%d)"), PackageName.c_str(), "NewPackage", 1); + continue; + } if (Version.empty() == true) { if (MergeListPackage(List, Pkg) == false) - return false; + continue; } else { @@ -336,18 +340,18 @@ bool pkgCacheGenerator::MergeListPackage(ListParser &List, pkgCache::PkgIterator pkgCache::VerIterator Ver(Cache); Dynamic DynVer(Ver); if (List.UsePackage(Pkg, Ver) == false) - return _error->Error(_("Error occurred while processing %s (%s%d)"), + return _error->Warning(_("Error occurred while processing %s (%s%d)"), Pkg.Name(), "UsePackage", 1); // Find the right version to write the description - MD5SumValue CurMd5 = List.Description_md5(); + StringView CurMd5 = List.Description_md5(); std::vector availDesc = List.AvailableDescriptionLanguages(); for (Ver = Pkg.VersionList(); Ver.end() == false; ++Ver) { pkgCache::DescIterator VerDesc = Ver.DescriptionList(); // a version can only have one md5 describing it - if (VerDesc.end() == true || MD5SumValue(VerDesc.md5()) != CurMd5) + if (VerDesc.end() == true || Cache.ViewString(VerDesc->md5sum) != CurMd5) continue; map_stringitem_t md5idx = VerDesc->md5sum; @@ -355,7 +359,7 @@ bool pkgCacheGenerator::MergeListPackage(ListParser &List, pkgCache::PkgIterator { // don't add a new description if we have one for the given // md5 && language - if (IsDuplicateDescription(VerDesc, CurMd5, *CurLang) == true) + if (IsDuplicateDescription(Cache, VerDesc, CurMd5, *CurLang) == true) continue; AddNewDescription(List, Ver, *CurLang, CurMd5, md5idx); @@ -415,11 +419,11 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator if (Res == 0 && Ver.end() == false && Ver->Hash == Hash) { if (List.UsePackage(Pkg,Ver) == false) - return _error->Error(_("Error occurred while processing %s (%s%d)"), + return _error->Warning(_("Error occurred while processing %s (%s%d)"), Pkg.Name(), "UsePackage", 2); if (NewFileVer(Ver,List) == false) - return _error->Error(_("Error occurred while processing %s (%s%d)"), + return _error->Warning(_("Error occurred while processing %s (%s%d)"), Pkg.Name(), "NewFileVer", 1); // Read only a single record and return @@ -436,7 +440,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator // Add a new version map_pointer_t const verindex = NewVersion(Ver, Version, Pkg.Index(), Hash, *LastVer); if (unlikely(verindex == 0)) - return _error->Error(_("Error occurred while processing %s (%s%d)"), + return _error->Warning(_("Error occurred while processing %s (%s%d)"), Pkg.Name(), "NewVersion", 1); if (oldMap != Map.Data()) @@ -444,15 +448,15 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator *LastVer = verindex; if (unlikely(List.NewVersion(Ver) == false)) - return _error->Error(_("Error occurred while processing %s (%s%d)"), + return _error->Warning(_("Error occurred while processing %s (%s%d)"), Pkg.Name(), "NewVersion", 2); if (unlikely(List.UsePackage(Pkg,Ver) == false)) - return _error->Error(_("Error occurred while processing %s (%s%d)"), + return _error->Warning(_("Error occurred while processing %s (%s%d)"), Pkg.Name(), "UsePackage", 3); if (unlikely(NewFileVer(Ver,List) == false)) - return _error->Error(_("Error occurred while processing %s (%s%d)"), + return _error->Warning(_("Error occurred while processing %s (%s%d)"), Pkg.Name(), "NewFileVer", 2); pkgCache::GrpIterator Grp = Pkg.Group(); @@ -473,12 +477,12 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator Dynamic DynV(V); for (; V.end() != true; ++V) if (unlikely(AddImplicitDepends(V, Pkg) == false)) - return _error->Error(_("Error occurred while processing %s (%s%d)"), + return _error->Warning(_("Error occurred while processing %s (%s%d)"), Pkg.Name(), "AddImplicitDepends", 1); } } if (unlikely(AddImplicitDepends(Grp, Pkg, Ver) == false)) - return _error->Error(_("Error occurred while processing %s (%s%d)"), + return _error->Warning(_("Error occurred while processing %s (%s%d)"), Pkg.Name(), "AddImplicitDepends", 2); // Read only a single record and return @@ -489,7 +493,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator } /* Record the Description(s) based on their master md5sum */ - MD5SumValue CurMd5 = List.Description_md5(); + StringView CurMd5 = List.Description_md5(); /* 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 @@ -500,7 +504,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V) { - if (V->DescriptionList == 0 || MD5SumValue(V.DescriptionList().md5()) != CurMd5) + if (V->DescriptionList == 0 || Cache.ViewString(V.DescriptionList()->md5sum) != CurMd5) continue; Ver->DescriptionList = V->DescriptionList; } @@ -515,14 +519,14 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator return true; } /*}}}*/ -bool pkgCacheGenerator::AddNewDescription(ListParser &List, pkgCache::VerIterator &Ver, std::string const &lang, MD5SumValue const &CurMd5, map_stringitem_t &md5idx) /*{{{*/ +bool pkgCacheGenerator::AddNewDescription(ListParser &List, pkgCache::VerIterator &Ver, std::string const &lang, APT::StringView CurMd5, map_stringitem_t &md5idx) /*{{{*/ { pkgCache::DescIterator Desc; Dynamic DynDesc(Desc); map_pointer_t const descindex = NewDescription(Desc, lang, CurMd5, md5idx); if (unlikely(descindex == 0)) - return _error->Error(_("Error occurred while processing %s (%s%d)"), + return _error->Warning(_("Error occurred while processing %s (%s%d)"), Ver.ParentPkg().Name(), "NewDescription", 1); md5idx = Desc->md5sum; @@ -536,7 +540,7 @@ bool pkgCacheGenerator::AddNewDescription(ListParser &List, pkgCache::VerIterato *LastNextDesc = descindex; if (NewFileDesc(Desc,List) == false) - return _error->Error(_("Error occurred while processing %s (%s%d)"), + return _error->Warning(_("Error occurred while processing %s (%s%d)"), Ver.ParentPkg().Name(), "NewFileDesc", 1); return true; @@ -935,7 +939,7 @@ bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc, /* This puts a description structure in the linked list */ map_pointer_t pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc, const string &Lang, - const MD5SumValue &md5sum, + APT::StringView md5sum, map_stringitem_t const idxmd5str) { // Get a structure @@ -955,7 +959,7 @@ map_pointer_t pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc, Desc->md5sum = idxmd5str; else { - map_stringitem_t const idxmd5sum = WriteStringInMap(md5sum.Value()); + map_stringitem_t const idxmd5sum = WriteStringInMap(md5sum); if (unlikely(idxmd5sum == 0)) return 0; Desc->md5sum = idxmd5sum; @@ -1271,6 +1275,36 @@ bool pkgCacheGenerator::SelectReleaseFile(const string &File,const string &Site, Cache.HeaderP->RlsFileList = CurrentRlsFile - Cache.RlsFileP; Cache.HeaderP->ReleaseFileCount++; + return true; +} + /*}}}*/ +// ListParser::NewTag - Create a Tag element /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool pkgCacheListParser::NewTag(pkgCache::VerIterator &Ver, + const char *NameStart, + unsigned int NameSize) +{ + return Owner->NewTag(Ver, NameStart, NameSize); +} +bool pkgCacheGenerator::NewTag(pkgCache::VerIterator &Ver, + const char *NameStart, + unsigned int NameSize) +{ + // Get a structure + unsigned long Tagg = AllocateInMap(sizeof(pkgCache::Tag)); + if (Tagg == 0) + return false; + Cache.HeaderP->TagCount++; + + // Fill it in + pkgCache::TagIterator Tg(Cache,Cache.TagP + Tagg); + Tg->Name = WriteStringInMap(NameStart,NameSize); + if (Tg->Name == 0) + return false; + Tg->NextTag = Ver->TagList; + Ver->TagList = Tg.Index(); + return true; } /*}}}*/ @@ -1516,16 +1550,14 @@ static map_filesize_t ComputeSize(pkgSourceList const * const List, FileIterator } /*}}}*/ // BuildCache - Merge the list of index files into the cache /*{{{*/ -static bool BuildCache(pkgCacheGenerator &Gen, +static void BuildCache(pkgCacheGenerator &Gen, OpProgress * const Progress, map_filesize_t &CurrentSize,map_filesize_t TotalSize, pkgSourceList const * const List, FileIterator const Start, FileIterator const End) { - bool mergeFailure = false; - auto const indexFileMerge = [&](pkgIndexFile * const I) { - if (I->HasPackages() == false || mergeFailure) + if (I->HasPackages() == false) return; if (I->Exists() == false) @@ -1544,7 +1576,7 @@ static bool BuildCache(pkgCacheGenerator &Gen, CurrentSize += Size; if (I->Merge(Gen,Progress) == false) - mergeFailure = true; + return; }; if (List != NULL) @@ -1559,13 +1591,11 @@ static bool BuildCache(pkgCacheGenerator &Gen, } if ((*i)->Merge(Gen, Progress) == false) - return false; + continue; std::vector *Indexes = (*i)->GetIndexFiles(); if (Indexes != NULL) std::for_each(Indexes->begin(), Indexes->end(), indexFileMerge); - if (mergeFailure) - return false; } } @@ -1573,10 +1603,7 @@ static bool BuildCache(pkgCacheGenerator &Gen, { Gen.SelectReleaseFile("", ""); std::for_each(Start, End, indexFileMerge); - if (mergeFailure) - return false; } - return true; } /*}}}*/ // CacheGenerator::MakeStatusCache - Construct the status cache /*{{{*/ @@ -1750,9 +1777,8 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress return false; TotalSize += ComputeSize(&List, Files.begin(),Files.end()); - if (BuildCache(*Gen, Progress, CurrentSize, TotalSize, &List, - Files.end(),Files.end()) == false) - return false; + BuildCache(*Gen, Progress, CurrentSize, TotalSize, &List, + Files.end(),Files.end()); if (Writeable == true && SrcCacheFile.empty() == false) if (writeBackMMapToFile(Gen.get(), Map.get(), SrcCacheFile) == false) @@ -1763,9 +1789,8 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress { if (Debug == true) std::clog << "Building status cache in pkgcache.bin now" << std::endl; - if (BuildCache(*Gen, Progress, CurrentSize, TotalSize, NULL, - Files.begin(), Files.end()) == false) - return false; + BuildCache(*Gen, Progress, CurrentSize, TotalSize, NULL, + Files.begin(), Files.end()); if (Writeable == true && CacheFile.empty() == false) if (writeBackMMapToFile(Gen.get(), Map.get(), CacheFile) == false) @@ -1786,9 +1811,8 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress } Files = List.GetVolatileFiles(); - if (BuildCache(*Gen, Progress, CurrentSize, TotalSize, NULL, - Files.begin(), Files.end()) == false) - return false; + BuildCache(*Gen, Progress, CurrentSize, TotalSize, NULL, + Files.begin(), Files.end()); } if (OutMap != nullptr) @@ -1827,9 +1851,8 @@ bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **O pkgCacheGenerator Gen(Map.get(),Progress); if (Gen.Start() == false || _error->PendingError() == true) return false; - if (BuildCache(Gen,Progress,CurrentSize,TotalSize, NULL, - Files.begin(), Files.end()) == false) - return false; + BuildCache(Gen,Progress,CurrentSize,TotalSize, NULL, + Files.begin(), Files.end()); if (_error->PendingError() == true) return false; @@ -1839,11 +1862,11 @@ bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **O } /*}}}*/ // IsDuplicateDescription /*{{{*/ -static bool IsDuplicateDescription(pkgCache::DescIterator Desc, - MD5SumValue const &CurMd5, std::string const &CurLang) +static bool IsDuplicateDescription(pkgCache &Cache, pkgCache::DescIterator Desc, + APT::StringView CurMd5, std::string const &CurLang) { // Descriptions in the same link-list have all the same md5 - if (Desc.end() == true || MD5SumValue(Desc.md5()) != CurMd5) + if (Desc.end() == true || Cache.ViewString(Desc->md5sum) != CurMd5) return false; for (; Desc.end() == false; ++Desc) if (Desc.LanguageCode() == CurLang)