diff options
author | David Kalnischkies <david@kalnischkies.de> | 2018-01-26 16:15:13 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2018-05-11 17:58:46 +0200 |
commit | 9169cd5049bd7f0d5dcc56c40d567a766cf5b851 (patch) | |
tree | f8ba50406de8e2f9539e00451bff5c22795a14e3 /apt-private | |
parent | b0283a5aeee428c9f2567b81ae78c9da68f6f4af (diff) |
Extend apt build-dep pkg/release to switch dep as needed
apt install pkg/release follows versioned dependencies in the candidate
switching if the current candidate does not satisfy the dependency,
so for uniformity the same should be supported in build-dep.
Diffstat (limited to 'apt-private')
-rw-r--r-- | apt-private/private-install.cc | 12 | ||||
-rw-r--r-- | apt-private/private-source.cc | 38 |
2 files changed, 42 insertions, 8 deletions
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index e1beb21c6..c9e45cc00 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -945,13 +945,21 @@ bool TryToInstall::propergateReleaseCandiateSwitching(std::list<std::pair<pkgCac c != Changed.end(); ++c) { if (c->second.end() == true) + { + auto const pkgname = c->first.ParentPkg().FullName(true); + if (APT::String::Startswith(pkgname, "builddeps:")) + continue; ioprintf(out, _("Selected version '%s' (%s) for '%s'\n"), - c->first.VerStr(), c->first.RelStr().c_str(), c->first.ParentPkg().FullName(true).c_str()); + c->first.VerStr(), c->first.RelStr().c_str(), pkgname.c_str()); + } else if (c->first.ParentPkg()->Group != c->second.ParentPkg()->Group) { + auto pkgname = c->second.ParentPkg().FullName(true); + if (APT::String::Startswith(pkgname, "builddeps:")) + pkgname.replace(0, strlen("builddeps"), "src"); pkgCache::VerIterator V = (*Cache)[c->first.ParentPkg()].CandidateVerIter(*Cache); ioprintf(out, _("Selected version '%s' (%s) for '%s' because of '%s'\n"), V.VerStr(), - V.RelStr().c_str(), V.ParentPkg().FullName(true).c_str(), c->second.ParentPkg().FullName(true).c_str()); + V.RelStr().c_str(), V.ParentPkg().FullName(true).c_str(), pkgname.c_str()); } } return Success; diff --git a/apt-private/private-source.cc b/apt-private/private-source.cc index 32651cfdb..a24493421 100644 --- a/apt-private/private-source.cc +++ b/apt-private/private-source.cc @@ -658,7 +658,15 @@ bool DoBuildDep(CommandLine &CmdL) StripMultiArch = true; std::ostringstream buildDepsPkgFile; - std::vector<std::pair<std::string,std::string>> pseudoPkgs; + struct PseudoPkg + { + std::string name; + std::string arch; + std::string release; + PseudoPkg(std::string const &n, std::string const &a, std::string const &r) : + name(n), arch(a), release(r) {} + }; + std::vector<PseudoPkg> pseudoPkgs; // deal with the build essentials first { std::vector<pkgSrcRecords::Parser::BuildDepRec> BuildDeps; @@ -675,7 +683,7 @@ bool DoBuildDep(CommandLine &CmdL) std::string const pseudo = "builddeps:essentials"; std::string const nativeArch = _config->Find("APT::Architecture"); WriteBuildDependencyPackage(buildDepsPkgFile, pseudo, nativeArch, BuildDeps); - pseudoPkgs.emplace_back(pseudo, nativeArch); + pseudoPkgs.emplace_back(pseudo, nativeArch, ""); } // Read the source list @@ -703,7 +711,7 @@ bool DoBuildDep(CommandLine &CmdL) std::string const pseudo = std::string("builddeps:") + Src; WriteBuildDependencyPackage(buildDepsPkgFile, pseudo, pseudoArch, GetBuildDeps(Last.get(), Src.c_str(), StripMultiArch, hostArch)); - pseudoPkgs.emplace_back(pseudo, pseudoArch); + pseudoPkgs.emplace_back(pseudo, pseudoArch, ""); } } else @@ -731,7 +739,13 @@ bool DoBuildDep(CommandLine &CmdL) std::string const pseudo = std::string("builddeps:") + Src; WriteBuildDependencyPackage(buildDepsPkgFile, pseudo, pseudoArch, GetBuildDeps(Last, Src.c_str(), StripMultiArch, hostArch)); - pseudoPkgs.emplace_back(pseudo, pseudoArch); + std::string reltag = *I; + size_t found = reltag.find_last_of("/"); + if (found == std::string::npos) + reltag.clear(); + else + reltag.erase(0, found + 1); + pseudoPkgs.emplace_back(pseudo, pseudoArch, std::move(reltag)); } } @@ -745,12 +759,24 @@ bool DoBuildDep(CommandLine &CmdL) { pkgDepCache::ActionGroup group(Cache); TryToInstall InstallAction(Cache, &Fix, false); + std::list<std::pair<pkgCache::VerIterator, std::string>> candSwitch; + for (auto const &pkg: pseudoPkgs) + { + pkgCache::PkgIterator const Pkg = Cache->FindPkg(pkg.name, pkg.arch); + if (Pkg.end()) + continue; + if (pkg.release.empty()) + Cache->SetCandidateVersion(Pkg.VersionList()); + else + candSwitch.emplace_back(Pkg.VersionList(), pkg.release); + } + if (candSwitch.empty() == false) + InstallAction.propergateReleaseCandiateSwitching(candSwitch, c0out); for (auto const &pkg: pseudoPkgs) { - pkgCache::PkgIterator const Pkg = Cache->FindPkg(pkg.first, pkg.second); + pkgCache::PkgIterator const Pkg = Cache->FindPkg(pkg.name, pkg.arch); if (Pkg.end()) continue; - Cache->SetCandidateVersion(Pkg.VersionList()); InstallAction(Cache[Pkg].CandidateVerIter(Cache)); removeAgain.push_back(Pkg); } |