From 9603b0e804fe2852a528880e8c4ae09907a63574 Mon Sep 17 00:00:00 2001 From: Gari Singh Date: Thu, 13 Apr 2017 06:27:06 -0400 Subject: [PATCH] [FAB-3136] Include install script with release package Since we distribute our runtime(s) as Docker images and there are several of them to download, it's convenient to provide a script which will download the correct version as well as iamges for the correct architecture. The script basically has a list of the various fabric images and the make target uses substituion to set the right variables for each platform. NOTE: I hard-coded VERSION to 1.0.0-alpha for now because we do need to publish these packages and update the docs to ensure things will still work with the alpha Change-Id: I76d6db3ab638e13e65c4b4c0ce23d4af4e6ef068 Signed-off-by: Gari Singh --- Makefile | 44 ++++++++++++++++---------- release/templates/get-docker-images.in | 17 ++++++++++ 2 files changed, 44 insertions(+), 17 deletions(-) create mode 100644 release/templates/get-docker-images.in diff --git a/Makefile b/Makefile index c9dc4546399..567f72d1535 100644 --- a/Makefile +++ b/Makefile @@ -276,41 +276,49 @@ release: $(patsubst %,release/%, $(shell go env GOOS)-$(shell go env GOARCH)) release-all: $(patsubst %,release/%, $(RELEASE_PLATFORMS)) release/windows-amd64: GOOS=windows -release/windows-amd64: GOARCH=amd64 release/windows-amd64: GO_TAGS+= nopkcs11 -release/windows-amd64: $(patsubst %,release/windows-amd64/%, $(RELEASE_PKGS)) +release/windows-amd64: $(patsubst %,release/windows-amd64/bin/%, $(RELEASE_PKGS)) release/windows-amd64/install release/darwin-amd64: GOOS=darwin -release/darwin-amd64: GOARCH=amd64 release/darwin-amd64: GO_TAGS+= nopkcs11 -release/darwin-amd64: $(patsubst %,release/darwin-amd64/%, $(RELEASE_PKGS)) +release/darwin-amd64: $(patsubst %,release/darwin-amd64/bin/%, $(RELEASE_PKGS)) release/darwin-amd64/install release/linux-amd64: GOOS=linux -release/linux-amd64: GOARCH=amd64 release/linux-amd64: GO_TAGS+= nopkcs11 -release/linux-amd64: $(patsubst %,release/linux-amd64/%, $(RELEASE_PKGS)) +release/linux-amd64: $(patsubst %,release/linux-amd64/bin/%, $(RELEASE_PKGS)) release/linux-amd64/install + +release/%-amd64: DOCKER_ARCH=x86_64 +release/%-amd64: GOARCH=amd64 +release/linux-%: GOOS=linux -release/linux-ppc64le: GOOS=linux release/linux-ppc64le: GOARCH=ppc64le +release/linux-ppc64le: DOCKER_ARCH=ppc64le release/linux-ppc64le: GO_TAGS+= nopkcs11 -release/linux-ppc64le: $(patsubst %,release/linux-ppc64le/%, $(RELEASE_PKGS)) +release/linux-ppc64le: $(patsubst %,release/linux-ppc64le/bin/%, $(RELEASE_PKGS)) release/linux-ppc64le/install -release/linux-s390x: GOOS=linux release/linux-s390x: GOARCH=s390x +release/linux-s390x: DOCKER_ARCH=s390x release/linux-s390x: GO_TAGS+= nopkcs11 -release/linux-s390x: $(patsubst %,release/linux-s390x/%, $(RELEASE_PKGS)) +release/linux-s390x: $(patsubst %,release/linux-s390x/bin/%, $(RELEASE_PKGS)) release/linux-s390x/install -release/%/configtxgen: $(PROJECT_FILES) +release/%/bin/configtxgen: $(PROJECT_FILES) @echo "Building $@ for $(GOOS)-$(GOARCH)" mkdir -p $(@D) $(CGO_FLAGS) GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(abspath $@) -tags "$(GO_TAGS)" -ldflags "$(GO_LDFLAGS)" $(pkgmap.$(@F)) - @touch $@ -release/%/cryptogen: $(PROJECT_FILES) +release/%/bin/cryptogen: $(PROJECT_FILES) @echo "Building $@ for $(GOOS)-$(GOARCH)" mkdir -p $(@D) $(CGO_FLAGS) GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(abspath $@) -tags "$(GO_TAGS)" -ldflags "$(GO_LDFLAGS)" $(pkgmap.$(@F)) - @touch $@ + +release/%/install: $(PROJECT_FILES) + mkdir -p $@ + @cat $@/../../templates/get-docker-images.in \ + | sed -e 's/_NS_/$(DOCKER_NS)/g' \ + | sed -e 's/_ARCH_/$(DOCKER_ARCH)/g' \ + | sed -e 's/_VERSION_/$(PROJECT_VERSION)/g' \ + > $@/get-docker-images.sh + @chmod +x $@/get-docker-images.sh .PHONY: protos protos: buildenv @@ -331,9 +339,11 @@ clean: docker-clean unit-test-clean dist-clean: clean gotools-clean -@rm -rf /var/hyperledger/* ||: -.PHONY: release-clean -release-clean: - -@rm -rf release +%-release-clean: + $(eval TARGET = ${patsubst %-release-clean,%,${@}}) + -@rm -rf release/$(TARGET) + +release-clean: $(patsubst %,%-release-clean, $(RELEASE_PLATFORMS)) .PHONY: unit-test-clean unit-test-clean: diff --git a/release/templates/get-docker-images.in b/release/templates/get-docker-images.in new file mode 100644 index 00000000000..7bb35306b06 --- /dev/null +++ b/release/templates/get-docker-images.in @@ -0,0 +1,17 @@ +#!/bin/bash -eu + +# This script pulls docker images from the Dockerhub hyperledger repositories + +# set the default Docker namespace and tag +DOCKER_NS=_NS_ +ARCH=_ARCH_ +VERSION=1.0.0-alpha + +# set of Hyperledger Fabric images +FABRIC_IMAGES=(fabric-peer fabric-orderer fabric-ccenv fabric-javaenv fabric-kafka fabric-zookeeper fabric-couchdb) + +for image in ${FABRIC_IMAGES[@]}; do + echo "Pulling ${DOCKER_NS}/$image:${ARCH}-${VERSION}" + docker pull ${DOCKER_NS}/$image:${ARCH}-${VERSION} +done +