Package: sbuild
Version: 0.60.1-2
Severity: wishlist
Tags: patch
It would be helpful if one script (perhaps sbuild-update) were to be used to
perform apt-get update, upgrade, and/or dist-upgrade on an sbuild chroot. This
is especially helpful for those (like me) who use an sbuild chroot tarball.
This patch is from bug #545215. I've submitted a new bug with just this new
change since I thought this change alone would be easier to review.
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-5-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages sbuild depends on:
ii adduser 3.112 add and remove users and groups
ii libsbuild-perl 0.60.1-2 Tool for building Debian binary pa
ii perl 5.10.1-13 Larry Wall's Practical Extraction
ii perl-modules 5.10.1-13 Core Perl modules
Versions of packages sbuild recommends:
ii debootstrap 1.0.23 Bootstrap a basic Debian system
ii fakeroot 1.14.4-1 Gives a fake root environment
Versions of packages sbuild suggests:
pn deborphan <none> (no description available)
ii wget 1.12-2 retrieves files from the web
-- no debconf information
diff --git a/bin/sbuild-distupgrade b/bin/sbuild-distupgrade
index 5e8cad7..97abe03 100755
--- a/bin/sbuild-distupgrade
+++ b/bin/sbuild-distupgrade
@@ -21,33 +21,6 @@
use strict;
use warnings;
-use Getopt::Long;
-use Sbuild qw(help_text version_text usage_error);
-use Sbuild::Utility qw(setup cleanup);
-use Sbuild::ChrootSetup qw(distupgrade);
-use Sbuild::Conf;
-use Sbuild::OptionsBase;
-
-my $conf = Sbuild::Conf->new();
-exit 1 if !defined($conf);
-my $options = Sbuild::OptionsBase->new($conf, "sbuild-distupgrade", "1");
-exit 1 if !defined($options);
-$conf->check_group_membership();
-
-usage_error("sbuild-distupgrade", "Incorrect number of options") if (@ARGV < 1);
-
-foreach (@ARGV) {
-
- my $chroot = Sbuild::Utility::get_dist($_);
-
- my $session = setup($_, $conf) or die "Chroot setup failed for $chroot chroot";
-
- my $status = distupgrade($session, $conf);
- $status >>= 8;
-
- cleanup($conf);
-
- exit $status if ($status);
-}
-
-exit 0;
+print "$0 is deprecated. Use sbuild-update --dist-upgrade directly instead.\n";
+exec("/usr/bin/sbuild-update", "--dist-upgrade", @ARGV) or
+ die "Can't run sbuild-update: $!";
diff --git a/bin/sbuild-update b/bin/sbuild-update
index d6dac48..ab923d4 100755
--- a/bin/sbuild-update
+++ b/bin/sbuild-update
@@ -21,19 +21,90 @@
use strict;
use warnings;
+use Sbuild::ChrootSetup qw(update upgrade distupgrade);
+
+package Conf;
+
+use Sbuild::Conf;
+
+BEGIN {
+ use Exporter ();
+ our (@ISA, @EXPORT);
+
+ @ISA = qw(Exporter Sbuild::Conf);
+
+ @EXPORT = qw();
+}
+
+sub init_allowed_keys {
+ my $self = shift;
+
+ $self->SUPER::init_allowed_keys();
+
+ my %update_keys = (
+ 'UPDATE' => {
+ DEFAULT => 0
+ },
+ 'UPGRADE' => {
+ DEFAULT => 0
+ },
+ 'DISTUPGRADE' => {
+ DEFAULT => 0
+ },
+ );
+
+ $self->set_allowed_keys(\%update_keys);
+}
+
+package Options;
+
+use Sbuild::OptionsBase;
+use Sbuild::Conf;
+
+BEGIN {
+ use Exporter ();
+ our (@ISA, @EXPORT);
+
+ @ISA = qw(Exporter Sbuild::OptionsBase);
+
+ @EXPORT = qw();
+}
+
+sub set_options {
+ my $self = shift;
+
+ $self->add_options(
+ "update|u" => sub {
+ $self->set_conf('UPDATE', 1);
+ },
+ "upgrade|g" => sub {
+ $self->set_conf('UPGRADE', 1);
+ },
+ "dist-upgrade|d" => sub {
+ $self->set_conf('DISTUPGRADE', 1);
+ });
+}
+
+package main;
+
use Getopt::Long;
use Sbuild qw(help_text version_text usage_error);
use Sbuild::Utility qw(setup cleanup);
-use Sbuild::ChrootSetup qw(update);
-use Sbuild::Conf;
-use Sbuild::OptionsBase;
-my $conf = Sbuild::Conf->new();
+my $conf = Conf->new();
exit 1 if !defined($conf);
-my $options = Sbuild::OptionsBase->new($conf, "sbuild-update", "1");
+my $options = Options->new($conf, "sbuild-update", "1");
exit 1 if !defined($options);
$conf->check_group_membership();
+if ( ! $conf->get('UPDATE') && ! $conf->get('UPGRADE') &&
+ ! $conf->get('DISTUPGRADE') ) {
+ my $msg = "$0 will perform apt-get command 'update' now, however this ";
+ $msg .= "may change at a later revision.\n";
+ print "$msg";
+ $conf->set('UPDATE', 1);
+}
+
usage_error("sbuild-update", "Incorrect number of options") if (@ARGV < 1);
foreach (@ARGV) {
@@ -42,12 +113,34 @@ foreach (@ARGV) {
my $session = setup($ARGV[0], $conf) or die "Chroot setup failed";
- my $status = update($session, $conf);
- $status >>= 8;
+ if ($conf->get('UPDATE')) {
+ print "Performing update.\n";
+ my $status = update($session, $conf);
+ $status >>= 8;
+ if ($status) {
+ die "Exiting from update with status $status.\n";
+ }
+ }
- cleanup($conf);
+ if ($conf->get('UPGRADE')) {
+ print "Performing upgrade.\n";
+ my $status = upgrade($session, $conf);
+ $status >>= 8;
+ if ($status) {
+ die "Exiting from upgrade with status $status.\n";
+ }
+ }
- exit $status if ($status);
+ if ($conf->get('DISTUPGRADE')) {
+ print "Performing dist-upgrade.\n";
+ my $status = distupgrade($session, $conf);
+ $status >>= 8;
+ if ($status) {
+ die "Exiting from distupgrade with status $status.\n";
+ }
+ }
+
+ cleanup($conf);
}
exit 0;
diff --git a/bin/sbuild-upgrade b/bin/sbuild-upgrade
index 9017ad7..a25b62d 100755
--- a/bin/sbuild-upgrade
+++ b/bin/sbuild-upgrade
@@ -21,33 +21,6 @@
use strict;
use warnings;
-use Getopt::Long;
-use Sbuild qw(help_text version_text usage_error);
-use Sbuild::Utility qw(setup cleanup);
-use Sbuild::ChrootSetup qw(upgrade);
-use Sbuild::Conf;
-use Sbuild::OptionsBase;
-
-my $conf = Sbuild::Conf->new();
-exit 1 if !defined($conf);
-my $options = Sbuild::OptionsBase->new($conf, "sbuild-upgrade", "1");
-exit 1 if !defined($options);
-$conf->check_group_membership();
-
-usage_error("sbuild-upgrade", "Incorrect number of options") if (@ARGV < 1);
-
-foreach (@ARGV) {
-
- my $chroot = Sbuild::Utility::get_dist($_);
-
- my $session = setup($_, $conf) or die "Chroot setup failed for $chroot chroot";
-
- my $status = upgrade($session, $conf);
- $status >>= 8;
-
- cleanup($conf);
-
- exit $status if ($status);
-}
-
-exit 0;
+print "$0 is deprecated. Use sbuild-update --upgrade directly instead.\n";
+exec("/usr/bin/sbuild-update", "--upgrade", @ARGV) or
+ die "Can't run sbuild-update: $!";
diff --git a/man/sbuild-update.1.in b/man/sbuild-update.1.in
index 911de77..95e5adc 100644
--- a/man/sbuild-update.1.in
+++ b/man/sbuild-update.1.in
@@ -18,22 +18,27 @@
sbuild\-update \- update and upgrade an sbuild chroot with apt-get
.SH SYNOPSIS
.BR sbuild\-update
-.RB [ \-h \[or] \-\-help " \[or] " \-V \[or] \-\-version ]
+.BR [ \-h \[or] \-\-help ] " " [ \-V \[or] \-\-version ]
+.BR [ \-u \[or] \-\-update ] " " [ \-g \[or] \-\-upgrade ] " "
+.BR [ \-d \[or] \-\-dist\-upgrade ]
.BR CHROOT1 " [" CHROOT2 " [" CHROOT\f[BI]n\fP... ]]
-.BR sbuild\-upgrade
-.RB [ \-h \[or] \-\-help " \[or] " \-V \[or] \-\-version ]
+.br
+.BR (DEPRECATED) " " sbuild\-upgrade
+.BR [ \-h \[or] \-\-help ] " " [ \-V \[or] \-\-version ]
.BR CHROOT1 " [" CHROOT2 " [" CHROOT\f[BI]n\fP... ]]
-.BR sbuild\-distupdate
-.RB [ \-h \[or] \-\-help " \[or] " \-V \[or] \-\-version ]
+.br
+.BR (DEPRECATED) " " sbuild\-distupgrade
+.BR [ \-h \[or] \-\-help ] " " [ \-V \[or] \-\-version ]
.BR CHROOT1 " [" CHROOT2 " [" CHROOT\f[BI]n\fP... ]]
-.BR buildd\-update\-chroots
.SH DESCRIPTION
-\fBsbuild\-update\fR runs \f[CB]apt\-get update\fP inside the specified chroot.
-\fBsbuild\-upgrade\fR and \fBsbuild\-distupgrade\fR run \f[CB]apt\-get
-upgrade\fP and \f[CB]apt\-get dist-upgrade\fP, respectively.
-\fBbuildd\-update\-chroots\fP does the equivalent (update, dist-upgrade,
-autoremove and debfoster) but for buildd systems where it will stop the buildd
-prior to updating and will act on all schroot-managed chroots.
+\fBsbuild\-update\fR runs \f[CB]apt\-get\fP inside the specified chroot
+performing \f[CB]update\fP, \f[CB]upgrade\fP, and/or \f[CB]dist\-upgrade\fP
+depending on the options specified on the command line.
+.PP
+\fBsbuild\-upgrade\fR and \fBsbuild\-distupgrade\fR are deprecated. They now
+simply run \fBsbuild\-update\fR with the appropriate option (either
+\f[CB]\-\-upgrade\fP or \f[CB]\-\-dist\-upgrade\fP) along with whatever
+arguments were passed in the scripts.
.SH OPTIONS
.SS Actions
.TP
@@ -42,6 +47,15 @@ Display this manual.
.TP
.BR \-V ", " \-\-version
Print version information.
+.TP
+.BR \-u ", " \-\-update
+Perform an \f[CB]apt\-get update\fP.
+.TP
+.BR \-g ", " \-\-upgrade
+Perform an \f[CB]apt\-get upgrade\fP.
+.TP
+.BR \-d ", " \-\-dist\-upgrade
+Perform an \f[CB]apt\-get dist\-upgrade\fP.
.SS Chroot selection
.TP
.B CHROOT
@@ -52,8 +66,16 @@ and \[oq]experimental\[cq], respectively.
.SH EXAMPLES
To update the \fIunstable\fP chroot:
.PP
-\f[CR]% \f[CB]sbuild\-update unstable\fP\fP
-.br
+\f[CR]% \f[CB]sbuild\-update \-\-update unstable\fP\fP
+.PP
+To upgrade the \fIunstable\fP chroot:
+.PP
+\f[CR]% \f[CB]sbuild\-update \-\-upgrade unstable\fP\fP
+.PP
+To perform both an update and dist-upgrade for the
+\fIunstable\fP chroot:
+.PP
+\f[CR]% \f[CB]sbuild\-update \-ud unstable\fP\fP
.SH AUTHORS
.nf
Roger Leigh.
@@ -65,7 +87,6 @@ Copyright \[co] 2006\[en]2009 Roger Leigh <[email protected]>.
.SH "SEE ALSO"
.BR sbuild (1),
.BR sbuild\-apt (1),
-.BR sbuild\-upgrade (1).
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables: