[lxc-devel] [distrobuilder/master] Support architecture specific package sets

monstermunchkin on Github lxc-bot at linuxcontainers.org
Fri Feb 15 07:27:40 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 310 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190214/38372292/attachment.bin>
-------------- next part --------------
From 8b80b8840fa5c198e3411713c44445c844bbf4fa Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Fri, 15 Feb 2019 08:24:32 +0100
Subject: [PATCH 1/2] shared: Add Architecture to package set definition

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 shared/definition.go | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/shared/definition.go b/shared/definition.go
index 367f13b..33fa9e3 100644
--- a/shared/definition.go
+++ b/shared/definition.go
@@ -15,9 +15,10 @@ import (
 // A DefinitionPackagesSet is a set of packages which are to be installed
 // or removed.
 type DefinitionPackagesSet struct {
-	Packages []string `yaml:"packages"`
-	Action   string   `yaml:"action"`
-	Releases []string `yaml:"releases,omitempty"`
+	Packages      []string `yaml:"packages"`
+	Action        string   `yaml:"action"`
+	Releases      []string `yaml:"releases,omitempty"`
+	Architectures []string `yaml:"architectures,omitempty"`
 }
 
 // A DefinitionPackagesRepository contains data of a specific repository

From 8fa1835ee6e6d66b5fce76e6defa9461fc262d7b Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Fri, 15 Feb 2019 08:24:48 +0100
Subject: [PATCH 2/2] distrobuilder: Architecture specific package sets

This adds support for architecture specific package sets. If the field
is unset, packages will be installed/removed on all architectures.

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 distrobuilder/chroot.go | 6 +++++-
 distrobuilder/main.go   | 3 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/distrobuilder/chroot.go b/distrobuilder/chroot.go
index 8983831..ac0a4dd 100644
--- a/distrobuilder/chroot.go
+++ b/distrobuilder/chroot.go
@@ -10,7 +10,7 @@ import (
 )
 
 func managePackages(def shared.DefinitionPackages, actions []shared.DefinitionAction,
-	release string) error {
+	release string, architecture string) error {
 	var err error
 
 	manager := managers.Get(def.Manager)
@@ -60,6 +60,10 @@ func managePackages(def shared.DefinitionPackages, actions []shared.DefinitionAc
 			continue
 		}
 
+		if len(set.Architectures) > 0 && !lxd.StringInSlice(architecture, set.Architectures) {
+			continue
+		}
+
 		if set.Action == "install" {
 			installablePackages = append(installablePackages, set.Packages...)
 		} else if set.Action == "remove" {
diff --git a/distrobuilder/main.go b/distrobuilder/main.go
index fa075e6..a2b96a2 100644
--- a/distrobuilder/main.go
+++ b/distrobuilder/main.go
@@ -214,7 +214,8 @@ func (c *cmdGlobal) preRunBuild(cmd *cobra.Command, args []string) error {
 
 	// Install/remove/update packages
 	err = managePackages(c.definition.Packages,
-		c.definition.GetRunnableActions("post-update"), c.definition.Image.Release)
+		c.definition.GetRunnableActions("post-update"), c.definition.Image.Release,
+		c.definition.Image.ArchitectureMapped)
 	if err != nil {
 		return fmt.Errorf("Failed to manage packages: %s", err)
 	}


More information about the lxc-devel mailing list