summaryrefslogtreecommitdiffstats
path: root/third_party/heimdal/import-lorikeet.sh
blob: 45a5888f721bb7ca2605393ba3e03f86132eb839 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
#
# Usage copy import-lorikeet.sh and rebase-lorikeet.sh
# into an empty directory maybe call it update-heimdal
# and don't use it for any other work than importing lorikeet heimdal
# into samba.
#
# You need to pass the name of the lorikeet branch
# within the heimdal/ repository as first argument.
#
# You can pass skip_fetch=yes, skip_create=yes, skip_build=yes, skip_test=yes
# as env vars
#

DATE=`date --utc +%Y%m%d%H%M`

lorikeet_branch="$1"
tmp_samba_branch="import-lorikeet-tmp"
new_samba_branch="import-${lorikeet_branch}"
samba_master_branch="$2"
test -n "$samba_master_branch" || {
    samba_master_branch="origin/master"
}

export CC="ccache gcc"

bailout() {
	exit $1;
}

# 1. check if the heimdal repository created with rebase-lorikeet.sh already
# exist
heimdal_check() {
	test -d heimdal || {
		ls heimdal/
		bailout 255
	}

	test -n "$lorikeet_branch" || {
		echo "usage: $0 <lorikeet-branch> [<samba-branch>]"
		bailout 1
	}

	return 0;
}

# 2. initialize the samba repository in the samba subdir
samba_init() {
	test -d samba || {
		mkdir samba || bailout $?
		pushd samba
		git init || bailout $?
		git remote add origin https://git.samba.org/samba.git
		git remote add local-heimdal ../heimdal
		popd
	}

	return 0;
}

# 3. bring the repository uptodate
samba_fetch() {
	test x"$skip_fetch" = x"yes" || {
		pushd samba
		git fetch origin || bailout $?
		git fetch local-heimdal || bailout $?
		popd
	}

	return 0;
}

#
# It would be good if you have a lex:yacc combination which can rebuild this
# files...
#

build_samba() {
	test x"$skip_build" = x"yes" || {
		./configure.developer || return $?
		make -j || return $?
		test x"$skip_test" = x"yes" || {
			TDB_NO_FSYNC=1 make -j test || return $?
		}
	}

	return 0;
}

samba_create() {
	test x"$skip_create" = x"yes" || {
		pushd samba
		lorikeet_commit=`git log -1 local-heimdal/$lorikeet_branch | head -1 | cut -d ' ' -f2`
		echo "local-heimdal/$lorikeet_branch => commit:$lorikeet_commit"
		echo "git update-ref"
		git update-ref refs/heads/$tmp_samba_branch $samba_master_branch || bailout $?
		echo "git checkout"
		git checkout $tmp_samba_branch || bailout $?
		echo "git reset --hard HEAD"
		git reset --hard HEAD
		echo "git clean -d -x -f"
		git clean -d -x -f
		echo "git read-tree..."
		git read-tree -u --prefix=third_party/heimdal-new/ local-heimdal/$lorikeet_branch || bailout $?
		echo "git reset --mixed HEAD"
		git reset --mixed HEAD
		echo "swap old -> new"
		mv third_party/heimdal third_party/heimdal-old || bailout $?
		rsync -a third_party/heimdal-new/ third_party/heimdal || bailout $?
	#	echo "PS1=\"'import-heimdal shell'>\"" > ../.bashrc.samba_create
	#	bash --rcfile ../.bashrc.samba_create
	#	bailout 255
		echo "add changed files to the index"
		git add -u third_party/heimdal
		echo "commit the changed files blindly"
		git commit --no-verify -m "third_party/heimdal: import $lorikeet_branch (commit $lorikeet_commit)"
		echo "cleanup third_party/heimdal"
		rm -rf third_party/heimdal
		git checkout third_party/heimdal
		echo "try to build samba"
		build_samba || {
			echo ""
			echo "Now build the tree and make it compile."
			echo "Missing files can be copied from third_party/heimdal-new/"
			echo "Also run make test!"
		}
		echo ""
		echo "Then do a 'git add third_party/heimdal' and a 'git commit --amend'"
		echo "and write a useful commit message..."
		echo "Then commit all needed changes outside of third_party/heimdal"
		echo "maybe splitted into multiple commits."
		echo ""
		echo "!!!!!!!!!"
		echo ""
		echo "if you this shell exit with 0, then $new_samba_branch will be created"
		echo ""
		echo "PS1=\"'import-heimdal shell'>\"" > ../.bashrc.samba_create
		bash --rcfile ../.bashrc.samba_create || bailout $?
		git branch $new_samba_branch $tmp_samba_branch || bailout $?
		echo "branch $new_samba_branch created"
		popd
	}

	return 0;
}

heimdal_check
samba_init

samba_fetch
samba_create