2009-03-05 19:07:21 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
# Copyright (C) 2009 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-11-01 18:38:41 +00:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
2009-03-08 18:10:24 +00:00
|
|
|
use IO::File;
|
2009-03-05 19:07:21 +00:00
|
|
|
use Config::Auto;
|
|
|
|
use File::Basename;
|
2009-03-08 18:10:24 +00:00
|
|
|
use Parse::Debian::Packages;
|
2009-11-01 18:38:41 +00:00
|
|
|
use POSIX qw(locale_h);
|
|
|
|
use Locale::gettext;
|
|
|
|
|
2009-03-29 15:37:34 +00:00
|
|
|
use vars qw/ $progname $ourversion $dstrap $extra @aptsources
|
2009-03-05 19:07:21 +00:00
|
|
|
@archives $deb $cachedir $config_str %packages $retval $str $retries
|
2009-11-01 18:38:41 +00:00
|
|
|
$dir $include $arch $foreign $suite $url $unpack $sourcedir $msg
|
2010-02-27 20:05:07 +00:00
|
|
|
@e $sourcesname $libdir $dpkgdir @debootstrap %suites %components $component $mirror $etcdir
|
2009-03-05 19:07:21 +00:00
|
|
|
$repo @dirs @touch %sources $section %keys $host $key $value $type
|
2009-11-15 23:15:44 +00:00
|
|
|
$file $config $tidy $noauth $keyring %keyrings $deflist @extrapkgs /;
|
2009-11-01 18:38:41 +00:00
|
|
|
|
|
|
|
setlocale(LC_MESSAGES, "");
|
|
|
|
textdomain("multistrap");
|
2009-03-05 19:07:21 +00:00
|
|
|
$progname = basename($0);
|
2009-11-01 18:38:41 +00:00
|
|
|
$ourversion = "0.0.8";
|
2009-03-22 16:28:09 +00:00
|
|
|
$unpack = "true";
|
2009-03-05 19:07:21 +00:00
|
|
|
|
|
|
|
while( @ARGV ) {
|
|
|
|
$_= shift( @ARGV );
|
|
|
|
last if m/^--$/;
|
|
|
|
if (!/^-/) {
|
|
|
|
unshift(@ARGV,$_);
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
elsif (/^(-\?|-h|--help|--version)$/) {
|
|
|
|
&usageversion();
|
|
|
|
exit( 0 );
|
|
|
|
}
|
|
|
|
elsif (/^(-f|--file)$/) {
|
|
|
|
$file = shift(@ARGV);
|
|
|
|
}
|
2009-03-06 12:00:27 +00:00
|
|
|
elsif (/^(-a|--arch)$/) {
|
|
|
|
$arch = shift(@ARGV);
|
|
|
|
}
|
2009-03-08 18:10:24 +00:00
|
|
|
elsif (/^(-d|--dir)$/) {
|
|
|
|
$dir = shift(@ARGV);
|
|
|
|
$dir .= ($dir =~ m:/$:) ? '' : "/";
|
|
|
|
}
|
|
|
|
elsif (/^(--tidy-up)$/) {
|
|
|
|
$tidy++;
|
|
|
|
}
|
2009-03-29 15:37:34 +00:00
|
|
|
elsif (/^(--source-dir)$/) {
|
|
|
|
$sourcedir = shift (@ARGV);
|
|
|
|
$sourcedir .= ($sourcedir =~ m:/$:) ? '' : "/";
|
|
|
|
$sourcedir = (-d $sourcedir) ? $sourcedir : undef;
|
|
|
|
}
|
2009-03-23 22:28:50 +00:00
|
|
|
elsif (/^(--no-auth)$/) {
|
|
|
|
$noauth++;
|
|
|
|
}
|
2009-03-05 19:07:21 +00:00
|
|
|
else {
|
2009-11-01 18:38:41 +00:00
|
|
|
die "$progname: "._g("Unknown option")." $_.\n";
|
2009-03-05 19:07:21 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-15 23:15:44 +00:00
|
|
|
$msg = sprintf (_g("Need a configuration file - use %s -f\n"), $progname);
|
2009-11-01 18:38:41 +00:00
|
|
|
die ($msg)
|
2009-03-05 19:07:21 +00:00
|
|
|
if (not defined $file);
|
|
|
|
$config = Config::Auto::parse("$file");
|
|
|
|
%keys=();
|
|
|
|
foreach $key (%$config)
|
|
|
|
{
|
|
|
|
$type = lc($key) if (ref $key ne "HASH");
|
|
|
|
$value = $key if (ref $key eq "HASH");
|
|
|
|
$keys{$type} = $value;
|
|
|
|
}
|
|
|
|
%sources=();
|
|
|
|
%packages=();
|
|
|
|
%suites=();
|
2010-02-27 20:05:07 +00:00
|
|
|
%components=();
|
2009-03-23 22:28:50 +00:00
|
|
|
%keyrings=();
|
2009-03-29 15:37:34 +00:00
|
|
|
@aptsources=();
|
2009-03-05 19:07:21 +00:00
|
|
|
foreach $section (sort keys %keys)
|
|
|
|
{
|
|
|
|
if ($section eq "general")
|
|
|
|
{
|
2009-03-06 12:00:27 +00:00
|
|
|
$arch = $keys{$section}{'arch'} if (not defined $arch);
|
2009-03-08 18:10:24 +00:00
|
|
|
$dir = $keys{$section}{'directory'} if (not defined $dir);
|
2009-03-22 16:28:09 +00:00
|
|
|
# support the original value but replace by new value.
|
|
|
|
$unpack = lc($keys{$section}{'unpack'})
|
|
|
|
if (defined $keys{$section}{'forceunpack'});
|
|
|
|
$unpack = lc($keys{$section}{'unpack'})
|
|
|
|
if (defined $keys{$section}{'unpack'});
|
2009-03-23 22:28:50 +00:00
|
|
|
$tidy++ if ((defined $keys{$section}{'cleanup'}) and
|
|
|
|
($keys{$section}{'cleanup'} eq "true"));
|
|
|
|
$noauth++ if ((defined $keys{$section}{'noauth'}) and
|
|
|
|
($keys{$section}{'noauth'} eq "true"));
|
2009-03-29 15:37:34 +00:00
|
|
|
$sourcedir = $keys{$section}{'retainsources'} if
|
|
|
|
((defined $keys{$section}{'retainsources'}) and
|
|
|
|
(-d $keys{$section}{'retainsources'}));
|
2009-03-05 19:07:21 +00:00
|
|
|
@debootstrap = split(' ', lc($keys{$section}{'debootstrap'}));
|
2009-03-29 15:37:34 +00:00
|
|
|
@aptsources = split (' ', lc($keys{$section}{'aptsources'}));
|
2009-03-05 19:07:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$sources{$section}=$keys{$section}{'source'};
|
|
|
|
$packages{$section}=$keys{$section}{'packages'};
|
|
|
|
$suites{$section}=$keys{$section}{'suite'};
|
2010-02-27 20:05:07 +00:00
|
|
|
$components{$section}=$keys{$section}{'components'};
|
2010-03-04 09:43:49 +00:00
|
|
|
if (not defined $components{$section})
|
2010-02-27 20:05:07 +00:00
|
|
|
{
|
|
|
|
$components{$section}='main';
|
|
|
|
}
|
2009-03-23 22:28:50 +00:00
|
|
|
$keyrings{$section}=$keys{$section}{'keyring'};
|
2009-11-15 23:15:44 +00:00
|
|
|
push @extrapkgs, split (' ', lc($keys{$section}{'additional'}));
|
2009-03-05 19:07:21 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-01 18:38:41 +00:00
|
|
|
# Translators: fields are: programname, versionstring, configfile.
|
|
|
|
printf (_g("%s %s using %s\n"), $progname, $ourversion, $file);
|
2009-03-05 19:07:21 +00:00
|
|
|
$host = `dpkg-architecture -qDEB_BUILD_ARCH`;
|
|
|
|
chomp ($host);
|
2009-09-15 16:34:09 +00:00
|
|
|
if (not defined $arch)
|
|
|
|
{
|
|
|
|
$arch = $host;
|
2009-11-01 18:38:41 +00:00
|
|
|
printf (_g("Defaulting architecture to native: %s\n"),$arch);
|
2009-09-15 16:34:09 +00:00
|
|
|
}
|
2009-11-15 23:15:44 +00:00
|
|
|
elsif ($arch eq $host)
|
|
|
|
{
|
|
|
|
printf (_g("Defaulting architecture to native: %s\n"),$arch);
|
|
|
|
}
|
2009-09-15 16:34:09 +00:00
|
|
|
else
|
|
|
|
{
|
2009-11-01 18:38:41 +00:00
|
|
|
printf (_g("Using foreign architecture: %s\n"), $arch);
|
2009-09-15 16:34:09 +00:00
|
|
|
}
|
2009-03-22 16:28:09 +00:00
|
|
|
$foreign++ if ($host ne $arch);
|
2009-09-15 16:34:09 +00:00
|
|
|
|
|
|
|
unless (keys %sources and @aptsources)
|
|
|
|
{
|
2009-11-01 18:38:41 +00:00
|
|
|
my $msg = sprintf(_g("No sources defined for a foreign multistrap
|
2009-09-15 16:34:09 +00:00
|
|
|
Using your existing apt sources. To use different sources,
|
2009-11-01 18:38:41 +00:00
|
|
|
and list them with aptsources= in '%s'."), $file);
|
2009-09-15 16:34:09 +00:00
|
|
|
warn ("$progname: $msg\n");
|
|
|
|
$deflist = prepare_sources_list();
|
|
|
|
}
|
|
|
|
|
2009-11-01 18:38:41 +00:00
|
|
|
# Translators: fields are: programname, architecture, host architecture.
|
|
|
|
printf (_g("%s building %s multistrap on '%s'\n"), $progname, $arch, $host);
|
2009-03-05 19:07:21 +00:00
|
|
|
$cachedir = "var/cache/apt/"; # archives
|
|
|
|
$libdir = "var/lib/apt/"; # lists
|
|
|
|
$etcdir = "etc/apt/"; # sources
|
|
|
|
$dpkgdir = "var/lib/dpkg/"; # state
|
|
|
|
|
|
|
|
mkdir ("$dir") if (not -d "$dir");
|
2009-09-15 16:34:09 +00:00
|
|
|
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/");
|
|
|
|
system ("mkdir -p ${dir}etc/apt/preferences.d/")
|
|
|
|
if (not -d "${dir}etc/apt/preferences.d/");
|
2009-03-05 19:07:21 +00:00
|
|
|
@dirs = qw/ alternatives info parts updates/;
|
2009-03-23 22:28:50 +00:00
|
|
|
@touch = qw/ diversions statoverride status lock/;
|
2009-03-05 19:07:21 +00:00
|
|
|
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 (
|
2009-03-23 22:28:50 +00:00
|
|
|
open(F, ">${dir}${dpkgdir}/$file") && close F );
|
2009-03-05 19:07:21 +00:00
|
|
|
}
|
2009-03-23 22:28:50 +00:00
|
|
|
utime(time, time, "${dir}etc/shells") or
|
|
|
|
(open(F, ">${dir}etc/shells") && close F );
|
|
|
|
|
2009-03-24 13:37:53 +00:00
|
|
|
if (not -d "${dir}etc/network") {
|
|
|
|
mkdir "${dir}etc/network";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (not -d "${dir}dev") {
|
|
|
|
mkdir "${dir}dev";
|
|
|
|
}
|
|
|
|
|
2009-11-01 14:58:54 +00:00
|
|
|
# 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";
|
|
|
|
if ($r =~ m:^/:)
|
|
|
|
{
|
|
|
|
my $old = `pwd`;
|
|
|
|
chomp ($old);
|
|
|
|
unlink "${dir}lib64";
|
|
|
|
chdir ("$dir");
|
2009-11-01 18:38:41 +00:00
|
|
|
print _g("INF: ./lib64 -> /lib symbolic link reset to ./lib.\n");
|
2009-11-01 14:58:54 +00:00
|
|
|
symlink "./lib", "lib64";
|
|
|
|
chdir ("${old}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
my $old = `pwd`;
|
|
|
|
chomp ($old);
|
|
|
|
chdir ("$dir");
|
2009-11-01 18:38:41 +00:00
|
|
|
print _g("INF: Setting ./lib64 -> ./lib symbolic link.\n");
|
2009-11-01 14:58:54 +00:00
|
|
|
symlink "./lib", "lib64";
|
|
|
|
chdir ("${old}");
|
|
|
|
}
|
|
|
|
|
2009-03-23 22:28:50 +00:00
|
|
|
unlink ("${dir}etc/apt/sources.list.d/multistrap.sources.list")
|
|
|
|
if (-f "${dir}etc/apt/sources.list.d/multistrap.sources.list");
|
2009-03-05 19:07:21 +00:00
|
|
|
unlink ("${dir}etc/apt/sources.list")
|
|
|
|
if (-f "${dir}etc/apt/sources.list");
|
|
|
|
|
|
|
|
foreach $repo (sort keys %suites)
|
|
|
|
{
|
|
|
|
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";
|
|
|
|
}
|
2009-03-29 15:37:34 +00:00
|
|
|
}
|
|
|
|
foreach my $aptsrc (@aptsources)
|
|
|
|
{
|
2009-09-15 16:34:09 +00:00
|
|
|
if (defined $deflist)
|
2009-03-05 19:07:21 +00:00
|
|
|
{
|
2009-03-23 22:28:50 +00:00
|
|
|
open (SOURCES, ">>${dir}etc/apt/sources.list.d/multistrap.sources.list")
|
2009-11-01 18:38:41 +00:00
|
|
|
or die _g("Cannot open sources list"). $!;
|
2009-09-15 16:34:09 +00:00
|
|
|
print SOURCES $deflist;
|
|
|
|
close SOURCES;
|
|
|
|
}
|
|
|
|
elsif (-d "${dir}etc/apt/")
|
|
|
|
{
|
|
|
|
open (SOURCES, ">>${dir}etc/apt/sources.list.d/multistrap.sources.list")
|
|
|
|
or die _g("Cannot open sources list"). $!;
|
2009-03-29 15:37:34 +00:00
|
|
|
$mirror = $sources{$aptsrc};
|
|
|
|
$suite = $suites{$aptsrc};
|
2010-03-04 09:43:49 +00:00
|
|
|
$component = (defined $components{$aptsrc}) ? $components{$aptsrc} : "main";
|
2009-03-05 19:07:21 +00:00
|
|
|
print SOURCES<<END;
|
2010-02-27 20:05:07 +00:00
|
|
|
deb $mirror $suite $component
|
|
|
|
deb-src $mirror $suite $component
|
2009-03-05 19:07:21 +00:00
|
|
|
END
|
|
|
|
close SOURCES;
|
|
|
|
}
|
|
|
|
}
|
2009-03-24 14:09:55 +00:00
|
|
|
my $k;
|
|
|
|
foreach my $pkg (values %keyrings)
|
|
|
|
{
|
|
|
|
next if (not defined $pkg);
|
2009-09-15 16:34:09 +00:00
|
|
|
my $status = `LC_ALL=C dpkg -s $pkg`;
|
2009-03-24 14:09:55 +00:00
|
|
|
next if $status =~ /Status: install ok installed/;
|
|
|
|
$k .= "$pkg ";
|
|
|
|
}
|
|
|
|
if (defined $k)
|
2009-03-23 22:28:50 +00:00
|
|
|
{
|
2009-09-15 16:34:09 +00:00
|
|
|
my $e=`LC_ALL=C printenv`;
|
2009-03-23 22:28:50 +00:00
|
|
|
my $str = ($e =~ /\nUSER=root\n/) ? "" : "sudo ";
|
|
|
|
$str = (-f "/usr/bin/sudo") ? "$str" : "";
|
2009-11-01 18:38:41 +00:00
|
|
|
printf (_g("I: Installing %s\n"), $k);
|
2009-03-24 14:09:55 +00:00
|
|
|
system ("$str apt-get install $k");
|
2009-03-23 22:28:50 +00:00
|
|
|
}
|
|
|
|
|
2009-03-05 19:07:21 +00:00
|
|
|
$config_str = '';
|
|
|
|
$config_str .= " -o Apt::Architecture=$arch";
|
2009-03-23 22:28:50 +00:00
|
|
|
$config_str .= " -o Apt::Get::AllowUnauthenticated=true"
|
|
|
|
if (defined $noauth);
|
2009-03-05 19:07:21 +00:00
|
|
|
$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}";
|
2009-03-23 22:28:50 +00:00
|
|
|
$sourcesname = "sources.list.d/multistrap.sources.list";
|
2009-03-05 19:07:21 +00:00
|
|
|
$config_str .= " -o Dir::Etc::SourceList=${dir}${etcdir}$sourcesname";
|
|
|
|
$config_str .= " -o Dir::State=${dir}${libdir}";
|
2009-09-15 16:34:09 +00:00
|
|
|
$config_str .= " -o Dir::State::Status=${dir}${dpkgdir}status";
|
2009-03-05 19:07:21 +00:00
|
|
|
$config_str .= " -o Dir::Cache=${dir}${cachedir}";
|
2009-11-01 18:38:41 +00:00
|
|
|
printf (_g("Getting package lists: apt-get %s update\n"), $config_str);
|
2009-09-15 16:34:09 +00:00
|
|
|
$retval = system ("apt-get $config_str update");
|
2009-11-01 18:38:41 +00:00
|
|
|
die (sprintf (_g("apt update failed. Exit value: %d\n"), ($retval/256)))
|
2009-09-15 16:34:09 +00:00
|
|
|
if ($retval != 0);
|
2009-11-15 23:15:44 +00:00
|
|
|
my $required = &get_required_debs;
|
|
|
|
$str = join (' ', @$required);
|
2009-03-23 22:28:50 +00:00
|
|
|
chomp($str);
|
2010-03-04 09:43:49 +00:00
|
|
|
$str .= " " . join (' ', values %packages) . " ";
|
2009-03-05 19:07:21 +00:00
|
|
|
chomp($str);
|
2010-03-04 09:43:49 +00:00
|
|
|
$str .= " " . join (' ', values %keyrings) . " ";
|
2009-03-08 18:10:24 +00:00
|
|
|
chomp($str);
|
2009-11-15 23:15:44 +00:00
|
|
|
my %uniq=();
|
|
|
|
my @s = split (' ', $str);
|
|
|
|
foreach my $a (@s)
|
|
|
|
{
|
|
|
|
$uniq{$a}++;
|
|
|
|
}
|
|
|
|
$str = join (' ', sort keys %uniq);
|
2009-03-05 19:07:21 +00:00
|
|
|
print "apt-get -y $config_str install $str\n";
|
|
|
|
$retval = system ("apt-get -y $config_str install $str");
|
2009-11-01 18:38:41 +00:00
|
|
|
die (sprintf (_g("apt download failed. Exit value: %d\n"),($retval/256)))
|
2009-03-05 19:07:21 +00:00
|
|
|
if ($retval != 0);
|
|
|
|
|
2009-03-22 16:28:09 +00:00
|
|
|
&force_unpack if ($unpack eq "true");
|
2009-03-08 18:10:24 +00:00
|
|
|
system ("touch ${dir}${libdir}lists/lock");
|
2009-03-22 16:28:09 +00:00
|
|
|
&native if (not defined ($foreign));
|
2009-11-15 23:15:44 +00:00
|
|
|
&add_extra_packages;
|
2009-03-23 22:28:50 +00:00
|
|
|
(not defined $tidy) ? system ("apt-get $config_str update") : &tidy_apt;
|
2009-11-01 14:58:54 +00:00
|
|
|
if (-l "${dir}lib64" ) {
|
|
|
|
my $r = readlink "${dir}lib64";
|
|
|
|
if ($r =~ m:^/:)
|
|
|
|
{
|
2009-11-01 18:38:41 +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);
|
2009-11-01 14:58:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-01 18:38:41 +00:00
|
|
|
printf (_g("\nMultistrap system installed successfully in %s.\n\n"), $dir);
|
2009-11-01 14:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-08 18:10:24 +00:00
|
|
|
exit 0;
|
|
|
|
|
2009-11-23 21:25:46 +00:00
|
|
|
# lenny grip-config misses gcc-4.2-base, needs:
|
|
|
|
# touch /usr/share/doc/gcc-4.2-base/.changelog.Debian.gz
|
|
|
|
# touch /usr/share/doc/gcc-4.2-base/.changelog.Debian.gz
|
|
|
|
|
2009-11-15 23:15:44 +00:00
|
|
|
sub add_extra_packages
|
|
|
|
{
|
|
|
|
$str = join (' ', @extrapkgs);
|
2009-11-23 21:25:46 +00:00
|
|
|
if (@extrapkgs)
|
|
|
|
{
|
|
|
|
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));
|
|
|
|
}
|
2009-11-15 23:15:44 +00:00
|
|
|
}
|
|
|
|
|
2009-03-08 18:10:24 +00:00
|
|
|
sub force_unpack
|
2009-03-05 19:07:21 +00:00
|
|
|
{
|
2009-11-15 23:15:44 +00:00
|
|
|
my (@limits) = @_;
|
2009-03-08 18:10:24 +00:00
|
|
|
my %unpack=();
|
2009-11-15 23:15:44 +00:00
|
|
|
my %filter = ();
|
2009-03-08 18:10:24 +00:00
|
|
|
opendir (DEBS, "${dir}${cachedir}archives/")
|
2009-11-01 18:38:41 +00:00
|
|
|
or die (_g("Cannot read apt archives directory.\n"));
|
2009-03-08 18:10:24 +00:00
|
|
|
@archives=grep(/.*\.deb$/, readdir DEBS);
|
|
|
|
closedir (DEBS);
|
2009-11-15 23:15:44 +00:00
|
|
|
if (@limits)
|
|
|
|
{
|
|
|
|
foreach my $l (@limits)
|
|
|
|
{
|
|
|
|
foreach my $file (@archives)
|
|
|
|
{
|
|
|
|
if ($file =~ m:$l:)
|
|
|
|
{
|
|
|
|
$filter{$l} = "$file";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@archives = sort values %filter;
|
|
|
|
}
|
2009-11-01 18:38:41 +00:00
|
|
|
print _g("I: Calculating obsolete packages\n");
|
2009-03-08 18:10:24 +00:00
|
|
|
foreach $deb (sort @archives)
|
|
|
|
{
|
2009-09-15 16:34:09 +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`;
|
2009-03-08 18:10:24 +00:00
|
|
|
chomp ($version);
|
|
|
|
chomp ($package);
|
|
|
|
if (exists $unpack{$package})
|
|
|
|
{
|
|
|
|
my $test=system("dpkg --compare-versions $unpack{$package} '<<' $version");
|
|
|
|
$test /= 256;
|
|
|
|
# unlink version in $unpack if 0
|
|
|
|
# unlink $deb (current one) if 1
|
|
|
|
if ($test == 0)
|
|
|
|
{
|
|
|
|
my $old = $deb;
|
|
|
|
$old =~ s/$version/$unpack{$package}/;
|
2009-11-01 18:38:41 +00:00
|
|
|
printf (_g("I: Removing %s\n"), $old);
|
2009-03-08 18:10:24 +00:00
|
|
|
unlink "${dir}${cachedir}archives/$old";
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-01 18:38:41 +00:00
|
|
|
printf (_g("I: Removing %s\n"), $deb);
|
2009-03-08 18:10:24 +00:00
|
|
|
unlink "${dir}${cachedir}archives/$deb";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$unpack{$package}=$version;
|
|
|
|
}
|
2009-11-15 23:15:44 +00:00
|
|
|
if (not @limits)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2009-03-08 18:10:24 +00:00
|
|
|
my $old = `pwd`;
|
|
|
|
chomp ($old);
|
2009-03-05 19:07:21 +00:00
|
|
|
chdir ("${dir}");
|
2009-03-08 18:10:24 +00:00
|
|
|
foreach $deb (sort @archives)
|
2009-03-05 19:07:21 +00:00
|
|
|
{
|
2009-11-01 18:38:41 +00:00
|
|
|
printf (_g("I: Extracting %s...\n"), $deb);
|
2009-09-15 16:34:09 +00:00
|
|
|
my $ver=`LC_ALL=C dpkg -f ./${cachedir}archives/$deb Version`;
|
|
|
|
my $pkg=`LC_ALL=C dpkg -f ./${cachedir}archives/$deb Package`;
|
2009-03-08 18:10:24 +00:00
|
|
|
chomp ($ver);
|
|
|
|
chomp ($pkg);
|
|
|
|
mkdir ("./tmp");
|
|
|
|
my $tmpdir = `mktemp -p ./tmp -d -t multistrap.XXXXXX`;
|
|
|
|
chomp ($tmpdir);
|
2009-11-15 23:15:44 +00:00
|
|
|
my $datatar = `LC_ALL=C dpkg -X ./${cachedir}archives/$deb ${dir}`;
|
2009-03-08 18:10:24 +00:00
|
|
|
my @lines = split("\n", $datatar);
|
|
|
|
open (LIST, ">>./${dpkgdir}info/${pkg}.list");
|
|
|
|
foreach my $l (@lines)
|
|
|
|
{
|
|
|
|
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");
|
|
|
|
foreach my $mscript (@maint)
|
|
|
|
{
|
|
|
|
rename "./${tmpdir}/$mscript", "./${dpkgdir}info/$pkg.$mscript";
|
|
|
|
if ( $mscript eq "control" )
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
if ( -f "./${dpkgdir}info/$pkg.conffiles")
|
|
|
|
{
|
|
|
|
print STATUS "Conffiles:\n";
|
2009-11-01 18:38:41 +00:00
|
|
|
printf (_g(" -> Processing conffiles for %s\n"), $pkg);
|
2009-03-08 18:10:24 +00:00
|
|
|
open (CONF, "./${dpkgdir}info/$pkg.conffiles");
|
|
|
|
my @lines=<CONF>;
|
|
|
|
close (CONF);
|
|
|
|
foreach my $line (@lines)
|
|
|
|
{
|
|
|
|
chomp ($line);
|
2009-11-15 23:15:44 +00:00
|
|
|
my $md5=`LC_ALL=C md5sum ./$line | cut -d" " -f1`;
|
2009-03-08 18:10:24 +00:00
|
|
|
chomp ($md5);
|
|
|
|
print STATUS " $line $md5\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print STATUS "\n";
|
|
|
|
close (STATUS);
|
|
|
|
system ("rm -rf ./${tmpdir}");
|
2009-11-01 14:58:54 +00:00
|
|
|
if (-l "${dir}lib64" ) {
|
|
|
|
my $r = readlink "${dir}lib64";
|
|
|
|
if ($r =~ m:^/:)
|
|
|
|
{
|
|
|
|
my $old = `pwd`;
|
|
|
|
chomp ($old);
|
2009-11-01 18:38:41 +00:00
|
|
|
printf (_g("ERR: lib64 -> ./lib symbolic link clobbered by %s\n"), $pkg);
|
2009-11-01 14:58:54 +00:00
|
|
|
unlink "${dir}lib64";
|
|
|
|
chdir ("$dir");
|
2009-11-01 18:38:41 +00:00
|
|
|
print _g("INF: lib64 -> /lib symbolic link reset to ./lib.\n");
|
2009-11-01 14:58:54 +00:00
|
|
|
symlink "./lib", "lib64";
|
|
|
|
chdir ("${old}");
|
|
|
|
}
|
|
|
|
}
|
2009-03-05 19:07:21 +00:00
|
|
|
}
|
2009-03-08 18:10:24 +00:00
|
|
|
chdir ("$old");
|
2009-11-01 18:38:41 +00:00
|
|
|
print _g("I: Unpacking complete.\n");
|
2009-03-08 18:10:24 +00:00
|
|
|
}
|
|
|
|
|
2009-11-15 23:15:44 +00:00
|
|
|
sub check_bin_sh
|
|
|
|
{
|
|
|
|
$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
|
|
|
|
if (not -l "$dir/bin/sh")
|
|
|
|
{
|
|
|
|
print (_g("ERR: ./bin/sh symbolic link does not exist.\n"));
|
|
|
|
if (-f "$dir/bin/dash")
|
|
|
|
{
|
|
|
|
print (_g("INF: Setting ./bin/sh -> ./bin/dash\n"));
|
|
|
|
chdir ("$dir/bin");
|
|
|
|
symlink ("dash", "sh");
|
|
|
|
chdir ("$old");
|
|
|
|
}
|
|
|
|
elsif (-f "$dir/bin/bash")
|
|
|
|
{
|
|
|
|
print (_g("INF: ./bin/dash not found. Setting ./bin/sh -> ./bin/bash\n"));
|
|
|
|
chdir ("$dir/bin");
|
|
|
|
symlink ("bash", "sh");
|
|
|
|
chdir ("$old");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (-l "$dir/bin/sh")
|
|
|
|
{
|
|
|
|
print ("${dir}bin/sh found OK:\n");
|
|
|
|
system ("(cd $dir ; ls -lh bin/sh)");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
die ("No shell.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-08 18:10:24 +00:00
|
|
|
sub tidy_apt
|
|
|
|
{
|
2009-11-01 18:38:41 +00:00
|
|
|
print _g("I: Tidying up apt cache and list data.\n");
|
2009-03-23 22:28:50 +00:00
|
|
|
unlink ("${dir}etc/apt/sources.list")
|
|
|
|
if (-f "${dir}etc/apt/sources.list");
|
2009-03-08 18:10:24 +00:00
|
|
|
opendir (DEBS, "${dir}${libdir}lists/")
|
2009-11-01 18:38:41 +00:00
|
|
|
or die (_g("Cannot read apt lists directory.\n"));
|
2009-03-08 18:10:24 +00:00
|
|
|
my @lists=grep(!m:\.\.?$:, readdir DEBS);
|
|
|
|
closedir (DEBS);
|
|
|
|
foreach my $file (@lists)
|
|
|
|
{
|
|
|
|
next if (-d $file);
|
|
|
|
unlink ("${dir}${libdir}lists/$file");
|
|
|
|
}
|
|
|
|
opendir (DEBS, "${dir}${cachedir}/")
|
2009-11-01 18:38:41 +00:00
|
|
|
or die (_g("Cannot read apt cache directory/.\n"));
|
2009-03-08 18:10:24 +00:00
|
|
|
my @files=grep(!m:\.\.?$:, readdir DEBS);
|
|
|
|
closedir (DEBS);
|
|
|
|
foreach my $file (@files)
|
|
|
|
{
|
|
|
|
next if (-d $file);
|
|
|
|
next unless ($file =~ /\.bin$/);
|
|
|
|
unlink ("${dir}${cachedir}$file");
|
|
|
|
}
|
2009-03-22 16:28:09 +00:00
|
|
|
if ($unpack eq "true")
|
2009-03-08 18:10:24 +00:00
|
|
|
{
|
|
|
|
opendir (DEBS, "${dir}${cachedir}/archives/")
|
2009-11-01 18:38:41 +00:00
|
|
|
or die (_g("Cannot read apt archives directory/.\n"));
|
2009-03-08 18:10:24 +00:00
|
|
|
my @files=grep(!m:\.\.?$:, readdir DEBS);
|
|
|
|
closedir (DEBS);
|
|
|
|
foreach my $file (@files)
|
|
|
|
{
|
|
|
|
next if (-d $file);
|
|
|
|
next unless ($file =~ /\.deb$/);
|
2009-03-29 15:37:34 +00:00
|
|
|
(defined $sourcedir) ?
|
|
|
|
system ("mv ${dir}${cachedir}archives/$file $sourcedir/$file") :
|
2009-03-08 18:10:24 +00:00
|
|
|
unlink ("${dir}${cachedir}archives/$file");
|
2009-03-29 15:37:34 +00:00
|
|
|
;
|
2009-03-08 18:10:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-22 16:28:09 +00:00
|
|
|
# if native arch, do a few tasks just because we can and probably should.
|
|
|
|
sub native
|
|
|
|
{
|
2009-11-01 18:38:41 +00:00
|
|
|
print _g("I: Native mode - configuring unpacked packages . . .\n");
|
2009-09-15 16:34:09 +00:00
|
|
|
my $e=`LC_ALL=C printenv`;
|
2009-03-23 22:28:50 +00:00
|
|
|
my $str = ($e =~ /\nUSER=root\n/) ? "" : "sudo";
|
|
|
|
$str = (-f "/usr/bin/sudo") ? "$str" : "";
|
2009-09-15 16:34:09 +00:00
|
|
|
my $env = "DEBIAN_FRONTEND=noninteractive ".
|
|
|
|
"DEBCONF_NONINTERACTIVE_SEEN=true ".
|
|
|
|
"LC_ALL=C LANGUAGE=C LANG=C";
|
2009-11-01 18:38:41 +00:00
|
|
|
printf (_g("I: dpkg configuration settings:\n\t%s\n"), $env);
|
2009-11-15 23:15:44 +00:00
|
|
|
# check that we have a workable shell inside the chroot
|
|
|
|
&check_bin_sh("$dir");
|
2009-09-15 16:34:09 +00:00
|
|
|
system ("$str $env chroot $dir dpkg --configure -a");
|
2009-03-22 16:28:09 +00:00
|
|
|
}
|
|
|
|
|
2009-03-08 18:10:24 +00:00
|
|
|
sub get_required_debs
|
|
|
|
{
|
|
|
|
# emulate required="$(get_debs Priority: required)"
|
|
|
|
# from debootstrap/functions
|
|
|
|
# needs to be run after the first apt-get install so that
|
|
|
|
# Packages files exist
|
|
|
|
my @required=();
|
|
|
|
my @debs=();
|
|
|
|
opendir (PKGS, "${dir}${libdir}lists/")
|
2009-11-01 18:38:41 +00:00
|
|
|
or die sprintf(_g("Cannot open %s directory. %s\n"),
|
|
|
|
"${dir}${libdir}lists/", $!);
|
2009-03-08 18:10:24 +00:00
|
|
|
my @lists=grep(/_Packages$/, readdir (PKGS));
|
|
|
|
closedir (PKGS);
|
|
|
|
foreach my $strap (@debootstrap)
|
|
|
|
{
|
|
|
|
my $s = lc($strap);
|
|
|
|
foreach my $l (@lists)
|
|
|
|
{
|
|
|
|
next unless ($l =~ /$s/);
|
|
|
|
push (@required, $l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach my $file (@required)
|
|
|
|
{
|
|
|
|
my $fh = IO::File->new("${dir}${libdir}lists/$file");
|
|
|
|
my $parser = Parse::Debian::Packages->new( $fh );
|
|
|
|
while (my %package = $parser->next)
|
|
|
|
{
|
|
|
|
next unless $package{'Priority'} eq "required";
|
|
|
|
push @debs, $package{'Package'};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return \@debs;
|
2009-03-05 19:07:21 +00:00
|
|
|
}
|
|
|
|
|
2009-09-15 16:34:09 +00:00
|
|
|
# inherited from apt-cross
|
|
|
|
sub prepare_sources_list
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-03-05 19:07:21 +00:00
|
|
|
sub usageversion {
|
2009-11-01 18:38:41 +00:00
|
|
|
printf STDERR (_g("
|
2009-09-15 16:34:09 +00:00
|
|
|
%s version %s
|
2009-03-05 19:07:21 +00:00
|
|
|
|
|
|
|
Usage:
|
2009-09-15 16:34:09 +00:00
|
|
|
%s [-a ARCH] [-d DIR] -f CONFIG_FILE
|
|
|
|
%s -?|-h|--help|--version
|
2009-03-05 19:07:21 +00:00
|
|
|
|
2009-03-06 12:00:27 +00:00
|
|
|
Command:
|
2009-03-05 19:07:21 +00:00
|
|
|
-f|--file CONFIG_FILE: path the the multistrap configuration file.
|
2009-03-06 12:00:27 +00:00
|
|
|
|
|
|
|
Options:
|
|
|
|
-a|--arch ARCHITECTURE: override the configuration file architecture.
|
|
|
|
-d|--dir PATH: override the configuration file directory.
|
2009-03-23 22:28:50 +00:00
|
|
|
--no-auth: do not use Secure Apt for any repositories
|
|
|
|
--tidy-up: remove apt cache data and downloaded archives.
|
2009-03-05 19:07:21 +00:00
|
|
|
-?|-h|--help: print this usage message and exit
|
|
|
|
--version: print this usage message and exit
|
|
|
|
|
2009-09-15 16:34:09 +00:00
|
|
|
%s extends debootstrap to provide support for multiple
|
2009-03-05 19:07:21 +00:00
|
|
|
repositories, using a configuration file to specify the relevant suites,
|
2009-03-22 16:28:09 +00:00
|
|
|
architecture, extra packages and the mirror to use for each repository.
|
2009-03-05 19:07:21 +00:00
|
|
|
|
|
|
|
Example configuration:
|
2009-03-06 12:00:27 +00:00
|
|
|
[General]
|
2009-03-22 16:28:09 +00:00
|
|
|
arch=armel
|
2009-03-06 12:00:27 +00:00
|
|
|
directory=/opt/multistrap/
|
2009-03-23 22:28:50 +00:00
|
|
|
# same as --tidy-up option if set to true
|
|
|
|
cleanup=true
|
|
|
|
# same as --no-auth option if set to true
|
2009-03-24 13:37:53 +00:00
|
|
|
# keyring packages listed in each debootstrap will
|
|
|
|
# still be installed.
|
2009-03-23 22:28:50 +00:00
|
|
|
noauth=false
|
2009-03-22 16:28:09 +00:00
|
|
|
# extract all downloaded archives (default is true)
|
|
|
|
unpack=true
|
2009-11-15 23:15:44 +00:00
|
|
|
# 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
|
2009-03-22 16:28:09 +00:00
|
|
|
# the order of sections is not important.
|
2009-03-23 22:28:50 +00:00
|
|
|
# the debootstrap option determines which repository
|
|
|
|
# is used to calculate the list of Priority: required packages.
|
2009-03-06 12:00:27 +00:00
|
|
|
debootstrap=Debian
|
|
|
|
|
2009-03-05 19:07:21 +00:00
|
|
|
[Debian]
|
|
|
|
packages=
|
|
|
|
source=http://ftp.uk.debian.org/debian
|
2009-03-23 22:28:50 +00:00
|
|
|
keyring=debian-archive-keyring
|
2009-03-05 19:07:21 +00:00
|
|
|
suite=lenny
|
|
|
|
|
|
|
|
This will result in a completely normal debootstrap of Debian lenny from
|
2009-03-22 16:28:09 +00:00
|
|
|
the specified mirror, for armel in /opt/multistrap/.
|
2009-03-06 12:00:27 +00:00
|
|
|
|
|
|
|
'Architecture' and 'directory' can be overridden on the command line.
|
2009-03-05 19:07:21 +00:00
|
|
|
|
|
|
|
Specify a package to extend the debootstap to include that package and
|
2009-03-23 22:28:50 +00:00
|
|
|
all dependencies. Dependencies will be calculated by apt so as to use
|
|
|
|
only the most recent suitable version from all configured repositories.
|
2009-03-05 19:07:21 +00:00
|
|
|
|
|
|
|
General settings:
|
|
|
|
|
|
|
|
'directory' specifies the top level directory where the debootstrap
|
|
|
|
will be created - it is not packed into a .tgz once complete.
|
|
|
|
|
2009-11-01 18:38:41 +00:00
|
|
|
"), $progname, $ourversion, $progname, $progname, $progname)
|
|
|
|
or die ("$progname: ". _g("failed to write usage:") . "$!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
sub _g {
|
|
|
|
return gettext(shift);
|
2009-03-05 19:07:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
=pod
|
|
|
|
|
2009-03-06 12:00:27 +00:00
|
|
|
=head1 Name
|
|
|
|
|
|
|
|
em_multistrap - extends debootstrap for multiple repository support
|
|
|
|
|
2009-03-08 18:10:24 +00:00
|
|
|
=head1 Synopsis
|
|
|
|
|
|
|
|
em_multistrap [-a ARCH] [-d DIR] -f CONFIG_FILE
|
|
|
|
em_multistrap -?|-h|--help|--version
|
|
|
|
|
2009-03-23 22:28:50 +00:00
|
|
|
=head1 Options
|
|
|
|
|
|
|
|
(These options can also be set in the configuration file.)
|
|
|
|
|
|
|
|
--tidy-up - remove apt cache data, downloaded Packages files and
|
|
|
|
the apt package cache. Same as cleanup=true.
|
|
|
|
|
|
|
|
--no-auth - allow the use of unauthenticated repositories. Same
|
|
|
|
as noauth=true
|
|
|
|
|
2009-03-05 19:07:21 +00:00
|
|
|
=head1 Description
|
|
|
|
|
2009-03-23 22:28:50 +00:00
|
|
|
em_multistrap provides a debootstrap-like method based on apt and
|
|
|
|
extended to provide support for multiple repositories, using a
|
|
|
|
configuration file to specify the relevant suites, architecture,
|
|
|
|
extra packages and the mirror to use for each debootstrap.
|
|
|
|
|
|
|
|
The aim is to create a complete debootstrap with all packages
|
|
|
|
installed and configured, instead of just the base system.
|
2009-03-05 19:07:21 +00:00
|
|
|
|
|
|
|
Example configuration:
|
|
|
|
|
|
|
|
[General]
|
2009-03-22 16:28:09 +00:00
|
|
|
arch=armel
|
2009-03-08 18:10:24 +00:00
|
|
|
directory=/opt/multistrap/
|
2009-03-23 22:28:50 +00:00
|
|
|
# same as --tidy-up option if set to true
|
|
|
|
cleanup=true
|
|
|
|
# same as --no-auth option if set to true
|
2009-03-24 13:37:53 +00:00
|
|
|
# keyring packages listed in each debootstrap will
|
|
|
|
# still be installed.
|
2009-03-23 22:28:50 +00:00
|
|
|
noauth=false
|
2009-03-22 16:28:09 +00:00
|
|
|
# extract all downloaded archives (default is true)
|
|
|
|
unpack=true
|
2009-11-02 12:01:47 +00:00
|
|
|
# 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
|
2009-03-22 16:28:09 +00:00
|
|
|
# the order of sections is not important.
|
2009-03-23 22:28:50 +00:00
|
|
|
# the debootstrap option determines which repository
|
|
|
|
# is used to calculate the list of Priority: required packages.
|
2009-03-05 19:07:21 +00:00
|
|
|
debootstrap=Debian
|
|
|
|
|
|
|
|
[Debian]
|
|
|
|
packages=
|
|
|
|
source=http://ftp.uk.debian.org/debian
|
2009-03-23 22:28:50 +00:00
|
|
|
keyring=debian-archive-keyring
|
2009-03-05 19:07:21 +00:00
|
|
|
suite=lenny
|
|
|
|
|
|
|
|
This will result in a completely normal debootstrap of Debian lenny from
|
2009-03-23 22:28:50 +00:00
|
|
|
the specified mirror, for armel in '/opt/multistrap/'.
|
2009-03-08 18:10:24 +00:00
|
|
|
|
2009-03-23 22:28:50 +00:00
|
|
|
Specify a package to extend the multistrap to include that package and
|
|
|
|
all dependencies.
|
|
|
|
|
|
|
|
Specify more debootstraps by adding new sections. Section names are used
|
|
|
|
in the debootstrap general option.
|
2009-03-05 19:07:21 +00:00
|
|
|
|
|
|
|
Section names are case-insensitive.
|
|
|
|
|
2009-03-23 22:28:50 +00:00
|
|
|
e.g. change
|
|
|
|
|
|
|
|
debootstrap=Debian
|
|
|
|
|
|
|
|
to
|
|
|
|
|
|
|
|
debootstrap=Grip
|
|
|
|
|
|
|
|
then add the new section for Grip:
|
|
|
|
|
|
|
|
[Grip]
|
|
|
|
packages=locales
|
|
|
|
keyring=emdebian-archive-keyring
|
|
|
|
source=http://www.emdebian.org/grip
|
|
|
|
suite=lenny
|
|
|
|
|
|
|
|
Setting Grip instead of Debian in the debootstrap option, as above,
|
|
|
|
will provide a base system from Emdebian Grip 1.0 and locate any
|
|
|
|
missing dependencies in Debian 5.0 Lenny, allowing you to add any
|
|
|
|
package(s) you need from Debian that are not yet in Emdebian Grip.
|
2009-03-05 19:07:21 +00:00
|
|
|
|
2009-03-23 22:28:50 +00:00
|
|
|
All dependencies are resolved only by apt, using all configured
|
|
|
|
repositories, to use only the most recent and most suitable
|
|
|
|
dependencies. Note that multistrap turns off Install-Recommends
|
|
|
|
so if the multistrap needs a package that is only a Recommended
|
|
|
|
dependency, the recommended package needs to be specified in the
|
|
|
|
packages line explicitly.
|
|
|
|
|
|
|
|
'Architecture' and 'directory' can be overridden on the command line.
|
|
|
|
Other general options have command line options, except debootstrap
|
|
|
|
itself.
|
2009-03-05 19:07:21 +00:00
|
|
|
|
2009-03-08 18:10:24 +00:00
|
|
|
=head1 General settings:
|
2009-03-05 19:07:21 +00:00
|
|
|
|
|
|
|
'directory' specifies the top level directory where the debootstrap
|
|
|
|
will be created - it is not packed into a .tgz once complete.
|
|
|
|
|
2009-03-23 22:28:50 +00:00
|
|
|
As with debootstrap, em_multistrap will continue after errors.
|
2009-03-05 19:07:21 +00:00
|
|
|
|
2009-03-23 22:28:50 +00:00
|
|
|
em_multistrap does not currently implement the machine:variant support
|
2009-03-22 16:28:09 +00:00
|
|
|
used in Emdebian but the build directory is not packed up at the
|
|
|
|
end of the run so other scripts can be used to implement customisations.
|
2009-03-06 12:00:27 +00:00
|
|
|
|
2009-03-23 22:28:50 +00:00
|
|
|
=head1 Secure Apt
|
|
|
|
|
|
|
|
To use authenticated apt repositories, multistrap either needs to be
|
|
|
|
able to install an appropriate keyring package from the existing apt
|
|
|
|
sources *outside the multistrap environment* or have the relevant keys
|
|
|
|
already configured using apt-key *on the host system*.
|
|
|
|
|
|
|
|
If relevant packages exist, specify them in the 'keyring' option for
|
|
|
|
each repository. em_multistrap will then check that apt has already
|
|
|
|
installed this package so that the repository can be authenticated
|
|
|
|
before any packages are downloaded from it.
|
|
|
|
|
|
|
|
Note that *all* repositories to be used with multistrap must be
|
|
|
|
authenticated or apt will fail. Similarly, secure apt can only be
|
|
|
|
disabled for all repositories (by using the --no-auth command line
|
|
|
|
option or setting the general noauth option in the configuration
|
|
|
|
file), even if only one repository does not have a suitable keyring
|
|
|
|
available. Not all packages need keyring packages, if you configure
|
|
|
|
apt-key appropriately.
|
|
|
|
|
|
|
|
The keyring package(s) will also be installed inside the multistrap
|
|
|
|
environment to match the installed apt sources for the multistrap.
|
|
|
|
|
|
|
|
All configuration of apt-key needs to be done for the machine
|
|
|
|
running multistrap itself.
|
|
|
|
|
2009-03-22 16:28:09 +00:00
|
|
|
=head1 State
|
2009-03-08 18:10:24 +00:00
|
|
|
|
2009-03-22 16:28:09 +00:00
|
|
|
multistrap is stateless - if the directory exists, it will simply
|
|
|
|
proceed as normal and apt will try to pick up where it left off.
|
|
|
|
|
2009-11-02 12:01:47 +00:00
|
|
|
=head1 Configuration
|
|
|
|
|
|
|
|
multistrap unpacks the downloaded packages but other stages of
|
|
|
|
system configuration are not attempted. Examples include:
|
|
|
|
|
|
|
|
/etc/inittab
|
|
|
|
/etc/fstab
|
|
|
|
/etc/hosts
|
|
|
|
/etc/securetty
|
|
|
|
/etc/modules
|
|
|
|
/etc/hostname
|
|
|
|
/etc/network/interfaces
|
|
|
|
/etc/init.d
|
|
|
|
/etc/dhcp3
|
|
|
|
|
|
|
|
Any device-specific device nodes will also need to be created
|
|
|
|
using MAKEDEV.
|
|
|
|
|
|
|
|
Once multistrap has successfully created the basic file and
|
|
|
|
directory layout, other device-specific scripts are needed before
|
|
|
|
the filesystem can be packaged up and installed onto the
|
|
|
|
target device.
|
|
|
|
|
|
|
|
Once installed, the packages themselves need to be configured
|
|
|
|
using the package maintainer scripts and C<dpkg --configure -a>,
|
|
|
|
unless this is a native multistrap.
|
|
|
|
|
|
|
|
For C<dpkg> to work, F</proc> and F</sysfs> must be mounted (or
|
|
|
|
mountable), F</dev/pts> is also recommended.
|
|
|
|
|
|
|
|
See also: http://wiki.debian.org/Multistrap
|
|
|
|
|
|
|
|
=head1 Environment
|
|
|
|
|
|
|
|
To configure the unpacked packages (whether in native or cross mode),
|
|
|
|
certain environment variables are needed:
|
|
|
|
|
|
|
|
Debconf needs to be told to accept that user interaction is not
|
|
|
|
desired:
|
|
|
|
|
|
|
|
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
|
|
|
|
|
|
|
|
Perl needs to be told to accept that no locales are available inside
|
|
|
|
the chroot and not to complain:
|
|
|
|
|
|
|
|
LC_ALL=C LANGUAGE=C LANG=C
|
|
|
|
|
|
|
|
Then, dpkg can configure the packages:
|
|
|
|
|
|
|
|
chroot method (PATH = top directory of chroot):
|
|
|
|
|
|
|
|
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
|
|
|
|
LC_ALL=C LANGUAGE=C LANG=C chroot /PATH/ dpkg --configure -a
|
|
|
|
|
|
|
|
at a login shell:
|
|
|
|
|
|
|
|
# export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
|
|
|
|
# export LC_ALL=C LANGUAGE=C LANG=C
|
|
|
|
# dpkg --configure -a
|
|
|
|
|
|
|
|
(As above, dpkg needs F</proc> and F</sysfs> mounted first.)
|
|
|
|
|
2009-03-22 16:28:09 +00:00
|
|
|
=head1 Native mode - multistrap
|
|
|
|
|
|
|
|
em_multistrap was not intended for native support, it was developed for
|
2009-03-23 22:28:50 +00:00
|
|
|
cross architecture support. In order for multiple repositories to be
|
|
|
|
used, em_multistrap only unpacks the packages selected by apt.
|
2009-03-08 18:10:24 +00:00
|
|
|
|
2009-03-22 16:28:09 +00:00
|
|
|
In native mode, various post-multistrap operations are likely to be
|
|
|
|
needed that debootstrap would do for you:
|
|
|
|
|
|
|
|
1. copy /etc/hosts into the chroot
|
|
|
|
2. clean the environment to unset LANGUAGE, LC_ALL and LANG
|
|
|
|
to silence nuisance perl warnings that obscure other errors
|
|
|
|
|
|
|
|
(An alternative to unset the localisation variables is to add
|
|
|
|
locales to your multistrap configuration file in the 'packages'
|
|
|
|
option.
|
2009-03-08 18:10:24 +00:00
|
|
|
|
2009-11-02 12:01:47 +00:00
|
|
|
A native multistrap can be used directly with chroot, so
|
|
|
|
C<multistrap> runs C<dpkg --configure -a> at the end of the
|
|
|
|
multistrap process.
|
2009-03-23 22:28:50 +00:00
|
|
|
|
2009-03-05 19:07:21 +00:00
|
|
|
=cut
|