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 Maemian::huge_usr_share;
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;
37 # Skip architecture-dependent packages.
38 my $arch = $info->field('architecture') || '';
39 return 0 if $arch eq 'all';
41 # usr/share missing. other checks will moan about it
42 # so just ignore this package
43 return 0 if !-d 'unpacked/usr/share';
45 my $size = `du -ks unpacked`;
49 my $size_usrshare = `du -ks unpacked/usr/share`;
50 $size_usrshare =~ s/\t.*//;
51 $size_usrshare = int $size_usrshare;
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%";