typedef std::vector<pkgIndexFile *>::iterator FileIterator;
template <typename Iter> std::vector<Iter*> pkgCacheGenerator::Dynamic<Iter>::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;
bool const newError = _error->PendingError();
_error->MergeWithStack();
if (newError)
- return false;
+ return _error->ReturnError();
if (Map.Size() <= 0)
return false;
advoid a problem during a crash */
pkgCacheGenerator::~pkgCacheGenerator()
{
- if (_error->PendingError() == true || Map.validData() == false)
+ if (Map.validData() == false)
return;
if (Map.Sync() == false)
return;
{
string const PackageName = List.Package();
if (PackageName.empty() == true)
- return false;
+ continue;
Counter++;
if (Counter % 100 == 0 && Progress != 0)
{
// package descriptions
if (MergeListGroup(List, PackageName) == false)
- return false;
+ continue;
continue;
}
// Get a pointer to the package structure
pkgCache::PkgIterator Pkg;
Dynamic<pkgCache::PkgIterator> 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->Error(_("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
{
Pkg.Name(), "UsePackage", 1);
// Find the right version to write the description
- MD5SumValue CurMd5 = List.Description_md5();
+ StringView CurMd5 = List.Description_md5();
std::vector<std::string> 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;
{
// 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);
}
/* 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
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;
}
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<pkgCache::DescIterator> DynDesc(Desc);
unsigned long const Hash = Cache.Hash(Name);
map_pointer_t *insertAt = &Cache.HeaderP->GrpHashTableP()[Hash];
- while (*insertAt != 0 && Name.compare(Cache.ViewString((Cache.GrpP + *insertAt)->Name)) > 0)
+ while (*insertAt != 0 && StringViewCompareFast(Name, Cache.ViewString((Cache.GrpP + *insertAt)->Name)) > 0)
insertAt = &(Cache.GrpP + *insertAt)->Next;
Grp->Next = *insertAt;
*insertAt = Group;
// Insert it into the hash table
map_id_t const Hash = Cache.Hash(Name);
map_pointer_t *insertAt = &Cache.HeaderP->PkgHashTableP()[Hash];
- while (*insertAt != 0 && Name.compare(Cache.StrP + (Cache.GrpP + (Cache.PkgP + *insertAt)->Group)->Name) > 0)
+ while (*insertAt != 0 && StringViewCompareFast(Name, Cache.ViewString((Cache.GrpP + (Cache.PkgP + *insertAt)->Group)->Name)) > 0)
insertAt = &(Cache.PkgP + *insertAt)->NextPackage;
Pkg->NextPackage = *insertAt;
*insertAt = Package;
/* 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
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;
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;
}
/*}}}*/
{
if (Debug == true)
std::clog << "Errors are pending or Map is empty() for " << CacheFile << std::endl;
- return false;
+ return _error->ReturnError();
}
std::unique_ptr<bool[]> RlsVisited(new bool[Cache.HeaderP->ReleaseFileCount]);
std::clog << "Validity failed because of pending errors:" << std::endl;
_error->DumpErrors(std::clog, GlobalError::DEBUG, false);
}
- return false;
+ return _error->ReturnError();
}
if (OutMap != 0)
}
/*}}}*/
// 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)
Progress->OverallProgress(CurrentSize, TotalSize, Size, _("Reading package lists"));
CurrentSize += Size;
- if (I->Merge(Gen,Progress) == false)
- mergeFailure = true;
+ if (I->Merge(Gen,Progress) == false) {
+ _error->ReturnError();
+ return;
+ }
};
if (List != NULL)
continue;
}
- if ((*i)->Merge(Gen, Progress) == false)
- return false;
+ if ((*i)->Merge(Gen, Progress) == false) {
+ _error->ReturnError();
+ continue;
+ }
std::vector <pkgIndexFile *> *Indexes = (*i)->GetIndexFiles();
if (Indexes != NULL)
std::for_each(Indexes->begin(), Indexes->end(), indexFileMerge);
- if (mergeFailure)
- return false;
}
}
{
Gen.SelectReleaseFile("", "");
std::for_each(Start, End, indexFileMerge);
- if (mergeFailure)
- return false;
}
- return true;
}
/*}}}*/
// CacheGenerator::MakeStatusCache - Construct the status cache /*{{{*/
bool const newError = _error->PendingError();
_error->MergeWithStack();
if (alloc == 0 && newError)
- return false;
+ return _error->ReturnError();
if (CacheF.Read((unsigned char *)Map->Data() + alloc, CacheF.Size()) == false)
return false;
Gen.reset(new pkgCacheGenerator(Map.get(),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)
{
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)
}
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)
if (Progress != NULL)
Progress->OverallProgress(0,1,1,_("Reading package lists"));
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)
+ if (Gen.Start() == false)
return false;
-
if (_error->PendingError() == true)
- return false;
+ return _error->ReturnError();
+ BuildCache(Gen,Progress,CurrentSize,TotalSize, NULL,
+ Files.begin(), Files.end());
+ // We've passed the point of no return
+ _error->ReturnError();
+
*OutMap = Map.release();
return true;
}
/*}}}*/
// 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)