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

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 e65a7babb0187136c99792bd49bdaf2706471914 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.h...@canonical.com>
Date: Thu, 9 Jul 2020 13:25:41 +0200
Subject: [PATCH 1/2] Revert "managers/yum: Pass "--allowerasing" flag"

This reverts commit 075be6c56d4a27b93f83cd8dec44e0c885a4425c.
---
 managers/yum.go | 1 -
 1 file changed, 1 deletion(-)

diff --git a/managers/yum.go b/managers/yum.go
index d93a1c5..f18f6a5 100644
--- a/managers/yum.go
+++ b/managers/yum.go
@@ -27,7 +27,6 @@ func NewYum() *Manager {
                        },
                        global: []string{
                                "-y",
-                               "--allowerasing",
                        },
                        install: []string{
                                "install",

From 25c9b6246a67b372327337c4462978de2aaa74c2 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.h...@canonical.com>
Date: Thu, 9 Jul 2020 14:18:22 +0200
Subject: [PATCH 2/2] managers/yum: Use --allowerasing when available

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

diff --git a/managers/yum.go b/managers/yum.go
index f18f6a5..9317532 100644
--- a/managers/yum.go
+++ b/managers/yum.go
@@ -1,6 +1,8 @@
 package managers
 
 import (
+       "bufio"
+       "bytes"
        "fmt"
        "os"
        "path/filepath"
@@ -13,6 +15,20 @@ import (
 
 // NewYum creates a new Manager instance.
 func NewYum() *Manager {
+       var buf bytes.Buffer
+       globalFlags := []string{"-y"}
+
+       lxd.RunCommandWithFds(nil, &buf, "yum", "--help")
+
+       scanner := bufio.NewScanner(&buf)
+
+       for scanner.Scan() {
+               if strings.Contains(scanner.Text(), "--allowerasing") {
+                       globalFlags = append(globalFlags, "--allowerasing")
+                       break
+               }
+       }
+
        return &Manager{
                commands: ManagerCommands{
                        clean:   "yum",
@@ -25,9 +41,7 @@ func NewYum() *Manager {
                        clean: []string{
                                "clean", "all",
                        },
-                       global: []string{
-                               "-y",
-                       },
+                       global: globalFlags,
                        install: []string{
                                "install",
                        },
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to