If the Packages file gets rewritten during apt-get update
execution, then piupart might fail with a hashsum mismatch
error, like:
| DEBUG: Starting command: ['chroot', '/var/cache/pbuilder/tmp.3l19K3MgeX_piuparts_tmp/tmp1m34xz', 'apt-get', 'update']
| DUMP:
| [...]
| Err:5 https://deb.example.com/autobuild gerrit_mika_foobar/main amd64 Packages
| File has unexpected size (1338 != 1346). Mirror sync in progress? [IP: 10.10.42.42 443]
| Hashes of expected file:
| - Filesize:1346 [weak]
| - SHA256:5af5db54c0d80e595a247a2070a1f8381468cbdacea1b62ead353d5bea074697
| - SHA1:61962e3dcd01055a4baf3ab8e318c17832b6b0fd [weak]
| - MD5Sum:92f602acb8051cfd90b3e33900a29932 [weak]
| Release file created at: Tue, 16 Feb 2021 01:13:26 +0000
| [...]
| Reading package lists...
| E: Failed to fetch https://deb.example.com/autobuild/dists/gerrit_mika_foobar/main/binary-amd64/Packages.gz File has unexpected size (1338 != 1346). Mirror sync in progress? [IP: 10.10.42.42 443]
| Hashes of expected file:
| - Filesize:1346 [weak]
| - SHA256:5af5db54c0d80e595a247a2070a1f8381468cbdacea1b62ead353d5bea074697
| - SHA1:61962e3dcd01055a4baf3ab8e318c17832b6b0fd [weak]
| - MD5Sum:92f602acb8051cfd90b3e33900a29932 [weak]
| Release file created at: Tue, 16 Feb 2021 01:13:26 +0000
| E: Some index files failed to download. They have been ignored, or old ones used instead.
| ERROR: Command failed (status=100): ['chroot', '/var/cache/pbuilder/tmp.3l19K3MgeX_piuparts_tmp/tmp1m34xz', 'apt-get', 'update']
By giving the user an option to retry the update procedure (up to times, as specified on the command line), we increase chances for a successful build. This is useful especially in busy continuous integration/delivery environments, lacking by-hash support (see https://www.chiark.greenend.org.uk/~cjwatson/blog/no-more-hash-sum-mismatch-errors.html), for example all repositories using reprepro, which doesn't support by-hash yet (see https://bugs.debian.org/820660).