~ubuntu-branches/ubuntu/karmic/sbuild/karmic-proposed

« back to all changes in this revision

Viewing changes to lib/Buildd/Conf.pm

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2009-05-09 16:06:44 UTC
  • mfrom: (8.1.6 upstream) (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090509160644-9k0fgp6c2ajcu54h
Tags: 0.58.2-1ubuntu1
* Merge from debian unstable, remaining changes:
  - bin/sbuild, lib/Sbuild/{Base,Conf,Options}.pm: add --setup-hook
    to allow pre-build modifications to underlying chroots (needed
    to adjust pockets and components in sources.list).  (debian bug
    500746).

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
    @ISA = qw(Exporter);
35
35
 
36
 
    @EXPORT = qw($HOME $max_build $nice_level $idle_sleep_time
 
36
    @EXPORT = qw($HOME $arch $max_build $nice_level $idle_sleep_time
37
37
                 $min_free_space @take_from_dists @no_auto_build
38
38
                 $no_build_regex $build_regex @weak_no_auto_build
39
39
                 $delay_after_give_back $pkg_log_keep $pkg_log_keep
47
47
                 $log_queued_messages $wanna_build_dbbase read);
48
48
}
49
49
 
 
50
sub read_file ($\$);
50
51
sub read ();
 
52
sub convert_sshcmd ();
51
53
sub init ();
52
54
 
 
55
my $reread_config = 0;
 
56
 
53
57
# Originally from the main namespace.
54
58
(our $HOME = $ENV{'HOME'})
55
59
    or die "HOME not defined in environment!\n";
 
60
# Configuration files.
 
61
my $config_global = "/etc/buildd.conf";
 
62
my $config_user = "$HOME/.builddrc";
 
63
my $config_global_time = 0;
 
64
my $config_user_time = 0;
56
65
 
57
66
# Defaults.
 
67
chomp( our $arch = `dpkg --print-architecture 2>/dev/null` );
58
68
our $max_build = 10;
59
69
our $nice_level = 10;
60
70
our $idle_sleep_time = 5*60;
61
 
our $min_free_space = 10*1024;
62
 
our @take_from_dists = qw(stable testing unstable);
 
71
our $min_free_space = 50*1024;
 
72
our @take_from_dists = qw();
63
73
our @no_auto_build = ();
64
74
our $no_build_regex = "^(contrib/|non-free/)?non-US/";
65
75
our $build_regex = "";
69
79
our $build_log_keep = 2;
70
80
our $daemon_log_rotate = 1;
71
81
our $daemon_log_send = 1;
72
 
our $daemon_log_keepb = 7;
 
82
our $daemon_log_keep = 7;
73
83
our $warning_age = 7;
74
84
our $error_mail_window = 8*60*60;
75
85
our $statistics_period = 7;
88
98
our $dupload_to_non_us = "anonymous-non-us";
89
99
our $dupload_to_security = "security";
90
100
our $log_queued_messages = 0;
91
 
our $wanna_build_dbbase = "arch/build-db";
 
101
our $wanna_build_dbbase = "$arch/build-db";
 
102
 
 
103
sub ST_MTIME () { 9 }
 
104
 
 
105
sub read_file ($\$) {
 
106
    my $filename = shift;
 
107
    my $time_var = shift;
 
108
    if (-r $filename) {
 
109
        my @stat = stat( $filename );
 
110
        $$time_var = $stat[ST_MTIME];
 
111
        delete $INC{$filename};
 
112
        require $filename;
 
113
    }
 
114
}
92
115
 
93
116
# read conf files
94
117
sub read () {
95
 
    require "/etc/buildd/buildd.conf" if -r "/etc/buildd/buildd.conf";
96
 
    require "$HOME/.builddrc" if -r "$HOME/.builddrc";
 
118
    read_file( $config_global, $config_global_time );
 
119
    read_file( $config_user, $config_user_time );
 
120
    convert_sshcmd();
97
121
}
98
122
 
99
 
sub init () {
100
 
    Buildd::Conf::read();
101
 
 
102
 
    # some checks
 
123
sub convert_sshcmd () {
103
124
    if ($sshcmd) {
104
125
        if ($sshcmd =~ /-l\s*(\S+)\s+(\S+)/) {
105
126
            ($main::sshuser, $main::sshhost) = ($1, $2);
117
138
    }
118
139
}
119
140
 
 
141
sub init () {
 
142
    Buildd::Conf::read();
 
143
}
 
144
 
 
145
$SIG{'USR1'} = sub ($) { $reread_config = 1; };
 
146
 
 
147
sub check_reread_config () {
 
148
    my @stat_user = stat( $config_user );
 
149
    my @stat_global = stat( $config_global );
 
150
 
 
151
    if ( $reread_config ||
 
152
        (@stat_user && $config_user_time != $stat_user[ST_MTIME]) ||
 
153
        (@stat_global && $config_global_time != $stat_global[ST_MTIME])) {
 
154
        logger( "My config file has been updated -- rereading it\n" );
 
155
        Buildd::Conf::read();
 
156
        $reread_config = 0;
 
157
    }
 
158
}
 
159
 
120
160
1;