[lxc-devel] [distrobuilder/master] Fix CentOS

monstermunchkin on Github lxc-bot at linuxcontainers.org
Wed Mar 28 09:24:45 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 1149 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180328/fa3e908d/attachment.bin>
-------------- next part --------------
From c057ba649f7f70c3fd10a627c2369f79d53e5f06 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Wed, 28 Mar 2018 11:00:55 +0200
Subject: [PATCH 1/2] sources: Fix CentOS

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 sources/centos-http.go | 43 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 38 insertions(+), 5 deletions(-)

diff --git a/sources/centos-http.go b/sources/centos-http.go
index 43779ef..f94f28e 100644
--- a/sources/centos-http.go
+++ b/sources/centos-http.go
@@ -32,7 +32,7 @@ func (s *CentOSHTTP) Run(definition shared.Definition, rootfsDir string) error {
 		strings.Split(definition.Image.Release, ".")[0],
 		definition.Image.ArchitectureMapped)
 
-	s.fname = getRelease(definition.Source.URL, definition.Image.Release,
+	s.fname = s.getRelease(definition.Source.URL, definition.Image.Release,
 		definition.Source.Variant, definition.Image.ArchitectureMapped)
 	if s.fname == "" {
 		return fmt.Errorf("Couldn't get name of iso")
@@ -76,6 +76,7 @@ func (s CentOSHTTP) unpack(filePath, rootfsDir string) error {
 	tempRootDir := filepath.Join(os.TempDir(), "distrobuilder", "rootfs")
 
 	os.MkdirAll(isoDir, 0755)
+	os.MkdirAll(squashfsDir, 0755)
 	os.MkdirAll(tempRootDir, 0755)
 	defer os.RemoveAll(filepath.Join(os.TempDir(), "distrobuilder"))
 
@@ -86,13 +87,15 @@ func (s CentOSHTTP) unpack(filePath, rootfsDir string) error {
 	}
 	defer syscall.Unmount(isoDir, 0)
 
-	err = shared.RunCommand("unsquashfs", "-d", squashfsDir,
-		filepath.Join(isoDir, "LiveOS/squashfs.img"))
+	err = shared.RunCommand("mount", filepath.Join(isoDir, "LiveOS",
+		"squashfs.img"), squashfsDir)
 	if err != nil {
 		return err
 	}
+	defer syscall.Unmount(squashfsDir, 0)
 
-	err = shared.RunCommand("mount", filepath.Join(squashfsDir, "LiveOS", "rootfs.img"), tempRootDir)
+	err = shared.RunCommand("mount", filepath.Join(squashfsDir, "LiveOS",
+		"rootfs.img"), tempRootDir)
 	if err != nil {
 		return err
 	}
@@ -110,10 +113,40 @@ func (s CentOSHTTP) unpack(filePath, rootfsDir string) error {
 		return err
 	}
 
+	// Create cdrom repo for yum
+	err = os.MkdirAll(filepath.Join(rootfsDir, "mnt", "cdrom"), 0755)
+	if err != nil {
+		return err
+	}
+
+	// Copy repo relevant files to the cdrom
+	err = shared.RunCommand("rsync", "-qa",
+		filepath.Join(isoDir, "Packages"),
+		filepath.Join(isoDir, "repodata"),
+		filepath.Join(rootfsDir, "mnt", "cdrom"))
+	if err != nil {
+		return err
+	}
+
+	// Find all relevant GPG keys
+	gpgKeys, err := filepath.Glob(filepath.Join(isoDir, "RPM-GPG-KEY-*"))
+	if err != nil {
+		return err
+	}
+
+	// Copy the keys to the cdrom
+	for _, key := range gpgKeys {
+		err = shared.RunCommand("rsync", "-qa", key,
+			filepath.Join(rootfsDir, "mnt", "cdrom"))
+		if err != nil {
+			return err
+		}
+	}
+
 	return nil
 }
 
-func getRelease(URL, release, variant, arch string) string {
+func (s CentOSHTTP) getRelease(URL, release, variant, arch string) string {
 	resp, err := http.Get(URL + path.Join("/", strings.Split(release, ".")[0], "isos", arch))
 	if err != nil {
 		fmt.Fprintln(os.Stderr, err)

From 5555dd7c6e16ebec1491c0ea50054c6f1245bcae Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Wed, 28 Mar 2018 11:02:57 +0200
Subject: [PATCH 2/2] managers: Fix yum commands

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

diff --git a/managers/yum.go b/managers/yum.go
index 7ba2ced..0016107 100644
--- a/managers/yum.go
+++ b/managers/yum.go
@@ -6,7 +6,7 @@ func NewYum() *Manager {
 		command: "yum",
 		flags: ManagerFlags{
 			clean: []string{
-				"clean",
+				"clean", "all",
 			},
 			global: []string{
 				"-y",
@@ -18,10 +18,10 @@ func NewYum() *Manager {
 				"remove",
 			},
 			refresh: []string{
-				"update",
+				"makecache",
 			},
 			update: []string{
-				"upgrade",
+				"update",
 			},
 		},
 	}


More information about the lxc-devel mailing list