Use environment for apt config.

* Use environment variables for apt configuration instead of Dir::Etc.
  Patch from Pip Cet <pipcet@gmail.com> (Closes: #774698)
This commit is contained in:
Neil Williams 2015-05-03 11:07:34 +01:00
parent be19f284af
commit d0224765c2
2 changed files with 36 additions and 13 deletions

4
debian/changelog vendored
View file

@ -1,11 +1,13 @@
multistrap (2.2.1) UNRELEASED; urgency=medium multistrap (2.2.1) UNRELEASED; urgency=medium
* Move to github * Move to github with alioth copy.
* Switch example mirror in usage information. (Closes: #774476) * Switch example mirror in usage information. (Closes: #774476)
* Update for Jessie release * Update for Jessie release
* [INTL:pt] Updated Portuguese translation of manpage * [INTL:pt] Updated Portuguese translation of manpage
(Closes: #756217) (Closes: #756217)
* Drop old crossbuild support reliant on outdated support. * Drop old crossbuild support reliant on outdated support.
* Use environment variables for apt configuration instead of Dir::Etc.
Patch from Pip Cet <pipcet@gmail.com> (Closes: #774698)
-- Neil Williams <codehelp@debian.org> Sun, 12 Apr 2015 18:15:30 +0100 -- Neil Williams <codehelp@debian.org> Sun, 12 Apr 2015 18:15:30 +0100

View file

@ -36,7 +36,7 @@ use vars qw/ $progname $ourversion $dstrap $extra @aptsources
$explicit_suite $allow_recommends %omitdebsrc @dsclist @sectoutput $explicit_suite $allow_recommends %omitdebsrc @dsclist @sectoutput
%flatfile %important $addimportant @debconf $hookdir %hooks %flatfile %important $addimportant @debconf $hookdir %hooks
$warn_count $use_shortcut @foreignarches $olddpkg $ignorenative $warn_count $use_shortcut @foreignarches $olddpkg $ignorenative
%foreignpkgs $markauto $default_release /; %foreignpkgs $markauto $default_release $pre_config_str/;
setlocale(LC_MESSAGES, ""); setlocale(LC_MESSAGES, "");
textdomain("multistrap"); textdomain("multistrap");
@ -241,6 +241,9 @@ foreach $repo (sort keys %suites) {
if (not -e "$dir/${cachedir}archives/partial") { if (not -e "$dir/${cachedir}archives/partial") {
mkdir_fatal ("$dir/${cachedir}archives/partial"); mkdir_fatal ("$dir/${cachedir}archives/partial");
} }
if (not -e "${dir}${etcdir}apt.conf.d") {
mkdir_fatal ("${dir}${etcdir}apt.conf.d");
}
} }
foreach my $aptsrc (@debootstrap) { foreach my $aptsrc (@debootstrap) {
if (defined $deflist) { if (defined $deflist) {
@ -329,6 +332,19 @@ if ((defined $k) and (not defined $noauth)) {
die (_g("Secure Apt handling failed - try without authentication.")."\n"); die (_g("Secure Apt handling failed - try without authentication.")."\n");
} }
} }
$pre_config_str = '';
$pre_config_str .= "Dir::Etc \"${dir}${etcdir}\";\n";
$pre_config_str .= "Dir::Etc::Parts \"${dir}${etcdir}apt.conf.d/\";\n";
$pre_config_str .= "Dir::Etc::PreferencesParts \"${dir}${etcdir}preferences.d/\";\n";
my $tmp_apt_conf = `mktemp -t multistrap.XXXXXX`;
chomp ($tmp_apt_conf);
open CONFIG, ">$tmp_apt_conf";
print CONFIG $pre_config_str;
close CONFIG;
$config_str = ''; $config_str = '';
$config_str .= " -o Apt::Architecture=$arch"; $config_str .= " -o Apt::Architecture=$arch";
$config_str .= " -o Dir::Etc::TrustedParts=${dir}${etcdir}trusted.gpg.d"; $config_str .= " -o Dir::Etc::TrustedParts=${dir}${etcdir}trusted.gpg.d";
@ -351,8 +367,12 @@ if (defined $deflist) {
$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}";
printf (_g("Getting package lists: apt-get %s update\n"), $config_str);
$retval = system ("apt-get $config_str update"); my $apt_get = "APT_CONFIG=\"$tmp_apt_conf\" apt-get $config_str";
my $apt_mark = "APT_CONFIG=\"$tmp_apt_conf\" apt-mark $config_str";
printf (_g("Getting package lists: %s update\n"), $apt_get);
$retval = system ("$apt_get update");
$retval >>= 8; $retval >>= 8;
die (sprintf (_g("apt update failed. Exit value: %d\n"), $retval)) die (sprintf (_g("apt update failed. Exit value: %d\n"), $retval))
if ($retval != 0); if ($retval != 0);
@ -397,9 +417,9 @@ chomp($str);
@s = split (/ /, $str); @s = split (/ /, $str);
uniq_sort (\@s); uniq_sort (\@s);
$str = join (' ', @s); $str = join (' ', @s);
print "apt-get -y $config_str install $str\n"; print "$apt_get -y install $str\n";
$retval = 0; $retval = 0;
$retval = system ("apt-get -y $config_str install $str"); $retval = system ("$apt_get -y install $str");
$retval >>= 8; $retval >>= 8;
die (sprintf (_g("apt download failed. Exit value: %d\n"),$retval)) die (sprintf (_g("apt download failed. Exit value: %d\n"),$retval))
if ($retval != 0); if ($retval != 0);
@ -425,7 +445,7 @@ if (defined $err and $err != 0) {
&add_extra_packages; &add_extra_packages;
system ("cp $configsh $dir/") if ((defined $configsh) and (-f $configsh)); system ("cp $configsh $dir/") if ((defined $configsh) and (-f $configsh));
&handle_source_packages; &handle_source_packages;
(not defined $tidy) ? system ("apt-get $config_str update") : &tidy_apt; (not defined $tidy) ? system ("$apt_get update") : &tidy_apt;
&guard_lib64($dir); &guard_lib64($dir);
# cleanly separate the bootstrap sources from the final apt sources. # cleanly separate the bootstrap sources from the final apt sources.
@ -470,9 +490,10 @@ foreach my $aptsrc (@aptsources) {
} }
} }
# altered the sources, so get apt to update. # altered the sources, so get apt to update.
(not defined $tidy) ? system ("apt-get $config_str update") : &tidy_apt; (not defined $tidy) ? system ("$apt_get update") : &tidy_apt;
# run second set of hooks # run second set of hooks
&run_completion_hooks(sort @{$hooks{'A'}}) if (defined ($hooks{'A'})); &run_completion_hooks(sort @{$hooks{'A'}}) if (defined ($hooks{'A'}));
unlink $tmp_apt_conf;
if (not defined $warn_count) { if (not defined $warn_count) {
printf (_g("\nMultistrap system installed successfully in %s.\n"), $dir); printf (_g("\nMultistrap system installed successfully in %s.\n"), $dir);
} else { } else {
@ -515,8 +536,8 @@ sub our_version {
sub add_extra_packages { sub add_extra_packages {
if (scalar @extrapkgs > 0) { if (scalar @extrapkgs > 0) {
$str = join (' ', @extrapkgs); $str = join (' ', @extrapkgs);
print "apt-get -y $config_str install $str\n"; print "$apt_get -y install $str\n";
system ("apt-get -y $config_str install $str"); system ("$apt_get -y install $str");
&force_unpack (@extrapkgs) if ($unpack eq "true"); &force_unpack (@extrapkgs) if ($unpack eq "true");
system ("touch ${dir}${libdir}lists/lock"); system ("touch ${dir}${libdir}lists/lock");
&native if (not defined ($foreign)); &native if (not defined ($foreign));
@ -537,7 +558,7 @@ sub mark_manual_install {
my @auto = grep {my $pkg = $_; ! grep /$pkg/, @manual} @all; my @auto = grep {my $pkg = $_; ! grep /$pkg/, @manual} @all;
printf(ngettext ("Found %d package to mark.\n", printf(ngettext ("Found %d package to mark.\n",
"Found %d packages to mark.\n", scalar @auto), scalar @auto); "Found %d packages to mark.\n", scalar @auto), scalar @auto);
system ("apt-mark $config_str auto " . join (" ", sort @auto)) if (scalar @auto > 0); system ("$apt_mark auto " . join (" ", sort @auto)) if (scalar @auto > 0);
printf (_g("Marking automatically installed packages completed.\n")); printf (_g("Marking automatically installed packages completed.\n"));
} }
@ -889,9 +910,9 @@ sub handle_source_packages {
my $olddir = getcwd(); my $olddir = getcwd();
chdir ($sourcedir); chdir ($sourcedir);
if (scalar @dsclist > 0) { if (scalar @dsclist > 0) {
print "apt-get -d $config_str source " . join (" ", @dsclist) . "\n"; print "$apt_get -d source " . join (" ", @dsclist) . "\n";
foreach my $srcpkg (@dsclist) { foreach my $srcpkg (@dsclist) {
system ("apt-get -d $config_str source $srcpkg"); system ("$apt_get -d source $srcpkg");
} }
} }
chdir ($olddir); chdir ($olddir);