Include example config and provide sensible default configuration values. (Closes: #545488)
git-svn-id: http://emdebian.org/svn/current@6626 563faec7-e20c-0410-992a-a66f704d0ccd
This commit is contained in:
parent
affe599c7d
commit
424abe579a
5 changed files with 126 additions and 33 deletions
2
Makefile
2
Makefile
|
@ -7,8 +7,8 @@ clean:
|
||||||
$(RM) *tar.gz.cdbs-config_list
|
$(RM) *tar.gz.cdbs-config_list
|
||||||
$(RM) *.1 *.3
|
$(RM) *.1 *.3
|
||||||
$(RM) doc/po4a.config
|
$(RM) doc/po4a.config
|
||||||
|
$(RM) -r doc/html/multistrap/ doc/html/emdebian-rootfs/
|
||||||
|
|
||||||
check:
|
check:
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
|
||||||
|
|
4
debian/changelog
vendored
4
debian/changelog
vendored
|
@ -1,8 +1,10 @@
|
||||||
emdebian-rootfs (2.0.3) unstable; urgency=low
|
emdebian-rootfs (2.0.3) unstable; urgency=low
|
||||||
|
|
||||||
* [INTL:pt] Portuguese manpage translation. (Closes: #544953)
|
* [INTL:pt] Portuguese manpage translation. (Closes: #544953)
|
||||||
|
* Include example config and provide sensible default
|
||||||
|
configuration values. (Closes: #545488)
|
||||||
|
|
||||||
-- Neil Williams <codehelp@debian.org> Fri, 04 Sep 2009 19:22:46 +0100
|
-- Neil Williams <codehelp@debian.org> Tue, 15 Sep 2009 16:26:24 +0100
|
||||||
|
|
||||||
emdebian-rootfs (2.0.2) unstable; urgency=low
|
emdebian-rootfs (2.0.2) unstable; urgency=low
|
||||||
|
|
||||||
|
|
1
debian/multistrap.install
vendored
1
debian/multistrap.install
vendored
|
@ -1,4 +1,5 @@
|
||||||
em_multistrap ./usr/sbin/
|
em_multistrap ./usr/sbin/
|
||||||
multistrap ./usr/sbin/
|
multistrap ./usr/sbin/
|
||||||
doc/multistrap/man/* ./usr/share/man/
|
doc/multistrap/man/* ./usr/share/man/
|
||||||
|
examples/multistrap-example.conf ./usr/share/doc/multistrap/examples/
|
||||||
bash/multistrap ./etc/bash_completion.d/
|
bash/multistrap ./etc/bash_completion.d/
|
||||||
|
|
127
em_multistrap
127
em_multistrap
|
@ -26,9 +26,9 @@ use vars qw/ $progname $ourversion $dstrap $extra @aptsources
|
||||||
$dir $include $arch $foreign $suite $url $unpack $sourcedir
|
$dir $include $arch $foreign $suite $url $unpack $sourcedir
|
||||||
@e $sourcesname $libdir $dpkgdir @debootstrap %suites $mirror $etcdir
|
@e $sourcesname $libdir $dpkgdir @debootstrap %suites $mirror $etcdir
|
||||||
$repo @dirs @touch %sources $section %keys $host $key $value $type
|
$repo @dirs @touch %sources $section %keys $host $key $value $type
|
||||||
$file $config $tidy $noauth $keyring %keyrings /;
|
$file $config $tidy $noauth $keyring %keyrings $deflist /;
|
||||||
$progname = basename($0);
|
$progname = basename($0);
|
||||||
$ourversion = "0.0.6";
|
$ourversion = "0.0.7";
|
||||||
$unpack = "true";
|
$unpack = "true";
|
||||||
|
|
||||||
while( @ARGV ) {
|
while( @ARGV ) {
|
||||||
|
@ -114,18 +114,40 @@ foreach $section (sort keys %keys)
|
||||||
print "$progname $ourversion using $file\n";
|
print "$progname $ourversion using $file\n";
|
||||||
$host = `dpkg-architecture -qDEB_BUILD_ARCH`;
|
$host = `dpkg-architecture -qDEB_BUILD_ARCH`;
|
||||||
chomp ($host);
|
chomp ($host);
|
||||||
|
if (not defined $arch)
|
||||||
|
{
|
||||||
|
$arch = $host;
|
||||||
|
printf ("Defaulting architecture to native: %s\n",$arch);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf ("Using foreign architecture: %s\n", $arch);
|
||||||
|
}
|
||||||
$foreign++ if ($host ne $arch);
|
$foreign++ if ($host ne $arch);
|
||||||
print "$progname building '$arch' multistrap on '$host'\n";
|
|
||||||
|
unless (keys %sources and @aptsources)
|
||||||
|
{
|
||||||
|
my $msg = sprintf("No sources defined for a foreign multistrap
|
||||||
|
Using your existing apt sources. To use different sources,
|
||||||
|
and list them with aptsources= in '%s'.", $file);
|
||||||
|
warn ("$progname: $msg\n");
|
||||||
|
$deflist = prepare_sources_list();
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("%s building %s multistrap on '%s'\n", $progname, $arch, $host);
|
||||||
$cachedir = "var/cache/apt/"; # archives
|
$cachedir = "var/cache/apt/"; # archives
|
||||||
$libdir = "var/lib/apt/"; # lists
|
$libdir = "var/lib/apt/"; # lists
|
||||||
$etcdir = "etc/apt/"; # sources
|
$etcdir = "etc/apt/"; # sources
|
||||||
$dpkgdir = "var/lib/dpkg/"; # state
|
$dpkgdir = "var/lib/dpkg/"; # state
|
||||||
|
|
||||||
mkdir ("$dir") if (not -d "$dir");
|
mkdir ("$dir") if (not -d "$dir");
|
||||||
system ("mkdir -p ${dir}${cachedir}");
|
system ("mkdir -p ${dir}${cachedir}") if (not -d "${dir}${cachedir}");
|
||||||
system ("mkdir -p ${dir}${libdir}");
|
system ("mkdir -p ${dir}${libdir}") if (not -d "${dir}${libdir}");
|
||||||
system ("mkdir -p ${dir}${dpkgdir}");
|
system ("mkdir -p ${dir}${dpkgdir}") if (not -d "${dir}${dpkgdir}");
|
||||||
system ("mkdir -p ${dir}etc/apt/sources.list.d/");
|
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/");
|
||||||
@dirs = qw/ alternatives info parts updates/;
|
@dirs = qw/ alternatives info parts updates/;
|
||||||
@touch = qw/ diversions statoverride status lock/;
|
@touch = qw/ diversions statoverride status lock/;
|
||||||
foreach my $dpkgd (@dirs) {
|
foreach my $dpkgd (@dirs) {
|
||||||
|
@ -173,10 +195,17 @@ foreach $repo (sort keys %suites)
|
||||||
}
|
}
|
||||||
foreach my $aptsrc (@aptsources)
|
foreach my $aptsrc (@aptsources)
|
||||||
{
|
{
|
||||||
if (-d "${dir}etc/apt/")
|
if (defined $deflist)
|
||||||
{
|
{
|
||||||
open (SOURCES, ">>${dir}etc/apt/sources.list.d/multistrap.sources.list")
|
open (SOURCES, ">>${dir}etc/apt/sources.list.d/multistrap.sources.list")
|
||||||
or die "Cannot open sources list $!";
|
or die "Cannot open sources list $!";
|
||||||
|
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"). $!;
|
||||||
$mirror = $sources{$aptsrc};
|
$mirror = $sources{$aptsrc};
|
||||||
$suite = $suites{$aptsrc};
|
$suite = $suites{$aptsrc};
|
||||||
print SOURCES<<END;
|
print SOURCES<<END;
|
||||||
|
@ -190,13 +219,13 @@ my $k;
|
||||||
foreach my $pkg (values %keyrings)
|
foreach my $pkg (values %keyrings)
|
||||||
{
|
{
|
||||||
next if (not defined $pkg);
|
next if (not defined $pkg);
|
||||||
my $status = `dpkg -s $pkg`;
|
my $status = `LC_ALL=C dpkg -s $pkg`;
|
||||||
next if $status =~ /Status: install ok installed/;
|
next if $status =~ /Status: install ok installed/;
|
||||||
$k .= "$pkg ";
|
$k .= "$pkg ";
|
||||||
}
|
}
|
||||||
if (defined $k)
|
if (defined $k)
|
||||||
{
|
{
|
||||||
my $e=`printenv`;
|
my $e=`LC_ALL=C printenv`;
|
||||||
my $str = ($e =~ /\nUSER=root\n/) ? "" : "sudo ";
|
my $str = ($e =~ /\nUSER=root\n/) ? "" : "sudo ";
|
||||||
$str = (-f "/usr/bin/sudo") ? "$str" : "";
|
$str = (-f "/usr/bin/sudo") ? "$str" : "";
|
||||||
print "I: Installing $k\n";
|
print "I: Installing $k\n";
|
||||||
|
@ -214,9 +243,12 @@ $config_str .= " -o Dir::Etc=${dir}${etcdir}";
|
||||||
$sourcesname = "sources.list.d/multistrap.sources.list";
|
$sourcesname = "sources.list.d/multistrap.sources.list";
|
||||||
$config_str .= " -o Dir::Etc::SourceList=${dir}${etcdir}$sourcesname";
|
$config_str .= " -o Dir::Etc::SourceList=${dir}${etcdir}$sourcesname";
|
||||||
$config_str .= " -o Dir::State=${dir}${libdir}";
|
$config_str .= " -o Dir::State=${dir}${libdir}";
|
||||||
$config_str .= " -o Dir::State::Status=${dir}${dpkgdir}/status";
|
$config_str .= " -o Dir::State::Status=${dir}${dpkgdir}status";
|
||||||
$config_str .= " -o Dir::Cache=${dir}${cachedir}";
|
$config_str .= " -o Dir::Cache=${dir}${cachedir}";
|
||||||
system ("apt-get $config_str update");
|
printf ("Getting package lists: apt-get %s update\n", $config_str);
|
||||||
|
$retval = system ("apt-get $config_str update");
|
||||||
|
die (sprintf("apt update failed. Exit value: ").($retval/256)."\n")
|
||||||
|
if ($retval != 0);
|
||||||
$str = join (' ', values %packages) . " ";
|
$str = join (' ', values %packages) . " ";
|
||||||
chomp($str);
|
chomp($str);
|
||||||
$str .= join (' ', values %keyrings) . " ";
|
$str .= join (' ', values %keyrings) . " ";
|
||||||
|
@ -233,7 +265,7 @@ die ("apt download failed. Exit value: ".($retval/256)."\n")
|
||||||
system ("touch ${dir}${libdir}lists/lock");
|
system ("touch ${dir}${libdir}lists/lock");
|
||||||
&native if (not defined ($foreign));
|
&native if (not defined ($foreign));
|
||||||
(not defined $tidy) ? system ("apt-get $config_str update") : &tidy_apt;
|
(not defined $tidy) ? system ("apt-get $config_str update") : &tidy_apt;
|
||||||
print "\nMultistrap system installed successfully in $dir.\n\n";
|
printf ("\nMultistrap system installed successfully in %s.\n\n", $dir);
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|
||||||
sub force_unpack
|
sub force_unpack
|
||||||
|
@ -246,8 +278,8 @@ sub force_unpack
|
||||||
print "I: Calculating obsolete packages\n";
|
print "I: Calculating obsolete packages\n";
|
||||||
foreach $deb (sort @archives)
|
foreach $deb (sort @archives)
|
||||||
{
|
{
|
||||||
my $version = `dpkg -f ${dir}${cachedir}archives/$deb Version`;
|
my $version = `LC_ALL=C dpkg -f ${dir}${cachedir}archives/$deb Version`;
|
||||||
my $package = `dpkg -f ${dir}${cachedir}archives/$deb Package`;
|
my $package = `LC_ALL=C dpkg -f ${dir}${cachedir}archives/$deb Package`;
|
||||||
chomp ($version);
|
chomp ($version);
|
||||||
chomp ($package);
|
chomp ($package);
|
||||||
if (exists $unpack{$package})
|
if (exists $unpack{$package})
|
||||||
|
@ -260,13 +292,13 @@ sub force_unpack
|
||||||
{
|
{
|
||||||
my $old = $deb;
|
my $old = $deb;
|
||||||
$old =~ s/$version/$unpack{$package}/;
|
$old =~ s/$version/$unpack{$package}/;
|
||||||
print "I: Removing $old\n";
|
printf ("I: Removing %s\n", $old);
|
||||||
unlink "${dir}${cachedir}archives/$old";
|
unlink "${dir}${cachedir}archives/$old";
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "I: Removing $deb\n";
|
printf ("I: Removing %s\n", $deb);
|
||||||
unlink "${dir}${cachedir}archives/$deb";
|
unlink "${dir}${cachedir}archives/$deb";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,10 +315,10 @@ sub force_unpack
|
||||||
chdir ("${dir}");
|
chdir ("${dir}");
|
||||||
foreach $deb (sort @archives)
|
foreach $deb (sort @archives)
|
||||||
{
|
{
|
||||||
print "I: Extracting $deb...\n";
|
printf ("I: Extracting %s...\n", $deb);
|
||||||
system ("ar -p \"./${cachedir}archives/$deb\" data.tar.gz | zcat | tar -xf -");
|
system ("ar -p \"./${cachedir}archives/$deb\" data.tar.gz | zcat | tar -xf -");
|
||||||
my $ver=`dpkg -f ./${cachedir}archives/$deb Version`;
|
my $ver=`LC_ALL=C dpkg -f ./${cachedir}archives/$deb Version`;
|
||||||
my $pkg=`dpkg -f ./${cachedir}archives/$deb Package`;
|
my $pkg=`LC_ALL=C dpkg -f ./${cachedir}archives/$deb Package`;
|
||||||
chomp ($ver);
|
chomp ($ver);
|
||||||
chomp ($pkg);
|
chomp ($pkg);
|
||||||
mkdir ("./tmp");
|
mkdir ("./tmp");
|
||||||
|
@ -333,7 +365,7 @@ sub force_unpack
|
||||||
if ( -f "./${dpkgdir}info/$pkg.conffiles")
|
if ( -f "./${dpkgdir}info/$pkg.conffiles")
|
||||||
{
|
{
|
||||||
print STATUS "Conffiles:\n";
|
print STATUS "Conffiles:\n";
|
||||||
print " -> Processing conffiles for $pkg\n";
|
printf (" -> Processing conffiles for %s\n", $pkg);
|
||||||
open (CONF, "./${dpkgdir}info/$pkg.conffiles");
|
open (CONF, "./${dpkgdir}info/$pkg.conffiles");
|
||||||
my @lines=<CONF>;
|
my @lines=<CONF>;
|
||||||
close (CONF);
|
close (CONF);
|
||||||
|
@ -399,10 +431,14 @@ sub tidy_apt
|
||||||
sub native
|
sub native
|
||||||
{
|
{
|
||||||
print "I: Native mode - configuring unpacked packages . . .\n";
|
print "I: Native mode - configuring unpacked packages . . .\n";
|
||||||
my $e=`printenv`;
|
my $e=`LC_ALL=C printenv`;
|
||||||
my $str = ($e =~ /\nUSER=root\n/) ? "" : "sudo";
|
my $str = ($e =~ /\nUSER=root\n/) ? "" : "sudo";
|
||||||
$str = (-f "/usr/bin/sudo") ? "$str" : "";
|
$str = (-f "/usr/bin/sudo") ? "$str" : "";
|
||||||
system ("$str chroot $dir dpkg --configure -a");
|
my $env = "DEBIAN_FRONTEND=noninteractive ".
|
||||||
|
"DEBCONF_NONINTERACTIVE_SEEN=true ".
|
||||||
|
"LC_ALL=C LANGUAGE=C LANG=C";
|
||||||
|
print "I: dpkg configuration settings:\n\t$env\n";
|
||||||
|
system ("$str $env chroot $dir dpkg --configure -a");
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_required_debs
|
sub get_required_debs
|
||||||
|
@ -414,7 +450,7 @@ sub get_required_debs
|
||||||
my @required=();
|
my @required=();
|
||||||
my @debs=();
|
my @debs=();
|
||||||
opendir (PKGS, "${dir}${libdir}lists/")
|
opendir (PKGS, "${dir}${libdir}lists/")
|
||||||
or die ("Cannot open ${dir}${libdir}lists/ directory. $!\n");
|
or die sprintf("Cannot open %s directory. %s\n","${dir}${libdir}lists/", $!);
|
||||||
my @lists=grep(/_Packages$/, readdir (PKGS));
|
my @lists=grep(/_Packages$/, readdir (PKGS));
|
||||||
closedir (PKGS);
|
closedir (PKGS);
|
||||||
foreach my $strap (@debootstrap)
|
foreach my $strap (@debootstrap)
|
||||||
|
@ -439,13 +475,42 @@ sub get_required_debs
|
||||||
return \@debs;
|
return \@debs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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;
|
||||||
|
}
|
||||||
|
|
||||||
sub usageversion {
|
sub usageversion {
|
||||||
print(STDERR <<END)
|
printf STDERR ("
|
||||||
$progname version $ourversion
|
%s version %s
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
$progname [-a ARCH] [-d DIR] -f CONFIG_FILE
|
%s [-a ARCH] [-d DIR] -f CONFIG_FILE
|
||||||
$progname -?|-h|--help|--version
|
%s -?|-h|--help|--version
|
||||||
|
|
||||||
Command:
|
Command:
|
||||||
-f|--file CONFIG_FILE: path the the multistrap configuration file.
|
-f|--file CONFIG_FILE: path the the multistrap configuration file.
|
||||||
|
@ -458,7 +523,7 @@ Options:
|
||||||
-?|-h|--help: print this usage message and exit
|
-?|-h|--help: print this usage message and exit
|
||||||
--version: print this usage message and exit
|
--version: print this usage message and exit
|
||||||
|
|
||||||
$progname extends debootstrap to provide support for multiple
|
%s extends debootstrap to provide support for multiple
|
||||||
repositories, using a configuration file to specify the relevant suites,
|
repositories, using a configuration file to specify the relevant suites,
|
||||||
architecture, extra packages and the mirror to use for each repository.
|
architecture, extra packages and the mirror to use for each repository.
|
||||||
|
|
||||||
|
@ -499,8 +564,8 @@ General settings:
|
||||||
'directory' specifies the top level directory where the debootstrap
|
'directory' specifies the top level directory where the debootstrap
|
||||||
will be created - it is not packed into a .tgz once complete.
|
will be created - it is not packed into a .tgz once complete.
|
||||||
|
|
||||||
END
|
", $progname, $ourversion, $progname, $progname, $progname)
|
||||||
|| die "$progname: failed to write usage: $!\n";
|
or die "$progname: "."failed to write usage:". "$!\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
|
|
25
examples/multistrap-example.conf
Normal file
25
examples/multistrap-example.conf
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Example multistrap configuration file
|
||||||
|
# to create a plain lenny debootstrap for amd64
|
||||||
|
|
||||||
|
[General]
|
||||||
|
arch=amd64
|
||||||
|
directory=/tmp/multistrap/
|
||||||
|
# same as --tidy-up option if set to true
|
||||||
|
cleanup=true
|
||||||
|
# same as --no-auth option if set to true
|
||||||
|
# keyring packages listed in each debootstrap will
|
||||||
|
# still be installed.
|
||||||
|
noauth=false
|
||||||
|
# extract all downloaded archives (default is true)
|
||||||
|
unpack=true
|
||||||
|
# the order of sections is not important.
|
||||||
|
# the debootstrap option determines which repository
|
||||||
|
# is used to calculate the list of Priority: required packages.
|
||||||
|
debootstrap=Debian
|
||||||
|
aptsources=Debian
|
||||||
|
|
||||||
|
[Debian]
|
||||||
|
packages=
|
||||||
|
source=http://ftp.uk.debian.org/debian
|
||||||
|
keyring=debian-archive-keyring
|
||||||
|
suite=lenny
|
Loading…
Reference in a new issue