summaryrefslogtreecommitdiff
path: root/apt-pkg/pkgcachegen.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2025-05-19 15:19:43 +0000
committerJulian Andres Klode <jak@debian.org>2025-05-19 15:19:43 +0000
commitb4e745bfed0c06b1b7faeceeab32a02a76fb8a54 (patch)
tree475fdfe3b426378cfafecdc6cda09155af20b4db /apt-pkg/pkgcachegen.cc
parent9a7e34d491b828a227930654d4f99e4fd2eb93ec (diff)
parent93416f3227685c390c7ab579981efde526134181 (diff)
Merge branch 'include-exclude' into 'main'
Add 'Include'/'Exclude' options to limit packages used from a repository See merge request apt-team/apt!439
Diffstat (limited to 'apt-pkg/pkgcachegen.cc')
-rw-r--r--apt-pkg/pkgcachegen.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 7d93db4b4..3358441ee 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -251,6 +251,15 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
if (PackageName.empty() == true)
return false;
+ // Package is excluded
+ if (exclude.find(PackageName) != exclude.end())
+ continue;
+
+ // Includes are specified, this is the total set of packages to include,
+ // so we need to skip the package if it is not in the include list.
+ if (not include.empty() && include.find(PackageName) == include.end())
+ continue;
+
Counter++;
if (Counter % 100 == 0 && Progress != 0)
Progress->Progress(List.Offset());
@@ -1332,6 +1341,7 @@ bool pkgCacheGenerator::SelectFile(std::string const &File,
pkgIndexFile const &Index,
std::string const &Architecture,
std::string const &Component,
+ const IndexTarget *Target,
unsigned long const Flags)
{
CurrentFile = nullptr;
@@ -1374,6 +1384,22 @@ bool pkgCacheGenerator::SelectFile(std::string const &File,
Cache.HeaderP->FileList = map_pointer<pkgCache::PackageFile>{NarrowOffset(CurrentFile - Cache.PkgFileP)};
Cache.HeaderP->PackageFileCount++;
+ include.clear();
+ exclude.clear();
+ if (Target)
+ {
+ if (auto inc = Target->Options.find("INCLUDE"); inc != Target->Options.end())
+ {
+ auto v = VectorizeString(inc->second, ' ');
+ include.insert(v.begin(), v.end());
+ }
+ if (auto exc = Target->Options.find("EXCLUDE"); exc != Target->Options.end())
+ {
+ auto v = VectorizeString(exc->second, ' ');
+ exclude.insert(v.begin(), v.end());
+ }
+ }
+
if (Progress != 0)
Progress->SubProgress(Index.Size());
return true;