Koha/debian/list-deps
Lars Wirzenius 2fcc4fe94e Add tools to update debian/control's build dependencies.
The canonical list of Perl module dependencies are in
C4::Installer::PerlDependencies::PERL_DEPS now. Add a script
(debian/list-deps) to turn that into a list of Debian package names.

Because that is a slow process, and the output rarely changes, do
not do that at build time. Also, doing it at build time would require
modifying debian/control in evil ways.

Instead, add another tool, debian/update-control, which reads the
new file debian/control.in, and adds the output of debian/list-deps to
Build-Depends and creates a new debian/control.

debian/control.in is the master file. If changes are needed, that should
be edited. For performance and convenience reasons, the output is also kept
in git, but don't edit debian/control directly, please. Such changes
might get lost by the next commit by someone else.

Whenever PERL_DEPS changes, debian/update-control should be run as well
and the result committed to git.

This is not quite as automatic as it might be, but should be good enough.
It avoids keeping the list of Perl modules in two places.

Note that since it seems impossible to automatically figure out the Debian
package version that corresponds to a Perl module version, I have not
tried to do that at all.

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
2010-06-02 07:14:36 -04:00

49 lines
1.5 KiB
Perl
Executable file

#!/usr/bin/perl
#
# Write dependency list from Koha PerlDependencies.pm, in Debian format.
#
# Copyright 2010 Catalyst IT, Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use C4::Installer::PerlDependencies;
my $deps = $C4::Installer::PerlDependencies::PERL_DEPS;
my $prefix = "^/usr/((lib|share)/perl5|(lib|share)/perl/[0-9.]+)";
foreach my $module (keys %$deps) {
my $ver = $deps->{$module}->{'min_ver'};
my $subpath = $module;
$subpath =~ s,::,/,g;
my $output =
qx(apt-file -l -x search "$prefix/$subpath.pm\$");
my @lines = split(/\n/, $output);
if (scalar(@lines) == 1 && $lines[0] ne "") {
my $pkg = $lines[0];
print "$pkg\n";
} elsif (scalar(@lines) > 1) {
foreach my $pkg (@lines) {
print " | " if ($pkg ne $lines[0]);
print "$pkg";
}
print "\n";
} else {
print "EEEK: unknown package for $module\n";
}
}