summaryrefslogtreecommitdiff
path: root/Master/tlpkg/bin/tl-compare-tlpdbs
blob: f1bee1796322ead9d85980908a5546edca478baa (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/env perl
# Copyright 2008, 2009, 2010, 2011 Norbert Preining
# This file is licensed under the GNU General Public License version 2
# or any later version.
#
# compare two tlpdbs
#

BEGIN {
  $vc_id = '$Id$';
  $^W = 1;
  ($mydir = $0) =~ s,/[^/]*$,,;
  unshift (@INC, "$mydir/..");
}

use strict;
use TeXLive::TLUtils;
use TeXLive::TLPDB;
use Getopt::Long;
use Pod::Usage;

# packages ignored unless --all is given
# see @critical_pkg_list in tl-update-containers
my @add_ignored_packs = qw/texlive.infra tlperl.win32/;

our ($mydir, $vc_id);
my $opt_version = 0;
my $opt_help = 0;

TeXLive::TLUtils::process_logging_options();
GetOptions(
  "version"	=> \$opt_version,
  "help|?"      => \$opt_help,
  "all"   => sub { @add_ignored_packs = () },
) or pod2usage(1);

pod2usage("-exitstatus" => 0, "-verbose" => 2) if $opt_help;
if ($opt_version) { print "$vc_id\n"; exit 0; } 

exit (&main());


sub main
{
  chomp(my $Master = `cd $mydir/../.. && pwd`);
  #
  # if tl-compare-tlpdbs was called with two arguments like
  #   tl-compare-tlpdbs aaa bbb
  # then aaa and bbb are assumed to be two .tlpdb files.
  # if it was called with one argument only then this one is the tlpdb
  # to be compared with the "self-defined" (i.e., the one in 
  # $Master/tlpkg/texlive.tlpdb) one, where the "self-defined" is the
  # first one, and the to be compared the second one

  my $tlpdbAsrc;
  my $tlpdbBsrc;

  if ($#ARGV < 0) {
    tlwarn("$0 expects either one or two arguments, exiting.\n");
    exit 1;
  }

  if ($#ARGV == 0) {
    # one argument
    $tlpdbBsrc = $ARGV[0];
    $tlpdbAsrc = "$Master/tlpkg/texlive.tlpdb";
  } elsif ($#ARGV == 1) {
    $tlpdbAsrc = $ARGV[0];
    $tlpdbBsrc = $ARGV[1];
  } else {
    tlwarn("$0 expects either one or two arguments, exiting.\n");
    exit 1;
  }

  if (! -r $tlpdbAsrc) {
    tlwarn("$0: not readable $tlpdbAsrc, exiting.\n");
    exit 1;
  }
  if (! -r $tlpdbBsrc) {
    tlwarn("$0: not readable $tlpdbBsrc, exiting.\n");
    exit 1;
  }

  my $tlpdbA = TeXLive::TLPDB->new();
  my $tlpdbB = TeXLive::TLPDB->new();
  $tlpdbA->from_file($tlpdbAsrc);
  $tlpdbB->from_file($tlpdbBsrc);

  my %ret = TeXLive::TLUtils::compare_tlpdbs(
      $tlpdbA, $tlpdbB, @add_ignored_packs);

  # anything reported here is a difference in tlpdbs which we do not want
  if (keys %ret) {
    TeXLive::TLUtils::report_tlpdb_differences(\%ret);
    return 1;
  }
  return 0;
}


__END__

=head1 NAME

tl-compare-tlpdbs - compare two tlpdbs

=head1 SYNOPSIS

tl-compare-tlpdbs [I<option>]... <TLPDB1> [<TLPDB2>]

=head1 OPTIONS

=over 4

=item B<-help>

Print this documentation and exit.

=back

The standard options B<-q>, B<-v>, and B<-logfile>=I<file> are also
accepted; see the C<process_logging_options> function in
L<TeXLive::TLUtils> for details.

=head1 DESCRIPTION

This program compares two tlpdbs. If two arguments are given both
have to refer to a .tlpdb file and the two tlpdbs will be compared.
If only one argument is given then the tlpdb from the tree of this
program itself is compared with the tlpdb given on the command line.

The comparision reports revision differences, and if the revision are
the same, differences in the file lists.

=head1 AUTHORS AND COPYRIGHT

This script and its documentation were written for the TeX Live
distribution (L<http://tug.org/texlive>) and both are licensed under the
GNU General Public License Version 2 or later.

=cut

### Local Variables:
### perl-indent-level: 2
### tab-width: 2
### indent-tabs-mode: nil
### End:
# vim:set tabstop=2 expandtab: #