5 diff.pl -- Helper to diff files (rights, acl and content)
9 diff.pl -s source -d dest [--acl | --attr]
16 no warnings 'File::Find';
23 my ($src, $dst, $help, $acl, $attr);
29 GetOptions("src=s" => \$src,
34 ) or pod2usage(-verbose => 1,
37 pod2usage(-verbose => 1,
42 pod2usage(-verbose => 2,
45 my $md5 = Digest::MD5->new;
51 find(\&wanted_src, '.');
57 find(\&wanted_src, '.');
59 #print Data::Dumper::Dumper(\%src_attr);
60 #print Data::Dumper::Dumper(\%dst_attr);
62 foreach my $f (keys %src_attr)
64 if (!defined $dst_attr{$f}) {
66 print "E: Can't find $f in dst\n";
69 compare($src_attr{$f}, $dst_attr{$f});
75 foreach my $f (keys %dst_attr)
78 print "E: Can't find $f in src\n";
86 my ($f1, $f2) = ($h1->{file}, $h2->{file});
87 foreach my $k (keys %$h1) {
88 if (!exists $h2->{$k}) {
90 print "E: Can't find $k for dest $f2 ($k=$h1->{$k})\n";
92 if ($h2->{$k} ne $h1->{$k}) {
94 print "E: src and dst $f2 differ on $k ($h1->{$k} != $h2->{$k})\n";
100 foreach my $k (keys %$h2) {
102 print "E: Found $k on dst file and not on src ($k=$h2->{$k})\n";
109 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
110 $atime,$mtime,$ctime,$blksize,$blocks) = stat($f);
113 my $target = readlink($f);
114 $hash->{$File::Find::name} = {
123 file => $File::Find::name,
127 $hash->{$File::Find::name} = {
137 file => $File::Find::name,
140 open(FILE, $f) or die "Can't open '$f': $!";
142 $hash->{$File::Find::name}->{md5} = $md5->addfile(*FILE)->hexdigest;
146 $hash->{$File::Find::name}->{acl} = `getfacl $f 2>/dev/null`;
149 $hash->{$File::Find::name}->{attr} = `getfattr $f 2>/dev/null`;
153 $hash->{$File::Find::name} = {
161 file => $File::Find::name,
164 $hash->{$File::Find::name}->{acl} = `getfacl $f 2>/dev/null`;
167 $hash->{$File::Find::name}->{attr} = `getfattr $f 2>/dev/null`;