From 80e1d243e641b8cf30868ac4a81b367e266b2bc8 Mon Sep 17 00:00:00 2001 From: Paulo Gomes Date: Tue, 8 Feb 2022 10:51:20 +0000 Subject: [PATCH] Upgrade to libgit2-1.1.1-6 Signed-off-by: Paulo Gomes --- .github/workflows/e2e.yaml | 6 +++++- Makefile | 7 ++++--- hack/install-libraries.sh | 27 +++++++++++++++++++++------ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 33ee1ca4..482e7cac 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -57,7 +57,11 @@ jobs: with: go-version: 1.17.x - name: Run tests - run: make test + run: | + mkdir tmp-download; cd tmp-download; go mod init go-download; + GOBIN="${GITHUB_WORKSPACE}/build/gobin" go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest + cd ..; rm -rf tmp-download + make test - name: Prepare id: prep run: | diff --git a/Makefile b/Makefile index 552007dd..b6f636bd 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ TAG ?= latest # Base image used to build the Go binary LIBGIT2_IMG ?= ghcr.io/fluxcd/golang-with-libgit2 -LIBGIT2_TAG ?= libgit2-1.1.1-4 +LIBGIT2_TAG ?= libgit2-1.1.1-6 # Allows for defining additional Docker buildx arguments, # e.g. '--push'. @@ -35,13 +35,14 @@ export LIBRARY_PATH=$(LIBGIT2_LIB_PATH) export CGO_CFLAGS=-I$(LIBGIT2_PATH)/include -I$(LIBGIT2_PATH)/include/openssl +# The pkg-config command will yield warning messages until libgit2 is downloaded. ifeq ($(shell uname -s),Darwin) -export CGO_LDFLAGS=$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs --static --cflags libssh2 openssl libgit2) +export CGO_LDFLAGS=$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs --static --cflags libssh2 openssl libgit2 2>/dev/null) GO_STATIC_FLAGS=-ldflags "-s -w" -tags 'netgo,osusergo,static_build' else export PKG_CONFIG_PATH:=$(PKG_CONFIG_PATH):$(LIBGIT2_LIB64_PATH)/pkgconfig export LIBRARY_PATH:=$(LIBRARY_PATH):$(LIBGIT2_LIB64_PATH) -export CGO_LDFLAGS=$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs --static --cflags libssh2 openssl libgit2) +export CGO_LDFLAGS=$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs --static --cflags libssh2 openssl libgit2 2>/dev/null) endif diff --git a/hack/install-libraries.sh b/hack/install-libraries.sh index cc5615c3..270ce191 100755 --- a/hack/install-libraries.sh +++ b/hack/install-libraries.sh @@ -47,22 +47,37 @@ function setup_current() { # For MacOS development environments, download the amd64 static libraries released from from golang-with-libgit2. #TODO: update URL with official URL + TAG: - curl -o output.tar.gz -LO "https://github.com/pjbgf/golang-with-libgit2/releases/download/1.1.1-6/darwin-libs.tar.gz" + curl -o output.tar.gz -LO "https://github.com/fluxcd/golang-with-libgit2/releases/download/${TAG}/darwin-libs.tar.gz" DIR=libgit2-darwin NEW_DIR="$(/bin/pwd)/build/libgit2/${TAG}" INSTALLED_DIR="/Users/runner/work/golang-with-libgit2/golang-with-libgit2/build/${DIR}-amd64" tar -xf output.tar.gz + rm output.tar.gz mv "${DIR}" "${TAG}" mv "${TAG}/" "./build/libgit2" - sed -i "" "s;-L/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/lib ;;g" "$(/bin/pwd)/build/libgit2/${TAG}/lib/pkgconfig/libgit2.pc" + LIBGIT2_SED="s;-L/Applications/Xcode_.* ;;g" + LIBGIT2PC="$(/bin/pwd)/build/libgit2/${TAG}/lib/pkgconfig/libgit2.pc" + # Some macOS users may override their sed with gsed. If gsed is the PATH, use that instead. + if command -v gsed &> /dev/null; then + # Removes abs path from build machine, and let iconv be resolved automatically by default search paths. + gsed -i "${LIBGIT2_SED}" "${LIBGIT2PC}" - # Update the prefix paths included in the .pc files. - # This will make it easier to update to the location in which they will be used. - # sed has a sight different behaviour in MacOS - find "${NEW_DIR}" -type f -name "*.pc" | xargs -I {} sed -i "" "s;${INSTALLED_DIR};${NEW_DIR};g" {} + # Update the prefix paths included in the .pc files. + # This will make it easier to update to the location in which they will be used. + # sed has a sight different behaviour in MacOS + find "${NEW_DIR}" -type f -name "*.pc" | xargs -I {} gsed -i "s;${INSTALLED_DIR};${NEW_DIR};g" {} + else + # Removes abs path from build machine, and let iconv be resolved automatically by default search paths. + sed -i "" "${LIBGIT2_SED}" "${LIBGIT2PC}" + + # Update the prefix paths included in the .pc files. + # This will make it easier to update to the location in which they will be used. + # sed has a sight different behaviour in MacOS + find "${NEW_DIR}" -type f -name "*.pc" | xargs -I {} sed -i "" "s;${INSTALLED_DIR};${NEW_DIR};g" {} + fi else # for linux development environments, use the static libraries from the official container images. DIR="x86_64-alpine-linux-musl"