tags 355035 + patch tags 355037 + patch tags 355038 + patch thanks Martin Michlmayr <[EMAIL PROTECTED]> writes:
> updatechroot should export a proper $PATH since you cannot expect > people to have /usr/share/sbuild/ in their $PATH. Thanks for reporting this. The attached patch makes updatechroot use the sbuild chroot code, including the configuration files. This should fix all three bugs. There's also a package here: http://people.debian.org/~rleigh/sbuild_0.44_all.deb Please could you test to confirm all three bugs are fixed? Thanks, Roger -- Roger Leigh Printing on GNU/Linux? http://gutenprint.sourceforge.net/ Debian GNU/Linux http://www.debian.org/ GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
Index: Sbuild/Utility.pm =================================================================== --- Sbuild/Utility.pm (revision 0) +++ Sbuild/Utility.pm (revision 0) @@ -0,0 +1,100 @@ +# +# Utility.pm: library for sbuild utility programs +# Copyright (C) 2006 Roger Leigh <[EMAIL PROTECTED]> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# $Id: Sbuild.pm,v 1.2 2006/03/07 16:58:12 rleigh Exp $ +# + +# Import default modules into main +package main; +use Sbuild::Conf; +use Sbuild::Log qw(open_log close_log); +use Sbuild::Chroot qw(get_command run_command exec_command + get_apt_command run_apt_command current); + +$ENV{'LC_ALL'} = "POSIX"; +$ENV{'SHELL'} = "/bin/sh"; + +# avoid intermixing of stdout and stderr +$| = 1; + +Sbuild::Conf::init(); +$Sbuild::Conf::verbose++; +Sbuild::Chroot::init(); + +package Sbuild::Utility; + +use Sbuild::Conf; +use Sbuild::Chroot qw(begin_session end_session); + +use strict; +use warnings; + +BEGIN { + use Exporter (); + our (@ISA, @EXPORT); + + @ISA = qw(Exporter); + + @EXPORT = qw(setup cleanup shutdown); + + $SIG{'INT'} = \&shutdown; + $SIG{'TERM'} = \&shutdown; + $SIG{'ALRM'} = \&shutdown; + $SIG{'PIPE'} = \&shutdown; +} + +sub get_dist { + my $dist = shift; + + $dist = "unstable" if ($dist eq "-u" || $dist eq "u"); + $dist = "testing" if ($dist eq "-t" || $dist eq "t"); + $dist = "stable" if ($dist eq "-s" || $dist eq "s"); + $dist = "oldstable" if ($dist eq "-o" || $dist eq "o"); + $dist = "experimental" if ($dist eq "-e" || $dist eq "e"); + + return $dist; +} + +sub setup { + my $chroot = shift; + $chroot = get_dist($chroot); + + if (!begin_session($chroot)) { + print STDERR "Error setting up $chroot chroot\n"; + return 1; + } + + if (defined(&main::local_setup)) { + return main::local_setup($chroot); + } + return 0; +} + +sub cleanup { + if (defined(&main::local_cleanup)) { + main::local_cleanup(); + } + end_session(); +} + +sub shutdown { + cleanup(); + exit 1; +} + +1; Index: debian/changelog =================================================================== --- debian/changelog (revision 538) +++ debian/changelog (working copy) @@ -1,6 +1,14 @@ sbuild (0.44) UNRELEASED; urgency=low * avg-pkg-build-time: Use Sbuild::Conf. + * bin/checkchroot: Convert to Perl, using Sbuild::Utility. + * bin/chrapt: Convert to Perl, using Sbuild::Utility. + * bin/updatechroot: + - Convert to Perl, using Sbuild::Utility. + - chrapt is no longer used (Closes: #355035). + - Sbuild::Chroot is used for chroot access: + + Suite names are no longer hardcoded (Closes: #355037). + + APT Options are set correctly (Closes: #355038). * sbuild: - Treat schroot chroots with a "-sbuild" suffix in the same way as chroots without a suffix (Closes: #360124). @@ -84,6 +92,8 @@ - add_space_entry: Use $space rather than $t, and don't use $main::this_space. - Use File::Temp. + * Sbuild/Log.pm: New perl module for utility programs. This is a perl + replacement for bin/common_functions. * bin/checkchroot: - Quote all variables. - Sort ref-chroot file before diffing (Closes: 360058). Index: debian/rules =================================================================== --- debian/rules (revision 523) +++ debian/rules (working copy) @@ -55,6 +55,7 @@ $(INSTALL) -m 644 Sbuild/Chroot.pm $(DESTDIR)/usr/share/perl5/Sbuild/Chroot.pm $(INSTALL) -m 644 Sbuild/Conf.pm $(DESTDIR)/usr/share/perl5/Sbuild/Conf.pm $(INSTALL) -m 644 Sbuild/Log.pm $(DESTDIR)/usr/share/perl5/Sbuild/Log.pm + $(INSTALL) -m 644 Sbuild/Utility.pm $(DESTDIR)/usr/share/perl5/Sbuild/Utility.pm ln -s avg-pkg-build-time $(DESTDIR)/usr/bin/avg-pkg-build-space $(INSTALL) -m 644 sbuild.conf $(DESTDIR)/usr/share/sbuild/ $(INSTALL) -m 644 sbuild.conf.local $(DESTDIR)/etc/sbuild/sbuild.conf Index: bin/chrapt =================================================================== --- bin/chrapt (revision 523) +++ bin/chrapt (working copy) @@ -1,28 +1,50 @@ -#!/bin/bash +#!/usr/bin/perl -w +# +# Copyright (C) 2006 Roger Leigh <[EMAIL PROTECTED]> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -USAGE_STRING="${0##*/} <chroot> apt-get|apt-cache args" -. /usr/share/sbuild/common_functions -parse_arg $1 -shift +use strict; +use warnings; +use Sbuild::Utility qw(setup cleanup); -if [ $# -lt 2 ]; then usage; fi +package main; -# FHS change, potato -> woody -if [ -d $CHROOT/var/lib/apt/lists ]; then - APTDIR=lib -else - APTDIR=state -fi +sub usage { + print STDERR "Usage: $^X <chroot> apt-get|apt-cache args\n"; + exit 1; +} -cmd=$1 -shift -exec sudo $cmd \ - -o Dir::State=$CHROOT/var/$APTDIR/apt \ - -o Dir::State::status=$CHROOT/var/lib/dpkg/status \ - -o Dir::Cache=$CHROOT/var/cache/apt \ - -o Dir::Etc=$CHROOT/etc/apt \ - -o Dir::Etc::main=$CHROOT/apt.conf \ - -o Dir::Etc::parts=$CHROOT/apt.conf.d \ - -o DPkg::Options::=--root=$CHROOT \ - -o DPkg::Run-Directory=$CHROOT \ - "$@" +usage() if ($#ARGV < 2); + +my $command = $ARGV[1]; +if ($command eq "apt-get") { + $command = $Sbuild::Conf::apt_get; +} elsif ($command eq "apt-cache") { + $command = $Sbuild::Conf::apt_cache; +} else { + print STDERR "Bad command $command. Allowed commands: apt-get or apt-cache\n"; + exit 1; +} + +!setup($ARGV[0]) or die "Chroot setup failed"; + +shift @ARGV; +shift @ARGV; +my $cmd = join(' ', @ARGV); +my $status = run_apt_command($command, $cmd, "root", 1); + +cleanup(); +exit $status; Index: bin/updatechroot =================================================================== --- bin/updatechroot (revision 523) +++ bin/updatechroot (working copy) @@ -1,13 +1,37 @@ -#!/bin/sh +#!/usr/bin/perl -w # +# Copyright (C) 2006 Roger Leigh <[EMAIL PROTECTED]> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -DEFAULT_CHROOT="oldstable stable testing unstable" -USAGE_STRING="${0##*/} <chroot> (default: $DEFAULT_CHROOT)" +use strict; +use warnings; +use Sbuild::Utility qw(setup cleanup); -. /usr/share/sbuild/common_functions -CHROOTS=${*:-"$DEFAULT_CHROOT"} +package main; -for i in $CHROOTS; do - parse_arg $i - chrapt $i apt-get update -done +sub usage { + print STDERR "Usage: $^X <chroot>\n"; + exit 1; +} + +usage() if ($#ARGV != 0); + +!setup($ARGV[0]) or die "Chroot setup failed"; + +my $status = run_apt_command($Sbuild::Conf::apt_get, "update", "root", 1); + +cleanup(); +exit $status; Index: bin/checkchroot =================================================================== --- bin/checkchroot (revision 523) +++ bin/checkchroot (working copy) @@ -1,32 +1,98 @@ -#!/bin/bash -e +#!/usr/bin/perl -w +# check the package list in a chroot against a reference list. +# +# Copyright (C) 2006 Roger Leigh <[EMAIL PROTECTED]> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# check the package list in a chroot against a reference. +use strict; +use warnings; +use locale; +use POSIX qw(locale_h); +use Sbuild::Utility qw(setup cleanup); -LC_COLLATE=POSIX +package main; -if [ $(id -u) != 0 ]; then - echo "You must be root to run this script, sorry." - exit 1 -fi +sub usage { + print STDERR "Usage: $0 <chroot>\n"; + exit 1; +} -USAGE_STRING="${0##*/} <chroot>" -. /usr/share/sbuild/common_functions -parse_arg $1 +usage() if ($#ARGV != 0); -tfile1="$(tempfile)" -tfile2="$(tempfile)" +setlocale(LC_COLLATE, "POSIX"); +$ENV{'LC_COLLATE'} = "POSIX"; -grep-status -F Status -s Package ' installed' "$CHROOT/var/lib/dpkg/status" | awk '{print $2}' | sort >"$tfile1" +!setup($ARGV[0]) or die "Chroot setup failed"; +my $chroot_dir = $$Sbuild::Chroot::current{'Location'}; +my (@status, @ref, @install, @remove); -sort "$CHROOT/../ref-$DIST" >"$tfile2" +if (! open STATUS, "grep-status -F Status -s Package ' installed' '$chroot_dir/var/lib/dpkg/status' | awk '{print \$2}' |" ) { + print STDERR "Can't read dpkg status file in chroot: $!\n"; + main::shutdown(); +} +while (<STATUS>) { + chomp; + push @status, $_; +} +if (! close STATUS) { + print STDERR "Error reading dpkg status file in chroot: $!\n"; + main::shutdown(); +} -echo "DELETE ADD" -echo "============================" -diff -u "$tfile1" "$tfile2" | - tail -n +3 | - grep ^[+-] | - sed -e 's/^-//' -e "s/^+/ /" | - sort +my $dist = Sbuild::Utility::get_dist($ARGV[0]); -rm -f "$tfile1" "$tfile2" +if (! open REF, "< $chroot_dir/../ref-$dist") { + print STDERR "Can't read reference status file $chroot_dir/../ref-$dist: $!\n"; + main::shutdown(); +} +while (<REF>) { + chomp; + push @ref, $_; +} +if (! close REF) { + print STDERR "Error reading reference status file: $!\n"; + main::shutdown(); +} [EMAIL PROTECTED] = sort @status; [EMAIL PROTECTED] = sort @ref; + +print "DELETE ADD\n"; +print "======================================\n"; +my $i = 0; +my $j = 0; + +while ($i < scalar @status || $j < scalar @ref) { + + my $c = $status[$i] cmp $ref[$j]; + if ($c < 0) { + # In status, not reference; remove. + print "$status[$i]\n"; + $i++; + } elsif ($c > 0) { + # In reference, not status; install. + print " $ref[$j]\n"; + $j++; + } else { + # Identical; skip. + $i++; $j++; + } +} + +#ystem ("diff -u '$F1' '$F2' | tail -n +3 | grep ^[+-] | sed -e 's/^-//' -e 's/^+/ /' | sort"); + +cleanup(); +exit 0;
pgp6dGStf43dk.pgp
Description: PGP signature