@@ -23,54 +23,3 @@ set -euxo pipefail
2323# for traversing into ascending dirs, therefore we copy those contents here:
2424mkdir -p controllers/testdata/crd
2525cp config/crd/bases/* .yaml controllers/testdata/crd/
26-
27- # libgit2, cmake and pkg-config are requirements to support libgit2.
28- LIBGIT2_TAG=" ${LIBGIT2_TAG:- v0.4.0} "
29-
30- # Avoid updating apt get and installing dependencies, if they are already in place.
31- if (! command -v cmake & > /dev/null) || (! command -v pkg-config & > /dev/null) then
32- apt-get update && apt-get install -y cmake pkg-config
33- fi
34-
35- export TARGET_DIR=" $( /bin/pwd) /build/libgit2/${LIBGIT2_TAG} "
36-
37- # For most cases, libgit2 will already be present.
38- # The exception being at the oss-fuzz integration.
39- if [ ! -d " ${TARGET_DIR} " ]; then
40- curl --connect-timeout 2 --retry 3 --retry-delay 1 --retry-max-time 30 \
41- -o output.tar.gz -LO " https://github.com/fluxcd/golang-with-libgit2/releases/download/${LIBGIT2_TAG} /linux-$( uname -m) -libgit2-only.tar.gz"
42-
43- DIR=linux-libgit2-only
44- NEW_DIR=" $( /bin/pwd) /build/libgit2/${LIBGIT2_TAG} "
45- INSTALLED_DIR=" /home/runner/work/golang-with-libgit2/golang-with-libgit2/build/${DIR} "
46-
47- mkdir -p ./build/libgit2
48-
49- tar -xf output.tar.gz
50- rm output.tar.gz
51- mv " ${DIR} " " ${LIBGIT2_TAG} "
52- mv " ${LIBGIT2_TAG} /" " ./build/libgit2"
53-
54- # Update the prefix paths included in the .pc files.
55- # This will make it easier to update to the location in which they will be used.
56- find " ${NEW_DIR} " -type f -name " *.pc" | xargs -I {} sed -i " s;${INSTALLED_DIR} ;${NEW_DIR} ;g" {}
57- fi
58-
59- export CGO_ENABLED=1
60- export LIBRARY_PATH=" ${TARGET_DIR} /lib"
61- export PKG_CONFIG_PATH=" ${TARGET_DIR} /lib/pkgconfig"
62- export CGO_CFLAGS=" -I${TARGET_DIR} /include"
63- export CGO_LDFLAGS=" $( pkg-config --libs --static --cflags libgit2) "
64-
65- # Temporary hack whilst libgit2 is still in use.
66- # Enables the fuzzing compilation to link libgit2.
67- #
68- # After building the fuzzers, the value of
69- # LIB_FUZZING_ENGINE is reset to what it was before
70- # it to avoid side effects onto other repositories.
71- #
72- # For context refer to:
73- # https://github.com/google/oss-fuzz/pull/9063
74- export PRE_LIB_FUZZING_ENGINE=" ${LIB_FUZZING_ENGINE} "
75-
76- export LIB_FUZZING_ENGINE=" ${LIB_FUZZING_ENGINE} -Wl,--start-group ${TARGET_DIR} /lib/libgit2.a"
0 commit comments