Added some code to peer into a data structure in Maemian/Schedule.pm. Also added the
[maemian] / nokia-lintian / checks / control-files
1 # control-files -- lintian check script -*- perl -*-
2
3 # Copyright (C) 1998 Christian Schwarz and Richard Braakman
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, you can find it on the World Wide
17 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
18 # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20
21 package Lintian::control_files;
22 use strict;
23 use Tags;
24 use Util;
25
26 sub run {
27
28 my $pkg = shift;
29 my $type = shift;
30
31 my %ctrl_deb =
32     (
33      'clilibs', 0644,
34      'config', 0755,
35      'control', 0644,
36      'conffiles', 0644,
37      'md5sums', 0644,
38      'postinst', 0755,
39      'preinst', 0755,
40      'postrm', 0755,
41      'prerm', 0755,
42      'shlibs', 0644,
43      'symbols', 0644,
44      'templates', 0644,
45      'triggers', 0644,
46     );
47
48 my %ctrl_udeb =
49     (
50      'config', 0755,
51      'control', 0644,
52      'isinstallable', 0755,
53      'menutest', 0755,
54      'postinst', 0755,
55      'shlibs', 0644,
56      'symbols', 0644,
57      'templates', 0644,
58     );
59
60 my %ctrl = $type eq 'udeb' ? %ctrl_udeb : %ctrl_deb;
61 my %ctrl_alt = $type eq 'udeb' ? %ctrl_deb : %ctrl_udeb;
62
63 # process control-index file
64 open(IN, '<', "control-index") or fail("cannot open control-index file: $!");
65 while (<IN>) {
66     chop;
67
68     my ($perm,$owner,$size,$date,$time,$file) = split(' ', $_, 6);
69     my $operm;
70
71     next if $file eq './';
72
73     $file =~ s,^(\./),,;
74     $file =~ s/ link to .*//;
75     $file =~ s/ -> .*//;
76
77     next if $file eq './';
78
79     # valid control file?
80     unless ( exists $ctrl{$file} ) {
81         if ( exists $ctrl_alt{$file} ) {
82             tag "not-allowed-control-file", "$file";
83             next;
84         } else {
85             tag "unknown-control-file", "$file";
86             next;
87         }
88     }
89
90     # I'm not sure about the udeb case
91     if ($type ne 'udeb' and $size == 0) {
92         tag "control-file-is-empty", "$file";
93     }
94
95
96     # skip `control' control file (that's an exception: dpkg doesn't care and
97     # this file isn't installed on the systems anyways)
98     next if $file eq 'control';
99
100     $operm = perm2oct($perm);
101
102     # correct permissions?
103     unless ($operm == $ctrl{$file}) {
104         tag "control-file-has-bad-permissions",
105             sprintf("$file %04o != %04o",$operm,$ctrl{$file});
106     }
107
108     # correct owner?
109     unless ($owner eq 'root/root') {
110         tag "control-file-has-bad-owner", "$file $owner != root/root";
111     }
112
113 # for other maintainer scripts checks, see the scripts check
114 }
115 close IN;
116
117 } # </run>
118
119 1;
120
121 # vim: syntax=perl sw=4 ts=8