X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/a249b3e6fd798935a02b769149c9791a6fa6ef16..3f7604340855760289d7ed7e2dca70f99a9f4986:/apt-private/private-source.cc diff --git a/apt-private/private-source.cc b/apt-private/private-source.cc index a6b446587..5053c60fc 100644 --- a/apt-private/private-source.cc +++ b/apt-private/private-source.cc @@ -73,8 +73,6 @@ static pkgSrcRecords::Parser *FindSrc(const char *Name, pkgSrcRecords &SrcRecs,std::string &Src, CacheFile &Cache) { - if (Cache.BuildCaches(false) == false) - return nullptr; std::string VerTag, UserRequestedVerTag; std::string ArchTag = ""; std::string RelTag = _config->Find("APT::Default-Release"); @@ -122,7 +120,7 @@ static pkgSrcRecords::Parser *FindSrc(const char *Name, return 0; } - if (MatchSrcOnly == false && Pkg.end() == false) + if (MatchSrcOnly == false && Pkg.end() == false) { if(VerTag != "" || RelTag != "" || ArchTag != "") { @@ -152,12 +150,12 @@ static pkgSrcRecords::Parser *FindSrc(const char *Name, // pick highest version for the arch unless the user wants // something else if (ArchTag != "" && VerTag == "" && RelTag == "") - if(Cache->VS().CmpVersion(VerTag, Ver.VerStr()) < 0) + if(Cache.GetPkgCache()->VS->CmpVersion(VerTag, Ver.VerStr()) < 0) VerTag = Ver.VerStr(); // We match against a concrete version (or a part of this version) if (VerTag.empty() == false && - (fuzzy == true || Cache->VS().CmpVersion(VerTag, Ver.VerStr()) != 0) && // exact match + (fuzzy == true || Cache.GetPkgCache()->VS->CmpVersion(VerTag, Ver.VerStr()) != 0) && // exact match (fuzzy == false || strncmp(VerTag.c_str(), Ver.VerStr(), VerTag.size()) != 0)) // fuzzy match continue; @@ -176,7 +174,7 @@ static pkgSrcRecords::Parser *FindSrc(const char *Name, // or we match against a release if(VerTag.empty() == false || (VF.File().Archive() != 0 && VF.File().Archive() == RelTag) || - (VF.File().Codename() != 0 && VF.File().Codename() == RelTag)) + (VF.File().Codename() != 0 && VF.File().Codename() == RelTag)) { // the Version we have is possibly fuzzy or includes binUploads, // so we use the Version of the SourcePkg (empty if same as package) @@ -190,12 +188,12 @@ static pkgSrcRecords::Parser *FindSrc(const char *Name, } } - if (Src == "" && ArchTag != "") + if (Src.empty() == true && ArchTag.empty() == false) { - if (VerTag != "") + if (VerTag.empty() == false) _error->Error(_("Can not find a package '%s' with version '%s'"), Pkg.FullName().c_str(), VerTag.c_str()); - if (RelTag != "") + if (RelTag.empty() == false) _error->Error(_("Can not find a package '%s' with release '%s'"), Pkg.FullName().c_str(), RelTag.c_str()); Src = Name; @@ -254,34 +252,32 @@ static pkgSrcRecords::Parser *FindSrc(const char *Name, /* Iterate over all of the hits, which includes the resulting binary packages in the search */ pkgSrcRecords::Parser *Parse; - while (true) + while (true) { SrcRecs.Restart(); - while ((Parse = SrcRecs.Find(Src.c_str(), MatchSrcOnly)) != 0) + while ((Parse = SrcRecs.Find(Src.c_str(), MatchSrcOnly)) != 0) { const std::string Ver = Parse->Version(); - bool CorrectRelTag = false; // See if we need to look for a specific release tag - if (RelTag != "" && UserRequestedVerTag == "") + if (RelTag.empty() == false && UserRequestedVerTag.empty() == true) { pkgCache::RlsFileIterator const Rls = GetReleaseFileForSourceRecord(Cache, SrcList, Parse); if (Rls.end() == false) { - if ((Rls->Archive != 0 && RelTag == Rls.Archive()) || - (Rls->Codename != 0 && RelTag == Rls.Codename())) - CorrectRelTag = true; + if ((Rls->Archive != 0 && RelTag != Rls.Archive()) && + (Rls->Codename != 0 && RelTag != Rls.Codename())) + continue; } - } else - CorrectRelTag = true; + } // Ignore all versions which doesn't fit if (VerTag.empty() == false && - Cache->VS().CmpVersion(VerTag, Ver) != 0) // exact match + Cache.GetPkgCache()->VS->CmpVersion(VerTag, Ver) != 0) // exact match continue; // Newer version or an exact match? Save the hit - if (CorrectRelTag && (Last == 0 || Cache->VS().CmpVersion(Version,Ver) < 0)) { + if (Last == 0 || Cache.GetPkgCache()->VS->CmpVersion(Version,Ver) < 0) { Last = Parse; Offset = Parse->Offset(); Version = Ver; @@ -293,7 +289,7 @@ static pkgSrcRecords::Parser *FindSrc(const char *Name, break; } if (UserRequestedVerTag == "" && Version != "" && RelTag != "") - ioprintf(c1out, "Selected version '%s' (%s) for %s\n", + ioprintf(c1out, "Selected version '%s' (%s) for %s\n", Version.c_str(), RelTag.c_str(), Src.c_str()); if (Last != 0 || VerTag.empty() == true) @@ -319,19 +315,15 @@ struct DscFile }; bool DoSource(CommandLine &CmdL) { - CacheFile Cache; - if (Cache.Open(false) == false) - return false; - if (CmdL.FileSize() <= 1) return _error->Error(_("Must specify at least one package to fetch source for")); - // Read the source list - if (Cache.BuildSourceList() == false) + CacheFile Cache; + if (Cache.BuildCaches(false) == false) return false; - pkgSourceList *List = Cache.GetSourceList(); // Create the text record parsers + pkgSourceList * const List = Cache.GetSourceList(); pkgSrcRecords SrcRecs(*List); if (_error->PendingError() == true) return false; @@ -516,7 +508,7 @@ bool DoSource(CommandLine &CmdL) bool const fixBroken = _config->FindB("APT::Get::Fix-Broken", false); for (unsigned I = 0; I != J; ++I) { - std::string Dir = Dsc[I].Package + '-' + Cache->VS().UpstreamVersion(Dsc[I].Version.c_str()); + std::string Dir = Dsc[I].Package + '-' + Cache.GetPkgCache()->VS->UpstreamVersion(Dsc[I].Version.c_str()); // Diff only mode only fetches .diff files if (_config->FindB("APT::Get::Diff-Only",false) == true || @@ -730,8 +722,11 @@ bool DoBuildDep(CommandLine &CmdL) VolatileCmdL.size()); } + bool const WantLock = _config->FindB("APT::Get::Print-URIs", false) == false; if (CmdL.FileList[1] != 0) { + if (Cache.BuildCaches(WantLock) == false) + return false; // Create the text record parsers pkgSrcRecords SrcRecs(*List); if (_error->PendingError() == true) @@ -752,7 +747,6 @@ bool DoBuildDep(CommandLine &CmdL) Cache.AddIndexFile(new debStringPackageIndex(buildDepsPkgFile.str())); - bool WantLock = _config->FindB("APT::Get::Print-URIs", false) == false; if (Cache.Open(WantLock) == false) return false; pkgProblemResolver Fix(Cache.GetDepCache()); @@ -781,8 +775,31 @@ bool DoBuildDep(CommandLine &CmdL) } if (DoAutomaticRemove(Cache) == false) return false; + { pkgDepCache::ActionGroup group(Cache); + if (_config->FindB("APT::Get::Build-Dep-Automatic", false) == false) + { + for (auto const &pkg: removeAgain) + { + auto const instVer = Cache[pkg].InstVerIter(Cache); + if (unlikely(instVer.end() == true)) + continue; + for (auto D = instVer.DependsList(); D.end() != true; ++D) + { + if (D->Type != pkgCache::Dep::Depends || D.IsMultiArchImplicit()) + continue; + APT::VersionList verlist = APT::VersionList::FromDependency(Cache, D, APT::CacheSetHelper::CANDIDATE); + for (auto const &V : verlist) + { + auto const P = V.ParentPkg(); + if (Cache[P].InstallVer != V) + continue; + Cache->MarkAuto(P, false); + } + } + } + } for (auto const &pkg: removeAgain) Cache->MarkDelete(pkg, false, 0, true); }