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
This commit is contained in:
Christian Schwarz 2017-11-19 12:32:25 +01:00
parent e8facfe9fa
commit 2716c75ad5
5 changed files with 17 additions and 39 deletions

View File

@ -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 .DEFAULT_GOAL := build
ROOT := github.com/zrepl/zrepl 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) GO_BUILD := go build -ldflags $(GO_LDFLAGS)
vendordeps:
dep ensure -v -vendor-only
generate: #not part of the build, must do that manually generate: #not part of the build, must do that manually
@for pkg in $(_TESTPKGS); do\ @for pkg in $(_TESTPKGS); do\
go generate "$$pkg" || exit 1; \ go generate "$$pkg" || exit 1; \
done; done;
build: build:
$(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl" @echo "INFO: In case of missing dependencies, run 'make vendordeps'"
$(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl"
test: test:
@for pkg in $(_TESTPKGS); do \ @for pkg in $(_TESTPKGS); do \
@ -64,6 +68,7 @@ docs-clean:
BUILDDIR=../artifacts/docs BUILDDIR=../artifacts/docs
release-bins: $(ARTIFACTDIR) vet test 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=linux GOARCH=amd64 $(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl-linux-amd64"
GOOS=freebsd GOARCH=amd64 $(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl-freebsd-amd64" GOOS=freebsd GOARCH=amd64 $(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl-freebsd-amd64"

View File

@ -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 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. * Ship a service manager file and _please_ try to upstream it to this repository.
* Use `make release ZREPL_VERSION='mydistro-1.2.3_1'` * 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. * Make sure you are informed about new zrepl versions, e.g. by subscribing to GitHub's release RSS feed.
## Developer Documentation ## 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 ### Overall Architecture

View File

@ -1,20 +1,16 @@
FROM golang:latest FROM golang:latest
# Docs deps
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
python3-pip python3-pip
ADD lazy.sh /tmp/lazy.sh ADD lazy.sh /tmp/lazy.sh
RUN /tmp/lazy.sh builddep
ADD docs/requirements.txt /tmp/requirements.txt ADD docs/requirements.txt /tmp/requirements.txt
ENV ZREPL_LAZY_DOCS_REQPATH=/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 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 WORKDIR /go/src/github.com/zrepl/zrepl

View File

@ -57,7 +57,7 @@ and serves as a reference for build dependencies and procedure:
sudo docker run -it --rm \ sudo docker run -it --rm \
-v "${PWD}:/zrepl" \ -v "${PWD}:/zrepl" \
--user "$(id -u):$(id -g)" \ --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``: 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" git clone https://github.com/zrepl/zrepl.git "${GOPATH}/src/github.com/zrepl/zrepl"
cd "${GOPATH}/src/github.com/zrepl/zrepl" cd "${GOPATH}/src/github.com/zrepl/zrepl"
./lazy.sh devsetup ./lazy.sh devsetup
make release make vendordeps release
Build results are located in the ``artifacts/`` directory. Build results are located in the ``artifacts/`` directory.

29
lazy.sh
View File

@ -13,7 +13,7 @@ step() {
echo "${bold}$1${normal}" 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 step "go binary not installed or not in \$PATH" 1>&2
exit 1 exit 1
fi fi
@ -25,23 +25,6 @@ fi
CHECKOUTPATH="${GOPATH}/src/github.com/zrepl/zrepl" 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() { builddep() {
step "Install build depdencies using 'go get' to \$GOPATH/bin" step "Install build depdencies using 'go get' to \$GOPATH/bin"
go get -u golang.org/x/tools/cmd/stringer go get -u golang.org/x/tools/cmd/stringer
@ -75,16 +58,15 @@ release() {
make release make release
} }
# precheck
for cmd in "$@"; do for cmd in "$@"; do
case "$cmd" in case "$cmd" in
clone|builddep|godep|docdep|release_bins|docs) builddep|godep|docdep|release_bins|docs)
eval $cmd
continue continue
;; ;;
devsetup) devsetup)
step "Installing development dependencies" step "Installing development dependencies"
builddep builddep
godep
docdep docdep
step "Development dependencies installed" step "Development dependencies installed"
continue continue
@ -96,8 +78,3 @@ for cmd in "$@"; do
esac esac
done done
for cmd in "$@"; do
step "Step ${cmd}"
eval $cmd
done