fix problems with incomplete lists of required packages.

git-svn-id: http://emdebian.org/svn/current@7149 563faec7-e20c-0410-992a-a66f704d0ccd
This commit is contained in:
codehelp 2010-04-28 20:45:22 +00:00
parent 9c55deb69a
commit 4a121cd0a0
2 changed files with 23 additions and 22 deletions

View file

@ -31,7 +31,7 @@ use vars qw/ $progname $ourversion $dstrap $extra @aptsources $mirror
$component $repo @dirs @touch %sources $section %keys $host $key $value $component $repo @dirs @touch %sources $section %keys $host $key $value
$type $file $config $tidy $noauth $keyring %keyrings $deflist $cfgdir $type $file $config $tidy $noauth $keyring %keyrings $deflist $cfgdir
@extrapkgs @includes %source $setupsh $configsh $omitrequired $dryrun @extrapkgs @includes %source $setupsh $configsh $omitrequired $dryrun
$omitpreinst @reinstall $tgzname %uniq /; $omitpreinst @reinstall $tgzname %uniq %required /;
setlocale(LC_MESSAGES, ""); setlocale(LC_MESSAGES, "");
textdomain("multistrap"); textdomain("multistrap");
@ -82,6 +82,11 @@ $msg = sprintf (_g("Need a configuration file - use %s -f\n"), $progname);
die ($msg) die ($msg)
if (not defined $file); if (not defined $file);
$cachedir = "var/cache/apt/"; # archives
$libdir = "var/lib/apt/"; # lists
$etcdir = "etc/apt/"; # sources
$dpkgdir = "var/lib/dpkg/"; # state
$cfgdir=dirname($file); $cfgdir=dirname($file);
cascade($file); cascade($file);
@ -134,10 +139,6 @@ unless (keys %sources and @aptsources)
# Translators: fields are: programname, architecture, host architecture. # Translators: fields are: programname, architecture, host architecture.
printf (_g("%s building %s multistrap on '%s'\n"), $progname, $arch, $host); printf (_g("%s building %s multistrap on '%s'\n"), $progname, $arch, $host);
$cachedir = "var/cache/apt/"; # archives
$libdir = "var/lib/apt/"; # lists
$etcdir = "etc/apt/"; # sources
$dpkgdir = "var/lib/dpkg/"; # state
if (not -d "$dir") if (not -d "$dir")
{ {
@ -307,11 +308,11 @@ die (sprintf (_g("apt update failed. Exit value: %d\n"), ($retval/256)))
if ($retval != 0); if ($retval != 0);
my @s = (); my @s = ();
$str = ""; $str = "";
if ((defined $omitrequired) and ($omitrequired eq "false")) if ((not defined $omitrequired) or ($omitrequired eq "false"))
{ {
print "Calculating required packages.\n"; print "Calculating required packages.\n";
my $required = &get_required_debs; &get_required_debs;
$str .= join (' ', @$required); $str .= join (' ', keys %required);
chomp($str); chomp($str);
} }
$str .= " "; $str .= " ";
@ -347,7 +348,7 @@ print "apt-get $forceyes -y $config_str install $str\n";
$retval = system ("apt-get -y $config_str install $str"); $retval = system ("apt-get -y $config_str install $str");
die (sprintf (_g("apt download failed. Exit value: %d\n"),($retval/256))) die (sprintf (_g("apt download failed. Exit value: %d\n"),($retval/256)))
if ($retval != 0); if ($retval != 0);
system ("$setupsh") if (defined $setupsh); system ("$setupsh $dir $arch") if (defined $setupsh);
&force_unpack if ($unpack eq "true"); &force_unpack if ($unpack eq "true");
system ("cp $configsh $dir/") if ((defined $configsh) and (-f "$configsh")); system ("cp $configsh $dir/") if ((defined $configsh) and (-f "$configsh"));
system ("touch ${dir}${libdir}lists/lock"); system ("touch ${dir}${libdir}lists/lock");
@ -726,8 +727,8 @@ sub get_required_debs
# from debootstrap/functions # from debootstrap/functions
# needs to be run after the first apt-get install so that # needs to be run after the first apt-get install so that
# Packages files exist # Packages files exist
my @required=(); %required=();
my @debs=(); my %listfiles=();
opendir (PKGS, "${dir}${libdir}lists/") opendir (PKGS, "${dir}${libdir}lists/")
or die sprintf(_g("Cannot open %s directory. %s\n"), or die sprintf(_g("Cannot open %s directory. %s\n"),
"${dir}${libdir}lists/", $!); "${dir}${libdir}lists/", $!);
@ -738,20 +739,19 @@ sub get_required_debs
my $s = lc($strap); my $s = lc($strap);
foreach my $l (@lists) foreach my $l (@lists)
{ {
push (@required, $l); $listfiles{$l}++;
} }
} }
foreach my $file (@required) foreach my $file (keys %listfiles)
{ {
my $fh = IO::File->new("${dir}${libdir}lists/$file"); my $fh = IO::File->new("${dir}${libdir}lists/$file");
my $parser = Parse::Debian::Packages->new( $fh ); my $parser = Parse::Debian::Packages->new( $fh );
while (my %package = $parser->next) while (my %package = $parser->next)
{ {
next unless $package{'Priority'} eq "required"; next unless $package{'Priority'} eq "required";
push @debs, $package{'Package'}; $required{$package{'Package'}}++;
} }
} }
return \@debs;
} }
# inherited from apt-cross # inherited from apt-cross
@ -947,7 +947,7 @@ sub _g {
} }
sub dump_config { sub dump_config {
print "Debootstrap: ".join (", ", sort @debootstrap)."\n"; print "Bootstrap: ".join (", ", sort @debootstrap)."\n";
print "Apt sources: ".join (", ", sort @aptsources)."\n"; print "Apt sources: ".join (", ", sort @aptsources)."\n";
print "Includes: ".join (", ", sort @includes)."\n"; print "Includes: ".join (", ", sort @includes)."\n";
print "Sources: ".join (", ", sort values %sources)."\n"; print "Sources: ".join (", ", sort values %sources)."\n";

View file

@ -37,19 +37,20 @@ Example configuration:
# same as --tidy-up option if set to true # same as --tidy-up option if set to true
cleanup=true cleanup=true
# same as --no-auth option if set to true # same as --no-auth option if set to true
# keyring packages listed in each debootstrap will # keyring packages listed in each bootstrap will
# still be installed. # still be installed.
noauth=false noauth=false
# extract all downloaded archives (default is true) # extract all downloaded archives (default is true)
unpack=true unpack=true
# aptsources is a list of sections to be used for downloading packages # aptsources is a list of sections to be used
# and lists and placed in the /etc/apt/sources.list.d/multistrap.sources.list # the /etc/apt/sources.list.d/multistrap.sources.list
# of the target. Order is not important # of the target. Order is not important
aptsources=Grip Updates aptsources=Grip Updates
# the order of sections is not important. # the order of sections is not important.
# the debootstrap option determines which repository # the bootstrap option determines which repository
# is used to calculate the list of Priority: required packages. # is used to calculate the list of Priority: required packages
debootstrap=Debian # and which packages go into the rootfs.
bootstrap=Debian
[Debian] [Debian]
packages= packages=