This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Archive-Tar to CPAN version 1.78
[perl5.git] / cpan / Archive-Tar / bin / ptardiff
CommitLineData
81a5970e
RGS
1#!/usr/bin/perl
2
3use strict;
4use Archive::Tar;
5use Getopt::Std;
6
7my $opts = {};
8getopts('h:', $opts) or die usage();
9
10die usages() if $opts->{h};
11
12### need Text::Diff -- give a polite error (not a standard prereq)
13unless ( eval { require Text::Diff; Text::Diff->import; 1 } ) {
14 die "\n\t This tool requires the 'Text::Diff' module to be installed\n";
15}
16
17my $arch = shift or die usage();
18my $tar = Archive::Tar->new( $arch ) or die "Couldn't read '$arch': $!";
19
20
21foreach my $file ( $tar->get_files ) {
22 next unless $file->is_file;
23 my $name = $file->name;
93e94d8a
CBW
24
25 diff( \($file->get_content), $name,
81a5970e
RGS
26 { FILENAME_A => $name,
27 MTIME_A => $file->mtime,
28 OUTPUT => \*STDOUT
93e94d8a 29 }
81a5970e
RGS
30 );
31}
32
33
34
35
36sub usage {
37 return q[
38
39Usage: ptardiff ARCHIVE_FILE
40 ptardiff -h
93e94d8a 41
81a5970e
RGS
42 ptardiff is a small program that diffs an extracted archive
43 against an unextracted one, using the perl module Archive::Tar.
93e94d8a
CBW
44
45 This effectively lets you view changes made to an archives contents.
46
81a5970e
RGS
47 Provide the progam with an ARCHIVE_FILE and it will look up all
48 the files with in the archive, scan the current working directory
49 for a file with the name and diff it against the contents of the
50 archive.
51
93e94d8a 52
81a5970e
RGS
53Options:
54 h Prints this help message
55
56
57Sample Usage:
58
93e94d8a 59 $ tar -xzf Acme-Buffy-1.3.tar.gz
81a5970e 60 $ vi Acme-Buffy-1.3/README
93e94d8a 61
81a5970e
RGS
62 [...]
63
64 $ ptardiff Acme-Buffy-1.3.tar.gz > README.patch
65
66
67See Also:
68 tar(1)
69 ptar
70 Archive::Tar
71
72 ] . $/;
93e94d8a 73}
b3200c5d
SP
74
75
76
77=head1 NAME
78
79ptardiff - program that diffs an extracted archive against an unextracted one
80
81=head1 DESCRIPTION
82
83 ptardiff is a small program that diffs an extracted archive
84 against an unextracted one, using the perl module Archive::Tar.
93e94d8a
CBW
85
86 This effectively lets you view changes made to an archives contents.
87
b3200c5d
SP
88 Provide the progam with an ARCHIVE_FILE and it will look up all
89 the files with in the archive, scan the current working directory
90 for a file with the name and diff it against the contents of the
91 archive.
92
93=head1 SYNOPSIS
94
95 ptardiff ARCHIVE_FILE
96 ptardiff -h
97
93e94d8a 98 $ tar -xzf Acme-Buffy-1.3.tar.gz
b3200c5d
SP
99 $ vi Acme-Buffy-1.3/README
100 [...]
101 $ ptardiff Acme-Buffy-1.3.tar.gz > README.patch
102
103
104=head1 OPTIONS
105
106 h Prints this help message
107
108=head1 SEE ALSO
109
110tar(1), L<Archive::Tar>.
111
112=cut