What's cooking (2015/08 #05)
[alt-git.git] / Dothem
blob14988d485990d6dc93fd500218f2b18a00693a1c
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 --) shift; break ;;
35 -*) echo >&2 "Unknown option: $1"; exit 1 ;;
36 *) break ;;
37 esac
39 shift
40 done
42 sh -c 'asciidoc --version >/dev/null 2>&1' || nodoc=y
44 GIT_TEST_CHAIN_LINT=1
45 export GIT_TEST_CHAIN_LINT
47 test -f /bin/dash || with_dash=
48 if test -z "$BUILDBASE"
49 then
50 if test -d "$inst_prefix/buildfarm"
51 then
52 BUILDBASE="$inst_prefix/buildfarm"
53 elif test -d "../buildfarm"
54 then
55 BUILDBASE=../buildfarm
56 else
57 echo >&2 "Buildbase unknown"
58 exit 1
61 test -n "$branches" || branches='next master maint jch pu'
62 test -n "$jobs" || jobs=-j2
64 find_installed () {
65 branch=$1
66 test -f "$inst_prefix/git-$branch/bin/git" &&
67 installed=$($inst_prefix/git-$branch/bin/git version) &&
68 if version=$(expr "$installed" : '.*\.g\([0-9a-f]*\)$')
69 then
71 elif version=v$(expr "$installed" : \
72 'git version \(.*\)\.rc[0-9]*$')
73 then
74 version="$version"-$(expr "$installed" : \
75 'git version .*\.\(rc[0-9]*\)$')
76 else
77 version=v$(expr "$installed" : 'git version \(.*\)')
78 fi &&
79 git rev-parse --verify "$version^0" 2>/dev/null
82 installed_source_trees=" "
83 for branch in $branches
85 if v=$(find_installed $branch) &&
86 test -n "$v" &&
87 v=$(git rev-parse --verify "$v^{tree}" 2>/dev/null)
88 then
89 installed_source_trees="$installed_source_trees$v "
91 done
93 for branch in $branches
95 echo "** $branch **"
96 revision=$(git show-ref -s --verify "refs/heads/$branch") || {
97 echo "** No $branch"
98 continue
101 if test ! -d "$BUILDBASE/$branch"
102 then
103 if test -z "$bootstrap"
104 then
105 echo "** No $BUILDBASE/$branch"
106 continue
108 "$NWD" . "$BUILDBASE/$branch" $branch &&
109 ln -s "$(pwd)/Meta" "$BUILDBASE/$branch/Meta" || {
110 echo "** Failed to bootstrap $BUILDBASE/$branch"
111 continue
115 private=$(git rev-parse -q --verify private-$branch 2>/dev/null)
116 case $? in 0|1) ;; *) exit $? ;; esac
118 version=$(find_installed $branch)
119 if test "z$version" = "z$revision"
120 then
121 echo "* up-to-date version is already installed from $branch"
122 test -n "$force" || continue
125 vtree=$(git rev-parse --verify "$version^{tree}")
126 rtree=$(git rev-parse --verify "$revision^{tree}")
128 skip_test=$notest skip_doc=$nodoc
129 case "$force" in
133 for xtree in $installed_source_trees $vtree
135 if test "z$xtree" = "z$rtree" ||
136 git diff --quiet "$xtree" "$rtree" -- . \
137 ':!GIT-VERSION-GEN' \
138 ':!RelNotes' \
139 ':!Documentation/'
140 then
141 skip_test=1
142 break
144 done
146 dvtree=$(git rev-parse --verify "$version:Documentation/")
147 drtree=$(git rev-parse --verify "$revision:Documentation/")
148 if test "z$dvtree" = "z$drtree"
149 then
150 skip_doc=1
153 esac
155 case "$skip_test" in
156 ?*) dotest= ;;
157 '') dotest=test ;;
158 esac
160 cd "$BUILDBASE/$branch"
161 git reset --hard &&
162 case "$(git symbolic-ref HEAD)" in
163 "refs/heads/$branch")
164 : ;;
166 git checkout "$branch" &&
167 git reset --hard || exit
168 esac &&
170 case "$scratch" in
174 Meta/Make distclean
176 esac &&
178 case "$private" in
182 git merge --squash --no-commit "$private" || {
183 echo >&2 "** Cannot apply private edition changes"
184 git reset --hard
187 esac &&
189 save=$(git rev-parse HEAD) &&
191 Meta/Make $M ${test+"$test"} $jobs --memtrash \
192 -- ${with_dash:+SHELL_PATH=/bin/dash} "$@" $dotest &&
195 test -n "$skip_doc" ||
196 if test "$save" = "$(git rev-parse HEAD)"
197 then
198 Meta/Make $M $jobs -- doc &&
199 Meta/Make $M -- install-man install-html
200 else
201 echo >&2 "Head moved--not installing docs"
203 } &&
206 test z$install = znoinstall ||
207 if test "$save" = "$(git rev-parse HEAD)"
208 then
209 Meta/Make $M -- ${with_dash:+SHELL_PATH=/bin/dash} "$@" install
210 else
211 echo >&2 "Head moved--not installing"
213 } || exit $?
215 git reset --hard
216 ) </dev/null || exit $?
218 installed_source_trees="$installed_source_trees$rtree "
219 done