diff options
author | Maciek Borzecki | 2021-07-27 14:43:19 +0200 |
---|---|---|
committer | Maciek Borzecki | 2021-07-27 14:48:09 +0200 |
commit | 275cba8f4e4ebbbf95766c562b72d83364436580 (patch) | |
tree | 6e56af3eb020e4f4f371f8ccd03fdab37cb4e9c0 | |
parent | 3e593bd2e50547ad5d7035a621ccb3c11127445c (diff) | |
download | aur-275cba8f4e4ebbbf95766c562b72d83364436580.tar.gz |
upgpkg: snapd 2.51.3-2
Include squashfs-tools 4.5 compatibility patch
Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | 0001-snap-squashfs-handle-squashfs-tools-4.5.patch | 250 | ||||
-rw-r--r-- | PKGBUILD | 13 |
3 files changed, 263 insertions, 4 deletions
@@ -1,7 +1,7 @@ pkgbase = snapd pkgdesc = Service and tools for management of snap packages. pkgver = 2.51.3 - pkgrel = 1 + pkgrel = 2 url = https://github.com/snapcore/snapd install = snapd.install arch = x86_64 @@ -28,6 +28,8 @@ pkgbase = snapd options = !strip options = emptydirs source = snapd-2.51.3.tar.xz::https://github.com/snapcore/snapd/releases/download/2.51.3/snapd_2.51.3.vendor.tar.xz + source = 0001-snap-squashfs-handle-squashfs-tools-4.5.patch sha256sums = 67d3701b52484d7dba9c7b122752429eafbb20a0182966dd44ab1b1f6c1b780e + sha256sums = 8142631da873d49d9b7d32b78afcededf347199f9f42161b88213f9aef33ab82 pkgname = snapd diff --git a/0001-snap-squashfs-handle-squashfs-tools-4.5.patch b/0001-snap-squashfs-handle-squashfs-tools-4.5.patch new file mode 100644 index 000000000000..8aca0a8fd5f2 --- /dev/null +++ b/0001-snap-squashfs-handle-squashfs-tools-4.5.patch @@ -0,0 +1,250 @@ +From dfba7de59a41bc22786d87f53b20deea14240713 Mon Sep 17 00:00:00 2001 +Message-Id: <dfba7de59a41bc22786d87f53b20deea14240713.1627390028.git.maciej.zenon.borzecki@canonical.com> +From: Maciej Borzecki <maciej.zenon.borzecki@canonical.com> +Date: Tue, 27 Jul 2021 14:13:57 +0200 +Subject: [PATCH] snap/squashfs: handle squashfs-tools 4.5+ + +Arch recently landed an update of squahfs-tools to 4.5 which broke our code. The +main difference is that the output of unsquahfs stdout does not contain the +header we expected. For instance: + +google:ubuntu-20.04-64 .../mini/hello# unsquashfs -n -dest . -ll /root/foo.snap +Parallel unsquashfs: Using 1 processor +5 inodes (1 blocks) to write + +drwx------ root/root 55 2021-07-27 11:31 . +-rw-r--r-- root/root 0 2021-07-27 11:31 ./data.bin +drwxr-xr-x root/root 27 2021-07-27 11:31 ./food +drwxr-xr-x root/root 27 2021-07-27 11:31 ./food/bard +drwxr-xr-x root/root 3 2021-07-27 11:31 ./food/bard/bazd +drwxr-xr-x root/root 45 2021-07-27 11:31 ./meta +drwxr-xr-x root/root 58 2021-07-27 11:31 ./meta/hooks +-rwxr-xr-x root/root 0 2021-07-27 11:31 ./meta/hooks/bar-hook +drwxr-xr-x root/root 26 2021-07-27 11:31 ./meta/hooks/dir +-rwxr-xr-x root/root 0 2021-07-27 11:31 ./meta/hooks/dir/baz +-rwxr-xr-x root/root 0 2021-07-27 11:31 ./meta/hooks/foo-hook +-rw-r--r-- root/root 9 2021-07-27 11:31 ./meta/snap.yaml + +While on Arch with squashfs 4.5: + +$ unsquashfs -n -dest . -ll /tmp/check-1302223697476122084/0/foo.snap +drwx------ root/root 55 2021-07-27 13:31 . +-rw-r--r-- root/root 0 2021-07-27 13:31 ./data.bin +drwxr-xr-x root/root 27 2021-07-27 13:31 ./food +drwxr-xr-x root/root 27 2021-07-27 13:31 ./food/bard +drwxr-xr-x root/root 3 2021-07-27 13:31 ./food/bard/bazd +drwxr-xr-x root/root 45 2021-07-27 13:31 ./meta +drwxr-xr-x root/root 58 2021-07-27 13:31 ./meta/hooks +-rwxr-xr-x root/root 0 2021-07-27 13:31 ./meta/hooks/bar-hook +drwxr-xr-x root/root 26 2021-07-27 13:31 ./meta/hooks/dir +-rwxr-xr-x root/root 0 2021-07-27 13:31 ./meta/hooks/dir/baz +-rwxr-xr-x root/root 0 2021-07-27 13:31 ./meta/hooks/foo-hook +-rw-r--r-- root/root 9 2021-07-27 13:31 ./meta/snap.yaml + +Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com> +--- + snap/squashfs/squashfs.go | 27 ++++++--- + snap/squashfs/squashfs_test.go | 101 ++++++++++++++++++++++++++++++--- + 2 files changed, 113 insertions(+), 15 deletions(-) + +diff --git a/snap/squashfs/squashfs.go b/snap/squashfs/squashfs.go +index c656de953546f7bda4eadd95d269cc966cb4e28b..6cc9451fa9c7f8ab0f05546000404b276aa70ae4 100644 +--- a/snap/squashfs/squashfs.go ++++ b/snap/squashfs/squashfs.go +@@ -294,6 +294,12 @@ func (sk skipper) Has(path string) bool { + return false + } + ++// pre-4.5 unsquashfs writes a funny header like: ++// "Parallel unsquashfs: Using 1 processor" ++// "1 inodes (1 blocks) to write" ++// "" <-- empty line ++var maybeHeaderRegex = regexp.MustCompile(`^(Parallel unsquashfs: Using .* processor.*|[0-9]+ inodes .* to write)$`) ++ + // Walk (part of snap.Container) is like filepath.Walk, without the ordering guarantee. + func (s *Snap) Walk(relative string, walkFn filepath.WalkFunc) error { + relative = filepath.Clean(relative) +@@ -321,16 +327,21 @@ func (s *Snap) Walk(relative string, walkFn filepath.WalkFunc) error { + defer cmd.Process.Kill() + + scanner := bufio.NewScanner(stdout) +- // skip the header +- for scanner.Scan() { +- if len(scanner.Bytes()) == 0 { +- break +- } +- } +- + skipper := make(skipper) ++ seenHeader := false + for scanner.Scan() { +- st, err := fromRaw(scanner.Bytes()) ++ raw := scanner.Bytes() ++ if !seenHeader { ++ // try to match the header written by older (pre-4.5) ++ // squashfs tools ++ if len(scanner.Bytes()) == 0 || ++ maybeHeaderRegex.Match(raw) { ++ continue ++ } else { ++ seenHeader = true ++ } ++ } ++ st, err := fromRaw(raw) + if err != nil { + err = walkFn(relative, nil, err) + if err != nil { +diff --git a/snap/squashfs/squashfs_test.go b/snap/squashfs/squashfs_test.go +index f510a4466dcb1a1b7238a9365e0ce0347852df77..5618e5cc0e4f84dd05f1ea547c7c8e048c9bd796 100644 +--- a/snap/squashfs/squashfs_test.go ++++ b/snap/squashfs/squashfs_test.go +@@ -20,6 +20,7 @@ + package squashfs_test + + import ( ++ "bytes" + "errors" + "fmt" + "io/ioutil" +@@ -348,7 +349,7 @@ func (s *SquashfsTestSuite) TestListDir(c *C) { + c.Check(fileNames[2], Equals, "foo-hook") + } + +-func (s *SquashfsTestSuite) TestWalk(c *C) { ++func (s *SquashfsTestSuite) TestWalkNative(c *C) { + sub := "." + sn := makeSnap(c, "name: foo", "") + sqw := map[string]os.FileInfo{} +@@ -411,6 +412,86 @@ func (s *SquashfsTestSuite) TestWalk(c *C) { + + } + ++func (s *SquashfsTestSuite) testWalkMockedUnsquashfs(c *C) { ++ expectingNames := []string{ ++ ".", ++ "data.bin", ++ "food", ++ "meta", ++ "meta/hooks", ++ "meta/hooks/bar-hook", ++ "meta/hooks/dir", ++ "meta/hooks/dir/baz", ++ "meta/hooks/foo-hook", ++ "meta/snap.yaml", ++ } ++ sub := "." ++ sn := makeSnap(c, "name: foo", "") ++ var seen []string ++ sn.Walk(sub, func(path string, info os.FileInfo, err error) error { ++ c.Logf("got %v", path) ++ if err != nil { ++ return err ++ } ++ seen = append(seen, path) ++ if path == "food" { ++ return filepath.SkipDir ++ } ++ return nil ++ }) ++ c.Assert(len(seen), Equals, len(expectingNames)) ++ for idx, name := range seen { ++ c.Check(name, Equals, expectingNames[idx]) ++ } ++} ++ ++func (s *SquashfsTestSuite) TestWalkMockedUnsquashfs45(c *C) { ++ // mock behavior of squashfs-tools 4.5 and later ++ mockUnsquashfs := testutil.MockCommand(c, "unsquashfs", ` ++cat <<EOF ++drwx------ root/root 55 2021-07-27 13:31 . ++-rw-r--r-- root/root 0 2021-07-27 13:31 ./data.bin ++drwxr-xr-x root/root 27 2021-07-27 13:31 ./food ++drwxr-xr-x root/root 27 2021-07-27 13:31 ./food/bard ++drwxr-xr-x root/root 3 2021-07-27 13:31 ./food/bard/bazd ++drwxr-xr-x root/root 45 2021-07-27 13:31 ./meta ++drwxr-xr-x root/root 58 2021-07-27 13:31 ./meta/hooks ++-rwxr-xr-x root/root 0 2021-07-27 13:31 ./meta/hooks/bar-hook ++drwxr-xr-x root/root 26 2021-07-27 13:31 ./meta/hooks/dir ++-rwxr-xr-x root/root 0 2021-07-27 13:31 ./meta/hooks/dir/baz ++-rwxr-xr-x root/root 0 2021-07-27 13:31 ./meta/hooks/foo-hook ++-rw-r--r-- root/root 9 2021-07-27 13:31 ./meta/snap.yaml ++EOF ++`) ++ defer mockUnsquashfs.Restore() ++ s.testWalkMockedUnsquashfs(c) ++} ++ ++func (s *SquashfsTestSuite) TestWalkMockedUnsquashfsOld(c *C) { ++ // mock behavior of pre-4.5 squashfs-tools ++ mockUnsquashfs := testutil.MockCommand(c, "unsquashfs", ` ++cat <<EOF ++Parallel unsquashfs: Using 1 processor ++5 inodes (1 blocks) to write ++ ++drwx------ root/root 55 2021-07-27 13:31 . ++-rw-r--r-- root/root 0 2021-07-27 13:31 ./data.bin ++drwxr-xr-x root/root 27 2021-07-27 13:31 ./food ++drwxr-xr-x root/root 27 2021-07-27 13:31 ./food/bard ++drwxr-xr-x root/root 3 2021-07-27 13:31 ./food/bard/bazd ++drwxr-xr-x root/root 45 2021-07-27 13:31 ./meta ++drwxr-xr-x root/root 58 2021-07-27 13:31 ./meta/hooks ++-rwxr-xr-x root/root 0 2021-07-27 13:31 ./meta/hooks/bar-hook ++drwxr-xr-x root/root 26 2021-07-27 13:31 ./meta/hooks/dir ++-rwxr-xr-x root/root 0 2021-07-27 13:31 ./meta/hooks/dir/baz ++-rwxr-xr-x root/root 0 2021-07-27 13:31 ./meta/hooks/foo-hook ++-rw-r--r-- root/root 9 2021-07-27 13:31 ./meta/snap.yaml ++EOF ++`) ++ defer mockUnsquashfs.Restore() ++ s.testWalkMockedUnsquashfs(c) ++} ++ + // TestUnpackGlob tests the internal unpack + func (s *SquashfsTestSuite) TestUnpackGlob(c *C) { + data := "some random data" +@@ -478,7 +559,7 @@ EOF + c.Check(err.Error(), Equals, `cannot extract "*" to "some-output-dir": failed: "Failed to write /tmp/1/modules/4.4.0-112-generic/modules.symbols, skipping", "Write on output file failed because No space left on device", "writer: failed to write data block 0", "Failed to write /tmp/1/modules/4.4.0-112-generic/modules.symbols.bin, skipping", and 15 more`) + } + +-func (s *SquashfsTestSuite) TestBuild(c *C) { ++func (s *SquashfsTestSuite) TestBuildAll(c *C) { + // please keep TestBuildUsesExcludes in sync with this one so it makes sense. + buildDir := c.MkDir() + err := os.MkdirAll(filepath.Join(buildDir, "/random/dir"), 0755) +@@ -492,13 +573,16 @@ func (s *SquashfsTestSuite) TestBuild(c *C) { + err = sn.Build(buildDir, &squashfs.BuildOpts{SnapType: "app"}) + c.Assert(err, IsNil) + +- // unsquashfs writes a funny header like: ++ // pre-4.5 unsquashfs writes a funny header like: + // "Parallel unsquashfs: Using 1 processor" + // "1 inodes (1 blocks) to write" + outputWithHeader, err := exec.Command("unsquashfs", "-n", "-l", sn.Path()).Output() + c.Assert(err, IsNil) +- split := strings.Split(string(outputWithHeader), "\n") +- output := strings.Join(split[3:], "\n") ++ output := outputWithHeader ++ if bytes.HasPrefix(outputWithHeader, []byte(`Parallel unsquashfs: `)) { ++ split := bytes.Split(outputWithHeader, []byte("\n")) ++ output = bytes.Join(split[3:], []byte("\n")) ++ } + c.Assert(string(output), Equals, ` + squashfs-root + squashfs-root/data.bin +@@ -538,8 +622,11 @@ data.bin + + outputWithHeader, err := exec.Command("unsquashfs", "-n", "-l", sn.Path()).Output() + c.Assert(err, IsNil) +- split := strings.Split(string(outputWithHeader), "\n") +- output := strings.Join(split[3:], "\n") ++ output := outputWithHeader ++ if bytes.HasPrefix(outputWithHeader, []byte(`Parallel unsquashfs: `)) { ++ split := bytes.Split(outputWithHeader, []byte("\n")) ++ output = bytes.Join(split[3:], []byte("\n")) ++ } + // compare with TestBuild + c.Assert(string(output), Equals, ` + squashfs-root +-- +2.32.0 + @@ -9,7 +9,7 @@ depends=('squashfs-tools' 'libseccomp' 'libsystemd' 'apparmor') optdepends=('bash-completion: bash completion support' 'xdg-desktop-portal: desktop integration') pkgver=2.51.3 -pkgrel=1 +pkgrel=2 arch=('x86_64' 'i686' 'armv7h' 'aarch64') url="https://github.com/snapcore/snapd" license=('GPL3') @@ -17,8 +17,15 @@ makedepends=('git' 'go' 'go-tools' 'libseccomp' 'libcap' 'systemd' 'xfsprogs' 'p conflicts=('snap-confine') options=('!strip' 'emptydirs') install=snapd.install -source=("$pkgname-$pkgver.tar.xz::https://github.com/snapcore/${pkgname}/releases/download/${pkgver}/${pkgname}_${pkgver}.vendor.tar.xz") -sha256sums=('67d3701b52484d7dba9c7b122752429eafbb20a0182966dd44ab1b1f6c1b780e') +source=( + "$pkgname-$pkgver.tar.xz::https://github.com/snapcore/${pkgname}/releases/download/${pkgver}/${pkgname}_${pkgver}.vendor.tar.xz" + # cherry-picked from https://github.com/snapcore/snapd/pull/10567/ + "0001-snap-squashfs-handle-squashfs-tools-4.5.patch" +) +sha256sums=( + '67d3701b52484d7dba9c7b122752429eafbb20a0182966dd44ab1b1f6c1b780e' + '8142631da873d49d9b7d32b78afcededf347199f9f42161b88213f9aef33ab82' +) _gourl=github.com/snapcore/snapd |