File Coverage

blib/lib/Devel/AssertApplicationCapabilities/TarMinusZ.pm
Criterion Covered Total %
statement 36 36 100.0
branch 3 6 50.0
condition 1 3 33.3
subroutine 8 8 100.0
pod 0 1 0.0
total 48 54 88.8


line stmt bran cond sub pod time code
1             package Devel::AssertApplicationCapabilities::TarMinusZ;
2              
3 1     1   6 use strict;
  1         3  
  1         62  
4 1     1   9 use vars qw($VERSION);
  1         2  
  1         130  
5             local $^W = 1;
6             $VERSION = '1.0';
7 1     1   9 use base qw(Devel::AssertApplicationCapabilities::_Base);
  1         2  
  1         185  
8              
9 1     1   6 use Devel::CheckApplicationCapabilities;
  1         8  
  1         76  
10 1     1   7 use File::Temp qw(tempdir);
  1         2  
  1         83  
11 1     1   6 use Cwd qw(getcwd);
  1         6  
  1         365  
12              
13             local $/ = undef;
14             my $data = ;
15              
16             sub app_is {
17 2     2 0 8 my $app = shift;
18 2         23 my $original_dir = getcwd();
19              
20 2         24 my $dir = tempdir(); chdir($dir);
  2         1752  
21 2 50       1402 open(my $tempfh, '>', "foo.tgz") ||
22             die("Can't create $dir/foo.tgz to test whether $app supports -z\n");
23 2         25 print $tempfh $data;
24 2         102 close($tempfh);
25              
26             Devel::CheckApplicationCapabilities::_with_STDERR_closed(sub {
27 2     2   34748 system($app, '-xzf', 'foo.tgz');
28 2         20 });
29              
30 2         45 my $rval = 0;
31 2 50 33     82 if(-e 'foo' && do { if(open(my $tempfh, 'foo')) { <$tempfh> } } eq 'bar') {
  2 50       114  
  2         116  
32 2         10 $rval = 1;
33             }
34 2         402 unlink "$dir/foo", "$dir/foo.tbz";
35 2         46 chdir($original_dir);
36 2         91 rmdir $dir;
37 2         557 return $rval;
38             }
39              
40             =head1 NAME
41              
42             Devel::AssertApplicationCapabilities::TarMinusZ - check that a tar binary
43             supports the GNU-ish -j argument, to handle bzip2'ed tarballs
44              
45             =cut
46              
47             =head1 BUGS/WARNINGS/LIMITATIONS
48              
49             This is a heuristic. That means that it can be wrong. Bug reports are
50             most welcome, and should include the output from 'cp --version' as well
51             as, of course, telling me what the bug is.
52              
53             The check is actually whether 'cp -al blah/foo blah/bar' results in two
54             files with the same inode number, as well as whether cp looks GNU-ish.
55              
56             =head1 SEE ALSO
57              
58             L
59              
60             =head1 SOURCE CODE REPOSITORY
61              
62             L
63              
64             =head1 AUTHOR, COPYRIGHT and LICENCE
65              
66             Copyright 2010 David Cantrell
67              
68             This software is free-as-in-speech software, and may be used,
69             distributed, and modified under the terms of either the GNU
70             General Public Licence version 2 or the Artistic Licence. It's
71             up to you which one you use. The full text of the licences can
72             be found in the files GPL2.txt and ARTISTIC.txt, respectively.
73              
74             =head1 CONSPIRACY
75              
76             This module is also free-as-in-mason software.
77              
78             =cut
79              
80             1;
81             __DATA__