Bug 6540 - [SIGNED-OFF] fix some command-line args issues
[koha.git] / debian / list-deps
1 #!/usr/bin/perl
2 #
3 # Write dependency list from Koha PerlDependencies.pm, in Debian format.
4 #
5 # Copyright 2010  Catalyst IT, Ltd
6
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20
21 use strict;
22 use warnings;
23
24 use C4::Installer::PerlDependencies;
25
26 my $deps = $C4::Installer::PerlDependencies::PERL_DEPS;
27
28 my $prefix = "^/usr/((lib|share)/perl5|(lib|share)/perl/[0-9.]+)";
29
30 foreach my $module (keys %$deps) {
31     my $ver = $deps->{$module}->{'min_ver'};
32     my $subpath = $module;
33     $subpath =~ s,::,/,g;
34     my $output = 
35         qx(apt-file -l -x search "$prefix/$subpath.pm\$");
36     my @temp = split(/\n/, $output);
37     my @lines = ();
38     # Remove packages that are required/essential and always installed on
39     # a Debian system. Debian packages should not have unversioned 
40     # dependencies on such packages.
41     foreach my $line (@temp) {
42         if ($line ne "perl-base") {
43             @lines = (@lines, $line);
44         }
45     }
46     if (scalar(@lines) == 1 && $lines[0] ne "") {
47         my $pkg = $lines[0];
48         print "$pkg\n";
49     } elsif (scalar(@lines) > 1) {
50         foreach my $pkg (@lines) {
51             print " | " if ($pkg ne $lines[0]);
52             print "$pkg";
53         }
54         print "\n";
55     } elsif (scalar(@temp) != 0) {
56         # I'm an Essential and I'm OK,
57         # I install all night, and work all day.
58         # I chomp up strings. I eat my bugs.
59         # I go to the base install.
60         # On Fridays I go drinking,
61         # and have buttered commits for git.
62         # (Beer O'Clock is more than two hours
63         # away. I don't even drink beer. There
64         # is no reason to be suspicious of this
65         # commit.)
66         # RM note: suspicious?  me?  always!
67     } else {
68         print "EEEK: unknown package for $module\n";
69     }
70 }