Skip to content

Commit

Permalink
Merge branch 'main' into chisel-db-parse-generate
Browse files Browse the repository at this point in the history
  • Loading branch information
letFunny committed Aug 6, 2024
2 parents 7e19d3f + 73e7a7c commit 301f506
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/spread.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion internal/slicer/slicer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "/"
}
Expand Down
30 changes: 30 additions & 0 deletions internal/slicer/slicer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
Expand Down
16 changes: 9 additions & 7 deletions tests/basic/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 301f506

Please sign in to comment.