(bug #2996) fix and improve 100 and 105 unimarc plugins
[koha.git] / misc / syspref-diff.pl
1 #!/usr/bin/perl 
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
8 # version.
9 #
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA  02111-1307 USA
17
18 =head1 NAME
19
20 syspref-diff.pl <syspref-file-1> <syspref-file-2> 
21
22 For example: 
23
24   cd <koharoot>/installer/data/mysql
25   syspref-diff.pl en/mandatory.sql fr-FR/1-Obligatoire/unimarcsp.sql
26
27 =head1 DESCRIPTION
28
29 Make a diff between two Koha syspref files. 
30 'en' syspref file beeing authoritative, this script identifies
31 variables to be added/deleted in another language syspref file.
32
33 =cut
34
35 use strict;
36
37
38 my $file1 = shift @ARGV;
39 my $file2 = shift @ARGV;
40
41 open FILE1, "<$file1" or die "Unable to open $file1\n";
42 open FILE2, "<$file2" or die "Unable to open $file2\n";
43
44 my (%syspref1, %syspref2);
45 my $variable;
46
47 while ( <FILE1> ) {
48     /VALUES.*\(\'([\w-:]+)\'/;
49     $variable = lc $1; 
50     $syspref1{$variable} = 1 unless $syspref1{$variable};
51 }
52 while ( <FILE2> ) {
53     /VALUES.*\(\'([\w-:]+)\'/;
54     $variable = lc $1;
55     $syspref2{$variable} = 1 unless $syspref2{$variable};
56 }
57
58 print "Variables present in $file1 but unavailable in $file2\n";
59 for ( sort keys %syspref1 ) {
60     print $_, "\n" unless $syspref2{$_};
61 }
62 print "\nVariables present in $file2 but unavailable in $file2\n";
63 for ( sort keys %syspref2 ) {
64     print $_, "\n" unless $syspref1{$_};
65 }
66
67