Makefile: Add update-libcalico target
Takes LIBCALICO_VERSION and LIBCALICO_REPO arguments (but defaults them
to sensible values)
@@ -110,6 +110,31 @@ vendor: glide.yaml
cd /go/src/$(PACKAGE_NAME) && \
glide install -strip-vendor'
+# Default the libcalico repo and version but allow them to be overridden
+LIBCALICO_REPO?=github.com/projectcalico/libcalico-go
+LIBCALICO_VERSION?=$(shell git ls-remote git@github.com:projectcalico/libcalico-go master 2>/dev/null | cut -f 1)
+
+## Update libcalico pin in glide.yaml
+update-libcalico:
+ @echo "Updating libcalico to $(LIBCALICO_VERSION) from $(LIBCALICO_REPO)"
+ @export OLD_VER=$$(grep --after 50 libcalico-go glide.yaml |grep --max-count=1 --only-matching --perl-regexp "version:\s*\K[\.0-9a-z]+") ;\
+ echo "Old version: $$OLD_VER";\
+ if [ $(LIBCALICO_VERSION) != $$OLD_VER ]; then \
+ sed -i "s/$$OLD_VER/$(LIBCALICO_VERSION)/" glide.yaml && \
+ docker run --rm -i \
+ -v $(CURDIR):/go/src/$(PACKAGE_NAME):rw $$EXTRA_DOCKER_BIND \
+ -v $(HOME)/.glide:/home/user/.glide:rw \
+ -e LOCAL_USER_ID=$(LOCAL_USER_ID) \
+ $(GO_BUILD_CONTAINER) /bin/sh -c ' \
+ cd /go/src/$(PACKAGE_NAME) && \
+ if [ $(LIBCALICO_REPO) != "github.com/projectcalico/libcalico-go" ]; then \
+ glide mirror set https://github.com/projectcalico/libcalico-go $(LIBCALICO_REPO) --vcs git; glide mirror list; \
+ fi;\
+ OUTPUT=`mktemp`;\
+ glide up --strip-vendor 2>&1 | tee $$OUTPUT; \
+ if ! grep "\[WARN\]" $$OUTPUT; then true; else false; fi;'; \
+ fi
+
# The supported different binary names. For each, ensure that an OS and ARCH is set
bin/calicoctl-%-amd64: ARCH=amd64
bin/calicoctl-%-arm64: ARCH=arm64
