git: 0767979029be - main - Mk: try and fix makesum another way

From: Mathieu Arnold <mat_at_FreeBSD.org>
Date: Wed, 23 Sep 2026 10:22:49 UTC
The branch main has been updated by mat:

URL: https://cgit.FreeBSD.org/ports/commit/?id=0767979029be4c4a9dfc60f893eee47ac33ccf9f

commit 0767979029be4c4a9dfc60f893eee47ac33ccf9f
Author:     Mathieu Arnold <mat@FreeBSD.org>
AuthorDate: 2026-09-22 14:57:57 +0000
Commit:     Mathieu Arnold <mat@FreeBSD.org>
CommitDate: 2026-09-23 10:21:42 +0000

    Mk: try and fix makesum another way
    
    Differential Revision:  https://reviews.freebsd.org/D59905
---
 Mk/Scripts/do-fetch.sh | 12 ++++------
 Mk/bsd.port.mk         | 59 ++++++++++++++++++++++++++++++--------------------
 2 files changed, 40 insertions(+), 31 deletions(-)

diff --git a/Mk/Scripts/do-fetch.sh b/Mk/Scripts/do-fetch.sh
index e2bec577dfe2..cb564a4b1303 100644
--- a/Mk/Scripts/do-fetch.sh
+++ b/Mk/Scripts/do-fetch.sh
@@ -19,10 +19,6 @@ validate_env dp_DEVELOPER dp_DISABLE_SIZE dp_DISTDIR dp_DISTINFO_FILE \
 set -u
 
 case ${dp_TARGET} in
-	makesum-fetch)
-		dp_NO_CHECKSUM=yes
-		dp_DISABLE_SIZE=yes
-		;&
 	do-fetch|makesum)
 		if [ ! -d "${dp_DISTDIR}" ]; then
 			mkdir -p "${dp_DISTDIR}"
@@ -77,7 +73,7 @@ while IFS= read -r _file; do
 		fi
 	fi
 	case ${dp_TARGET} in
-		do-fetch|makesum|makesum-fetch)
+		do-fetch|makesum)
 			${dp_ECHO_MSG} "=> $file doesn't seem to exist in ${dp_DISTDIR}."
 			if [ ! -w "${dp_DISTDIR}" ]; then
 				${dp_ECHO_MSG} "=> ${dp_DISTDIR} is not writable by you; cannot fetch."
@@ -96,7 +92,7 @@ while IFS= read -r _file; do
 			__MASTER_SITES_TMP="${__MASTER_SITES_TMP} ${___MASTER_SITES_TMP}"
 		else
 			case ${dp_TARGET} in
-				do-fetch|makesum|makesum-fetch)
+				do-fetch|makesum)
 					if [ -n "${dp_DEVELOPER}" ]; then
 						${dp_ECHO_MSG} "===> /!\\ Error /!\\"
 					else
@@ -156,7 +152,7 @@ while IFS= read -r _file; do
 		fi
 		_fetch_cmd="${_fetch_cmd} ${args} ${dp_FETCH_AFTER_ARGS}"
 		case ${dp_TARGET} in
-			do-fetch|makesum|makesum-fetch)
+			do-fetch|makesum)
 				${dp_ECHO_MSG} "=> Attempting to fetch ${site}${file}"
 				if env -S "${dp_FETCH_ENV}" ${_fetch_cmd}; then
 					actual_size=$(stat -f %z "${file}")
@@ -180,7 +176,7 @@ while IFS= read -r _file; do
 		esac
 	done
 	case ${dp_TARGET} in
-		do-fetch|makesum|makesum-fetch)
+		do-fetch|makesum)
 			${dp_ECHO_MSG} "=> Couldn't fetch it - please try to retrieve this"
 			${dp_ECHO_MSG} "=> port manually into ${dp_DISTDIR} and try again."
 			exit 1
diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index d9102a62e28e..798d4830db74 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -3116,21 +3116,43 @@ _DISTFILES_FILE=${WRKDIR}/.distfiles
 _PATCH_SITES_FILE=${WRKDIR}/.patch_sites
 _PATCHFILES_FILE=${WRKDIR}/.patchfiles
 
+create-do-fetch-distfiles-files: .PHONY
+.    if !empty(DISTFILES)
+.      if !defined(_DO_FETCH_FILES_CREATED) || ${_DO_FETCH_FILES_CREATED} != ${PKGORIGIN}
+	@${MKDIR} ${WRKDIR}
+	@${RM} ${_MASTER_SITES_FILE} ${_DISTFILES_FILE}
+.        for site in ${_MASTER_SITES_ENV}
+	@printf '%s\n' "${site}" >> ${_MASTER_SITES_FILE}
+.        endfor
+.        for file in ${DISTFILES}
+	@printf '%s\n' "${file}" >> ${_DISTFILES_FILE}
+.        endfor
+.      endif
+.    endif
+
+create-do-fetch-patchfiles-files: .PHONY
+.    if defined(PATCHFILES) && !empty(PATCHFILES)
+.      if !defined(_DO_FETCH_FILES_CREATED) || ${_DO_FETCH_FILES_CREATED} != ${PKGORIGIN}
+	@${MKDIR} ${WRKDIR}
+	@${RM} ${_PATCH_SITES_FILE} ${_PATCHFILES_FILE}
+.        for site in ${_PATCH_SITES_ENV}
+	@printf '%s\n' "${site}" >> ${_PATCH_SITES_FILE}
+.        endfor
+.        for file in ${PATCHFILES}
+	@printf '%s\n' "${file:C/:-p[0-9]//}" >> ${_PATCHFILES_FILE}
+.        endfor
+.      endif
+.    endif
+
+
 # do-fetch does the fetching
 # fetch-list Prints out a list of files to fetch (useful to do a batch fetch)
 # fetch-url-list-int Used by fetch-urlall-list and fetch-url-list
-.    for _target in do-fetch fetch-list fetch-url-list-int makesum-fetch
+.    for _target in do-fetch fetch-list fetch-url-list-int
 .      if !target(${_target})
-${_target}:
+${_target}: create-do-fetch-distfiles-files create-do-fetch-patchfiles-files
 	@${MKDIR} ${WRKDIR}
 .        if !empty(DISTFILES)
-	@${RM} ${_MASTER_SITES_FILE} ${_DISTFILES_FILE}
-.          for site in ${_MASTER_SITES_ENV}
-	@printf '%s\n' "${site}" >> ${_MASTER_SITES_FILE}
-.          endfor
-.          for file in ${DISTFILES}
-	@printf '%s\n' "${file}" >> ${_DISTFILES_FILE}
-.          endfor
 	@${SETENV} \
 			${_DO_FETCH_ENV} \
 			dp_SITES_FILE=${_MASTER_SITES_FILE} \
@@ -3139,13 +3161,6 @@ ${_target}:
 			${SH} ${SCRIPTSDIR}/do-fetch.sh
 .        endif
 .        if defined(PATCHFILES) && !empty(PATCHFILES)
-	@${RM} ${_PATCH_SITES_FILE} ${_PATCHFILES_FILE}
-.          for site in ${_PATCH_SITES_ENV}
-	@printf '%s\n' "${site}" >> ${_PATCH_SITES_FILE}
-.          endfor
-.          for file in ${PATCHFILES}
-	@printf '%s\n' "${file:C/:-p[0-9]//}" >> ${_PATCHFILES_FILE}
-.          endfor
 	@${SETENV} \
 			${_DO_FETCH_ENV} \
 			dp_SITES_FILE=${_PATCH_SITES_FILE} \
@@ -3937,13 +3952,11 @@ _CKSUMFILES_FILE=${WRKDIR}/.cksumfiles
 # the options consistent when fetching and when makesum'ing.
 # As we're fetching new distfiles, that are not in the distinfo file, disable
 # checksum and sizes checks.
-# NOTE: if you arrived here because your port defines a custom do-fetch target,
-# and makesum is somewhat broken, you need to define both do-fetch and
-# makesum-fetch to do the same thing, the easiest way is to do:
-# do-fetch makesum-fetch:
-#		@target content
-makesum: check-sanity
-	@cd ${.CURDIR} && ${MAKE} makesum-fetch
+makesum: check-sanity create-do-fetch-distfiles-files create-do-fetch-patchfiles-files
+	@cd ${.CURDIR} && ${MAKE} fetch \
+			NO_CHECKSUM=yes \
+			DISABLE_SIZE=yes \
+			_DO_FETCH_FILES_CREATED=${PKGORIGIN}
 	@${MKDIR} ${WRKDIR}
 	@${RM} ${_CKSUMFILES_FILE}
 .      for file in ${_CKSUMFILES}