## # Extra checks, because we do not use autoconf. Set extra_check to false if it is bothering you. ## extra_check = true go_min_version = 1.8.3 gpg_key = 2122CBE9 ifeq ($(extra_check),true) ifndef GOPATH $(error GOPATH not set) else go_version := $(shell go version | sed "s/^.* go\([0-9\.]*\) .*$$/\1/" ) $(info Found go version $(go_version)) go_version_check := $(shell echo -e "$(go_min_version)\n$(go_version)" | sort -V | head -1) ifneq ($(go_min_version),$(go_version_check)) $(error go version go_min_version or above is required) endif endif gpg_check := $(shell gpg -K | grep '/$(gpg_key) ' | sed 's,^.*/\($(gpg_key)\) .*$$,\1,') ifneq ($(gpg_check),$(gpg_key)) $(error GPG key $(gpg_key) not found.) else $(info GPG key $(gpg_key) found) endif ifndef GPG_PASSPHRASE $(error GPG_PASSPHRASE not set) endif endif ### # Here comes the real deal ### binaries = tendermint basecoin ethermint trackomatron build-binaries = build-tendermint build-basecoin build-ethermint build-trackomatron package-rpm = package-rpm-tendermint package-rpm-basecoin package-rpm-ethermint package-rpm-trackomatron install-rpm = install-rpm-tendermint install-rpm-basecoin install-rpm-ethermint install-rpm-trackomatron package-deb = package-deb-tendermint package-deb-basecoin package-deb-ethermint package-deb-trackomatron install-deb = install-deb-tendermint install-deb-basecoin install-deb-ethermint install-deb-trackomatron all: $(binaries) build: $(build-binaries) package: $(package-rpm) $(package-deb) install: $(install-rpm) $(install-deb) $(binaries): %: build-% package-rpm-% package-deb-% ### # Building the binaries is not in the spec file, because in the spec file you already need to know the version number ### git-branch: $(eval $GIT_BRANCH=$(shell test -z "$(GIT_BRANCH)" && echo "master" || echo "$(GIT_BRANCH)" )) build-tendermint: git-branch @echo "*** Building tendermint" go get -d -u github.com/tendermint/tendermint/cmd/tendermint cd $(GOPATH)/src/github.com/tendermint/tendermint && git checkout "$(GIT_BRANCH)" && git pull $(MAKE) -C $(GOPATH)/src/github.com/tendermint/tendermint get_vendor_deps build cp $(GOPATH)/src/github.com/tendermint/tendermint/build/tendermint $(GOPATH)/bin @echo "*** Built tendermint" build-basecoin: git-branch @echo "*** Building basecoin" go get -d -u github.com/tendermint/basecoin/cmd/basecoin cd $(GOPATH)/src/github.com/tendermint/basecoin && git checkout "$(GIT_BRANCH)" && git pull $(MAKE) -C $(GOPATH)/src/github.com/tendermint/basecoin get_vendor_deps install @echo "*** Built basecoin" build-ethermint: git-branch @echo "*** Building ethermint" go get -d -u github.com/tendermint/ethermint/cmd/ethermint cd $(GOPATH)/src/github.com/tendermint/ethermint && git checkout "$(GIT_BRANCH)" && git pull $(MAKE) -C $(GOPATH)/src/github.com/tendermint/ethermint get_vendor_deps build cp $(GOPATH)/src/github.com/tendermint/ethermint/build/ethermint $(GOPATH)/bin @echo "*** Built ethermint" build-trackomatron: git-branch @echo "*** Building trackomatron" go get -d -u go github.com/tendermint/trackomatron || echo "Workaround so there is no error message." cd $(GOPATH)/src/github.com/tendermint/trackomatron && git checkout "$(GIT_BRANCH)" && git pull $(MAKE) -C $(GOPATH)/src/github.com/tendermint/trackomatron get_vendor_deps install @echo "Workaround: trackomatron package has tracko as the binary - trackomatron needed to get the version number" && rm -rf $(GOPATH)/bin/trackomatron && ln -s $(GOPATH)/bin/tracko $(GOPATH)/bin/trackomatron @echo "*** Built trackomatron" version-%: $(GOPATH)/bin/% if [ -z "$(BUILD_NUMBER)" ]; then echo "BUILD_NUMBER not set" ; false ; fi $(eval $*_version=$(shell $< version | cut -d- -f1 )) prepare-spec-%: version-% mkdir -p {SPECS,tmp} echo "Version: $($*_version)" > SPECS/$*.spec echo "Release: $(BUILD_NUMBER)" >> SPECS/$*.spec cat spectemplates/$*.spec >> SPECS/$*.spec package-rpm-%: prepare-spec-% @echo "*** Packaging RPM $* version $($*_version)" rpmbuild -bb SPECS/$*.spec ./sign RPMS/x86_64/$*-$($*_version)-$(BUILD_NUMBER).x86_64.rpm rpm -Kv RPMS/x86_64/$*-$($*_version)-$(BUILD_NUMBER).x86_64.rpm @echo "*** Packaged RPM $* version $($*_version)" package-deb-%: version-% @echo "*** Packaging DEB $* version $($*_version)-$(BUILD_NUMBER)" echo "BUILD/$*-$($*_version) folder is generated by package-rpm-$*" test -d BUILD/$*-$($*_version) rm -rf BUILD/$*-$($*_version)-$(BUILD_NUMBER) tmp/_gpg tmp/_gpgbuilder tmp/debian-binary tmp/control.tar.gz tmp/data.tar.xz cp -r BUILD/$*-$($*_version) BUILD/$*-$($*_version)-$(BUILD_NUMBER) cp -r extrafiles/DEBIAN-$* BUILD/$*-$($*_version)-$(BUILD_NUMBER)/DEBIAN sed -i "s/@VERSION@/$($*_version)-$(BUILD_NUMBER)/" BUILD/$*-$($*_version)-$(BUILD_NUMBER)/DEBIAN/changelog sed -i "s/@STABILITY@/stable/" BUILD/$*-$($*_version)-$(BUILD_NUMBER)/DEBIAN/changelog sed -i "s/@DATETIMESTAMP@/`date +%a,\ %d\ %b\ %Y\ %T\ %z`/" BUILD/$*-$($*_version)-$(BUILD_NUMBER)/DEBIAN/changelog sed -i "s/@VERSION@/$($*_version)-$(BUILD_NUMBER)/" BUILD/$*-$($*_version)-$(BUILD_NUMBER)/DEBIAN/control rm -rf BUILD/$*-$($*_version)-$(BUILD_NUMBER)/usr/share/licenses mkdir -p BUILD/$*-$($*_version)-$(BUILD_NUMBER)/usr/share/doc/$* cp BUILD/$*-$($*_version)-$(BUILD_NUMBER)/DEBIAN/copyright BUILD/$*-$($*_version)-$(BUILD_NUMBER)/usr/share/doc/$* gzip -c BUILD/$*-$($*_version)-$(BUILD_NUMBER)/DEBIAN/changelog > BUILD/$*-$($*_version)-$(BUILD_NUMBER)/usr/share/doc/$*/changelog.Debian.gz gzip -c BUILD/$*-$($*_version)-$(BUILD_NUMBER)/DEBIAN/changelog > BUILD/$*-$($*_version)-$(BUILD_NUMBER)/usr/share/doc/$*/changelog.Debian.amd64.gz sed -i "s/@INSTALLEDSIZE@/`du -ks BUILD/$*-$($*_version)-$(BUILD_NUMBER) | cut -f 1`/" BUILD/$*-$($*_version)-$(BUILD_NUMBER)/DEBIAN/control cd BUILD/$*-$($*_version)-$(BUILD_NUMBER) && tar --owner=root --group=root -cvJf ../../tmp/data.tar.xz --exclude DEBIAN * cd BUILD/$*-$($*_version)-$(BUILD_NUMBER)/DEBIAN && tar --owner=root --group=root -cvzf ../../../tmp/control.tar.gz * echo "2.0" > tmp/debian-binary cp extrafiles/_gpg tmp/ cd tmp && sed -i "s/@DATETIMESTAMP@/`date +%a\ %b\ %d\ %T\ %Y`/" _gpg cd tmp && sed -i "s/@BINMD5@/`md5sum debian-binary | cut -d\ -f1`/" _gpg cd tmp && sed -i "s/@BINSHA1@/`sha1sum debian-binary | cut -d\ -f1`/" _gpg cd tmp && sed -i "s/@BINSIZE@/`stat -c %s debian-binary | cut -d\ -f1`/" _gpg cd tmp && sed -i "s/@CONMD5@/`md5sum control.tar.gz | cut -d\ -f1`/" _gpg cd tmp && sed -i "s/@CONSHA1@/`sha1sum control.tar.gz | cut -d\ -f1`/" _gpg cd tmp && sed -i "s/@CONSIZE@/`stat -c %s control.tar.gz | cut -d\ -f1`/" _gpg cd tmp && sed -i "s/@DATMD5@/`md5sum data.tar.xz | cut -d\ -f1`/" _gpg cd tmp && sed -i "s/@DATSHA1@/`sha1sum data.tar.xz | cut -d\ -f1`/" _gpg cd tmp && sed -i "s/@DATSIZE@/`stat -c %s data.tar.xz | cut -d\ -f1`/" _gpg gpg --batch --passphrase "$(GPG_PASSPHRASE)" --clearsign tmp/_gpg mv tmp/_gpg.asc tmp/_gpgbuilder ar r tmp/$*-$($*_version)-$(BUILD_NUMBER)_amd64.deb tmp/debian-binary tmp/control.tar.gz tmp/data.tar.xz tmp/_gpgbuilder mv tmp/$*-$($*_version)-$(BUILD_NUMBER)_amd64.deb RPMS/ rm tmp/debian-binary tmp/control.tar.gz tmp/data.tar.xz tmp/_gpgbuilder tmp/_gpg @echo "*** Packaged DEB $* version $($*_version)-$(BUILD_NUMBER)" install-rpm-%: version-% #Make sure your host has the IAM role to read/write the S3 bucket OR that you set up ~/.boto @echo "*** Uploading $*-$($*_version)-$(BUILD_NUMBER).x86_64.rpm to AWS CentOS repository" aws s3 sync s3://tendermint-packages/centos/ tmp/s3/ --delete mkdir -p tmp/s3/7/os/x86_64/Packages cp RPMS/x86_64/$*-$($*_version)-$(BUILD_NUMBER).x86_64.rpm tmp/s3/7/os/x86_64/Packages cp repofiles/RPM-GPG-KEY-Tendermint tmp/s3/7/os/x86_64/ cp repofiles/tendermint.repo tmp/s3/7/os/x86_64/ rm -f tmp/s3/7/os/x86_64/repodata/*.bz2 tmp/s3/7/os/x86_64/repodata/*.gz tmp/s3/7/os/x86_64/repodata/repomd.xml.asc createrepo tmp/s3/7/os/x86_64/Packages -u http://tendermint-packages.s3-website-us-west-1.amazonaws.com/centos/7/os/x86_64/Packages -o tmp/s3/7/os/x86_64 --update -S --repo Tendermint --content tendermint --content basecoin --content ethermint gpg --batch --passphrase "$(GPG_PASSPHRASE)" --detach-sign -a tmp/s3/7/os/x86_64/repodata/repomd.xml aws s3 sync tmp/s3/ s3://tendermint-packages/centos/ --delete --acl public-read @echo "*** Uploaded $* to AWS CentOS repository" install-deb-%: version-% @echo "*** Uploading $*-$($*_version)-$(BUILD_NUMBER)_amd64.deb to AWS Debian repository" @echo "Testing if $*-$($*_version)-$(BUILD_NUMBER)_amd64.deb is already uploaded" test ! -f tmp/debian-s3/pool/$*-$($*_version)-$(BUILD_NUMBER)_amd64.deb aws s3 sync s3://tendermint-packages/debian/ tmp/debian-s3/ --delete @echo "Testing if $*-$($*_version)-$(BUILD_NUMBER)_amd64.deb is already uploaded" test ! -f tmp/debian-s3/pool/$*-$($*_version)-$(BUILD_NUMBER)_amd64.deb mkdir -p tmp/debian-s3/pool tmp/debian-s3/dists/stable/main/binary-amd64 cp RPMS/$*-$($*_version)-$(BUILD_NUMBER)_amd64.deb tmp/debian-s3/pool cp repofiles/Release_amd64 tmp/debian-s3/dists/stable/main/binary-amd64/Release #Packages / Packages.gz echo > tmp/Package echo "Filename: pool/$*-$($*_version)-$(BUILD_NUMBER)_amd64.deb" >> tmp/Package echo "MD5sum: `md5sum RPMS/$*-$($*_version)-$(BUILD_NUMBER)_amd64.deb | cut -d\ -f 1`" >> tmp/Package echo "SHA1: `sha1sum RPMS/$*-$($*_version)-$(BUILD_NUMBER)_amd64.deb | cut -d\ -f 1`" >> tmp/Package echo "SHA256: `sha256sum RPMS/$*-$($*_version)-$(BUILD_NUMBER)_amd64.deb | cut -d\ -f 1`" >> tmp/Package echo "Size: `stat -c %s RPMS/$*-$($*_version)-$(BUILD_NUMBER)_amd64.deb | cut -d\ -f 1`" >> tmp/Package cat BUILD/$*-$($*_version)-$(BUILD_NUMBER)/DEBIAN/control >> tmp/Package cat tmp/Package >> tmp/debian-s3/dists/stable/main/binary-amd64/Packages rm -f tmp/debian-s3/dists/stable/main/binary-amd64/Packages.gz gzip -c tmp/debian-s3/dists/stable/main/binary-amd64/Packages > tmp/debian-s3/dists/stable/main/binary-amd64/Packages.gz rm -f tmp/Package #main / Release / InRelease / Release.gpg cp repofiles/Release tmp/debian-s3/dists/stable/main/Release rm -f tmp/debian-s3/dists/stable/main/InRelease rm -f tmp/debian-s3/dists/stable/main/Release.gpg echo "MD5Sum:" >> tmp/debian-s3/dists/stable/main/Release cd tmp/debian-s3/dists/stable/main && for f in `find . -type f | sed 's/^.\///'` ; do test "$$f" == "Release" && continue ; echo -n " " ; md5sum $$f | sed "s/ / `stat -c %s $$f` /" ; done >> Release echo "SHA1:" >> tmp/debian-s3/dists/stable/main/Release cd tmp/debian-s3/dists/stable/main && for f in `find . -type f | sed 's/^.\///'` ; do test "$$f" == "Release" && continue ; echo -n " " ; sha1sum $$f | sed "s/ / `stat -c %s $$f` /" ; done >> Release echo "SHA256:" >> tmp/debian-s3/dists/stable/main/Release cd tmp/debian-s3/dists/stable/main && for f in `find . -type f | sed 's/^.\///'` ; do test "$$f" == "Release" && continue ; echo -n " " ; sha256sum $$f | sed "s/ / `stat -c %s $$f` /" ; done >> Release gpg --batch --passphrase "$(GPG_PASSPHRASE)" --digest-algo SHA256 -b -a tmp/debian-s3/dists/stable/main/Release mv tmp/debian-s3/dists/stable/main/Release.asc tmp/debian-s3/dists/stable/main/Release.gpg gpg --batch --passphrase "$(GPG_PASSPHRASE)" --digest-algo SHA512 --clearsign tmp/debian-s3/dists/stable/main/Release mv tmp/debian-s3/dists/stable/main/Release.asc tmp/debian-s3/dists/stable/main/InRelease #stable / Release / InRelease / Release.gpg cp repofiles/Release tmp/debian-s3/dists/stable/Release rm -f tmp/debian-s3/dists/stable/InRelease rm -f tmp/debian-s3/dists/stable/Release.gpg echo "MD5Sum:" >> tmp/debian-s3/dists/stable/Release cd tmp/debian-s3/dists/stable && for f in `find . -type f | sed 's/^.\///'` ; do test "$$f" == "Release" && continue ; echo -n " " ; md5sum $$f | sed "s/ / `stat -c %s $$f` /" ; done >> Release echo "SHA1:" >> tmp/debian-s3/dists/stable/Release cd tmp/debian-s3/dists/stable && for f in `find . -type f | sed 's/^.\///'` ; do test "$$f" == "Release" && continue ; echo -n " " ; sha1sum $$f | sed "s/ / `stat -c %s $$f` /" ; done >> Release echo "SHA256:" >> tmp/debian-s3/dists/stable/Release cd tmp/debian-s3/dists/stable && for f in `find . -type f | sed 's/^.\///'` ; do test "$$f" == "Release" && continue ; echo -n " " ; sha256sum $$f | sed "s/ / `stat -c %s $$f` /" ; done >> Release gpg --batch --passphrase "$(GPG_PASSPHRASE)" --digest-algo SHA256 -b -a tmp/debian-s3/dists/stable/Release mv tmp/debian-s3/dists/stable/Release.asc tmp/debian-s3/dists/stable/Release.gpg gpg --batch --passphrase "$(GPG_PASSPHRASE)" --digest-algo SHA512 --clearsign tmp/debian-s3/dists/stable/Release mv tmp/debian-s3/dists/stable/Release.asc tmp/debian-s3/dists/stable/InRelease aws s3 sync tmp/debian-s3/ s3://tendermint-packages/debian/ --delete --acl public-read @echo "*** Uploaded $*-$($*_version)-$(BUILD_NUMBER)_amd64.deb to AWS Debian repository" mostlyclean: rm -rf {BUILDROOT,SOURCES,SPECS,SRPMS,tmp} clean: mostlyclean rm -rf {BUILD,RPMS} distclean: clean rm -rf $(GOPATH)/src/github.com/tendermint/tendermint rm -rf $(GOPATH)/src/github.com/tendermint/basecoin rm -rf $(GOPATH)/src/github.com/tendermint/ethermint rm -rf $(GOPATH)/src/github.com/tendermint/trackomatron rm -rf $(GOPATH)/bin/tendermint rm -rf $(GOPATH)/bin/basecoin rm -rf $(GOPATH)/bin/basecli rm -rf $(GOPATH)/bin/ethermint rm -rf $(GOPATH)/bin/tracko rm -rf $(GOPATH)/bin/trackocli .PHONY : clean