Skip to content

Commit

Permalink
Add copyright only once per package
Browse files Browse the repository at this point in the history
In the current code, a copyright file from a package is added to every
slice of that package. This went unnoticed because the file was silently
overwritten from successive slices of the same package. However, the
openssl's copyright file is a symlink to the libssl3's copyright file,
and creating a symlink on the same path for the second time fails. Fix
it by adding a copyright file to only the first slice of a package.
  • Loading branch information
woky committed Oct 17, 2022
1 parent 829d21f commit 05c8aa9
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions internal/slicer/slicer.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ func Run(options *RunOptions) error {
extract[slice.Package] = extractPackage
}
arch := archives[slice.Package].Options().Arch
copyrightPath := "/usr/share/doc/" + slice.Package + "/copyright"
hasCopyright := false
for targetPath, pathInfo := range slice.Contents {
if targetPath == "" {
continue
Expand All @@ -81,9 +79,6 @@ func Run(options *RunOptions) error {
extractPackage[sourcePath] = append(extractPackage[sourcePath], deb.ExtractInfo{
Path: targetPath,
})
if sourcePath == copyrightPath && targetPath == copyrightPath {
hasCopyright = true
}
} else {
targetDir := filepath.Dir(strings.TrimRight(targetPath, "/")) + "/"
if targetDir == "" || targetDir == "/" {
Expand All @@ -95,6 +90,20 @@ func Run(options *RunOptions) error {
})
}
}
}

// Add copyright files to list of files to extract
for packageName, extractPackage := range extract {
copyrightPath := "/usr/share/doc/" + packageName + "/copyright"
hasCopyright := false
if extractInfos, ok := extractPackage[copyrightPath]; ok {
for _, info := range extractInfos {
if info.Path == copyrightPath {
hasCopyright = true
break
}
}
}
if !hasCopyright {
extractPackage[copyrightPath] = append(extractPackage[copyrightPath], deb.ExtractInfo{
Path: copyrightPath,
Expand Down

0 comments on commit 05c8aa9

Please sign in to comment.