From 8f3a894c3200247211dff74ea108ce6f7063d359 Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Tue, 15 May 2018 13:33:04 +0200 Subject: [PATCH 1/6] Allows run builds or tests with local vendor --- Makefile | 1 + build/bin/Makefile | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 806bbaad..57743c0a 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ BIN_IMAGE = blockbook-build DEB_IMAGE = blockbook-build-deb PACKAGER = $(shell id -u):$(shell id -g) NO_CACHE = false +UPDATE_VENDOR = 1 .PHONY: build build-debug test deb diff --git a/build/bin/Makefile b/build/bin/Makefile index 31e683ef..4461abb7 100644 --- a/build/bin/Makefile +++ b/build/bin/Makefile @@ -1,3 +1,5 @@ +UPDATE_VENDOR=1 + build: prepare-sources cd $(GOPATH)/src/blockbook && go build -o $(CURDIR)/blockbook -ldflags="-s -w" cp $(CURDIR)/blockbook /out/blockbook @@ -19,5 +21,12 @@ test-all: prepare-sources prepare-sources: @ [ -n "`ls /src 2> /dev/null`" ] || (echo "/src doesn't exist or is empty" 1>&2 && exit 1) cp -r /src $(GOPATH)/src/blockbook - rm -rf $(GOPATH)/src/blockbook/vendor - cd $(GOPATH)/src/blockbook && dep ensure -vendor-only + $(MAKE) prepare-vendor + +prepare-vendor: + @ if [ "$(UPDATE_VENDOR)" -eq 1 ]; then \ + echo "Updating vendor"; \ + rm -rf $(GOPATH)/src/blockbook/vendor && cd $(GOPATH)/src/blockbook && dep ensure -vendor-only ; \ + else \ + echo "Update of vendor not demanded, keeping version from src" ; \ + fi From bcb9c9459e9037231244bb98b56d3fe5e22fc5de Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Tue, 15 May 2018 14:49:40 +0200 Subject: [PATCH 2/6] Fixed passing of env variable --- Makefile | 10 +++++----- build/bin/Makefile | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 57743c0a..5cc443d7 100644 --- a/Makefile +++ b/Makefile @@ -7,19 +7,19 @@ UPDATE_VENDOR = 1 .PHONY: build build-debug test deb build: .bin-image - docker run -t --rm -e PACKAGER=$(PACKAGER) -v $(CURDIR):/src -v $(CURDIR)/build:/out $(BIN_IMAGE) make build + docker run -t --rm -e PACKAGER=$(PACKAGER) -e UPDATE_VENDOR=$(UPDATE_VENDOR) -v $(CURDIR):/src -v $(CURDIR)/build:/out $(BIN_IMAGE) make build build-debug: .bin-image - docker run -t --rm -e PACKAGER=$(PACKAGER) -v $(CURDIR):/src -v $(CURDIR)/build:/out $(BIN_IMAGE) make build-debug + docker run -t --rm -e PACKAGER=$(PACKAGER) -e UPDATE_VENDOR=$(UPDATE_VENDOR) -v $(CURDIR):/src -v $(CURDIR)/build:/out $(BIN_IMAGE) make build-debug test: .bin-image - docker run -t --rm -e PACKAGER=$(PACKAGER) -v $(CURDIR):/src $(BIN_IMAGE) make test + docker run -t --rm -e PACKAGER=$(PACKAGER) -e UPDATE_VENDOR=$(UPDATE_VENDOR) -v $(CURDIR):/src $(BIN_IMAGE) make test test-all: .bin-image - docker run -t --rm -e PACKAGER=$(PACKAGER) -v $(CURDIR):/src $(BIN_IMAGE) make test-all + docker run -t --rm -e PACKAGER=$(PACKAGER) -e UPDATE_VENDOR=$(UPDATE_VENDOR) -v $(CURDIR):/src $(BIN_IMAGE) make test-all deb: .deb-image - docker run -t --rm -e PACKAGER=$(PACKAGER) -v $(CURDIR):/src -v $(CURDIR)/build:/out $(DEB_IMAGE) + docker run -t --rm -e PACKAGER=$(PACKAGER) -e UPDATE_VENDOR=$(UPDATE_VENDOR) -v $(CURDIR):/src -v $(CURDIR)/build:/out $(DEB_IMAGE) build-images: rm -f .bin-image .deb-image diff --git a/build/bin/Makefile b/build/bin/Makefile index 4461abb7..50c40414 100644 --- a/build/bin/Makefile +++ b/build/bin/Makefile @@ -1,4 +1,4 @@ -UPDATE_VENDOR=1 +UPDATE_VENDOR ?= 1 build: prepare-sources cd $(GOPATH)/src/blockbook && go build -o $(CURDIR)/blockbook -ldflags="-s -w" From e572ce7f7fd7643e942ced336b9f968c3afa31b0 Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Tue, 15 May 2018 16:33:35 +0200 Subject: [PATCH 3/6] Make executes all tests in repo --- build/bin/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/build/bin/Makefile b/build/bin/Makefile index 50c40414..d81d9314 100644 --- a/build/bin/Makefile +++ b/build/bin/Makefile @@ -11,12 +11,10 @@ build-debug: prepare-sources chown $(PACKAGER) /out/blockbook test: prepare-sources - #cd $(GOPATH)/src/blockbook && go test -short ./... # FIXME - cd $(GOPATH)/src/blockbook && go test -short ./bchain/coins/btc ./bchain/coins/bch ./bchain/coins/eth ./bchain/coins/zec + cd $(GOPATH)/src/blockbook && go test -short ./... test-all: prepare-sources - # cd $(GOPATH)/src/blockbook && go test ./... # FIXME - cd $(GOPATH)/src/blockbook && go test ./bchain/coins/btc ./bchain/coins/bch ./bchain/coins/eth ./bchain/coins/zec + cd $(GOPATH)/src/blockbook && go test ./... prepare-sources: @ [ -n "`ls /src 2> /dev/null`" ] || (echo "/src doesn't exist or is empty" 1>&2 && exit 1) From 85c0ceed684351eb970ed23cff6d50b02fd10aae Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Tue, 15 May 2018 16:34:27 +0200 Subject: [PATCH 4/6] Added dependency of deb-image build on bin-image --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5cc443d7..b4ece5dc 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ build-images: docker build --no-cache=$(NO_CACHE) -t $(BIN_IMAGE) build/bin @ docker images -q $(BIN_IMAGE) > $@ -.deb-image: +.deb-image: .bin-image docker build --no-cache=$(NO_CACHE) -t $(DEB_IMAGE) build/deb @ docker images -q $(DEB_IMAGE) > $@ From 2cb257b0bd3c6050a18e2d3fb2a33ca157691193 Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Tue, 15 May 2018 17:22:02 +0200 Subject: [PATCH 5/6] Added default shell /bin/false for all users --- build/deb/debian/blockbook-bch-testnet.postinst | 2 +- build/deb/debian/blockbook-bch.postinst | 2 +- build/deb/debian/blockbook-btc-testnet.postinst | 2 +- build/deb/debian/blockbook-btc.postinst | 2 +- build/deb/debian/blockbook-zec.postinst | 2 +- contrib/backends/bcash/debian/bcash-bch.postinst | 2 +- contrib/backends/bcash/debian/bcash-testnet.postinst | 2 +- contrib/backends/bitcoin/debian/bitcoin-btc.postinst | 2 +- contrib/backends/bitcoin/debian/bitcoin-testnet.postinst | 2 +- contrib/backends/zcash/debian/zcash-zec.postinst | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/build/deb/debian/blockbook-bch-testnet.postinst b/build/deb/debian/blockbook-bch-testnet.postinst index aa28cbbe..daa1910e 100644 --- a/build/deb/debian/blockbook-bch-testnet.postinst +++ b/build/deb/debian/blockbook-bch-testnet.postinst @@ -6,7 +6,7 @@ case "$1" in configure) if ! id -u blockbook-bch &> /dev/null then - useradd --system -M -U blockbook-bch + useradd --system -M -U blockbook-bch -s /bin/false fi for dir in /opt/coins/data/bch-testnet/blockbook /opt/coins/blockbook/bch-testnet/logs diff --git a/build/deb/debian/blockbook-bch.postinst b/build/deb/debian/blockbook-bch.postinst index ee286500..ebc552d1 100644 --- a/build/deb/debian/blockbook-bch.postinst +++ b/build/deb/debian/blockbook-bch.postinst @@ -6,7 +6,7 @@ case "$1" in configure) if ! id -u blockbook-bch &> /dev/null then - useradd --system -M -U blockbook-bch + useradd --system -M -U blockbook-bch -s /bin/false fi for dir in /opt/coins/data/bch/blockbook /opt/coins/blockbook/bch/logs diff --git a/build/deb/debian/blockbook-btc-testnet.postinst b/build/deb/debian/blockbook-btc-testnet.postinst index c8365a81..e5097cb5 100644 --- a/build/deb/debian/blockbook-btc-testnet.postinst +++ b/build/deb/debian/blockbook-btc-testnet.postinst @@ -6,7 +6,7 @@ case "$1" in configure) if ! id -u blockbook-btc &> /dev/null then - useradd --system -M -U blockbook-btc + useradd --system -M -U blockbook-btc -s /bin/false fi for dir in /opt/coins/data/btc-testnet/blockbook /opt/coins/blockbook/btc-testnet/logs diff --git a/build/deb/debian/blockbook-btc.postinst b/build/deb/debian/blockbook-btc.postinst index 9b839b8e..87dcf12a 100644 --- a/build/deb/debian/blockbook-btc.postinst +++ b/build/deb/debian/blockbook-btc.postinst @@ -6,7 +6,7 @@ case "$1" in configure) if ! id -u blockbook-btc &> /dev/null then - useradd --system -M -U blockbook-btc + useradd --system -M -U blockbook-btc -s /bin/false fi for dir in /opt/coins/data/btc/blockbook /opt/coins/blockbook/btc/logs diff --git a/build/deb/debian/blockbook-zec.postinst b/build/deb/debian/blockbook-zec.postinst index 668103af..e3018848 100644 --- a/build/deb/debian/blockbook-zec.postinst +++ b/build/deb/debian/blockbook-zec.postinst @@ -6,7 +6,7 @@ case "$1" in configure) if ! id -u blockbook-zec &> /dev/null then - useradd --system -M -U blockbook-zec + useradd --system -M -U blockbook-zec -s /bin/false fi for dir in /opt/coins/data/zec/blockbook /opt/coins/blockbook/zec/logs diff --git a/contrib/backends/bcash/debian/bcash-bch.postinst b/contrib/backends/bcash/debian/bcash-bch.postinst index 82a9b058..5c0a6b46 100644 --- a/contrib/backends/bcash/debian/bcash-bch.postinst +++ b/contrib/backends/bcash/debian/bcash-bch.postinst @@ -6,7 +6,7 @@ case "$1" in configure) if ! id -u bcash &> /dev/null then - useradd --system -M -U bcash + useradd --system -M -U bcash -s /bin/false fi if [ "$(stat -c '%U' /opt/coins/data/bch/bitcoin)" != "bcash" ] diff --git a/contrib/backends/bcash/debian/bcash-testnet.postinst b/contrib/backends/bcash/debian/bcash-testnet.postinst index 8692e3f4..6cf4fdff 100644 --- a/contrib/backends/bcash/debian/bcash-testnet.postinst +++ b/contrib/backends/bcash/debian/bcash-testnet.postinst @@ -6,7 +6,7 @@ case "$1" in configure) if ! id -u bcash &> /dev/null then - useradd --system -M -U bcash + useradd --system -M -U bcash -s /bin/false fi if [ "$(stat -c '%U' /opt/coins/data/bch-testnet/bitcoin)" != "bcash" ] diff --git a/contrib/backends/bitcoin/debian/bitcoin-btc.postinst b/contrib/backends/bitcoin/debian/bitcoin-btc.postinst index 84a26bf8..495f0345 100644 --- a/contrib/backends/bitcoin/debian/bitcoin-btc.postinst +++ b/contrib/backends/bitcoin/debian/bitcoin-btc.postinst @@ -6,7 +6,7 @@ case "$1" in configure) if ! id -u bitcoin &> /dev/null then - useradd --system -M -U bitcoin + useradd --system -M -U bitcoin -s /bin/false fi if [ "$(stat -c '%U' /opt/coins/data/btc/bitcoin)" != "bitcoin" ] diff --git a/contrib/backends/bitcoin/debian/bitcoin-testnet.postinst b/contrib/backends/bitcoin/debian/bitcoin-testnet.postinst index e95584a3..ae1a2441 100644 --- a/contrib/backends/bitcoin/debian/bitcoin-testnet.postinst +++ b/contrib/backends/bitcoin/debian/bitcoin-testnet.postinst @@ -6,7 +6,7 @@ case "$1" in configure) if ! id -u bitcoin &> /dev/null then - useradd --system -M -U bitcoin + useradd --system -M -U bitcoin -s /bin/false fi if [ "$(stat -c '%U' /opt/coins/data/btc-testnet/bitcoin)" != "bitcoin" ] diff --git a/contrib/backends/zcash/debian/zcash-zec.postinst b/contrib/backends/zcash/debian/zcash-zec.postinst index 510c8a43..42acc20d 100644 --- a/contrib/backends/zcash/debian/zcash-zec.postinst +++ b/contrib/backends/zcash/debian/zcash-zec.postinst @@ -6,7 +6,7 @@ case "$1" in configure) if ! id -u zcash &> /dev/null then - useradd --system -M -U zcash + useradd --system -M -U zcash -s /bin/false fi if [ "$(stat -c '%U' /opt/coins/data/zec/zcash)" != "zcash" ] From 9324fed5deed411e3bcc92d0309a7dd5e2cb6bf0 Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Wed, 16 May 2018 12:05:50 +0200 Subject: [PATCH 6/6] Fixed duplicit copying of /src into existing source directory --- build/bin/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/bin/Makefile b/build/bin/Makefile index d81d9314..c1861871 100644 --- a/build/bin/Makefile +++ b/build/bin/Makefile @@ -18,7 +18,7 @@ test-all: prepare-sources prepare-sources: @ [ -n "`ls /src 2> /dev/null`" ] || (echo "/src doesn't exist or is empty" 1>&2 && exit 1) - cp -r /src $(GOPATH)/src/blockbook + [ -d $(GOPATH)/src/blockbook ] || cp -r /src $(GOPATH)/src/blockbook $(MAKE) prepare-vendor prepare-vendor: