src/rt/release.sh: Teach it to build bash
[msysgit.git] / src / rt / release.sh
blob2b86fbb79f7b15f0e64573266c30d2587d89039c
1 #!/bin/sh
3 die () {
4 echo "$*" >&2
5 exit 1
8 cd "$(dirname "$0")"
10 target=
11 debug=
13 # see what to build
14 case "$1" in
15 msys|bash)
16 target=$1
19 die "$0 (msys|bash) [options]"
21 esac
23 shift
25 test "a$1" = "a--debug" && debug=t
26 debug_clean=
27 test "$debug" = "$(cat debug.txt 2>/dev/null)" || debug_clean=t
28 echo "$debug" > debug.txt
30 test -d ../msys/msys/rt ||
32 cd ../.. &&
33 git submodule update --init src/msys
34 ) ||
35 die "Could not check out msys.git"
37 cd ../msys || {
38 echo "Huh? ../msys does not exist."
39 exit 1
42 current=$(git rev-list --no-merges origin/master.. | wc -l) &&
43 total=$(ls ../rt/patches/*.patch | wc -l) &&
44 i=1 &&
45 while test $i -le $total
47 test $i -le $current ||
48 git am ../rt/patches/$(printf "%04d" $i)*.patch ||
49 die "Error: Applying patches failed."
50 i=$(($i+1))
51 done
54 cd msys &&
55 release=MSYS-g$(git show -s --pretty=%h HEAD) ||
56 die "Could not detect MSYS release"
58 test -f /bin/cc.exe || ln gcc.exe /bin/cc.exe ||
59 die "Could not make sure that MSys cc is found instead of MinGW one"
61 # build msys.dll
62 release_msys() {
63 (export MSYSTEM=MSYS &&
64 export PATH=/bin:$PATH &&
65 cd rt &&
66 (test -d bld || mkdir bld) &&
67 cd bld &&
68 DLL=i686-pc-msys/winsup/cygwin/new-msys-1.0.dll &&
69 (test -f Makefile && test -z "$debug_clean" ||
70 ../src/configure --prefix=/usr) &&
71 (test -z "$debug" || perl -i.bak -pe 's/-O2//g' $(find -name Makefile)) &&
72 (test -z "$debug_clean" || make clean) &&
73 (make || test -f $DLL) &&
74 (test ! -z "$debug" || strip $DLL) &&
75 rebase -b 0x68000000 $DLL &&
76 mv $DLL /bin/) &&
77 cd / &&
78 hash=$(git hash-object -w bin/new-msys-1.0.dll) &&
79 git update-index --cacheinfo 100755 $hash bin/msys-1.0.dll &&
80 git commit -s -m "Updated msys-1.0.dll to $release" &&
81 /share/msysGit/post-checkout-hook HEAD^ HEAD 1
84 # build bash.exe
85 release_bash() {
86 (export MSYSTEM=MSYS &&
87 export PATH=/bin:$PATH &&
88 cd packages/bash &&
89 (test -d bld || mkdir bld) &&
90 cd bld &&
91 BASH=bash.exe &&
92 (test -f Makefile && test -z "$debug_clean" ||
93 ../3.1/configure \
94 --prefix=/usr \
95 --sysconfdir=/etc \
96 --localstatedir=/var \
97 --disable-nls \
98 --disable-rpath \
99 --without-curses) &&
100 (test -z "$debug" || perl -i.bak -pe 's/-O2//g' $(find -name Makefile)) &&
101 (test -z "$debug_clean" || make clean) &&
102 make &&
103 test -f $BASH &&
104 (test ! -z "$debug" || strip $BASH) &&
105 cp $BASH /bin/new-bash.exe) &&
106 cd / &&
107 hash=$(git hash-object -w bin/new-bash.exe) &&
108 git update-index --cacheinfo 100755 $hash bin/bash.exe &&
109 git update-index --cacheinfo 100755 $hash bin/sh.exe &&
110 git commit -s -m "Updated bash.exe to $release" &&
111 /share/msysGit/post-checkout-hook HEAD^ HEAD 1
114 release_$target