~ubuntu-branches/debian/squeeze/sbuild/squeeze

« back to all changes in this revision

Viewing changes to lib/Sbuild/Conf.pm

  • Committer: Bazaar Package Importer
  • Author(s): Roger Leigh
  • Date: 2008-08-18 11:15:05 UTC
  • mfrom: (0.1.1 upstream) (3.1.6 hardy)
  • Revision ID: james.westby@ubuntu.com-20080818111505-5j8x6j4d4krxbjdv
Tags: 0.57.7-1
* New release.
* sbuild-checkpackages handles --list and --set options correctly
  (Closes: #495490).
* sbuild-createchroot: Correctly parse --arch option (Closes: #495517).
  Thanks to Cyril Brulebois for this patch.
* sbuild-setup.7.in: Change permissions of /build to 02775
  (Closes: #494076).  Thanks to Lucas Nussbaum for finding this missing
  step.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Conf.pm: configuration library for sbuild
 
3
# Copyright © 2005 Ryan Murray <rmurray@debian.org>
 
4
# Copyright © 2006 Roger Leigh <rleigh@debian.org>
 
5
#
 
6
# This program is free software: you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation, either version 2 of the License, or
 
9
# (at your option) any later version.
 
10
#
 
11
# This program is distributed in the hope that it will be useful, but
 
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
# General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with this program.  If not, see
 
18
# <http://www.gnu.org/licenses/>.
 
19
#
 
20
#######################################################################
 
21
 
 
22
package Sbuild::Conf;
 
23
 
 
24
use strict;
 
25
use warnings;
 
26
use Cwd qw(cwd);
 
27
 
 
28
sub init ();
 
29
 
 
30
BEGIN {
 
31
    use Exporter ();
 
32
    our (@ISA, @EXPORT);
 
33
 
 
34
    @ISA = qw(Exporter);
 
35
 
 
36
    @EXPORT = qw($HOME %alternatives $apt_policy $apt_update
 
37
                 $apt_allow_unauthenticated $check_watches $cwd
 
38
                 $username $verbose $nolog $mailprog $dpkg $su
 
39
                 $schroot $schroot_options $fakeroot $apt_get
 
40
                 $apt_cache $dpkg_source $dcmd $md5sum $avg_time_db
 
41
                 $avg_space_db $stats_dir $package_checklist
 
42
                 $build_env_cmnd $pgp_options $log_dir $mailto
 
43
                 $mailfrom @no_auto_upgrade $check_depends_algorithm
 
44
                 $purge_build_directory @toolchain_regex
 
45
                 $stalled_pkg_timeout $srcdep_lock_dir
 
46
                 $srcdep_lock_wait $max_lock_trys $lock_interval
 
47
                 @ignore_watches_no_build_deps $build_dir $sbuild_mode
 
48
                 $debug $force_orig_source
 
49
                 %individual_stalled_pkg_timeout $path
 
50
                 $maintainer_name $uploader_name %watches $key_id);
 
51
}
 
52
 
 
53
INIT {
 
54
    init();
 
55
}
 
56
 
 
57
# Originally from the main namespace.
 
58
(our $HOME = $ENV{'HOME'})
 
59
    or die "HOME not defined in environment!\n";
 
60
our $username = (getpwuid($<))[0] || $ENV{'LOGNAME'} || $ENV{'USER'};
 
61
our $cwd = cwd();
 
62
our $verbose = 0;
 
63
our $nolog = 0;
 
64
 
 
65
# Defaults.
 
66
# TODO: Remove $source_dependencies after Lenny.
 
67
our $source_dependencies;
 
68
our $mailprog = "/usr/sbin/sendmail";
 
69
our $dpkg = "/usr/bin/dpkg";
 
70
our $sudo;
 
71
our $su = "/bin/su";
 
72
our $schroot = "/usr/bin/schroot";
 
73
our $schroot_options = "-q";
 
74
our $fakeroot = "/usr/bin/fakeroot";
 
75
our $apt_get = "/usr/bin/apt-get";
 
76
our $apt_cache = "/usr/bin/apt-cache";
 
77
our $dpkg_source = "/usr/bin/dpkg-source";
 
78
our $dcmd = "/usr/bin/dcmd";
 
79
our $md5sum = "/usr/bin/md5sum";
 
80
our $avg_time_db = "/var/lib/sbuild/avg-build-times";
 
81
our $avg_space_db = "/var/lib/sbuild/avg-build-space";
 
82
our $stats_dir = "$HOME/stats";
 
83
our $package_checklist = "/var/lib/sbuild/package-checklist";
 
84
our $build_env_cmnd = "";
 
85
our $pgp_options = "-us -uc";
 
86
our $log_dir = "$HOME/logs";
 
87
our $mailto = "";
 
88
our $mailfrom = "Source Builder <sbuild>";
 
89
our $purge_build_directory = "successful";
 
90
our @toolchain_regex = ( 'binutils$', 'gcc-[\d.]+$', 'g\+\+-[\d.]+$', 'libstdc\+\+', 'libc[\d.]+-dev$', 'linux-kernel-headers$', 'linux-libc-dev$', 'gnumach-dev$', 'hurd-dev$', 'kfreebsd-kernel-headers$');
 
91
our $stalled_pkg_timeout = 150; # minutes
 
92
our $srcdep_lock_dir = "/var/lib/sbuild/srcdep-lock";
 
93
our $srcdep_lock_wait = 1; # minutes
 
94
our $max_lock_trys = 120;
 
95
our $lock_interval = 5;
 
96
# TODO: Remove $chroot_only after Lenny
 
97
our $chroot_only;
 
98
# TODO: Remove $chroot_mode after Lenny
 
99
our $chroot_mode;
 
100
our $apt_policy = 1;
 
101
our $check_watches = 1;
 
102
our @ignore_watches_no_build_deps = qw();
 
103
our %watches;
 
104
# TODO: Remove $build_dir after Lenny
 
105
our $build_dir = undef;
 
106
our $sbuild_mode = "user";
 
107
our $debug = 0;
 
108
our $force_orig_source = 0;
 
109
our %individual_stalled_pkg_timeout = ();
 
110
our $path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/usr/games";
 
111
our $maintainer_name;
 
112
our $uploader_name;
 
113
our $key_id;
 
114
our $apt_update = 0;
 
115
our $apt_allow_unauthenticated = 0;
 
116
our %alternatives = ("info-browser"             => "info",
 
117
                     "httpd"                    => "apache",
 
118
                     "postscript-viewer"        => "ghostview",
 
119
                     "postscript-preview"       => "psutils",
 
120
                     "www-browser"              => "lynx",
 
121
                     "awk"                      => "gawk",
 
122
                     "c-shell"                  => "tcsh",
 
123
                     "wordlist"                 => "wenglish",
 
124
                     "tclsh"                    => "tcl8.4",
 
125
                     "wish"                     => "tk8.4",
 
126
                     "c-compiler"               => "gcc",
 
127
                     "fortran77-compiler"       => "g77",
 
128
                     "java-compiler"            => "jikes",
 
129
                     "libc-dev"                 => "libc6-dev",
 
130
                     "libgl-dev"                => "xlibmesa-gl-dev",
 
131
                     "libglu-dev"               => "xlibmesa-glu-dev",
 
132
                     "libncurses-dev"           => "libncurses5-dev",
 
133
                     "libz-dev"                 => "zlib1g-dev",
 
134
                     "libg++-dev"               => "libstdc++6-4.0-dev",
 
135
                     "emacsen"                  => "emacs21",
 
136
                     "mail-transport-agent"     => "ssmtp",
 
137
                     "mail-reader"              => "mailx",
 
138
                     "news-transport-system"    => "inn",
 
139
                     "news-reader"              => "nn",
 
140
                     "xserver"                  => "xvfb",
 
141
                     "mysql-dev"                => "libmysqlclient-dev",
 
142
                     "giflib-dev"               => "libungif4-dev",
 
143
                     "freetype2-dev"            => "libttf-dev");
 
144
 
 
145
our @no_auto_upgrade = qw(dpkg apt bash libc6 libc6-dev dpkg-dev);
 
146
our $check_depends_algorithm = "first-only";
 
147
 
 
148
# read conf files
 
149
require "/etc/sbuild/sbuild.conf" if -r "/etc/sbuild/sbuild.conf";
 
150
require "$HOME/.sbuildrc" if -r "$HOME/.sbuildrc";
 
151
 
 
152
sub init () {
 
153
    # some checks
 
154
    die "mailprog binary $Sbuild::Conf::mailprog does not exist or isn't executable\n"
 
155
        if !-x $Sbuild::Conf::mailprog;
 
156
    die "schroot binary $Sbuild::Conf::schroot does not exist or isn't executable\n"
 
157
        if !-x $Sbuild::Conf::schroot;
 
158
    die "apt-get binary $Sbuild::Conf::apt_get does not exist or isn't executable\n"
 
159
        if !-x $Sbuild::Conf::apt_get;
 
160
    die "apt-cache binary $Sbuild::Conf::apt_cache does not exist or isn't executable\n"
 
161
        if !-x $Sbuild::Conf::apt_cache;
 
162
    die "dpkg-source binary $Sbuild::Conf::dpkg_source does not exist or isn't executable\n"
 
163
        if !-x $Sbuild::Conf::dpkg_source;
 
164
    die "$Sbuild::Conf::srcdep_lock_dir is not a directory\n"
 
165
        if ! -d $Sbuild::Conf::srcdep_lock_dir;
 
166
 
 
167
    die "mailto not set\n" if !$Sbuild::Conf::mailto && $sbuild_mode eq "buildd";
 
168
 
 
169
    if (!defined($Sbuild::Conf::build_dir)) {
 
170
        $Sbuild::Conf::build_dir = $Sbuild::Conf::cwd;
 
171
    }
 
172
    if (! -d "$Sbuild::Conf::build_dir") {
 
173
        die "Build directory $Sbuild::Conf::build_dir does not exist";
 
174
    }
 
175
 
 
176
    # TODO: Remove chroot_mode, chroot_only, sudo and
 
177
    # source_dependencies after Lenny.
 
178
 
 
179
    if (defined($chroot_mode)) {
 
180
        die "chroot_mode is obsolete";
 
181
    }
 
182
 
 
183
    if (defined($chroot_only)) {
 
184
        die "chroot_only is obsolete";
 
185
    }
 
186
 
 
187
    if (defined($sudo)) {
 
188
        die "sudo is obsolete";
 
189
    }
 
190
 
 
191
    if (defined($source_dependencies)) {
 
192
        die "Source dependencies are obsolete";
 
193
    }
 
194
 
 
195
}
 
196
 
 
197
1;