blob: 05ec7d0165a96e9fdb2874920c573f26b94a5525 (
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
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
|
#!/bin/sh
# load global variables
# shellcheck disable=SC2034
set -e
export LANG=C
if [ "$(hostname)" = 'buildmaster.archlinux32.org' ]; then
i_am_the_master=true
# abort early if mysqld is not running or kill switch active
# ('/tmp/do-not-run-build-master')
if [ ! -S '/var/run/mysqld/mysqld.sock' ] || \
[ -f '/tmp/do-not-run-build-master' ]; then
>&2 echo 'mysqld is not running or build master is on halt'
>&2 echo 'I will abort - whatever you try to do would probably fail anyway.'
# When the buildmaster is on halt,
# - systemd MUST NOT hickup - e.g. exit code 0,
# - connecting slaves MUST get exit code 1 and
# - interactively run commands SHOULD get exit code 1, too
if tty -s && [ -z "${SSH_ORIGINAL_COMMAND}" ]; then
exit 1
else
exit 0
fi
fi
else
i_am_the_master=false
fi
# dirty hack to get this stuff debugable from a bash
if [ "x${0##*/}" = "x-bash" ] || [ "x${0##*/}" = "xbash" ] || [ "x${0##*/}" = "xdash" ]; then
set +e
if [ -z "${base_dir}" ]; then
base_dir=$(pwd)
fi
fi
if [ -z "${base_dir}" ]; then
base_dir=$(printf '%s/..' "$(dirname "$(readlink -f "$0")")")
fi
base_dir=$(
readlink -e "${base_dir}"
)
work_dir="${base_dir}/work"
# shellcheck source=../lib/common-functions
. "${base_dir}/lib/common-functions"
# if mysqld is not running, we're either on a build slave and don't need
# lib/mysql-functions or we're on the build master and something is wrong
# anyway
if pgrep -x mysqld >/dev/null 2>&1; then
# shellcheck source=../lib/mysql-functions
. "${base_dir}/lib/mysql-functions"
fi
if ${i_am_the_master}; then
releng_directory="${work_dir}/repos/releng"
else
repo_names='packages community archlinux32'
repo_paths__packages="${work_dir}/repos/packages"
repo_paths__community="${work_dir}/repos/community"
repo_paths__archlinux32="${work_dir}/repos/packages32"
fi
master_build_server="buildmaster.archlinux32.org"
master_build_server_port="22"
master_build_server_user="master"
master_build_server_identity="${work_dir}/.ssh/id_rsa"
repo_key='0xdeadbeef'
package_key='0x15eebadc0de'
# to access the master mirror via rsync
master_mirror_rsync_command='rsync --password-file=/home/master/rsync.password -l'
master_mirror_rsync_directory='rsync://buildmaster@mirror.archlinux32.org/packages32'
# to access the master mirror via sftp
master_mirror_sftp_command='sftp -b- user@mirror'
# mirror of sources, identified (solely) by hash
source_by_hash_mirror='https://sources.archlinux32.org/'
# what should be tried in what order to somehow repair a broken build
straws_that_might_repair_failing_builds=$(
printf '%s\n' \
':mirrored_source:mirrored_source_by_hash:' \
':clean_chroot:haskell_without_check:' \
':with_build_support:' \
':with_build_support:clean_chroot:'
)
# root directory of the webserver
webserver_directory='/srv/http'
# directory to keep the build log files in
build_log_directory='/srv/http/build-logs'
# irc client configuration
irc_dir='/home/master/irc/irc.freenode.net'
irc_password='top_secret'
# commands to run to update the package mirror used for installing archlinux32 packages,
# e.g. the one from /etc/pacman.d/mirrorlist32 (useful on build slaves which do not
# have the master mirror in the mirrorlist32)
mirror_update_command=''
# list of urls to trigger updates of the respective mirrors (used on build master only)
mirror_refresh_trigger_urls=''
# command to access the mysql database
mysql_command='mysql buildmaster'
# how long should packages be in [community-testing]/[testing] before
# automatically being marked as tested
max_testing_duration="14"
# set default location of archbuild chroots
archbuild_chroots='/var/lib/archbuild'
# possibly pull in custom modifications
if [ -r "${base_dir}/conf/common.conf" ]; then
# shellcheck source=/dev/null
. "${base_dir}/conf/common.conf"
fi
if ${i_am_the_master} && \
[ -r "${base_dir}/conf/master.conf" ]; then
# shellcheck source=/dev/null
. "${base_dir}/conf/master.conf"
fi
if ! ${i_am_the_master} && \
[ -r "${base_dir}/conf/slave.conf" ]; then
# shellcheck source=../conf/slave.conf.example
. "${base_dir}/conf/slave.conf"
fi
# load static values from the database
if ${i_am_the_master}; then
mysql_retrieve_static_information
fi
# check / set up environment
if [ -z "${build_list_lock_file}" ]; then
build_list_lock_file="${work_dir}/build-list.lock"
fi
if [ -z "${harvest_commit_times_lock_file}" ]; then
harvest_commit_times_lock_file="${work_dir}/harvest-commit-times.lock"
fi
if [ -z "${package_database_lock_file}" ]; then
package_database_lock_file="${work_dir}/package-database.lock"
fi
if [ -z "${sanity_check_lock_file}" ]; then
sanity_check_lock_file="${work_dir}/sanity-check.lock"
fi
if [ -z "${status_lock_file}" ]; then
status_lock_file="${work_dir}/status.lock"
fi
mkdir -p "${work_dir}"
for repo in ${repo_names} 'releng'; do
if [ "${repo}" = 'releng' ]; then
if [ -z "${releng_directory}" ]; then
continue
fi
repo_path="${releng_directory}"
else
eval repo_path='"${repo_paths__'"${repo}"'}"'
fi
mkdir -p "${repo_path%/*}"
if ! git -C "${repo_path}" rev-parse --git-dir > /dev/null 2>&1; then
case "${repo}" in
'archlinux32')
repo_source='https://git.archlinux32.org/archlinux32/packages.git'
;;
'releng')
repo_source='git@git.archlinux32.org:archlinux32/releng.git'
;;
*)
repo_source="git://git.archlinux.org/svntogit/${repo}.git"
;;
esac
git clone --mirror "${repo_source}" "${repo_path}"
fi
done
if [ "${master_build_server_identity}" = "${work_dir}/.ssh/id_rsa" ] && \
[ ! -f "${master_build_server_identity}" ]; then
mkdir -p "${master_build_server_identity%/*}"
ssh-keygen -b4096 -f "${master_build_server_identity}"
fi
if ${i_am_the_master}; then
command="${0##*/}"
# these commands are useless to log
if [ "${command}" != 'ii-answer' ] && \
[ "${command}" != 'slave-build-connect' ] && \
[ "${SKIP_COMMAND_LOG}" != 1 ]; then
# shellcheck disable=SC2016
{
printf 'INSERT INTO `command_log`(`command`,`parameters`,`shell`)'
printf ' VALUES ('
printf 'from_base64("%s"),' \
"$(
printf '%s' "${command}" | \
base64
)"
printf 'from_base64("%s"),' \
"$(
printf '%s' "$*" | \
head -c $((64*1024-1)) | \
base64
)"
if tty -s; then
printf '1'
else
printf '0'
fi
printf ');\n'
} | \
mysql_run_query 'unimportant'
fi
export SKIP_COMMAND_LOG=''
fi
|