diff --git a/Makefile b/Makefile index e459e71..a04380c 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,8 @@ clean: $(RM) *tar.gz.cdbs-config_list $(RM) *.1 *.3 $(RM) doc/po4a.config + $(RM) -r doc/html/multistrap/ doc/html/emdebian-rootfs/ check: test: - diff --git a/debian/changelog b/debian/changelog index 47bb511..0266088 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,10 @@ emdebian-rootfs (2.0.3) unstable; urgency=low * [INTL:pt] Portuguese manpage translation. (Closes: #544953) + * Include example config and provide sensible default + configuration values. (Closes: #545488) - -- Neil Williams Fri, 04 Sep 2009 19:22:46 +0100 + -- Neil Williams Tue, 15 Sep 2009 16:26:24 +0100 emdebian-rootfs (2.0.2) unstable; urgency=low diff --git a/debian/multistrap.install b/debian/multistrap.install index aed51ac..7c909f6 100644 --- a/debian/multistrap.install +++ b/debian/multistrap.install @@ -1,4 +1,5 @@ em_multistrap ./usr/sbin/ multistrap ./usr/sbin/ doc/multistrap/man/* ./usr/share/man/ +examples/multistrap-example.conf ./usr/share/doc/multistrap/examples/ bash/multistrap ./etc/bash_completion.d/ diff --git a/em_multistrap b/em_multistrap index c36f6ae..1a29730 100755 --- a/em_multistrap +++ b/em_multistrap @@ -26,9 +26,9 @@ use vars qw/ $progname $ourversion $dstrap $extra @aptsources $dir $include $arch $foreign $suite $url $unpack $sourcedir @e $sourcesname $libdir $dpkgdir @debootstrap %suites $mirror $etcdir $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); -$ourversion = "0.0.6"; +$ourversion = "0.0.7"; $unpack = "true"; while( @ARGV ) { @@ -114,18 +114,40 @@ foreach $section (sort keys %keys) print "$progname $ourversion using $file\n"; $host = `dpkg-architecture -qDEB_BUILD_ARCH`; 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); -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 $libdir = "var/lib/apt/"; # lists $etcdir = "etc/apt/"; # sources $dpkgdir = "var/lib/dpkg/"; # state mkdir ("$dir") if (not -d "$dir"); -system ("mkdir -p ${dir}${cachedir}"); -system ("mkdir -p ${dir}${libdir}"); -system ("mkdir -p ${dir}${dpkgdir}"); -system ("mkdir -p ${dir}etc/apt/sources.list.d/"); +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/"); @dirs = qw/ alternatives info parts updates/; @touch = qw/ diversions statoverride status lock/; foreach my $dpkgd (@dirs) { @@ -173,10 +195,17 @@ foreach $repo (sort keys %suites) } foreach my $aptsrc (@aptsources) { - if (-d "${dir}etc/apt/") + if (defined $deflist) { open (SOURCES, ">>${dir}etc/apt/sources.list.d/multistrap.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}; $suite = $suites{$aptsrc}; print SOURCES< Processing conffiles for $pkg\n"; + printf (" -> Processing conffiles for %s\n", $pkg); open (CONF, "./${dpkgdir}info/$pkg.conffiles"); my @lines=; close (CONF); @@ -399,10 +431,14 @@ sub tidy_apt sub native { print "I: Native mode - configuring unpacked packages . . .\n"; - my $e=`printenv`; + my $e=`LC_ALL=C printenv`; my $str = ($e =~ /\nUSER=root\n/) ? "" : "sudo"; $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 @@ -414,7 +450,7 @@ sub get_required_debs my @required=(); my @debs=(); 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)); closedir (PKGS); foreach my $strap (@debootstrap) @@ -439,13 +475,42 @@ sub get_required_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 = ; + 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() { + push @source_list, $_; + } + close (SOURCES); + } + closedir (FILES); + } + return \@source_list; +} + sub usageversion { - print(STDERR <