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
|
#!/usr/bin/perl
use strict;
use File::Temp qw/ tempfile tempdir /;
use File::Basename;
use Cwd qw/abs_path/;
my $top = dirname(abs_path($0));
my @files;
my $opt_ignore_revisions;
while (@ARGV)
{
my $opt = shift;
if ($opt =~ /^--ignore[-_]?revisions$/) { $opt_ignore_revisions = 1; next; }
push @files, $opt;
}
die "Syntax: $0 [--ignore-revisions] <manifest1.txt> <manifest2.txt>" unless $#files==1;
my @tmpfiles;
foreach my $file (@files)
{
my ($tmpfh, $tmp) = tempfile();
push @tmpfiles, $tmp;
if (system("$top/validate-manifest.pl", "--no-online", "--quiet", "--output-normalized=$tmp", "--type=generic", $file))
{
print STDERR "Manifest normalization failed for $file\n";
clean_tmp_and_exit(1, @tmpfiles);
}
if ($opt_ignore_revisions)
{
if (system("sed","-i","-e",'s/_revision=.*/_revision=.../; s/manifestid=.*/manifestid=.../',$tmp))
{
print STDERR "Revision stripping failed for $tmp\n";
clean_tmp_and_exit(1, @tmpfiles);
}
}
}
if (system("diff","-u",@tmpfiles))
{
# diff returned non-zero, files differ
print STDERR "Manifests differ\n";
clean_tmp_and_exit(1, @tmpfiles);
}
print STDERR "Manifests are equivalent\n";
clean_tmp_and_exit(0, @tmpfiles);
sub clean_tmp_and_exit()
{
my ($res) = @_;
foreach my $f (@tmpfiles) { unlink $f; }
exit($res);
}
|