Checksum mismatch error

One fairly common portupgrade (and first time install for that matter) error is "checksum mismatch." (bash seems to be particularly prone to this error). The error will manifest itself in a scenario something like this:

fongsaiyuk# portupgrade bash
---> Upgrading 'bash-3.1.16' to 'bash-3.1.17' (shells/bash)
---> Building '/usr/ports/shells/bash'
===> Cleaning for gettext-0.14.5_2
===> Cleaning for libtool-1.5.22_2
===> Cleaning for libiconv-1.9.2_2
===> Cleaning for bash-3.1.17
===> Vulnerability check disabled, database not found
=> bash31-017 doesn't seem to exist in /usr/ports/distfiles/bash.
=> Attempting to fetch from http://ftp.gnu.org/gnu/bash/bash-3.1-patches//.
bash31-017                                    nbsp;100% of 3640 B 1682 kBps
===> Extracting for bash-3.1.17
=> MD5 Checksum OK for bash/bash-3.1.tar.gz.
=> SHA256 Checksum OK for bash/bash-3.1.tar.gz.
=> MD5 Checksum OK for bash/bash31-001.
=> SHA256 Checksum OK for bash/bash31-001.
=> MD5 Checksum OK for bash/bash31-002.
=> SHA256 Checksum OK for bash/bash31-002.
=> MD5 Checksum OK for bash/bash31-003.
=> SHA256 Checksum OK for bash/bash31-003.
=> MD5 Checksum OK for bash/bash31-004.
=> SHA256 Checksum OK for bash/bash31-004.
=> MD5 Checksum OK for bash/bash31-005.
=> SHA256 Checksum OK for bash/bash31-005.
=> MD5 Checksum OK for bash/bash31-006.
=> SHA256 Checksum OK for bash/bash31-006.
=> MD5 Checksum OK for bash/bash31-007.
=> SHA256 Checksum OK for bash/bash31-007.
=> MD5 Checksum OK for bash/bash31-008.
=> SHA256 Checksum OK for bash/bash31-008.
=> MD5 Checksum OK for bash/bash31-009.
=> SHA256 Checksum OK for bash/bash31-009.
=> MD5 Checksum mismatch for bash/bash31-010.
=> SHA256 Checksum mismatch for bash/bash31-010.

Catch the problem? It's those last two lines (well in this particular example there are actually bash31-001 through bash-31-017, but I cut out the last 7 because the checksum data is OK for all of them), which are telling us that the size given in distinfo for bash31-10 does not match the actual size of the bash31-10 we downloaded. Following all of the checksums, you'll get something like this:

===> Refetch for 1 more times files: bash/bash31-010 bash/bash31-010
===> Vulnerability check disabled, database not found
=> bash31-010 doesn't seem to exist in /usr/ports/distfiles/bash.
=> Attempting to fetch from http://ftp.gnu.org/gnu/bash/bash-3.1-patches//.
fetch: bash31-010: local modification time does not match remote

And this same or a similar "fetch error" will then be repeated for each server (18 or 19 for this app) that portupgrade tries to download this from. The end result is:

=> Couldn't fetch it - please try to retrieve this
=> port manually into /usr/ports/distfiles/bash and try again.
*** Error code 1

You have 2 options at this point: (1) wait for the port maintainer to fix the incorrect information in this Port's distfile so that after a fresh cvsup, you'll be able to portupgrade or install this Port. (2) Delete distinfo and try portupgrading or installing again. We're opting for option #2.

whereis bash
cd /usr/ports/shells/bash
rm distinfo
portupgrade bash

portupgrade will complain about:

=> No checksum file (/usr/ports/shells/bash/distinfo).

But will continue anyway and upgrade (or install) bash without any further problems.