diff --git a/container/container.go b/container/container.go index 8edfa250a..0951c8184 100644 --- a/container/container.go +++ b/container/container.go @@ -136,10 +136,8 @@ func (c *Container) Execute(args string, stdin io.Reader) error { } // we want to be sure to remove the /stacker from the generated - // filesystem after execution. TODO: parameterize this by storage - // backend? it will always be "rootfs" for btrfs and "overlay" for the - // overlay backend. Maybe this shouldn't even live here. - defer os.Remove(path.Join(c.sc.RootFSDir, c.c.Name(), "rootfs", "stacker")) + // filesystem after execution. we should probably parameterize this in + // the storage API. defer os.Remove(path.Join(c.sc.RootFSDir, c.c.Name(), "overlay", "stacker")) cmd, cleanup, err := embed_exec.GetCommand( diff --git a/doc/install.md b/doc/install.md index 08fb5dea7..13ea26b5a 100644 --- a/doc/install.md +++ b/doc/install.md @@ -36,7 +36,7 @@ packages: To run `make check` you will also need: - sudo apt install bats btrfs-progs jq libbtrfs-dev tree + sudo apt install bats jq tree umoci - https://github.com/opencontainers/umoci squashtool - https://github.com/project-stacker/squashfs @@ -53,7 +53,6 @@ The other build dependencies can be satisfied with the following command and packages: sudo dnf install lxc-devel libcap-devel libacl-devel gpgme-devel - sudo dnf install btrfs-progs sudo dnf install bats jq ### Building the Stacker Binary diff --git a/doc/running.md b/doc/running.md index 2531a6d7a..89edd316e 100644 --- a/doc/running.md +++ b/doc/running.md @@ -55,12 +55,3 @@ released in 5.11. Stacker has checks to ensure that it can run with all these environment requirements, and will fail fast if it can't do something it should be able to do. - -#### Importing squashfs images - -In order to correctly import squashfs-based images using the btrfs backend, -[squashtool](https://github.com/project-stacker/squashfs) is also required in `$PATH`. This -is required because tools like unsquashfs don't understand OCI style whiteouts, -and so will not extract them correctly. (One could fix this by implementing a -subsequent extrat pass to fix up overlay style whiteouts, but it would be -better to just use the overlay backend in this case.) diff --git a/mount/filesystems.go b/mount/filesystems.go deleted file mode 100644 index 48ef627d5..000000000 --- a/mount/filesystems.go +++ /dev/null @@ -1,35 +0,0 @@ -package mount - -import ( - "bufio" - "io" - "os" - "strings" - - "github.com/pkg/errors" -) - -func filesystemIsSupported(fs string, procFilesystems io.Reader) (bool, error) { - scanner := bufio.NewScanner(procFilesystems) - for scanner.Scan() { - line := scanner.Text() - fields := strings.Fields(line) - filesystem := fields[len(fields)-1] - - if filesystem == fs { - return true, nil - } - } - - return false, nil -} - -func FilesystemIsSupported(fs string) (bool, error) { - f, err := os.Open("/proc/filesystems") - if err != nil { - return false, errors.WithStack(err) - } - defer f.Close() - - return filesystemIsSupported(fs, f) -} diff --git a/mount/filesystems_test.go b/mount/filesystems_test.go deleted file mode 100644 index fc29dcd5c..000000000 --- a/mount/filesystems_test.go +++ /dev/null @@ -1,93 +0,0 @@ -package mount - -import ( - "bytes" - "testing" - - "github.com/stretchr/testify/assert" -) - -const hasBtrfs = `nodev sysfs -nodev tmpfs -nodev bdev -nodev proc -nodev cgroup -nodev cgroup2 -nodev cpuset -nodev devtmpfs -nodev configfs -nodev debugfs -nodev tracefs -nodev securityfs -nodev sockfs -nodev bpf -nodev pipefs -nodev ramfs -nodev hugetlbfs -nodev devpts - ext3 - ext2 - ext4 - squashfs - vfat -nodev ecryptfs - fuseblk -nodev fuse -nodev fusectl -nodev efivarfs -nodev mqueue -nodev pstore - btrfs -nodev autofs -nodev overlay -` - -func TestBtrfsPresent(t *testing.T) { - assert := assert.New(t) - - foundBtrfs, err := filesystemIsSupported("btrfs", bytes.NewReader([]byte(hasBtrfs))) - assert.NoError(err) - assert.True(foundBtrfs) -} - -const noBtrfs = `nodev sysfs -nodev tmpfs -nodev bdev -nodev proc -nodev cgroup -nodev cgroup2 -nodev cpuset -nodev devtmpfs -nodev configfs -nodev debugfs -nodev tracefs -nodev securityfs -nodev sockfs -nodev bpf -nodev pipefs -nodev ramfs -nodev hugetlbfs -nodev devpts - ext3 - ext2 - ext4 - squashfs - vfat -nodev ecryptfs - fuseblk -nodev fuse -nodev fusectl -nodev efivarfs -nodev mqueue -nodev pstore -nodev autofs -nodev overlay -` - -func TestBtrfsMissing(t *testing.T) { - assert := assert.New(t) - - foundBtrfs, err := filesystemIsSupported("btrfs", bytes.NewReader([]byte(noBtrfs))) - assert.NoError(err) - assert.False(foundBtrfs) -} diff --git a/squashfs/squashfs.go b/squashfs/squashfs.go index 0d7db98e2..09a3dc5e6 100644 --- a/squashfs/squashfs.go +++ b/squashfs/squashfs.go @@ -13,7 +13,6 @@ import ( "sync" "github.com/pkg/errors" - "golang.org/x/sys/unix" ) var checkZstdSupported sync.Once @@ -168,16 +167,10 @@ func ExtractSingleSquash(squashFile string, extractDir string, storageType strin } var uCmd []string - if storageType == "btrfs" { - if which("squashtool") == "" { - return errors.Errorf("must have squashtool (https://github.com/anuvu/squashfs) to correctly extract squashfs using btrfs storage backend") - } - - uCmd = []string{"squashtool", "extract", "--whiteouts", "--perms", - "--devs", "--sockets", "--owners"} - uCmd = append(uCmd, squashFile, extractDir) - } else { + if storageType == "overlay" { uCmd = []string{"unsquashfs", "-f", "-d", extractDir, squashFile} + } else { + return errors.Errorf("unknown storage type %v", storageType) } cmd := exec.Command(uCmd[0], uCmd[1:]...) @@ -187,35 +180,6 @@ func ExtractSingleSquash(squashFile string, extractDir string, storageType strin return cmd.Run() } -func which(name string) string { - return whichSearch(name, strings.Split(os.Getenv("PATH"), ":")) -} - -func whichSearch(name string, paths []string) string { - var search []string - - if strings.ContainsRune(name, os.PathSeparator) { - if path.IsAbs(name) { - search = []string{name} - } else { - search = []string{"./" + name} - } - } else { - search = []string{} - for _, p := range paths { - search = append(search, path.Join(p, name)) - } - } - - for _, fPath := range search { - if err := unix.Access(fPath, unix.X_OK); err == nil { - return fPath - } - } - - return "" -} - func mksquashfsSupportsZstd() bool { checkZstdSupported.Do(func() { var stdoutBuffer strings.Builder diff --git a/test/env.bats b/test/env.bats index 30a2b7484..a5719647d 100644 --- a/test/env.bats +++ b/test/env.bats @@ -41,10 +41,6 @@ EOF touch roots/.lock .stacker/.lock chmod 777 -R roots .stacker - # this only works in overlay, since the btrfs storage will mount - # btrfs.loop and the roots/.lock won't be on the same fs. since the kernel - # will give us an EBUSY for mounting the same source to the same target - # anyway, that can't race, so it's fine to ignore. ( flock 9 bad_stacker build