[lxc-devel] [distrobuilder/master] managers/apk: Add repo handler

monstermunchkin on Github lxc-bot at linuxcontainers.org
Thu Nov 21 14:23:35 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/20191121/6e535b74/attachment.bin>
-------------- next part --------------
From ae3fef6742271d912f27364d4f30c8289b3817cc Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Thu, 21 Nov 2019 15:17:30 +0100
Subject: [PATCH] managers/apk: Add repo handler

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 managers/apk.go | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/managers/apk.go b/managers/apk.go
index 7d77106..29f2d81 100644
--- a/managers/apk.go
+++ b/managers/apk.go
@@ -1,5 +1,11 @@
 package managers
 
+import (
+	"os"
+
+	"github.com/lxc/distrobuilder/shared"
+)
+
 // NewApk creates a new Manager instance.
 func NewApk() *Manager {
 	return &Manager{
@@ -27,5 +33,19 @@ func NewApk() *Manager {
 				"upgrade",
 			},
 		},
+		RepoHandler: func(repoAction shared.DefinitionPackagesRepository) error {
+			f, err := os.OpenFile("/etc/apk/repositories", os.O_WRONLY|os.O_APPEND, 0644)
+			if err != nil {
+				return err
+			}
+			defer f.Close()
+
+			_, err = f.WriteString(repoAction.URL + "\n")
+			if err != nil {
+				return err
+			}
+
+			return nil
+		},
 	}
 }


More information about the lxc-devel mailing list