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

« back to all changes in this revision

Viewing changes to bin/sbuild-hold

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
use Getopt::Long;
26
26
use Sbuild qw(help_text version_text usage_error);
 
27
use Sbuild::Conf;
27
28
use Sbuild::Utility qw(setup cleanup shutdown);
28
29
 
29
30
package main;
30
31
 
 
32
my $conf = Sbuild::Conf->new();
 
33
 
31
34
GetOptions (
32
35
    "h|help" => sub { help_text("1", "sbuild-hold"); },
33
36
    "V|version" => sub {version_text("sbuild-hold"); })
37
40
 
38
41
my $chroot = Sbuild::Utility::get_dist($ARGV[0]);
39
42
 
40
 
my $session = setup($ARGV[0]) or die "Chroot setup failed for $chroot chroot";
 
43
my $session = setup($ARGV[0], $conf) or die "Chroot setup failed for $chroot chroot";
41
44
 
42
45
print STDOUT "Holding packages in $chroot chroot:";
43
46
 
44
 
my $command = $session->get_command("$Sbuild::Conf::dpkg --set-selections",
45
 
                                    "root", 1);
46
 
if (!open(SELECTIONS, "| $command")) {
 
47
my $pipe = $session->pipe_command(
 
48
    {COMMAND => [$conf->get('DPKG'), '--set-selections'],
 
49
     PIPE => 'out',
 
50
     USER => 'root',
 
51
     CHROOT => 1,
 
52
     PRIORITY => 0});
 
53
 
 
54
if (!$pipe) {
47
55
    print STDERR "Can't run dpkg --set-selections in chroot\n";
48
56
    shutdown("TERM");
49
57
}
50
58
 
51
59
shift @ARGV;
52
60
foreach (@ARGV) {
53
 
    print SELECTIONS "$_        hold\n";
 
61
    print $pipe "$_        hold\n";
54
62
    print STDOUT " $_";
55
63
}
56
64
 
57
 
if (!close SELECTIONS) {
 
65
if (!close $pipe) {
58
66
    print STDERR "Can't run dpkg --set-selections in chroot\n";
59
67
    shutdown("TERM");
60
68
}
61
69
 
62
 
print STDOUT ".\n";
63
 
 
64
 
my $packages = join(" ", @ARGV);
65
 
my $status = $session->run_command("$Sbuild::Conf::dpkg --list $packages",
66
 
                                   "root", 1, 0);
67
 
 
68
 
cleanup();
 
70
print STDOUT ".\n\n";
 
71
 
 
72
$session->run_command(
 
73
    {COMMAND => [$conf->get('DPKG'), '--list', @ARGV],
 
74
     USER => 'root',
 
75
     CHROOT => 1,
 
76
     PRIORITY => 0});
 
77
my $status = $? >> 8;
 
78
 
 
79
cleanup($conf);
69
80
 
70
81
exit $status;