diff --git a/internal/deb/extract.go b/internal/deb/extract.go index 570572ec..ca9762b0 100644 --- a/internal/deb/extract.go +++ b/internal/deb/extract.go @@ -266,8 +266,6 @@ func extractData(pkgReader io.ReadSeeker, options *ExtractOptions) error { } // Create the entry itself. link := tarHeader.Linkname - // TODO: The first hard link in the tarball does not have tar.TypeLink flag. - // We need to update its fstutil.Entry.Link later. if tarHeader.Typeflag == tar.TypeLink { // A hard link requires the real path of the target file. link = filepath.Join(options.TargetDir, link) diff --git a/internal/slicer/slicer.go b/internal/slicer/slicer.go index 0a097f46..aaa38ef4 100644 --- a/internal/slicer/slicer.go +++ b/internal/slicer/slicer.go @@ -32,9 +32,9 @@ type RunOptions struct { } type pathData struct { - until setup.PathUntil - mutable bool - isHardLink bool + until setup.PathUntil + mutable bool + hardLink bool } type contentChecker struct { @@ -44,7 +44,8 @@ type contentChecker struct { func (cc *contentChecker) checkMutable(path string) error { if !cc.knownPaths[path].mutable { return fmt.Errorf("cannot write file which is not mutable: %s", path) - } else if cc.knownPaths[path].isHardLink { // mutable + } + if cc.knownPaths[path].hardLink { return fmt.Errorf("cannot mutate a hard link: %s", path) } return nil @@ -209,9 +210,9 @@ func Run(options *RunOptions) error { if inSliceContents { data := pathData{ - mutable: mutable, - until: until, - isHardLink: entry.Mode.IsRegular() && entry.Link != "", + mutable: mutable, + until: until, + hardLink: entry.LinkType == fsutil.TypeHardLink, } addKnownPath(knownPaths, relPath, data) } diff --git a/internal/slicer/slicer_test.go b/internal/slicer/slicer_test.go index 53943310..8ca644ff 100644 --- a/internal/slicer/slicer_test.go +++ b/internal/slicer/slicer_test.go @@ -1764,7 +1764,7 @@ var slicerTests = []slicerTest{{ }, error: `slice test-package_myslice: cannot mutate a hard link: /hardlink`, }, { - summary: "Specifying mutability true for a hard link but not write to it is allowed", + summary: "Hard links can be marked as mutable, but not mutated", slices: []setup.SliceKey{ {"test-package", "myslice"}}, pkgs: []*testutil.TestPackage{{