From 0e1e6f38d65920827a86682fb0ef0d658eb835f4 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Wed, 26 Aug 2020 06:00:57 +0000 Subject: [PATCH] [rpm/deb] query version/release from git tag Signed-off-by: Leo Chen --- Makefile | 29 +++++++++++++++-------------- scripts/package/rpm/harmony.spec | 5 +++-- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 26bdb7e00..1b289e31b 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,8 @@ export LIBRARY_PATH:=$(LD_LIBRARY_PATH) export DYLD_FALLBACK_LIBRARY_PATH:=$(LD_LIBRARY_PATH) export GO111MODULE:=on PKGNAME=harmony -VERSION?=2.3.6 +VERSION?=$(shell git tag -l --sort=-v:refname | head -n 1 | tr -d v) +RELEASE?=$(shell git describe | cut -f2 -d-) RPMBUILD=$(HOME)/rpmbuild DEBBUILD=$(HOME)/debbuild SHELL := bash @@ -88,19 +89,19 @@ arm_static: deb_init: rm -rf $(DEBBUILD) - mkdir -p $(DEBBUILD)/$(PKGNAME)-$(VERSION)/{etc/systemd/system,usr/sbin,etc/sysctl.d,etc/harmony} - cp -f bin/harmony $(DEBBUILD)/$(PKGNAME)-$(VERSION)/usr/sbin/ - bin/harmony dumpconfig $(DEBBUILD)/$(PKGNAME)-$(VERSION)/etc/harmony/harmony.conf - cp -f scripts/package/rclone.conf $(DEBBUILD)/$(PKGNAME)-$(VERSION)/etc/harmony/ - cp -f scripts/package/harmony.service $(DEBBUILD)/$(PKGNAME)-$(VERSION)/etc/systemd/system/ - cp -f scripts/package/harmony-setup.sh $(DEBBUILD)/$(PKGNAME)-$(VERSION)/usr/sbin/ - cp -f scripts/package/harmony-rclone.sh $(DEBBUILD)/$(PKGNAME)-$(VERSION)/usr/sbin/ - cp -f scripts/package/harmony-sysctl.conf $(DEBBUILD)/$(PKGNAME)-$(VERSION)/etc/sysctl.d/99-harmony.conf - cp -r scripts/package/deb/DEBIAN $(DEBBUILD)/$(PKGNAME)-$(VERSION) - VER=$(VERSION) scripts/package/templater.sh scripts/package/deb/DEBIAN/control > $(DEBBUILD)/$(PKGNAME)-$(VERSION)/DEBIAN/control + mkdir -p $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/{etc/systemd/system,usr/sbin,etc/sysctl.d,etc/harmony} + cp -f bin/harmony $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/usr/sbin/ + bin/harmony dumpconfig $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/etc/harmony/harmony.conf + cp -f scripts/package/rclone.conf $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/etc/harmony/ + cp -f scripts/package/harmony.service $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/etc/systemd/system/ + cp -f scripts/package/harmony-setup.sh $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/usr/sbin/ + cp -f scripts/package/harmony-rclone.sh $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/usr/sbin/ + cp -f scripts/package/harmony-sysctl.conf $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/etc/sysctl.d/99-harmony.conf + cp -r scripts/package/deb/DEBIAN $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE) + VER=$(VERSION)-$(RELEASE) scripts/package/templater.sh scripts/package/deb/DEBIAN/control > $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/DEBIAN/control deb_build: - (cd $(DEBBUILD); dpkg-deb --build $(PKGNAME)-$(VERSION)/) + (cd $(DEBBUILD); dpkg-deb --build $(PKGNAME)-$(VERSION)-$(RELEASE)/) deb: deb_init deb_build @@ -123,14 +124,14 @@ rpm_init: cp -f scripts/package/harmony-rclone.sh $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION) cp -f scripts/package/rclone.conf $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION) cp -f scripts/package/harmony-sysctl.conf $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION) - VER=$(VERSION) scripts/package/templater.sh scripts/package/rpm/harmony.spec > $(RPMBUILD)/SPECS/harmony.spec + VER=$(VERSION) REL=$(RELEASE) scripts/package/templater.sh scripts/package/rpm/harmony.spec > $(RPMBUILD)/SPECS/harmony.spec (cd $(RPMBUILD)/SOURCES; tar cvf $(PKGNAME)-$(VERSION).tar $(PKGNAME)-$(VERSION)) rpm_build: rpmbuild --target x86_64 -bb $(RPMBUILD)/SPECS/harmony.spec rpm: rpm_init rpm_build - rpm --addsign $(RPMBUILD)/RPMS/x86_64/$(PKGNAME)-$(VERSION)-0.x86_64.rpm + rpm --addsign $(RPMBUILD)/RPMS/x86_64/$(PKGNAME)-$(VERSION)-$(RELEASE).x86_64.rpm rpmpub_dev: rpm ./scripts/package/publish-repo.sh -p dev -n rpm -s $(RPMBUILD) diff --git a/scripts/package/rpm/harmony.spec b/scripts/package/rpm/harmony.spec index 757bf1fa6..9ff93c9b1 100644 --- a/scripts/package/rpm/harmony.spec +++ b/scripts/package/rpm/harmony.spec @@ -1,4 +1,5 @@ {{VER=2.0.0}} +{{REL=0}} # SPEC file overview: # https://docs.fedoraproject.org/en-US/quick-docs/creating-rpm-packages/#con_rpm-spec-file-overview # Fedora packaging guidelines: @@ -6,14 +7,14 @@ Name: harmony Version: {{ VER }} -Release: 0 +Release: {{ REL }} Summary: harmony blockchain validator node program License: MIT URL: https://harmony.one Source0: %{name}-%{version}.tar BuildArch: x86_64 -Packager: Leo Chen +Packager: Leo Chen Requires(pre): shadow-utils Requires: systemd-rpm-macros