What's cooking
[git/dscho.git] / Dothem
blob47c9fb9787549b3076ee25658119024a55f379e3
1 #!/bin/sh
3 NWD=contrib/workdir/git-new-workdir
5 inst_prefix=$(
6 IFS=:
7 for p in $PATH
8 do
9 probed=${p%/git-active/bin}
10 if test "$probed" != "$p"
11 then
12 echo "$probed"
13 exit
15 done
16 echo $HOME
19 force= with_dash= M= install= nodoc= notest= bootstrap= branches= jobs=
20 scratch=
21 while case "$1" in
22 --pedantic | --locale=* | --loose) M="$M $1" ;;
23 --force) force=$1 ;;
24 --dash) with_dash=y ;;
25 --noinstall) install=noinstall ;;
26 --nodoc) nodoc=y ;;
27 --notest) notest=y ;;
28 --test=*) test="$1" ;;
29 --scratch) scratch=y ;;
30 --bootstrap) bootstrap=y ;;
31 --base=*) BUILDBASE=${1#*=} ;;
32 --branches=*) branches=${1#*=} ;;
33 -j*) jobs=$1 ;;
34 -*) echo >&2 "Unknown option: $1"; exit 1 ;;
35 *) break ;;
36 esac
38 shift
39 done
41 sh -c 'asciidoc --version >/dev/null 2>&1' || nodoc=y
43 test -f /bin/dash || with_dash=
44 if test -z "$BUILDBASE"
45 then
46 if test -d "$inst_prefix/buildfarm"
47 then
48 BUILDBASE="$inst_prefix/buildfarm"
49 elif test -d "../buildfarm"
50 then
51 BUILDBASE=../buildfarm
52 else
53 echo >&2 "Buildbase unknown"
54 exit 1
57 test -n "$branches" || branches='next master maint jch pu'
58 test -n "$jobs" || jobs=-j2
60 for branch in $branches
62 echo "** $branch **"
63 revision=$(git show-ref -s --verify "refs/heads/$branch") || {
64 echo "** No $branch"
65 continue
68 if test ! -d "$BUILDBASE/$branch"
69 then
70 if test -z "$bootstrap"
71 then
72 echo "** No $BUILDBASE/$branch"
73 continue
75 "$NWD" . "$BUILDBASE/$branch" $branch &&
76 ln -s "$(pwd)/Meta" "$BUILDBASE/$branch/Meta" || {
77 echo "** Failed to bootstrap $BUILDBASE/$branch"
78 continue
82 private=$(git rev-parse -q --verify private-$branch 2>/dev/null)
83 case $? in 0|1) ;; *) exit $? ;; esac
85 if test -f "$inst_prefix/git-$branch/bin/git" &&
86 installed=$($inst_prefix/git-$branch/bin/git version) &&
87 if version=$(expr "$installed" : '.*\.g\([0-9a-f]*\)$')
88 then
90 elif version=v$(expr "$installed" : \
91 'git version \(.*\)\.rc[0-9]*$')
92 then
93 version="$version"-$(expr "$installed" : \
94 'git version .*\.\(rc[0-9]*\)$')
95 else
96 version=v$(expr "$installed" : 'git version \(.*\)')
97 fi &&
98 version=$(git rev-parse --verify "$version^0" 2>/dev/null) &&
99 test "z$version" = "z$revision"
100 then
101 echo "* up-to-date version \"$installed\" is already installed from $branch"
102 test -n "$force" || continue
106 case "$branch, $branches " in
107 jch,*' next '*)
108 if git diff --quiet --exit-code jch next
109 then
110 dotest=
111 else
112 dotest=test
116 dotest=test ;;
117 esac
118 test -z "$notest" || dotest=
120 cd "$BUILDBASE/$branch"
121 git reset --hard &&
122 case "$(git symbolic-ref HEAD)" in
123 "refs/heads/$branch")
124 : ;;
126 git checkout "$branch" &&
127 git reset --hard || exit
128 esac &&
130 case "$scratch" in
134 Meta/Make clean
136 esac &&
138 case "$private" in
142 git merge --squash --no-commit "$private" || {
143 echo >&2 "** Cannot apply private edition changes"
144 git reset --hard
147 esac &&
149 save=$(git rev-parse HEAD) &&
151 test "z$with_dash" != 'zy' ||
152 Meta/Make $M $test -- $jobs SHELL_PATH=/bin/dash $dotest
153 } &&
155 Meta/Make $M $test -- $jobs $dotest &&
157 test -n "$nodoc" ||
158 Meta/Make $M -- doc install-doc
159 } &&
162 test z$install = znoinstall ||
163 if test "$save" = "$(git rev-parse HEAD)"
164 then
165 Meta/Make $M -- install
166 else
167 echo >&2 "Head moved--not installing"
169 } || exit $?
171 git reset --hard
172 ) || break;
174 done