Adding side stream changes to Maemian. Working to integrate full upstream libraries...
[maemian] / nokia-lintian / 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 Lintian::huge_usr_share;
22 use strict;
23 use Tags;
24
25 sub run {
26
27 my $pkg = shift;
28 my $type = shift;
29
30 # Threshold in kB of /usr/share to trigger this warning
31 # Consider that the changelog alone can be quite big, and cannot be moved away
32 my $THRESHOLD_SIZE_SOFT = 1024;
33 my $THRESHOLD_SIZE_HARD = 2048;
34 my $THRESHOLD_PERC = 50;
35
36 my $arch;
37
38 # read architecture file
39 if (open(IN, '<', "fields/architecture")) {
40     chop($arch = <IN>);
41     close(IN);
42 }
43
44 # If this is a arch-independent package, this test doesn't apply
45 return 0 if $arch eq 'all';
46 # usr/share missing. other checks will moan about it
47 # so just ignore this package
48 return 0 if !-d 'unpacked/usr/share';
49
50 my $size = `du -ks unpacked`;
51 $size =~ s/\t.*//;
52 $size = int $size;
53
54 my $size_usrshare = `du -ks unpacked/usr/share`;
55 $size_usrshare =~ s/\t.*//;
56 $size_usrshare = int $size_usrshare;
57
58 if ($size_usrshare > $THRESHOLD_SIZE_SOFT) {
59     my $perc = int (100 * $size_usrshare / $size);
60     if (($size_usrshare > $THRESHOLD_SIZE_HARD)
61         || ($perc > $THRESHOLD_PERC)) { 
62         tag "arch-dep-package-has-big-usr-share", "${size_usrshare}kB $perc%";
63     }
64 }
65
66 }
67
68 1;