Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1unpackCmdHooks+=(_FreeBSDUnpackSource)
2
3_FreeBSDUnpackSource() {
4 local fn="$1"
5 local destination
6
7 if [ -d "$fn" ]; then
8
9 destination="$(stripHash "$fn")"
10
11 if [ -e "$destination" ]; then
12 echo "Cannot copy $fn to $destination: destination already exists!"
13 echo "Did you specify two \"srcs\" with the same \"name\"?"
14 return 1
15 fi
16
17 # We can't preserve hardlinks because they may have been
18 # introduced by store optimization, which might break things
19 # in the build.
20 bsdcp -a -- "$fn" "$destination"
21 chmod -R +w "$destination"
22
23 else
24
25 case "$fn" in
26 *.tar.xz | *.tar.lzma | *.txz)
27 # Don't rely on tar knowing about .xz.
28 xz -d < "$fn" | tar xf - --warning=no-timestamp
29 ;;
30 *.tar | *.tar.* | *.tgz | *.tbz2 | *.tbz)
31 # GNU tar can automatically select the decompression method
32 # (info "(tar) gzip").
33 tar xf "$fn" --warning=no-timestamp
34 ;;
35 *)
36 return 1
37 ;;
38 esac
39
40 fi
41}