From 469b93eaa44b6abfe7ab959da028618a8ae5543c Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Fri, 21 Sep 2018 20:01:55 +0300 Subject: [PATCH 1/2] Rewrite Makefile * fixes building outdated coredns plugin from inside GOPATH * make clean now cleans all build output, including node_modules and webpack output * smarter invocation of `npm install` -- only if package.json or package-lock.json changed * use separate gopath because coredns build system requires custom checkout of prometheus dependency --- Makefile | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 8f3e1cbb..5bed39bc 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags) -GOPATH := $(shell go env GOPATH) NATIVE_GOOS = $(shell unset GOOS; go env GOOS) NATIVE_GOARCH = $(shell unset GOARCH; go env GOARCH) mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) mkfile_dir := $(patsubst %/,%,$(dir $(mkfile_path))) +GOPATH := $(mkfile_dir)/build/gopath STATIC := build/static/bundle.css build/static/bundle.js build/static/index.html .PHONY: all build clean @@ -11,26 +11,37 @@ all: build build: AdguardDNS coredns -$(STATIC): +client/node_modules: client/package.json client/package-lock.json npm --prefix client install + touch client/node_modules + +$(STATIC): client/node_modules npm --prefix client run build-prod AdguardDNS: $(STATIC) *.go echo mkfile_dir = $(mkfile_dir) - go get -v -d . - GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) go get -v github.com/gobuffalo/packr/... - PATH=$(GOPATH)/bin:$(PATH) packr build -ldflags="-X main.VersionString=$(GIT_VERSION)" -o AdguardDNS + mkdir -p $(GOPATH) + GOPATH=$(GOPATH) go get -v -d . + GOPATH=$(GOPATH) go get -v -d -u github.com/AdguardTeam/AdguardDNS + GOPATH=$(GOPATH) GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) go get -v github.com/gobuffalo/packr/... + mkdir -p $(GOPATH)/src/github.com/AdguardTeam/AdguardDNS/build/static ## work around packr bug + GOPATH=$(GOPATH) PATH=$(GOPATH)/bin:$(PATH) packr build -ldflags="-X main.VersionString=$(GIT_VERSION)" -o AdguardDNS coredns: coredns_plugin/*.go dnsfilter/*.go echo mkfile_dir = $(mkfile_dir) - go get -v -d github.com/coredns/coredns + GOPATH=$(GOPATH) go get -v -d github.com/coredns/coredns cd $(GOPATH)/src/github.com/prometheus/client_golang && git checkout -q v0.8.0 cd $(GOPATH)/src/github.com/coredns/coredns && perl -p -i.bak -e 's/^(trace|route53|federation|kubernetes|etcd):.*//' plugin.cfg cd $(GOPATH)/src/github.com/coredns/coredns && grep -q '^dnsfilter:' plugin.cfg || perl -p -i.bak -e 's|^log:log|log:log\ndnsfilter:github.com/AdguardTeam/AdguardDNS/coredns_plugin|' plugin.cfg grep '^dnsfilter:' $(GOPATH)/src/github.com/coredns/coredns/plugin.cfg ## used to check that plugin.cfg was successfully edited by sed - cd $(GOPATH)/src/github.com/coredns/coredns && GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) go generate - cd $(GOPATH)/src/github.com/coredns/coredns && go get -v -d . - cd $(GOPATH)/src/github.com/coredns/coredns && go build -o $(mkfile_dir)/coredns + cd $(GOPATH)/src/github.com/coredns/coredns && GOPATH=$(GOPATH) GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) go generate + cd $(GOPATH)/src/github.com/coredns/coredns && GOPATH=$(GOPATH) go get -v -d . + cd $(GOPATH)/src/github.com/coredns/coredns && GOPATH=$(GOPATH) go build -o $(mkfile_dir)/coredns clean: + $(MAKE) cleanfast + rm -rvf build + rm -rvf client/node_modules + +cleanfast: rm -vf coredns AdguardDNS From d8fbb2cd3b688b3890d60bc3923db50696dd9d59 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Fri, 21 Sep 2018 20:06:33 +0300 Subject: [PATCH 2/2] Remove leftover from old internal repo --- packaging/postinstall.sh | 3 --- packaging/postrm.sh | 3 --- packaging/preinstall.sh | 3 --- packaging/prerm.sh | 3 --- 4 files changed, 12 deletions(-) delete mode 100644 packaging/postinstall.sh delete mode 100644 packaging/postrm.sh delete mode 100644 packaging/preinstall.sh delete mode 100644 packaging/prerm.sh diff --git a/packaging/postinstall.sh b/packaging/postinstall.sh deleted file mode 100644 index 061ecaa2..00000000 --- a/packaging/postinstall.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -set -e -x -o pipefail -echo "executing $0" diff --git a/packaging/postrm.sh b/packaging/postrm.sh deleted file mode 100644 index 061ecaa2..00000000 --- a/packaging/postrm.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -set -e -x -o pipefail -echo "executing $0" diff --git a/packaging/preinstall.sh b/packaging/preinstall.sh deleted file mode 100644 index 061ecaa2..00000000 --- a/packaging/preinstall.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -set -e -x -o pipefail -echo "executing $0" diff --git a/packaging/prerm.sh b/packaging/prerm.sh deleted file mode 100644 index 061ecaa2..00000000 --- a/packaging/prerm.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -set -e -x -o pipefail -echo "executing $0"