From a1191d1e7c1d23b64e9c237ec0d72dbddcd399f0 Mon Sep 17 00:00:00 2001 From: Den Kong Date: Sun, 6 Sep 2026 11:39:43 +0800 Subject: [PATCH] Detect the system on windows instead of reading Windows_NT ci/lib.sh works out OS only when the caller has not set one: if [[ ! ${OS-} ]]; then OS=$(os); fi Windows predefines OS as Windows_NT in every process environment, so on a windows shell that test always finds a value, os() is never called, and OS stays Windows_NT for the whole build. Every question the build then asks about the system gets an answer it does not understand: which bin scripts to fix up, whether to build packages, what the release archive is called. os() already handles this platform -- `cygwin* | mingw*` answers windows -- it just never gets the chance. Windows_NT is not a name this build knows, so it is not treated as one a caller chose. Measured on a windows shell, sourcing the file three ways: OS unset -> windows (was Windows_NT) OS=Windows_NT -> windows (was Windows_NT) OS=linux -> linux (unchanged) so an explicit choice still wins, which is the point of the check. Nothing changes anywhere else: no other platform sets OS, so the added test is never reached off windows. --- ci/lib.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ci/lib.sh b/ci/lib.sh index 7c1f0d9e5914..bd9c5c9c0c53 100755 --- a/ci/lib.sh +++ b/ci/lib.sh @@ -49,7 +49,10 @@ if [[ ! ${ARCH-} ]]; then export ARCH fi -if [[ ! ${OS-} ]]; then +# Windows predefines OS as Windows_NT for every process, so on a windows shell +# the check below would always find a value and never call os(). That is not a +# name this build knows, so it does not count as one the caller chose. +if [[ ! ${OS-} || ${OS-} == "Windows_NT" ]]; then OS=$(os) export OS fi