Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions internal/slicer/slicer.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type pathData struct {
until setup.PathUntil
mutable bool
hardLink bool
// implicit is set when the path is only known as the parent of another
// known path and no slice has listed it yet.
implicit bool
}

type contentChecker struct {
Expand Down Expand Up @@ -439,12 +442,12 @@ func addKnownPath(knownPaths map[string]pathData, path string, data pathData) {
slashPath += "/"
}
for {
if _, ok := knownPaths[slashPath]; ok {
if old, ok := knownPaths[slashPath]; ok && !old.implicit {
break
}
knownPaths[slashPath] = data
// The parents have empty data.
data = pathData{}
// The parents have empty data until a slice lists them explicitly.
data = pathData{implicit: true}
cleanPath = filepath.Dir(cleanPath)
if cleanPath == "/" {
break
Expand Down
32 changes: 32 additions & 0 deletions internal/slicer/slicer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,38 @@ var slicerTests = []slicerTest{{
manifestPaths: map[string]string{
"/dir/nested/file-copy": "file 0644 cc55e2ec {test-package_myslice}",
},
}, {
summary: "Script: 'until' on a made directory that is also an implicit parent",
slices: []setup.SliceKey{{"test-package", "myslice"}},
release: map[string]string{
"slices/mydir/test-package.yaml": `
package: test-package
slices:
myslice:
contents:
/dir/: {make: true, until: mutate}
/dir/file: {until: mutate}
`,
},
// Extracting /dir/file registers /dir/ as an implicit parent before the
// generated content is created, which must not hide the explicit entry.
filesystem: map[string]string{},
manifestPaths: map[string]string{},
}, {
summary: "Script: 'until' on a generated directory and its generated child",
slices: []setup.SliceKey{{"test-package", "myslice"}},
release: map[string]string{
"slices/mydir/test-package.yaml": `
package: test-package
slices:
myslice:
contents:
/gen/: {make: true, until: mutate}
/gen/text: {text: data1, until: mutate}
`,
},
filesystem: map[string]string{},
manifestPaths: map[string]string{},
}, {
summary: "Script: writing same contents to existing file does not set the final hash in report",
slices: []setup.SliceKey{{"test-package", "myslice"}},
Expand Down
Loading