blade-formatter: 1.42.0 -> 1.42.1 (#376873)
[NixPkgs.git] / pkgs / development / compilers / llvm / update.sh
blob95ad356dbd9a93a68f2c430791c74a7aff74d70c
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"
23 if [ "$VERSION_MAJOR" -ge "14" ]; then
24 readonly SOURCES=(
25 "llvm.monorepoSrc"
27 elif [ "$VERSION_MAJOR" -eq "13" ]; then
28 readonly SOURCES=(
29 "llvm.src"
31 else
32 readonly SOURCES=(
33 "clang-unwrapped.src"
34 "compiler-rt.src"
35 "clang-unwrapped.clang-tools-extra_src"
36 "libcxx.src"
37 "libcxxabi.src"
38 "libunwind.src"
39 "lld.src"
40 "lldb.src"
41 "llvm.src"
42 "llvm.polly_src"
43 "openmp.src"
47 for SOURCE in "${SOURCES[@]}"; do
48 echo "Updating the hash of $SOURCE:"
49 declare ATTR="$ATTRSET.$SOURCE"
50 declare OLD_HASH="$(nix --extra-experimental-features nix-command eval -f . $ATTR.outputHash)"
51 declare NEW_HASH="\"$(nix-prefetch-url -A $ATTR)\""
52 find "$DIR" -type f -exec sed -i "s/$OLD_HASH/$NEW_HASH/" {} +
53 done
55 echo OK