From 0e0d82ad265012fd1f9f631318f93cb304303c9b 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 | 6 ++++++ etc/defaults.conf | 11 +++++++++++ xbps-src | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/common/environment/build-style/go.sh b/common/environment/build-style/go.sh index 68f88c6dbee8f..2773c608d59ec 100644 --- a/common/environment/build-style/go.sh +++ b/common/environment/build-style/go.sh @@ -17,6 +17,10 @@ else fi fi +if [ "$XBPS_GOPROXY" = direct ]; then + hostmakedepends+=" git mercurial" +fi + case "$XBPS_TARGET_MACHINE" in aarch64*) export GOARCH=arm64;; armv5*) export GOARCH=arm; export GOARM=5;; @@ -39,6 +43,8 @@ export CGO_CXXFLAGS="$CXXFLAGS" export CGO_LDFLAGS="$LDFLAGS" export CGO_ENABLED="${CGO_ENABLED:-1}" export GO111MODULE=auto +export GOPROXY="$XBPS_GOPROXY" +export GOSUMDB="$XBPS_GOSUMDB" case "$XBPS_TARGET_MACHINE" in *-musl) export GOCACHE="${XBPS_HOSTDIR}/gocache-muslc" ;; *) export GOCACHE="${XBPS_HOSTDIR}/gocache-glibc" ;; diff --git a/etc/defaults.conf b/etc/defaults.conf index f70e4ea3d0067..2a8cf14d6adac 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 cdb5f8c6d643e..96c7562a57987 100755 --- a/xbps-src +++ b/xbps-src @@ -665,7 +665,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"