From 53730eed4f710a87877ca925f4af1f175ba5f5c6 Mon Sep 17 00:00:00 2001 From: hazen2215 Date: Sat, 29 Apr 2023 17:33:50 +0900 Subject: [PATCH] xbps-src: optionally set GOPROXY, GOSUMDB when building go packages. --- common/environment/build-style/go.sh | 8 ++++++-- etc/defaults.conf | 11 +++++++++++ xbps-src | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/common/environment/build-style/go.sh b/common/environment/build-style/go.sh index 223bba83ff11b4..7efc396fff9454 100644 --- a/common/environment/build-style/go.sh +++ b/common/environment/build-style/go.sh @@ -17,6 +17,10 @@ else fi fi +case "$XBPS_GOPROXY" in + *direct*) hostmakedepends+=" git mercurial" ;; +esac + case "$XBPS_TARGET_MACHINE" in aarch64*) export GOARCH=arm64;; armv5*) export GOARCH=arm; export GOARM=5;; @@ -41,8 +45,8 @@ export CGO_LDFLAGS="$LDFLAGS" export CGO_ENABLED="${CGO_ENABLED:-1}" export GO111MODULE=auto export GOTOOLCHAIN="${GOTOOLCHAIN:-local}" -export GOPROXY="https://proxy.golang.org,direct" -export GOSUMDB="sum.golang.org" +export GOPROXY="${XBPS_GOPROXY:-https://proxy.golang.org,direct}" +export GOSUMDB="${XBPS_GOSUMDB:-sum.golang.org}" case "$XBPS_TARGET_MACHINE" in *-musl) export GOCACHE="${XBPS_HOSTDIR}/gocache-muslc" ;; diff --git a/etc/defaults.conf b/etc/defaults.conf index f70e4ea3d0067e..2a8cf14d6adacf 100644 --- a/etc/defaults.conf +++ b/etc/defaults.conf @@ -165,3 +165,14 @@ XBPS_SUCMD="sudo /bin/sh -c" # This can also be set or exported as a regular environment variable. # #XBPS_UPDATE_CHECK_VERBOSE=yes + +# [OPTIONAL] +# Set the environment variable 'GOPROXY' when building go packages. +# When set to 'direct', will download modules directly from source repositories +#XBPS_GOPROXY=direct + +# [OPTIONAL] +# Set the environment variable 'GOSUMDB' when building go packages. +# When set to 'off', will disable querying for module checksum which is +# undefined in go.sum. +#XBPS_GOSUMDB=off diff --git a/xbps-src b/xbps-src index 97ca0bc5564523..f0d4dc31f2fe42 100755 --- a/xbps-src +++ b/xbps-src @@ -692,7 +692,7 @@ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \ XBPS_LIBEXECDIR XBPS_DISTDIR XBPS_DISTFILES_MIRROR XBPS_ALLOW_RESTRICTED \ XBPS_USE_GIT_COMMIT_DATE XBPS_PKG_COMPTYPE XBPS_REPO_COMPTYPE \ XBPS_BUILDHELPERDIR XBPS_USE_BUILD_MTIME XBPS_BUILD_ENVIRONMENT \ - XBPS_PRESERVE_PKGS XBPS_IGNORE_BROKENNESS + XBPS_PRESERVE_PKGS XBPS_IGNORE_BROKENNESS XBPS_GOPROXY XBPS_GOSUMDB for i in REPOSITORY DESTDIR BUILDDIR SRCDISTDIR; do eval val="\$XBPS_$i"