summaryrefslogtreecommitdiff
path: root/apt-private/private-source.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-private/private-source.cc')
-rw-r--r--apt-private/private-source.cc70
1 files changed, 31 insertions, 39 deletions
diff --git a/apt-private/private-source.cc b/apt-private/private-source.cc
index a24493421..c8a48a74a 100644
--- a/apt-private/private-source.cc
+++ b/apt-private/private-source.cc
@@ -636,15 +636,6 @@ static void WriteBuildDependencyPackage(std::ostringstream &buildDepsPkgFile,
}
bool DoBuildDep(CommandLine &CmdL)
{
- CacheFile Cache;
- std::vector<std::string> VolatileCmdL;
- Cache.GetSourceList()->AddVolatileFiles(CmdL, &VolatileCmdL);
-
- _config->Set("APT::Install-Recommends", false);
-
- if (CmdL.FileSize() <= 1 && VolatileCmdL.empty())
- return _error->Error(_("Must specify at least one package to check builddeps for"));
-
bool StripMultiArch;
std::string hostArch = _config->Find("APT::Get::Host-Architecture");
if (hostArch.empty() == false)
@@ -656,16 +647,18 @@ bool DoBuildDep(CommandLine &CmdL)
}
else
StripMultiArch = true;
+ auto const nativeArch = _config->Find("APT::Architecture");
+ std::string const pseudoArch = hostArch.empty() ? nativeArch : hostArch;
+
+ CacheFile Cache;
+ auto VolatileCmdL = GetPseudoPackages(Cache.GetSourceList(), CmdL, AddVolatileSourceFile, pseudoArch);
+
+ _config->Set("APT::Install-Recommends", false);
+
+ if (CmdL.FileSize() <= 1 && VolatileCmdL.empty())
+ return _error->Error(_("Must specify at least one package to check builddeps for"));
std::ostringstream buildDepsPkgFile;
- 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
{
@@ -681,7 +674,6 @@ bool DoBuildDep(CommandLine &CmdL)
BuildDeps.push_back(rec);
}
std::string const pseudo = "builddeps:essentials";
- std::string const nativeArch = _config->Find("APT::Architecture");
WriteBuildDependencyPackage(buildDepsPkgFile, pseudo, nativeArch, BuildDeps);
pseudoPkgs.emplace_back(pseudo, nativeArch, "");
}
@@ -690,34 +682,34 @@ bool DoBuildDep(CommandLine &CmdL)
if (Cache.BuildSourceList() == false)
return false;
pkgSourceList *List = Cache.GetSourceList();
- std::string const pseudoArch = hostArch.empty() ? _config->Find("APT::Architecture") : hostArch;
- // FIXME: Avoid volatile sources == cmdline assumption
{
auto const VolatileSources = List->GetVolatileFiles();
- if (VolatileSources.size() == VolatileCmdL.size())
+ for (auto &&pkg : VolatileCmdL)
{
- for (size_t i = 0; i < VolatileSources.size(); ++i)
+ if (unlikely(pkg.index == -1))
{
- auto const Src = VolatileCmdL[i];
- if (DirectoryExists(Src))
- ioprintf(c1out, _("Note, using directory '%s' to get the build dependencies\n"), Src.c_str());
- else
- ioprintf(c1out, _("Note, using file '%s' to get the build dependencies\n"), Src.c_str());
- std::unique_ptr<pkgSrcRecords::Parser> Last(VolatileSources[i]->CreateSrcParser());
- if (Last == nullptr)
- return _error->Error(_("Unable to find a source package for %s"), Src.c_str());
-
- 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, "");
+ _error->Error(_("Unable to find a source package for %s"), pkg.name.c_str());
+ continue;
+ }
+ if (DirectoryExists(pkg.name))
+ ioprintf(c1out, _("Note, using directory '%s' to get the build dependencies\n"), pkg.name.c_str());
+ else
+ ioprintf(c1out, _("Note, using file '%s' to get the build dependencies\n"), pkg.name.c_str());
+ std::unique_ptr<pkgSrcRecords::Parser> Last(VolatileSources[pkg.index]->CreateSrcParser());
+ if (Last == nullptr)
+ {
+ _error->Error(_("Unable to find a source package for %s"), pkg.name.c_str());
+ continue;
}
+
+ auto pseudo = std::string("builddeps:") + pkg.name;
+ WriteBuildDependencyPackage(buildDepsPkgFile, pseudo, pseudoArch,
+ GetBuildDeps(Last.get(), pkg.name.c_str(), StripMultiArch, hostArch));
+ pkg.name = std::move(pseudo);
+ pseudoPkgs.push_back(std::move(pkg));
}
- else
- return _error->Error("Implementation error: Volatile sources (%lu) and"
- "commandline elements (%lu) do not match!", VolatileSources.size(),
- VolatileCmdL.size());
+ VolatileCmdL.clear();
}
bool const WantLock = _config->FindB("APT::Get::Print-URIs", false) == false;