X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/a2884e32d61a123cf1298df6b1e1ea9cf50cab70..3dc863efa5f825a16b46ccba0771e86895459c77:/cmdline/apt-cache.cc diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 4e16b8c11..cc4c1559e 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -71,6 +71,12 @@ void LocalitySort(pkgCache::VerFile **begin, { qsort(begin,Count,Size,LocalityCompare); } + +void LocalitySort(pkgCache::DescFile **begin, + unsigned long Count,size_t Size) +{ + qsort(begin,Count,Size,LocalityCompare); +} /*}}}*/ // UnMet - Show unmet dependencies /*{{{*/ // --------------------------------------------------------------------- @@ -96,13 +102,15 @@ bool UnMet(CommandLine &CmdL) if (End->Type != pkgCache::Dep::PreDepends && End->Type != pkgCache::Dep::Depends && End->Type != pkgCache::Dep::Suggests && - End->Type != pkgCache::Dep::Recommends) + End->Type != pkgCache::Dep::Recommends && + End->Type != pkgCache::Dep::DpkgBreaks) continue; // Important deps only if (Important == true) if (End->Type != pkgCache::Dep::PreDepends && - End->Type != pkgCache::Dep::Depends) + End->Type != pkgCache::Dep::Depends && + End->Type != pkgCache::Dep::DpkgBreaks) continue; // Verify the or group @@ -182,7 +190,14 @@ bool DumpPackage(CommandLine &CmdL) { cout << Cur.VerStr(); for (pkgCache::VerFileIterator Vf = Cur.FileList(); Vf.end() == false; Vf++) - cout << "(" << Vf.File().FileName() << ")"; + cout << " (" << Vf.File().FileName() << ")"; + cout << endl; + for (pkgCache::DescIterator D = Cur.DescriptionList(); D.end() == false; D++) + { + cout << " Description Language: " << D.LanguageCode() << endl + << " File: " << D.FileList().File().FileName() << endl + << " MD5: " << D.md5() << endl; + } cout << endl; } @@ -229,7 +244,7 @@ bool DumpPackage(CommandLine &CmdL) bool Stats(CommandLine &Cmd) { pkgCache &Cache = *GCache; - cout << _("Total Package Names : ") << Cache.Head().PackageCount << " (" << + cout << _("Total package names : ") << Cache.Head().PackageCount << " (" << SizeToStr(Cache.Head().PackageCount*Cache.Head().PackageSz) << ')' << endl; int Normal = 0; @@ -269,20 +284,24 @@ bool Stats(CommandLine &Cmd) continue; } } - cout << _(" Normal Packages: ") << Normal << endl; - cout << _(" Pure Virtual Packages: ") << Virtual << endl; - cout << _(" Single Virtual Packages: ") << DVirt << endl; - cout << _(" Mixed Virtual Packages: ") << NVirt << endl; + cout << _(" Normal packages: ") << Normal << endl; + cout << _(" Pure virtual packages: ") << Virtual << endl; + cout << _(" Single virtual packages: ") << DVirt << endl; + cout << _(" Mixed virtual packages: ") << NVirt << endl; cout << _(" Missing: ") << Missing << endl; - cout << _("Total Distinct Versions: ") << Cache.Head().VersionCount << " (" << + cout << _("Total distinct versions: ") << Cache.Head().VersionCount << " (" << SizeToStr(Cache.Head().VersionCount*Cache.Head().VersionSz) << ')' << endl; - cout << _("Total Dependencies: ") << Cache.Head().DependsCount << " (" << + cout << _("Total Distinct Descriptions: ") << Cache.Head().DescriptionCount << " (" << + SizeToStr(Cache.Head().DescriptionCount*Cache.Head().DescriptionSz) << ')' << endl; + cout << _("Total dependencies: ") << Cache.Head().DependsCount << " (" << SizeToStr(Cache.Head().DependsCount*Cache.Head().DependencySz) << ')' << endl; - cout << _("Total Ver/File relations: ") << Cache.Head().VerFileCount << " (" << + cout << _("Total ver/file relations: ") << Cache.Head().VerFileCount << " (" << SizeToStr(Cache.Head().VerFileCount*Cache.Head().VerFileSz) << ')' << endl; - cout << _("Total Provides Mappings: ") << Cache.Head().ProvidesCount << " (" << + cout << _("Total Desc/File relations: ") << Cache.Head().DescFileCount << " (" << + SizeToStr(Cache.Head().DescFileCount*Cache.Head().DescFileSz) << ')' << endl; + cout << _("Total Provides mappings: ") << Cache.Head().ProvidesCount << " (" << SizeToStr(Cache.Head().ProvidesCount*Cache.Head().ProvidesSz) << ')' << endl; // String list stats @@ -294,7 +313,7 @@ bool Stats(CommandLine &Cmd) Count++; Size += strlen(Cache.StrP + I->String) + 1; } - cout << _("Total Globbed Strings: ") << Count << " (" << SizeToStr(Size) << ')' << endl; + cout << _("Total globbed strings: ") << Count << " (" << SizeToStr(Size) << ')' << endl; unsigned long DepVerSize = 0; for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++) @@ -308,12 +327,12 @@ bool Stats(CommandLine &Cmd) } } } - cout << _("Total Dependency Version space: ") << SizeToStr(DepVerSize) << endl; + cout << _("Total dependency version space: ") << SizeToStr(DepVerSize) << endl; unsigned long Slack = 0; for (int I = 0; I != 7; I++) Slack += Cache.Head().Pools[I].ItemSize*Cache.Head().Pools[I].Count; - cout << _("Total Slack space: ") << SizeToStr(Slack) << endl; + cout << _("Total slack space: ") << SizeToStr(Slack) << endl; unsigned long Total = 0; Total = Slack + Size + Cache.Head().DependsCount*Cache.Head().DependencySz + @@ -321,7 +340,7 @@ bool Stats(CommandLine &Cmd) Cache.Head().PackageCount*Cache.Head().PackageSz + Cache.Head().VerFileCount*Cache.Head().VerFileSz + Cache.Head().ProvidesCount*Cache.Head().ProvidesSz; - cout << _("Total Space Accounted for: ") << SizeToStr(Total) << endl; + cout << _("Total space accounted for: ") << SizeToStr(Total) << endl; return true; } @@ -344,6 +363,12 @@ bool Dump(CommandLine &Cmd) for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; D++) cout << " Depends: " << D.TargetPkg().Name() << ' ' << DeNull(D.TargetVer()) << endl; + for (pkgCache::DescIterator D = V.DescriptionList(); D.end() == false; D++) + { + cout << " Description Language: " << D.LanguageCode() << endl + << " File: " << D.FileList().File().FileName() << endl + << " MD5: " << D.md5() << endl; + } } } @@ -846,6 +871,7 @@ bool XVcg(CommandLine &CmdL) then show the relation but do not recurse */ if (Hit == false && (D->Type == pkgCache::Dep::Conflicts || + D->Type == pkgCache::Dep::DpkgBreaks || D->Type == pkgCache::Dep::Obsoletes)) { if (Show[D.TargetPkg()->ID] == None && @@ -867,6 +893,9 @@ bool XVcg(CommandLine &CmdL) case pkgCache::Dep::Conflicts: printf("label: \"conflicts\" color: lightgreen }\n"); break; + case pkgCache::Dep::DpkgBreaks: + printf("label: \"breaks\" color: lightgreen }\n"); + break; case pkgCache::Dep::Obsoletes: printf("label: \"obsoletes\" color: lightgreen }\n"); break; @@ -1192,17 +1221,50 @@ bool DisplayRecord(pkgCache::VerIterator V) if (_error->PendingError() == true) return false; - // Read the record and then write it out again. + // Read the record unsigned char *Buffer = new unsigned char[GCache->HeaderP->MaxVerFileSize+1]; Buffer[V.FileList()->Size] = '\n'; if (PkgF.Seek(V.FileList()->Offset) == false || - PkgF.Read(Buffer,V.FileList()->Size) == false || - fwrite(Buffer,1,V.FileList()->Size+1,stdout) < (size_t)(V.FileList()->Size+1)) + PkgF.Read(Buffer,V.FileList()->Size) == false) { delete [] Buffer; return false; } - + + // Get a pointer to start of Description field + const unsigned char *DescP = (unsigned char*)strstr((char*)Buffer, "Description:"); + + // Write all but Description + if (fwrite(Buffer,1,DescP - Buffer,stdout) < (size_t)(DescP - Buffer)) + { + delete [] Buffer; + return false; + } + + // Show the right description + pkgRecords Recs(*GCache); + pkgCache::DescIterator Desc = V.TranslatedDescription(); + pkgRecords::Parser &P = Recs.Lookup(Desc.FileList()); + cout << "Description" << ( (strcmp(Desc.LanguageCode(),"") != 0) ? "-" : "" ) << Desc.LanguageCode() << ": " << P.LongDesc(); + + // Find the first field after the description (if there is any) + for(DescP++;DescP != &Buffer[V.FileList()->Size];DescP++) + { + if(*DescP == '\n' && *(DescP+1) != ' ') + { + // write the rest of the buffer + const unsigned char *end=&Buffer[V.FileList()->Size]; + if (fwrite(DescP,1,end-DescP,stdout) < (size_t)(end-DescP)) + { + delete [] Buffer; + return false; + } + + break; + } + } + // write a final newline (after the description) + cout<PackageCount+1]; - memset(VFList,0,sizeof(*VFList)*Cache.HeaderP->PackageCount+1); + ExDescFile *DFList = new ExDescFile[Cache.HeaderP->PackageCount+1]; + memset(DFList,0,sizeof(*DFList)*Cache.HeaderP->PackageCount+1); // Map versions that we want to write out onto the VerList array. for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++) { - VFList[P->ID].NameMatch = NumPatterns != 0; + DFList[P->ID].NameMatch = NumPatterns != 0; for (unsigned I = 0; I != NumPatterns; I++) { if (regexec(&Patterns[I],P.Name(),0,0,0) == 0) - VFList[P->ID].NameMatch &= true; + DFList[P->ID].NameMatch &= true; else - VFList[P->ID].NameMatch = false; + DFList[P->ID].NameMatch = false; } // Doing names only, drop any that dont match.. - if (NamesOnly == true && VFList[P->ID].NameMatch == false) + if (NamesOnly == true && DFList[P->ID].NameMatch == false) continue; // Find the proper version to use. pkgCache::VerIterator V = Plcy.GetCandidateVer(P); if (V.end() == false) - VFList[P->ID].Vf = V.FileList(); + DFList[P->ID].Df = V.DescriptionList().FileList(); } // Include all the packages that provide matching names too for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++) { - if (VFList[P->ID].NameMatch == false) + if (DFList[P->ID].NameMatch == false) continue; for (pkgCache::PrvIterator Prv = P.ProvidesList() ; Prv.end() == false; Prv++) @@ -1289,18 +1351,18 @@ bool Search(CommandLine &CmdL) pkgCache::VerIterator V = Plcy.GetCandidateVer(Prv.OwnerPkg()); if (V.end() == false) { - VFList[Prv.OwnerPkg()->ID].Vf = V.FileList(); - VFList[Prv.OwnerPkg()->ID].NameMatch = true; + DFList[Prv.OwnerPkg()->ID].Df = V.DescriptionList().FileList(); + DFList[Prv.OwnerPkg()->ID].NameMatch = true; } } } - - LocalitySort(&VFList->Vf,Cache.HeaderP->PackageCount,sizeof(*VFList)); + + LocalitySort(&DFList->Df,Cache.HeaderP->PackageCount,sizeof(*DFList)); // Iterate over all the version records and check them - for (ExVerFile *J = VFList; J->Vf != 0; J++) + for (ExDescFile *J = DFList; J->Df != 0; J++) { - pkgRecords::Parser &P = Recs.Lookup(pkgCache::VerFileIterator(Cache,J->Vf)); + pkgRecords::Parser &P = Recs.Lookup(pkgCache::DescFileIterator(Cache,J->Df)); bool Match = true; if (J->NameMatch == false) @@ -1331,7 +1393,7 @@ bool Search(CommandLine &CmdL) } } - delete [] VFList; + delete [] DFList; for (unsigned I = 0; I != NumPatterns; I++) regfree(&Patterns[I]); if (ferror(stdout)) @@ -1459,7 +1521,7 @@ bool Policy(CommandLine &CmdL) // Print out all of the package files if (CmdL.FileList[1] == 0) { - cout << _("Package Files:") << endl; + cout << _("Package files:") << endl; for (pkgCache::PkgFileIterator F = Cache.FileBegin(); F.end() == false; F++) { // Locate the associated index files so we can derive a description @@ -1479,7 +1541,7 @@ bool Policy(CommandLine &CmdL) } // Show any packages have explicit pins - cout << _("Pinned Packages:") << endl; + cout << _("Pinned packages:") << endl; pkgCache::PkgIterator I = Cache.PkgBegin(); for (;I.end() != true; I++) { @@ -1529,7 +1591,7 @@ bool Policy(CommandLine &CmdL) // Pinned version if (Plcy.GetPriority(Pkg) != 0) { - cout << _(" Package Pin: "); + cout << _(" Package pin: "); V = Plcy.GetMatch(Pkg); if (V.end() == true) cout << _("(not found)") << endl; @@ -1538,7 +1600,7 @@ bool Policy(CommandLine &CmdL) } // Show the priority tables - cout << _(" Version Table:") << endl; + cout << _(" Version table:") << endl; for (V = Pkg.VersionList(); V.end() == false; V++) { if (Pkg.CurrentVer() == V) @@ -1574,10 +1636,11 @@ bool Madison(CommandLine &CmdL) pkgCache &Cache = *GCache; - // Create the text record parsers + // Create the src text record parsers and ignore errors about missing + // deb-src lines that are generated from pkgSrcRecords::pkgSrcRecords pkgSrcRecords SrcRecs(*SrcList); if (_error->PendingError() == true) - return false; + _error->Discard(); for (const char **I = CmdL.FileList + 1; *I != 0; I++) {