99
98
my %buildd_keys = (
101
VARNAME => 'admin_mail',
104
HELP => 'email address for admin'
108
VARNAME => 'apt_get',
104
110
CHECK => $validate_program,
107
'AUTOCLEAN_INTERVAL' => {
111
DEFAULT => 'apt-get',
112
HELP => 'Path to apt-get binary'
110
114
'BUILD_LOG_KEEP' => {
113
'BUILD_LOG_REGEX' => {
116
VARNAME => 'build_log_keep',
119
HELP => 'Number of days until build logs are archived'
116
121
'DAEMON_LOG_FILE' => {
117
DEFAULT => "$HOME/daemon.log"
123
VARNAME => 'daemon_log_file',
125
DEFAULT => "$HOME/daemon.log",
126
HELP => 'Main buildd daemon log file'
119
128
'DAEMON_LOG_KEEP' => {
130
VARNAME => 'daemon_log_keep',
133
HELP => 'Number of days until old daemon logs are archived in a .tar.gz file'
122
135
'DAEMON_LOG_ROTATE' => {
137
VARNAME => 'daemon_log_rotate',
140
HELP => 'Number how many days until daemon logs are rotated (one is kept as daemon.log.old, others are moved to old-logs and gzipped)'
125
142
'DAEMON_LOG_SEND' => {
144
VARNAME => 'daemon_log_send',
147
HELP => 'email rotated daemon logs to the admin?'
128
149
'DELAY_AFTER_GIVE_BACK' => {
129
DEFAULT => 8 * 60 # 8 hours
151
VARNAME => 'delay_after_give_back',
153
DEFAULT => 8 * 60, # 8 hours
154
HELP => 'Time to avoid packages that have automatically been given back by sbuild (in minutes)'
131
156
'ERROR_MAIL_WINDOW' => {
158
VARNAME => 'error_mail_window',
161
HELP => 'If more than five error mails are received within the specified time (in seconds), do not forward (to avoid possible mail loops)'
134
163
'IDLE_SLEEP_TIME' => {
165
VARNAME => 'idle_sleep_time',
168
HELP => 'Time to sleep when idle (in seconds) between wanna-build --list=needs-build calls)'
137
170
'LOG_QUEUED_MESSAGES' => {
172
VARNAME => 'log_queued_messages',
175
HELP => 'Log success messages from upload queue daemon?'
140
177
'MIN_FREE_SPACE' => {
179
VARNAME => 'min_free_space',
182
HELP => 'Minimum free space (in KiB) on build filesystem'
143
184
'NICE_LEVEL' => {
186
VARNAME => 'nice_level',
187
GROUP => 'Build options',
189
HELP => 'Nice level to run sbuild. Dedicated build daemons should not be niced.'
193
VARNAME => 'no_detach',
196
HELP => 'Disable becoming a daemon, for debugging purposes. Set to 1 to stop daemonising, otherwise set to 0 to become a daemon.'
149
198
'NO_WARN_PATTERN' => {
150
DEFAULT => '^build/(SKIP|REDO|SBUILD-GIVEN-BACK|buildd\.pid|[^/]*.ssh|chroot-[^/]*|current-[^/]*)$'
200
VARNAME => 'no_warn_pattern',
202
DEFAULT => '^build/(SKIP|REDO|SBUILD-GIVEN-BACK|buildd\.pid|[^/]*.ssh|chroot-[^/]*|current-[^/]*)$',
203
HELP => 'Don\'t complain about old files if they match the regexp.'
207
VARNAME => 'pidfile',
153
209
# Set once running as a system service.
154
210
# DEFAULT => "${Sbuild::Sysconfig::paths{'LOCALSTATEDIR'}/run/buildd.pid"
155
DEFAULT => "$HOME/build/buildd.pid"
211
DEFAULT => "$HOME/build/buildd.pid",
212
HELP => 'PID file to identify running daemon.'
157
214
'PKG_LOG_KEEP' => {
160
'SECONDARY_DAEMON_THRESHOLD' => {
216
VARNAME => 'pkg_log_keep',
219
HELP => 'Number of days until to package logs are archived'
163
221
'SHOULD_BUILD_MSGS' => {
223
VARNAME => 'should_build_msgs',
226
HELP => 'Should buildd send "Should I build" messages?'
166
228
'STATISTICS_MAIL' => {
230
VARNAME => 'statistics_mail',
233
HELP => 'email address for statistics summaries'
169
235
'STATISTICS_PERIOD' => {
237
VARNAME => 'statistics_period',
240
HELP => 'Period for statistic summaries (days)'
173
246
CHECK => $validate_program,
248
HELP => 'Path to sudo binary'
176
250
'WARNING_AGE' => {
252
VARNAME => 'warning_age',
255
HELP => 'Age (in days) after which a warning is issued for files in upload and dirs in build'
179
257
'CONFIG_TIME' => {
259
VARNAME => 'config_time',
260
GROUP => '__INTERNAL',
262
HELP => 'Time configuration was last read'
182
264
'DISTRIBUTIONS' => {
265
TYPE => 'ARRAY:HASH:SCALAR',
266
VARNAME => 'distributions',
267
GROUP => 'Build options',
269
IGNORE_DEFAULT => 1, # Don't dump class to config
270
HELP => 'List of distributions that buildd should take packages from',
274
# name of the suite to build (also used to query wanna-build)
275
dist_name => ["unstable", "testing"],
277
# architecture to be built (will be passed to sbuild and can be
278
# used to compute wanna_build_db_name
279
built_architecture => undef,
281
# host on which wanna-build is run
282
wanna_build_ssh_host => "buildd.debian.org",
284
# user as who we are going to connect to the host running wanna-build
285
wanna_build_ssh_user => "buildd_arch",
287
# SSH control socket path for ssh -S option
288
wanna_build_ssh_socket => "",
290
# Additional SSH options used when connecting
291
wanna_build_ssh_options => [],
293
# database used for wanna-build
294
wanna_build_db_name => "arch/build-db",
296
# Username to use for wanna-build.
297
wanna_build_db_user => $Buildd::username,
299
# Local queue directory where binaries are stored before uploaded
300
# by dupload. You need to configure this directory in
301
# @upload_queues to get packages uploaded from there.
302
dupload_local_queue_dir => "upload",
304
# list of packages which shouldn\'t be picked up by buildd
307
# list of packages which should only be taken if there absolutely
308
# nothing else to do (probably packages included in no_auto_build
309
# because they take too long)
310
weak_no_auto_build => [],
312
# regex used to filter out unwanted packages:
313
#no_build_regex => "^(contrib/|non-free/)?non-US/",
315
# regex used to filter packages to build:
318
# mail addr of buildd admin handling packages from this distribution
319
logs_mailed_to => $admin_mail,
321
# schroot name (or alias) of the chrooted environment to use for
322
# building (will be passed to sbuild). sbuild\'s default is
323
# the first of $distribution-$arch-sbuild, $distribution-sbuild,
324
# $distribution-$arch and $distribution.
325
sbuild_chroot => undef,
185
330
'UPLOAD_QUEUES' => {
331
TYPE => 'ARRAY:HASH:SCALAR',
332
VARNAME => 'upload_queues',
335
IGNORE_DEFAULT => 1, # Don't dump class to config
336
HELP => 'Package upload queues',
340
# Local queue directory where binaries are stored before uploaded
342
dupload_local_queue_dir => "upload",
344
# Upload site for buildd-upload to pass to dupload(1); see
345
# /etc/dupload.conf for possible values.
346
dupload_archive_name => "anonymous-ftp-master",
350
# Local queue directory where binaries are stored before uploaded
352
dupload_local_queue_dir => "upload-security",
354
# Upload site for buildd-upload to pass to dupload(1); see
355
# /etc/dupload.conf for possible values.
356
dupload_archive_name => "security",
190
361
$conf->set_allowed_keys(\%buildd_keys);
191
Sbuild::DB::ClientConf::setup($conf);
362
Buildd::ClientConf::setup($conf);
279
# Need to reread all config files, even if one is updated.
395
# For compatibility only. Non-scalars are deprecated.
396
my $deprecated_init = <<END;
397
# Variables are undefined, so config will default to DEFAULT if unset.
400
undef \@distributions;
402
undef \@upload_queues;
405
my \@weak_no_auto_build;
406
undef \@weak_no_auto_build;
407
my \$build_regex = undef; # Should this be user settable?
409
undef \@no_auto_build;
410
my \$no_build_regex = undef;
411
my \@take_from_dists;
412
undef \@take_from_dists;
414
my \$sshsocket = undef;
415
my \$wanna_build_user = undef;
416
my \$wanna_build_dbbase = undef;
419
my $deprecated_setup = '';
421
my $custom_setup = <<END;
422
if (\$sshcmd && \$sshcmd =~ /^\\s*(\\S+)\\s+(.+)/) {
424
\$conf->set('SSH', \$1);
426
#Try to pry the user out:
427
if (\$rest =~ /(-l\\s*(\\S+))\\s+/) {
428
\$wanna_build_ssh_user = \$2;
429
#purge this from the rest:
430
\$rest =~ s/\\Q\$1//;
431
} elsif (\$rest =~ /\\s+(\\S+)\@/) {
432
\$wanna_build_ssh_user = \$1;
433
\$rest =~ s/\\Q\$1\\E\@//;
436
#Hope that the last argument is the host:
437
if (\$rest =~ /\\s+(\\S+)\\s*\$/) {
438
\$wanna_build_ssh_host = \$1;
439
\$rest =~ s/\\Q\$1//;
442
#rest should be options:
443
if (\$rest !~ /\\s*/) {
444
\$wanna_build_ssh_options = [split \$rest];
449
\$wanna_build_ssh_socket = \$sshsocket;
452
if (\$wanna_build_user) {
453
\$wanna_build_db_user = \$wanna_build_user;
456
if (\$wanna_build_dbbase) {
457
\$wanna_build_db_name = \$wanna_build_dbbase;
460
#Convert old config, if needed:
461
my \@distributions_info;
462
if (\@take_from_dists) {
463
for my \$dist (\@take_from_dists) {
466
\$entry{DIST_NAME} = \$dist;
467
\$entry{SSH} = \$ssh;
469
if (\$dist =~ /security/) {
470
\$entry{DUPLOAD_LOCAL_QUEUE_DIR} = 'upload-security';
473
\$entry{BUILD_REGEX} = \$build_regex;
475
if (\$no_build_regex) {
476
\$entry{NO_BUILD_REGEX} = \$build_regex;
478
if (\@no_auto_build) {
479
\$entry{NO_AUTO_BUILD} = \\\@no_auto_build;
481
if (\@weak_no_auto_build) {
482
\$entry{WEAK_NO_AUTO_BUILD} = \\\@weak_no_auto_build;
485
\$entry{WANNA_BUILD_DB_NAME} = \$wanna_build_db_name;
486
\$entry{WANNA_BUILD_DB_USER} = \$wanna_build_db_user;
487
\$entry{WANNA_BUILD_SSH_HOST} = \$wanna_build_ssh_host;
488
\$entry{WANNA_BUILD_SSH_USER} = \$wanna_build_ssh_user;
489
\$entry{WANNA_BUILD_SSH_SOCKET} = \$wanna_build_ssh_socket;
490
\$entry{WANNA_BUILD_SSH_OPTIONS} = \$wanna_build_ssh_options;
491
\$entry{WANNA_BUILD_API} = 0;
493
my \$dist_config = Buildd::DistConf::new_hash(CHECK=>$conf->{'CHECK'},
496
push \@distributions_info, \$dist_config;
499
for my \$raw_entry (\@distributions) {
503
#Find out for which distributions this entry is intended:
504
for my \$key (keys \%\$raw_entry) {
505
if (uc(\$key) eq "DIST_NAME") {
506
if (ref(\$raw_entry->{\$key}) eq "ARRAY") {
507
push \@dist_names, \@{\$raw_entry->{\$key}};
509
push \@dist_names, \$raw_entry->{\$key};
514
for my \$key (keys \%\$raw_entry) {
515
if (uc(\$key) ne "DIST_NAME") {
516
\$entry{uc(\$key)} = \$raw_entry->{\$key};
520
for my \$key (keys \%\$defaults) {
521
if (uc(\$key) ne "DIST_NAME" && not defined \$entry{uc(\$key)}) {
522
\$entry{uc(\$key)} = \$defaults->{\$key};
526
\$entry{WANNA_BUILD_API} //= 1;
529
#We need this to pass this to Buildd::Client:
530
\$entry{SSH} = \$ssh;
532
#Make one entry per distribution, it's easier later on:
533
for my \$dist (\@dist_names) {
534
\$entry{'DIST_NAME'} = \$dist;
535
my \$dist_config = Buildd::DistConf::new_hash(\\\%entry);
536
push \@distributions_info, \$dist_config;
541
\$conf->set('DISTRIBUTIONS', \\\@distributions_info);
543
if (\@upload_queues) {
544
my \@upload_queue_configs;
545
for my \$raw_entry (\@upload_queues) {
547
for my \$key (keys \%\$raw_entry) {
548
\$entry{uc(\$key)} = \$raw_entry->{\$key};
551
my \$queue_config = Buildd::UploadQueueConf::new_hash(CHECK=>$conf->{'CHECK'},
554
push \@upload_queue_configs, \$queue_config;
556
\$conf->set('UPLOAD_QUEUES', \\\@upload_queue_configs);
558
push \@{\$conf->get('UPLOAD_QUEUES')},
559
Buildd::UploadQueueConf::new_hash(CHECK=>$conf->{'CHECK'},
562
DUPLOAD_LOCAL_QUEUE_DIR => 'upload',
563
DUPLOAD_ARCHIVE_NAME => 'anonymous-ftp-master'
566
Buildd::UploadQueueConf::new_hash(CHECK=>$conf->{'CHECK'},
569
DUPLOAD_LOCAL_QUEUE_DIR => 'upload-security',
570
DUPLOAD_ARCHIVE_NAME => 'security'
575
# Set here to allow user to override.
576
if (-t STDIN && -t STDOUT && \$conf->get('NO_DETACH')) {
577
\$conf->_set_default('VERBOSE', 1);
579
\$conf->_set_default('VERBOSE', 0);
583
$conf->read(\@config_files, $deprecated_init, $deprecated_setup,
281
588
foreach (@config_files) {
283
my $e = eval `cat "$_"`;
285
print STDERR "E: $_: Errors found in configuration file:\n$@";
288
590
$conf->get('CONFIG_TIME')->{$_} = $config_time{$_};
292
# Set configuration if updated.
293
$conf->set('ADMIN_MAIL', $admin_mail);
294
$conf->set('APT_GET', $apt_get);
295
$conf->set('ARCH', $arch);
296
$conf->set('AUTOCLEAN_INTERVAL', $autoclean_interval);
297
$conf->set('BUILD_LOG_KEEP', $build_log_keep);
298
$conf->set('DAEMON_LOG_FILE', $daemon_log_file);
299
$conf->set('DAEMON_LOG_KEEP', $daemon_log_keep);
300
$conf->set('DAEMON_LOG_ROTATE', $daemon_log_rotate);
301
$conf->set('DAEMON_LOG_SEND', $daemon_log_send);
302
$conf->set('DELAY_AFTER_GIVE_BACK', $delay_after_give_back);
303
$conf->set('ERROR_MAIL_WINDOW', $error_mail_window);
304
$conf->set('IDLE_SLEEP_TIME', $idle_sleep_time);
305
$conf->set('LOG_QUEUED_MESSAGES', $log_queued_messages);
306
$conf->set('MIN_FREE_SPACE', $min_free_space);
307
$conf->set('NICE_LEVEL', $nice_level);
308
$conf->set('NO_DETACH', $no_detach);
309
$conf->set('NO_WARN_PATTERN', $no_warn_pattern);
310
$conf->set('PIDFILE', $pidfile);
311
$conf->set('PKG_LOG_KEEP', $pkg_log_keep);
312
$conf->set('SECONDARY_DAEMON_THRESHOLD', $secondary_daemon_threshold);
313
$conf->set('SHOULD_BUILD_MSGS', $should_build_msgs);
314
$conf->set('SSH', $ssh);
315
$conf->set('STATISTICS_MAIL', $statistics_mail);
316
$conf->set('STATISTICS_PERIOD', $statistics_period);
317
$conf->set('SUDO', $sudo);
318
$conf->set('WARNING_AGE', $warning_age);
320
if ($sshcmd && $sshcmd =~ /^\s*(\S+)\s+(.+)/) {
322
$conf->set('SSH', $1);
324
#Try to pry the user out:
325
if ($rest =~ /(-l\s*(\S+))\s+/) {
326
$wanna_build_ssh_user = $2;
327
#purge this from the rest:
329
} elsif ($rest =~ /\s+(\S+)\@/) {
330
$wanna_build_ssh_user = $1;
331
$rest =~ s/\Q$1\E\@//;
334
#Hope that the last argument is the host:
335
if ($rest =~ /\s+(\S+)\s*$/) {
336
$wanna_build_ssh_host = $1;
340
#rest should be options:
341
if ($rest !~ /\s*/) {
342
$wanna_build_ssh_options = [split $rest];
347
$wanna_build_ssh_socket = $sshsocket;
350
if ($wanna_build_user) {
351
$wanna_build_db_user = $wanna_build_user;
354
if ($wanna_build_dbbase) {
355
$wanna_build_db_name = $wanna_build_dbbase;
358
#Convert old config, if needed:
359
my @distributions_info;
360
if (@take_from_dists) {
361
for my $dist (@take_from_dists) {
364
$entry{DIST_NAME} = $dist;
367
if ($dist =~ /security/) {
368
$entry{DUPLOAD_LOCAL_QUEUE_DIR} = 'upload-security';
371
$entry{BUILD_REGEX} = $build_regex;
373
if ($no_build_regex) {
374
$entry{NO_BUILD_REGEX} = $build_regex;
376
if (@no_auto_build) {
377
$entry{NO_AUTO_BUILD} = \@no_auto_build;
379
if (@weak_no_auto_build) {
380
$entry{WEAK_NO_AUTO_BUILD} = \@weak_no_auto_build;
383
$entry{WANNA_BUILD_DB_NAME} = $wanna_build_db_name;
384
$entry{WANNA_BUILD_DB_USER} = $wanna_build_db_user;
385
$entry{WANNA_BUILD_SSH_HOST} = $wanna_build_ssh_host;
386
$entry{WANNA_BUILD_SSH_USER} = $wanna_build_ssh_user;
387
$entry{WANNA_BUILD_SSH_SOCKET} = $wanna_build_ssh_socket;
388
$entry{WANNA_BUILD_SSH_OPTIONS} = $wanna_build_ssh_options;
389
$entry{WANNA_BUILD_API} = 0;
391
my $dist_config = Buildd::DistConf::new_hash(\%entry);
393
push @distributions_info, $dist_config;
396
for my $raw_entry (@distributions) {
400
#Find out for which distributions this entry is intended:
401
for my $key (keys %$raw_entry) {
402
if (uc($key) eq "DIST_NAME") {
403
if (ref($raw_entry->{$key}) eq "ARRAY") {
404
push @dist_names, @{$raw_entry->{$key}};
406
push @dist_names, $raw_entry->{$key};
411
for my $key (keys %$raw_entry) {
412
if (uc($key) ne "DIST_NAME") {
413
$entry{uc($key)} = $raw_entry->{$key};
417
for my $key (keys %$defaults) {
418
if (uc($key) ne "DIST_NAME" && not defined $entry{uc($key)}) {
419
$entry{uc($key)} = $defaults->{$key};
423
$entry{WANNA_BUILD_API} //= 1;
426
#We need this to pass this to Sbuild::DB::Client:
429
#Make one entry per distribution, it's easier later on:
430
for my $dist (@dist_names) {
431
$entry{'DIST_NAME'} = $dist;
432
my $dist_config = Buildd::DistConf::new_hash(\%entry);
433
push @distributions_info, $dist_config;
438
$conf->set('DISTRIBUTIONS', \@distributions_info);
440
if (@upload_queues) {
441
my @upload_queue_configs;
442
for my $raw_entry (@upload_queues) {
444
for my $key (keys %$raw_entry) {
445
$entry{uc($key)} = $raw_entry->{$key};
448
my $queue_config = Buildd::UploadQueueConf::new_hash(\%entry);
450
push @upload_queue_configs, $queue_config;
452
$conf->set('UPLOAD_QUEUES', \@upload_queue_configs);
454
push @{$conf->get('UPLOAD_QUEUES')},
455
Buildd::UploadQueueConf::new_hash(
457
DUPLOAD_LOCAL_QUEUE_DIR => 'upload',
458
DUPLOAD_ARCHIVE_NAME => 'anonymous-ftp-master'
461
Buildd::UploadQueueConf::new_hash(
463
DUPLOAD_LOCAL_QUEUE_DIR => 'upload-security',
464
DUPLOAD_ARCHIVE_NAME => 'security'
469
# Set here to allow user to override.
470
if (-t STDIN && -t STDOUT && $conf->get('NO_DETACH')) {
471
$conf->set('VERBOSE', 1);