Skip to content

Commit c36a977

Browse files
committed
clang: add helper script to keep package updated
We'll need to update our clang when Msys2 updates theirs and reapply our customisations every time, so a script makes this job less tedious and leaves no room to miss a step of the process. This script performs the same steps as the previous two commits. (it was used to generate the files for those) Signed-off-by: Matthias Aßhauer <[email protected]>
1 parent 79ea579 commit c36a977

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/bash
2+
die () {
3+
printf "$@" >&2
4+
cleanup
5+
exit 1
6+
}
7+
cleanup(){
8+
rm -rf upstream
9+
}
10+
11+
pkgname=mingw-w64-clang
12+
13+
old_pkgver="$(sed -ne 's/pkgver=\([.0-9]*\).*/\1/p' -e 's/_version=\([.0-9]*\).*/\1/p' < PKGBUILD)"
14+
old_pkgrel="$(sed -ne 's/pkgrel=\([0-9]*\).*/\1/p' < PKGBUILD)"
15+
16+
test -n "$old_pkgver" ||
17+
die "$0: could not determine current pkgver\n"
18+
19+
test -n "$old_pkgrel" ||
20+
die "$0: could not determine current pkgrel\n"
21+
22+
git clone --sparse --depth 1 https://github.com/msys2/MINGW-packages upstream
23+
cd upstream
24+
git sparse-checkout add $pkgname
25+
cd ..
26+
27+
new_pkgver="$(sed -ne 's/pkgver=\([.0-9]*\).*/\1/p' -e 's/_version=\([.0-9]*\).*/\1/p' < upstream/$pkgname/PKGBUILD)"
28+
new_pkgrel="$(sed -ne 's/pkgrel=\([0-9]*\).*/\1/p' < upstream/$pkgname/PKGBUILD)"
29+
rc="$(sed -ne 's/_rc="\(*\)".*/\1/p' < upstream/$pkgname/PKGBUILD)"
30+
31+
test -n "$new_pkgver" ||
32+
die "$0: could not determine new pkgver\n"
33+
34+
test -n "$new_pkgrel" ||
35+
die "$0: could not determine new pkgrel\n"
36+
37+
test -z "$rc" ||
38+
die "$0: MSYS2 is currently on an RC version. This script is not able to handle RC versions."
39+
40+
test "$new_pkgver" = "$old_pkgver" &&
41+
new_pkgrel="$old_pkgrel"
42+
43+
new_pkgrel=$(("$new_pkgrel"+1))
44+
45+
rm -f *.patch
46+
mv upstream/$pkgname/*.patch ./
47+
rm -f PKGBUILD
48+
mv upstream/$pkgname/PKGBUILD ./
49+
rm -f README-patches.md
50+
mv upstream/$pkgname/README-patches.md ./
51+
52+
sed -i "s/pkgrel=[.0-9]\+\(.*\)/pkgrel=$new_pkgrel\1/" PKGBUILD
53+
54+
sed -i 's/1d33da596dcef12272389cb81277db205dd2153e2e52612d2d01ab3f0e7b3fb7/614a86cb22d3785d8099760c00f3981908c9a97b65b280e7350ee5dd1a0967bd/' PKGBUILD # I don't know how, but the hash of this patch changed
55+
56+
sed -i 's/-DCMAKE_BUILD_TYPE=Release/-DCMAKE_BUILD_TYPE=MinSizeRel/' PKGBUILD # size is the main reason we build our own clang
57+
sed -i 's/-DLLVM_TARGETS_TO_BUILD=".*"/-DLLVM_TARGETS_TO_BUILD="host"/' PKGBUILD # we don't need any cross-compilation targets
58+
sed -i 's/-DLLVM_ENABLE_SPHINX=ON/-DLLVM_ENABLE_SPHINX=OFF/' PKGBUILD # we don't need to spend time building documentation that we don't ship
59+
sed -n '/^check()/{p;:a;N;/\n}/!ba;s/.*\n/echo \n/};p' -i PKGBUILD # skip about an hour of linker tests
60+
61+
62+
cleanup

0 commit comments

Comments
 (0)