File Coverage

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