Added lots more modules from lintian. Maemian appears to work.
[maemian] / checks / huge-usr-share
1 # huge-usr-share -- lintian check script -*- perl -*-
2
3 # Copyright (C) 2004 Jeroen van Wolffelaar <jeroen@wolffelaar.nl>
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 Maemian::huge_usr_share;
22 use strict;
23 use Tags;
24
25 # Threshold in kB of /usr/share to trigger this warning.  Consider that the
26 # changelog alone can be quite big, and cannot be moved away.
27 my $THRESHOLD_SIZE_SOFT = 1024;
28 my $THRESHOLD_SIZE_HARD = 2048;
29 my $THRESHOLD_PERC = 50;
30
31 sub run {
32
33 my $pkg = shift;
34 my $type = shift;
35 my $info = shift;
36
37 # Skip architecture-dependent packages.
38 my $arch = $info->field('architecture') || '';
39 return 0 if $arch eq 'all';
40
41 # usr/share missing. other checks will moan about it
42 # so just ignore this package
43 return 0 if !-d 'unpacked/usr/share';
44
45 my $size = `du -ks unpacked`;
46 $size =~ s/\t.*//;
47 $size = int $size;
48
49 my $size_usrshare = `du -ks unpacked/usr/share`;
50 $size_usrshare =~ s/\t.*//;
51 $size_usrshare = int $size_usrshare;
52
53 if ($size_usrshare > $THRESHOLD_SIZE_SOFT) {
54     my $perc = int (100 * $size_usrshare / $size);
55     if (($size_usrshare > $THRESHOLD_SIZE_HARD)
56         || ($perc > $THRESHOLD_PERC)) { 
57         tag "arch-dep-package-has-big-usr-share", "${size_usrshare}kB $perc%";
58     }
59 }
60
61 }
62
63 1;