The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/distrobuilder/pull/255

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===

From 3732bd4b33a531fdd39e1e74889897813908c113 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.h...@canonical.com>
Date: Fri, 25 Oct 2019 08:32:24 +0200
Subject: [PATCH 1/2] managers/yum: Add repo handler

This allows defining custom repositories.

Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
---
 managers/yum.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/managers/yum.go b/managers/yum.go
index 767fd32..f18f6a5 100644
--- a/managers/yum.go
+++ b/managers/yum.go
@@ -1,5 +1,16 @@
 package managers
 
+import (
+       "fmt"
+       "os"
+       "path/filepath"
+       "strings"
+
+       lxd "github.com/lxc/lxd/shared"
+
+       "github.com/lxc/distrobuilder/shared"
+)
+
 // NewYum creates a new Manager instance.
 func NewYum() *Manager {
        return &Manager{
@@ -30,5 +41,42 @@ func NewYum() *Manager {
                                "update",
                        },
                },
+               RepoHandler: yumRepoHandler,
+       }
+}
+
+func yumRepoHandler(repoAction shared.DefinitionPackagesRepository) error {
+       targetFile := filepath.Join("/etc/yum.repos.d", repoAction.Name)
+
+       if !strings.HasSuffix(targetFile, ".repo") {
+               targetFile = fmt.Sprintf("%s.repo", targetFile)
+       }
+
+       if !lxd.PathExists(filepath.Dir(targetFile)) {
+               err := os.MkdirAll(filepath.Dir(targetFile), 0755)
+               if err != nil {
+                       return err
+               }
+       }
+
+       f, err := os.Create(targetFile)
+       if err != nil {
+               return err
+       }
+       defer f.Close()
+
+       _, err = f.WriteString(repoAction.URL)
+       if err != nil {
+               return err
+       }
+
+       // Append final new line if missing
+       if !strings.HasSuffix(repoAction.URL, "\n") {
+               _, err = f.WriteString("\n")
+               if err != nil {
+                       return err
+               }
        }
+
+       return nil
 }

From cb1dd6bbcea93913a80de6c06d4323907b1b33e1 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.h...@canonical.com>
Date: Fri, 25 Oct 2019 08:34:31 +0200
Subject: [PATCH 2/2] managers/dnf: Add repo handler

This allows defining custom repositories. It uses the yum repo handler
as they have the same repo structure.

Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
---
 managers/dnf.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/managers/dnf.go b/managers/dnf.go
index 83d4e0a..b1331c5 100644
--- a/managers/dnf.go
+++ b/managers/dnf.go
@@ -30,5 +30,6 @@ func NewDnf() *Manager {
                                "clean", "all",
                        },
                },
+               RepoHandler: yumRepoHandler,
        }
 }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to