From 72120d7a2c79e284762d107993303150e755feb9 Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean <97607754+ddevsr@users.noreply.github.com> Date: Wed, 8 Jan 2025 17:37:15 +0700 Subject: [PATCH] fix(static): check command go and xcaddy in build-static.sh (#1298) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kévin Dunglas --- build-static.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build-static.sh b/build-static.sh index 107eacce1..dbb487db8 100755 --- a/build-static.sh +++ b/build-static.sh @@ -137,8 +137,15 @@ else ${spcCommand} build --debug --enable-zts --build-embed ${extraOpts} "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}" fi -if ! type "xcaddy" >/dev/null 2>&1; then +if ! type "go" >/dev/null 2>&1; then + echo "The \"go\" command must be installed." + exit 1 +fi + +XCADDY_COMMAND="xcaddy" +if ! type "$XCADDY_COMMAND" >/dev/null 2>&1; then go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest + XCADDY_COMMAND="$(go env GOPATH)/bin/xcaddy" fi curlGitHubHeaders=(--header "X-GitHub-Api-Version: 2022-11-28") @@ -296,7 +303,7 @@ cd caddy/ CGO_ENABLED=1 \ XCADDY_GO_BUILD_FLAGS="-buildmode=pie -tags cgo,netgo,osusergo,static_build,nobadger,nomysql,nopgx -ldflags \"-linkmode=external -extldflags '-static-pie ${extraExtldflags}' ${extraLdflags} -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ${FRANKENPHP_VERSION} PHP ${LIBPHP_VERSION} Caddy'\"" \ XCADDY_DEBUG="${XCADDY_DEBUG}" \ - xcaddy build \ + ${XCADDY_COMMAND} build \ --output "../dist/${bin}" \ ${XCADDY_ARGS} \ --with github.com/dunglas/frankenphp=.. \