Added some code to peer into a data structure in Maemian/Schedule.pm. Also added the
[maemian] / nokia-lintian / collection / debian-readme
1 #!/usr/bin/perl -w
2 # debian-readme -- lintian 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 ($#ARGV == 1) or fail("syntax: debian-readme <pkg> <type>");
25 my $pkg = shift;
26 my $type = shift;
27
28 -f "fields/package" or fail("debian-readme invoked in wrong directory");
29
30 unlink("README.Debian");
31
32 # Pick the first of these files that exists.
33 my @readmes = ("unpacked/usr/share/doc/$pkg/README.Debian.gz",
34             "unpacked/usr/share/doc/$pkg/README.Debian",
35             "unpacked/usr/share/doc/$pkg/README.debian.gz",
36             "unpacked/usr/share/doc/$pkg/README.debian",
37         "unpacked/usr/doc/$pkg/README.Debian.gz",
38             "unpacked/usr/doc/$pkg/README.Debian",
39             "unpacked/usr/doc/$pkg/README.debian.gz",
40             "unpacked/usr/doc/$pkg/README.debian");
41
42 my $file;
43 for (@readmes) {
44     if (-f $_) {
45         $file = $_;
46         last;
47     }
48 }
49
50 if (not defined $file) {
51     # no README found
52     open(DUMMY, '>', "README.Debian");
53     close(DUMMY);
54 } elsif ($file =~ m/\.gz$/) {
55     use lib "$ENV{'LINTIAN_ROOT'}/lib";
56     use Pipeline;
57
58     pipeline((sub { exec 'gzip', '-dc', $file }), "README.Debian") == 0
59         or fail("error in gzip");
60 } else {
61     link($file, "README.Debian")
62         or fail("cannot link $file to README.Debian: $!");
63 }
64
65 exit 0;
66
67 # -----------------------------------
68
69 sub fail {
70     if ($_[0]) {
71         print STDERR "internal error: $_[0]\n";
72     } elsif ($!) {
73         print STDERR "internal error: $!\n";
74     } else {
75         print STDERR "internal error.\n";
76     }
77     exit 1;
78 }