Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / compilers / llvm / update.sh
blob8f28d34073cd6be4120caaa7d307fe50850cab4e
1 #!/usr/bin/env bash
3 set -eu
5 # Example usage: ./pkgs/development/compilers/llvm/update.sh 12.0.0-rc4
7 readonly VERSION="$1"
8 readonly VERSION_MAJOR="${VERSION%%.*}"
9 readonly VERSION_MAIN="${VERSION%%-*}"
10 declare VERSION_PATCH="${VERSION/$VERSION_MAIN/}"
11 readonly VERSION_PATCH="${VERSION_PATCH/-/}"
13 readonly DIR="pkgs/development/compilers/llvm/$VERSION_MAJOR"
14 readonly FILE="$DIR/default.nix"
16 sed -Ei \
17 -e "s/release_version = \".+\";/release_version = \"$VERSION_MAIN\";/" \
18 -e "s/candidate = \".*\";/candidate = \"$VERSION_PATCH\";/" \
19 "$FILE"
21 readonly ATTRSET="llvmPackages_$VERSION_MAJOR"
22 readonly SOURCES=(
23 "clang-unwrapped.src"
24 "compiler-rt.src"
25 "clang-unwrapped.clang-tools-extra_src"
26 "libcxx.src"
27 "libcxxabi.src"
28 "libunwind.src"
29 "lld.src"
30 "lldb.src"
31 "llvm.src"
32 "llvm.polly_src"
33 "openmp.src"
36 for SOURCE in "${SOURCES[@]}"; do
37 echo "Updating the hash of $SOURCE:"
38 declare ATTR="$ATTRSET.$SOURCE"
39 declare OLD_HASH="$(nix eval -f . $ATTR.outputHash)"
40 declare NEW_HASH="\"$(nix-prefetch-url -A $ATTR)\""
41 find "$DIR" -type f -exec sed -i "s/$OLD_HASH/$NEW_HASH/" {} +
42 done
44 echo OK