What's in/cooking
[git/spearce.git] / Dothem
blob0c95205c05702e35df47c465597cf9e10ae36e90
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 while case "$1" in
21 --pedantic | --locale=* | --loose) M="$M $1" ;;
22 --force) force=$1 ;;
23 --dash) with_dash=y ;;
24 --noinstall) install=noinstall ;;
25 --nodoc) nodoc=y ;;
26 --notest) notest=y ;;
27 --bootstrap) bootstrap=y ;;
28 --base=*) BUILDBASE=${1#*=} ;;
29 --branches=*) branches=${1#*=} ;;
30 -j*) jobs=$1 ;;
31 -*) echo >&2 "Unknown option: $1"; exit 1 ;;
32 *) break ;;
33 esac
35 shift
36 done
37 test -f /bin/dash || with_dash=
38 if test -z "$BUILDBASE"
39 then
40 if test -d "$inst_prefix/buildfarm"
41 then
42 BUILDBASE="$inst_prefix/buildfarm"
43 elif test -d "../buildfarm"
44 then
45 BUILDBASE=../buildfarm
46 else
47 echo >&2 "Buildbase unknown"
48 exit 1
51 test -n "$branches" || branches='next master maint pu jch'
52 test -n "$jobs" || jobs=-j2
54 for branch in $branches
56 echo "** $branch **"
57 revision=$(git show-ref -s --verify "refs/heads/$branch") || {
58 echo "** No $branch"
59 continue
62 if test ! -d "$BUILDBASE/$branch"
63 then
64 if test -z "$bootstrap"
65 then
66 echo "** No $BUILDBASE/$branch"
67 continue
69 "$NWD" . "$BUILDBASE/$branch" $branch &&
70 ln -s "$(pwd)/Meta" "$BUILDBASE/$branch/Meta" || {
71 echo "** Failed to bootstrap $BUILDBASE/$branch"
72 continue
76 private=$(git rev-parse -q --verify private-$branch 2>/dev/null)
77 case $? in 0|1) ;; *) exit $? ;; esac
79 if test -f "$inst_prefix/git-$branch/bin/git" &&
80 installed=$($inst_prefix/git-$branch/bin/git version) &&
81 if version=$(expr "$installed" : '.*\.g\([0-9a-f]*\)$')
82 then
84 elif version=v$(expr "$installed" : \
85 'git version \(.*\)\.rc[0-9]*$')
86 then
87 version="$version"-$(expr "$installed" : \
88 'git version .*\.\(rc[0-9]*\)$')
89 else
90 version=v$(expr "$installed" : 'git version \(.*\)')
91 fi &&
92 version=$(git rev-parse --verify "$version^0" 2>/dev/null) &&
93 test "z$version" = "z$revision"
94 then
95 echo "* up-to-date version \"$installed\" is already installed from $branch"
96 test -n "$force" || continue
100 case "$branch, $branches " in
101 jch,*' next '*)
102 if git diff --quiet --exit-code jch next
103 then
104 dotest=
105 else
106 dotest=test
110 dotest=test ;;
111 esac
112 test -z "$notest" || dotest=
114 cd "$BUILDBASE/$branch"
115 git reset --hard &&
116 case "$(git symbolic-ref HEAD)" in
117 "refs/heads/$branch")
118 : ;;
120 git checkout "$branch" &&
121 git reset --hard || exit
122 esac &&
124 case "$private" in
128 git merge --squash --no-commit "$private" || {
129 echo >&2 "** Cannot apply private edition changes"
130 git reset --hard
133 esac &&
136 test "z$with_dash" != 'zy' ||
137 Meta/Make $M -- $jobs SHELL_PATH=/bin/dash $dotest
138 } &&
140 Meta/Make $M -- $jobs $dotest &&
142 test -n "$nodoc" ||
143 Meta/Make $M -- doc install-doc
144 } &&
147 test z$install = znoinstall ||
148 Meta/Make $M -- install
149 } || exit $?
151 git reset --hard
152 ) || break;
154 done