Dothem: make it easier to bootstrap
[git/spearce.git] / Dothem
blob75e90ab289a06239d8f577217f02af8a67da3d53
1 #!/bin/sh
3 NWD=contrib/workdir/git-new-workdir
5 force= with_dash= M= install= nodoc= bootstrap= branches= jobs=
6 while case "$1" in
7 --pedantic) M="$M $1" ;;
8 --force) force=$1 ;;
9 --dash) with_dash=y ;;
10 --noinstall) install=noinstall ;;
11 --nodoc) nodoc=y ;;
12 --bootstrap) bootstrap=y ;;
13 --base=*) BUILDBASE=${1#*=} ;;
14 --branches=*) branches=${1#*=} ;;
15 -j*) jobs=$1 ;;
16 *) break ;;
17 esac
19 shift
20 done
21 test -f /bin/dash || with_dash=
22 test -n "$BUILDBASE" || BUILDBASE=../buildfarm
23 test -n "$branches" || branches='next master maint pu jch'
24 test -n "$jobs" || jobs=-j2
26 for branch in $branches
28 echo "** $branch **"
29 revision=$(git show-ref -s --verify "refs/heads/$branch") || {
30 echo "** No $branch"
31 continue
34 if test ! -d "$BUILDBASE/$branch"
35 then
36 if test -z "$bootstrap"
37 then
38 echo "** No $BUILDBASE/$branch"
39 continue
41 "$NWD" . "$BUILDBASE/$branch" $branch &&
42 "$NWD" Meta "$BUILDBASE/$branch/Meta" || {
43 echo "** Failed to bootstrap $BUILDBASE/$branch"
44 continue
48 private=$(git rev-parse -q --verify private-$branch 2>/dev/null)
49 case $? in 0|1) ;; *) exit $? ;; esac
51 if test -f "$HOME/git-$branch/bin/git" &&
52 installed=$($HOME/git-$branch/bin/git version) &&
53 if version=$(expr "$installed" : '.*\.g\([0-9a-f]*\)$')
54 then
56 elif version=v$(expr "$installed" : \
57 'git version \(.*\)\.rc[0-9]*$')
58 then
59 version="$version"-$(expr "$installed" : \
60 'git version .*\.\(rc[0-9]*\)$')
61 else
62 version=v$(expr "$installed" : 'git version \(.*\)')
63 fi &&
64 version=$(git rev-parse --verify "$version^0" 2>/dev/null) &&
65 test "z$version" = "z$revision"
66 then
67 echo "* up-to-date version \"$installed\" is already installed from $branch"
68 test -n "$force" || continue
72 case "$branch, $branches " in
73 jch,*' next '*)
74 if git diff --quiet --exit-code jch next
75 then
76 dotest=
77 else
78 dotest=test
82 dotest=test ;;
83 esac
85 cd "$BUILDBASE/$branch"
86 git reset --hard &&
87 case "$(git symbolic-ref HEAD)" in
88 "refs/heads/$branch")
89 : ;;
91 git checkout "$branch" &&
92 git reset --hard || exit
93 esac &&
95 case "$private" in
96 '')
98 ?*)
99 git merge --squash --no-commit "$private" || {
100 echo >&2 "** Cannot apply private edition changes"
101 git reset --hard
104 esac &&
107 test "z$with_dash" != 'zy' ||
108 Meta/Make $M -- $jobs SHELL_PATH=/bin/dash $dotest
109 } &&
111 Meta/Make $M -- $jobs $dotest &&
113 test -n "$nodoc" ||
114 Meta/Make $M -- doc install-doc
115 } &&
118 test z$install = znoinstall ||
119 Meta/Make $M -- install
120 } || exit $?
122 git reset --hard
123 ) || break;
125 done