From 234a327a03808476156909b2dae0c29e056aaead Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Sun, 23 Jun 2019 12:10:52 +0200 Subject: [PATCH] build: Linux arm64 support * protoc zip fetching * Makefile: * GOOS and GOARCH * run vet on all targets Note: freebsd/arm64 is apparently not supported fixes #180 refs #181 --- Makefile | 19 +++++++++++++------ build.Dockerfile | 5 ++--- build.installprotoc.bash | 25 +++++++++++++++++++++++++ docs/changelog.rst | 5 +++++ 4 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 build.installprotoc.bash diff --git a/Makefile b/Makefile index dddfd69..e5e2e42 100644 --- a/Makefile +++ b/Makefile @@ -16,8 +16,10 @@ GO_LDFLAGS := "-X github.com/zrepl/zrepl/version.zreplVersion=$(_ZREPL_VERSION)" GO_BUILD := go build -ldflags $(GO_LDFLAGS) +# keep in sync with vet target RELEASE_BINS := $(ARTIFACTDIR)/zrepl-freebsd-amd64 RELEASE_BINS += $(ARTIFACTDIR)/zrepl-linux-amd64 +RELEASE_BINS += $(ARTIFACTDIR)/zrepl-linux-arm64 RELEASE_BINS += $(ARTIFACTDIR)/zrepl-darwin-amd64 RELEASE_NOARCH := $(ARTIFACTDIR)/zrepl-noarch.tar @@ -42,12 +44,17 @@ build: test: go test ./... + # TODO compile the tests for each supported platform + # but `go test -c ./...` is not supported vet: + go vet ./... # for each supported platform to cover conditional compilation - GOOS=linux go vet ./... - GOOS=darwin go vet ./... - GOOS=freebsd go vet ./... + # (keep in sync with RELEASE_BINS) + GOOS=freebsd GOARCH=amd64 go vet ./... + GOOS=linux GOARCH=amd64 go vet ./... + GOOS=linux GOARCH=arm64 go vet ./... + GOOS=darwin GOARCH=amd64 go vet ./... $(ARTIFACTDIR): mkdir -p "$@" @@ -71,12 +78,12 @@ docs-clean: clean \ BUILDDIR=../artifacts/docs - .PHONY: $(RELEASE_BINS) # TODO: two wildcards possible -$(RELEASE_BINS): $(ARTIFACTDIR)/zrepl-%-amd64: generate $(ARTIFACTDIR) vet test lint +$(RELEASE_BINS): $(ARTIFACTDIR)/zrepl-%: generate $(ARTIFACTDIR) vet test lint @echo "INFO: In case of missing dependencies, run 'make vendordeps'" - GOOS=$* GOARCH=amd64 $(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl-$*-amd64" + STEM=$*; GOOS="$${STEM%%-*}"; GOARCH="$${STEM##*-}"; export GOOS GOARCH; \ + $(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl-$$GOOS-$$GOARCH" $(RELEASE_NOARCH): docs $(ARTIFACTDIR)/bash_completion $(ARTIFACTDIR)/go_version.txt tar --mtime='1970-01-01' --sort=name \ diff --git a/build.Dockerfile b/build.Dockerfile index 95dcd66..4e127ea 100644 --- a/build.Dockerfile +++ b/build.Dockerfile @@ -4,9 +4,8 @@ RUN apt-get update && apt-get install -y \ python3-pip \ unzip -RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip -RUN echo "6003de742ea3fcf703cfec1cd4a3380fd143081a2eb0e559065563496af27807 protoc-3.6.1-linux-x86_64.zip" | sha256sum -c -RUN unzip -d /usr protoc-3.6.1-linux-x86_64.zip +ADD build.installprotoc.bash ./ +RUN bash build.installprotoc.bash ADD lazy.sh /tmp/lazy.sh ADD docs/requirements.txt /tmp/requirements.txt diff --git a/build.installprotoc.bash b/build.installprotoc.bash new file mode 100644 index 0000000..c39c74a --- /dev/null +++ b/build.installprotoc.bash @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail +set -x + +MACH=$(uname -m) +MACH="${MACH/aarch64/aarch_64}" + +VERSION=3.6.1 +FILENAME=protoc-"$VERSION"-linux-"$MACH".zip + +if [ -e "$FILENAME" ]; then + echo "$FILENAME" already exists 1>&2 + exit 1 +fi + +wget https://github.com/protocolbuffers/protobuf/releases/download/v"$VERSION"/"$FILENAME" + +stat "$FILENAME" + +sha256sum -c --ignore-missing <