[lxc-devel] [distrobuilder/master] Ability to add a Zypper repository

inercia on Github lxc-bot at linuxcontainers.org
Mon Apr 1 15:53:03 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 367 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190401/86ef9909/attachment.bin>
-------------- next part --------------
From a266453a36b421a22a0b6b2457dd1ca645c6c2b3 Mon Sep 17 00:00:00 2001
From: Alvaro Saurin <alvaro.saurin at gmail.com>
Date: Mon, 1 Apr 2019 17:51:15 +0200
Subject: [PATCH] Ability to add a Zypper repository

Signed-off-by: Alvaro Saurin <alvaro.saurin at gmail.com>
---
 managers/zypper.go | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/managers/zypper.go b/managers/zypper.go
index 936d8d0..851ae2f 100644
--- a/managers/zypper.go
+++ b/managers/zypper.go
@@ -1,5 +1,23 @@
 package managers
 
+import (
+	"fmt"
+
+	"github.com/lxc/distrobuilder/shared"
+)
+
+func zypperRepoCaller(repo shared.DefinitionPackagesRepository) error {
+	if repo.Name == "" {
+		return fmt.Errorf("Invalid repository name")
+	}
+
+	if repo.URL == "" {
+		return fmt.Errorf("Invalid repository url")
+	}
+
+	return shared.RunCommand("zypper", "ar", "--refresh", "--check", repo.URL, repo.Name)
+}
+
 // NewZypper create a new Manager instance.
 func NewZypper() *Manager {
 	return &Manager{
@@ -32,5 +50,11 @@ func NewZypper() *Manager {
 				"update",
 			},
 		},
+		RepoHandler: func(repoAction shared.DefinitionPackagesRepository) error {
+			if repoAction.Type == "" || repoAction.Type == "zypper" {
+				return zypperRepoCaller(repoAction)
+			}
+			return fmt.Errorf("Invalid repository Type")
+		},
 	}
 }


More information about the lxc-devel mailing list