]> git.samba.org - rsync.git/blob - packaging/prep-auto-dir
Even more man page improvements.
[rsync.git] / packaging / prep-auto-dir
1 #!/bin/sh -e
2
3 # This script will setup the build dir based on the current git branch and the
4 # directory auto-build-save/$BRANCH.  We don't use a symlink for the build dir
5 # because we want to maximize the ccache reuse, so all builds must happen in
6 # the same real dir.  When a dir is moved out of auto-build-save/$BRANCH to the
7 # build dir, it is replaced with a symlink so that it can still be found under
8 # that dir.  The build dir also gets a .branch -> $BRANCH symlink so that we
9 # can figure out the current build dir's branch.
10
11 # To get started, just clone the rsync git repo and create the auto-build-save
12 # dir.  If you have an existing git checkout and it is not in a pristine state,
13 # run "make distclean" before creating the auto-build-save dir.
14
15 auto_top='auto-build-save'
16 if test -d $auto_top && test -d .git; then
17     desired_branch=`git rev-parse --abbrev-ref HEAD | tr / %`
18     if test "$desired_branch" = HEAD; then
19         echo "ERROR: switch to the right build dir manually when in detached HEAD mode." 1>&2
20         exit 1
21     fi
22     auto_dir="$auto_top/$desired_branch"
23     if test -d build; then
24         cur_branch=`readlink build/.branch`
25     else
26         cur_branch='/'
27     fi
28     if test "$desired_branch" != "$cur_branch"; then
29         if test "$cur_branch" != /; then
30             rm -f "$auto_top/$cur_branch"
31             mv build "$auto_top/$cur_branch"
32         fi
33         test -d "$auto_dir" || mkdir "$auto_dir"
34         test -h "$auto_dir/.branch" || ln -s "$desired_branch" "$auto_dir/.branch"
35         mv "$auto_dir" build
36         ln -s ../build "$auto_dir"
37     fi
38     if test ! -h Makefile; then
39         rm -f Makefile
40         ln -s packaging/auto-Makefile Makefile
41     fi
42     echo $desired_branch
43 fi