[lxc-devel] [distrobuilder/master] *: Add filters to package repositories

monstermunchkin on Github lxc-bot at linuxcontainers.org
Fri Aug 23 17:28:19 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190823/8c97ea26/attachment.bin>
-------------- next part --------------
From 124cf22d2e0af1fb367e63ec84f471b853a62bae Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Fri, 23 Aug 2019 19:23:04 +0200
Subject: [PATCH] *: Add filters to package repositories

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 distrobuilder/chroot.go | 12 ++++++++++++
 shared/definition.go    | 10 +++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/distrobuilder/chroot.go b/distrobuilder/chroot.go
index 5e1b02a..98af837 100644
--- a/distrobuilder/chroot.go
+++ b/distrobuilder/chroot.go
@@ -30,6 +30,18 @@ func managePackages(def shared.DefinitionPackages, actions []shared.DefinitionAc
 		}
 
 		for _, repo := range def.Repositories {
+			if len(repo.Releases) > 0 && !lxd.StringInSlice(release, repo.Releases) {
+				continue
+			}
+
+			if len(repo.Architectures) > 0 && !lxd.StringInSlice(architecture, repo.Architectures) {
+				continue
+			}
+
+			if len(repo.Variants) > 0 && !lxd.StringInSlice(variant, repo.Variants) {
+				continue
+			}
+
 			err = manager.RepoHandler(repo)
 			if err != nil {
 				return fmt.Errorf("Error for repository %s: %s", repo.Name, err)
diff --git a/shared/definition.go b/shared/definition.go
index f4087ef..ed812cd 100644
--- a/shared/definition.go
+++ b/shared/definition.go
@@ -29,11 +29,11 @@ type DefinitionPackagesSet struct {
 
 // A DefinitionPackagesRepository contains data of a specific repository
 type DefinitionPackagesRepository struct {
-	Name     string   `yaml:"name"`              // Name of the repository
-	URL      string   `yaml:"url"`               // URL (may differ based on manager)
-	Type     string   `yaml:"type,omitempty"`    // For distros that have more than one repository manager
-	Key      string   `yaml:"key,omitempty"`     // GPG armored keyring
-	Releases []string `yaml:"release,omitempty"` // Releases that this repo applies to
+	DefinitionFilter
+	Name string `yaml:"name"`           // Name of the repository
+	URL  string `yaml:"url"`            // URL (may differ based on manager)
+	Type string `yaml:"type,omitempty"` // For distros that have more than one repository manager
+	Key  string `yaml:"key,omitempty"`  // GPG armored keyring
 }
 
 // CustomManagerCmd represents a command for a custom manager.


More information about the lxc-devel mailing list