~ubuntu-branches/ubuntu/gutsy/sbuild/gutsy

« back to all changes in this revision

Viewing changes to sbuild

  • Committer: Bazaar Package Importer
  • Author(s): Roger Leigh
  • Date: 2007-05-18 17:46:31 UTC
  • Revision ID: james.westby@ubuntu.com-20070518174631-tvxpqt09n51bs589
Tags: 0.54
* debian/control:
  - Remove sudo from Depends.
  - Add schroot to Depends.
  - Remove schroot from Recommends.
  - Depend on dctrl-tools rather than the transitional grep-dctrl package.
    Thanks to Jonh Wendell (Closes: #417573).
* debian/rules:
  - Don't install sbuild.conf.local.
  - Install sbuild.conf into /etc/sbuild.
* debian/NEWS.Debian:
  - New file.
  - Document removal of manual source dependencies and sudo.
  - Document removal of support for building from a directory.
  - Document removal of building on the host system.
  - Document sudo->schroot migration.
  - Document change in $sbuild_mode default.
* debian/README.Debian:
  - Document removal of manual src-deps.
  - Remove requirements for chroot symlinks in working directory.
* sbuild:
  - Remove read_deps, so manual src-deps are no longer read.  The
    remainder of the manual src-deps support remains to be removed.
  - Quote all arguments to system commands such as "rm -rf", to prevent
    potential disasters.
  - Update copyrights, and encode in UTF-8.
  - Use "du -k -s" instead of "du -s" to increase portability.  Thanks to
    Martin Koeppe (Closes: #418061).
  - Compute package, version, directory and whether to download sources
    before calling fetch_source_files, because all the needed information
    is available at this point.
  - cleanup_packages:
    + Remove check for schroot when removing build dependencies, since
      schroot is the default.
    + Remove undo_specials().
  - build:
    + Remove do_apply_patches.
    + Replace "822-date" with "date -R".  Thanks to Guillem Jover for
      this patch (Closes: #415798).
    + Remove support for building from a directory.
    + Run dpkg-source from within the chroot.
    + Don't chdir before running dpkg-source.
    + Don't chdir before running dpkg-parsechangelog (do it in the
      schroot child process).
    + Remove obsolete code for running dpkg-buildpackage outside a chroot.
  - fetch_source_files:
    + Remove support for building from a directory.
    + Download sources directly into the chroot build directory.  For
      sources already existing outside the chroot, copy them into the
      chroot build directory.
    + Add extra directory, package, version and download arguments.
    + Only call dsc_md5sums once, rather than twice.
  - apply_patches: Remove.
  - get_special: Remove use of @main::global_patches.
  - Remove SVN Id:.
  - install_deps: Remove @special use.
  - unpack_special_source: Remove.
  - undo_specials: Remove.
  - filter_dependencies: Remove @special use.
  - run_script: Remove.
  - parse_one_srcdep: Remove @special use.
  - get_special: Remove.
  - write_srcdep_lock_file: Remove @special use.
  - check_srcdep_conflicts: Remove @special use.
  - dump_main_state: New function to dump the program state using
    Data::Dumper.  Use to dump the state after each build.
  - Add / separators to all users of $main::chroot_build_dir in paths.
  - Replace all users of regular expressions to strip the chroot dir
    from paths with strip_chroot_path.
  - get_dpkg_status: Print debugging messages with defined variables
    only, to avoid Perl warning.
  - verify_md5sums: Remove obsolete comment regarding chroots.
  - check_group_membership: New function to check the user is a member
    of the sbuild group (Closes: #414064).
  - Added new command-line argument --arch to specify the architecture,
    and pass this to begin_session (Closes: 410576).
* Sbuild/Chroot.pm:
  - Remove all special casing for sudo and schroot.  schroot is now the
    only supported method of accessing chroots.
  - end_session: Only attempt to end a session when $schroot_session is
    non-empty.
  - _setup_options:
    + Remove use of $chroot_only.
    + Remove trailing / from 'Build Location'.
  - init: Add newline to debugging message.
  - strip_chroot_path: New function to strip the chroot location from a
    path.
  - log_command: Correctly log commands when no APT Options stripping is
    needed.
  - get_command_internal: Set the working directory inside the chroot to
    the build location.
  - begin_session: take the architecture as a second argument, and check
    if a chroot specific for the architecture exists.
* Sbuild/Conf.pm:
  - Don't export $source_dependencies.
  - Don't define $source_dependencies.
  - Abort with an error if $source_dependencies is defined.
  - Don't export $sudo or $chroot_mode.
  - Don't define $sudo or $chroot_mode.
  - Remove sudo sanity checks.
  - Abort with an error if $sudo or $chroot_mode are defined.
  - Don't export $chroot_only.
  - Don't define $chroot_only.
  - Abort with an error if $chroot_only is defined.
  - Define and export %alternatives.  Thanks to Martin Koeppe
    (Closes: #418060).
  - Define and export @no_auto_upgrade and %watches.
  - Remove the requirement for /usr/share/sbuild/sbuild.conf.
  - Mark deprecated/obsolete variables for removal post-Lenny.
  - Set defaults from global sbuild.conf.
* sbuild.conf:
  - Remove $source_dependencies.
  - Remove $sudo.
  - Remove $chroot_only.
  - Add and document all options from Sbuild/Conf.pm.
  - Reorder into sections.
  - Merge with sbuild.conf.local, and install into /etc/sbuild.
* sbuild.conf.local:
  - Remove $source_dependencies.
  - Remove.
* example.sbuildrc:
  - Replace all options with documented options from sbuild.conf.
  - Add additional user-centric options from sbuild.conf.
  - Reorder into sections.
* sbuild.1.in: Document --arch and chroot search order.
* sbuild-setup.7.in:
  - Remove sudo setup.
  - Update user section to document sbuild group membership and
    add_sbuild_user.  Remove chroot setup, which is now handled by
    schroot (Closes: #413524).
* bin/README.bins: Remove sudo from extra package list.
* bin/updatechroot, bin/upgradechroot, bin/chrapt: Remove chroot_mode.
* chroot/add_sbuild_user:
  - Remove sudo setup instructions and copying of /etc/sudoers to the
    chroot.
  - Rewrite in perl.  Only call adduser; all other chroot setup is
    taken care of by the 50sbuild schroot chroot setup script
    (Closes: #413908).
* TODO: New file.  Document needed changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/perl
2
2
#
3
3
# sbuild: build packages, obeying source dependencies
4
 
# Copyright (C) 1998-2000 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
5
 
# Copyright (C) 2005      Ryan Murray <rmurray@debian.org>
6
 
# Copyright (C) 2005-2006 Roger Leigh <rleigh@debian.org>
 
4
# Copyright © 1998-2000 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
 
5
# Copyright © 2005      Ryan Murray <rmurray@debian.org>
 
6
# Copyright © 2005-2007 Roger Leigh <rleigh@debian.org>
7
7
#
8
8
# This program is free software; you can redistribute it and/or modify
9
9
# it under the terms of the GNU General Public License as published by
19
19
# along with this program; if not, write to the Free Software
20
20
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
21
21
#
22
 
# $Id: sbuild 1085 2007-02-10 19:52:51Z rleigh $
23
 
#
 
22
############################################################################
24
23
 
25
24
package main;
26
25
 
32
31
use IPC::Open3;
33
32
use FileHandle;
34
33
use Sbuild qw(binNMU_version version_compare);
 
34
use Data::Dumper;
35
35
 
36
36
package conf;
37
37
use Sbuild::Conf;
38
38
package main;
39
39
use Sbuild::Conf qw($cwd $nolog $username $verbose); # For backward compatibility.
40
 
use Sbuild::Chroot qw(begin_session end_session get_command
41
 
                      run_command exec_command get_apt_command
42
 
                      run_apt_command);
 
40
use Sbuild::Chroot qw(begin_session end_session strip_chroot_path
 
41
                      get_command run_command exec_command
 
42
                      get_apt_command run_apt_command);
43
43
use Sbuild::Log qw(open_log close_log open_pkg_log close_pkg_log);
44
44
 
45
45
Sbuild::Conf::init();
52
52
# in case the terminal disappears, the build should continue
53
53
$SIG{'HUP'} = 'IGNORE';
54
54
 
 
55
# A file representing /dev/null
55
56
if (!open(main::DEVNULL, '+<', '/dev/null')) {
56
57
        die "Cannot open /dev/null: $!\n";;
57
58
}
58
59
 
 
60
check_group_membership();
 
61
 
59
62
umask(022);
60
63
 
61
64
$main::distribution = "unstable";
62
65
 
63
66
chomp( $main::arch = `$conf::dpkg --print-installation-architecture` );
 
67
$main::user_arch = "";
64
68
$main::batchmode = 0;
65
69
$main::auto_giveback = 0;
66
70
$main::build_arch_all = 0;
136
140
                print "Selected distribution $main::distribution\n"
137
141
                        if $conf::debug;
138
142
        }
 
143
        elsif (/^--arch/) {
 
144
                if (/^--arch=(.)/) {
 
145
                        $main::user_arch = $1.$';
 
146
                }
 
147
                elsif (!@ARGV) {
 
148
                        die "$_ option missing argument\n";
 
149
                }
 
150
                else {
 
151
                        $main::user_arch = shift @ARGV;
 
152
                }
 
153
                print "Selected architecture $main::user_arch\n"
 
154
                        if $conf::debug;
 
155
        }
139
156
        elsif (/^-p/ || /^--purge/) {
140
157
                if (/^-p(.)/ || /^--purge=(.)/) {
141
158
                        $conf::purge_build_directory = $1.$';
259
276
$SIG{'TERM'} = \&shutdown;
260
277
$SIG{'ALRM'} = \&shutdown;
261
278
$SIG{'PIPE'} = \&shutdown;
262
 
read_deps( map { m,(?:.*/)?([^_/]+)[^/]*, } @ARGV );
263
279
 
264
280
write_jobs_file();
265
281
 
266
 
my( $pkgv, $pkg );
267
 
foreach $pkgv (@ARGV) {
268
 
        my $urlbase;
 
282
my $dscfile;
 
283
foreach $dscfile (@ARGV) {
269
284
 
270
 
        ($urlbase, $pkgv) = ($1, $3) if $pkgv =~ m,^(\w+://(\S+/)?)([^/]+)$,;
 
285
        my $dir = dirname($dscfile);
 
286
        my $dscbase = basename($dscfile);
 
287
        my $pkgv = basename($dscfile);
271
288
        $pkgv =~ s/\.dsc$//;
272
 
        (my $pkg = $pkgv) =~ s/_.*$//;
273
 
        $pkg =~ s/^\.\///;
 
289
        my ($pkg, $version) = split /_/, $pkgv;
 
290
 
 
291
        # Download if package does not have a .dsc extension and no
 
292
        # directory was specified.
 
293
        my $download = 1;
 
294
        if ($dscbase =~ m/\.dsc$/) {
 
295
                $download = 0;
 
296
        }
 
297
 
 
298
        print STDERR "D: dscfile = $dscfile\n" if $conf::debug;
 
299
        print STDERR "D: dir = $dir\n" if $conf::debug;
 
300
        print STDERR "D: dscbase = $dscbase\n" if $conf::debug;
 
301
        print STDERR "D: pkgv = $pkgv\n" if $conf::debug;
 
302
        print STDERR "D: pkg = $pkg\n" if $conf::debug;
 
303
        print STDERR "D: version = $version\n" if $conf::debug;
 
304
        print STDERR "D: download = $download\n" if $conf::debug;
 
305
 
 
306
        if ($download && $dscfile ne $pkgv) {
 
307
                print PLOG "Invalid source: $dscfile\n";
 
308
                print PLOG "Skipping $pkg\n";
 
309
                $main::pkg_status = "skipped";
 
310
                goto cleanup_close;
 
311
        }
274
312
 
275
313
        {
276
314
                my $tpkg = basename($pkgv);
285
323
                next if !open_pkg_log( $tpkg, $main::distribution );
286
324
        }
287
325
 
288
 
        if (!begin_session($main::distribution)) {
 
326
        if (!begin_session($main::distribution, $main::user_arch)) {
289
327
                print PLOG "Skipping $pkg\n";
290
328
                $main::pkg_status = "skipped";
291
329
                goto cleanup_close;
305
343
                $main::pkg_status = "skipped";
306
344
                goto cleanup_close;
307
345
        }
308
 
        my $dscfile = $pkgv.".dsc";
 
346
 
309
347
        $main::pkg_fail_stage = "fetch-src";
310
 
        my @files_to_rm = fetch_source_files( \$dscfile );
 
348
        my @files_to_rm = fetch_source_files( \$dscfile,
 
349
                                              $dir, $pkg, $version, $download);
311
350
        if (@files_to_rm && $files_to_rm[0] eq "ERROR") {
312
351
                shift @files_to_rm;
313
352
                goto cleanup_symlinks;
319
358
                goto cleanup_packages;
320
359
        }
321
360
 
322
 
        my $dscbase = basename( $dscfile );
323
 
        $main::pkg_status = "successful" if build( $dscbase, $pkgv );
 
361
        $main::pkg_status = "successful" if build( basename($dscfile), $pkgv );
324
362
        chdir( $main::cwd );
325
363
        write_jobs_file( $main::pkg_status );
326
364
        append_to_FINISHED( $pkgv );
327
365
 
328
366
  cleanup_packages:
329
 
        undo_specials();
330
 
        if ($conf::chroot_mode eq "schroot" &&
331
 
            defined ($$Sbuild::Chroot::current{'Session Managed'}) &&
 
367
        if (defined ($$Sbuild::Chroot::current{'Session Managed'}) &&
332
368
            $$Sbuild::Chroot::current{'Session Managed'} == 1) {
333
369
                print PLOG "Not removing build depends: session managed chroot in use\n";
334
370
        } else {
351
387
        if ( $main::batchmode and (-f "$conf::HOME/EXIT-DAEMON-PLEASE") ) {
352
388
            main::shutdown("NONE (flag file exit)");
353
389
        }
 
390
        dump_main_state() if $conf::debug;
354
391
}
355
392
write_jobs_file();
356
393
 
365
402
 
366
403
sub fetch_source_files {
367
404
        my $dscfile_ref = shift;
368
 
        my $dscfile = $$dscfile_ref;
369
 
        my ($dir, $dscbase, $files, @other_files, $dscarchs, @made);
 
405
        my $dir = shift;
 
406
        my $pkg = shift;
 
407
        my $version = shift;
 
408
        my $download = shift;
 
409
 
 
410
        my ($dscbase, $files, @other_files, $dscarchs, @made);
 
411
 
 
412
        $dscbase = "${pkg}_${version}.dsc";
 
413
 
370
414
        my $build_depends = "";
371
415
        my $build_depends_indep = "";
372
416
        my $build_conflicts = "";
373
417
        my $build_conflicts_indep = "";
374
418
        local( *F );
375
419
 
376
 
        $dscfile =~ m,^(.*)/([^/]+)$,;
377
 
        ($dir, $dscbase) = ($1, $2);
378
 
        my $urlbase;
379
 
        $urlbase = $1 if $dscfile =~ m,^(\w+://(\S+/)?)([^/]+)$,;
380
 
        (my $pkgv = $dscfile) =~ s,^(.*/)?([^/]+)\.dsc$,$2,;
381
 
        my ($pkg, $version) = split /_/, $pkgv;
382
420
        @main::have_dsc_build_deps = ();
383
421
 
384
 
        if (!defined($dscfile) || !defined($pkg) || !defined($version)) {
385
 
                print PLOG "Invalid source: $dscfile\n";
 
422
        if (!defined($pkg) || !defined($version) || !defined($dir) || !defined($dscbase)) {
 
423
                print PLOG "Invalid source: $$dscfile_ref\n";
386
424
                return ("ERROR");
387
425
        }
388
426
 
389
 
        $dscbase = $pkg . "_" . $version if !defined($dscbase);
390
 
 
391
 
        if (-d $dscfile) {
392
 
                if (-f "$dscfile/debian/.sbuild-build-deps") {
393
 
                        open( F, "<$dscfile/debian/.sbuild-build-deps" );
394
 
                        my $pkg;
395
 
                        while( <F> ) {
396
 
                                s/\s*$//;
397
 
                                /^Package:\s*(.*)/i and $pkg = $1;
398
 
                                /^Build-Depends:\s*(.*)/i and $build_depends = $1;
399
 
                                /^Build-Depends-Indep:\s*(.*)/i and $build_depends_indep = $1;
400
 
                                /^Build-Conflicts:\s*(.*)/i and $build_conflicts = $1;
401
 
                                /^Build-Conflicts-Indep:\s*(.*)/i and $build_conflicts_indep = $1;
402
 
                        }
403
 
                        close( F );
404
 
                        merge_pkg_build_deps( $pkg, $build_depends,
405
 
                                              $build_depends_indep,
406
 
                                              $build_conflicts,
407
 
                                              $build_conflicts_indep );
408
 
                }
409
 
                return;
410
 
        }
411
 
 
412
 
        if (!defined($dir) || $dir ne ".") {
413
 
                if (-f "${pkgv}.dsc" && !verify_md5sums(dsc_md5sums("${pkgv}.dsc"))) {
414
 
                        print PLOG "${pkgv}.dsc exists in cwd\n";
415
 
                }
416
 
                else {
417
 
                        my %entries = ();
418
 
                        my $retried = 0;
419
 
 
420
 
                  retry:
421
 
                        print PLOG "Checking available source versions...\n";
422
 
                        my $command = get_apt_command("$conf::apt_cache", "-q showsrc $pkg", $main::username, 0);
423
 
                        my $pid = open3(\*main::DEVNULL, \*PIPE, '>&PLOG', "$command" );
424
 
                        if (!$pid) {
425
 
                                print PLOG "Can't open pipe to $conf::apt_cache: $!\n";
426
 
                                return ("ERROR");
427
 
                        }
428
 
                        {
429
 
                                local($/) = "";
430
 
                                my $package;
431
 
                                my $ver;
432
 
                                my $tfile;
433
 
                                while( <PIPE> ) {
434
 
                                        $package = $1 if /^Package:\s+(\S+)\s*$/mi;
435
 
                                        $ver = $1 if /^Version:\s+(\S+)\s*$/mi;
436
 
                                        $tfile = $1 if /^Files:\s*\n((\s+.*\s*\n)+)/mi;
437
 
                                        if (defined $package && defined $ver && defined $tfile) {
438
 
                                                @{$entries{"$package $ver"}} = map { (split( /\s+/, $_ ))[3] }
439
 
                                                        split( "\n", $tfile );
440
 
                                                undef($package);
441
 
                                                undef($ver);
442
 
                                                undef($tfile);
443
 
                                        }
444
 
                                }
445
 
 
446
 
                                if (! scalar keys %entries) {
447
 
                                        print PLOG "$conf::apt_cache returned no information about $pkg source\n";
448
 
                                        print PLOG "Are there any deb-src lines in your /etc/apt/sources.list?\n";
449
 
                                        return ("ERROR");
450
 
 
451
 
                                }
452
 
                        }
453
 
                        close(PIPE);
454
 
                        waitpid $pid, 0;
455
 
                        if ($?) {
456
 
                                print PLOG "$conf::apt_cache failed\n";
457
 
                                return ("ERROR");
458
 
                        }
459
 
                                
460
 
                        if (!defined($entries{"$pkg $version"})) {
461
 
                                if (!$retried) {
462
 
                                        # try to update apt's cache if nothing found
463
 
                                        run_apt_command("$conf::apt_get", "update >/dev/null", "root", 0);
464
 
                                        $retried = 1;
465
 
                                        goto retry;
466
 
                                }
467
 
                                print PLOG "Can't find source for $pkgv\n";
468
 
                                print PLOG "(only different version(s) ",
469
 
                                        join( ", ", sort keys %entries), " found)\n"
470
 
                                                if %entries;
471
 
                                return( "ERROR" );
472
 
                        }
473
 
 
474
 
                        print PLOG "Fetching source files...\n";
475
 
                        @made = @{$entries{"$pkg $version"}};
476
 
 
477
 
                        my $command2 = get_apt_command("$conf::apt_get", "--only-source -q -d source $pkg=$version 2>&1 </dev/null", $main::username, 0);
478
 
                        if (!open( PIPE, "$command2 |" )) {
479
 
                                print PLOG "Can't open pipe to $conf::apt_get: $!\n";
 
427
        # TODO: Only call dsc_md5sums once.
 
428
        my $md5sums = dsc_md5sums("${dir}/${dscbase}");
 
429
        if (-f "${dir}/${dscbase}" && !$download && !verify_md5sums($md5sums)) {
 
430
                print PLOG "${dscbase} exists in ${dir}; copying to chroot\n";
 
431
                my @cwd_files = ("${dir}/${dscbase}");
 
432
                push @cwd_files, keys %$md5sums;
 
433
                foreach (@cwd_files) {
 
434
                        if (system ("cp '$_' '$main::chroot_build_dir'")) {
 
435
                                print PLOG "ERROR: Could not copy $_ to $main::chroot_build_dir \n";
480
436
                                return ("ERROR", @made);
481
437
                        }
 
438
                        push(@made, "${main::chroot_build_dir}/" . basename($_));
 
439
                }
 
440
        } else {
 
441
                my %entries = ();
 
442
                my $retried = 0;
 
443
          retry:
 
444
                print PLOG "Checking available source versions...\n";
 
445
                my $command = get_apt_command("$conf::apt_cache", "-q showsrc $pkg", $main::username, 0);
 
446
                my $pid = open3(\*main::DEVNULL, \*PIPE, '>&PLOG', "$command" );
 
447
                if (!$pid) {
 
448
                        print PLOG "Can't open pipe to $conf::apt_cache: $!\n";
 
449
                        return ("ERROR");
 
450
                }
 
451
                {
 
452
                        local($/) = "";
 
453
                        my $package;
 
454
                        my $ver;
 
455
                        my $tfile;
482
456
                        while( <PIPE> ) {
483
 
                                print PLOG $_;
484
 
                        }
485
 
                        close( PIPE );
486
 
                        if ($?) {
487
 
                                print PLOG "$conf::apt_get for sources failed\n";
488
 
                                return( "ERROR", @made );
489
 
                        }
490
 
                        # touch the downloaded files, otherwise buildd-watcher
491
 
                        # will complain that they're old :)
492
 
                        $$dscfile_ref = $dscfile = (grep { /\.dsc$/ } @made)[0];
493
 
                }
 
457
                                $package = $1 if /^Package:\s+(\S+)\s*$/mi;
 
458
                                $ver = $1 if /^Version:\s+(\S+)\s*$/mi;
 
459
                                $tfile = $1 if /^Files:\s*\n((\s+.*\s*\n)+)/mi;
 
460
                                if (defined $package && defined $ver && defined $tfile) {
 
461
                                        @{$entries{"$package $ver"}} = map { (split( /\s+/, $_ ))[3] }
 
462
                                                split( "\n", $tfile );
 
463
                                        undef($package);
 
464
                                        undef($ver);
 
465
                                        undef($tfile);
 
466
                                }
 
467
                        }
 
468
 
 
469
                        if (! scalar keys %entries) {
 
470
                                print PLOG "$conf::apt_cache returned no information about $pkg source\n";
 
471
                                print PLOG "Are there any deb-src lines in your /etc/apt/sources.list?\n";
 
472
                                return ("ERROR");
 
473
 
 
474
                        }
 
475
                }
 
476
                close(PIPE);
 
477
                waitpid $pid, 0;
 
478
                if ($?) {
 
479
                        print PLOG "$conf::apt_cache failed\n";
 
480
                        return ("ERROR");
 
481
                }
 
482
 
 
483
                if (!defined($entries{"$pkg $version"})) {
 
484
                        if (!$retried) {
 
485
                                # try to update apt's cache if nothing found
 
486
                                run_apt_command("$conf::apt_get", "update >/dev/null", "root", 0);
 
487
                                $retried = 1;
 
488
                                goto retry;
 
489
                        }
 
490
                        print PLOG "Can't find source for ${pkg}_${version}\n";
 
491
                        print PLOG "(only different version(s) ",
 
492
                                join( ", ", sort keys %entries), " found)\n"
 
493
                                        if %entries;
 
494
                        return( "ERROR" );
 
495
                }
 
496
 
 
497
                print PLOG "Fetching source files...\n";
 
498
                foreach (@{$entries{"$pkg $version"}}) {
 
499
                        push(@made, "$main::chroot_build_dir/$_");
 
500
                }
 
501
 
 
502
                my $command2 = get_apt_command("$conf::apt_get", "--only-source -q -d source $pkg=$version 2>&1 </dev/null", $main::username, 0);
 
503
                if (!open( PIPE, "$command2 |" )) {
 
504
                        print PLOG "Can't open pipe to $conf::apt_get: $!\n";
 
505
                        return ("ERROR", @made);
 
506
                }
 
507
                while( <PIPE> ) {
 
508
                        print PLOG $_;
 
509
                }
 
510
                close( PIPE );
 
511
                if ($?) {
 
512
                        print PLOG "$conf::apt_get for sources failed\n";
 
513
                        return( "ERROR", @made );
 
514
                }
 
515
                # touch the downloaded files, otherwise buildd-watcher
 
516
                # will complain that they're old :)
 
517
                $$dscfile_ref = (grep { /\.dsc$/ } @made)[0];
494
518
        }
495
519
 
496
 
        if (verify_md5sums(dsc_md5sums($dscfile))) {
 
520
        if (verify_md5sums(dsc_md5sums("${main::chroot_build_dir}/${dscbase}"))) {
497
521
                print PLOG "FAILED [dsc verification]\n";
498
522
                return( "ERROR", @made );
499
523
        }
500
524
 
501
 
        if (!open( F, "<$dscfile" )) {
502
 
                print PLOG "Can't open $dscfile: $!\n";
 
525
        if (!open( F, "<${main::chroot_build_dir}/${dscbase}" )) {
 
526
                print PLOG "Can't open ${main::chroot_build_dir}/${dscbase}: $!\n";
503
527
                return( "ERROR", @made );
504
528
        }
505
529
        my $dsctext;
546
570
        merge_pkg_build_deps( $pkg, $build_depends, $build_depends_indep,
547
571
                              $build_conflicts, $build_conflicts_indep );
548
572
 
549
 
        if ($main::build_source) {
550
 
                @made = "";
551
 
                if ($orig && $main::chroot_build_dir) {
552
 
                        system ("cp $orig $main::chroot_build_dir") 
553
 
                                and print PLOG "ERROR: Could not copy $orig to $main::chroot_build_dir \n";
554
 
                        push(@made, "$main::chroot_build_dir$orig");
555
 
                }
556
 
        }
557
 
 
558
 
 
559
573
        return @made;
560
574
}
561
575
 
563
577
        my $dsc = shift;
564
578
        my $pkgv = shift;
565
579
        my( $dir, $rv, $changes );
566
 
        my $do_apply_patches = 1;
567
580
        local( *PIPE, *F, *F2 );
568
581
 
569
582
        fixup_pkgv( \$pkgv );
577
590
        my $tmpunpackdir = $dsc;
578
591
        $tmpunpackdir =~ s/-.*$/.orig.tmp-nest/;
579
592
        $tmpunpackdir =~ s/_/-/;
580
 
        $tmpunpackdir = "$main::chroot_build_dir$tmpunpackdir";
 
593
        $tmpunpackdir = "$main::chroot_build_dir/$tmpunpackdir";
581
594
        
582
 
        if (-d "$main::chroot_build_dir$dsc" && -l "$main::chroot_build_dir$dsc") {
 
595
        if (-d "$main::chroot_build_dir/$dsc" && -l "$main::chroot_build_dir/$dsc") {
583
596
                # if the package dir already exists but is a symlink, complain
584
597
                print PLOG "Cannot unpack source: a symlink to a directory with the\n",
585
598
                                   "same name already exists.\n";
586
599
                return 0;
587
600
        }
588
 
        if (! -d "$main::chroot_build_dir$dsc") {
 
601
        if (! -d "$main::chroot_build_dir/$dsc") {
589
602
                $main::pkg_fail_stage = "unpack";
590
603
                # dpkg-source refuses to remove the remanants of an
591
604
                # aborted dpkg-source extraction, so we will if necessary.
592
605
                if (-d $tmpunpackdir) {
593
 
                    system ("rm -fr $tmpunpackdir");
 
606
                    system ("rm -fr '$tmpunpackdir'");
594
607
                }
595
608
                $main::sub_pid = open( PIPE, "-|" );
596
609
                if (!defined $main::sub_pid) {
598
611
                        return 0;
599
612
                }
600
613
                if ($main::sub_pid == 0) {
601
 
                        if ($main::chroot_build_dir && !chdir( $main::chroot_build_dir )) {
602
 
                                print PLOG "Couldn't cd to $main::chroot_build_dir: $!\n";
603
 
                                system ("rm -fr $tmpunpackdir") if -d $tmpunpackdir;
604
 
                                exit 1;
605
 
                        }
606
 
                        exec_command("$conf::dpkg_source -sn -x $main::cwd/$dsc 2>&1", $main::username, 0, 0);
 
614
                        exec_command("$conf::dpkg_source -sn -x $dsc 2>&1", $main::username, 1, 0);
607
615
                }
608
616
                $main::sub_task = "dpkg-source";
609
617
                
618
626
                if ($?) {
619
627
                        print PLOG "FAILED [dpkg-source died]\n";
620
628
                
621
 
                    system ("rm -fr $tmpunpackdir") if -d $tmpunpackdir;
 
629
                    system ("rm -fr '$tmpunpackdir'") if -d $tmpunpackdir;
622
630
                        return 0;
623
631
                }
624
632
                if (!$dir) {
625
633
                        print PLOG "Couldn't find directory of $dsc in dpkg-source output\n";
626
 
                    system ("rm -fr $tmpunpackdir") if -d $tmpunpackdir;
 
634
                    system ("rm -fr '$tmpunpackdir'") if -d $tmpunpackdir;
627
635
                        return 0;
628
636
                }
629
 
                $dir = "$main::chroot_build_dir$dir";
 
637
                $dir = "$main::chroot_build_dir/$dir";
630
638
 
631
639
                if (system( "chmod -R g-s,go+rX $dir" ) != 0) {
632
640
                        print PLOG "chmod -R g-s,go+rX $dir failed.\n";
633
641
                        return 0;
634
642
                }
635
 
                
636
 
                if (@main::have_dsc_build_deps && !defined $main::build_source) {
637
 
                        my ($d, $di, $c, $ci) = @main::have_dsc_build_deps;
638
 
                        open( F, ">$dir/debian/.sbuild-build-deps" );
639
 
                        print F "Package: $pkg\n";
640
 
                        print F "Build-Depends: $d\n" if $d;
641
 
                        print F "Build-Depends-Indep: $di\n" if $di;
642
 
                        print F "Build-Conflicts: $c\n" if $c;
643
 
                        print F "Build-Conflicts-Indep: $ci\n" if $ci;
644
 
                        close( F );
645
 
                }
646
643
        }
647
644
        else {
648
 
                $dir = "$main::chroot_build_dir$dsc";
649
 
                $do_apply_patches = 0;
 
645
                $dir = "$main::chroot_build_dir/$dsc";
650
646
 
651
647
                $main::pkg_fail_stage = "check-unpacked-version";
652
648
                # check if the unpacked tree is really the version we need
656
652
                        return 0;
657
653
                }
658
654
                if ($main::sub_pid == 0) {
659
 
                        chdir( $dir );
660
 
                        exec_command("dpkg-parsechangelog 2>&1", $main::username, 0, 0);
 
655
                        $dir = strip_chroot_path($dir);
 
656
                        exec_command("cd '$dir' && dpkg-parsechangelog 2>&1", $main::username, 1, 0);
661
657
                }
662
658
                $main::sub_task = "dpkg-parsechangelog";
663
659
 
687
683
 
688
684
        if (!chdir( $dir )) {
689
685
                print PLOG "Couldn't cd to $dir: $!\n";
690
 
                system ("rm -fr $tmpunpackdir") if -d $tmpunpackdir;
 
686
                system ("rm -fr '$tmpunpackdir'") if -d $tmpunpackdir;
691
687
                return 0;
692
688
        }
693
689
 
694
690
        $main::pkg_fail_stage = "check-space";
695
 
        my $current_usage = `/usr/bin/du -s .`;
 
691
        my $current_usage = `/usr/bin/du -k -s .`;
696
692
        $current_usage =~ /^(\d+)/;
697
693
        $current_usage = $1;
698
694
        if ($current_usage) {
702
698
                                           "(Source needs $current_usage KB, free are $free KB.)\n";
703
699
                        print PLOG "Purging $dir\n";
704
700
                        chdir( $main::cwd );
705
 
                        my $bdir = $dir;
706
 
                        $bdir =~ s/^\Q$main::chroot_dir\E//;
707
 
                        run_command("rm -rf $bdir", "root", 1, 0);
 
701
                        my $bdir = strip_chroot_path($dir);
 
702
                        run_command("rm -rf '$bdir'", "root", 1, 0);
708
703
                        return 0;
709
704
                }
710
705
        }
720
715
                        $firstline =~ /^(\S+)\s+\((\S+)\)\s+([^;]+)\s*;\s*urgency=(\S+)\s*$/;
721
716
                        my ($name, $version, $dists, $urgent) = ($1, $2, $3, $4);
722
717
                        my $NMUversion = binNMU_version($version,$main::binNMUver);
723
 
                        chomp( my $date = `822-date` );
 
718
                        chomp( my $date = `date -R` );
724
719
                        if (!open( F, ">debian/changelog" )) {
725
720
                                print PLOG "Can't open debian/changelog for binNMU hack: $!\n";
726
721
                                chdir( $main::cwd );
735
730
 
736
731
                        print F $firstline, $text;
737
732
                        close( F );
738
 
                        system "touch debian/.sbuild-binNMU-done";
 
733
                        system "touch 'debian/.sbuild-binNMU-done'";
739
734
                        print PLOG "*** Created changelog entry for bin-NMU version $NMUversion\n";
740
735
                }
741
736
                else {
742
737
                        print PLOG "Can't open debian/changelog -- no binNMU hack!\n";
743
738
                }
744
739
        }
745
 
        
746
 
        if ($do_apply_patches) {
747
 
                if (!apply_patches( $pkg )) {
748
 
                        chdir( $main::cwd );
749
 
                        return 0;
750
 
                }
751
 
        }
752
 
        
 
740
 
753
741
        if (-f "debian/files") {
754
742
                local( *FILES );
755
743
                my @lines;
792
780
                setsid;
793
781
                my $binopt = $main::build_source ?
794
782
                        $conf::force_orig_source ? "-sa" : "" :
795
 
                        $main::build_arch_all ? "-b" : "-B";
 
783
                                $main::build_arch_all ? "-b" : "-B";
796
784
 
797
 
                if ($main::chroot_dir) {
798
 
                        my $bdir = $dir;
799
 
                        $bdir =~ s/^\Q$main::chroot_dir\E//;
800
 
                        if (-f "$main::chroot_dir/etc/ld.so.conf" &&
801
 
                            ! -r "$main::chroot_dir/etc/ld.so.conf") {
802
 
                                run_command("chmod a+r /etc/ld.so.conf", "root", 1, 0);
803
 
                                print PLOG "ld.so.conf was not readable! Fixed.\n";
804
 
                        }
805
 
                        chdir( $main::cwd ); # schroot doesn't need to be in $dir, and this quells a harmless warning
806
 
                        my $buildcmd = "cd $bdir && PATH=$conf::path ".
807
 
                                (defined($main::ld_library_path) ?
808
 
                                 "LD_LIBRARY_PATH=".$main::ld_library_path." " : "").
 
785
                my $bdir = strip_chroot_path($dir);
 
786
                if (-f "$main::chroot_dir/etc/ld.so.conf" &&
 
787
                    ! -r "$main::chroot_dir/etc/ld.so.conf") {
 
788
                        run_command("chmod a+r /etc/ld.so.conf", "root", 1, 0);
 
789
                        print PLOG "ld.so.conf was not readable! Fixed.\n";
 
790
                }
 
791
                chdir( $main::cwd ); # schroot doesn't need to be in $dir, and this quells a harmless warning
 
792
                my $buildcmd = "cd $bdir && PATH=$conf::path ".
 
793
                        (defined($main::ld_library_path) ?
 
794
                         "LD_LIBRARY_PATH=".$main::ld_library_path." " : "").
809
795
                                 "exec $conf::build_env_cmnd dpkg-buildpackage $conf::pgp_options ".
810
 
                                 "$binopt $main::dpkg_buildpackage_signopt -r$conf::fakeroot 2>&1";
811
 
                        exec_command($buildcmd, $main::username, 1, 0);
812
 
                }
813
 
                else {
814
 
                        if (-f "/etc/ld.so.conf" && ! -r "/etc/ld.so.conf") {
815
 
                                run_command("chmod a+r /etc/ld.so.conf", "root", 0, 0);
816
 
                                print PLOG "ld.so.conf was not readable! Fixed.\n";
817
 
                        }
818
 
                        exec_command("$conf::build_env_cmnd dpkg-buildpackage $conf::pgp_options $binopt ".
819
 
                                     "$main::dpkg_buildpackage_signopt -r$conf::fakeroot 2>&1", $main::username, 0, 1);
820
 
                }
 
796
                                         "$binopt $main::dpkg_buildpackage_signopt -r$conf::fakeroot 2>&1";
 
797
                exec_command($buildcmd, $main::username, 1, 0);
821
798
        }
822
799
        $main::sub_task = "dpkg-buildpackage";
823
800
 
872
849
                        my @files = debian_files_list("$dir/debian/files");
873
850
 
874
851
                        foreach (@files) {
875
 
                                if (! -f "$main::chroot_build_dir$_") {
 
852
                                if (! -f "$main::chroot_build_dir/$_") {
876
853
                                        print PLOG "ERROR: Package claims to have built ".basename($_).", but did not.  This is a bug in the packaging.\n";
877
854
                                        next;
878
855
                                }
879
856
                                if (/_all.u?deb$/ and not $main::build_arch_all) {
880
857
                                        print PLOG "ERROR: Package builds ".basename($_)." when binary-indep target is not called.  This is a bug in the packaging.\n";
881
 
                                        unlink("$main::chroot_build_dir$_");
 
858
                                        unlink("$main::chroot_build_dir/$_");
882
859
                                        next;
883
860
                                }
884
861
                        }
888
865
                        ($main::binNMU ? binNMU_version($sversion,$main::binNMUver) : $sversion).
889
866
                        "_$main::arch.changes";
890
867
                my @cfiles;
891
 
                if (-r "$main::chroot_build_dir$changes") {
 
868
                if (-r "$main::chroot_build_dir/$changes") {
892
869
                        my(@do_dists, @saved_dists);
893
870
                        print PLOG "\n$changes:\n";
894
 
                        open( F, "<$main::chroot_build_dir$changes" );
 
871
                        open( F, "<$main::chroot_build_dir/$changes" );
895
872
                        if (open( F2, ">$changes.new" )) {
896
873
                                while( <F> ) {
897
874
                                        if (/^Distribution:\s*(.*)\s*$/ and $main::override_distribution) {
916
893
                                rename( "$changes.new", "$changes" )
917
894
                                        or print PLOG "$changes.new could not be renamed ".
918
895
                                                                  "to $changes: $!\n";
919
 
                                unlink( "$main::chroot_build_dir$changes" )
 
896
                                unlink( "$main::chroot_build_dir/$changes" )
920
897
                                        if $main::chroot_build_dir;
921
898
                        }
922
899
                        else {
923
900
                                print PLOG "Cannot create $changes.new: $!\n";
924
901
                                print PLOG "Distribution field may be wrong!!!\n";
925
902
                                if ($main::chroot_build_dir) {
926
 
                                        system "mv", "$main::chroot_build_dir$changes", "."
 
903
                                        system "mv", "$main::chroot_build_dir/$changes", "."
927
904
                                                and print PLOG "ERROR: Could not move ".basename($_)." to .\n";
928
905
                                }
929
906
                        }
935
912
 
936
913
                my @debcfiles = @cfiles;
937
914
                foreach (@debcfiles) {
938
 
                        my $deb = "$main::chroot_build_dir$_";
 
915
                        my $deb = "$main::chroot_build_dir/$_";
939
916
                        next if $deb !~ /($main::arch|all)\.[\w\d.-]*$/;
940
917
 
941
918
                        print PLOG "\n$deb:\n";
950
927
 
951
928
                @debcfiles = @cfiles;
952
929
                foreach (@debcfiles) {
953
 
                        my $deb = "$main::chroot_build_dir$_";
 
930
                        my $deb = "$main::chroot_build_dir/$_";
954
931
                        next if $deb !~ /($main::arch|all)\.[\w\d.-]*$/;
955
932
 
956
933
                        print PLOG "\n$deb:\n";
965
942
 
966
943
                foreach (@cfiles) {
967
944
                        push( @space_files, $_ );
968
 
                        system "mv", "$main::chroot_build_dir$_", "."
 
945
                        system "mv", "$main::chroot_build_dir/$_", "."
969
946
                                and print PLOG "ERROR: Could not move $_ to .\n";
970
947
                }
971
948
                print PLOG "\n";
979
956
        if ($conf::purge_build_directory eq "always" ||
980
957
                ($conf::purge_build_directory eq "successful" && $rv == 0)) {
981
958
                print PLOG "Purging $dir\n";
982
 
                my $bdir = $dir;
983
 
                $bdir =~ s/^\Q$main::chroot_dir\E//;
984
 
                run_command("rm -rf $bdir", "root", 1, 0);
 
959
                my $bdir = strip_chroot_path($dir);
 
960
                run_command("rm -rf '$bdir'", "root", 1, 0);
985
961
        }
986
962
        
987
963
        print PLOG "-"x78, "\n";
988
964
        return $rv == 0 ? 1 : 0;
989
965
}
990
966
 
991
 
sub apply_patches {
992
 
        my $pkg = shift;
993
 
        my $name;
994
 
        
995
 
        $main::pkg_fail_stage = "apply-patch";
996
 
        foreach $name ((map { $_->{'Package'} } @{$main::deps{$pkg}}),
997
 
                                   @main::global_patches) {
998
 
                if ($name =~ /^\*/ && exists $main::specials{$name}->{'patch'}) {
999
 
                        if (exists $main::specials{$name}->{'patchcond'}) {
1000
 
                                print "Testing condition for $name patch:\n"
1001
 
                                        if $conf::debug;
1002
 
                                if (run_script("+e",$main::specials{$name}->{'patchcond'})!=0){
1003
 
                                        print PLOG "Condition for $name patch not true -- ",
1004
 
                                                                "not applying\n" if $name !~ /^\*\*/;
1005
 
                                        next;
1006
 
                                }
1007
 
                                print PLOG "Condition for $name patch ok\n";
1008
 
                        }
1009
 
                        print PLOG "Applying $name patch\n";
1010
 
                        $main::sub_pid = open( PIPE, "|-" );
1011
 
                        if (!defined $main::sub_pid) {
1012
 
                                print PLOG "Can't spawn patch: $! -- can't patch\n";
1013
 
                                return 0;
1014
 
                        }
1015
 
                        if ($main::sub_pid == 0) {
1016
 
                                open( STDOUT, ">&PLOG" );
1017
 
                                open( STDERR, ">&PLOG" );
1018
 
                                exec_command("patch --batch --quiet -p1 -E -N --no-backup-if-mismatch", $main::username, 0, 0);
1019
 
                        }
1020
 
                        $main::sub_task = "patch";
1021
 
 
1022
 
                        print PIPE $main::specials{$name}->{'patch'};
1023
 
                        close( PIPE );
1024
 
                        undef $main::sub_pid;
1025
 
                        if ($name !~ /^\*\*/ && $?) {
1026
 
                                print PLOG "FAILED [patch died]\n";
1027
 
                                return 0;
1028
 
                        }
1029
 
                }
1030
 
        }
1031
 
        return 1;
1032
 
}
1033
 
 
1034
967
sub analyze_fail_stage {
1035
968
        my $pkgv = shift;
1036
969
        
1075
1008
 
1076
1009
sub install_deps {
1077
1010
        my $pkg = shift;
1078
 
        my( @positive, @negative, @special, @instd, @rmvd );
 
1011
        my( @positive, @negative, @instd, @rmvd );
1079
1012
 
1080
1013
        my $dep = [];
1081
1014
        if (exists $main::deps{$pkg}) {
1089
1022
        lock_file( "$main::ilock_file", 1 );
1090
1023
        
1091
1024
        print "Filtering dependencies\n" if $conf::debug;
1092
 
        if (!filter_dependencies( $dep, \@positive, \@negative, \@special )) {
 
1025
        if (!filter_dependencies( $dep, \@positive, \@negative )) {
1093
1026
                print PLOG "Package installation not possible\n";
1094
1027
                unlock_file( "$main::ilock_file" );
1095
1028
                return 0;
1104
1037
        # add negative deps as to be removed for checking srcdep conflicts
1105
1038
        push( @rmvd, @negative );
1106
1039
        my @confl;
1107
 
        if (@confl = check_srcdep_conflicts( \@instd, \@rmvd, \@special )) {
 
1040
        if (@confl = check_srcdep_conflicts( \@instd, \@rmvd )) {
1108
1041
                print PLOG "Waiting for job(s) @confl to finish\n";
1109
1042
 
1110
1043
                unlock_file( "$main::ilock_file" );
1112
1045
                goto repeat;
1113
1046
        }
1114
1047
        
1115
 
        write_srcdep_lock_file( $dep, \@special );
1116
 
        
1117
 
        foreach my $sp (@special) {
1118
 
                next if $sp !~ /^\*/ || !exists $main::specials{$sp}->{'prepre'};
1119
 
                print PLOG "Running prepre script for $sp\n";
1120
 
                if (run_script( "-e", $main::specials{$sp}->{'prepre'} ) != 0) {
1121
 
                        print PLOG "prepre script of special dependency $sp failed\n";
1122
 
                        unlock_file( "$main::ilock_file" );
1123
 
                        return 0;
1124
 
                }
1125
 
        }
 
1048
        write_srcdep_lock_file( $dep );
1126
1049
 
1127
1050
        my $install_start_time = time;
1128
1051
        print "Installing positive dependencies: @positive\n" if $conf::debug;
1164
1087
                return 0;
1165
1088
        }
1166
1089
 
1167
 
        foreach my $sp (@special) {
1168
 
                next if $sp !~ /^\*/ ||
1169
 
                            (!exists $main::specials{$sp}->{'pre'} &&
1170
 
                             !exists $main::specials{$sp}->{'post'} &&
1171
 
                             !exists $main::specials{$sp}->{'unpack'});
1172
 
                if (exists $main::specials{$sp}->{'unpack'}) {
1173
 
                        my $s = $main::specials{$sp}->{'unpack'};
1174
 
                        $s =~ s/^\s+//mg;
1175
 
                        $s =~ s/\s+$//mg;
1176
 
                        my @s = split( /\s+/, $s );
1177
 
                        my @rem;
1178
 
                        print PLOG "Unpacking special sources $sp: @s\n";
1179
 
                        if (!(@rem = unpack_special_source( @s ))) {
1180
 
                                print PLOG "unpacking of special dependency sources for $sp failed\n";
1181
 
                                unlock_file( "$main::ilock_file" );
1182
 
                                return 0;
1183
 
                        }
1184
 
                        $main::changes->{'unpacked'}->{$sp} = \@rem;
1185
 
                }
1186
 
                if (exists $main::specials{$sp}->{'pre'}) {
1187
 
                        print PLOG "Running pre script for $sp\n";
1188
 
                        $main::changes->{'specials'}->{$sp} = 1;
1189
 
                        if (run_script( "-e", $main::specials{$sp}->{'pre'} ) != 0) {
1190
 
                                print PLOG "pre script of special dependency $sp failed\n";
1191
 
                                unlock_file( "$main::ilock_file" );
1192
 
                                return 0;
1193
 
                        }
1194
 
                }
1195
 
        }
1196
 
        
1197
1090
        local (*F);
1198
1091
 
1199
1092
        my $command = get_command("$conf::dpkg --set-selections", "root", 1);
1216
1109
        return 1;
1217
1110
}
1218
1111
 
1219
 
sub unpack_special_source {
1220
 
        my @s = @_;
1221
 
        my (@files, @dirs);
1222
 
        local (*PIPE);
1223
 
 
1224
 
        foreach my $s (@s) {
1225
 
                my $dsc;
1226
 
 
1227
 
                {
1228
 
                        my $command = get_apt_command("$conf::apt_get", "--only-source -q -d source $s 2>&1 </dev/null", $main::username, 0);
1229
 
                        if (!open( PIPE, "$command |" )) {
1230
 
                                print PLOG "Can't open pipe to apt-get: $!\n";
1231
 
                                goto failed;
1232
 
                        }
1233
 
                        while( <PIPE> ) {
1234
 
                                $dsc = "$1_$2.dsc" if /(\S+) (?:[^:]+:)?(\S+) \(dsc\)/;
1235
 
                                print PLOG $_;
1236
 
                        }
1237
 
                        close( PIPE );
1238
 
                        if ($?) {
1239
 
                                print PLOG "Apt-get of special unpack sources failed\n";
1240
 
                                goto failed;
1241
 
                        }
1242
 
                        push( @files, $dsc );
1243
 
                        if (!open( F, "<$dsc" )) {
1244
 
                                print PLOG "Can't open $dsc: $!\n";
1245
 
                                goto failed;
1246
 
                        }
1247
 
                        my $dsctext;
1248
 
                        { local($/); $dsctext = <F>; }
1249
 
                        close( F );
1250
 
                        my $files;
1251
 
                        $dsctext =~ /^Files:\s*\n((\s+.*\s*\n)+)/mi and $files = $1;
1252
 
                        push(@files, map { (split( /\s+/, $_ ))[3] } split( "\n", $files ));
1253
 
                }
1254
 
 
1255
 
                my $pid = open( PIPE, "-|" );
1256
 
                if (!defined $pid) {
1257
 
                        print PLOG "Can't spawn dpkg-source: $! -- special unpack failed\n";
1258
 
                        goto failed;
1259
 
                }
1260
 
                if ($pid == 0) {
1261
 
                        if ($main::chroot_build_dir && !chdir( $main::chroot_build_dir )) {
1262
 
                                print PLOG "Couldn't cd to $main::chroot_build_dir: $! -- special unpack failed\n";
1263
 
                                exit 1;
1264
 
                        }
1265
 
                        exec_command("$conf::dpkg_source -sn -x $main::cwd/$dsc 2>&1", $main::username, 0);
1266
 
                }
1267
 
                my $dir;
1268
 
                while( <PIPE> ) {
1269
 
                        print PLOG $_;
1270
 
                        $dir = $1 if /^dpkg-source: extracting \S+ in (\S+)/;
1271
 
                }
1272
 
                close( PIPE );
1273
 
                if ($?) {
1274
 
                        print PLOG "dpkg-source failure -- special unpack failed\n";
1275
 
                        goto failed;
1276
 
                }
1277
 
                push( @dirs, "$main::chroot_build_dir$dir" );
1278
 
                unlink( @files );
1279
 
        }
1280
 
 
1281
 
        return @dirs;
1282
 
        
1283
 
  failed:
1284
 
        unlink( @files );
1285
 
        system( "rm", "-rf", @dirs );
1286
 
        return ();
1287
 
}
1288
 
        
1289
1112
sub wait_for_srcdep_conflicts {
1290
1113
        my @confl = @_;
1291
1114
        
1371
1194
        return $? == 0;
1372
1195
}
1373
1196
 
1374
 
sub undo_specials {
1375
 
        my $sp;
1376
 
 
1377
 
        print "Running post scripts of special dependencies:\n" if $conf::debug;
1378
 
        foreach $sp (keys %{$main::changes->{'specials'}}) {
1379
 
                print PLOG "Running post script for $sp\n";
1380
 
                if (run_script( "-e", $main::specials{$sp}->{'post'} ) != 0) {
1381
 
                        print PLOG "post script of special dependency $sp failed\n";
1382
 
                }
1383
 
                delete $main::changes->{'specials'}->{$sp};
1384
 
        }
1385
 
        foreach $sp (keys %{$main::changes->{'unpacked'}}) {
1386
 
                my @dirs = @{$main::changes->{'unpacked'}->{$sp}};
1387
 
                print PLOG "Removing special unpacked sources for $sp: @dirs\n";
1388
 
                system "rm", "-rf", @dirs;
1389
 
                delete $main::changes->{'unpacked'}->{$sp};
1390
 
        }
1391
 
}
1392
 
 
1393
 
 
1394
1197
sub run_apt {
1395
1198
        my $mode = shift;
1396
1199
        my $inst_ret = shift;
1523
1326
        my $dependencies = shift;
1524
1327
        my $pos_list = shift;
1525
1328
        my $neg_list = shift;
1526
 
        my $special_list = shift;
1527
1329
        my($dep, $d, $name, %names);
1528
1330
 
1529
1331
        print PLOG "Checking for already installed source dependencies...\n";
1530
1332
        
1531
 
        @$pos_list = @$neg_list = @$special_list = ();
 
1333
        @$pos_list = @$neg_list = ();
1532
1334
        foreach $d (@$dependencies) {
1533
1335
                my $name = $d->{'Package'};
1534
1336
                $names{$name} = 1 if $name !~ /^\*/;
1547
1349
        foreach $dep (@$dependencies) {
1548
1350
                $name = $dep->{'Package'};
1549
1351
                next if !$name;
1550
 
                if ($name =~ /^\*/) {
1551
 
                        my $doit = 1;
1552
 
                        if (exists $main::specials{$name}->{'condition'}) {
1553
 
                                print "Testing condition for special dependency $name:\n"
1554
 
                                        if $conf::debug;
1555
 
                                if (run_script("+e",$main::specials{$name}->{'condition'})!=0){
1556
 
                                        print "Condition false -> not running scripts\n"
1557
 
                                                if $conf::debug;
1558
 
                                        $doit = 0;
1559
 
                                }
1560
 
                        }
1561
 
                        push( @$special_list, $name ) if $doit;
1562
 
                        next;
1563
 
                }
 
1352
 
1564
1353
                my $stat = $status->{$name};
1565
1354
                if ($dep->{'Neg'}) {
1566
1355
                        if ($stat->{'Installed'}) {
1802
1591
                                           "no Package: field\n";
1803
1592
                        next;
1804
1593
                }
1805
 
                print "$pkg ($version) status: $status\n" if $conf::debug >= 2;
 
1594
                if (defined($version)) {
 
1595
                        print "$pkg ($version) status: $status\n" if $conf::debug >= 2;
 
1596
                } else {
 
1597
                        print "$pkg status: $status\n" if $conf::debug >= 2;
 
1598
                }
1806
1599
                if (!$status) {
1807
1600
                        print PLOG "sbuild: parse error in $main::chroot_dir/var/lib/dpkg/status: ",
1808
1601
                                           "no Status: field for package $pkg\n";
1833
1626
        return \%result;
1834
1627
}
1835
1628
 
1836
 
sub run_script {
1837
 
        my $e_mode = shift;
1838
 
        my $x_mode = "";
1839
 
        my $script = shift;
1840
 
 
1841
 
        if ($conf::debug >= 2) {
1842
 
                $x_mode = "set -x -v\n";
1843
 
        }
1844
 
        elsif ($conf::debug)  {
1845
 
                print "Running script:\n  ",
1846
 
                join( "\n  ", split( "\n", "set $e_mode\n$script" )), "\n";
1847
 
        }
1848
 
        my $pid = fork();
1849
 
        if (!defined $pid) {
1850
 
                print PLOG "Can't fork: $! -- can't execute script\n";
1851
 
                return 1;
1852
 
        }
1853
 
        if ($pid == 0) {
1854
 
                open( STDOUT, ">&PLOG" );
1855
 
                open( STDERR, ">&PLOG" );
1856
 
                if ($main::chroot_dir) {
1857
 
                        exec_command("cd /build/$main::username && set $e_mode && $x_mode$script", $main::username, 1, 0);
1858
 
                } else {
1859
 
                        exec_command("set $e_mode && $x_mode$script", $main::username, 0, 0);
1860
 
                }
1861
 
                die "Can't exec /bin/sh: $!\n";
1862
 
        }
1863
 
        wait;
1864
 
        print "Script return value: $?\n" if $conf::debug;
1865
 
        return $?
1866
 
}
1867
 
 
1868
 
 
1869
 
sub read_deps {
1870
 
        my @for_pkgs = @_;
1871
 
        my $fname;
1872
 
        local( *F );
1873
 
 
1874
 
        open( F, $fname = "<$conf::source_dependencies-$main::distribution" )
1875
 
                or open( F, $fname = "<$conf::source_dependencies" )
1876
 
                or return;
1877
 
        $fname = substr( $fname, 1 );
1878
 
        print "Reading source dependencies from $fname\n"
1879
 
                if $conf::debug;
1880
 
        while( <F> ) {
1881
 
                chomp;
1882
 
                next if /^\s*$/ || /^\s*#/;
1883
 
                while( /\\$/ ) {
1884
 
                        chop;
1885
 
                        $_ .= <F>;
1886
 
                        chomp;
1887
 
                }
1888
 
                if (/^(\*\*?[\w\d.+-]+):\s*$/) {
1889
 
                        # is a special definition
1890
 
                        my $sp = $1;
1891
 
                        get_special( $fname, $sp, \*F );
1892
 
                        next;
1893
 
                }
1894
 
                if (/^abbrev\s+([\w\d.+-]+)\s*=\s*(.*)\s*$/) {
1895
 
                        my ($abbrev, $def) = ($1, $2);
1896
 
                        parse_one_srcdep( $abbrev, $def, \%main::abbrevs );
1897
 
                        next;
1898
 
                }
1899
 
                if (!/^([a-zA-Z\d.+-]+):\s*(.*)\s*$/) {
1900
 
                        warn "Syntax error in line $. in $fname\n";
1901
 
                        next;
1902
 
                }
1903
 
                my( $pkg, $deps ) = ($1, $2);
1904
 
                if (exists $main::deps{$pkg}) {
1905
 
                        warn "Ignoring double entry for package $pkg at line $. ".
1906
 
                                 "in $fname\n";
1907
 
                        next;
1908
 
                }
1909
 
                next if !isin( $pkg, @for_pkgs );
1910
 
                parse_one_srcdep( $pkg, $deps, \%main::deps );
1911
 
        }
1912
 
        close( F );
1913
 
 
1914
 
        foreach (@main::manual_srcdeps) {
1915
 
                if (!/^([fa])([a-zA-Z\d.+-]+):\s*(.*)\s*$/) {
1916
 
                        warn "Syntax error in manual source dependency: ",
1917
 
                                 substr( $_, 1 ), "\n";
1918
 
                        next;
1919
 
                }
1920
 
                my ($mode, $pkg, $deps) = ($1, $2, $3);
1921
 
                next if !isin( $pkg, @for_pkgs );
1922
 
                @{$main::deps{$pkg}} = () if $mode eq 'f';
1923
 
                parse_one_srcdep( $pkg, $deps, \%main::deps );
1924
 
        }
1925
 
 
1926
 
        # substitute abbrevs and warn about undefined special deps
1927
 
        my( $pkg, $i, %warned );
1928
 
        foreach $pkg (keys %main::deps) {
1929
 
          repeat:
1930
 
                my $dl = $main::deps{$pkg};
1931
 
                for( $i = 0; $i < @$dl; ++$i ) {
1932
 
                        my $dep = $dl->[$i];
1933
 
                        my $name = $dep->{'Package'};
1934
 
                        if ($name =~ /^\*/) {
1935
 
                                if (!$warned{$name} && !exists $main::specials{$name}) {
1936
 
                                        warn "Warning: $pkg: No definition for special ",
1937
 
                                                 "dependency $name!\n";
1938
 
                                        $warned{$name}++;
1939
 
                                }
1940
 
                        }
1941
 
                        elsif (defined $main::abbrevs{$name}) {
1942
 
                                my @l = @{$main::abbrevs{$name}};
1943
 
                                if (defined $dep->{'Alternatives'}) {
1944
 
                                        warn "Warning: $pkg: abbrev $name not allowed ",
1945
 
                                                 "in alternative\n";
1946
 
                                        @l = ();
1947
 
                                }
1948
 
                                if ($dep->{'Neg'}) {
1949
 
                                        warn "Warning: $pkg: Negation of abbrev $name ",
1950
 
                                                 "not allowed\n";
1951
 
                                        @l = ();
1952
 
                                }
1953
 
                                if ($dep->{'Rel'}) {
1954
 
                                        warn "Warning: $pkg: No relation with abbrev $name ",
1955
 
                                                 "allowed\n";
1956
 
                                        @l = ();
1957
 
                                }
1958
 
                                if (my $ov = $dep->{'Override'}) {
1959
 
                                        @l = map { my $x = copy($_);
1960
 
                                                           $x->{'Override'} = $ov; $x } @l;
1961
 
                                }
1962
 
                                splice @$dl, $i, 1, @l;
1963
 
                                goto repeat;
1964
 
                        }
1965
 
                        elsif (defined $dep->{'Alternatives'}) {
1966
 
                                my $alt;
1967
 
                                foreach $alt (@{$dep->{'Alternatives'}}) {
1968
 
                                        if (defined $main::abbrevs{$alt->{'Package'}}) {
1969
 
                                                warn "Warning: $pkg: abbrev $alt->{'Package'} not ",
1970
 
                                                         "allowed in alternative\n";
1971
 
                                                splice @$dl, $i, 1;
1972
 
                                        }
1973
 
                                }
1974
 
                        }
1975
 
                }
1976
 
        }
1977
 
}
1978
 
 
1979
1629
sub copy {
1980
1630
        my $r = shift;
1981
1631
        my $new;
2341
1991
                        s/^\&\s+//;
2342
1992
                }
2343
1993
                my @alts = split( /\s*\|\s*/, $_ );
2344
 
                my $special_seen = 0;
2345
1994
                my $neg_seen = 0;
2346
1995
                foreach (@alts) {
2347
1996
                        if (!/^([^\s([]+)\s*(\(\s*([<=>]+)\s*(\S+)\s*\))?(\s*\[([^]]+)\])?/) {
2367
2016
                                                 if $ignore_it && $use_it;
2368
2017
                                next if $ignore_it || ($include && !$use_it);
2369
2018
                        }
2370
 
                        if ($dep =~ /^\*/) {
2371
 
                                warn "Warning: $pkg: ignoring version relation on ".
2372
 
                                         "special dependency $dep\n"
2373
 
                                                 if $rel || $relv;
2374
 
                                push( @l, { Package => $dep, Override => 1 } );
2375
 
                                $special_seen = 1;
2376
 
                                next;
2377
 
                        }
2378
2019
                        my $neg = 0;
2379
2020
                        if ($dep =~ /^!/) {
2380
2021
                                $dep =~ s/^!\s*//;
2402
2043
                        $h->{'Override'} = $override if $override;
2403
2044
                        push( @l, $h );
2404
2045
                }
2405
 
                if (@alts > 1 && $special_seen) {
2406
 
                        warn "Warning: $pkg: alternatives with special dependencies ",
2407
 
                                 "forbidden -- skipped\n";
2408
 
                }
2409
 
                elsif (@alts > 1 && $neg_seen) {
 
2046
                if (@alts > 1 && $neg_seen) {
2410
2047
                        warn "Warning: $pkg: alternatives with negative dependencies ",
2411
2048
                                 "forbidden -- skipped\n";
2412
2049
                }
2420
2057
        }
2421
2058
}
2422
2059
 
2423
 
sub get_special {
2424
 
        my $fname = shift;
2425
 
        my $sp = shift;
2426
 
        my $sub = "";
2427
 
        
2428
 
        while( <F> ) {
2429
 
                last if /^$/;
2430
 
                if (/^\s*(\w+)\s*\{\s*$/) {
2431
 
                        if ($sub) {
2432
 
                                warn "Syntax error in line $. in $fname:\n";
2433
 
                                warn "  Start of special subsection inside ".
2434
 
                                        "another one.\n";
2435
 
                        }
2436
 
                        else {
2437
 
                                $sub = $1;
2438
 
                                $main::specials{$sp}->{$sub} = "";
2439
 
                        }
2440
 
                }
2441
 
                elsif (/^\s*\}\s*$/) {
2442
 
                        if (!$sub) {
2443
 
                                warn "Syntax error in line $. in $fname:\n";
2444
 
                                warn "  }  outside of special subsection\n";
2445
 
                        }
2446
 
                        else {
2447
 
                                $sub = "";
2448
 
                        }
2449
 
                }
2450
 
                elsif ($sub) {
2451
 
                        $main::specials{$sp}->{$sub} .= $_;
2452
 
                }
2453
 
                else {
2454
 
                        warn "Syntax error in line $. in $fname:\n";
2455
 
                        warn "  Subsection start expected\n";
2456
 
                }
2457
 
        }
2458
 
        if ($sub) {
2459
 
                warn "Syntax error in line $. in $fname:\n";
2460
 
                warn "  Subsection not finished with }\n";
2461
 
        }
2462
 
 
2463
 
        push( @main::global_patches, $sp ) if $sp =~ /^\*\*/;
2464
 
}
2465
 
 
2466
2060
sub check_space {
2467
2061
        my @files = @_;
2468
2062
        my $sum = 0;
2472
2066
                my $command;
2473
2067
 
2474
2068
                if (/^\Q$main::chroot_dir\E/) {
2475
 
                        $_ =~ s/^\Q$main::chroot_dir\E//;
2476
 
                        $command = get_command("/usr/bin/du -s $_ 2>/dev/null", "root", 1, 0);
 
2069
                        $_ = strip_chroot_path($_);
 
2070
                        $command = get_command("/usr/bin/du -k -s $_ 2>/dev/null", "root", 1, 0);
2477
2071
                } else {
2478
 
                        $command = get_command("/usr/bin/du -s $_ 2>/dev/null", $main::username, 0, 0);
 
2072
                        $command = get_command("/usr/bin/du -k -s $_ 2>/dev/null", $main::username, 0, 0);
2479
2073
                }
2480
2074
 
2481
2075
                if (!open( PIPE, "$command |" )) {
2538
2132
 
2539
2133
sub write_srcdep_lock_file {
2540
2134
        my $deps = shift;
2541
 
        my $specials = shift;
2542
2135
        local( *F );
2543
2136
 
2544
2137
        ++$main::srcdep_lock_cnt;
2554
2147
        print "Job $main::current_job pid $$ user $user\n" if $conf::debug;
2555
2148
        foreach (@$deps) {
2556
2149
                my $name = $_->{'Package'};
2557
 
                # add special deps only if they affect global state ("global" sub)
2558
 
                next if $name =~ /^\*/ &&
2559
 
                            (!isin( $name, @$specials ) ||
2560
 
                                 $main::specials{$name}->{'global'} !~ /yes/m);
2561
2150
                print F ($_->{'Neg'} ? "!" : ""), "$name\n";
2562
2151
                print "  ", ($_->{'Neg'} ? "!" : ""), "$name\n" if $conf::debug;
2563
2152
        }
2567
2156
sub check_srcdep_conflicts {
2568
2157
        my $to_inst = shift;
2569
2158
        my $to_remove = shift;
2570
 
        my $special = shift;
2571
2159
        local( *F, *DIR );
2572
2160
        my $mypid = $$;
2573
2161
        my %conflict_builds;
2607
2195
                        print "Found ", ($neg ? "neg " : ""), "entry $pkg\n"
2608
2196
                                if $conf::debug;
2609
2197
 
2610
 
                        if ($pkg =~ /^\*/) {
2611
 
                                print PLOG "Build of $job by $user (pid $pid) has ",
2612
 
                                                   "installed the global special dependency $pkg.\n";
 
2198
                        if (isin( $pkg, @$to_inst, @$to_remove )) {
 
2199
                                print PLOG "Source dependency conflict with build of ",
 
2200
                                        "$job by $user (pid $pid):\n";
 
2201
                                print PLOG "  $job ", ($neg ? "conflicts with" : "needs"),
 
2202
                                        " $pkg\n";
 
2203
                                print PLOG "  $main::current_job wants to ",
 
2204
                                        (isin( $pkg, @$to_inst ) ? "update" : "remove"),
 
2205
                                                " $pkg\n";
2613
2206
                                $conflict_builds{$file} = 1;
2614
2207
                        }
2615
 
                        else {
2616
 
                                if (isin( $pkg, @$to_inst, @$to_remove )) {
2617
 
                                        print PLOG "Source dependency conflict with build of ",
2618
 
                                                           "$job by $user (pid $pid):\n";
2619
 
                                        print PLOG "  $job ", ($neg ? "conflicts with" : "needs"),
2620
 
                                                           " $pkg\n";
2621
 
                                        print PLOG "  $main::current_job wants to ",
2622
 
                                                           (isin( $pkg, @$to_inst ) ? "update" : "remove"),
2623
 
                                                           " $pkg\n";
2624
 
                                        $conflict_builds{$file} = 1;
2625
 
                                }
2626
 
                        }
2627
2208
                }
2628
2209
                close( F );
2629
2210
        }
2630
2211
 
2631
 
        foreach (@$special) {
2632
 
                if ($main::specials{$_}->{'global'} =~ /yes/m) {
2633
 
                        print PLOG "$main::current_job wants to apply global ",
2634
 
                                           "special dependency $_\n",
2635
 
                                           "Must wait for other builds to finish\n";
2636
 
                        foreach (@files) {
2637
 
                                $conflict_builds{$_} = 1;
2638
 
                        }
2639
 
                }
2640
 
        }
2641
 
 
2642
2212
        my @conflict_builds = keys %conflict_builds;
2643
2213
        if (@conflict_builds) {
2644
2214
                print "Srcdep conflicts with: @conflict_builds\n" if $conf::debug;
2703
2273
                }
2704
2274
                if ($st[8] > $main::build_start_time) {
2705
2275
                        my $pkg = $main::this_watches{$prg};
2706
 
                        my $prg2 = $prg;
2707
 
                        $prg2 =~ s/^\Q$main::chroot_dir\E// if $main::chroot_dir;
 
2276
                        my $prg2 = strip_chroot_path($prg);
2708
2277
                        push( @{$used{$pkg}}, $prg2 )
2709
2278
                                if @main::have_dsc_build_deps ||
2710
2279
                                   !isin( $pkg, @conf::ignore_watches_no_build_deps );
3050
2619
        if (scalar keys %$exp_md5 > 0) {
3051
2620
 
3052
2621
                my @files = keys %$exp_md5;
3053
 
                # NOTE this is run outside the chroot, but in schroot
3054
 
                # mode the files are downloaded inside the chroot, and
3055
 
                # so this will break if the build directory is not
3056
 
                # bind mounted inside the chroot.
 
2622
 
3057
2623
                my $command = get_command("cd $main::cwd && $conf::md5sum @files </dev/null", $main::username, 0, 0);
3058
 
 
3059
2624
                open(OBS, "$command |") or return 1;
3060
2625
                while (<OBS>) {
3061
2626
                        chomp;
3104
2669
 
3105
2670
        return $chroot_arch;
3106
2671
}
 
2672
 
 
2673
sub check_group_membership {
 
2674
        my $user = getpwuid($<);
 
2675
        my ($name,$passwd,$gid,$members) = getgrnam("sbuild");
 
2676
 
 
2677
        if (!$gid) {
 
2678
                die "Group sbuild does not exist";
 
2679
        }
 
2680
 
 
2681
        my $in_group = 0;
 
2682
        foreach (split(' ', $members)) {
 
2683
                $in_group = 1 if $_ eq $main::username;
 
2684
        }
 
2685
 
 
2686
        if (!$in_group) {
 
2687
                print STDERR "User $user is not a member of group $name\n";
 
2688
                print STDERR "See \"User Setup\" in sbuild-setup(7)\n";
 
2689
                exit(1);
 
2690
        }
 
2691
 
 
2692
        return;
 
2693
}
 
2694
 
 
2695
sub dump_main_state {
 
2696
        print STDERR Data::Dumper->Dump([\@main::additional_deps,
 
2697
                                         $main::arch,
 
2698
                                         $main::auto_giveback,
 
2699
                                         $main::auto_giveback_host,
 
2700
                                         $main::auto_giveback_socket,
 
2701
                                         $main::auto_giveback_user,
 
2702
                                         $main::auto_giveback_wb_user,
 
2703
                                         $main::batchmode,
 
2704
                                         $main::binNMU,
 
2705
                                         $main::binNMU_name,
 
2706
                                         $main::binNMUver,
 
2707
                                         $main::build_arch_all,
 
2708
                                         $main::build_source,
 
2709
                                         $main::build_start_time,
 
2710
                                         $main::changes,
 
2711
                                         $main::chroot_build_dir,
 
2712
                                         $main::chroot_dir,
 
2713
                                         $main::current_job,
 
2714
                                         $main::cwd,
 
2715
                                         $main::database,
 
2716
                                         \%main::deps,
 
2717
                                         $main::DEVNULL,
 
2718
                                         $main::distribution,
 
2719
                                         $main::dpkg_buildpackage_signopt,
 
2720
                                         \@main::have_dsc_build_deps,
 
2721
                                         $main::ilock_file,
 
2722
                                         $main::jobs_file,
 
2723
                                         \%main::job_state,
 
2724
                                         $main::ld_library_path,
 
2725
                                         $main::lock_interval,
 
2726
                                         \@main::manual_srcdeps,
 
2727
                                         $main::max_lock_trys,
 
2728
                                         $main::override_distribution,
 
2729
                                         $main::pkg_end_time,
 
2730
                                         $main::pkg_fail_stage,
 
2731
                                         $main::pkg_start_time,
 
2732
                                         $main::pkg_status,
 
2733
                                         $main::shutdown,
 
2734
                                         $main::srcdep_lock_cnt,
 
2735
                                         $main::srcdep_lock_dir,
 
2736
                                         $main::stats_dir,
 
2737
                                         $main::sub_pid,
 
2738
                                         $main::sub_task,
 
2739
                                         $main::this_space,
 
2740
                                         \%main::this_watches,
 
2741
                                         \@main::toolchain_pkgs,
 
2742
                                         $main::username,
 
2743
                                         $main::useSNAP,
 
2744
                                         $main::verbose],
 
2745
                                         [qw(@main::additional_deps
 
2746
                                         $main::arch
 
2747
                                         $main::auto_giveback
 
2748
                                         $main::auto_giveback_host
 
2749
                                         $main::auto_giveback_socket
 
2750
                                         $main::auto_giveback_user
 
2751
                                         $main::auto_giveback_wb_user
 
2752
                                         $main::batchmode
 
2753
                                         $main::binNMU
 
2754
                                         $main::binNMU_name
 
2755
                                         $main::binNMUver
 
2756
                                         $main::build_arch_all
 
2757
                                         $main::build_source
 
2758
                                         $main::build_start_time
 
2759
                                         $main::changes
 
2760
                                         $main::chroot_build_dir
 
2761
                                         $main::chroot_dir
 
2762
                                         $main::current_job $main::cwd
 
2763
                                         $main::database %main::deps
 
2764
                                         $main::DEVNULL
 
2765
                                         $main::distribution
 
2766
                                         $main::dpkg_buildpackage_signopt
 
2767
                                         @main::have_dsc_build_deps
 
2768
                                         $main::ilock_file
 
2769
                                         $main::jobs_file
 
2770
                                         %main::job_state
 
2771
                                         $main::ld_library_path
 
2772
                                         $main::lock_interval
 
2773
                                         @main::manual_srcdeps
 
2774
                                         $main::max_lock_trys
 
2775
                                         $main::override_distribution
 
2776
                                         $main::pkg_end_time
 
2777
                                         $main::pkg_fail_stage
 
2778
                                         $main::pkg_start_time
 
2779
                                         $main::pkg_status
 
2780
                                         $main::shutdown
 
2781
                                         $main::srcdep_lock_cnt
 
2782
                                         $main::srcdep_lock_dir
 
2783
                                         $main::stats_dir
 
2784
                                         $main::sub_pid
 
2785
                                         $main::sub_task
 
2786
                                         $main::this_space
 
2787
                                         %main::this_watches
 
2788
                                         @main::toolchain_pkgs
 
2789
                                         $main::username
 
2790
                                         $main::useSNAP
 
2791
                                         $main::verbose)]
 
2792
                                       );
 
2793
}