[lxc-devel] [distrobuilder/master] doc,sources: Fix CentOS 6
monstermunchkin on Github
lxc-bot at linuxcontainers.org
Fri Jun 29 16:40:02 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 409 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180629/8167eeb0/attachment.bin>
-------------- next part --------------
From e5acd73f81ad37151f3a2088fde650cea9b6a7e6 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Fri, 29 Jun 2018 18:32:12 +0200
Subject: [PATCH] doc,sources: Fix CentOS 6
Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
doc/examples/centos | 33 ++++++++++++++++++++++++++++++---
sources/centos-http.go | 42 ++++++++++++++++++++++++++++++++----------
2 files changed, 62 insertions(+), 13 deletions(-)
diff --git a/doc/examples/centos b/doc/examples/centos
index 9d19ae6..5ace4cd 100644
--- a/doc/examples/centos
+++ b/doc/examples/centos
@@ -11,6 +11,7 @@ source:
url: http://centos.uib.no
keys:
- 24C6A8A7F4A80EB5
+ - 0946FCA2C105B9DE
variant: Minimal
targets:
@@ -63,6 +64,8 @@ actions:
- trigger: post-unpack
action: |-
#!/bin/sh
+ touch /etc/mtab /etc/fstab
+
cd /mnt/cdrom/Packages
rpm -ivh --nodeps $(ls rpm-*.rpm | head -n1)
rpm -ivh --nodeps $(ls yum-*.rpm | head -n1)
@@ -75,16 +78,40 @@ actions:
baseurl=file:///mnt/cdrom
enabled=0
gpgcheck=1
- gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-7
EOF
+ - trigger: post-unpack
+ action: |-
+ echo gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-6 >> /etc/yum.repos.d/cdrom.repo
+ releases:
+ - 6
+
+ - trigger: post-unpack
+ action: |-
+ echo gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-7 >> /etc/yum.repos.d/cdrom.repo
+ releases:
+ - 7
+
+ - trigger: post-unpack
+ action: |-
yum --disablerepo=\* --enablerepo=cdrom -y reinstall yum
- yum --disablerepo=\* --enablerepo=cdrom -y groupinstall "Minimal Install"
- rm -rf /mnt/cdrom /etc/yum.repos.d/cdrom.repo
+ - trigger: post-unpack
+ action: |-
+ yum --disablerepo=\* --enablerepo=cdrom -y groupinstall "Core"
+ releases:
+ - 6
+
+ - trigger: post-unpack
+ action: |-
+ yum --disablerepo=\* --enablerepo=cdrom -y groupinstall "Minimal Install"
releases:
- 7
+ - trigger: post-unpack
+ action: |-
+ rm -rf /mnt/cdrom /etc/yum.repos.d/cdrom.repo
+
- trigger: post-packages
action: |-
#!/bin/sh
diff --git a/sources/centos-http.go b/sources/centos-http.go
index 5b5cf87..ae0fdc9 100644
--- a/sources/centos-http.go
+++ b/sources/centos-http.go
@@ -14,6 +14,7 @@ import (
"syscall"
"github.com/lxc/distrobuilder/shared"
+ lxd "github.com/lxc/lxd/shared"
)
// CentOSHTTP represents the CentOS HTTP downloader.
@@ -87,15 +88,23 @@ func (s CentOSHTTP) unpack(filePath, rootfsDir string) error {
}
defer syscall.Unmount(isoDir, 0)
- err = shared.RunCommand("mount", filepath.Join(isoDir, "LiveOS",
- "squashfs.img"), squashfsDir)
- if err != nil {
- return err
+ var rootfsImage string
+ squashfsImage := filepath.Join(isoDir, "LiveOS", "squashfs.img")
+ if lxd.PathExists(squashfsImage) {
+ // The squashfs.img contains an image containing the rootfs, so first
+ // mount squashfs.img
+ err = shared.RunCommand("mount", "-o", "ro", squashfsImage, squashfsDir)
+ if err != nil {
+ return err
+ }
+ defer syscall.Unmount(squashfsDir, 0)
+
+ rootfsImage = filepath.Join(squashfsDir, "LiveOS", "rootfs.img")
+ } else {
+ rootfsImage = filepath.Join(isoDir, "images", "install.img")
}
- defer syscall.Unmount(squashfsDir, 0)
- err = shared.RunCommand("mount", filepath.Join(squashfsDir, "LiveOS",
- "rootfs.img"), tempRootDir)
+ err = shared.RunCommand("mount", "-o", "ro", rootfsImage, tempRootDir)
if err != nil {
return err
}
@@ -147,7 +156,8 @@ func (s CentOSHTTP) unpack(filePath, rootfsDir string) error {
}
func (s CentOSHTTP) getRelease(URL, release, variant, arch string) string {
- resp, err := http.Get(URL + path.Join("/", strings.Split(release, ".")[0], "isos", arch))
+ releaseFields := strings.Split(release, ".")
+ resp, err := http.Get(URL + path.Join("/", releaseFields[0], "isos", arch))
if err != nil {
fmt.Fprintln(os.Stderr, err)
return ""
@@ -155,7 +165,19 @@ func (s CentOSHTTP) getRelease(URL, release, variant, arch string) string {
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ return ""
+ }
+
+ var re string
+ if len(releaseFields) > 1 {
+ re = fmt.Sprintf("CentOS-%s.%s-%s-(?i:%s)(-\\d+)?.iso",
+ releaseFields[0], releaseFields[1], arch, variant)
+ } else {
+ re = fmt.Sprintf("CentOS-%s(.\\d+)?-%s-(?i:%s)(-\\d+)?.iso",
+ releaseFields[0], arch, variant)
+ }
- regex := regexp.MustCompile(fmt.Sprintf("CentOS-%s-%s-(?i:%s)(-\\d+)?.iso", release, arch, variant))
- return regex.FindString(string(body))
+ return regexp.MustCompile(re).FindString(string(body))
}
More information about the lxc-devel
mailing list