git: c35f76fc2d0b - main - Uses/zig.mk: Handle the "NO_WRKSUBDIR" distfiles case

From: Gleb Popov <arrowd_at_FreeBSD.org>
Date: Sun, 28 Dec 2025 15:25:58 UTC
The branch main has been updated by arrowd:

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

commit c35f76fc2d0b8a7547c94fcf12693d66eb1a3b26
Author:     Gleb Popov <arrowd@FreeBSD.org>
AuthorDate: 2025-12-28 15:02:18 +0000
Commit:     Gleb Popov <arrowd@FreeBSD.org>
CommitDate: 2025-12-28 15:25:52 +0000

    Uses/zig.mk: Handle the "NO_WRKSUBDIR" distfiles case
    
    Reported by:    Siva Mahadevan <me@svmhdvn.name>
---
 Mk/Uses/zig.mk | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Mk/Uses/zig.mk b/Mk/Uses/zig.mk
index 5727a812fede..5708ff05a3da 100644
--- a/Mk/Uses/zig.mk
+++ b/Mk/Uses/zig.mk
@@ -70,7 +70,13 @@ zig-pre-extract:
 .  for z in ${ZIG_TUPLE}
 .    for group url dir in ${z:S/:/ /g:tw}
 	${MAKE} -C ${.CURDIR} do-extract EXTRACT_ONLY=${url:T} WRKDIR=${ZIG_TMPDEPSDIR}
-	${MV} ${ZIG_TMPDEPSDIR}/* ${ZIG_DEPSDIR}/${dir}
+	# In some cases the distfile holds files at the top level of the archive,
+	# s we have to move ${ZIG_TMPDEPSDIR} itself, not its contents.
+	if [ "$$(${FIND} ${ZIG_TMPDEPSDIR} -depth 1 -type f)" ]; then \
+		${MV} ${ZIG_TMPDEPSDIR} ${ZIG_DEPSDIR}/${dir}; \
+	else \
+		${MV} ${ZIG_TMPDEPSDIR}/* ${ZIG_DEPSDIR}/${dir}; \
+	fi
 .    endfor
 .  endfor
 	@${RMDIR} ${ZIG_TMPDEPSDIR}