What's cooking (2012/11 #10)
[alt-git.git] / Dothem
blob3f4a6bf64c26827d929308cb3f385aae827e518e
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 for TRASH in /dev/shm /tmp ""
43 if test -n "$TRASH" && mkdir -p "$TRASH/testpen" && test -w "TRASH/testpen"
44 then
45 TRASH="--root=$(cd "$TRASH/testpen" && /bin/pwd)"
46 break
48 done
50 sh -c 'asciidoc --version >/dev/null 2>&1' || nodoc=y
51 GIT_TEST_OPTS="$TRASH${GIT_TEST_OPTS+" $GIT_TEST_OPTS"}"
52 export GIT_TEST_OPTS
54 test -f /bin/dash || with_dash=
55 if test -z "$BUILDBASE"
56 then
57 if test -d "$inst_prefix/buildfarm"
58 then
59 BUILDBASE="$inst_prefix/buildfarm"
60 elif test -d "../buildfarm"
61 then
62 BUILDBASE=../buildfarm
63 else
64 echo >&2 "Buildbase unknown"
65 exit 1
68 test -n "$branches" || branches='next master maint jch pu'
69 test -n "$jobs" || jobs=-j2
71 find_installed () {
72 branch=$1
73 test -f "$inst_prefix/git-$branch/bin/git" &&
74 installed=$($inst_prefix/git-$branch/bin/git version) &&
75 if version=$(expr "$installed" : '.*\.g\([0-9a-f]*\)$')
76 then
78 elif version=v$(expr "$installed" : \
79 'git version \(.*\)\.rc[0-9]*$')
80 then
81 version="$version"-$(expr "$installed" : \
82 'git version .*\.\(rc[0-9]*\)$')
83 else
84 version=v$(expr "$installed" : 'git version \(.*\)')
85 fi &&
86 git rev-parse --verify "$version^0" 2>/dev/null
89 installed_source_trees=" "
90 for branch in $branches
92 if v=$(find_installed $branch) &&
93 test -n "$v" &&
94 v=$(git rev-parse --verify "$v^{tree}" 2>/dev/null)
95 then
96 installed_source_trees="$installed_source_trees$v "
98 done
100 for branch in $branches
102 echo "** $branch **"
103 revision=$(git show-ref -s --verify "refs/heads/$branch") || {
104 echo "** No $branch"
105 continue
108 if test ! -d "$BUILDBASE/$branch"
109 then
110 if test -z "$bootstrap"
111 then
112 echo "** No $BUILDBASE/$branch"
113 continue
115 "$NWD" . "$BUILDBASE/$branch" $branch &&
116 ln -s "$(pwd)/Meta" "$BUILDBASE/$branch/Meta" || {
117 echo "** Failed to bootstrap $BUILDBASE/$branch"
118 continue
122 private=$(git rev-parse -q --verify private-$branch 2>/dev/null)
123 case $? in 0|1) ;; *) exit $? ;; esac
125 version=$(find_installed $branch)
126 if test "z$version" = "z$revision"
127 then
128 echo "* up-to-date version is already installed from $branch"
129 test -n "$force" || continue
132 vtree=$(git rev-parse --verify "$version^{tree}")
133 rtree=$(git rev-parse --verify "$revision^{tree}")
135 skip_test=$notest skip_doc=$nodoc
136 case "$force" in
140 case "$installed_source_trees" in
141 *" $rtree "*)
142 skip_test=1
144 esac
145 if test "z$vtree" = "z$rtree"
146 then
147 skip_test=1
148 skip_doc=1
150 dvtree=$(git rev-parse --verify "$version:Documentation/")
151 drtree=$(git rev-parse --verify "$revision:Documentation/")
152 if test "z$dvtree" = "z$drtree"
153 then
154 skip_doc=1
156 case "$branch, $branches " in
157 jch,*' next '*)
158 if git diff --quiet --exit-code jch next
159 then
160 skip_test=1
163 esac
165 esac
167 case "$skip_test" in
168 ?*) dotest= ;;
169 '') dotest=test ;;
170 esac
172 cd "$BUILDBASE/$branch"
173 git reset --hard &&
174 case "$(git symbolic-ref HEAD)" in
175 "refs/heads/$branch")
176 : ;;
178 git checkout "$branch" &&
179 git reset --hard || exit
180 esac &&
182 case "$scratch" in
186 Meta/Make clean
188 esac &&
190 case "$private" in
194 git merge --squash --no-commit "$private" || {
195 echo >&2 "** Cannot apply private edition changes"
196 git reset --hard
199 esac &&
201 save=$(git rev-parse HEAD) &&
203 Meta/Make $M ${test+"$test"} $jobs -- ${with_dash:+SHELL_PATH=/bin/dash} $dotest &&
206 test -n "$skip_doc" ||
207 if test "$save" = "$(git rev-parse HEAD)"
208 then
209 Meta/Make $M $jobs -- doc &&
210 Meta/Make $M -- install-man install-html
211 else
212 echo >&2 "Head moved--not installing docs"
214 } &&
217 test z$install = znoinstall ||
218 if test "$save" = "$(git rev-parse HEAD)"
219 then
220 Meta/Make $M -- ${with_dash:+SHELL_PATH=/bin/dash} install
221 else
222 echo >&2 "Head moved--not installing"
224 } || exit $?
226 git reset --hard
227 ) </dev/null || exit $?
229 installed_source_trees="$installed_source_trees$rtree "
230 done