#!/usr/bin/perl # author: Vladimir Bogdanov (vladb) # date: 2004-03 # Compares java classes in a set of jar files and # prints out a straightforward inconsistency report. use Getopt::Long; use Data::Dumper; use strict; ##--------------------------------------------- ## CONFIG ##--------------------------------------------- @cfg::options = ("help|h","m"); $cfg::unzip = "/usr/5bin/unzip"; ##--------------------------------------------- ## MAIN ##--------------------------------------------- my %opts; GetOptions(\%opts, @cfg::options); help() if ($opts{help}); my @jars = @ARGV; my (%jar_files, %jar_classes, $cmd, $out); for my $jar (@jars) { $cmd = "$cfg::unzip -l $jar"; my $pid = open(CMD, "-|"); unless ($pid) { exec($cmd) || die "can't exec program: $!"; } while (<CMD>) { if (/(\d+)[\t\s]+([\d-]+)[\t\s]+([\d:]+)[\t\s+]+((.*?)\.class)/) { my $d = [$1, $2, $3]; $jar_files{$jar}{$4} = $d; $jar_classes{$4}{$jar} = $d; } } close(CMD) || warn "failed to close CMD: $?"; } for my $c (keys %jar_classes) { my ($info, $size, $osize, $mod); for my $j (@jars) { if (exists $jar_classes{$c}{$j}) { $size = $jar_classes{$c}{$j}->[0]; $osize = $size unless (defined $osize); $mod = 1 if ($size != $osize); $info .= " $j \t" . join("\t", @{$jar_classes{$c}{$j}}) . " +\n"; } else { $mod = 1; $info .= " $j \tMISSING\n"; } } if ($opts{m}) { next unless $mod; $mod = ""; } else { $mod = "*** " if ($mod); } print "$mod$c:\n"; print "$info\n"; } ##--------------------------------------------- ## SUBROUTINES ##--------------------------------------------- sub help { print qq~ jardiff [help] <jarfile1> <jarfile2> Compares contents of two jar files. EXAMPLES: Show modified files only jardiff -m j.jar j1.jar ~; exit; }

In reply to jdiff - jar/java diff by vladb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.