HEIMDAL: move code from source4/heimdal* to third_party/heimdal*
[Samba.git] / third_party / heimdal / import-lorikeet.sh
blob6d36ced6c3fd8a82dc6240627b68b641e907728a
1 #!/bin/bash
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.
8 # You need to pass the name of the lorikeet branch
9 # within the heimdal/ repository as first argument.
11 # You can pass skip_fetch=yes, skip_create=yes, skip_build=yes, skip_test=yes
12 # as env vars
15 DATE=`date --utc +%Y%m%d%H%M`
17 lorikeet_branch="$1"
18 tmp_samba_branch="import-lorikeet-tmp"
19 new_samba_branch="import-${lorikeet_branch}"
20 samba_master_branch="$2"
21 test -n "$samba_master_branch" || {
22 samba_master_branch="origin/master"
25 export CC="ccache gcc"
27 bailout() {
28 exit $1;
31 # 1. check if the heimdal repository created with rebase-lorikeet.sh already
32 # exist
33 heimdal_check() {
34 test -d heimdal || {
35 ls heimdal/
36 bailout 255
39 test -n "$lorikeet_branch" || {
40 echo "usage: $0 <lorikeet-branch> [<samba-branch>]"
41 bailout 1
44 return 0;
47 # 2. initialize the samba repository in the samba subdir
48 samba_init() {
49 test -d samba || {
50 mkdir samba || bailout $?
51 pushd samba
52 git init || bailout $?
53 git remote add origin https://git.samba.org/samba.git
54 git remote add local-heimdal ../heimdal
55 popd
58 return 0;
61 # 3. bring the repository uptodate
62 samba_fetch() {
63 test x"$skip_fetch" = x"yes" || {
64 pushd samba
65 git fetch origin || bailout $?
66 git fetch local-heimdal || bailout $?
67 popd
70 return 0;
74 # It would be good if you have a lex:yacc combination which can rebuild this
75 # files...
78 build_samba() {
79 test x"$skip_build" = x"yes" || {
80 ./configure.developer || return $?
81 make -j || return $?
82 test x"$skip_test" = x"yes" || {
83 TDB_NO_FSYNC=1 make -j test || return $?
87 return 0;
90 samba_create() {
91 test x"$skip_create" = x"yes" || {
92 pushd samba
93 lorikeet_commit=`git log -1 local-heimdal/$lorikeet_branch | head -1 | cut -d ' ' -f2`
94 echo "local-heimdal/$lorikeet_branch => commit:$lorikeet_commit"
95 echo "git update-ref"
96 git update-ref refs/heads/$tmp_samba_branch $samba_master_branch || bailout $?
97 echo "git checkout"
98 git checkout $tmp_samba_branch || bailout $?
99 echo "git reset --hard HEAD"
100 git reset --hard HEAD
101 echo "git clean -d -x -f"
102 git clean -d -x -f
103 echo "git read-tree..."
104 git read-tree -u --prefix=source4/heimdal-new/ local-heimdal/$lorikeet_branch || bailout $?
105 echo "git reset --mixed HEAD"
106 git reset --mixed HEAD
107 echo "swap old -> new"
108 mv source4/heimdal source4/heimdal-old || bailout $?
109 rsync -a source4/heimdal-new/ source4/heimdal || bailout $?
110 # echo "PS1=\"'import-heimdal shell'>\"" > ../.bashrc.samba_create
111 # bash --rcfile ../.bashrc.samba_create
112 # bailout 255
113 echo "add changed files to the index"
114 git add -u source4/heimdal
115 echo "commit the changed files blindly"
116 git commit --no-verify -m "s4:heimdal: import $lorikeet_branch (commit $lorikeet_commit)"
117 echo "cleanup source4/heimdal"
118 rm -rf source4/heimdal
119 git checkout source4/heimdal
120 echo "try to build samba"
121 build_samba || {
122 echo ""
123 echo "Now build the tree and make it compile."
124 echo "Missing files can be copied from source4/heimdal-new/"
125 echo "Also run make test!"
127 echo ""
128 echo "Then do a 'git add source4/heimdal' and a 'git commit --amend'"
129 echo "and write a useful commit message..."
130 echo "Then commit all needed changes outside of source4/heimdal"
131 echo "maybe splitted into multiple commits."
132 echo ""
133 echo "!!!!!!!!!"
134 echo ""
135 echo "if you this shell exit with 0, then $new_samba_branch will be created"
136 echo ""
137 echo "PS1=\"'import-heimdal shell'>\"" > ../.bashrc.samba_create
138 bash --rcfile ../.bashrc.samba_create || bailout $?
139 git branch $new_samba_branch $tmp_samba_branch || bailout $?
140 echo "branch $new_samba_branch created"
141 popd
144 return 0;
147 heimdal_check
148 samba_init
150 samba_fetch
151 samba_create