tags fixed-upstream patch pending thanks On Mon, Sep 14, 2009 at 01:27:25PM -0400, Nelson Elhage wrote: > When using schroot, sbuild runs 'schroot --list' to get a list of all > chroots on the machine, and then runs 'schroot --info' separately on > each one.
Fixed with the attached patch. Could you verify it works for you? Thanks, Roger -- .''`. Roger Leigh : :' : Debian GNU/Linux http://people.debian.org/~rleigh/ `. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/ `- GPG Public Key: 0x25BFB848 Please GPG sign your mail.
>From 54b2d2e955e9348993ca5008d2fa409c58575272 Mon Sep 17 00:00:00 2001 From: Roger Leigh <rle...@debian.org> Date: Wed, 16 Sep 2009 22:21:02 +0100 Subject: [PATCH 3/8] Sbuild::ChrootInfoSchroot: Run schroot --info only once at startup Rather than running "schroot --list", followed by "schroot --info" for each chroot found by '--list', just run "schroot --info --all-chroots". Add function get_info_from_stream(), split from get_info(). get_info_all() repeatedly passes the output of '--info --all-chroots' to this function to get the information for all chroots in a single attempt. This siginificantly speeds up startup, especially in the case where many chroots exist. --- lib/Sbuild/ChrootInfoSchroot.pm | 54 +++++++++++++++++++++++--------------- 1 files changed, 33 insertions(+), 21 deletions(-) diff --git a/lib/Sbuild/ChrootInfoSchroot.pm b/lib/Sbuild/ChrootInfoSchroot.pm index 97d839c..441e645 100644 --- a/lib/Sbuild/ChrootInfoSchroot.pm +++ b/lib/Sbuild/ChrootInfoSchroot.pm @@ -45,24 +45,25 @@ sub new { return $self; } -sub get_info { +sub get_info_from_stream { my $self = shift; - my $chroot = shift; + my $stream = shift; - my $chroot_type = ""; - my %tmp = ('Priority' => 0, - 'Location' => "", + my $chroot_type = ''; + my %tmp = ('Name' => '', + 'Priority' => 0, + 'Location' => '', 'Session Purged' => 0); - local %ENV; + while (<$stream>) { + chomp; - $ENV{'LC_ALL'} = 'C'; - $ENV{'LANGUAGE'} = 'C'; + last if ! $_; - open CHROOT_DATA, '-|', $self->get_conf('SCHROOT'), '--info', '--chroot', $chroot - or die 'Can\'t run ' . $self->get_conf('SCHROOT') . ' to get chroot data'; - while (<CHROOT_DATA>) { - chomp; + if (/^\s*Name:?\s+(.*)$/ && + $tmp{'Name'} eq "") { + $tmp{'Name'} = $1; + } if (/^\s*Type:?\s+(.*)$/) { $chroot_type = $1; } @@ -88,10 +89,8 @@ sub get_info { } } - close CHROOT_DATA or die "Can't close schroot pipe getting chroot data"; - if ($self->get_conf('DEBUG')) { - print STDERR "Found schroot chroot: $chroot\n"; + print STDERR "Found schroot chroot: $tmp{'Name'}\n"; foreach (sort keys %tmp) { print STDERR " $_ $tmp{$_}\n"; } @@ -100,6 +99,22 @@ sub get_info { return \%tmp; } +sub get_info { + my $self = shift; + my $chroot = shift; + + my $chroot_type = ""; + + open CHROOT_DATA, '-|', $self->get_conf('SCHROOT'), '--info', '--chroot', $chroot + or die 'Can\'t run ' . $self->get_conf('SCHROOT') . ' to get chroot data'; + + my $tmp = $self->get_info_from_stream(\*CHROOT_DATA); + + close CHROOT_DATA or die "Can't close schroot pipe getting chroot data"; + + return $tmp; +} + sub get_info_all { my $self = shift; @@ -111,14 +126,11 @@ sub get_info_all { $ENV{'LC_ALL'} = 'C'; $ENV{'LANGUAGE'} = 'C'; - open CHROOTS, '-|', $self->get_conf('SCHROOT'), '--list' + open CHROOTS, '-|', $self->get_conf('SCHROOT'), '--info', '--all-chroots' or die 'Can\'t run ' . $self->get_conf('SCHROOT'); while (<CHROOTS>) { - chomp; - my $chroot = $_; - print STDERR "Getting info for $chroot chroot\n" - if $self->get_conf('DEBUG'); - $chroots->{$chroot} = $self->get_info($chroot); + my $tmp = $self->get_info_from_stream(\*CHROOTS); + $chroots->{$tmp->{'Name'}} = $tmp; } close CHROOTS or die "Can't close schroot pipe"; -- 1.6.3.3
>From abea9e90479b76bec9cdf06b13ad6e5783d478f4 Mon Sep 17 00:00:00 2001 From: Roger Leigh <rle...@debian.org> Date: Wed, 16 Sep 2009 22:40:23 +0100 Subject: [PATCH 4/8] debian: Close #546624 --- debian/changelog | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/debian/changelog b/debian/changelog index b901a52..8bd4b37 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,12 @@ sbuild (0.59.1~rc1) unstable; urgency=low * debian/control: - Bump to Standards-Version 3.8.2. + * Only run "schroot --info" once on startup, to speed up the startup + time when many chroots exist (Closes: #546624). Thanks to + Nelson Elhage for finding this issue and suggesting a suitable + approach for fixing it. - -- Roger Leigh <rle...@debian.org> Sun, 02 Aug 2009 12:36:51 +0100 + -- Roger Leigh <rle...@debian.org> Wed, 16 Sep 2009 22:23:56 +0100 sbuild (0.59.0-1) unstable; urgency=low -- 1.6.3.3