From 46f8089b36a6a4e07b51ae128055fad848bc6dd1 Mon Sep 17 00:00:00 2001 From: Alberto Carretero Date: Tue, 2 Jul 2024 17:35:00 +0200 Subject: [PATCH 1/3] chore: enable noble spread tests (#141) --- .github/workflows/spread.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spread.yml b/.github/workflows/spread.yml index 4d40b814..190a9061 100644 --- a/.github/workflows/spread.yml +++ b/.github/workflows/spread.yml @@ -29,4 +29,4 @@ jobs: - name: Build and run spread run: | (cd _spread/cmd/spread && go build) - _spread/cmd/spread/spread -v focal jammy mantic + _spread/cmd/spread/spread -v focal jammy mantic noble From 504ad6328dc4d8ed2b543465a133ce2c5cc7ffa5 Mon Sep 17 00:00:00 2001 From: Rafid Bin Mostofa Date: Thu, 4 Jul 2024 15:15:05 +0600 Subject: [PATCH 2/3] fix: use TrimPrefix for relative paths (#145) Use strings.TrimPrefix for relative paths instead of strings.TrimLeft, as the latter takes in a cutset instead of a prefix substring. --- internal/slicer/slicer.go | 2 +- internal/slicer/slicer_test.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/internal/slicer/slicer.go b/internal/slicer/slicer.go index 1f59c6c8..f164efd8 100644 --- a/internal/slicer/slicer.go +++ b/internal/slicer/slicer.go @@ -180,7 +180,7 @@ func Run(options *RunOptions) (*Report, error) { return nil } - relPath := filepath.Clean("/" + strings.TrimLeft(o.Path, targetDir)) + relPath := filepath.Clean("/" + strings.TrimPrefix(o.Path, targetDir)) if o.Mode.IsDir() { relPath = relPath + "/" } diff --git a/internal/slicer/slicer_test.go b/internal/slicer/slicer_test.go index 7c76f8c2..4f9dee55 100644 --- a/internal/slicer/slicer_test.go +++ b/internal/slicer/slicer_test.go @@ -1021,6 +1021,36 @@ var slicerTests = []slicerTest{{ }, filesystem: map[string]string{}, report: map[string]string{}, +}, { + summary: "Relative paths are properly trimmed during extraction", + slices: []setup.SliceKey{{"test-package", "myslice"}}, + pkgs: map[string][]byte{ + "test-package": testutil.MustMakeDeb([]testutil.TarEntry{ + // This particular path starting with "/foo" is chosen to test for + // a particular bug; which appeared due to the usage of + // strings.TrimLeft() instead strings.TrimPrefix() to determine a + // relative path. Since TrimLeft takes in a cutset instead of a + // prefix, the desired relative path was not produced. + // See https://github.com/canonical/chisel/pull/145. + testutil.Dir(0755, "./foo-bar/"), + }), + }, + hackopt: func(c *C, opts *slicer.RunOptions) { + opts.TargetDir = filepath.Join(filepath.Clean(opts.TargetDir), "foo") + err := os.Mkdir(opts.TargetDir, 0755) + c.Assert(err, IsNil) + }, + release: map[string]string{ + "slices/mydir/test-package.yaml": ` + package: test-package + slices: + myslice: + contents: + /foo-bar/: + mutate: | + content.list("/foo-bar/") + `, + }, }} var defaultChiselYaml = ` From 73e7a7cba9dc743dafda28443bb5775b0f5f37e6 Mon Sep 17 00:00:00 2001 From: Alberto Carretero Date: Tue, 6 Aug 2024 11:22:50 +0200 Subject: [PATCH 3/3] chore: update spread test to latest release changes (#147) * also change slice to base-passwd_data Simpler slice with mutation scripts that is consistent across versions of Chisel and we do not foresee changes to it in the near future. --- tests/basic/task.yaml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/basic/task.yaml b/tests/basic/task.yaml index 03c60436..03fdb5a8 100644 --- a/tests/basic/task.yaml +++ b/tests/basic/task.yaml @@ -4,16 +4,18 @@ execute: | rootfs_folder=rootfs_${RELEASE} mkdir -p $rootfs_folder chisel cut --release ${OS}-${RELEASE} \ - --root $rootfs_folder ca-certificates_data openssl_bins - + --root $rootfs_folder base-passwd_data openssl_bins + # make sure $rootfs_folder is not empty ls ${rootfs_folder}/* - # with the ca-certificates mutation script, we can assert that: - # - etc/ssl/certs/ca-certificates.crt is not empty - # - usr/share/ca-certificates/mozilla/ does not exist - test -s ${rootfs_folder}/etc/ssl/certs/ca-certificates.crt - test ! -d ${rootfs_folder}/usr/share/ca-certificates/mozilla + # with the base-passwd mutation script, we can assert that: + # - etc/{group,passwd} are not empty and not equal to FIXME + # - usr/share/base-passwd/{group.master,passwd.master} do not exist + test -s ${rootfs_folder}/etc/group && test "$(< ${rootfs_folder}/etc/group)" != "FIXME" + test -s ${rootfs_folder}/etc/passwd && test "$(< ${rootfs_folder}/etc/passwd)" != "FIXME" + test ! -e ${rootfs_folder}/usr/share/base-passwd/group.master + test ! -e ${rootfs_folder}/usr/share/base-passwd/passwd.master # with the openssl pkg, both internal and external dependencies need to be met, for: # - libc6_libs