-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-base
executable file
·280 lines (274 loc) · 5.77 KB
/
make-base
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#!/bin/sh
LANG="C"
export LANG
ARCH=`make -V MACHINE_ARCH`
#HOST=`hostname -s`
HOST=`hostname -s`"-${ARCH}"
target="${1}"
shift
setup_jail5() {
D="${1}"
if test ! -f "${D}/etc/rc.conf"
then
echo "$D"
make distribution "DESTDIR=$D"
( cd "${D}"
ln -sf dev/null kernel )
touch "$D/etc/fstab"
cp -pi /etc/localtime "$D/etc/localtime"
mkdir -p "$D/root/.ssh"
cp -pi /root/.ssh/authorized_keys "$D/root/.ssh/authorized_keys"
cp -pi /root/jail.rc.conf "$D/etc/rc.conf"
touch "$D/etc/rc.conf"
mkdir "$D/usr/ports"
fi
}
setup_mail() {
D="${1}"
running=`jls -nq | grep "jid=.*${D}"`
if test "${running}" = ""
then
chroot "${D}" /bin/sh -c "cd /etc/mail && make"
chroot "${D}" /bin/sh -c "cd /etc/mail && make install"
else
jid="${running##*jid=}"
jid="${jid%% *}"
echo "${jid}"
echo \
jexec "${jid}" /bin/sh -c "cd /etc/mail && make"
jexec "${jid}" /bin/sh -c "cd /etc/mail && make"
echo \
jexec "${jid}" /bin/sh -c "cd /etc/mail && make install"
jexec "${jid}" /bin/sh -c "cd /etc/mail && make install"
fi
}
install_jail() {
D="${1}"
E="${D##*/}"
if test -L "${D}/usr/sbin/pkg"
then
rm -f "${D}/usr/sbin/pkg"
mv "${D}/usr/sbin/pkg.orig" "${D}/usr/sbin/pkg"
fi
make "DESTDIR=${D}" installworld >> "err-${HOST}-installjails-${E}" 2>&1 || exit 1
setup_jail5 "${D}"
make "DESTDIR=${D}" delete-old -DBATCH_DELETE_OLD_FILES
setup_mail "${D}"
echo "${target} ${D} ok"
}
case "${target}" in
update)
if test ! -d HISTORY
then
mkdir HISTORY
fi
mv -vf err* HISTORY/
if test -e .svn
then
if test -e /usr/local/bin/svn
then
svn up | tee "err-${HOST}-${target}" 2>&1 || exit 1
else
svnlite up | tee "err-${HOST}-${target}" 2>&1 || exit 1
fi
echo "${target} ok"
fi
if test -e .git
then
if test -e /usr/local/bin/git
then
git pull | tee "err-${HOST}-${target}" 2>&1 || exit 1
else
gitlite up | tee "err-${HOST}-${target}" 2>&1 || exit 1
fi
echo "${target} ok"
fi
;;
buildworld)
case "${1}" in
esac
make "${target}" "${@}" >> "err-${HOST}-${target}" 2>&1 || exit 1
echo "${target} ok"
;;
buildkernel)
listfile="kernels-${HOST}.txt"
if test -f "${listfile}"
then
for KERNCONF in `grep -v "^#" "${listfile}"`
do
echo "${target} ${KERNCONF}"
make "${target}" "KERNCONF=${KERNCONF}" "${@}" >> "err-${HOST}-${target}-${KERNCONF}" 2>&1 || exit 1
echo "${target} ok"
done
exit
fi
KERNCONF=`make -V KERNCONF`
if test "${KERNCONF}" = ""
then
KERNCONF="GENERIC"
fi
make "${target}" "KERNCONF=${KERNCONF}" "${@}" >> "err-${HOST}-${target}-${KERNCONF}" 2>&1 || exit 1
echo "${target} ok"
;;
build)
${0} buildworld "${@}" || exit 1
${0} buildkernel "${@}" || exit 1
;;
installkernel)
df -k /boot/ | tail -1 |
while read mdef mblock mused mfree mdir
do
if test "${mfree}" -lt "380000"
then
rm -f /boot/kernel/*.symbols
fi
done
KERNCONF=`make -V KERNCONF`
if test "${KERNCONF}" = ""
then
KERNCONF="GENERIC"
fi
make "${target}" "${@}" >> "err-${HOST}-${target}-${KERNCONF}" 2>&1 || exit 1
echo "${target} ok"
listfile="pxe-${HOST}.txt"
if test ! -f "${listfile}"
then
exit 0
fi
KERNCONF="GENERIC"
for D in `grep -v "^#" "${listfile}"`
do
echo "${D}"
E="${D##*/}"
make DESTDIR="${D}" KERNCONF="${KERNCONF}" "${target}" "${@}" >> "err-${HOST}-${target}-${E}-${KERNCONF}" 2>&1 || exit 1
done
echo "${target} ${D} ok"
;;
installworld)
make "${target}" "${@}" >> "err-${HOST}-${target}" 2>&1 || exit 1
echo "${target} ok"
make delete-old -DBATCH_DELETE_OLD_FILES "${@}"
( cd /etc/mail && make )
( cd /etc/mail && make install )
;;
install)
${0} installkernel "${@}" || exit 1
${0} installworld "${@}" || exit 1
;;
installjails)
case "${1}" in
*/*)
install_jail "${@}"
exit 0
;;
esac
listfile="jails-${HOST}.txt"
if test ! -f "${listfile}"
then
echo "${target}: File ${listfile} not found."
exit 0
fi
for D in `grep -v "^#" "${listfile}"`
do
echo "${D}"
install_jail "${D}" "${@}"
done
echo "${target} ok"
;;
installworlds)
${0} installworld "${@}" || exit 1
${0} installjails "${@}" || exit 1
;;
installall)
${0} installkernel "${@}" || exit 1
${0} installworld "${@}" || exit 1
${0} installjails "${@}" || exit 1
;;
mergemaster)
# etcupdate
mergemaster -U -F -i "${@}"
while test $# -gt 0
do
case "${1}" in
-D)
;;
*/*)
setup_mail "${@}"
;;
esac
shift
done
;;
mergemasterjails)
case "${1}" in
*/*)
${0} mergemaster -D "${@}" || exit 1
exit 0
;;
esac
listfile="jails-${HOST}.txt"
if test ! -f "${listfile}"
then
echo "${target}: File ${listfile} not found."
exit 0
fi
for D in `grep -v "^#" "${listfile}"`
do
echo "${D}"
${0} mergemaster -D "${D}" "${@}" || exit 1
done
echo "${target} ok"
;;
mergemasterall)
${0} mergemaster "${@}" || exit 1
${0} mergemasterjails "${@}" || exit 1
;;
delete-old-libs)
make delete-old -DBATCH_DELETE_OLD_FILES "${@}"
make delete-old-libs -DBATCH_DELETE_OLD_FILES "${@}"
if test -e "jails-${HOST}.libs"
then
listfile="jails-${HOST}.libs"
else
listfile="jails-${HOST}.txt"
fi
if test ! -f "${listfile}"
then
exit 0
fi
for D in `grep -v "^#" "${listfile}"`
do
echo "${D}"
make "DESTDIR=${D}" delete-old -DBATCH_DELETE_OLD_FILES "${@}"
make "DESTDIR=${D}" delete-old-libs -DBATCH_DELETE_OLD_FILES "${@}"
done
;;
diff)
for i in HISTORY/err-*
do
if ! test -f "${i}"
then
continue
fi
j="${i##*/}"
if test -f "${j}"
then
continue
fi
echo "Only in HISTORY: ${j}"
done
;;
ver*)
egrep '^(REVISION|BRANCH)' sys/conf/newvers.sh
;;
*)
echo "${0##*/} [ update | buildworld | buildkernel | build ]" >&2
echo "${0##*/} [ installkernel | installworld | install ]" >&2
echo "${0##*/} [ installjails | installworlds | installall ]" >&2
echo "${0##*/} [ mergemaster | mergemasterjails | mergemasterall ]" >&2
echo "${0##*/} [ delete-old-libs | version ]" >&2
exit 64
;;
esac
exit 0
# eof