Added lots more modules from lintian. Maemian appears to work.
[maemian] / collection / debian-readme
1 #!/usr/bin/perl -w
2 # debian-readme -- maemian collector script
3
4 # Copyright (C) 1998 Richard Braakman
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, you can find it on the World Wide
18 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
19 # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
20 # MA 02110-1301, USA.
21
22 use strict;
23
24 use lib "$ENV{'MAEMIAN_ROOT'}/lib";
25 use Util;
26
27 ($#ARGV == 1) or fail("syntax: debian-readme <pkg> <type>");
28 my $pkg = shift;
29 my $type = shift;
30
31 -f "fields/package" or fail("debian-readme invoked in wrong directory");
32
33 unlink("README.Debian");
34
35 # Pick the first of these files that exists.
36 my @readmes = ("unpacked/usr/share/doc/$pkg/README.Debian.gz",
37             "unpacked/usr/share/doc/$pkg/README.Debian",
38             "unpacked/usr/share/doc/$pkg/README.debian.gz",
39             "unpacked/usr/share/doc/$pkg/README.debian",
40             "unpacked/usr/doc/$pkg/README.Debian.gz",
41             "unpacked/usr/doc/$pkg/README.Debian",
42             "unpacked/usr/doc/$pkg/README.debian.gz",
43             "unpacked/usr/doc/$pkg/README.debian");
44
45 my $file;
46 for (@readmes) {
47     if (-f $_) {
48         $file = $_;
49         last;
50     }
51 }
52
53 if (not defined $file) {
54     # no README found
55     touch_file("README.Debian");
56 } elsif ($file =~ m/\.gz$/) {
57     gunzip_file($file, "README.Debian");
58 } else {
59     link($file, "README.Debian")
60         or fail("cannot link $file to README.Debian: $!");
61 }