Package: multistrap
Version: 2.1.20
Severity: wishlist
Tags: patch
To enable use of `apt-get autoremove`, it is necessary that packages
which are installed to satisfy dependencies (as opposed to those
packages directly specified, e.g. via a section "packages" list) be
marked as auto-installed in APT's extended_states database. apt-get
normally does this, but not when APT::Get::Download-Only is set, as it
is by multistrap.
The attached patch causes such packages to be so marked if
'markauto' is set to true in the general settings stanza of the
configuration file, e.g.:
[general]
markauto=true
[emdebian]
source=http://emdebian.org/grip
suite=wheezy-grip
Diffstat of the attached patch:
multistrap | 21 -
pod/multistrap |5 +
2 files changed, 25 insertions(+), 1 deletion(-)
-- System Information:
Debian Release: 7.0
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 3.2.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages multistrap depends on:
ii apt0.9.7.7
ii libconfig-auto-perl0.42-1
ii liblocale-gettext-perl 1.05-7+b1
ii libparse-debian-packages-perl 0.03-1
ii perl 5.14.2-18
Versions of packages multistrap recommends:
ii emdebian-archive-keyring 2.0.3
Versions of packages multistrap suggests:
ii fakeroot 1.18.4-2
-- no debconf information
--- a/multistrap
+++ b/multistrap
@@ -36,13 +36,14 @@ use vars qw/ $progname $ourversion $dstrap $extra @aptsources
$explicit_suite $allow_recommends %omitdebsrc @dsclist @sectoutput
%flatfile %important $addimportant @debconf $hookdir %hooks
$warn_count $use_shortcut @foreignarches $olddpkg $ignorenative
- %foreignpkgs /;
+ %foreignpkgs $markauto /;
setlocale(LC_MESSAGES, "");
textdomain("multistrap");
$progname = basename($0);
$ourversion = &our_version();
$unpack = "true";
+$markauto = "false";
%omitdebsrc=();
%foreignpkgs=();
while( @ARGV ) {
@@ -399,6 +400,7 @@ $retval >>= 8;
die (sprintf (_g("apt download failed. Exit value: %d\n"),$retval))
if ($retval != 0);
&force_unpack if ($unpack eq "true");
+&mark_as_autoinstalled_except ($str) if ($markauto eq "true");
system ("touch ${dir}${libdir}lists/lock");
if ((defined $setupsh) and (-x $setupsh)) {
$retval = 0;
@@ -683,6 +685,15 @@ sub force_unpack {
}
}
+sub mark_as_autoinstalled_except {
+ my @manual = split(/ +/, $_[0]);
+ my @all = map {
+ trim (`LC_ALL=C dpkg -f ${dir}${cachedir}archives/$_ Package`);
+ } @archives;
+ my @auto = grep {my $pkg = $_; ! grep /$pkg/, @manual} @all;
+ system ("apt-mark $config_str auto " . join (" ", @auto)) if @auto;
+}
+
sub run_download_hooks {
my (@hooks) = @_;
return if (scalar @hooks == 0);
@@ -1123,6 +1134,7 @@ sub cascade {
if (defined $keys{$section}{'directory'} and (not defined $dir));
# support the original value but replace by new value.
$unpack = "false" if (defined $keys{$section}{'forceunpack'} and (lc($keys{$section}{'forceunpack'}) ne "true"));
+ $markauto = lc($keys{$section}{'markauto'}) if (defined $keys{$section}{'markauto'});
$unpack = "false" if (defined $keys{$section}{'unpack'} and (lc($keys{$section}{'unpack'} ne "true")));
$configsh = lc($keys{$section}{'configscript'})
if (defined $keys{$section}{'configscript'} and (not defined $configsh));
@@ -1477,3 +1489,10 @@ sub dump_config {
exit 1;
}
}
+
+sub trim {
+ my $str = shift;
+ $str =~ s/^\s+//;
+ $str =~ s/\s+$//;
+ return $str;
+}
--- a/pod/multistrap
+++ b/pod/multistrap
@@ -175,6 +175,11 @@ the C list under General.
The order of section names in either list is not important.
+'markauto' if true will cause packages installed to satisfy a
+dependency (as opposed to those installed intentionally, via a
+C list) to be marked as automatically installed in APT's
+extended state database.
+
As with debootstrap, multistrap will continue after errors, as long
as the configuration file can be correctly parsed.