Tweak print/hplip version 3.16.11_2
[dports.git] / Tools / scripts / checksize.sh
1 #!/bin/sh
2 # checksize.sh:  scan the ports collection for "size mismatch" and
3 # "size unknown" errors by attempting to fetch onto a full filesystem
4 #
5 # When called with a parameter that is the name of a category of
6 # ports, the script checks that category, then checks the whole
7 # ports collection, redoing the named category.  When called with
8 # no parameter, it checks the whole collection.
9 #
10 # First do something like:
11 #
12 #       dd if=/dev/zero of=/usr/ports/mfs.img bs=1k count=512
13 #       mdconfig -a -t vnode -f /usr/ports/mfs.img -u 1
14 #       newfs /dev/md1
15 #       mount /dev/md1 /mnt
16 #
17 # (for RELENG_4 use vnconfig instead of mdconfig).  Then run this
18 # while logging with, for example, the "script" utility and look
19 # for "size mismatch" (indicating the server has a distfile with a
20 # different size than what is listed in the distinfo file) and "size
21 # unknown" (indicating that the server does not report file sizes)
22 # errors in the output.  Pipe the output through:
23 #
24 #       grep -w size | grep -1 -E "unknown|mismatch"
25 #
26 # By keeping the filesystem full, we avoid fetching entire distfiles.
27 # The script attempts to partially download each distfile from all
28 # master sites.  Contacting all sites is desirable because sometimes
29 # a site which ostensibly mirrors another may contain corrupt files
30 # which are intact on the main site (or vice versa).
31 #
32 # bugs:
33 # - assumes ports tree is in /usr/ports/
34 # - doesn't provide for checking only particular categories or ports
35 # - support for multiple architectures is inefficient
36 # - output is messy
37 # - on my system, the first 20 kB of each distfile are fetched
38 #   (this can be suppressed by adding FETCH_BEFORE_ARGS=-s to the make options,
39 #   in which case the word "Unknown" appears by itself on a line
40 #   where otherwise there would be a "size unknown" error, and "size
41 #   mismatch" errors are not detected)
42 # - needs manual setup of /mnt/
43 #
44 # placed in the public domain by Trevor Johnson
45
46 for category in $1 `grep ^SUBDIR /usr/ports/Makefile | cut -f3 -d\ `; do
47         cd /usr/ports/$category
48         for port in \
49                 `grep -wc SIZE */distinfo* | grep -v :0 | cut -f1 -d\/`; do
50                 cd /usr/ports/$category/$port
51                 for arc in i386; do
52                         dd if=/dev/zero of=/mnt/zero
53                         echo checking $arc size data for $category/$port
54                         make    DISTDIR=/mnt \
55                                 ARCH=$arc \
56                                 BATCH=yes \
57                                 MACHINE_ARCH=$arc \
58                                 PACKAGE_BUILDING=yes \
59                                 TRYBROKEN=yes checksum
60                         rm -rf /mnt/*
61                 done
62         done
63 done