-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrebuild-full.sh
executable file
·222 lines (184 loc) · 5.79 KB
/
rebuild-full.sh
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
#!/bin/sh
pgm="${0##*/}" # Program basename
progdir="${0%/*}" # Program directory
progdir=$( realpath ${progdir} )
export PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
### SET version in /root/myb-build/ports/myb/Makefile
### + /root/myb-build/skel/usr/local/etc/mybee/version
# Brand, used in sysinstall/bsdconfig...
#export OSNAME="home.olevole.ru"
#export OSNAME="mother.olevole.ru"
#export OSNAME="FreeBSD"
export OSNAME="MyBee"
#export OSNAME="ClonOS"
cd /
OS=$( uname -s )
echo "Platform: ${OS}"
# Init CMD Macros
UNAME_CMD=$( which uname )
if [ ! -x "${UNAME_CMD}" ]; then
echo "error: no such command: uname"
exit 1
fi
TR_CMD=$( which tr )
if [ ! -x "${TR_CMD}" ]; then
echo "error: no such command: tr"
exit 1
fi
TRUNCATE_CMD=$( which truncate )
if [ ! -x "${TRUNCATE_CMD}" ]; then
echo "error: no such command: truncate"
exit 1
fi
CAT_CMD=$( which cat )
if [ ! -x "${CAT_CMD}" ]; then
echo "error: no such command: cat"
exit 1
fi
SORT_CMD=$( which sort )
if [ ! -x "${SORT_CMD}" ]; then
echo "error: no such command: sort"
exit 1
fi
if [ -r "${progdir}/cmd.${OS}.conf" ]; then
. ${progdir}/cmd.${OS}.conf
else
. ${progdir}/cmd.conf
fi
if [ "${USE_TOR}" = "YES" ]; then
MAIN_CMD="${MAIN_CMD} nc"
fi
${TRUNCATE_CMD} -s0 ${progdir}/cmd.subr
${CAT_CMD} > ${progdir}/cmd.subr <<EOF
if [ ! "\$_CBSD_CMD_SUBR" ]; then
_CBSD_CMD_SUBR=1
###
EOF
MAIN_CMD=$( echo ${MAIN_CMD} | ${SORT_CMD} )
OPTIONAL_CMD=$( echo ${OPTIONAL_CMD} | ${SORT_CMD} )
for i in ${MAIN_CMD}; do
mycmd=
mycmd=$( which ${i} || true ) # true for 'set -e' case
if [ ! -x "${mycmd}" ]; then
echo "${pgm} error: no such executable dependency/requirement: ${i}"
${CAT_CMD} >> ${progdir}/cmd.subr <<EOF
###
fi
EOF
exit 1
fi
MY_CMD=$( echo ${i} | ${TR_CMD} '\-[:lower:]' '_[:upper:]' )
MY_CMD="${MY_CMD}_CMD"
eval "${MY_CMD}=\"${mycmd}\""
echo "${MY_CMD}=\"${mycmd}\"" >> ${progdir}/cmd.subr
done
${CAT_CMD} >> ${progdir}/cmd.subr <<EOF
###
fi
EOF
set -e
. ${progdir}/cmd.subr
. ${progdir}/system.subr
set +e
FULL_ST_TIME=$( ${DATE_CMD} +%s )
#### PREPARE
if [ 3 -gt 2 ]; then
if [ -r "${progdir}/rebuild-prepare.${OS}.subr" ]; then
. ${progdir}/rebuild-prepare.${OS}.subr
else
. ${progdir}/rebuild-prepare.subr
fi
fi
# !!!
# not for half:
set -o errexit
if [ 3 -gt 2 ]; then
if [ -r "${progdir}/rebuild-buildenv.${OS}.subr" ]; then
. ${progdir}/rebuild-buildenv.${OS}.subr
else
. ${progdir}/rebuild-buildenv.subr
fi
fi
### HALF-build
#fi
# half build
#fi
# jail
st_time=$( ${DATE_CMD} +%s )
/root/myb-build/ci/40_jail.sh
time_stats "${N1_COLOR}jail done"
end_time=$( ${DATE_CMD} +%s )
diff_time=$(( end_time - st_time ))
put_prometheus_file_metrics "rebuild-full" "jail" ${diff_time}
exit 0
# export-micro
st_time=$( ${DATE_CMD} +%s )
/root/myb-build/ci/44_export-micro.sh
time_stats "${N1_COLOR}export micro jail done"
end_time=$( ${DATE_CMD} +%s )
diff_time=$(( end_time - st_time ))
put_prometheus_file_metrics "rebuild-full" "exportmicrojail" ${diff_time}
# purgejail
st_time=$( ${DATE_CMD} +%s )
/root/myb-build/ci/50_purgejail.sh
time_stats "${N1_COLOR}purgejail done"
end_time=$( ${DATE_CMD} +%s )
diff_time=$(( end_time - st_time ))
put_prometheus_file_metrics "rebuild-full" "purgejail" ${diff_time}
# purge_distribution
st_time=$( ${DATE_CMD} +%s )
/root/myb-build/ci/55_purge_distribution.sh
time_stats "${N1_COLOR}purge_distribution done"
end_time=$( ${DATE_CMD} +%s )
diff_time=$(( end_time - st_time ))
put_prometheus_file_metrics "rebuild-full" "purgedistribution" ${diff_time}
# purge_distribution-base
st_time=$( ${DATE_CMD} +%s )
/root/myb-build/ci/60_distribution-base.sh
time_stats "${N1_COLOR}purge_distribution_base done"
end_time=$( ${DATE_CMD} +%s )
diff_time=$(( end_time - st_time ))
put_prometheus_file_metrics "rebuild-full" "purge_distribution_base" ${diff_time}
# distribution-pkg
st_time=$( ${DATE_CMD} +%s )
/root/myb-build/ci/60_distribution-pkg.sh
time_stats "${N1_COLOR}distribution_pkg done"
end_time=$( ${DATE_CMD} +%s )
diff_time=$(( end_time - st_time ))
put_prometheus_file_metrics "rebuild-full" "distribution_pkg" ${diff_time}
# manifests
st_time=$( ${DATE_CMD} +%s )
/root/myb-build/ci/70_manifests.sh
time_stats "${N1_COLOR}manifests done"
end_time=$( ${DATE_CMD} +%s )
diff_time=$(( end_time - st_time ))
put_prometheus_file_metrics "rebuild-full" "manifests" ${diff_time}
# conv
st_time=$( ${DATE_CMD} +%s )
/root/myb-build/ci/90_conv.sh
time_stats "${N1_COLOR}conv done"
end_time=$( ${DATE_CMD} +%s )
diff_time=$(( end_time - st_time ))
put_prometheus_file_metrics "rebuild-full" "conv" ${diff_time}
# updaterepo
st_time=$( ${DATE_CMD} +%s )
/root/myb-build/ci/95_updaterepo.sh
time_stats "${N1_COLOR}updaterepo done"
end_time=$( ${DATE_CMD} +%s )
diff_time=$(( end_time - st_time ))
put_prometheus_file_metrics "rebuild-full" "updaterepo" ${diff_time}
set +o errexit
full_diff_time=$(( full_end_time - full_st_time ))
chmod 0644 /tmp/mybee1-14.1_amd64.img
chmod 0644 /usr/jails/jails-data/mybee1-data/usr/freebsd-dist/*
echo "----------------------------------"
echo "scp /tmp/mybee1-14.1_amd64.img [email protected]:mybee1-14.1_amd64.img"
echo
echo "cd /usr/jails/jails-data/mybee1-data/usr/freebsd-dist"
echo "sftp -oPort=222 [email protected] -> /usr/local/www/myb.convectix.com/"
echo "or"
echo "scp -oPort=222 /usr/jails/jails-data/mybee1-data/usr/freebsd-dist/MANIFEST [email protected]:/usr/local/www/myb.convectix.com/"
echo "scp -oPort=222 /usr/jails/jails-data/mybee1-data/usr/freebsd-dist/base.txz [email protected]:/usr/local/www/myb.convectix.com/"
echo "scp -oPort=222 /usr/jails/jails-data/mybee1-data/usr/freebsd-dist/cbsd.txz [email protected]:/usr/local/www/myb.convectix.com/"
echo "scp -oPort=222 /usr/jails/jails-data/mybee1-data/usr/freebsd-dist/kernel.txz [email protected]:/usr/local/www/myb.convectix.com/"
echo