about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support/setup-hooks/canonicalize-jars.sh
blob: 5137bfc94b011722fba62a199bbfa58391a7651b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# This setup hook causes the fixup phase to repack all JAR files in a
# canonical & deterministic fashion, e.g. resetting mtimes (like with normal
# store files) and avoiding impure metadata.

fixupOutputHooks+=('if [ -z "$dontCanonicalizeJars" -a -e "$prefix" ]; then canonicalizeJarsIn "$prefix"; fi')

canonicalizeJarsIn() {
  local dir="$1"
  echo "canonicalizing jars in $dir"
  dir="$(realpath -sm -- "$dir")"
  while IFS= read -rd '' f; do
    canonicalizeJar "$f"
  done < <(find -- "$dir" -type f -name '*.jar' -print0)
}

source @canonicalize_jar@