From 2716c75ad543441a0cc1b1f0cb22aca16ae2d535 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Sun, 19 Nov 2017 12:32:25 +0100 Subject: [PATCH] build: target for go library dependencies Didn't notice it because vendor/ was already populated on my dev machine, but did notice it in Docker build. Docker build now consumes devsetup like regular user, so this should catch future problems. Remove remaining curl|shit functionality from lazy.sh (no checkout logic needed anymore). refs #35 --- Makefile | 9 +++++++-- README.md | 4 ++-- build.Dockerfile | 10 +++------- docs/installation.rst | 4 ++-- lazy.sh | 29 +++-------------------------- 5 files changed, 17 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index 28bc59b..3fa14ca 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: generate build test vet cover release docs docs-clean clean release-bins +.PHONY: generate build test vet cover release docs docs-clean clean release-bins vendordeps .DEFAULT_GOAL := build ROOT := github.com/zrepl/zrepl @@ -18,13 +18,17 @@ GO_LDFLAGS := "-X github.com/zrepl/zrepl/cmd.zreplVersion=$(ZREPL_VERSION)" GO_BUILD := go build -ldflags $(GO_LDFLAGS) +vendordeps: + dep ensure -v -vendor-only + generate: #not part of the build, must do that manually @for pkg in $(_TESTPKGS); do\ go generate "$$pkg" || exit 1; \ done; build: - $(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl" + @echo "INFO: In case of missing dependencies, run 'make vendordeps'" + $(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl" test: @for pkg in $(_TESTPKGS); do \ @@ -64,6 +68,7 @@ docs-clean: BUILDDIR=../artifacts/docs release-bins: $(ARTIFACTDIR) vet test + @echo "INFO: In case of missing dependencies, run 'make vendordeps'" GOOS=linux GOARCH=amd64 $(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl-linux-amd64" GOOS=freebsd GOARCH=amd64 $(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl-freebsd-amd64" diff --git a/README.md b/README.md index 5c73709..2a51134 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,12 @@ Check out the *Coding Workflow* section below for details. * Ship a default config that adheres to your distro's `hier` and logging system. * Ship a service manager file and _please_ try to upstream it to this repository. * Use `make release ZREPL_VERSION='mydistro-1.2.3_1'` - * Your distro's name and any versioning supplemental to zrepl's (e.g. package revesion) should be in this string + * Your distro's name and any versioning supplemental to zrepl's (e.g. package revision) should be in this string * Make sure you are informed about new zrepl versions, e.g. by subscribing to GitHub's release RSS feed. ## Developer Documentation -First, use `./lazy.sh devesetup` to install build dependencies and read `docs/installation.rst -> Compiling from Source`. +First, use `./lazy.sh devsetup` to install build dependencies and read `docs/installation.rst -> Compiling from Source`. ### Overall Architecture diff --git a/build.Dockerfile b/build.Dockerfile index d35512c..f377ee6 100644 --- a/build.Dockerfile +++ b/build.Dockerfile @@ -1,20 +1,16 @@ FROM golang:latest -# Docs deps RUN apt-get update && apt-get install -y \ python3-pip ADD lazy.sh /tmp/lazy.sh - -RUN /tmp/lazy.sh builddep - ADD docs/requirements.txt /tmp/requirements.txt ENV ZREPL_LAZY_DOCS_REQPATH=/tmp/requirements.txt -RUN /tmp/lazy.sh docdep +RUN /tmp/lazy.sh devsetup +# prepare volume mount of git checkout to /zrepl RUN mkdir -p /go/src/github.com/zrepl -RUN ln -sf /zrepl /go/src/github.com/zrepl/zrepl - +RUN chmod -R 0777 /go WORKDIR /go/src/github.com/zrepl/zrepl diff --git a/docs/installation.rst b/docs/installation.rst index 6d87610..9f5787e 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -57,7 +57,7 @@ and serves as a reference for build dependencies and procedure: sudo docker run -it --rm \ -v "${PWD}:/zrepl" \ --user "$(id -u):$(id -g)" \ - zrepl_build make release + zrepl_build make vendordeps release Alternatively, you can install build dependencies on your local system and then build in your ``$GOPATH``: @@ -67,7 +67,7 @@ Alternatively, you can install build dependencies on your local system and then git clone https://github.com/zrepl/zrepl.git "${GOPATH}/src/github.com/zrepl/zrepl" cd "${GOPATH}/src/github.com/zrepl/zrepl" ./lazy.sh devsetup - make release + make vendordeps release Build results are located in the ``artifacts/`` directory. diff --git a/lazy.sh b/lazy.sh index 8000ad9..8d785cb 100755 --- a/lazy.sh +++ b/lazy.sh @@ -13,7 +13,7 @@ step() { echo "${bold}$1${normal}" } -if ! type go; then +if ! type go >/dev/null; then step "go binary not installed or not in \$PATH" 1>&2 exit 1 fi @@ -25,23 +25,6 @@ fi CHECKOUTPATH="${GOPATH}/src/github.com/zrepl/zrepl" -clone() { - step "Checkout sources to \$GOPATH/github.com/zrepl/zrepl" - if [ -e "$CHECKOUTPATH" ]; then - echo "${CHECKOUTPATH} already exists" - if [ ! -d "$CHECKOUTPATH" ]; then - echo "${CHECKOUTPATH} is not a directory, aborting" 1>&2 - else - cd "$CHECKOUTPATH" - fi - else - mkdir -p "$GOPATH/src/github.com/zrepl" - cd "$GOPATH/src/github.com/zrepl" - git clone https://github.com/zrepl/zrepl.git - cd zrepl - fi -} - builddep() { step "Install build depdencies using 'go get' to \$GOPATH/bin" go get -u golang.org/x/tools/cmd/stringer @@ -75,16 +58,15 @@ release() { make release } -# precheck for cmd in "$@"; do case "$cmd" in - clone|builddep|godep|docdep|release_bins|docs) + builddep|godep|docdep|release_bins|docs) + eval $cmd continue ;; devsetup) step "Installing development dependencies" builddep - godep docdep step "Development dependencies installed" continue @@ -96,8 +78,3 @@ for cmd in "$@"; do esac done -for cmd in "$@"; do - step "Step ${cmd}" - eval $cmd -done -