2 # checksize.sh: scan the ports collection for "size mismatch" and
3 # "size unknown" errors by attempting to fetch onto a full filesystem
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.
10 # First do something like:
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
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:
24 # grep -w size | grep -1 -E "unknown|mismatch"
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).
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
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/
44 # placed in the public domain by Trevor Johnson
46 for category in $1 `grep ^SUBDIR /usr/ports/Makefile | cut -f3 -d\ `; do
47 cd /usr/ports/$category
49 `grep -wc SIZE */distinfo* | grep -v :0 | cut -f1 -d\/`; do
50 cd /usr/ports/$category/$port
52 dd if=/dev/zero of=/mnt/zero
53 echo checking $arc size data for $category/$port
58 PACKAGE_BUILDING=yes \
59 TRYBROKEN=yes checksum