Skip to content

Commit

Permalink
Merge pull request #146 from basho-labs/mtc-configurable-patch-path
Browse files Browse the repository at this point in the history
Configurable patch path
  • Loading branch information
travisbhartwell authored Aug 26, 2016
2 parents 5e724e3 + 33add91 commit 14ee5d8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ configure.sh
.vagrant
packages
oauth.txt
rel/sandbox
47 changes: 35 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ recompile:
$(REBAR) compile skip_deps=true
deps:
$(REBAR) get-deps
clean: cleantest relclean
clean: cleantest relclean clean-sandbox
-rm -rf packages
clean-sandbox:
-rm -rf rel/sandbox
cleantest:
rm -rf .eunit/*
test: cleantest
Expand Down Expand Up @@ -95,27 +97,48 @@ PATCH_PKGNAME ?= $(REPO)-$(PATCH_PKG_VERSION)-$(OS_FAMILY)-$(OS_VERSION)
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)

tarball: compile
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/$(RIAK_BASE)
mkdir -p rel/$(RIAK_BASE)/riak/lib/basho-patches
mkdir -p rel/$(RIAK_BASE)/riak/priv
cp -R deps/riakc/ebin/* rel/$(RIAK_BASE)/riak/lib/basho-patches/
cp -R deps/riak_pb/ebin/* rel/$(RIAK_BASE)/riak/lib/basho-patches/
cp -R deps/protobuffs/ebin/* rel/$(RIAK_BASE)/riak/lib/basho-patches/
cp -R ebin/* rel/$(RIAK_BASE)/riak/lib/basho-patches/
cp -R priv/* rel/$(RIAK_BASE)/riak/priv/
-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 -czf $(PATCH_PKGNAME) root
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
sync:
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)])')
Expand Down

0 comments on commit 14ee5d8

Please sign in to comment.