[Midnightbsd-cvs] [MidnightBSD/mports] 11da37: Mk/scripts/do-fetch.sh: diagnose duplicated distin...

Lucas Holt noreply at github.com
Fri Aug 21 23:48:06 EDT 2026


  Branch: refs/heads/master
  Home:   https://github.com/MidnightBSD/mports
  Commit: 11da37178655722145db4436f78cf5d30c812674
      https://github.com/MidnightBSD/mports/commit/11da37178655722145db4436f78cf5d30c812674
  Author: Lucas Holt <luke at foolishgames.com>
  Date:   2026-08-21 (Fri, 21 Aug 2026)

  Changed paths:
    M Mk/scripts/do-fetch.sh

  Log Message:
  -----------
  Mk/scripts/do-fetch.sh: diagnose duplicated distinfo entries (#760)

## Problem

`distinfo_data()` prints one line per matching entry, so a distfile
listed twice in `distinfo` makes `CKSIZE` **two** values instead of one:

```sh
CKSIZE=$(distinfo_data SIZE "${full_file}")   # -> "117326728 117326728"
```

`CKSIZE` is interpolated unquoted into `-S ${CKSIZE}`, so it word-splits
into `fetch(1)`'s argument list and the second value is taken as an
extra URL. Every mirror then fails with an error that points nowhere
near the real problem:

```
fetch: 117326728: No such file or directory
fetch: rust/crates/Inflector-0.11.4.crate is not a directory
=> Couldn't fetch it - please try to retrieve this port manually
```

The size comparison further down breaks the same way — `[
"${actual_size}" -eq "${CKSIZE}" ]` gets too many arguments — so even a
*completed* download is discarded as a size mismatch.

This cost real debugging time: two ports in Magus run 647 (`ai/codex`,
`java/openjdk23`) were reported as fetch failures that looked exactly
like mirror outages. Fixed separately in #758 and #759.

## Fix

Validate `CKSIZE` before it reaches the command line, and report the
actual cause:

```
=> Invalid SIZE for zipmix_src.zip in .../distinfo.
=> Expected a single integer, got: 4759 4759
=> The entry is most likely present more than once.
```

The check sits inside the existing `-z "${dp_DISABLE_SIZE}"` guard, so
**`makesum` is unaffected** — it runs with `DISABLE_SIZE=yes
NO_CHECKSUM=yes` and remains usable to regenerate a duplicated distinfo.
That matters: a check placed outside the guard would break the very
command you'd use to recover.

## Deliberately not changed

- `checksum.sh` iterates `for chksum in $CKSUM` on purpose, to allow
several recorded checksums — duplicates are harmless there.
- The `_sha256sum` lookup at line 60 is only tested for emptiness.

Neither is affected, so the `-S` path is the only genuinely broken call
site.

## Testing

With `archivers/zipmix` against a scratch `DISTDIR`:

| Case | Result |
|---|---|
| Clean distinfo | fetches normally, exit 0 (unchanged) |
| Duplicated distinfo, **without** this patch | `=> Couldn't fetch it -
please try to retrieve this port manually` |
| Duplicated distinfo, **with** this patch | the diagnostic above |
| `makesum` on a duplicated distinfo | still regenerates a clean
distinfo |

Also `sh -n` clean, and the `*[!0-9]*` pattern verified against
single-integer, empty, two-value, and non-numeric input.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

## Summary by Sourcery

Bug Fixes:
- Detect duplicated or otherwise invalid distinfo SIZE values before
fetching, replacing misleading fetch failures with a clear diagnostic.

Signed-off-by: Lucas Holt <luke at foolishgames.com>



To unsubscribe from these emails, change your notification settings at https://github.com/MidnightBSD/mports/settings/notifications



More information about the Midnightbsd-cvs mailing list