3 #=======================================================================
5 # File ID: 352732aa-2e4d-11e5-bd5f-fefdb24f8e10
7 # Compile and install git(1).
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #=======================================================================
26 " -n "$progname" -- "$@
")"
27 test "$?" = "0" ||
exit 1
36 (-h|
--help) opt_help
=1; shift ;;
37 (--no-net) opt_no_net
=1; shift ;;
38 (-q|
--quiet) opt_quiet
=$
(($opt_quiet + 1)); shift ;;
39 (-v|
--verbose) opt_verbose
=$
(($opt_verbose + 1)); shift ;;
40 (--version) echo $progname $VERSION; exit 0 ;;
42 (*) echo $progname: Internal error
>&2; exit 1 ;;
45 opt_verbose
=$
(($opt_verbose - $opt_quiet))
47 if test "$opt_help" = "1"; then
48 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
51 Compile and install git(1). Default action is to build from the newest
52 revision on 'master'. Another branch or tag can be specified as first
55 Usage: $progname [options] [branch]
62 Don't fetch or push, use what's present in the local repo.
64 Be more quiet. Can be repeated to increase silence.
66 Increase level of verbosity. Can be repeated.
68 Print version information.
74 lockdir
=$HOME/.Build-git.LOCK
77 rmdir $lockdir ||
echo $progname: $lockdir: Cannot remove lockdir
>&2
81 trap "myexit 1" INT TERM
83 echo $progname: $lockdir: Cannot create lockdir
>&2
87 rcfile
=$HOME/.build-gitrc
88 origin_url
=git
://git.kernel.org
/pub
/scm
/git
/git.git
90 # Directory where the git build happens
91 builddir
=$HOME/src
/other
/git
/build-git
93 # Prefix to directory tree where git will be installed. You can change
94 # it to for example $HOME/local if you don’t have root access.
97 # If you don’t have sudo rights or you don’t need it at the location in
98 # the file system, clear the value of the $sudo variable
101 # Local name of remote master
104 # Name of remote master
105 remote_master
=origin
/master
107 # Set to 0 to skip ./configure and use Makefile in git.git instead
117 [ -e $rcfile ] && .
$rcfile
123 is_official_branch
() {
124 echo -n $1 |
grep -Eq '^(master|maint|next|pu|todo)$' &&
129 git remote |
grep -q '^origin$' || git remote add origin
$origin_url
130 git remote |
grep -q '^kernelorg$' ||
131 git remote add kernelorg git
://git.kernel.org
/pub
/scm
/git
/git.git
132 git remote |
grep -q '^gitster$' ||
{
133 git remote add gitster git
://github.com
/gitster
/git.git
134 git config
--add remote.gitster.fetch
+refs
/notes
/*:refs
/notes
/*
136 git remote |
grep -q '^gitlab$' ||
137 git remote add gitlab git@gitlab.com
:oyvholm
/git.git
138 git remote |
grep -q '^peff$' ||
139 git remote add peff git
://github.com
/peff
/git.git
140 git remote |
grep -q '^sunbase$' ||
141 git remote add sunbase \
142 sunny@sunbase.org
:/home
/sunny
/repos
/Git-other
/git.git
143 if test "$opt_no_net" = "0"; then
144 echo ================= git fetch
=================
145 echo ===== origin
=====
146 until git fetch origin
; do
147 echo $progname: Fetch error from origin
, retrying
>&2
150 # git fetch --all arrived in v1.6.6, and that’s too recent to use.
151 for f
in $
(git remote |
grep -v '^origin$'); do
155 for f
in maint master next pu todo
; do
156 git branch | cut
-c 3- |
grep -q ^
$f\$ || git branch
$f origin
/$f
162 git log
--color --graph --pretty=format
:'%Cred%h %Cblue%p%Creset '\
163 '-%C(yellow)%d%Creset %s %Cgreen(%cd %Cblue%an%Cgreen)%Creset' \
168 until $sudo echo Password OK |
grep -q "Password OK"; do
174 if test "$opt_no_net" = "0"; then
175 for f
in bellmann loc-repo passp sunbase gitlab rsync-net
; do
176 git remote |
grep -q "^$f\$" && {
177 echo ==== push changes to
$f ====
180 for f
in loc-repo passp sunbase rsync-net
; do
181 git remote |
grep -q "^$f\$" && {
182 echo ==== push tags to
$f ====
185 echo ==== push finished
====
191 date +"%Y-%m-%d %H:%M:%S%z"
202 [ -z "`git --version | grep '^git version '`" ] && {
203 echo $progname: You need to have git installed to use this
script.
>&2
207 rmdir $builddir 2>/dev
/null
208 if [ ! -d $builddir/.
]; then
209 mkdir
-p $builddir ||
{
210 echo $progname: $builddir: Cannot create directory
214 echo ================= git clone
=================
215 git clone
$origin_url $builddir
216 cd $builddir ||
{ echo $progname: $builddir: Cannot chdir
>&2; myexit
1; }
217 git config lpar.name git
218 for f
in maint next pu todo
; do
219 git branch
-t $f origin
/$f ||
{
220 echo $progname: $f: Could not create branch
>&2
225 cd $builddir ||
{ echo $progname: $builddir: Cannot chdir
>&2; myexit
1; }
226 GIT_PAGER
=cat git status
--porcelain |
grep .
&& {
227 echo $progname: $builddir is not clean
, aborting
>&2
232 (git tag |
grep compiled-
$hname-2 |
tail -1) ||
echo UNKNOWN
239 echo "curr_git_ver = \"$curr_git_ver\" ($(
241 git describe --long --match 'v[12]*' $curr_git_ver
243 echo "rcfile = \"$rcfile\" ($([ -e $rcfile ] || echo -n "not
")found)"
244 echo "builddir = \"$builddir\""
245 echo "pref = \"$pref\""
246 echo "sudo = \"$sudo\""
247 echo "local_master = \"$local_master\""
248 echo "remote_master = \"$remote_master\""
249 echo "makeflags = \"$makeflags\""
250 echo "make_doc = \"$make_doc\""
251 echo "make_info = \"$make_info\""
252 echo "hname = \"$hname\""
253 echo "use_configure = \"$use_configure\""
254 echo "configure_opts = \"$configure_opts\""
257 git checkout
$local_master ||
{ echo Cannot check out branch
>&2; myexit
1; }
258 if [ ! -e GIT-VERSION-GEN
]; then
260 echo $progname: Didn’t
find GIT-VERSION-GEN. That’s strange
, aborting.
263 is_official_branch
$local_master &&
264 destbranch
=origin
/$local_master || destbranch
=$local_master
266 if [ -n "$curr_git_ver" ]; then
267 echo ================= git status
in `pwd` =================
268 GIT_PAGER
=cat git status
272 until [ "$choice" = "y" ]; do
275 echo $
(git log
--format=oneline
$curr_git_ver..
$destbranch |
wc -l) \
276 "new commits available in range $curr_git_ver..$destbranch"
277 echo Going to compile git $
(
278 git describe
--long --match 'v[12]*' $destbranch
281 echo If that looks okay to you
, press
\'y
\' to start the build
, or
:
283 echo \'ds
\' to
diff --stat
284 echo \'dw
\' to word-diff
285 echo \'l
\' to list log
286 echo \'lp\' to list log with
patch
287 echo \'lt
\' to list log with commit tree
288 echo \'lw
\' to list log with
patch using word
diff
290 echo \'p
\' to push new commits
291 echo \'t
\' to show commit tree
293 [ "$choice" = "d" ] && git
diff $curr_git_ver $destbranch
294 [ "$choice" = "ds" ] && git
diff --stat $curr_git_ver $destbranch
295 [ "$choice" = "dw" ] && git
diff --word-diff $curr_git_ver $destbranch
296 [ "$choice" = "l" ] && git log
--stat $curr_git_ver..
$destbranch
297 [ "$choice" = "lp" ] && git log
--patch $curr_git_ver..
$destbranch
298 [ "$choice" = "lt" ] &&
299 git log
--graph --stat $curr_git_ver..
$destbranch
300 [ "$choice" = "lw" ] &&
301 git log
--patch --word-diff $curr_git_ver..
$destbranch
302 [ "$choice" = "n" ] && myexit
0
303 [ "$choice" = "p" ] && {
304 if test "$opt_no_net" = "0"; then
308 echo $progname: --no-net was specified
, will not push
>&2
311 [ "$choice" = "t" ] && commit_tree
$curr_git_ver..
$destbranch
315 until [ "$choice" = "y" ]; do
316 echo -n Press
\'y
\' to start the build
, or
\'n
\' to abort...
318 [ "$choice" = "n" ] && myexit
0
322 echo ================= git clean
=================
324 echo ================= Update all branches
=================
326 vername
=git.
$local_master.
`git describe --long --match 'v[12]*'`
327 dest
=$pref/varprg
/$vername
330 echo "Sorry, no new git(1) for you this time."
331 echo You’ll have to stick with
`git --version` for now.
336 if [ "$use_configure" = "1" ]; then
337 echo $progname: Creating .
/configure
339 echo ==== .
/configure
--prefix=$dest $configure_opts
340 .
/configure
--prefix=$dest $configure_opts
342 if [ "$make_doc" = "1" ]; then
344 inst_doc_str
="install-doc install-html"
349 if [ "$make_info" = "1" ]; then
351 inst_info_str
=install-info
356 unset make_doc_str make_info_str inst_doc_str inst_info_str run_tests
357 echo Compiling
$vername
358 echo "==== make prefix=$dest $makeflags all" \
359 "$make_doc_str $make_info_str \|\| myexit"
360 make prefix
=$dest $makeflags all
$make_doc_str $make_info_str || myexit
361 if test "$run_tests" = "1"; then
362 echo ==== make $makeflags test
366 echo Ready to
install $
(.
/git
--version) from branch
\"$local_master\"
368 until test "$choice" = "y"; do
371 echo -n If all tests succeeded
, press y to
continue...
375 echo "==== $sudo make prefix=$dest" \
376 "$makeflags install $inst_doc_str $inst_info_str"
377 $sudo make prefix
=$dest $makeflags install $inst_doc_str $inst_info_str
378 echo ================= make install finished
=================