summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/bin/ptardiff.bat
blob: 85ac789661097716e6ba30e69bd78ba1c48e2abb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
@rem = '--*-Perl-*--
@echo off
if "%OS%" == "Windows_NT" goto WinNT
perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
:WinNT
perl -x -S %0 %*
if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
if %errorlevel% == 9009 echo You do not have Perl in your PATH.
if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
goto endofperl
@rem ';
#!/usr/bin/perl
#line 15

use strict;
use Archive::Tar;
use Getopt::Std;

my $opts = {};
getopts('h:', $opts) or die usage();

die usages() if $opts->{h};

### need Text::Diff -- give a polite error (not a standard prereq)
unless ( eval { require Text::Diff; Text::Diff->import; 1 } ) {
    die "\n\t This tool requires the 'Text::Diff' module to be installed\n";
}

my $arch = shift                        or die usage();
my $tar  = Archive::Tar->new( $arch )   or die "Couldn't read '$arch': $!";


foreach my $file ( $tar->get_files ) {
    next unless $file->is_file;
    my $name = $file->name;
    
    diff(   \($file->get_content), $name, 
            {   FILENAME_A  => $name,
                MTIME_A     => $file->mtime,
                OUTPUT      => \*STDOUT
            } 
    );
}




sub usage {
    return q[

Usage:  ptardiff ARCHIVE_FILE
        ptardiff -h
    
    ptardiff is a small program that diffs an extracted archive
    against an unextracted one, using the perl module Archive::Tar.
    
    This effectively lets you view changes made to an archives contents. 
    
    Provide the progam with an ARCHIVE_FILE and it will look up all
    the files with in the archive, scan the current working directory
    for a file with the name and diff it against the contents of the
    archive.

    
Options:
    h   Prints this help message


Sample Usage:

    $ tar -xzf Acme-Buffy-1.3.tar.gz 
    $ vi Acme-Buffy-1.3/README
    
    [...]

    $ ptardiff Acme-Buffy-1.3.tar.gz > README.patch


See Also:
    tar(1)
    ptar
    Archive::Tar

    ] . $/;
}    



=head1 NAME

ptardiff - program that diffs an extracted archive against an unextracted one

=head1 DESCRIPTION

    ptardiff is a small program that diffs an extracted archive
    against an unextracted one, using the perl module Archive::Tar.
    
    This effectively lets you view changes made to an archives contents. 
    
    Provide the progam with an ARCHIVE_FILE and it will look up all
    the files with in the archive, scan the current working directory
    for a file with the name and diff it against the contents of the
    archive.

=head1 SYNOPSIS

    ptardiff ARCHIVE_FILE
    ptardiff -h

    $ tar -xzf Acme-Buffy-1.3.tar.gz 
    $ vi Acme-Buffy-1.3/README
    [...]
    $ ptardiff Acme-Buffy-1.3.tar.gz > README.patch


=head1 OPTIONS

    h   Prints this help message

=head1 SEE ALSO

tar(1), L<Archive::Tar>.

=cut

__END__
:endofperl