Skip to content

Commit

Permalink
sources: Fix RHEL common build directories
Browse files Browse the repository at this point in the history
This uses temporary directories for building RHEL based images as the
previous directory names caused the rootfs to be larger than needed.

Signed-off-by: Thomas Hipp <thomas.hipp@canonical.com>
  • Loading branch information
monstermunchkin committed Nov 4, 2021
1 parent c015943 commit 05f057b
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions sources/rhel-common.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,26 @@ type commonRHEL struct {
}

func (c *commonRHEL) unpackISO(filePath, rootfsDir string, scriptRunner func(string) error) error {
isoDir := filepath.Join(c.cacheDir, "iso")
squashfsDir := filepath.Join(c.cacheDir, "squashfs")
roRootDir := filepath.Join(c.cacheDir, "rootfs.ro")
tempRootDir := filepath.Join(c.cacheDir, "rootfs")
isoDir, err := ioutil.TempDir(c.cacheDir, "temp_")
if err != nil {
return fmt.Errorf("Failed to create temporary directory: %w", err)
}
defer os.RemoveAll(isoDir)

for _, dir := range []string{isoDir, squashfsDir, roRootDir} {
err := os.MkdirAll(dir, 0755)
if err != nil {
return fmt.Errorf("Failed to create directory %q: %w", dir, err)
}
squashfsDir, err := ioutil.TempDir(c.cacheDir, "temp_")
if err != nil {
return fmt.Errorf("Failed to create temporary directory: %w", err)
}
defer os.RemoveAll(squashfsDir)

tempRootDir, err := ioutil.TempDir(c.cacheDir, "temp_")
if err != nil {
return fmt.Errorf("Failed to create temporary directory: %w", err)
}
defer os.RemoveAll(tempRootDir)

// this is easier than doing the whole loop thing ourselves
err := shared.RunCommand("mount", "-o", "ro", filePath, isoDir)
err = shared.RunCommand("mount", "-o", "ro", filePath, isoDir)
if err != nil {
return fmt.Errorf("Failed to mount %q: %w", filePath, err)
}
Expand Down

0 comments on commit 05f057b

Please sign in to comment.