From 9169cd5049bd7f0d5dcc56c40d567a766cf5b851 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 26 Jan 2018 16:15:13 +0100 Subject: 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. --- apt-private/private-install.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'apt-private/private-install.cc') 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::listsecond.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; -- cgit v1.2.3 From ce9223cc4e4ffcc43d17ae97ff8c57fb759a2c49 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 26 Jan 2018 23:33:25 +0100 Subject: Support release selector for volatile files as well The syntax is a bit awkward, but it is the same as for a package name and introducing another syntax wouldn't really help usability, so with apt install ./foo.deb/experimental you will get the dependencies of foo satisfied by your default release, but if this wouldn't satisfy the version requirements the candidate for this dependency is switched to the version from the experimental release. The same applies for apt build-dep ./foo.dsc/stable-backports which was the initial request. --- apt-private/private-install.cc | 80 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 7 deletions(-) (limited to 'apt-private/private-install.cc') diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index c9e45cc00..4bb756b4f 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -564,16 +564,16 @@ static const unsigned short MOD_INSTALL = 2; bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache, int UpgradeMode) { - std::vector VolatileCmdL; + std::vector VolatileCmdL; return DoCacheManipulationFromCommandLine(CmdL, VolatileCmdL, Cache, UpgradeMode); } -bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector &VolatileCmdL, CacheFile &Cache, int UpgradeMode) +bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector &VolatileCmdL, CacheFile &Cache, int UpgradeMode) { std::map verset; std::set UnknownPackages; return DoCacheManipulationFromCommandLine(CmdL, VolatileCmdL, Cache, verset, UpgradeMode, UnknownPackages); } -bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector &VolatileCmdL, CacheFile &Cache, +bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector &VolatileCmdL, CacheFile &Cache, std::map &verset, int UpgradeMode, std::set &UnknownPackages) { // Enter the special broken fixing mode if the user specified arguments @@ -611,13 +611,18 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vectorFindPkg(I); + pkgCache::PkgIterator const P = Cache->FindPkg(I.name); if (P.end()) continue; // Set any version providing the .deb as the candidate. for (auto Prv = P.ProvidesList(); Prv.end() == false; Prv++) - Cache.GetDepCache()->SetCandidateVersion(Prv.OwnerVer()); + { + if (I.release.empty()) + Cache.GetDepCache()->SetCandidateVersion(Prv.OwnerVer()); + else + Cache.GetDepCache()->SetCandidateRelease(Prv.OwnerVer(), I.release); + } // via cacheset to have our usual virtual handling APT::VersionContainerInterface::FromPackage(&(verset[MOD_INSTALL]), Cache, P, APT::CacheSetHelper::CANDIDATE, helper); @@ -703,6 +708,68 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector &VolatileCmdL)/*{{{*/ +{ + auto const ext = flExtension(pkg.name); + if (ext != "dsc" && FileExists(pkg.name + "/debian/control") == false) + return false; + std::vector files; + SL->AddVolatileFile(pkg.name, &files); + for (auto &&f: files) + VolatileCmdL.emplace_back(std::move(f), pkg.arch, pkg.release, pkg.index); + return true; + +} + /*}}}*/ +bool AddVolatileBinaryFile(pkgSourceList *const SL, PseudoPkg &&pkg, std::vector &VolatileCmdL)/*{{{*/ +{ + auto const ext = flExtension(pkg.name); + if (ext != "deb" && ext != "ddeb" && ext != "changes") + return false; + std::vector files; + SL->AddVolatileFile(pkg.name, &files); + for (auto &&f: files) + VolatileCmdL.emplace_back(std::move(f), pkg.arch, pkg.release, pkg.index); + return true; +} + /*}}}*/ +std::vector GetPseudoPackages(pkgSourceList *const SL, CommandLine &CmdL, bool (*Add)(pkgSourceList *const, PseudoPkg &&, std::vector &), std::string const &pseudoArch)/*{{{*/ +{ + std::vector VolatileCmdL; + std::remove_if(CmdL.FileList + 1, CmdL.FileList + 1 + CmdL.FileSize(), [&](char const *const I) { + if (I != nullptr && (I[0] == '/' || (I[0] == '.' && (I[1] == '\0' || (I[1] == '.' && (I[2] == '\0' || I[2] == '/')) || I[1] == '/')))) + { + PseudoPkg pkg(I, pseudoArch, "", SL->GetVolatileFiles().size()); + if (FileExists(I)) // this accepts directories and symlinks, too + { + if (Add(SL, std::move(pkg), VolatileCmdL)) + ; + else + _error->Error(_("Unsupported file %s given on commandline"), I); + return true; + } + else + { + auto const found = pkg.name.rfind("/"); + if (found == pkg.name.find("/")) + _error->Error(_("Unsupported file %s given on commandline"), I); + else + { + pkg.release = pkg.name.substr(found + 1); + pkg.name.erase(found); + if (Add(SL, std::move(pkg), VolatileCmdL)) + ; + else + _error->Error(_("Unsupported file %s given on commandline"), I); + } + return true; + } + } + return false; + }); + return VolatileCmdL; +} + /*}}}*/ // DoInstall - Install packages from the command line /*{{{*/ // --------------------------------------------------------------------- /* Install named packages */ @@ -721,8 +788,7 @@ struct PkgIsExtraInstalled { bool DoInstall(CommandLine &CmdL) { CacheFile Cache; - std::vector VolatileCmdL; - Cache.GetSourceList()->AddVolatileFiles(CmdL, &VolatileCmdL); + auto VolatileCmdL = GetPseudoPackages(Cache.GetSourceList(), CmdL, AddVolatileBinaryFile, ""); // then open the cache if (Cache.OpenForInstall() == false || -- cgit v1.2.3 From 6085ab7488326cfed8f82e07eefcbc2dc40d4bea Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 12 Apr 2018 09:59:47 +0200 Subject: Support local files as arguments in show command Now that --with-source is supported in show we can go a little further and add the "syntactic sugar" of supporting deb-files on the commandline directly to give users an alternative to remembering dpkg -I for deb files & as a bonus apt also works on changes files. Most of the code churn is actually to deal with cases probably not too common in reality like mixing packages and deb-files on the commandline and getting the right order for these multiple records. Closes: 883206 --- apt-private/private-install.cc | 63 ++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 24 deletions(-) (limited to 'apt-private/private-install.cc') diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index 4bb756b4f..f90e7097f 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -733,39 +733,54 @@ bool AddVolatileBinaryFile(pkgSourceList *const SL, PseudoPkg &&pkg, std::vector return true; } /*}}}*/ -std::vector GetPseudoPackages(pkgSourceList *const SL, CommandLine &CmdL, bool (*Add)(pkgSourceList *const, PseudoPkg &&, std::vector &), std::string const &pseudoArch)/*{{{*/ +static bool AddIfVolatile(pkgSourceList *const SL, std::vector &VolatileCmdL, bool (*Add)(pkgSourceList *const, PseudoPkg &&, std::vector &), char const * const I, std::string const &pseudoArch)/*{{{*/ { - std::vector VolatileCmdL; - std::remove_if(CmdL.FileList + 1, CmdL.FileList + 1 + CmdL.FileSize(), [&](char const *const I) { - if (I != nullptr && (I[0] == '/' || (I[0] == '.' && (I[1] == '\0' || (I[1] == '.' && (I[2] == '\0' || I[2] == '/')) || I[1] == '/')))) + if (I != nullptr && (I[0] == '/' || (I[0] == '.' && (I[1] == '\0' || (I[1] == '.' && (I[2] == '\0' || I[2] == '/')) || I[1] == '/')))) + { + PseudoPkg pkg(I, pseudoArch, "", SL->GetVolatileFiles().size()); + if (FileExists(I)) // this accepts directories and symlinks, too + { + if (Add(SL, std::move(pkg), VolatileCmdL)) + ; + else + _error->Error(_("Unsupported file %s given on commandline"), I); + return true; + } + else { - PseudoPkg pkg(I, pseudoArch, "", SL->GetVolatileFiles().size()); - if (FileExists(I)) // this accepts directories and symlinks, too + auto const found = pkg.name.rfind("/"); + if (found == pkg.name.find("/")) + _error->Error(_("Unsupported file %s given on commandline"), I); + else { + pkg.release = pkg.name.substr(found + 1); + pkg.name.erase(found); if (Add(SL, std::move(pkg), VolatileCmdL)) ; else _error->Error(_("Unsupported file %s given on commandline"), I); - return true; - } - else - { - auto const found = pkg.name.rfind("/"); - if (found == pkg.name.find("/")) - _error->Error(_("Unsupported file %s given on commandline"), I); - else - { - pkg.release = pkg.name.substr(found + 1); - pkg.name.erase(found); - if (Add(SL, std::move(pkg), VolatileCmdL)) - ; - else - _error->Error(_("Unsupported file %s given on commandline"), I); - } - return true; } + return true; } - return false; + } + return false; +} + /*}}}*/ +std::vector GetAllPackagesAsPseudo(pkgSourceList *const SL, CommandLine &CmdL, bool (*Add)(pkgSourceList *const, PseudoPkg &&, std::vector &), std::string const &pseudoArch)/*{{{*/ +{ + std::vector PkgCmdL; + std::for_each(CmdL.FileList + 1, CmdL.FileList + CmdL.FileSize(), [&](char const *const I) { + if (AddIfVolatile(SL, PkgCmdL, Add, I, pseudoArch) == false) + PkgCmdL.emplace_back(I, pseudoArch, "", -1); + }); + return PkgCmdL; +} + /*}}}*/ +std::vector GetPseudoPackages(pkgSourceList *const SL, CommandLine &CmdL, bool (*Add)(pkgSourceList *const, PseudoPkg &&, std::vector &), std::string const &pseudoArch)/*{{{*/ +{ + std::vector VolatileCmdL; + std::remove_if(CmdL.FileList + 1, CmdL.FileList + 1 + CmdL.FileSize(), [&](char const *const I) { + return AddIfVolatile(SL, VolatileCmdL, Add, I, pseudoArch); }); return VolatileCmdL; } -- cgit v1.2.3