Skip to content

Commit 96bfc8f

Browse files
authored
Merge pull request #81 from cgwalters/drop-losetup
Drop losetup wrapper
2 parents 4bab85f + 6c36d74 commit 96bfc8f

File tree

1 file changed

+3
-31
lines changed

1 file changed

+3
-31
lines changed

pkg/bootc/bootc_disk.go

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8-
"io"
98
"os"
109
"os/exec"
1110
"path/filepath"
12-
"strings"
1311
"sync"
1412
"syscall"
1513
"time"
@@ -34,19 +32,6 @@ const containerSizeToDiskSizeMultiplier = 2
3432
const diskSizeMinimum = 10 * 1024 * 1024 * 1024 // 10GB
3533
const imageMetaXattr = "user.bootc.meta"
3634

37-
// tempLosetupWrapperContents is a workaround for https://github.com/containers/bootc/pull/487/commits/89d34c7dbcb8a1fa161f812c6ba0a8b49ccbe00f
38-
const tempLosetupWrapperContents = `#!/bin/bash
39-
set -euo pipefail
40-
args=(/usr/sbin/losetup --direct-io=off)
41-
for arg in "$@"; do
42-
case $arg in
43-
--direct-io=*) echo "ignoring: $arg" 1>&2;;
44-
*) args+=("$arg") ;;
45-
esac
46-
done
47-
exec "${args[@]}"
48-
`
49-
5035
// DiskImageConfig defines configuration for the
5136
type DiskImageConfig struct {
5237
Filesystem string
@@ -293,20 +278,7 @@ func (p *BootcDisk) pullImage() error {
293278

294279
// runInstallContainer runs the bootc installer in a container to create a disk image
295280
func (p *BootcDisk) runInstallContainer(quiet bool, config DiskImageConfig) error {
296-
// Create a temporary external shell script with the contents of our losetup wrapper
297-
losetupTemp, err := os.CreateTemp(p.Directory, "losetup-wrapper")
298-
if err != nil {
299-
return fmt.Errorf("temp losetup wrapper: %w", err)
300-
}
301-
defer os.Remove(losetupTemp.Name())
302-
if _, err := io.Copy(losetupTemp, strings.NewReader(tempLosetupWrapperContents)); err != nil {
303-
return fmt.Errorf("temp losetup wrapper copy: %w", err)
304-
}
305-
if err := losetupTemp.Chmod(0o755); err != nil {
306-
return fmt.Errorf("temp losetup wrapper chmod: %w", err)
307-
}
308-
309-
c := p.createInstallContainer(config, losetupTemp.Name())
281+
c := p.createInstallContainer(config)
310282
if err := c.Run(); err != nil {
311283
return fmt.Errorf("failed to invoke install: %w", err)
312284
}
@@ -316,7 +288,7 @@ func (p *BootcDisk) runInstallContainer(quiet bool, config DiskImageConfig) erro
316288
// createInstallContainer creates a podman command to run the bootc installer.
317289
// Note: This code used to use the Go bindings for the podman remote client, but the
318290
// Attach interface currently leaks goroutines.
319-
func (p *BootcDisk) createInstallContainer(config DiskImageConfig, tempLosetup string) *exec.Cmd {
291+
func (p *BootcDisk) createInstallContainer(config DiskImageConfig) *exec.Cmd {
320292
bootcInstallArgs := []string{
321293
"bootc", "install", "to-disk", "--via-loopback", "--generic-image",
322294
"--skip-fetch-check",
@@ -334,7 +306,7 @@ func (p *BootcDisk) createInstallContainer(config DiskImageConfig, tempLosetup s
334306
// - add privileged, pid=host, SELinux config and bind mounts per https://containers.github.io/bootc/bootc-install.html
335307
podmanArgs := []string{"--remote", "run", "--rm", "-i", "--pid=host", "--privileged", "--security-opt=label=type:unconfined_t", "--volume=/dev:/dev", "--volume=/var/lib/containers:/var/lib/containers"}
336308
// Custom bind mounts
337-
podmanArgs = append(podmanArgs, fmt.Sprintf("--volume=%s:/output", p.Directory), fmt.Sprintf("--volume=%s:/usr/local/sbin/losetup:ro", tempLosetup))
309+
podmanArgs = append(podmanArgs, fmt.Sprintf("--volume=%s:/output", p.Directory))
338310
if term.IsTerminal(int(os.Stdin.Fd())) {
339311
podmanArgs = append(podmanArgs, "-t")
340312
}

0 commit comments

Comments
 (0)