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

« back to all changes in this revision

Viewing changes to lib/Sbuild/Chroot.pm

  • Committer: Bazaar Package Importer
  • Author(s): Roger Leigh, Roger Leigh
  • Date: 2009-05-17 15:52:53 UTC
  • mfrom: (8.1.7 upstream) (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090517155253-fbxadfsyaf940ete
Tags: 0.58.3-1
[ Roger Leigh ]
* New release.
* debian/control:
  - Update to Standards Version 3.8.1.
  - Add buildd package.
  - Add libsbuild-perl package.
  - All packages depend upon libsbuild-perl.
* Add support for appending a tag to version numbers (Closes: #475777).
  Thanks to Timothy G Abbott for this patch.
* When using the --help or --version options, don't abort if not
  in the sbuild group (Closes: #523670).  Group membership is now
  only performed after options parsing, and only if required.
* Allow config files to use $HOME (Closes: #524564).  Thanks to
  James Vega for this patch.
* Restore buildd package.
* Split common library functions into new libsbuild-perl package.
* debian/sbuild.(preinst|postinst|postrm):
  - Remove special cases for versions older than oldstable.  Update
    addition and removal of sbuild group to use return value of getent
    rather than parsing getent output.
  - Use addgroup/delgroup in place of adduser/deluser.
  - Use --system when adding and deleting group, to ensure creation
    of a system group.  Migrate existing non-system group and group
    members if the system group is not present.
  - Handle removal of 50sbuild setup script.
* debian/buildd.(preinst|postinst|postrm): Add maintainer scripts for
  buildd package.  Move configuration file from /etc/buildd.conf to
  /etc/buildd/buildd.conf if present.  Also create buildd user and
  group for running the buildd daemon.
* Sbuild::Conf: Don't default MAINTAINER_NAME to $DEBEMAIL if unset
  in the configuration file (Closes: #520158).
* /etc/schroot/setup.d/50sbuild: Remove.  The setup tasks performed by
  this script are now handled internally by sbuild.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
use Sbuild::Base;
27
27
use Sbuild::Conf;
28
28
use Sbuild::ChrootInfo;
 
29
use Sbuild::ChrootSetup qw(basesetup);
29
30
 
30
31
use strict;
31
32
use warnings;
95
96
    $self->set('Srcdep Lock Dir', $self->get('Location') . '/' . $self->get_conf('SRCDEP_LOCK_DIR'));
96
97
    $self->set('Install Lock', $self->get('Srcdep Lock Dir') . "/install");
97
98
 
 
99
    if (basesetup($self, $self->get('Config'))) {
 
100
        print STDERR "Failed to set up chroot\n";
 
101
        return 0;
 
102
    }
98
103
    my $aptconf = "/var/lib/sbuild/apt.conf";
99
104
    $self->set('APT Conf', $aptconf);
100
105
 
108
113
        $self->_setup_aptconf($F);
109
114
 
110
115
        if (! rename $F->filename, $chroot_aptconf) {
111
 
            die "Can't rename $F->filename to $chroot_aptconf: $!\n";
 
116
            print STDERR "Can't rename $F->filename to $chroot_aptconf: $!\n";
 
117
            return 0;
112
118
        }
113
119
    } else {
114
 
        die "Can't create $chroot_aptconf: $!";
 
120
        print STDERR "Can't create $chroot_aptconf: $!";
 
121
        return 0;
115
122
    }
116
123
 
117
124
    # unsplit mode uses an absolute path inside the chroot, rather
132
139
        $self->get('Defaults')->{'ENV'}->{'APT_CONFIG'} =
133
140
            $self->get('APT Conf');
134
141
    }
 
142
 
 
143
    return 1;
135
144
}
136
145
 
137
146
sub strip_chroot_path {
230
239
    my $self = shift;
231
240
    my $options = shift;
232
241
 
233
 
    $options->{'PIPE'} = 'in';
234
 
    my $pipe = $self->pipe_command($options);
235
 
 
236
 
    if (defined($pipe)) {
237
 
        while (<$pipe>) {
238
 
            $self->log("$_");
239
 
        }
240
 
        return close($pipe);
241
 
    } else {
242
 
        return 1;
 
242
    my $pid = fork();
 
243
 
 
244
    if (!defined $pid) {
 
245
        warn "Cannot fork: $!\n";
 
246
    } elsif ($pid == 0) { # child
 
247
        # redirect stdout
 
248
        my $in = undef;
 
249
        $in = $self->get('Defaults')->{'STREAMIN'} if
 
250
            (defined($self->get('Defaults')) &&
 
251
             defined($self->get('Defaults')->{'STREAMIN'}));
 
252
        $in = $options->{'STREAMIN'} if defined($options->{'STREAMIN'});
 
253
        if (defined($in) && $in && \*STDIN != $in) {
 
254
            open(STDIN, '<&', $in)
 
255
                or warn "Can't redirect stdin\n";
 
256
        }
 
257
        # redirect stdout
 
258
        my $out = undef;
 
259
        $out = $self->get('Defaults')->{'STREAMOUT'} if
 
260
            (defined($self->get('Defaults')) &&
 
261
             defined($self->get('Defaults')->{'STREAMOUT'}));
 
262
        $out = $options->{'STREAMOUT'} if defined($options->{'STREAMOUT'});
 
263
        if (defined($out) && $out && \*STDOUT != $out) {
 
264
            open(STDOUT, '>&', $out)
 
265
                or warn "Can't redirect stdout\n";
 
266
        }
 
267
        # redirect stderr
 
268
        my $err = undef;
 
269
        $err = $self->get('Defaults')->{'STREAMERR'} if
 
270
            (defined($self->get('Defaults')) &&
 
271
             defined($self->get('Defaults')->{'STREAMERR'}));
 
272
        $err = $options->{'STREAMERR'} if defined($options->{'STREAMERR'});
 
273
        if (defined($err) && $err && \*STDERR != $err) {
 
274
            open(STDERR, '>&', $err)
 
275
                or warn "Can't redirect stderr\n";
 
276
        }
 
277
 
 
278
        $self->exec_command($options);
243
279
    }
 
280
 
 
281
    debug("Pipe (PID $pid) created for: ",
 
282
          join(" ", @{$options->{'COMMAND'}}),
 
283
          "\n");
 
284
 
 
285
    waitpid($pid, 0);
244
286
}
245
287
 
246
288
# Note, do not run with $user="root", and $chroot=0, because root
293
335
    }
294
336
 
295
337
    debug("Environment set:\n");
296
 
    foreach (keys %ENV) {
 
338
    foreach (sort keys %ENV) {
297
339
        debug("  $_=$ENV{$_}\n");
298
340
    }
299
341
 
314
356
    my $command = $options->{'COMMAND'};
315
357
    my $apt_options = $self->get('APT Options');
316
358
 
317
 
    debug("APT Options: ", join(" ", @$apt_options), "\n");
 
359
    debug("APT Options: ", join(" ", @$apt_options), "\n")
 
360
        if defined($apt_options);
318
361
 
319
362
    my @aptcommand = ();
320
363
    if (defined($apt_options)) {