Skip to content

Commit

Permalink
Allow same globs in multiple slices
Browse files Browse the repository at this point in the history
There's no reason why the following slices shouldn't be accepted when
the globs are identical:

    package: openjdk-8-jre-headless
    slices:
      abc:
        contents:
          /usr/lib/jvm/java-8-openjdk-*/jre/lib/*/libnpt.so:
      bcd:
        contents:
          /usr/lib/jvm/java-8-openjdk-*/jre/lib/*/libnpt.so:

Drop this restriction.
  • Loading branch information
woky committed May 17, 2023
1 parent bd27f87 commit c5bfbc5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 4 additions & 2 deletions internal/deb/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ func checkExtractOptions(options *ExtractOptions) error {
for extractPath, extractInfos := range options.Extract {
isGlob := strings.ContainsAny(extractPath, "*?")
if isGlob {
if len(extractInfos) != 1 || extractInfos[0].Path != extractPath || extractInfos[0].Mode != 0 {
return fmt.Errorf("when using wildcards source and target paths must match: %s", extractPath)
for _, info := range extractInfos {
if info.Path != extractPath || info.Mode != 0 {
return fmt.Errorf("when using wildcards source and target paths must match: %s", extractPath)
}
}
}
}
Expand Down
20 changes: 19 additions & 1 deletion internal/deb/extract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,25 @@ var extractTests = []extractTest{{
}},
},
},
error: `cannot extract .*: when using wildcards source and target paths must match: /etc/d\*\*`,
result: map[string]string{
"/etc/": "dir 0755",
"/etc/debian_version": "file 0644 cce26cfe",
"/etc/default/": "dir 0755",
"/etc/dpkg/": "dir 0755",
"/etc/dpkg/origins/": "dir 0755",
"/etc/dpkg/origins/debian": "file 0644 50f35af8",
"/etc/dpkg/origins/ubuntu": "file 0644 d2537b95",
},
globbed: map[string][]string{
"/etc/d**": []string{
"/etc/debian_version",
"/etc/default/",
"/etc/dpkg/",
"/etc/dpkg/origins/",
"/etc/dpkg/origins/debian",
"/etc/dpkg/origins/ubuntu",
},
},
}, {
summary: "Globbing cannot change modes",
pkgdata: testutil.PackageData["base-files"],
Expand Down

0 comments on commit c5bfbc5

Please sign in to comment.