Просмотр исходного кода

Dpkg::Source::Patch: Pass PATCH_GET envvar instead of -g0 to patch

For GNU patch the default value for -g is already 0, but that option is
not available in other systems, such as FreeBSD. Let's switch to use the
environment variable PATCH_GET, so that we make sure it gets set to a
known value, and so that we can stop using the unportable option.
Guillem Jover лет назад: 11
Родитель
Сommit
2a76ceda76
3 измененных файлов с 9 добавлено и 6 удалено
  1. 3 0
      debian/changelog
  2. 4 4
      scripts/Dpkg/Source/Patch.pm
  3. 2 2
      scripts/Dpkg/Source/Quilt.pm

+ 3 - 0
debian/changelog

@@ -82,6 +82,9 @@ dpkg (1.18.0) UNRELEASED; urgency=low
       clarify what whitespace really maps to, we should really match the GnuPG
       clarify what whitespace really maps to, we should really match the GnuPG
       implementation anyway, as that's what we use to verify the signatures.
       implementation anyway, as that's what we use to verify the signatures.
       Reported by Jann Horn <jann@thejh.net>. Fixes CVE-2015-0840.
       Reported by Jann Horn <jann@thejh.net>. Fixes CVE-2015-0840.
+    - Pass PATCH_GET environment varialbe instead of -g0 to the patch command
+      in Dpkg::Source::Patch. This allows using non-GNU patch programs, like
+      FreeBSD's patch.
   * Test suite:
   * Test suite:
     - Check perl code compilation, warnings and strictness.
     - Check perl code compilation, warnings and strictness.
     - Fix dpkg-divert unit test to work on BSD «rm -rf» that cannot traverse
     - Fix dpkg-divert unit test to work on BSD «rm -rf» that cannot traverse

+ 4 - 4
scripts/Dpkg/Source/Patch.pm

@@ -565,7 +565,7 @@ sub apply {
     $opts{remove_backup} //= 1;
     $opts{remove_backup} //= 1;
     $opts{create_dirs} //= 1;
     $opts{create_dirs} //= 1;
     $opts{options} ||= [ '-t', '-F', '0', '-N', '-p1', '-u',
     $opts{options} ||= [ '-t', '-F', '0', '-N', '-p1', '-u',
-            '-V', 'never', '-g0', '-b', '-z', '.dpkg-orig'];
+            '-V', 'never', '-b', '-z', '.dpkg-orig'];
     $opts{add_options} //= [];
     $opts{add_options} //= [];
     push @{$opts{options}}, @{$opts{add_options}};
     push @{$opts{options}}, @{$opts{add_options}};
     # Check the diff and create missing directories
     # Check the diff and create missing directories
@@ -577,7 +577,7 @@ sub apply {
     spawn(
     spawn(
 	exec => [ 'patch', @{$opts{options}} ],
 	exec => [ 'patch', @{$opts{options}} ],
 	chdir => $destdir,
 	chdir => $destdir,
-	env => { LC_ALL => 'C', LANG => 'C' },
+	env => { LC_ALL => 'C', LANG => 'C', PATCH_GET => '0' },
 	delete_env => [ 'POSIXLY_CORRECT' ], # ensure expected patch behaviour
 	delete_env => [ 'POSIXLY_CORRECT' ], # ensure expected patch behaviour
 	wait_child => 1,
 	wait_child => 1,
 	nocheck => 1,
 	nocheck => 1,
@@ -616,7 +616,7 @@ sub check_apply {
     # Set default values to options
     # Set default values to options
     $opts{create_dirs} //= 1;
     $opts{create_dirs} //= 1;
     $opts{options} ||= [ '--dry-run', '-s', '-t', '-F', '0', '-N', '-p1', '-u',
     $opts{options} ||= [ '--dry-run', '-s', '-t', '-F', '0', '-N', '-p1', '-u',
-            '-V', 'never', '-g0', '-b', '-z', '.dpkg-orig'];
+            '-V', 'never', '-b', '-z', '.dpkg-orig'];
     $opts{add_options} //= [];
     $opts{add_options} //= [];
     push @{$opts{options}}, @{$opts{add_options}};
     push @{$opts{options}}, @{$opts{add_options}};
     # Check the diff and create missing directories
     # Check the diff and create missing directories
@@ -627,7 +627,7 @@ sub check_apply {
     my $patch_pid = spawn(
     my $patch_pid = spawn(
 	exec => [ 'patch', @{$opts{options}} ],
 	exec => [ 'patch', @{$opts{options}} ],
 	chdir => $destdir,
 	chdir => $destdir,
-	env => { LC_ALL => 'C', LANG => 'C' },
+	env => { LC_ALL => 'C', LANG => 'C', PATCH_GET => '0' },
 	delete_env => [ 'POSIXLY_CORRECT' ], # ensure expected patch behaviour
 	delete_env => [ 'POSIXLY_CORRECT' ], # ensure expected patch behaviour
 	from_handle => $self->get_filehandle(),
 	from_handle => $self->get_filehandle(),
 	to_file => '/dev/null',
 	to_file => '/dev/null',

+ 2 - 2
scripts/Dpkg/Source/Quilt.pm

@@ -179,7 +179,7 @@ sub push {
                     verbose => $opts{verbose},
                     verbose => $opts{verbose},
                     force_timestamp => 1, create_dirs => 1, remove_backup => 0,
                     force_timestamp => 1, create_dirs => 1, remove_backup => 0,
                     options => [ '-t', '-F', '0', '-N', '-p1', '-u',
                     options => [ '-t', '-F', '0', '-N', '-p1', '-u',
-                                 '-V', 'never', '-g0', '-E', '-b',
+                                 '-V', 'never', '-E', '-b',
                                  '-B', ".pc/$patch/", '--reject-file=-' ]);
                                  '-B', ".pc/$patch/", '--reject-file=-' ]);
     };
     };
     if ($@) {
     if ($@) {
@@ -216,7 +216,7 @@ sub pop {
         $obj->apply($self->{dir}, timestamp => $opts{timestamp},
         $obj->apply($self->{dir}, timestamp => $opts{timestamp},
                     verbose => 0, force_timestamp => 1, remove_backup => 0,
                     verbose => 0, force_timestamp => 1, remove_backup => 0,
                     options => [ '-R', '-t', '-N', '-p1',
                     options => [ '-R', '-t', '-N', '-p1',
-                                 '-u', '-V', 'never', '-g0', '-E',
+                                 '-u', '-V', 'never', '-E',
                                  '--no-backup-if-mismatch' ]);
                                  '--no-backup-if-mismatch' ]);
     }
     }