-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMakefile
151 lines (133 loc) · 6.93 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
REPO ?= riak_explorer
PKG_VERSION ?= $(shell git describe --tags --abbrev=0 | tr - .)
OS_FAMILY ?= ubuntu
OS_VERSION ?= 14.04
PKGNAME ?= $(REPO)-$(PKG_VERSION)-$(OS_FAMILY)-$(OS_VERSION).tar.gz
OAUTH_TOKEN ?= $(shell cat oauth.txt)
GIT_TAG ?= $(shell git describe --tags --abbrev=0)
RELEASE_ID ?= $(shell curl -sS https://api.github.com/repos/basho-labs/$(REPO)/releases/tags/$(GIT_TAG)?access_token=$(OAUTH_TOKEN) | python -c 'import sys, json; print(json.load(sys.stdin)["id"])')
DEPLOY_BASE ?= "https://uploads.github.com/repos/basho-labs/$(REPO)/releases/$(RELEASE_ID)/assets?access_token=$(OAUTH_TOKEN)&name=$(PKGNAME)"
DOWNLOAD_BASE ?= https://github.com/basho-labs/$(REPO)/releases/download/$(GIT_TAG)/$(PKGNAME)
BASE_DIR = $(shell pwd)
ERLANG_BIN = $(shell dirname $(shell which erl))
REBAR ?= $(BASE_DIR)/rebar
OVERLAY_VARS ?=
ifneq (,$(shell whereis sha256sum | awk '{print $2}';))
SHASUM = sha256sum
else
SHASUM = shasum -a 256
endif
.PHONY: deps
all: compile
compile: deps
$(REBAR) compile
recompile:
$(REBAR) compile skip_deps=true
deps:
$(REBAR) get-deps
clean: cleantest relclean clean-sandbox
-rm -rf packages
clean-sandbox:
-rm -rf rel/sandbox
cleantest:
rm -rf .eunit/*
test: cleantest
$(REBAR) skip_deps=true eunit
itest: recompile cleantest
INTEGRATION_TEST=true $(REBAR) skip_deps=true eunit
reitest: cleantest
INTEGRATION_TEST=true $(REBAR) skip_deps=true eunit
relclean:
-rm -rf rel/riak_explorer
-rm -rf rel/root
rel: relclean deps compile
$(REBAR) compile
$(REBAR) skip_deps=true generate $(OVERLAY_VARS)
stage: rel
$(foreach dep,$(wildcard deps/*), rm -rf rel/riak_explorer/lib/$(shell basename $(dep))-* && ln -sf $(abspath $(dep)) rel/riak_explorer/lib;)
$(foreach app,$(wildcard apps/*), rm -rf rel/riak_explorer/lib/$(shell basename $(app))-* && ln -sf $(abspath $(app)) rel/riak_explorer/lib;)
rm -rf rel/riak_explorer/priv/ember_riak_explorer/dist && ln -sf $(abspath priv/ember_riak_explorer/dist) rel/riak_explorer/priv/ember_riak_explorer
riak-addon:
-rm -rf rel/riak-addon
mkdir -p rel/riak-addon/ebin
mkdir -p rel/riak-addon/priv
$(REBAR) compile
cp -R deps/riakc/ebin/* rel/riak-addon/ebin/
cp -R deps/riak_pb/ebin/* rel/riak-addon/riak/lib/basho-patches/
cp -R deps/protobuffs/ebin/* rel/riak-addon/riak/lib/basho-patches/
cp -R ebin/* rel/riak-addon/ebin/
cp -R priv/* rel/riak-addon/priv/
##
## Packaging targets
##
tarball-standalone: rel
echo "Creating packages/"$(PKGNAME)
mkdir -p packages
tar -C rel -czf $(PKGNAME) $(REPO)/
mv $(PKGNAME) packages/
cd packages && $(SHASUM) $(PKGNAME) > $(PKGNAME).sha
cd packages && echo "$(DOWNLOAD_BASE)" > remote.txt
cd packages && echo "$(BASE_DIR)/packages/$(PKGNAME)" > local.txt
sync-standalone:
echo "Uploading to "$(DOWNLOAD_BASE)
@cd packages && \
curl -XPOST -sS -H 'Content-Type: application/gzip' $(DEPLOY_BASE) --data-binary @$(PKGNAME) && \
curl -XPOST -sS -H 'Content-Type: application/octet-stream' $(DEPLOY_BASE).sha --data-binary @$(PKGNAME).sha
ASSET_ID ?= $(shell curl -sS https://api.github.com/repos/basho-labs/$(REPO)/releases/$(RELEASE_ID)/assets?access_token=$(OAUTH_TOKEN) | python -c 'import sys, json; print("".join([str(asset["id"]) if asset["name"] == "$(PKGNAME)" else "" for asset in json.load(sys.stdin)]))')
ASSET_SHA_ID ?= $(shell curl -sS https://api.github.com/repos/basho-labs/$(REPO)/releases/$(RELEASE_ID)/assets?access_token=$(OAUTH_TOKEN) | python -c 'import sys, json; print("".join([str(asset["id"]) if asset["name"] == "$(PKGNAME).sha" else "" for asset in json.load(sys.stdin)]))')
DELETE_DEPLOY_BASE ?= "https://api.github.com/repos/basho-labs/$(REPO)/releases/assets/$(ASSET_ID)?access_token=$(OAUTH_TOKEN)"
DELETE_SHA_DEPLOY_BASE ?= "https://api.github.com/repos/basho-labs/$(REPO)/releases/assets/$(ASSET_SHA_ID)?access_token=$(OAUTH_TOKEN)"
sync-delete-standalone:
echo "Deleting "$(DOWNLOAD_BASE)
- $(shell curl -XDELETE -sS $(DELETE_DEPLOY_BASE))
- $(shell curl -XDELETE -sS $(DELETE_SHA_DEPLOY_BASE))
RIAK_BASE ?= root
PATCH_PKG_VERSION ?= $(PKG_VERSION).patch
PATCH_PKGNAME ?= $(REPO)-$(PATCH_PKG_VERSION)-$(OS_FAMILY)-$(OS_VERSION).tar.gz
PATCH_DEPLOY_BASE ?= "https://uploads.github.com/repos/basho-labs/$(REPO)/releases/$(RELEASE_ID)/assets?access_token=$(OAUTH_TOKEN)&name=$(PATCH_PKGNAME)"
PATCH_DOWNLOAD_BASE ?= https://github.com/basho-labs/$(REPO)/releases/download/$(GIT_TAG)/$(PATCH_PKGNAME)
reltarball: RIAK_BASE = .
reltarball: PATCH_PKG_VERSION = $(PKG_VERSION).relpatch
reltarball: compile clean-sandbox
reltarball:
$(call build-tarball)
relsync: RIAK_BASE = .
relsync: PATCH_PKG_VERSION = $(PKG_VERSION).relpatch
relsync:
$(call do-sync)
tarball: compile clean-sandbox
tarball:
$(call build-tarball)
sync:
$(call do-sync)
define build-tarball
echo "Creating packages/"$(PATCH_PKGNAME)
-rm -rf rel/sandbox/$(RIAK_BASE)
mkdir -p rel/sandbox/$(RIAK_BASE)/riak/lib/basho-patches
mkdir -p rel/sandbox/$(RIAK_BASE)/riak/priv
cp -R deps/riakc/ebin/* rel/sandbox/$(RIAK_BASE)/riak/lib/basho-patches/
cp -R deps/riak_pb/ebin/* rel/sandbox/$(RIAK_BASE)/riak/lib/basho-patches/
cp -R deps/protobuffs/ebin/* rel/sandbox/$(RIAK_BASE)/riak/lib/basho-patches/
cp -R ebin/* rel/sandbox/$(RIAK_BASE)/riak/lib/basho-patches/
cp -R priv/* rel/sandbox/$(RIAK_BASE)/riak/priv/
mkdir -p packages
tar -C rel/sandbox -czf $(PATCH_PKGNAME) $(RIAK_BASE)
mv $(PATCH_PKGNAME) packages/
cd packages && $(SHASUM) $(PATCH_PKGNAME) > $(PATCH_PKGNAME).sha
cd packages && echo "$(PATCH_DOWNLOAD_BASE)" > remote.txt
cd packages && echo "$(BASE_DIR)/packages/$(PATCH_PKGNAME)" > local.txt
endef
define do-sync
echo "Uploading to "$(PATCH_DOWNLOAD_BASE)
@cd packages && \
curl -XPOST -sS -H 'Content-Type: application/gzip' $(PATCH_DEPLOY_BASE) --data-binary @$(PATCH_PKGNAME) && \
curl -XPOST -sS -H 'Content-Type: application/octet-stream' $(PATCH_DEPLOY_BASE).sha --data-binary @$(PATCH_PKGNAME).sha
endef
PATCH_ASSET_ID ?= $(shell curl -sS https://api.github.com/repos/basho-labs/$(REPO)/releases/$(RELEASE_ID)/assets?access_token=$(OAUTH_TOKEN) | python -c 'import sys, json; print "".join([str(asset["id"]) if asset["name"] == "$(PATCH_PKGNAME)" else "" for asset in json.load(sys.stdin)])')
PATCH_ASSET_SHA_ID ?= $(shell curl -sS https://api.github.com/repos/basho-labs/$(REPO)/releases/$(RELEASE_ID)/assets?access_token=$(OAUTH_TOKEN) | python -c 'import sys, json; print "".join([str(asset["id"]) if asset["name"] == "$(PATCH_PKGNAME).sha" else "" for asset in json.load(sys.stdin)])')
PATCH_DELETE_DEPLOY_BASE ?= "https://api.github.com/repos/basho-labs/$(REPO)/releases/assets/$(PATCH_ASSET_ID)?access_token=$(OAUTH_TOKEN)"
PATCH_DELETE_SHA_DEPLOY_BASE ?= "https://api.github.com/repos/basho-labs/$(REPO)/releases/assets/$(PATCH_ASSET_SHA_ID)?access_token=$(OAUTH_TOKEN)"
sync-delete:
echo "Deleting "$(PATCH_DOWNLOAD_BASE)
- $(shell curl -XDELETE -sS $(PATCH_DELETE_DEPLOY_BASE))
- $(shell curl -XDELETE -sS $(PATCH_DELETE_SHA_DEPLOY_BASE))