git: 5457f710e8b8 - main - framework: Fix fetch-url-list and fetch-urlall-list

From: Mateusz Piotrowski <0mp_at_FreeBSD.org>
Date: Wed, 12 Jul 2023 14:19:25 UTC
The branch main has been updated by 0mp:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5457f710e8b827281d83bbba17db0868389205b4

commit 5457f710e8b827281d83bbba17db0868389205b4
Author:     Mateusz Piotrowski <0mp@FreeBSD.org>
AuthorDate: 2023-06-30 09:58:48 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2023-07-12 14:18:21 +0000

    framework: Fix fetch-url-list and fetch-urlall-list
    
    The fetch-url-list and fetch-urlall-list targets are meant to produce
    a list of URLs from which a port fetches its distfiles and patches.
    
    Currently, those targets were not working as expected as they print
    parts of the output meant for other targets like the fetch-list target.
    
    For example:
    
        mateusz.piotrowski@server /ports/x11-servers/xwayland-devel$ make fetch-urlall-list
        [...]
        mkdir -p "xorg" &&
        -o xorg/proto-xorgproto-824001c947cb1962209c6a8f2c63c2637877220d_GL0.tar.gz
        [...]
    
    This patch prevents do-fetch.sh from printing the "mkdir" line and the
    "-o" line.
    
    While here:
    
    - Remove the outdated comment about escaping. There is no excessive
      escaping happening there anymore.
    - Indent cases in the case statement to match the style of the rest of
      the file.
    
    Reviewed by:    pizzamig
    Approved by:    portmgr (pizzamig)
    Sponsored by:   Klara Inc.
    Differential Revision:  https://reviews.freebsd.org/D40808
---
 Mk/Scripts/do-fetch.sh | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/Mk/Scripts/do-fetch.sh b/Mk/Scripts/do-fetch.sh
index 707337928989..da42191cf533 100644
--- a/Mk/Scripts/do-fetch.sh
+++ b/Mk/Scripts/do-fetch.sh
@@ -123,23 +123,24 @@ for _file in "${@}"; do
 	for site in ${sites}; do
 		sites_remaining=$((sites_remaining - 1))
 		CKSIZE=$(distinfo_data SIZE "${full_file}")
-		# There is a lot of escaping, but the " needs to survive echo/eval.
+		early_args=""
 		case ${file} in
 			*/*)
 				case ${dp_TARGET} in
-				fetch-list|fetch-url-list-int)
-					echo "mkdir -p \"${file%/*}\" && "
-					;;
-				*)
-					mkdir -p "${file%/*}"
-					;;
+					fetch-list)
+						echo "mkdir -p \"${file%/*}\" && "
+						early_args="-o ${file}"
+						;;
+					fetch-url-list-int)
+						;;
+					*)
+						mkdir -p "${file%/*}"
+						early_args="-o ${file}"
+						;;
 				esac
-				args="-o ${file} ${site}${file}"
-				;;
-			*)
-				args="${site}${file}"
-				;;
+			;;
 		esac
+		args="${early_args:+${early_args} }${site}${file}"
 		_fetch_cmd="${dp_FETCH_CMD} ${dp_FETCH_BEFORE_ARGS}"
 		if [ -z "${dp_DISABLE_SIZE}" -a -n "${CKSIZE}" ]; then
 			_fetch_cmd="${_fetch_cmd} -S ${CKSIZE}"