1 # huge-usr-share -- lintian check script -*- perl -*-
3 # Copyright (C) 2004 Jeroen van Wolffelaar <jeroen@wolffelaar.nl>
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.
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.
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,
21 package Lintian::huge_usr_share;
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;
38 # read architecture file
39 if (open(IN, '<', "fields/architecture")) {
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';
50 my $size = `du -ks unpacked`;
54 my $size_usrshare = `du -ks unpacked/usr/share`;
55 $size_usrshare =~ s/\t.*//;
56 $size_usrshare = int $size_usrshare;
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%";