[lxc-devel] [distrobuilder/master] managers/yum: Use --allowerasing only if available
monstermunchkin on Github
lxc-bot at linuxcontainers.org
Thu Jul 9 12:19:36 UTC 2020
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/20200709/d3f043dc/attachment.bin>
-------------- next part --------------
From e65a7babb0187136c99792bd49bdaf2706471914 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at 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.hipp at 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.hipp at 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",
},
More information about the lxc-devel
mailing list