2009-03-22 16:28:09 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
2010-04-05 20:03:39 +00:00
|
|
|
# Copyright (C) 2009, 2010 Neil Williams <codehelp@debian.org>
|
|
|
|
#
|
|
|
|
# This package 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2009-03-22 16:28:09 +00:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
2010-04-05 20:03:39 +00:00
|
|
|
use IO::File;
|
|
|
|
use Config::Auto;
|
|
|
|
use File::Basename;
|
|
|
|
use Parse::Debian::Packages;
|
|
|
|
use POSIX qw(locale_h);
|
|
|
|
use Locale::gettext;
|
|
|
|
|
|
|
|
use vars qw/ $progname $ourversion $dstrap $extra @aptsources $mirror
|
|
|
|
@archives $deb $cachedir $config_str %packages $retval $str $retries
|
|
|
|
$dir $include $arch $foreign $suite $url $unpack $sourcedir $msg $etcdir
|
2010-04-05 22:25:24 +00:00
|
|
|
@e $sourcesname $libdir $dpkgdir @debootstrap %suites %components $chk
|
2010-04-05 20:03:39 +00:00
|
|
|
$component $repo @dirs @touch %sources $section %keys $host $key $value
|
2010-04-05 22:25:24 +00:00
|
|
|
$type $file $config $tidy $noauth $keyring %keyrings $deflist $cfgdir
|
2010-04-17 21:24:53 +00:00
|
|
|
@extrapkgs @includes %source $setupsh $configsh $omitrequired $dryrun
|
2010-05-27 15:14:05 +00:00
|
|
|
$omitpreinst @reinstall $tgzname %uniq %required $check @check %uniq
|
2010-08-25 21:54:03 +00:00
|
|
|
$explicit_suite $allow_recommends %omitdebsrc @dsclist @sectoutput
|
2011-01-23 00:15:35 +00:00
|
|
|
%flatfile %important $addimportant/;
|
2010-04-05 20:03:39 +00:00
|
|
|
|
|
|
|
setlocale(LC_MESSAGES, "");
|
|
|
|
textdomain("multistrap");
|
|
|
|
$progname = basename($0);
|
|
|
|
$ourversion = &our_version();
|
2011-01-28 12:23:04 +00:00
|
|
|
$unpack = "true";
|
2010-05-27 15:14:05 +00:00
|
|
|
%omitdebsrc=();
|
2010-04-05 20:03:39 +00:00
|
|
|
|
|
|
|
while( @ARGV ) {
|
|
|
|
$_= shift( @ARGV );
|
|
|
|
last if m/^--$/;
|
|
|
|
if (!/^-/) {
|
|
|
|
unshift(@ARGV,$_);
|
|
|
|
last;
|
2010-12-25 12:28:44 +00:00
|
|
|
} elsif (/^(-\?|-h|--help|--version)$/) {
|
2010-04-05 20:03:39 +00:00
|
|
|
&usageversion();
|
|
|
|
exit( 0 );
|
2010-12-25 12:28:44 +00:00
|
|
|
} elsif (/^(-f|--file)$/) {
|
2010-04-05 20:03:39 +00:00
|
|
|
$file = shift(@ARGV);
|
2010-12-25 12:28:44 +00:00
|
|
|
} elsif (/^(-a|--arch)$/) {
|
2010-04-05 20:03:39 +00:00
|
|
|
$arch = shift(@ARGV);
|
2010-12-25 12:28:44 +00:00
|
|
|
} elsif (/^(-d|--dir)$/) {
|
2010-04-05 20:03:39 +00:00
|
|
|
$dir = shift(@ARGV);
|
|
|
|
$dir .= ($dir =~ m:/$:) ? '' : "/";
|
2010-12-25 12:28:44 +00:00
|
|
|
} elsif (/^(--tidy-up)$/) {
|
2010-04-05 20:03:39 +00:00
|
|
|
$tidy++;
|
2010-12-25 12:28:44 +00:00
|
|
|
} elsif (/^(--source-dir)$/) {
|
2010-04-05 20:03:39 +00:00
|
|
|
$sourcedir = shift (@ARGV);
|
|
|
|
$sourcedir .= ($sourcedir =~ m:/$:) ? '' : "/";
|
|
|
|
$sourcedir = (-d $sourcedir) ? $sourcedir : undef;
|
2010-12-25 12:28:44 +00:00
|
|
|
} elsif (/^(--no-auth)$/) {
|
2010-04-05 20:03:39 +00:00
|
|
|
$noauth++;
|
2010-12-25 12:28:44 +00:00
|
|
|
} elsif (/^(--dry-run|--simulate)$/) {
|
2010-04-17 21:24:53 +00:00
|
|
|
$dryrun++;
|
2010-12-25 12:28:44 +00:00
|
|
|
} else {
|
2010-04-05 20:03:39 +00:00
|
|
|
die "$progname: "._g("Unknown option")." $_.\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$msg = sprintf (_g("Need a configuration file - use %s -f\n"), $progname);
|
|
|
|
die ($msg)
|
|
|
|
if (not defined $file);
|
2010-10-15 15:46:08 +00:00
|
|
|
undef ($msg);
|
2010-04-05 20:03:39 +00:00
|
|
|
|
2010-04-28 20:45:22 +00:00
|
|
|
$cachedir = "var/cache/apt/"; # archives
|
|
|
|
$libdir = "var/lib/apt/"; # lists
|
|
|
|
$etcdir = "etc/apt/"; # sources
|
|
|
|
$dpkgdir = "var/lib/dpkg/"; # state
|
|
|
|
|
2010-04-05 20:03:39 +00:00
|
|
|
$cfgdir=dirname($file);
|
|
|
|
cascade($file);
|
2010-10-16 11:40:18 +00:00
|
|
|
# Translators: fields are programname, version string, include file.
|
|
|
|
printf (_g("%s %s using %s\n"), $progname, $ourversion, $file);
|
2010-04-17 21:24:53 +00:00
|
|
|
|
2010-10-03 18:56:42 +00:00
|
|
|
foreach my $inc (@includes) {
|
|
|
|
cascade($inc);
|
2010-04-05 20:03:39 +00:00
|
|
|
}
|
2011-01-23 00:15:35 +00:00
|
|
|
if (defined $omitrequired and defined $addimportant) {
|
|
|
|
warn("\n"._g("Error: Cannot set 'add Priority: important' when packages ".
|
|
|
|
"of 'Priority: required' are being omitted.\n"));
|
|
|
|
if (scalar @includes > 0) {
|
|
|
|
my $plural = ngettext("Please also check the included configuration file:",
|
|
|
|
"Please also check the included configuration files:", scalar @includes);
|
|
|
|
warn (sprintf("%s '%s'\n", $plural, join ("', '", sort @includes)));
|
|
|
|
}
|
|
|
|
if (defined $dryrun) {
|
|
|
|
warn("\n");
|
|
|
|
&dump_config;
|
|
|
|
}
|
|
|
|
exit (7);
|
|
|
|
}
|
2010-08-25 20:30:50 +00:00
|
|
|
%uniq=();
|
|
|
|
foreach my $line (@debootstrap) {
|
|
|
|
$uniq{$line}++;
|
|
|
|
}
|
|
|
|
@debootstrap=sort keys %uniq;
|
|
|
|
%uniq=();
|
|
|
|
foreach my $line (@aptsources) {
|
|
|
|
$uniq{$line}++;
|
|
|
|
}
|
|
|
|
@aptsources=sort keys %uniq;
|
2010-04-05 20:03:39 +00:00
|
|
|
|
2010-04-17 21:24:53 +00:00
|
|
|
&dump_config if (defined $dryrun);
|
2010-07-20 22:00:12 +00:00
|
|
|
if (not defined $dir or not defined $arch) {
|
2010-05-08 10:40:06 +00:00
|
|
|
&dump_config;
|
|
|
|
exit 3;
|
|
|
|
}
|
2010-04-17 21:24:53 +00:00
|
|
|
|
2010-04-05 20:03:39 +00:00
|
|
|
# Translators: fields are: programname, versionstring, configfile.
|
|
|
|
printf (_g("%s %s using %s\n"), $progname, $ourversion, $file);
|
2010-07-20 10:00:16 +00:00
|
|
|
$host = `dpkg --print-architecture`;
|
2010-04-05 20:03:39 +00:00
|
|
|
chomp ($host);
|
2010-07-20 22:00:12 +00:00
|
|
|
if ((not defined $arch) or ($arch eq "")) {
|
2010-04-05 20:03:39 +00:00
|
|
|
$arch = $host;
|
|
|
|
printf (_g("Defaulting architecture to native: %s\n"),$arch);
|
2010-07-20 22:00:12 +00:00
|
|
|
} elsif ($arch eq $host) {
|
2010-04-05 20:03:39 +00:00
|
|
|
printf (_g("Defaulting architecture to native: %s\n"),$arch);
|
2010-07-20 22:00:12 +00:00
|
|
|
} else {
|
2010-04-05 20:03:39 +00:00
|
|
|
printf (_g("Using foreign architecture: %s\n"), $arch);
|
|
|
|
}
|
|
|
|
$foreign++ if ($host ne $arch);
|
|
|
|
|
2010-07-20 22:00:12 +00:00
|
|
|
unless (keys %sources and @aptsources) {
|
2010-04-05 20:03:39 +00:00
|
|
|
my $msg = sprintf(_g("No sources defined for a foreign multistrap.
|
|
|
|
Using your existing apt sources. To use different sources,
|
|
|
|
list them with aptsources= in '%s'."), $file);
|
|
|
|
warn ("$progname: $msg\n");
|
|
|
|
$deflist = prepare_sources_list();
|
|
|
|
}
|
|
|
|
|
|
|
|
# Translators: fields are: programname, architecture, host architecture.
|
|
|
|
printf (_g("%s building %s multistrap on '%s'\n"), $progname, $arch, $host);
|
2010-10-03 18:25:57 +00:00
|
|
|
if ($dir =~ /^$/) {
|
|
|
|
my $msg = _g("No directory specified!");
|
|
|
|
die "$progname: $msg\n";
|
|
|
|
}
|
2010-07-20 22:00:12 +00:00
|
|
|
if (not -d "$dir") {
|
2010-04-20 15:47:03 +00:00
|
|
|
my $ret = system ("mkdir -p $dir");
|
|
|
|
$ret /= 256 if (defined $ret);
|
2010-05-30 23:40:38 +00:00
|
|
|
my $msg = sprintf (_g("Unable to create directory '%s'"),$dir);
|
|
|
|
die "$progname: $msg\n" if ($ret != 0);
|
2010-04-05 20:03:39 +00:00
|
|
|
}
|
|
|
|
$dir = `realpath $dir`;
|
|
|
|
chomp ($dir);
|
|
|
|
$dir .= ($dir =~ m:/$:) ? '' : "/";
|
|
|
|
system ("mkdir -p ${dir}${cachedir}") if (not -d "${dir}${cachedir}");
|
|
|
|
system ("mkdir -p ${dir}${libdir}") if (not -d "${dir}${libdir}");
|
|
|
|
system ("mkdir -p ${dir}${dpkgdir}") if (not -d "${dir}${dpkgdir}");
|
|
|
|
system ("mkdir -p ${dir}etc/apt/sources.list.d/")
|
|
|
|
if (not -d "${dir}etc/apt/sources.list.d/");
|
2010-10-02 15:56:26 +00:00
|
|
|
system ("mkdir -p ${dir}etc/apt/trusted.gpg.d/")
|
|
|
|
if (not -d "${dir}etc/apt/trusted.gpg.d/");
|
2010-04-05 20:03:39 +00:00
|
|
|
system ("mkdir -p ${dir}etc/apt/preferences.d/")
|
|
|
|
if (not -d "${dir}etc/apt/preferences.d/");
|
2010-04-05 20:48:03 +00:00
|
|
|
system ("mkdir -p ${dir}usr/share/info/")
|
|
|
|
if (not -d "${dir}usr/share/info/");
|
|
|
|
system ("touch ${dir}usr/share/info/dir");
|
2010-04-05 20:03:39 +00:00
|
|
|
|
|
|
|
@dirs = qw/ alternatives info parts updates/;
|
|
|
|
@touch = qw/ diversions statoverride status lock/;
|
|
|
|
foreach my $dpkgd (@dirs) {
|
|
|
|
if (not -d "${dir}${dpkgdir}$dpkgd") {
|
|
|
|
mkdir "${dir}${dpkgdir}$dpkgd";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach my $file (@touch) {
|
|
|
|
utime(time, time, "${dir}${dpkgdir}/$file") or (
|
|
|
|
open(F, ">${dir}${dpkgdir}/$file") && close F );
|
|
|
|
}
|
|
|
|
utime(time, time, "${dir}etc/shells") or
|
|
|
|
(open(F, ">${dir}etc/shells") && close F );
|
|
|
|
|
|
|
|
if (not -d "${dir}etc/network") {
|
|
|
|
mkdir "${dir}etc/network";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (not -d "${dir}dev") {
|
|
|
|
mkdir "${dir}dev";
|
|
|
|
}
|
|
|
|
|
|
|
|
# prevent the absolute symlink in libc6 from allowing
|
|
|
|
# writes outside the multistrap root dir. See: #553599
|
|
|
|
if (-l "${dir}lib64" ) {
|
|
|
|
my $r = readlink "${dir}lib64";
|
2010-12-25 18:26:20 +00:00
|
|
|
if ($r =~ m:^/:) {
|
2010-04-05 20:03:39 +00:00
|
|
|
my $old = `pwd`;
|
|
|
|
chomp ($old);
|
|
|
|
unlink "${dir}lib64";
|
|
|
|
chdir ("$dir");
|
|
|
|
print _g("INF: ./lib64 -> /lib symbolic link reset to ./lib.\n");
|
|
|
|
symlink "./lib", "lib64";
|
|
|
|
chdir ("${old}");
|
|
|
|
}
|
2010-07-20 22:00:12 +00:00
|
|
|
} else {
|
2010-12-25 18:26:20 +00:00
|
|
|
my $old = `pwd`;
|
|
|
|
chomp ($old);
|
|
|
|
chdir ("$dir");
|
|
|
|
print _g("INF: Setting ./lib64 -> ./lib symbolic link.\n");
|
|
|
|
symlink "./lib", "lib64";
|
|
|
|
chdir ("${old}");
|
2010-04-05 20:03:39 +00:00
|
|
|
}
|
|
|
|
|
2010-08-19 11:16:31 +00:00
|
|
|
system ("rm -rf ${dir}etc/apt/sources.list.d/*");
|
2010-04-05 20:03:39 +00:00
|
|
|
unlink ("${dir}etc/apt/sources.list")
|
|
|
|
if (-f "${dir}etc/apt/sources.list");
|
|
|
|
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach $repo (sort keys %suites) {
|
2010-04-05 20:03:39 +00:00
|
|
|
if (not -e "${dir}${cachedir}") {
|
|
|
|
mkdir "${dir}${cachedir}";
|
|
|
|
}
|
|
|
|
if (not -e "$dir/${libdir}lists") {
|
|
|
|
mkdir "$dir/${libdir}lists";
|
|
|
|
}
|
|
|
|
if (not -e "$dir/${libdir}lists/partial") {
|
|
|
|
mkdir "$dir/${libdir}lists/partial";
|
|
|
|
}
|
|
|
|
if (not -e "$dir/${cachedir}archives") {
|
|
|
|
mkdir "$dir/${cachedir}archives";
|
|
|
|
}
|
|
|
|
if (not -e "$dir/${cachedir}archives/partial") {
|
|
|
|
mkdir "$dir/${cachedir}archives/partial";
|
|
|
|
}
|
|
|
|
}
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $aptsrc (@debootstrap) {
|
|
|
|
if (defined $deflist) {
|
2010-04-05 20:03:39 +00:00
|
|
|
open (SOURCES, ">>${dir}etc/apt/sources.list.d/multistrap.sources.list")
|
|
|
|
or die _g("Cannot open sources list"). $!;
|
|
|
|
print SOURCES $deflist;
|
|
|
|
close SOURCES;
|
2010-07-20 22:00:12 +00:00
|
|
|
} elsif (-d "${dir}etc/apt/") {
|
2010-04-21 14:23:42 +00:00
|
|
|
open (SOURCES, ">>${dir}etc/apt/sources.list.d/multistrap-${aptsrc}.list")
|
2010-04-05 20:03:39 +00:00
|
|
|
or die _g("Cannot open sources list"). $!;
|
|
|
|
$mirror = $sources{$aptsrc};
|
2010-08-27 13:09:34 +00:00
|
|
|
$suite = (exists $flatfile{$aptsrc}) ? "" : $suites{$aptsrc};
|
|
|
|
$component = (exists $flatfile{$aptsrc}) ? ""
|
|
|
|
: (defined $components{$aptsrc}) ? $components{$aptsrc} : "main";
|
2010-07-20 22:00:12 +00:00
|
|
|
if (defined $mirror and defined $suite) {
|
2010-05-27 15:14:05 +00:00
|
|
|
print SOURCES "deb $mirror $suite $component\n";
|
|
|
|
print SOURCES "deb-src $mirror $suite $component\n" if (not defined $omitdebsrc{$aptsrc});
|
2010-04-21 14:30:39 +00:00
|
|
|
close SOURCES;
|
|
|
|
}
|
2010-04-05 20:03:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
my $k;
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $pkg (values %keyrings) {
|
2010-04-05 20:03:39 +00:00
|
|
|
next if (not defined $pkg);
|
|
|
|
next if ("" eq "$pkg");
|
|
|
|
$k .= "$pkg ";
|
|
|
|
}
|
2010-10-02 15:56:26 +00:00
|
|
|
if ((defined $k) and (not defined $noauth)) {
|
|
|
|
printf (_g("I: Installing %s\n"), $k);
|
2010-10-03 18:25:57 +00:00
|
|
|
# the keyring package must be available to the external apt
|
2010-10-15 15:37:01 +00:00
|
|
|
my $str = "";
|
|
|
|
my $e=`LC_ALL=C printenv`;
|
|
|
|
if ($e !~ /\nFAKEROOTKEY=[0-9]+\n/) {
|
|
|
|
if (($e =~ /\nUSER=root\n/)) {
|
|
|
|
$str = "sudo" if (-f "/usr/bin/sudo");
|
|
|
|
}
|
2010-10-15 15:45:12 +00:00
|
|
|
}
|
2010-10-15 15:37:01 +00:00
|
|
|
system ("$str apt-get -y -d --reinstall install $k");
|
2010-10-02 15:56:26 +00:00
|
|
|
foreach my $keyring_pkg (values %keyrings) {
|
|
|
|
my @files=();
|
2010-12-23 11:56:32 +00:00
|
|
|
my $file = `find /var/cache/apt/archives/ -name "$keyring_pkg*"|grep -m1 $keyring_pkg`;
|
2010-10-02 15:56:26 +00:00
|
|
|
chomp ($file);
|
2010-10-03 18:25:57 +00:00
|
|
|
if ($file eq "") {
|
|
|
|
my $msg = sprintf (_g("Unable to download keyring package: '%s'"),$dir);
|
|
|
|
die "$progname: $msg\n";
|
|
|
|
}
|
2010-10-02 15:56:26 +00:00
|
|
|
my $xdir = `mktemp -d -t keyring.XXXXXX`;
|
|
|
|
chomp ($xdir);
|
|
|
|
system ("dpkg -X $file $xdir >/dev/null");
|
|
|
|
if (-d "${xdir}/usr/share/keyrings") {
|
|
|
|
opendir (DIR, "${xdir}/usr/share/keyrings");
|
|
|
|
@files=grep(!m:\.\.?$:,readdir DIR);
|
|
|
|
closedir (DIR);
|
2010-05-28 21:08:00 +00:00
|
|
|
}
|
2010-10-02 15:56:26 +00:00
|
|
|
foreach my $gpg (@files) {
|
|
|
|
next if ($gpg =~ /removed/);
|
|
|
|
system ("gpg --no-default-keyring ".
|
|
|
|
"--homedir=${dir}/etc/apt/trusted.gpg.d/ ".
|
|
|
|
"--keyring=multistrap.gpg ".
|
|
|
|
" --import ${xdir}/usr/share/keyrings/${gpg} 2>/dev/null");
|
2010-12-23 11:56:32 +00:00
|
|
|
if (-f "${dir}/etc/apt/trusted.gpg.d/multistrap.gpg") {
|
|
|
|
system ("cp ${dir}/etc/apt/trusted.gpg.d/multistrap.gpg ${dir}/etc/apt/trusted.gpg.d/trustdb.gpg");
|
|
|
|
} else {
|
|
|
|
die (_g("Secure Apt handling failed - try without authentication."));
|
|
|
|
}
|
2010-10-02 15:56:26 +00:00
|
|
|
}
|
|
|
|
system ("rm -rf ${xdir}");
|
2010-05-28 21:08:00 +00:00
|
|
|
}
|
2010-04-05 20:03:39 +00:00
|
|
|
}
|
|
|
|
$config_str = '';
|
|
|
|
$config_str .= " -o Apt::Architecture=$arch";
|
2010-10-02 15:56:26 +00:00
|
|
|
$config_str .= " -o Dir::Etc::TrustedParts=${dir}${etcdir}trusted.gpg.d";
|
|
|
|
$config_str .= " -o Dir::Etc::Trusted=${dir}${etcdir}trusted.gpg";
|
2010-04-05 20:03:39 +00:00
|
|
|
$config_str .= " -o Apt::Get::AllowUnauthenticated=true"
|
|
|
|
if (defined $noauth);
|
|
|
|
$config_str .= " -o Apt::Get::Download-Only=true";
|
|
|
|
$config_str .= " -o Apt::Install-Recommends=false";
|
|
|
|
$config_str .= " -o Dir=$dir";
|
|
|
|
$config_str .= " -o Dir::Etc=${dir}${etcdir}";
|
2010-08-27 13:09:34 +00:00
|
|
|
if (defined $deflist) {
|
|
|
|
$sourcesname = "sources.list.d/multistrap.sources.list";
|
2010-10-02 15:56:26 +00:00
|
|
|
$config_str .= " -o Dir::Etc::SourceList=${dir}${etcdir}$sourcesname";
|
2010-08-27 13:09:34 +00:00
|
|
|
}
|
2010-04-05 20:03:39 +00:00
|
|
|
$config_str .= " -o Dir::State=${dir}${libdir}";
|
|
|
|
$config_str .= " -o Dir::State::Status=${dir}${dpkgdir}status";
|
|
|
|
$config_str .= " -o Dir::Cache=${dir}${cachedir}";
|
|
|
|
printf (_g("Getting package lists: apt-get %s update\n"), $config_str);
|
|
|
|
$retval = system ("apt-get $config_str update");
|
|
|
|
die (sprintf (_g("apt update failed. Exit value: %d\n"), ($retval/256)))
|
|
|
|
if ($retval != 0);
|
|
|
|
my @s = ();
|
|
|
|
$str = "";
|
2011-01-23 00:15:35 +00:00
|
|
|
if (not defined $omitrequired) {
|
2010-05-30 23:40:38 +00:00
|
|
|
print _g("I: Calculating required packages.\n");
|
2010-04-28 20:45:22 +00:00
|
|
|
&get_required_debs;
|
|
|
|
$str .= join (' ', keys %required);
|
2011-01-23 00:15:35 +00:00
|
|
|
if (defined $addimportant) {
|
|
|
|
my $imps = join (' ', sort keys %important);
|
|
|
|
printf(_g("I: Adding 'Priority: important': %s\n"), $imps);
|
|
|
|
$str .= " ".$imps;
|
|
|
|
}
|
2010-04-05 20:03:39 +00:00
|
|
|
chomp($str);
|
|
|
|
}
|
2010-04-05 22:25:24 +00:00
|
|
|
$str .= " ";
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $sect (sort keys %packages) {
|
2010-04-05 20:03:39 +00:00
|
|
|
my @list = split (' ', $sect);
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $pkg (@list) {
|
2010-04-05 22:25:24 +00:00
|
|
|
next if ($packages{$pkg} =~ /^\s*$/);
|
2010-08-20 21:40:04 +00:00
|
|
|
next if (!(grep(/^$sect$/i, @debootstrap)));
|
2010-04-20 15:47:03 +00:00
|
|
|
my @long=split (/ /, $packages{$sect});
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $l (@long) {
|
2010-04-20 15:47:03 +00:00
|
|
|
chomp ($l);
|
2010-08-27 13:09:34 +00:00
|
|
|
if (defined $explicit_suite and $suites{$sect}) {
|
2010-05-27 15:14:05 +00:00
|
|
|
# instruct apt to get packages from the specified
|
|
|
|
# suites (when the package exists in more than one).
|
|
|
|
$str .= " $l/$suites{$sect}" if ((defined $l) and ($l !~ /^\s*$/));
|
|
|
|
} else {
|
|
|
|
$str .= " $l" if ((defined $l) and ($l !~ /^\s*$/));
|
|
|
|
}
|
2010-04-20 15:47:03 +00:00
|
|
|
}
|
2010-04-05 20:03:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
chomp($str);
|
|
|
|
$str .= " " . join (' ', values %keyrings) . " ";
|
|
|
|
chomp($str);
|
2010-04-21 14:23:42 +00:00
|
|
|
%uniq=();
|
2010-04-21 15:00:09 +00:00
|
|
|
@s = split (/ /, $str);
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $a (@s) {
|
2010-04-05 20:03:39 +00:00
|
|
|
$uniq{$a}++;
|
|
|
|
}
|
|
|
|
$str = join (' ', sort keys %uniq);
|
2010-05-27 16:00:42 +00:00
|
|
|
@dsclist = sort keys %uniq;
|
2010-10-03 18:25:57 +00:00
|
|
|
print "apt-get -y $config_str install $str\n";
|
2010-04-05 20:03:39 +00:00
|
|
|
$retval = system ("apt-get -y $config_str install $str");
|
|
|
|
die (sprintf (_g("apt download failed. Exit value: %d\n"),($retval/256)))
|
|
|
|
if ($retval != 0);
|
|
|
|
&force_unpack if ($unpack eq "true");
|
|
|
|
system ("touch ${dir}${libdir}lists/lock");
|
2010-07-20 22:00:12 +00:00
|
|
|
system ("$setupsh $dir $arch") if ((defined $setupsh) and (-x $setupsh));
|
2011-01-28 12:23:04 +00:00
|
|
|
&native if (not defined ($foreign) and $unpack eq "true");
|
2010-04-05 20:03:39 +00:00
|
|
|
&add_extra_packages;
|
2010-05-03 18:45:36 +00:00
|
|
|
system ("cp $configsh $dir/") if ((defined $configsh) and (-f $configsh));
|
2010-04-05 20:03:39 +00:00
|
|
|
(not defined $tidy) ? system ("apt-get $config_str update") : &tidy_apt;
|
|
|
|
if (-l "${dir}lib64" ) {
|
|
|
|
my $r = readlink "${dir}lib64";
|
2010-12-25 18:26:20 +00:00
|
|
|
if ($r =~ m:^/:) {
|
2010-04-05 20:03:39 +00:00
|
|
|
print _g("ERR: ./lib64 -> /lib symbolic link reset to ./lib after unpacking.\n");
|
|
|
|
printf (_g("ERR: Some files may have been unpacked outside %s!\n"), $dir);
|
|
|
|
}
|
|
|
|
}
|
2010-04-21 14:23:42 +00:00
|
|
|
# cleanly separate the debootstrap sources from the final apt sources.
|
2010-04-05 20:03:39 +00:00
|
|
|
unlink ("${dir}etc/apt/sources.list.d/multistrap.sources.list")
|
|
|
|
if (-f "${dir}etc/apt/sources.list.d/multistrap.sources.list");
|
2010-04-21 14:23:42 +00:00
|
|
|
opendir (LISTS, "${dir}etc/apt/sources.list.d/")
|
|
|
|
or die (_g("Cannot read apt sources list directory.\n"));
|
|
|
|
my @sources=grep(!m:\.\.?$:, readdir LISTS);
|
|
|
|
closedir (LISTS);
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $filelist (@sources) {
|
2010-04-21 14:23:42 +00:00
|
|
|
next if (-d $filelist);
|
|
|
|
unlink ("${dir}etc/apt/sources.list.d/$filelist");
|
|
|
|
}
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $aptsrc (@aptsources) {
|
|
|
|
if (defined $deflist) {
|
2010-04-05 20:03:39 +00:00
|
|
|
open (SOURCES, ">>${dir}etc/apt/sources.list.d/multistrap.sources.list")
|
|
|
|
or die _g("Cannot open sources list"). $!;
|
|
|
|
print SOURCES $deflist;
|
|
|
|
close SOURCES;
|
2010-07-20 22:00:12 +00:00
|
|
|
} elsif (-d "${dir}etc/apt/") {
|
2010-04-21 14:23:42 +00:00
|
|
|
open (SOURCES, ">>${dir}etc/apt/sources.list.d/multistrap-${aptsrc}.list")
|
2010-04-05 20:03:39 +00:00
|
|
|
or die _g("Cannot open sources list"). $!;
|
|
|
|
$mirror = $sources{$aptsrc};
|
2010-08-27 13:09:34 +00:00
|
|
|
$suite = (exists $flatfile{$aptsrc}) ? "" : $suites{$aptsrc};
|
2010-08-26 06:21:00 +00:00
|
|
|
$component = (defined $components{$aptsrc}) ? $components{$aptsrc}
|
|
|
|
: (exists $flatfile{$aptsrc}) ? "" : "main";
|
2010-07-20 22:00:12 +00:00
|
|
|
if (defined $mirror and defined $suite) {
|
2010-05-27 15:14:05 +00:00
|
|
|
print SOURCES "deb $mirror $suite $component\n";
|
|
|
|
print SOURCES "deb-src $mirror $suite $component\n" if (not defined $omitdebsrc{$aptsrc});
|
2010-04-21 14:30:39 +00:00
|
|
|
close SOURCES;
|
|
|
|
}
|
2010-04-05 20:03:39 +00:00
|
|
|
}
|
|
|
|
}
|
2010-04-21 14:23:42 +00:00
|
|
|
# altered the sources, so get apt to update.
|
|
|
|
(not defined $tidy) ? system ("apt-get $config_str update") : &tidy_apt;
|
2010-05-03 18:45:36 +00:00
|
|
|
printf (_g("\nMultistrap system installed successfully in %s.\n"), $dir);
|
2010-07-20 22:00:12 +00:00
|
|
|
if (defined $tgzname) {
|
2010-04-20 17:15:15 +00:00
|
|
|
printf (_g("\nCompressing multistrap system in '%s' to a tarball called: '%s'.\n"), $dir, $tgzname);
|
|
|
|
chdir ("$dir");
|
|
|
|
unlink $tgzname if (-f $tgzname);
|
|
|
|
my $retval = system ("tar -czf ../$tgzname .");
|
|
|
|
$retval /= 256;
|
2010-07-20 22:00:12 +00:00
|
|
|
if ($retval == 0) {
|
2010-04-21 14:23:42 +00:00
|
|
|
printf (_g("\nRemoving build directory: '%s'\n"), $dir);
|
2010-04-20 17:15:15 +00:00
|
|
|
system ("rm -rf $dir/*");
|
|
|
|
}
|
2010-04-21 14:23:42 +00:00
|
|
|
my $final_path=`realpath $dir/../$tgzname`;
|
|
|
|
chomp ($final_path);
|
2010-04-21 14:24:49 +00:00
|
|
|
printf (_g("\nMultistrap system packaged successfully as '%s'.\n"), $final_path);
|
2010-04-20 17:15:15 +00:00
|
|
|
}
|
2010-04-21 14:23:42 +00:00
|
|
|
print "\n";
|
2010-04-05 20:03:39 +00:00
|
|
|
exit 0;
|
|
|
|
|
|
|
|
sub our_version {
|
|
|
|
my $query = `dpkg-query -W -f='\${Version}' multistrap`;
|
2010-05-30 23:40:38 +00:00
|
|
|
(defined $query) ? return $query : return "2.1.5";
|
2010-04-05 20:03:39 +00:00
|
|
|
}
|
|
|
|
|
2010-07-20 22:00:12 +00:00
|
|
|
sub add_extra_packages {
|
2010-10-16 11:40:18 +00:00
|
|
|
if (scalar @extrapkgs > 0) {
|
|
|
|
$str = join (' ', @extrapkgs);
|
2010-04-05 20:03:39 +00:00
|
|
|
print "apt-get -y $config_str install $str\n";
|
|
|
|
$retval = system ("apt-get -y $config_str install $str");
|
|
|
|
&force_unpack (@extrapkgs) if ($unpack eq "true");
|
|
|
|
system ("touch ${dir}${libdir}lists/lock");
|
|
|
|
&native if (not defined ($foreign));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-20 22:00:12 +00:00
|
|
|
sub force_unpack {
|
2010-04-05 20:03:39 +00:00
|
|
|
my (@limits) = @_;
|
|
|
|
my %unpack=();
|
|
|
|
my %filter = ();
|
|
|
|
opendir (DEBS, "${dir}${cachedir}archives/")
|
|
|
|
or die (_g("Cannot read apt archives directory.\n"));
|
|
|
|
@archives=grep(/.*\.deb$/, readdir DEBS);
|
|
|
|
closedir (DEBS);
|
2010-07-20 22:00:12 +00:00
|
|
|
if (@limits) {
|
|
|
|
foreach my $l (@limits) {
|
|
|
|
foreach my $file (@archives) {
|
|
|
|
if ($file =~ m:$l:) {
|
2010-04-05 20:03:39 +00:00
|
|
|
$filter{$l} = "$file";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@archives = sort values %filter;
|
|
|
|
}
|
|
|
|
print _g("I: Calculating obsolete packages\n");
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach $deb (sort @archives) {
|
2010-04-05 20:03:39 +00:00
|
|
|
my $version = `LC_ALL=C dpkg -f ${dir}${cachedir}archives/$deb Version`;
|
|
|
|
my $package = `LC_ALL=C dpkg -f ${dir}${cachedir}archives/$deb Package`;
|
|
|
|
chomp ($version);
|
|
|
|
chomp ($package);
|
2010-07-20 22:00:12 +00:00
|
|
|
if (exists $unpack{$package}) {
|
2010-04-05 20:03:39 +00:00
|
|
|
my $test=system("dpkg --compare-versions $unpack{$package} '<<' $version");
|
|
|
|
$test /= 256;
|
|
|
|
# unlink version in $unpack if 0
|
|
|
|
# unlink $deb (current one) if 1
|
2010-07-20 22:00:12 +00:00
|
|
|
if ($test == 0) {
|
2010-04-05 20:03:39 +00:00
|
|
|
my $old = $deb;
|
|
|
|
$old =~ s/$version/$unpack{$package}/;
|
|
|
|
printf (_g("I: Removing %s\n"), $old);
|
|
|
|
unlink "${dir}${cachedir}archives/$old";
|
|
|
|
next;
|
2010-07-20 22:00:12 +00:00
|
|
|
} else {
|
2010-04-05 20:03:39 +00:00
|
|
|
printf (_g("I: Removing %s\n"), $deb);
|
|
|
|
unlink "${dir}${cachedir}archives/$deb";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$unpack{$package}=$version;
|
|
|
|
}
|
2010-07-20 22:00:12 +00:00
|
|
|
if (not @limits) {
|
2010-04-05 20:03:39 +00:00
|
|
|
open (LOCK, ">${dir}${libdir}lists/lock");
|
|
|
|
close (LOCK);
|
|
|
|
opendir (DEBS, "${dir}${cachedir}archives/")
|
|
|
|
or die (_g("Cannot read apt archives directory.\n"));
|
|
|
|
@archives=grep(/.*\.deb$/, readdir DEBS);
|
|
|
|
closedir (DEBS);
|
|
|
|
}
|
|
|
|
my $old = `pwd`;
|
|
|
|
chomp ($old);
|
|
|
|
chdir ("${dir}");
|
2010-04-07 18:16:39 +00:00
|
|
|
printf (_g("Using directory %s for unpacking operations\n"), $dir);
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach $deb (sort @archives) {
|
2010-04-05 20:03:39 +00:00
|
|
|
printf (_g("I: Extracting %s...\n"), $deb);
|
|
|
|
my $ver=`LC_ALL=C dpkg -f ./${cachedir}archives/$deb Version`;
|
|
|
|
my $pkg=`LC_ALL=C dpkg -f ./${cachedir}archives/$deb Package`;
|
|
|
|
chomp ($ver);
|
|
|
|
chomp ($pkg);
|
2010-08-02 21:50:18 +00:00
|
|
|
push @dsclist, $pkg;
|
2010-04-05 20:03:39 +00:00
|
|
|
mkdir ("./tmp");
|
|
|
|
my $tmpdir = `mktemp -p ./tmp -d -t multistrap.XXXXXX`;
|
|
|
|
chomp ($tmpdir);
|
|
|
|
my $datatar = `LC_ALL=C dpkg -X ./${cachedir}archives/$deb ${dir}`;
|
|
|
|
my $exit = `echo $?`;
|
|
|
|
chomp ($exit);
|
2010-07-20 22:00:12 +00:00
|
|
|
if ($exit ne "0") {
|
2010-04-05 20:03:39 +00:00
|
|
|
printf(_g("dpkg -X failed with error code %s\nSkipping...\n"), $exit);
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
my @lines = split("\n", $datatar);
|
|
|
|
open (LIST, ">>./${dpkgdir}info/${pkg}.list");
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $l (@lines) {
|
2010-04-05 20:03:39 +00:00
|
|
|
chomp ($l);
|
|
|
|
$l =~ s:^\.::;
|
|
|
|
$l =~ s:^/$:/\.:;
|
|
|
|
$l =~ s:/$::;
|
|
|
|
print LIST "$l\n";
|
|
|
|
}
|
|
|
|
close (LIST);
|
|
|
|
system ("dpkg -e ./${cachedir}archives/$deb ${tmpdir}/");
|
|
|
|
opendir (MAINT, "./${tmpdir}");
|
|
|
|
my @maint=grep(!m:\.\.?:, readdir (MAINT));
|
|
|
|
closedir (MAINT);
|
|
|
|
open (AVAIL, ">>./${dpkgdir}available");
|
|
|
|
open (STATUS, ">>./${dpkgdir}status");
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $mscript (@maint) {
|
2010-04-05 20:03:39 +00:00
|
|
|
rename "./${tmpdir}/$mscript", "./${dpkgdir}info/$pkg.$mscript";
|
2010-07-20 22:00:12 +00:00
|
|
|
if ( $mscript eq "control" ) {
|
2010-04-05 20:03:39 +00:00
|
|
|
open (MSCRIPT, "./${dpkgdir}info/$pkg.$mscript");
|
|
|
|
my @scr=<MSCRIPT>;
|
|
|
|
close (MSCRIPT);
|
|
|
|
my @avail = grep(!/^$/, @scr);
|
|
|
|
print AVAIL @avail;
|
|
|
|
print STATUS @avail;
|
|
|
|
print AVAIL "\n";
|
|
|
|
print STATUS "Status: install ok unpacked\n";
|
|
|
|
unlink ("./${dpkgdir}info/$mscript");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close (AVAIL);
|
2010-07-20 22:00:12 +00:00
|
|
|
if ( -f "./${dpkgdir}info/$pkg.conffiles") {
|
2010-04-05 20:03:39 +00:00
|
|
|
print STATUS "Conffiles:\n";
|
|
|
|
printf (_g(" -> Processing conffiles for %s\n"), $pkg);
|
|
|
|
open (CONF, "./${dpkgdir}info/$pkg.conffiles");
|
|
|
|
my @lines=<CONF>;
|
|
|
|
close (CONF);
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $line (@lines) {
|
2010-04-05 20:03:39 +00:00
|
|
|
chomp ($line);
|
|
|
|
my $md5=`LC_ALL=C md5sum ./$line | cut -d" " -f1`;
|
|
|
|
chomp ($md5);
|
|
|
|
print STATUS " $line $md5\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print STATUS "\n";
|
|
|
|
close (STATUS);
|
|
|
|
system ("rm -rf ./${tmpdir}");
|
|
|
|
if (-l "${dir}lib64" ) {
|
|
|
|
my $r = readlink "${dir}lib64";
|
2010-07-20 22:00:12 +00:00
|
|
|
if ($r =~ m:^/:) {
|
2010-04-05 20:03:39 +00:00
|
|
|
my $old = `pwd`;
|
|
|
|
chomp ($old);
|
|
|
|
printf (_g("ERR: lib64 -> ./lib symbolic link clobbered by %s\n"), $pkg);
|
|
|
|
unlink "${dir}lib64";
|
|
|
|
chdir ("$dir");
|
|
|
|
print _g("INF: lib64 -> /lib symbolic link reset to ./lib.\n");
|
|
|
|
symlink "./lib", "lib64";
|
|
|
|
chdir ("${old}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
chdir ("$old");
|
|
|
|
print _g("I: Unpacking complete.\n");
|
|
|
|
}
|
|
|
|
|
2010-07-20 22:00:12 +00:00
|
|
|
sub check_bin_sh {
|
2010-04-05 20:03:39 +00:00
|
|
|
$dir = shift;
|
|
|
|
my $old = `pwd`;
|
|
|
|
chomp ($old);
|
|
|
|
# dash refuses to configure if no existing shell is found.
|
|
|
|
# (always expects a diversion to already exist).
|
|
|
|
# (works OK in subsequent upgrades.) #546528
|
|
|
|
unlink ("$dir/var/lib/dpkg/info/dash.postinst");
|
|
|
|
# now ensure that a usable shell is available as /bin/sh
|
2010-07-20 22:00:12 +00:00
|
|
|
if (not -l "$dir/bin/sh") {
|
2010-04-05 20:03:39 +00:00
|
|
|
print (_g("ERR: ./bin/sh symbolic link does not exist.\n"));
|
2010-07-20 22:00:12 +00:00
|
|
|
if (-f "$dir/bin/dash") {
|
2010-04-05 20:03:39 +00:00
|
|
|
print (_g("INF: Setting ./bin/sh -> ./bin/dash\n"));
|
|
|
|
chdir ("$dir/bin");
|
|
|
|
symlink ("dash", "sh");
|
|
|
|
chdir ("$old");
|
2010-07-20 22:00:12 +00:00
|
|
|
} elsif (-f "$dir/bin/bash") {
|
2010-04-05 20:03:39 +00:00
|
|
|
print (_g("INF: ./bin/dash not found. Setting ./bin/sh -> ./bin/bash\n"));
|
|
|
|
chdir ("$dir/bin");
|
|
|
|
symlink ("bash", "sh");
|
|
|
|
chdir ("$old");
|
|
|
|
}
|
|
|
|
}
|
2010-07-20 22:00:12 +00:00
|
|
|
if (-l "$dir/bin/sh") {
|
2010-04-05 20:03:39 +00:00
|
|
|
print ("${dir}bin/sh found OK:\n");
|
|
|
|
system ("(cd $dir ; ls -lh bin/sh)");
|
2010-07-20 22:00:12 +00:00
|
|
|
} else {
|
2010-04-20 15:47:03 +00:00
|
|
|
die ("No shell in $dir.");
|
2010-04-05 20:03:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-20 22:00:12 +00:00
|
|
|
sub tidy_apt {
|
2010-04-05 20:03:39 +00:00
|
|
|
print _g("I: Tidying up apt cache and list data.\n");
|
2010-05-31 19:18:16 +00:00
|
|
|
if (defined $sourcedir) {
|
2010-08-02 21:50:18 +00:00
|
|
|
my %uniqdsc=();
|
|
|
|
foreach my $a (@dsclist) {
|
|
|
|
$uniqdsc{$a}++;
|
|
|
|
}
|
|
|
|
my $str = join (" ", sort keys %uniqdsc);
|
2010-05-31 19:18:16 +00:00
|
|
|
print "(cd $sourcedir; apt-get -d $config_str source $str)";
|
|
|
|
system ("(cd $sourcedir; apt-get -d $config_str source $str)");
|
2010-05-27 16:00:42 +00:00
|
|
|
}
|
2010-04-05 20:03:39 +00:00
|
|
|
unlink ("${dir}etc/apt/sources.list")
|
|
|
|
if (-f "${dir}etc/apt/sources.list");
|
|
|
|
opendir (DEBS, "${dir}${libdir}lists/")
|
|
|
|
or die (_g("Cannot read apt lists directory.\n"));
|
|
|
|
my @lists=grep(!m:\.\.?$:, readdir DEBS);
|
|
|
|
closedir (DEBS);
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $file (@lists) {
|
2010-04-05 20:03:39 +00:00
|
|
|
next if (-d $file);
|
|
|
|
unlink ("${dir}${libdir}lists/$file");
|
|
|
|
}
|
|
|
|
opendir (DEBS, "${dir}${cachedir}/")
|
|
|
|
or die (_g("Cannot read apt cache directory.\n"));
|
|
|
|
my @files=grep(!m:\.\.?$:, readdir DEBS);
|
|
|
|
closedir (DEBS);
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $file (@files) {
|
2010-04-05 20:03:39 +00:00
|
|
|
next if (-d $file);
|
|
|
|
next unless ($file =~ /\.bin$/);
|
|
|
|
unlink ("${dir}${cachedir}$file");
|
|
|
|
}
|
2010-07-20 22:00:12 +00:00
|
|
|
if ($unpack eq "true") {
|
2010-05-31 19:18:16 +00:00
|
|
|
opendir (DEBS, "${dir}${cachedir}/archives/")
|
|
|
|
or die (_g("Cannot read apt archives directory.\n"));
|
|
|
|
my @files=grep(!m:\.\.?$:, readdir DEBS);
|
|
|
|
closedir (DEBS);
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $file (@files) {
|
2010-05-31 19:18:16 +00:00
|
|
|
next if (-d $file);
|
|
|
|
next unless ($file =~ /\.deb$/);
|
|
|
|
if (defined $sourcedir) {
|
|
|
|
system ("mv ${dir}${cachedir}archives/$file $sourcedir/$file");
|
|
|
|
} else {
|
|
|
|
unlink ("${dir}${cachedir}archives/$file");
|
|
|
|
}
|
|
|
|
}
|
2010-06-01 08:50:14 +00:00
|
|
|
$sourcedir=undef;
|
2010-05-31 19:18:16 +00:00
|
|
|
}
|
2010-04-05 20:03:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# if native arch, do a few tasks just because we can and probably should.
|
2010-07-20 22:00:12 +00:00
|
|
|
sub native {
|
2010-04-05 20:03:39 +00:00
|
|
|
my $e=`LC_ALL=C printenv`;
|
|
|
|
my $env = "DEBIAN_FRONTEND=noninteractive ".
|
|
|
|
"DEBCONF_NONINTERACTIVE_SEEN=true ".
|
|
|
|
"LC_ALL=C LANGUAGE=C LANG=C";
|
|
|
|
printf (_g("I: dpkg configuration settings:\n\t%s\n"), $env);
|
2010-05-28 21:08:00 +00:00
|
|
|
if ($e =~ /\nFAKEROOTKEY=[0-9]+\n/) {
|
2010-05-30 23:40:38 +00:00
|
|
|
warn (_g("W: Cannot use 'chroot' when fakeroot is in use. Skipping package configuration.\n"));
|
2010-05-28 21:08:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
print _g("I: Native mode - configuring unpacked packages . . .\n");
|
|
|
|
my $str = "";
|
|
|
|
if ($e =~ /\nUSER=root\n/) {
|
|
|
|
$str = "sudo" if (-f "/usr/bin/sudo");
|
|
|
|
}
|
2010-04-05 20:03:39 +00:00
|
|
|
# check that we have a workable shell inside the chroot
|
|
|
|
&check_bin_sh("$dir");
|
|
|
|
system ("$str $env chroot $dir dpkg --configure -a");
|
2010-04-07 13:33:14 +00:00
|
|
|
opendir (PRI, "${dir}/var/lib/dpkg/info") or return;
|
|
|
|
my @preinsts=grep(/\.preinst$/, readdir PRI);
|
|
|
|
closedir (PRI);
|
2010-04-20 15:47:03 +00:00
|
|
|
printf (_g("I: Running preinst scripts with 'upgrade' argument.\n"));
|
2010-04-20 17:15:15 +00:00
|
|
|
my $f = join (" ", @reinstall);
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $script (sort @preinsts) {
|
2010-04-20 17:15:15 +00:00
|
|
|
my $t = $script;
|
|
|
|
$t =~ s/\.preinst//;
|
|
|
|
next if ($t =~ /$f/);
|
2010-04-20 15:47:03 +00:00
|
|
|
next if ($script =~ /bash/);
|
2010-04-07 14:46:46 +00:00
|
|
|
system ("$str $env chroot $dir /var/lib/dpkg/info/$script upgrade");
|
2010-04-07 13:33:14 +00:00
|
|
|
}
|
2010-04-20 17:15:15 +00:00
|
|
|
# reinstall set
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $reinst (sort @reinstall) {
|
2010-10-03 18:25:57 +00:00
|
|
|
system ("$str $env chroot $dir apt-get --reinstall -y install $reinst");
|
2010-04-20 17:15:15 +00:00
|
|
|
}
|
2010-04-05 20:03:39 +00:00
|
|
|
}
|
|
|
|
|
2010-07-20 22:00:12 +00:00
|
|
|
sub get_required_debs {
|
2010-04-05 20:03:39 +00:00
|
|
|
# emulate required="$(get_debs Priority: required)"
|
|
|
|
# from debootstrap/functions
|
|
|
|
# needs to be run after the first apt-get install so that
|
|
|
|
# Packages files exist
|
2010-04-28 20:45:22 +00:00
|
|
|
%required=();
|
|
|
|
my %listfiles=();
|
2010-04-05 20:03:39 +00:00
|
|
|
opendir (PKGS, "${dir}${libdir}lists/")
|
|
|
|
or die sprintf(_g("Cannot open %s directory. %s\n"),
|
|
|
|
"${dir}${libdir}lists/", $!);
|
|
|
|
my @lists=grep(/_Packages$/, readdir (PKGS));
|
|
|
|
closedir (PKGS);
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $strap (@debootstrap) {
|
2010-04-05 20:03:39 +00:00
|
|
|
my $s = lc($strap);
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $l (@lists) {
|
2010-04-28 20:45:22 +00:00
|
|
|
$listfiles{$l}++;
|
2010-04-05 20:03:39 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach my $file (keys %listfiles) {
|
2010-04-05 20:03:39 +00:00
|
|
|
my $fh = IO::File->new("${dir}${libdir}lists/$file");
|
|
|
|
my $parser = Parse::Debian::Packages->new( $fh );
|
2010-07-20 22:00:12 +00:00
|
|
|
while (my %package = $parser->next) {
|
2010-06-29 12:57:03 +00:00
|
|
|
if (not defined $package{'Priority'} and (defined $package{'Essential'})) {
|
|
|
|
$required{$package{'Package'}}++;
|
2010-07-26 21:54:02 +00:00
|
|
|
next;
|
2010-06-29 12:57:03 +00:00
|
|
|
}
|
|
|
|
next if (not defined $package{'Priority'});
|
2011-01-23 00:15:35 +00:00
|
|
|
if ($package{'Priority'} eq "required") {
|
|
|
|
$required{$package{'Package'}}++;
|
|
|
|
} elsif ($package{'Priority'} eq "important") {
|
|
|
|
$important{$package{'Package'}}++;
|
|
|
|
}
|
2010-04-05 20:03:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# inherited from apt-cross
|
2010-07-20 22:00:12 +00:00
|
|
|
sub prepare_sources_list {
|
2010-04-05 20:03:39 +00:00
|
|
|
my @source_list=();
|
|
|
|
# collate all available/configured sources into one list
|
|
|
|
if (-e "/etc/apt/sources.list") {
|
|
|
|
open (SOURCES, "/etc/apt/sources.list")
|
|
|
|
or die _g("cannot open apt sources list. %s",$!);
|
|
|
|
@source_list = <SOURCES>;
|
|
|
|
close (SOURCES);
|
|
|
|
}
|
|
|
|
if (-d "/etc/apt/sources.list.d/") {
|
|
|
|
opendir (FILES, "/etc/apt/sources.list.d/")
|
|
|
|
or die _g("cannot open apt sources.list directory %s\n",$!);
|
|
|
|
my @files = grep(!/^\.\.?$/, readdir FILES);
|
|
|
|
foreach my $f (@files) {
|
|
|
|
next if ($f =~ /\.ucf-old$/);
|
|
|
|
open (SOURCES, "/etc/apt/sources.list.d/$f") or
|
|
|
|
die _g("cannot open /etc/apt/sources.list.d/%s %s",$f, $!);
|
|
|
|
while(<SOURCES>) {
|
|
|
|
push @source_list, $_;
|
|
|
|
}
|
|
|
|
close (SOURCES);
|
|
|
|
}
|
|
|
|
closedir (FILES);
|
|
|
|
}
|
|
|
|
return \@source_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub usageversion {
|
|
|
|
printf STDERR (_g("
|
|
|
|
%s version %s
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
%s [-a ARCH] [-d DIR] -f CONFIG_FILE
|
|
|
|
%s -?|-h|--help|--version
|
|
|
|
|
|
|
|
Command:
|
2010-05-07 12:34:40 +00:00
|
|
|
-f|--file CONFIG_FILE: path to the multistrap configuration file.
|
2010-04-05 20:03:39 +00:00
|
|
|
|
|
|
|
Options:
|
|
|
|
-a|--arch ARCHITECTURE: override the configuration file architecture.
|
|
|
|
-d|--dir PATH: override the configuration file directory.
|
|
|
|
--no-auth: do not use Secure Apt for any repositories
|
|
|
|
--tidy-up: remove apt cache data and downloaded archives.
|
2010-04-17 21:24:53 +00:00
|
|
|
--dry-run: output the configuration and exit
|
|
|
|
--simulate: output the configuration and exit
|
2010-04-05 20:03:39 +00:00
|
|
|
-?|-h|--help: print this usage message and exit
|
|
|
|
--version: print this usage message and exit
|
|
|
|
|
2010-05-08 10:40:06 +00:00
|
|
|
%s replaces debootstrap to provide support for multiple
|
2010-04-05 20:03:39 +00:00
|
|
|
repositories, using a configuration file to specify the relevant suites,
|
|
|
|
architecture, extra packages and the mirror to use for each repository.
|
|
|
|
|
|
|
|
Example configuration:
|
|
|
|
[General]
|
|
|
|
arch=armel
|
|
|
|
directory=/opt/multistrap/
|
|
|
|
# same as --tidy-up option if set to true
|
|
|
|
cleanup=true
|
|
|
|
# same as --no-auth option if set to true
|
2010-05-08 10:40:06 +00:00
|
|
|
# keyring packages listed in each bootstrap will
|
2010-04-05 20:03:39 +00:00
|
|
|
# still be installed.
|
|
|
|
noauth=false
|
|
|
|
# extract all downloaded archives (default is true)
|
|
|
|
unpack=true
|
|
|
|
# aptsources is a list of sections to be used for downloading packages
|
|
|
|
# and lists and placed in the /etc/apt/sources.list.d/multistrap.sources.list
|
|
|
|
# of the target. Order is not important
|
|
|
|
aptsources=Grip Updates
|
|
|
|
# the order of sections is not important.
|
2010-05-08 10:40:06 +00:00
|
|
|
# the bootstrap option determines which repository
|
2010-04-05 20:03:39 +00:00
|
|
|
# is used to calculate the list of Priority: required packages.
|
2010-05-08 10:40:06 +00:00
|
|
|
bootstrap=Debian
|
2010-04-05 20:03:39 +00:00
|
|
|
|
|
|
|
[Debian]
|
|
|
|
packages=
|
2010-08-05 23:25:22 +00:00
|
|
|
source=http://cdn.debian.net/debian
|
2010-04-05 20:03:39 +00:00
|
|
|
keyring=debian-archive-keyring
|
|
|
|
suite=lenny
|
|
|
|
|
|
|
|
This will result in a completely normal debootstrap of Debian lenny from
|
|
|
|
the specified mirror, for armel in /opt/multistrap/.
|
|
|
|
|
|
|
|
'Architecture' and 'directory' can be overridden on the command line.
|
|
|
|
|
|
|
|
Specify a package to extend the debootstap to include that package and
|
|
|
|
all dependencies. Dependencies will be calculated by apt so as to use
|
|
|
|
only the most recent suitable version from all configured repositories.
|
|
|
|
|
|
|
|
General settings:
|
|
|
|
|
2010-05-08 10:40:06 +00:00
|
|
|
'directory' specifies the top level directory where the bootstrap
|
2010-04-05 20:03:39 +00:00
|
|
|
will be created - it is not packed into a .tgz once complete.
|
|
|
|
|
|
|
|
"), $progname, $ourversion, $progname, $progname, $progname)
|
|
|
|
or die ("$progname: ". _g("failed to write usage:") . "$!\n");
|
|
|
|
}
|
|
|
|
|
2010-07-20 22:00:12 +00:00
|
|
|
sub cascade {
|
2010-04-05 20:03:39 +00:00
|
|
|
$file = shift;
|
2010-12-25 10:57:04 +00:00
|
|
|
$config = Config::Auto::parse($file, format => 'ini');
|
|
|
|
if (not defined $config or (scalar keys %$config) == 0) {
|
2010-12-25 11:01:32 +00:00
|
|
|
die ("$progname: ". sprintf(_g("Failed to parse '%s'!\n"), $file));
|
2010-12-25 10:57:04 +00:00
|
|
|
}
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach $key (%$config) {
|
2010-04-05 20:03:39 +00:00
|
|
|
$type = lc($key) if (ref $key ne "HASH");
|
|
|
|
$value = $key if (ref $key eq "HASH");
|
|
|
|
$keys{$type} = $value;
|
|
|
|
}
|
2010-07-20 22:00:12 +00:00
|
|
|
foreach $section (sort keys %keys) {
|
|
|
|
if ($section eq "general") {
|
2010-04-05 20:03:39 +00:00
|
|
|
$arch = $keys{$section}{'arch'}
|
2010-05-28 21:08:00 +00:00
|
|
|
if (defined $keys{$section}{'arch'} and (not defined $arch));
|
2010-04-05 20:03:39 +00:00
|
|
|
$dir = $keys{$section}{'directory'}
|
2010-05-28 21:08:00 +00:00
|
|
|
if (defined $keys{$section}{'directory'} and (not defined $dir));
|
2010-04-05 20:03:39 +00:00
|
|
|
# support the original value but replace by new value.
|
2011-01-28 12:23:04 +00:00
|
|
|
$unpack = "false" if (defined $keys{$section}{'forceunpack'} and (lc($keys{$section}{'forceunpack'}) ne "true"));
|
|
|
|
$unpack = "false" if (defined $keys{$section}{'unpack'} and (lc($keys{$section}{'unpack'} ne "true")));
|
2010-04-05 20:03:39 +00:00
|
|
|
$configsh = lc($keys{$section}{'configscript'})
|
2010-05-28 21:08:00 +00:00
|
|
|
if (defined $keys{$section}{'configscript'} and (not defined $configsh));
|
2010-04-20 17:15:15 +00:00
|
|
|
$tgzname = lc($keys{$section}{'tarballname'})
|
2010-05-28 21:08:00 +00:00
|
|
|
if (defined $keys{$section}{'tarballname'} and (not defined $tgzname));
|
2010-05-03 18:45:36 +00:00
|
|
|
undef $configsh if ((defined $configsh) and (not -x $configsh));
|
2010-04-05 20:03:39 +00:00
|
|
|
$setupsh = lc($keys{$section}{'setupscript'})
|
2010-05-28 21:08:00 +00:00
|
|
|
if (defined $keys{$section}{'setupscript'} and (not defined $setupsh));
|
2010-05-03 18:45:36 +00:00
|
|
|
undef $setupsh if ((defined $setupsh) and (not -x $setupsh));
|
2011-01-23 00:15:35 +00:00
|
|
|
$omitrequired++ if (defined $keys{$section}{'omitrequired'} and (lc($keys{$section}{'omitrequired'}) eq "true"));
|
|
|
|
$addimportant++ if (defined $keys{$section}{'addimportant'} and (lc($keys{$section}{'addimportant'}) eq "true"));
|
2010-04-20 15:47:03 +00:00
|
|
|
$omitpreinst = lc($keys{$section}{'omitpreinst'})
|
2010-05-28 21:08:00 +00:00
|
|
|
if (defined $keys{$section}{'omitpreinst'} and (not defined $omitpreinst));
|
|
|
|
$tidy++ if ((defined $keys{$section}{'cleanup'}) and ($keys{$section}{'cleanup'} eq "true"));
|
|
|
|
$noauth++ if ((defined $keys{$section}{'noauth'}) and ($keys{$section}{'noauth'} eq "true"));
|
|
|
|
$sourcedir = $keys{$section}{'retainsources'}
|
|
|
|
if ((defined $keys{$section}{'retainsources'}) and (-d $keys{$section}{'retainsources'}));
|
2010-05-27 15:14:05 +00:00
|
|
|
$explicit_suite++ if ((defined $keys{$section}{'explicitsuite'}) and
|
|
|
|
($keys{$section}{'explicitsuite'} eq "true"));
|
|
|
|
$allow_recommends++ if ((defined $keys{$section}{'allowrecommends'}) and
|
|
|
|
($keys{$section}{'allowrecommends'} eq "true"));
|
2010-04-05 20:03:39 +00:00
|
|
|
my @d = split(' ', lc($keys{$section}{'debootstrap'}));
|
|
|
|
push @debootstrap, @d;
|
2010-05-08 10:40:06 +00:00
|
|
|
my @b = split(' ', lc($keys{$section}{'bootstrap'}));
|
|
|
|
push @debootstrap, @b;
|
2010-04-05 20:03:39 +00:00
|
|
|
my @a = split (' ', lc($keys{$section}{'aptsources'}));
|
|
|
|
push @aptsources, @a;
|
2010-10-15 15:37:01 +00:00
|
|
|
my @i = split (' ', $keys{$section}{'include'})
|
|
|
|
if (defined $keys{$section}{'include'});
|
2010-10-03 18:25:57 +00:00
|
|
|
foreach my $inc (@i) {
|
|
|
|
# look for the full filepath or try same directory as current conf.
|
|
|
|
if (not -f $inc) {
|
|
|
|
$chk = `realpath $cfgdir/$inc 2>/dev/null`;
|
|
|
|
chomp ($chk) if (defined $chk);
|
|
|
|
$inc = $chk if (-f $chk);
|
|
|
|
}
|
|
|
|
if (not -f $inc) {
|
|
|
|
my $dirmsg = sprintf (_g("ERR: Cannot find include file: '%s' for '%s'"), $inc, $file);
|
|
|
|
die ("$dirmsg\n");
|
|
|
|
}
|
|
|
|
}
|
2010-04-05 20:03:39 +00:00
|
|
|
push @includes, @i;
|
2010-07-20 22:00:12 +00:00
|
|
|
} else {
|
2010-05-28 21:08:00 +00:00
|
|
|
$sources{$section}=$keys{$section}{'source'} if (not exists $source{$section});
|
2010-08-26 06:21:00 +00:00
|
|
|
# don't set suite or component if URL is of apt-ftparchive trailing-slash form
|
2010-12-25 12:28:44 +00:00
|
|
|
# regexp is: optional string in '[]', string without '[' or ']', string ending in '/'
|
2010-08-27 13:09:34 +00:00
|
|
|
$flatfile{$section}++ if (($sources{$section} =~ /^(\[.*\] )*[^\[\]]+ .+\/$/));
|
2010-12-25 12:28:44 +00:00
|
|
|
if (ref ($keys{$section}{'packages'}) eq 'ARRAY') {
|
|
|
|
$packages{$section}=join(' ', @{$keys{$section}{'packages'}}) if (not exists $packages{$section});
|
|
|
|
} else {
|
|
|
|
$packages{$section}=join(' ', $keys{$section}{'packages'}) if (not exists $packages{$section});
|
|
|
|
}
|
2010-08-26 06:21:00 +00:00
|
|
|
$suites{$section}=$keys{$section}{'suite'}
|
|
|
|
if (not exists $suites{$section} and not exists $flatfile{$section});
|
|
|
|
$components{$section}=$keys{$section}{'components'}
|
|
|
|
if (not exists $components{$section} and not exists $flatfile{$section});
|
2010-08-05 23:25:22 +00:00
|
|
|
$omitdebsrc{$section}=$section if ((defined $keys{$section}{'omitdebsrc'})
|
|
|
|
and ($keys{$section}{'omitdebsrc'} eq "true"));
|
2010-04-20 17:15:15 +00:00
|
|
|
push @reinstall, split (/ /, lc($keys{$section}{'reinstall'}));
|
2010-05-28 21:08:00 +00:00
|
|
|
$components{$section}='main' if (not defined $components{$section});
|
|
|
|
$keyrings{$section}=$keys{$section}{'keyring'} if (not exists $keyrings{$section});
|
2010-04-05 20:03:39 +00:00
|
|
|
push @extrapkgs, split (' ', lc($keys{$section}{'additional'}));
|
|
|
|
}
|
|
|
|
}
|
2010-04-20 17:15:15 +00:00
|
|
|
my %uniq=();
|
2010-05-30 23:40:38 +00:00
|
|
|
foreach my $listing (@reinstall) {
|
2010-04-20 17:15:15 +00:00
|
|
|
$uniq{$listing}++;
|
|
|
|
}
|
|
|
|
@reinstall=();
|
|
|
|
@reinstall=sort keys %uniq;
|
2010-10-16 11:40:18 +00:00
|
|
|
%uniq=();
|
|
|
|
foreach my $x (@extrapkgs) {
|
|
|
|
$uniq{$x}++;
|
|
|
|
}
|
|
|
|
@extrapkgs = keys %uniq;
|
2010-05-26 21:37:03 +00:00
|
|
|
# check for old versions of apt, <= 0.7.20.2+lenny1
|
|
|
|
my $aptVer = `dpkg-query -W -f='\${Version}' apt`;
|
|
|
|
if (defined $aptVer and ($aptVer ne "")) {
|
|
|
|
chomp ($aptVer);
|
|
|
|
my $retval = system ("dpkg --compare-versions $aptVer '>>' 0.7.20.2+lenny1");
|
|
|
|
$retval /= 256;
|
|
|
|
if ($retval == 1) {
|
|
|
|
foreach my $key (sort keys %suites) {
|
|
|
|
if (($suites{$key} =~ /lenny/)
|
|
|
|
or ($suites{$key} =~ /squeeze/)
|
|
|
|
or ($suites{$key} =~ /sid/)
|
|
|
|
or ($suites{$key} =~ /etch/)) {
|
2010-05-27 15:14:05 +00:00
|
|
|
my $msg = sprintf (_g("ERROR: Your version of apt is too old to support ".
|
|
|
|
"using a codename like '%s'. You MUST use the suite and multistrap is ".
|
|
|
|
"unable to guess which one you meant because suites change over time. " .
|
|
|
|
"Use one of: 'oldstable', 'stable', 'stable-proposed-updates', 'testing',".
|
|
|
|
" 'unstable' or 'experimental'. Alternatively, upgrade to version of apt ".
|
|
|
|
"newer than 0.7.20.2+lenny1.\n"), $suites{$key});
|
|
|
|
system ("echo \"$msg\" | fold -s");
|
|
|
|
exit 5;
|
2010-05-26 21:37:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-04-05 20:03:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub _g {
|
|
|
|
return gettext(shift);
|
|
|
|
}
|
|
|
|
|
2010-04-17 21:24:53 +00:00
|
|
|
sub dump_config {
|
2010-07-20 22:00:12 +00:00
|
|
|
if (not defined $dir or not defined $arch) {
|
2010-05-08 10:40:06 +00:00
|
|
|
my $msg = sprintf(_g("The supplied configuration file '%s'".
|
|
|
|
" cannot be parsed correctly."), $file);
|
2010-10-15 15:46:34 +00:00
|
|
|
warn ("\n$msg\n\n");
|
2010-05-08 10:40:06 +00:00
|
|
|
}
|
2010-10-16 11:40:18 +00:00
|
|
|
my $plural;
|
2010-05-05 19:10:43 +00:00
|
|
|
@check=();
|
|
|
|
%uniq=();
|
|
|
|
push @check, @debootstrap;
|
|
|
|
push @check, @aptsources;
|
|
|
|
foreach my $sect (@check) { $uniq{$sect}++; }
|
2010-08-25 20:44:21 +00:00
|
|
|
@check = sort keys %uniq;
|
|
|
|
%uniq=();
|
|
|
|
foreach my $sect (@check) {
|
2010-05-05 19:10:43 +00:00
|
|
|
if (not exists $keys{$sect}) {
|
2010-05-30 23:40:38 +00:00
|
|
|
$msg .= sprintf (_g("ERR: The '%s' section is not defined.\n"), $sect);
|
2010-05-05 19:10:43 +00:00
|
|
|
}
|
|
|
|
}
|
2010-05-27 15:14:05 +00:00
|
|
|
if (scalar @includes > 0) {
|
2010-10-16 11:40:18 +00:00
|
|
|
$plural = ngettext("Including configuration file from:",
|
|
|
|
"Including configuration files from:", scalar @includes);
|
|
|
|
printf ("include:\t%s '%s'\n", $plural, join ("', '", sort @includes));
|
2010-05-27 15:14:05 +00:00
|
|
|
} else {
|
2010-10-16 11:40:18 +00:00
|
|
|
printf ("include:\t\t"._g("No included configuration files.\n"));
|
2010-05-27 15:14:05 +00:00
|
|
|
}
|
2010-10-16 11:40:18 +00:00
|
|
|
undef $plural;
|
|
|
|
print "\n";
|
2010-08-25 20:30:50 +00:00
|
|
|
# explain the bootstrap section details explicitly and just refer to
|
|
|
|
# those for the apt sources.
|
2010-08-25 20:44:21 +00:00
|
|
|
foreach my $sect_name (@check) {
|
2010-10-29 14:32:06 +00:00
|
|
|
next unless (defined $packages{$sect_name});
|
2010-10-16 11:40:18 +00:00
|
|
|
printf ("Section name:\t$sect_name\n");
|
|
|
|
print "\tsource:\t\t$sources{$sect_name}\n";
|
2010-08-25 20:30:50 +00:00
|
|
|
my @sorted = split(/ /, $packages{$sect_name});
|
|
|
|
%uniq=();
|
|
|
|
foreach my $pkg (@sorted) {
|
|
|
|
$uniq{$pkg}++;
|
|
|
|
}
|
|
|
|
@sorted = sort keys %uniq;
|
|
|
|
%uniq=();
|
2010-10-16 11:40:18 +00:00
|
|
|
print "\tsuite:\t\t$suites{$sect_name}\n" if (not exists $flatfile{$sect_name});
|
2010-08-26 06:21:00 +00:00
|
|
|
print "\tcomponents:\t$components{$sect_name}\n" if (not exists $flatfile{$sect_name});
|
2010-10-16 11:40:18 +00:00
|
|
|
# only list packages in a bootstrapping section
|
|
|
|
if (not grep(/^$sect_name$/i, @debootstrap)) {
|
|
|
|
printf ("\t%s\n",_g("Not listed as a 'Bootstrap' section."));
|
|
|
|
print "\n";
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
print "\tpackages:\t".join(" ", @sorted)."\n";
|
|
|
|
print "\n";
|
2010-08-25 20:30:50 +00:00
|
|
|
}
|
2010-10-16 11:40:18 +00:00
|
|
|
$plural = ngettext("Section to install", "Sections to install", scalar @debootstrap);
|
|
|
|
printf ("%s:\t%s\n", $plural, join(" ", sort @debootstrap));
|
|
|
|
$plural = ngettext("Section for updates", "Sections for updates", scalar @aptsources);
|
|
|
|
printf ("%s:\t%s\n", $plural, join(" ", sort @aptsources));
|
2010-08-20 22:02:38 +00:00
|
|
|
my @srcdump=();
|
2010-08-25 19:53:33 +00:00
|
|
|
foreach my $src (sort keys %sources) {
|
2010-08-20 22:02:38 +00:00
|
|
|
next if ((!grep(/^$src$/i, @aptsources)) or (!grep(/^$src$/i, @debootstrap)));
|
|
|
|
push @srcdump, $sources{$src};
|
|
|
|
}
|
2010-10-16 11:40:18 +00:00
|
|
|
my $srcmsg="omitdebsrc\t\t"._g("Omit deb-src from sources.list for sections:");
|
|
|
|
if (scalar keys %omitdebsrc == 0) {
|
|
|
|
$srcmsg .= sprintf(" %s",_g("None."));
|
|
|
|
} else {
|
|
|
|
foreach my $omit (sort keys %omitdebsrc) {
|
2010-10-29 14:32:06 +00:00
|
|
|
$srcmsg .= " " . $omitdebsrc{$omit} if (defined $omitdebsrc{$omit});
|
2010-10-16 11:40:18 +00:00
|
|
|
}
|
2010-05-27 15:14:05 +00:00
|
|
|
}
|
2010-08-25 19:56:15 +00:00
|
|
|
print "$srcmsg\n";
|
2010-05-27 15:14:05 +00:00
|
|
|
if (defined $explicit_suite) {
|
2010-10-16 11:40:18 +00:00
|
|
|
printf("explicitsuite:\t\t"._g("Explicit suite selection: Yes\n"));
|
2010-05-27 15:14:05 +00:00
|
|
|
} else {
|
2010-10-16 11:40:18 +00:00
|
|
|
printf("explicitsuite:\t\t"._g("Explicit suite selection: No - let apt use latest.\n"));
|
2010-05-27 15:14:05 +00:00
|
|
|
}
|
|
|
|
if (defined $allow_recommends) {
|
|
|
|
printf("allowrecommends:\t"._g("Recommended packages are added to the selection.\n"));
|
|
|
|
} else {
|
|
|
|
printf("allowrecommends:\t"._g("Recommended packages are ignored.\n"));
|
|
|
|
}
|
2010-10-16 11:40:18 +00:00
|
|
|
$plural = ngettext ("Extra Package: ", "Extra Packages: ", scalar @extrapkgs);
|
|
|
|
print "additional:\t\t$plural".join (", ", sort @extrapkgs)."\n"
|
2010-04-17 21:24:53 +00:00
|
|
|
if (scalar @extrapkgs > 0);
|
2010-10-16 11:40:18 +00:00
|
|
|
print "reinstall:\t\t".join (", ", sort (@reinstall))."\n"
|
2010-04-20 17:15:15 +00:00
|
|
|
if (scalar @reinstall > 0);
|
2010-10-16 11:40:18 +00:00
|
|
|
if (defined $arch and $arch ne "") {
|
|
|
|
printf ("arch:\t\t\t"._g("Architecture to download: %s\n"), $arch);
|
2010-05-08 10:40:06 +00:00
|
|
|
} else {
|
|
|
|
$msg .= sprintf(_g("Cannot determine architecture from '%s'.\n"), $file);
|
|
|
|
}
|
2010-10-16 11:40:18 +00:00
|
|
|
if (defined $dir and $dir ne "") {
|
|
|
|
printf ("dir:\t\t\t"._g("Output directory: '%s'\n"), $dir);
|
2010-05-08 10:40:06 +00:00
|
|
|
} else {
|
|
|
|
$msg .= sprintf(_g("Cannot determine directory from '%s'.\n"), $file);
|
|
|
|
}
|
2011-01-28 12:23:04 +00:00
|
|
|
if ($unpack eq "true") {
|
|
|
|
printf ("unpack:\t\t\t"._g("extract all downloaded archives: %s\n"), $unpack);
|
|
|
|
} else {
|
|
|
|
printf ("unpack:\t\t\t"._g("extract all downloaded archives: %s\n"), "false");
|
|
|
|
}
|
2010-10-16 11:40:18 +00:00
|
|
|
print "configscript:\t\t$configsh\n" if (defined $configsh);
|
|
|
|
printf ("setupscript:\t\t%s: %s",_g("Script to be run after unpacking"),"$setupsh\n") if (defined $setupsh);
|
2011-01-23 00:15:35 +00:00
|
|
|
if (defined $omitrequired) {
|
2010-10-16 11:40:18 +00:00
|
|
|
printf ("omitrequired:\t\t%s\n",_g("'Priority required' packages are not included."));
|
|
|
|
} else {
|
|
|
|
printf ("omitrequired:\t\t%s\n",_g("'Priority: required' packages are included."));
|
|
|
|
}
|
2011-01-23 00:15:35 +00:00
|
|
|
if (defined $addimportant) {
|
|
|
|
printf("addimportant:\t\t"._g("'Priority: important' packages are included.\n"));
|
|
|
|
} else {
|
|
|
|
printf("addimportant:\t\t"._g("'Priority: important' packages are ignored.\n"));
|
|
|
|
}
|
2010-05-27 15:14:05 +00:00
|
|
|
if (defined $tidy) {
|
2010-10-16 11:40:18 +00:00
|
|
|
printf ("cleanup:\t\t"._g("remove apt cache data: true\n"));
|
2010-05-27 15:14:05 +00:00
|
|
|
} else {
|
2010-10-16 11:40:18 +00:00
|
|
|
printf ("cleanup:\t\t"._g("remove apt cache data: false\n"));
|
2010-05-27 15:14:05 +00:00
|
|
|
}
|
|
|
|
if (defined $noauth) {
|
2010-10-16 11:40:18 +00:00
|
|
|
printf ("noauth:\t\t\t"._g("allow the use of unauthenticated repositories: true\n"));
|
2010-05-27 15:14:05 +00:00
|
|
|
} else {
|
2010-10-16 11:40:18 +00:00
|
|
|
printf ("noauth:\t\t\t"._g("allow the use of unauthenticated repositories: false\n"));
|
2010-05-27 15:14:05 +00:00
|
|
|
}
|
|
|
|
if (defined $sourcedir) {
|
|
|
|
printf ("retainsources:\t"._g("Sources will be retained in: %s\n"), $sourcedir);
|
|
|
|
}
|
2010-10-16 11:40:18 +00:00
|
|
|
if (defined $tgzname) {
|
|
|
|
printf ("tarballname:\t\t"._g("Tarball name: '%s'\n"), $tgzname);
|
|
|
|
}
|
|
|
|
print "\n";
|
2010-05-05 19:10:43 +00:00
|
|
|
if (defined $msg) {
|
2010-05-08 10:40:06 +00:00
|
|
|
warn ("\n$msg\n");
|
2010-05-05 19:10:43 +00:00
|
|
|
exit 1;
|
|
|
|
}
|
2010-04-17 21:24:53 +00:00
|
|
|
exit 0;
|
|
|
|
}
|