summaryrefslogtreecommitdiff
path: root/apt-private/private-source.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2018-01-26 16:15:13 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2018-05-11 17:58:46 +0200
commit9169cd5049bd7f0d5dcc56c40d567a766cf5b851 (patch)
treef8ba50406de8e2f9539e00451bff5c22795a14e3 /apt-private/private-source.cc
parentb0283a5aeee428c9f2567b81ae78c9da68f6f4af (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/private-source.cc')
-rw-r--r--apt-private/private-source.cc38
1 files changed, 32 insertions, 6 deletions
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);
}