Skip to content

Commit 80e1d24

Browse files
author
Paulo Gomes
committed
Upgrade to libgit2-1.1.1-6
Signed-off-by: Paulo Gomes <[email protected]>
1 parent c5e2e5e commit 80e1d24

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

.github/workflows/e2e.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ jobs:
5757
with:
5858
go-version: 1.17.x
5959
- name: Run tests
60-
run: make test
60+
run: |
61+
mkdir tmp-download; cd tmp-download; go mod init go-download;
62+
GOBIN="${GITHUB_WORKSPACE}/build/gobin" go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
63+
cd ..; rm -rf tmp-download
64+
make test
6165
- name: Prepare
6266
id: prep
6367
run: |

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ TAG ?= latest
44

55
# Base image used to build the Go binary
66
LIBGIT2_IMG ?= ghcr.io/fluxcd/golang-with-libgit2
7-
LIBGIT2_TAG ?= libgit2-1.1.1-4
7+
LIBGIT2_TAG ?= libgit2-1.1.1-6
88

99
# Allows for defining additional Docker buildx arguments,
1010
# e.g. '--push'.
@@ -35,13 +35,14 @@ export LIBRARY_PATH=$(LIBGIT2_LIB_PATH)
3535
export CGO_CFLAGS=-I$(LIBGIT2_PATH)/include -I$(LIBGIT2_PATH)/include/openssl
3636

3737

38+
# The pkg-config command will yield warning messages until libgit2 is downloaded.
3839
ifeq ($(shell uname -s),Darwin)
39-
export CGO_LDFLAGS=$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs --static --cflags libssh2 openssl libgit2)
40+
export CGO_LDFLAGS=$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs --static --cflags libssh2 openssl libgit2 2>/dev/null)
4041
GO_STATIC_FLAGS=-ldflags "-s -w" -tags 'netgo,osusergo,static_build'
4142
else
4243
export PKG_CONFIG_PATH:=$(PKG_CONFIG_PATH):$(LIBGIT2_LIB64_PATH)/pkgconfig
4344
export LIBRARY_PATH:=$(LIBRARY_PATH):$(LIBGIT2_LIB64_PATH)
44-
export CGO_LDFLAGS=$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs --static --cflags libssh2 openssl libgit2)
45+
export CGO_LDFLAGS=$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs --static --cflags libssh2 openssl libgit2 2>/dev/null)
4546
endif
4647

4748

hack/install-libraries.sh

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,37 @@ function setup_current() {
4747
# For MacOS development environments, download the amd64 static libraries released from from golang-with-libgit2.
4848

4949
#TODO: update URL with official URL + TAG:
50-
curl -o output.tar.gz -LO "https://github.com/pjbgf/golang-with-libgit2/releases/download/1.1.1-6/darwin-libs.tar.gz"
50+
curl -o output.tar.gz -LO "https://github.com/fluxcd/golang-with-libgit2/releases/download/${TAG}/darwin-libs.tar.gz"
5151

5252
DIR=libgit2-darwin
5353
NEW_DIR="$(/bin/pwd)/build/libgit2/${TAG}"
5454
INSTALLED_DIR="/Users/runner/work/golang-with-libgit2/golang-with-libgit2/build/${DIR}-amd64"
5555

5656
tar -xf output.tar.gz
57+
rm output.tar.gz
5758
mv "${DIR}" "${TAG}"
5859
mv "${TAG}/" "./build/libgit2"
5960

60-
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"
61-
62-
# Update the prefix paths included in the .pc files.
63-
# This will make it easier to update to the location in which they will be used.
64-
# sed has a sight different behaviour in MacOS
65-
find "${NEW_DIR}" -type f -name "*.pc" | xargs -I {} sed -i "" "s;${INSTALLED_DIR};${NEW_DIR};g" {}
61+
LIBGIT2_SED="s;-L/Applications/Xcode_.* ;;g"
62+
LIBGIT2PC="$(/bin/pwd)/build/libgit2/${TAG}/lib/pkgconfig/libgit2.pc"
63+
# Some macOS users may override their sed with gsed. If gsed is the PATH, use that instead.
64+
if command -v gsed &> /dev/null; then
65+
# Removes abs path from build machine, and let iconv be resolved automatically by default search paths.
66+
gsed -i "${LIBGIT2_SED}" "${LIBGIT2PC}"
67+
68+
# Update the prefix paths included in the .pc files.
69+
# This will make it easier to update to the location in which they will be used.
70+
# sed has a sight different behaviour in MacOS
71+
find "${NEW_DIR}" -type f -name "*.pc" | xargs -I {} gsed -i "s;${INSTALLED_DIR};${NEW_DIR};g" {}
72+
else
73+
# Removes abs path from build machine, and let iconv be resolved automatically by default search paths.
74+
sed -i "" "${LIBGIT2_SED}" "${LIBGIT2PC}"
75+
76+
# Update the prefix paths included in the .pc files.
77+
# This will make it easier to update to the location in which they will be used.
78+
# sed has a sight different behaviour in MacOS
79+
find "${NEW_DIR}" -type f -name "*.pc" | xargs -I {} sed -i "" "s;${INSTALLED_DIR};${NEW_DIR};g" {}
80+
fi
6681
else
6782
# for linux development environments, use the static libraries from the official container images.
6883
DIR="x86_64-alpine-linux-musl"

0 commit comments

Comments
 (0)