The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/distrobuilder/pull/253
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) === This closes #251. Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
From 0fe7d9f189090844836eb6965aca2804a5c9b4cb Mon Sep 17 00:00:00 2001 From: Thomas Hipp <thomas.h...@canonical.com> Date: Thu, 24 Oct 2019 08:13:01 +0200 Subject: [PATCH] sources/oracle: Fix Oracle Linux 8 Signed-off-by: Thomas Hipp <thomas.h...@canonical.com> --- sources/oraclelinux-http.go | 47 +++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/sources/oraclelinux-http.go b/sources/oraclelinux-http.go index e02564a..4906455 100644 --- a/sources/oraclelinux-http.go +++ b/sources/oraclelinux-http.go @@ -2,12 +2,12 @@ package sources import ( "fmt" + "io/ioutil" "net/http" "os" "path/filepath" "regexp" "strings" - "syscall" lxd "github.com/lxc/lxd/shared" "golang.org/x/sys/unix" @@ -84,12 +84,6 @@ func (s *OracleLinuxHTTP) unpackISO(latestUpdate, filePath, rootfsDir string) er } - err = shared.RunCommand("mount", "-o", "ro", rootfsImage, roRootDir) - if err != nil { - return err - } - defer syscall.Unmount(roRootDir, 0) - // Remove rootfsDir otherwise rsync will copy the content into the directory // itself err = os.RemoveAll(rootfsDir) @@ -97,9 +91,7 @@ func (s *OracleLinuxHTTP) unpackISO(latestUpdate, filePath, rootfsDir string) er return err } - // Since roRootDir is read-only, we need to copy it to a temporary rootfs - // directory in order to create the minimal rootfs. - err = shared.RunCommand("rsync", "-qa", roRootDir+"/", tempRootDir) + err = s.unpackRootfsImage(rootfsImage, tempRootDir) if err != nil { return err } @@ -277,3 +269,38 @@ func (s *OracleLinuxHTTP) getLatestUpdate(URL string) (string, error) { return strings.TrimSuffix(latestUpdate, "/"), nil } + +func (s OracleLinuxHTTP) unpackRootfsImage(imageFile string, target string) error { + installDir, err := ioutil.TempDir(filepath.Join(os.TempDir(), "distrobuilder"), "temp_") + if err != nil { + return err + } + defer os.RemoveAll(installDir) + + err = shared.RunCommand("mount", "-o", "ro", imageFile, installDir) + if err != nil { + return err + } + defer unix.Unmount(installDir, 0) + + rootfsDir := installDir + rootfsFile := filepath.Join(installDir, "LiveOS", "rootfs.img") + + if lxd.PathExists(rootfsFile) { + rootfsDir, err = ioutil.TempDir(filepath.Join(os.TempDir(), "distrobuilder"), "temp_") + if err != nil { + return err + } + defer os.RemoveAll(rootfsDir) + + err = shared.RunCommand("mount", "-o", "ro", rootfsFile, rootfsDir) + if err != nil { + return err + } + defer unix.Unmount(rootfsFile, 0) + } + + // Since rootfs is read-only, we need to copy it to a temporary rootfs + // directory in order to create the minimal rootfs. + return shared.RunCommand("rsync", "-qa", rootfsDir+"/", target) +}
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel