Opened 6 months ago

Closed 6 months ago

#73593 closed defect (fixed)

`port bump` often updates the wrong checksum if a Portfile contains multiple checksums

Reported by: herbygillot (Herby Gillot) Owned by: herbygillot (Herby Gillot)
Priority: Normal Milestone:
Component: base Version: 2.12.3
Keywords: Cc:
Port:

Description

As per the summary. When a Portfile contains more than one checksum, perhaps for multiple distfiles, port bump does not behave correctly, and often updates the wrong checksum block.

Change History (2)

comment:1 Changed 6 months ago by herbygillot (Herby Gillot)

Last edited 6 months ago by herbygillot (Herby Gillot) (previous) (diff)

comment:2 Changed 6 months ago by herbygillot (Herby Gillot)

Resolution: fixed
Status: assignedclosed

In 0cd72bfdc87251b5d438e614f8693b7d8519f58d/macports-base (master):

portbump: replace sed with targeted Tcl-based checksum and revision handling

Drop sed(1) entirely from portbump. Instead, read the Portfile into a
line list and use three new procs for targeted modifications:

  • replace_checksums: match hash values as whole words using \y word-boundary anchors, so a size value like 123 cannot accidentally clobber a larger value such as 12345; targets only the correct lines even with multiple subports, conditional branches, or variant-scoped checksums.
  • find_revision_line: two-phase strategy — first check for an inline revision on the subport declaration line (e.g. llvm pattern), then fall back to the nearest standalone revision line, excluding lines inside subport { } blocks when bumping the parent port.
  • reset_revision: simple regsub to set revision to 0, preserving indentation and surrounding text.

Fixes a bug where both_checksums was reset on each distfile iteration,
causing only the last distfile's checksums to be updated in Portfiles
with multiple distfiles (e.g. git with git-manpages and git-htmldocs).

Fixes a bug where already-correct checksums were shown in the
"We will bump these:" output.

Also fixes a bug where patch mode applied file attributes to the
Portfile instead of the patch file.

Removes dead code left over from the sed-based implementation.

Adds comprehensive test suite covering real-world Portfile patterns
(git, go, llvm-16, gradle), including tests for whole-word size
matching, subport blocks with nested braces, multiple distfiles,
partial mismatch, and the no-revision-line code path.

Closes: #65601
Closes: #73593

Co-Authored-By: Claude Sonnet 4.6 <noreply@…>

Note: See TracTickets for help on using tickets.