summaryrefslogtreecommitdiff
path: root/apt-private
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2024-04-29 14:33:41 +0000
committerJulian Andres Klode <jak@debian.org>2024-04-29 14:33:41 +0000
commit4a76c77d1cd3f07c01d5908cca539ed90d1793d3 (patch)
tree66101d7488a186467488559f17cdd3768e5aadc4 /apt-private
parentc98bcdf00e5366fec101dd17094d36be21872a02 (diff)
parent84881c1914ca30435ff478b4138cd7559c35c8d1 (diff)
Merge branch 'src-specifier' into 'main'
showsrc, source, build-dep: Support src:name See merge request apt-team/apt!346
Diffstat (limited to 'apt-private')
-rw-r--r--apt-private/private-show.cc14
-rw-r--r--apt-private/private-source.cc8
2 files changed, 18 insertions, 4 deletions
diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc
index 4ae043071..ceef6707e 100644
--- a/apt-private/private-show.cc
+++ b/apt-private/private-show.cc
@@ -446,14 +446,22 @@ bool ShowSrcPackage(CommandLine &CmdL) /*{{{*/
std::set<std::string> seen;
for (const char **I = CmdL.FileList + 1; *I != 0; I++)
{
+ const char *pkgname = *I;
SrcRecs.Restart();
pkgSrcRecords::Parser *Parse;
bool found_this = false;
- while ((Parse = SrcRecs.Find(*I,false)) != 0) {
+ bool only_source = _config->FindB("APT::Cache::Only-Source", false);
+ if (APT::String::Startswith(pkgname, "src:"))
+ {
+ only_source = true;
+ pkgname += 4;
+ }
+ while ((Parse = SrcRecs.Find(pkgname, false)) != 0)
+ {
// SrcRecs.Find() will find both binary and source names
- if (_config->FindB("APT::Cache::Only-Source", false) == true)
- if (Parse->Package() != *I)
+ if (only_source)
+ if (Parse->Package() != pkgname)
continue;
std::string sha1str = Sha1FromString(Parse->AsStr());
if (std::find(seen.begin(), seen.end(), sha1str) == seen.end())
diff --git a/apt-private/private-source.cc b/apt-private/private-source.cc
index 9b9409c80..6280b9fff 100644
--- a/apt-private/private-source.cc
+++ b/apt-private/private-source.cc
@@ -77,7 +77,14 @@ static pkgSrcRecords::Parser *FindSrc(const char *Name,
std::string ArchTag = "";
std::string RelTag = _config->Find("APT::Default-Release");
std::string TmpSrc = Name;
+ bool MatchSrcOnly = _config->FindB("APT::Get::Only-Source");
+ // Check if we should look by source package
+ if (APT::String::Startswith(TmpSrc, "src:"))
+ {
+ MatchSrcOnly = true;
+ TmpSrc = TmpSrc.substr(4);
+ }
// extract release
size_t found = TmpSrc.find_last_of("/");
if (found != std::string::npos)
@@ -103,7 +110,6 @@ static pkgSrcRecords::Parser *FindSrc(const char *Name,
/* Lookup the version of the package we would install if we were to
install a version and determine the source package name, then look
in the archive for a source package of the same name. */
- bool MatchSrcOnly = _config->FindB("APT::Get::Only-Source");
pkgCache::PkgIterator Pkg;
if (ArchTag != "")
Pkg = Cache.GetPkgCache()->FindPkg(TmpSrc, ArchTag);