diff --git a/internal/slicer/slicer_test.go b/internal/slicer/slicer_test.go index e06661a0..01b2ec11 100644 --- a/internal/slicer/slicer_test.go +++ b/internal/slicer/slicer_test.go @@ -101,11 +101,11 @@ var slicerTests = []slicerTest{{ "/other-dir/file": "symlink ../dir/file", }, manifestPaths: map[string]string{ - "/dir/file": "file 0644 cc55e2ec <0> {test-package_myslice}", - "/dir/file-copy": "file 0644 cc55e2ec <0> {test-package_myslice}", + "/dir/file": "file 0644 cc55e2ec {test-package_myslice}", + "/dir/file-copy": "file 0644 cc55e2ec {test-package_myslice}", "/dir/foo/bar/": "dir 01777 {test-package_myslice}", - "/dir/text-file": "file 0644 5b41362b <0> {test-package_myslice}", - "/other-dir/file": "symlink ../dir/file <0> {test-package_myslice}", + "/dir/text-file": "file 0644 5b41362b {test-package_myslice}", + "/other-dir/file": "symlink ../dir/file {test-package_myslice}", }, }, { summary: "Glob extraction", @@ -126,8 +126,8 @@ var slicerTests = []slicerTest{{ "/dir/other-file": "file 0644 63d5dd49", }, manifestPaths: map[string]string{ - "/dir/nested/other-file": "file 0644 6b86b273 <0> {test-package_myslice}", - "/dir/other-file": "file 0644 63d5dd49 <0> {test-package_myslice}", + "/dir/nested/other-file": "file 0644 6b86b273 {test-package_myslice}", + "/dir/other-file": "file 0644 63d5dd49 {test-package_myslice}", }, }, { summary: "Create new file under extracted directory and preserve parent directory permissions", @@ -147,7 +147,7 @@ var slicerTests = []slicerTest{{ "/parent/new": "file 0644 5b41362b", }, manifestPaths: map[string]string{ - "/parent/new": "file 0644 5b41362b <0> {test-package_myslice}", + "/parent/new": "file 0644 5b41362b {test-package_myslice}", }, }, { summary: "Create new nested file under extracted directory and preserve parent directory permissions", @@ -168,7 +168,7 @@ var slicerTests = []slicerTest{{ "/parent/permissions/new": "file 0644 5b41362b", }, manifestPaths: map[string]string{ - "/parent/permissions/new": "file 0644 5b41362b <0> {test-package_myslice}", + "/parent/permissions/new": "file 0644 5b41362b {test-package_myslice}", }, }, { summary: "Create new directory under extracted directory and preserve parent directory permissions", @@ -211,7 +211,7 @@ var slicerTests = []slicerTest{{ manifestPaths: map[string]string{ "/parent/": "dir 01777 {test-package_myslice}", "/parent/permissions/": "dir 0764 {test-package_myslice}", - "/parent/permissions/file": "file 0755 722c14b3 <0> {test-package_myslice}", + "/parent/permissions/file": "file 0755 722c14b3 {test-package_myslice}", }, }, { summary: "Conditional architecture", @@ -240,10 +240,10 @@ var slicerTests = []slicerTest{{ "/dir/nested/copy-3": "file 0644 84237a05", }, manifestPaths: map[string]string{ - "/dir/nested/copy-1": "file 0644 84237a05 <0> {test-package_myslice}", - "/dir/nested/copy-3": "file 0644 84237a05 <0> {test-package_myslice}", - "/dir/text-file-1": "file 0644 5b41362b <0> {test-package_myslice}", - "/dir/text-file-3": "file 0644 5b41362b <0> {test-package_myslice}", + "/dir/nested/copy-1": "file 0644 84237a05 {test-package_myslice}", + "/dir/nested/copy-3": "file 0644 84237a05 {test-package_myslice}", + "/dir/text-file-1": "file 0644 5b41362b {test-package_myslice}", + "/dir/text-file-3": "file 0644 5b41362b {test-package_myslice}", }, }, { summary: "Copyright is not installed implicitly", @@ -267,7 +267,7 @@ var slicerTests = []slicerTest{{ "/dir/file": "file 0644 cc55e2ec", }, manifestPaths: map[string]string{ - "/dir/file": "file 0644 cc55e2ec <0> {test-package_myslice}", + "/dir/file": "file 0644 cc55e2ec {test-package_myslice}", }, }, { summary: "Install two packages", @@ -308,9 +308,9 @@ var slicerTests = []slicerTest{{ }, manifestPaths: map[string]string{ "/foo/": "dir 0755 {test-package_myslice}", - "/dir/file": "file 0644 cc55e2ec <0> {test-package_myslice}", + "/dir/file": "file 0644 cc55e2ec {test-package_myslice}", "/bar/": "dir 0755 {other-package_myslice}", - "/file": "file 0644 fc02ca0e <0> {other-package_myslice}", + "/file": "file 0644 fc02ca0e {other-package_myslice}", }, }, { summary: "Install two packages, explicit path has preference over implicit parent", @@ -366,8 +366,8 @@ var slicerTests = []slicerTest{{ }, manifestPaths: map[string]string{ "/dir/": "dir 01777 {b-explicit-dir_myslice}", - "/dir/file-1": "file 0644 a441b15f <0> {a-implicit-parent_myslice}", - "/dir/file-2": "file 0644 a441b15f <0> {c-implicit-parent_myslice}", + "/dir/file-1": "file 0644 a441b15f {a-implicit-parent_myslice}", + "/dir/file-2": "file 0644 a441b15f {c-implicit-parent_myslice}", }, }, { summary: "Valid same file in two slices in different packages", @@ -401,7 +401,7 @@ var slicerTests = []slicerTest{{ "/textFile": "file 0644 c6c83d10", }, manifestPaths: map[string]string{ - "/textFile": "file 0644 c6c83d10 <0> {other-package_myslice,test-package_myslice}", + "/textFile": "file 0644 c6c83d10 {other-package_myslice,test-package_myslice}", }, }, { summary: "Script: write a file", @@ -422,7 +422,7 @@ var slicerTests = []slicerTest{{ "/dir/text-file": "file 0644 d98cf53e", }, manifestPaths: map[string]string{ - "/dir/text-file": "file 0644 5b41362b d98cf53e <0> {test-package_myslice}", + "/dir/text-file": "file 0644 5b41362b d98cf53e {test-package_myslice}", }, }, { summary: "Script: read a file", @@ -447,8 +447,8 @@ var slicerTests = []slicerTest{{ "/foo/text-file-2": "file 0644 5b41362b", }, manifestPaths: map[string]string{ - "/dir/text-file-1": "file 0644 5b41362b <0> {test-package_myslice}", - "/foo/text-file-2": "file 0644 d98cf53e 5b41362b <0> {test-package_myslice}", + "/dir/text-file-1": "file 0644 5b41362b {test-package_myslice}", + "/foo/text-file-2": "file 0644 d98cf53e 5b41362b {test-package_myslice}", }, }, { summary: "Script: use 'until' to remove file after mutate", @@ -472,7 +472,7 @@ var slicerTests = []slicerTest{{ "/foo/text-file-2": "file 0644 5b41362b", }, manifestPaths: map[string]string{ - "/foo/text-file-2": "file 0644 d98cf53e 5b41362b <0> {test-package_myslice}", + "/foo/text-file-2": "file 0644 d98cf53e 5b41362b {test-package_myslice}", }, }, { summary: "Script: use 'until' to remove wildcard after mutate", @@ -511,7 +511,7 @@ var slicerTests = []slicerTest{{ "/dir/nested/file-copy": "file 0644 cc55e2ec", }, manifestPaths: map[string]string{ - "/dir/nested/file-copy": "file 0644 cc55e2ec <0> {test-package_myslice}", + "/dir/nested/file-copy": "file 0644 cc55e2ec {test-package_myslice}", }, }, { summary: "Script: writing same contents to existing file does not set the final hash in report", @@ -532,7 +532,7 @@ var slicerTests = []slicerTest{{ "/dir/text-file": "file 0644 5b41362b", }, manifestPaths: map[string]string{ - "/dir/text-file": "file 0644 5b41362b <0> {test-package_myslice}", + "/dir/text-file": "file 0644 5b41362b {test-package_myslice}", }, }, { summary: "Script: cannot write non-mutable files", @@ -848,8 +848,8 @@ var slicerTests = []slicerTest{{ "/other-file": "file 0644 fa0c9cdb", }, manifestPaths: map[string]string{ - "/file": "file 0644 7a3e00f5 <0> {test-package_myslice}", - "/other-file": "file 0644 fa0c9cdb <0> {other-package_myslice}", + "/file": "file 0644 7a3e00f5 {test-package_myslice}", + "/other-file": "file 0644 fa0c9cdb {other-package_myslice}", }, manifestPkgs: map[string]string{ "test-package": "test-package v1 a1 h1", @@ -915,7 +915,7 @@ var slicerTests = []slicerTest{{ "/file": "file 0644 fa0c9cdb", }, manifestPaths: map[string]string{ - "/file": "file 0644 fa0c9cdb <0> {test-package_myslice}", + "/file": "file 0644 fa0c9cdb {test-package_myslice}", }, manifestPkgs: map[string]string{ "test-package": "test-package v2 a2 h2", @@ -1072,7 +1072,7 @@ var slicerTests = []slicerTest{{ "/file": "file 0644 7a3e00f5", }, manifestPaths: map[string]string{ - "/file": "file 0644 7a3e00f5 <0> {test-package_myslice}", + "/file": "file 0644 7a3e00f5 {test-package_myslice}", }, manifestPkgs: map[string]string{ "test-package": "test-package v1 a1 h1", @@ -1109,11 +1109,11 @@ var slicerTests = []slicerTest{{ "/other-dir/file": "symlink ../dir/file", }, manifestPaths: map[string]string{ - "/dir/file": "file 0644 cc55e2ec <0> {test-package_myslice1}", - "/dir/file-copy": "file 0644 cc55e2ec <0> {test-package_myslice1}", + "/dir/file": "file 0644 cc55e2ec {test-package_myslice1}", + "/dir/file-copy": "file 0644 cc55e2ec {test-package_myslice1}", "/dir/foo/bar/": "dir 01777 {test-package_myslice1}", - "/dir/other-file": "file 0644 63d5dd49 <0> {test-package_myslice2}", - "/other-dir/file": "symlink ../dir/file <0> {test-package_myslice1}", + "/dir/other-file": "file 0644 63d5dd49 {test-package_myslice2}", + "/other-dir/file": "symlink ../dir/file {test-package_myslice1}", }, }, { summary: "Same glob in several entries with until:mutate and reading from script", @@ -1151,15 +1151,15 @@ var slicerTests = []slicerTest{{ }, manifestPaths: map[string]string{ "/dir/": "dir 0755 {test-package_myslice2}", - "/dir/file": "file 0644 cc55e2ec <0> {test-package_myslice2}", + "/dir/file": "file 0644 cc55e2ec {test-package_myslice2}", "/dir/nested/": "dir 0755 {test-package_myslice2}", - "/dir/nested/file": "file 0644 84237a05 <0> {test-package_myslice2}", - "/dir/nested/other-file": "file 0644 6b86b273 <0> {test-package_myslice2}", - "/dir/other-file": "file 0644 63d5dd49 <0> {test-package_myslice2}", + "/dir/nested/file": "file 0644 84237a05 {test-package_myslice2}", + "/dir/nested/other-file": "file 0644 6b86b273 {test-package_myslice2}", + "/dir/other-file": "file 0644 63d5dd49 {test-package_myslice2}", "/dir/several/": "dir 0755 {test-package_myslice2}", "/dir/several/levels/": "dir 0755 {test-package_myslice2}", "/dir/several/levels/deep/": "dir 0755 {test-package_myslice2}", - "/dir/several/levels/deep/file": "file 0644 6bc26dff <0> {test-package_myslice2}", + "/dir/several/levels/deep/file": "file 0644 6bc26dff {test-package_myslice2}", }, }, { summary: "Overlapping globs, until:mutate and reading from script", @@ -1197,15 +1197,15 @@ var slicerTests = []slicerTest{{ }, manifestPaths: map[string]string{ "/dir/": "dir 0755 {test-package_myslice1}", - "/dir/file": "file 0644 cc55e2ec <0> {test-package_myslice1}", + "/dir/file": "file 0644 cc55e2ec {test-package_myslice1}", "/dir/nested/": "dir 0755 {test-package_myslice1}", - "/dir/nested/file": "file 0644 84237a05 <0> {test-package_myslice1}", - "/dir/nested/other-file": "file 0644 6b86b273 <0> {test-package_myslice1}", - "/dir/other-file": "file 0644 63d5dd49 <0> {test-package_myslice1}", + "/dir/nested/file": "file 0644 84237a05 {test-package_myslice1}", + "/dir/nested/other-file": "file 0644 6b86b273 {test-package_myslice1}", + "/dir/other-file": "file 0644 63d5dd49 {test-package_myslice1}", "/dir/several/": "dir 0755 {test-package_myslice1}", "/dir/several/levels/": "dir 0755 {test-package_myslice1}", "/dir/several/levels/deep/": "dir 0755 {test-package_myslice1}", - "/dir/several/levels/deep/file": "file 0644 6bc26dff <0> {test-package_myslice1}", + "/dir/several/levels/deep/file": "file 0644 6bc26dff {test-package_myslice1}", }, }, { summary: "Overlapping glob and single entry, until:mutate on entry and reading from script", @@ -1243,15 +1243,15 @@ var slicerTests = []slicerTest{{ }, manifestPaths: map[string]string{ "/dir/": "dir 0755 {test-package_myslice1}", - "/dir/file": "file 0644 cc55e2ec <0> {test-package_myslice1}", + "/dir/file": "file 0644 cc55e2ec {test-package_myslice1}", "/dir/nested/": "dir 0755 {test-package_myslice1}", - "/dir/nested/file": "file 0644 84237a05 <0> {test-package_myslice1}", - "/dir/nested/other-file": "file 0644 6b86b273 <0> {test-package_myslice1}", - "/dir/other-file": "file 0644 63d5dd49 <0> {test-package_myslice1}", + "/dir/nested/file": "file 0644 84237a05 {test-package_myslice1}", + "/dir/nested/other-file": "file 0644 6b86b273 {test-package_myslice1}", + "/dir/other-file": "file 0644 63d5dd49 {test-package_myslice1}", "/dir/several/": "dir 0755 {test-package_myslice1}", "/dir/several/levels/": "dir 0755 {test-package_myslice1}", "/dir/several/levels/deep/": "dir 0755 {test-package_myslice1}", - "/dir/several/levels/deep/file": "file 0644 6bc26dff <0> {test-package_myslice1}", + "/dir/several/levels/deep/file": "file 0644 6bc26dff {test-package_myslice1}", }, }, { summary: "Overlapping glob and single entry, until:mutate on glob and reading from script", @@ -1280,7 +1280,7 @@ var slicerTests = []slicerTest{{ "/dir/file": "file 0644 cc55e2ec", }, manifestPaths: map[string]string{ - "/dir/file": "file 0644 cc55e2ec <0> {test-package_myslice2}", + "/dir/file": "file 0644 cc55e2ec {test-package_myslice2}", }, }, { summary: "Overlapping glob and single entry, until:mutate on both and reading from script", @@ -1329,7 +1329,7 @@ var slicerTests = []slicerTest{{ `, }, filesystem: map[string]string{"/file": "file 0644 2c26b46b"}, - manifestPaths: map[string]string{"/file": "file 0644 2c26b46b <0> {test-package_myslice1,test-package_myslice2}"}, + manifestPaths: map[string]string{"/file": "file 0644 2c26b46b {test-package_myslice1,test-package_myslice2}"}, }, { summary: "Install two packages, both are recorded", slices: []setup.SliceKey{ @@ -1573,7 +1573,7 @@ var slicerTests = []slicerTest{{ "/hardlink": "file 0644 28121945", }, manifestPaths: map[string]string{ - "/hardlink": "file 0644 28121945 <0> {test-package_myslice}", + "/hardlink": "file 0644 28121945 {test-package_myslice}", }, }, { summary: "Hard link identifier distinguishes different hard links", @@ -1840,17 +1840,23 @@ func treeDumpManifestPaths(mfest *manifest.Manifest) (map[string]string, error) case strings.HasSuffix(path.Path, "/"): fsDump = fmt.Sprintf("dir %s", path.Mode) case path.Link != "": - fsDump = fmt.Sprintf("symlink %s <%d>", path.Link, path.HardLinkId) + fsDump = fmt.Sprintf("symlink %s", path.Link) default: // Regular if path.Size == 0 { - fsDump = fmt.Sprintf("file %s empty <%d>", path.Mode, path.HardLinkId) + fsDump = fmt.Sprintf("file %s empty", path.Mode) } else if path.FinalSHA256 != "" { - fsDump = fmt.Sprintf("file %s %s %s <%d>", path.Mode, path.SHA256[:8], path.FinalSHA256[:8], path.HardLinkId) + fsDump = fmt.Sprintf("file %s %s %s", path.Mode, path.SHA256[:8], path.FinalSHA256[:8]) } else { - fsDump = fmt.Sprintf("file %s %s <%d>", path.Mode, path.SHA256[:8], path.HardLinkId) + fsDump = fmt.Sprintf("file %s %s", path.Mode, path.SHA256[:8]) } } + // Append to the end of the path dump when it represents + // a valid hard link group. + if path.HardLinkId != manifest.NON_HARD_LINK { + fsDump = fmt.Sprintf("%s <%d>", fsDump, path.HardLinkId) + } + // append {slice1, ..., sliceN} to the end of the path dump. slicesStr := make([]string, 0, len(path.Slices)) for _, slice := range path.Slices {