[rpm/deb] query version/release from git tag

Signed-off-by: Leo Chen <leo@harmony.one>
pull/3313/head
Leo Chen 4 years ago
parent b32c489ab3
commit 0e1e6f38d6
  1. 29
      Makefile
  2. 5
      scripts/package/rpm/harmony.spec

@ -6,7 +6,8 @@ export LIBRARY_PATH:=$(LD_LIBRARY_PATH)
export DYLD_FALLBACK_LIBRARY_PATH:=$(LD_LIBRARY_PATH) export DYLD_FALLBACK_LIBRARY_PATH:=$(LD_LIBRARY_PATH)
export GO111MODULE:=on export GO111MODULE:=on
PKGNAME=harmony 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 RPMBUILD=$(HOME)/rpmbuild
DEBBUILD=$(HOME)/debbuild DEBBUILD=$(HOME)/debbuild
SHELL := bash SHELL := bash
@ -88,19 +89,19 @@ arm_static:
deb_init: deb_init:
rm -rf $(DEBBUILD) rm -rf $(DEBBUILD)
mkdir -p $(DEBBUILD)/$(PKGNAME)-$(VERSION)/{etc/systemd/system,usr/sbin,etc/sysctl.d,etc/harmony} mkdir -p $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/{etc/systemd/system,usr/sbin,etc/sysctl.d,etc/harmony}
cp -f bin/harmony $(DEBBUILD)/$(PKGNAME)-$(VERSION)/usr/sbin/ cp -f bin/harmony $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/usr/sbin/
bin/harmony dumpconfig $(DEBBUILD)/$(PKGNAME)-$(VERSION)/etc/harmony/harmony.conf bin/harmony dumpconfig $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/etc/harmony/harmony.conf
cp -f scripts/package/rclone.conf $(DEBBUILD)/$(PKGNAME)-$(VERSION)/etc/harmony/ cp -f scripts/package/rclone.conf $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/etc/harmony/
cp -f scripts/package/harmony.service $(DEBBUILD)/$(PKGNAME)-$(VERSION)/etc/systemd/system/ cp -f scripts/package/harmony.service $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/etc/systemd/system/
cp -f scripts/package/harmony-setup.sh $(DEBBUILD)/$(PKGNAME)-$(VERSION)/usr/sbin/ cp -f scripts/package/harmony-setup.sh $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/usr/sbin/
cp -f scripts/package/harmony-rclone.sh $(DEBBUILD)/$(PKGNAME)-$(VERSION)/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)/etc/sysctl.d/99-harmony.conf 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) cp -r scripts/package/deb/DEBIAN $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)
VER=$(VERSION) scripts/package/templater.sh scripts/package/deb/DEBIAN/control > $(DEBBUILD)/$(PKGNAME)-$(VERSION)/DEBIAN/control VER=$(VERSION)-$(RELEASE) scripts/package/templater.sh scripts/package/deb/DEBIAN/control > $(DEBBUILD)/$(PKGNAME)-$(VERSION)-$(RELEASE)/DEBIAN/control
deb_build: deb_build:
(cd $(DEBBUILD); dpkg-deb --build $(PKGNAME)-$(VERSION)/) (cd $(DEBBUILD); dpkg-deb --build $(PKGNAME)-$(VERSION)-$(RELEASE)/)
deb: deb_init deb_build 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/harmony-rclone.sh $(RPMBUILD)/SOURCES/$(PKGNAME)-$(VERSION)
cp -f scripts/package/rclone.conf $(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) 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)) (cd $(RPMBUILD)/SOURCES; tar cvf $(PKGNAME)-$(VERSION).tar $(PKGNAME)-$(VERSION))
rpm_build: rpm_build:
rpmbuild --target x86_64 -bb $(RPMBUILD)/SPECS/harmony.spec rpmbuild --target x86_64 -bb $(RPMBUILD)/SPECS/harmony.spec
rpm: rpm_init rpm_build 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 rpmpub_dev: rpm
./scripts/package/publish-repo.sh -p dev -n rpm -s $(RPMBUILD) ./scripts/package/publish-repo.sh -p dev -n rpm -s $(RPMBUILD)

@ -1,4 +1,5 @@
{{VER=2.0.0}} {{VER=2.0.0}}
{{REL=0}}
# SPEC file overview: # SPEC file overview:
# https://docs.fedoraproject.org/en-US/quick-docs/creating-rpm-packages/#con_rpm-spec-file-overview # https://docs.fedoraproject.org/en-US/quick-docs/creating-rpm-packages/#con_rpm-spec-file-overview
# Fedora packaging guidelines: # Fedora packaging guidelines:
@ -6,14 +7,14 @@
Name: harmony Name: harmony
Version: {{ VER }} Version: {{ VER }}
Release: 0 Release: {{ REL }}
Summary: harmony blockchain validator node program Summary: harmony blockchain validator node program
License: MIT License: MIT
URL: https://harmony.one URL: https://harmony.one
Source0: %{name}-%{version}.tar Source0: %{name}-%{version}.tar
BuildArch: x86_64 BuildArch: x86_64
Packager: Leo Chen Packager: Leo Chen <leo@hamrony.one>
Requires(pre): shadow-utils Requires(pre): shadow-utils
Requires: systemd-rpm-macros Requires: systemd-rpm-macros

Loading…
Cancel
Save