[devscripts] 01/01: git-deborig: Avoid using the shell when running git-archive
James McCoy
jamessan at debian.org
Fri Jan 6 03:35:45 UTC 2017
This is an automated email from the git hooks/post-receive script.
jamessan pushed a commit to branch master
in repository devscripts.
commit d74a573df2e6279f1c195e4cd59f404f094d6a4b
Author: James McCoy <jamessan at debian.org>
Date: Thu Jan 5 22:31:36 2017 -0500
git-deborig: Avoid using the shell when running git-archive
Git allows specifying config on the fly with the ‘-c’ switch, so use
that to define the appropriate “tar.<format>.command” at runtime. With
that and a little help from Dpkg::IPC::spawn, we can then trivially run
the command directly instead of shelling out.
Signed-off-by: James McCoy <jamessan at debian.org>
---
scripts/git-deborig.pl | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/scripts/git-deborig.pl b/scripts/git-deborig.pl
index a2ff3db..7c40055 100755
--- a/scripts/git-deborig.pl
+++ b/scripts/git-deborig.pl
@@ -65,6 +65,7 @@ no warnings "experimental::smartmatch";
use Git::Wrapper;
use Dpkg::Changelog::Parse;
+use Dpkg::IPC;
use Dpkg::Version;
use List::Compare;
@@ -95,7 +96,7 @@ my $upstream_version = $version->version();
die "this looks like a native package .." if $version->is_native();
# Default to gzip
-my $compressor = "gzip";
+my $compressor = "gzip -cn";
my $compression = "gz";
# Now check if we can use xz
if ( -e "debian/source/format" ) {
@@ -104,7 +105,7 @@ if ( -e "debian/source/format" ) {
my $format = <$format_fh>;
chomp($format) if defined $format;
if ( $format eq "3.0 (quilt)" ) {
- $compressor = "xz";
+ $compressor = "xz -c";
$compression = "xz";
}
close $format_fh;
@@ -169,13 +170,12 @@ sub archive_tag {
print $attributes_fh "* -export-ignore\n";
close $attributes_fh;
- # git-archive(1) can be taught to invoke xz by adding some lines
- # to ~/.gitconfig. So that this script always works, we just pipe
- # to the compression tool
- system "git archive \\
- --prefix=$source-$upstream_version/\\
- --format=tar $tag \\
- | $compressor > $orig";
+ spawn(exec => ['git', '-c', "tar.${compression}.command=${compressor}",
+ 'archive', "--prefix=${source}-${upstream_version}/",
+ '--format=xz', $tag],
+ to_file => $orig,
+ wait_child => 1,
+ nocheck => 1);
# Restore situation before we messed around with git attributes
if ( -e ".git/info/attributes-deborig" ) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git
More information about the devscripts-devel
mailing list