Don't redefine socket() if socket_wrapper is already in use
[abartlet/lorikeet-heimdal.git/.git] / rebase-lorikeet.sh
1 #!/bin/sh
2 #
3 # Usage copy import-lorikeet.sh and rebase-lorikeet.sh
4 # into an empty directory maybe call it update-heimdal
5 # and don't use it for any other work than importing lorikeet heimdal
6 # into samba.
7 #
8 # These parameter might be changed:
9 #
10 # heimdal_my_wip_name
11 # heimdal_my_wip_url
12 # old_lorikeet_branch
13 #
14 # you can pass skip_fetch=yes and/or skip_rebase=yes as env vars
15 #
16
17 # this needs to be reachable from
18 old_lorikeet_branch=$1
19
20 DATE=`date --utc +%Y%m%d%H%M`
21
22 heimdal_my_wip_name="heimdal-my-wip"
23 heimdal_my_wip_url="git://git.samba.org/metze/heimdal/wip.git"
24
25 if test x"$old_lorikeet_branch" = x""; then
26         old_lorikeet_branch="heimdal-metze-wip/lorikeet-heimdal"
27 fi
28
29 tmp_lorikeet_branch="lorikeet-heimdal-tmp"
30 new_lorikeet_branch="lorikeet-heimdal-${DATE}"
31
32 bailout() {
33         exit $1;
34 }
35
36 # 1. create a local heimdal repository in the heimdal subdir
37
38 heimdal_init() {
39         test -d heimdal || {
40                 mkdir heimdal || bailout $?
41                 pushd heimdal
42                 git init || bailout $?
43                 git remote add heimdal-svnmirror git://git.samba.org/metze/heimdal/svnmirror.git
44                 git remote add heimdal-metze-wip git://git.samba.org/metze/heimdal/wip.git
45                 git remote add ${heimdal_my_wip_name} ${heimdal_my_wip_url}
46                 popd
47         }
48
49         return 0;
50 }
51
52 # 2. bring the repository uptodate
53 heimdal_fetch() {
54         test x"$skip_fetch" = x"yes" || {
55                 pushd heimdal
56                 git fetch heimdal-svnmirror || bailout $?
57                 git fetch heimdal-metze-wip || bailout $?
58                 git fetch ${heimdal_my_wip_name} || bailout $?
59                 popd
60         }
61
62         return 0;
63 }
64
65 # 3. rebase the old_lorikeet_branch on top of heimdals trunk
66 heimdal_rebase() {
67         test x"$skip_rebase" = x"yes" || {
68                 pushd heimdal
69                 echo "git update-ref"
70                 git update-ref refs/heads/$tmp_lorikeet_branch $old_lorikeet_branch || bailout $?
71                 echo "git checkout"
72                 git checkout $tmp_lorikeet_branch || bailout $?
73                 echo "git reset --hard HEAD"
74                 git reset --hard HEAD
75                 echo "git rebase"
76                 git rebase heimdal-svnmirror/trunk || {
77                         echo "PS1=\"'git-rebase shell'>\"" > ../.bashrc.heimdal_rebase
78                         bash --rcfile ../.bashrc.heimdal_rebase || {
79                                 ret=$?
80                                 echo "git rebase --abort (just in case)"
81                                 git rebase --abort
82                                 bailout $ret
83                         }
84                 }
85                 echo "git rebase --abort (just in case)"
86                 git rebase --abort
87                 echo "Now build and test the lorikeet heimdal tree"
88                 echo "and exit with 0 if you want to create a $new_lorikeet_branch branch"
89                 echo ""
90                 echo "PS1=\"'build shell'>\"" > ../.bashrc.heimdal_build
91                 bash --rcfile ../.bashrc.heimdal_build || bailout $?
92                 git branch $new_lorikeet_branch $tmp_lorikeet_branch || bailout $?
93                 echo "branch $new_lorikeet_branch created"
94                 popd
95         }
96
97         return 0;
98 }
99
100 heimdal_init
101 heimdal_fetch
102 heimdal_rebase