Package: mmdebstrap
Version: 1.2.5-1
File: /usr/bin/mmdebstrap
Tags: patch upstream

Hi Johannes,

we recently talked about mmdebstrap --include with an apt pattern
containing a comma being broken. An example invocation is:

    mmdebstrap --variant=apt 
'--include=?or(?exact-name(linux-image-cloud-amd64),?exact-name(linux-image-amd64))'
 unstable

I figured that I could also come up with the fixing patch and am
attaching it to your convenience. If you want to include test cases,
please keep in mind that this is fixed twice, once for --variant=extract
and once for --variant=apt.

Helmut
--- a/mmdebstrap
+++ b/mmdebstrap
@@ -2343,14 +2343,18 @@
         }
         my @apt_argv = ('install');
         for my $incl (@{ $options->{include} }) {
-            for my $pkg (split /[,\s]+/, $incl) {
-                # strip leading and trailing whitespace
-                $pkg =~ s/^\s+|\s+$//g;
-                # skip if the remainder is an empty string
-                if ($pkg eq '') {
-                    next;
+            if ($incl =~ /^[?~!(]/) {
+                push @apt_argv, $incl;
+            } else {
+                for my $pkg (split /[,\s]+/, $incl) {
+                    # strip leading and trailing whitespace
+                    $pkg =~ s/^\s+|\s+$//g;
+                    # skip if the remainder is an empty string
+                    if ($pkg eq '') {
+                        next;
+                    }
+                    push @apt_argv, $pkg;
                 }
-                push @apt_argv, $pkg;
             }
         }
 
@@ -2882,14 +2886,18 @@
 
     my %pkgs_to_install;
     for my $incl (@{ $options->{include} }) {
-        for my $pkg (split /[,\s]+/, $incl) {
-            # strip leading and trailing whitespace
-            $pkg =~ s/^\s+|\s+$//g;
-            # skip if the remainder is an empty string
-            if ($pkg eq '') {
-                next;
+        if ($incl =~ /^[?~!(]/) {
+            $pkgs_to_install{$incl} = ();
+        } else {
+            for my $pkg (split /[,\s]+/, $incl) {
+                # strip leading and trailing whitespace
+                $pkg =~ s/^\s+|\s+$//g;
+                # skip if the remainder is an empty string
+                if ($pkg eq '') {
+                    next;
+                }
+                $pkgs_to_install{$pkg} = ();
             }
-            $pkgs_to_install{$pkg} = ();
         }
     }
     if ($options->{variant} eq 'buildd') {

Reply via email to