From 19e12a595ef0f7e7d05d947998144c1020b84ecc Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Fri, 22 Jun 2018 13:24:19 +0200 Subject: [PATCH] Add git tag derived version to tarball and spec Stop hardcoding the version in the spec file, and put the version into dist tarballs. --- .gitignore | 1 + Makefile | 11 ++++++++--- ...it-starter-kit.spec => cockpit-starter-kit.spec.in | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) rename cockpit-starter-kit.spec => cockpit-starter-kit.spec.in (85%) diff --git a/.gitignore b/.gitignore index d5df499..32b6401 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.rpm node_modules/ dist/ +/*.spec /.vagrant package-lock.json Test*FAIL* diff --git a/Makefile b/Makefile index 1d3b02f..8bd3db7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ PACKAGE_NAME := $(shell python3 -c "import json; print(json.load(open('package.json'))['name'])") +VERSION := $(shell git describe 2>/dev/null || echo 1) ifeq ($(TEST_OS),) TEST_OS = centos-7 endif @@ -54,12 +55,16 @@ dist/po.%.js: po/%.po # Build/Install/dist # +%.spec: %.spec.in + sed -e 's/@VERSION@/$(VERSION)/g' $< > $@ + dist/index.js: node_modules/react-lite $(wildcard src/*) package.json webpack.config.js $(patsubst %,dist/po.%.js,$(LINGUAS)) NODE_ENV=$(NODE_ENV) npm run build clean: rm -rf dist/ rm -rf _install + rm -f $(PACKAGE_NAME).spec install: dist/index.js mkdir -p $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME) @@ -75,15 +80,15 @@ devel-install: dist/index.js # when building a distribution tarball, call webpack with a 'production' environment dist-gzip: NODE_ENV=production dist-gzip: clean all - tar czf cockpit-$(PACKAGE_NAME).tar.gz --transform 's,^,cockpit-$(PACKAGE_NAME)/,' $$(git ls-files) dist/ + tar czf cockpit-$(PACKAGE_NAME)-$(VERSION).tar.gz --transform 's,^,cockpit-$(PACKAGE_NAME)/,' $$(git ls-files) dist/ -srpm: dist-gzip +srpm: dist-gzip cockpit-$(PACKAGE_NAME).spec rpmbuild -bs \ --define "_sourcedir `pwd`" \ --define "_srcrpmdir `pwd`" \ cockpit-$(PACKAGE_NAME).spec -rpm: dist-gzip +rpm: dist-gzip cockpit-$(PACKAGE_NAME).spec mkdir -p "`pwd`/output" mkdir -p "`pwd`/rpmbuild" rpmbuild -bb \ diff --git a/cockpit-starter-kit.spec b/cockpit-starter-kit.spec.in similarity index 85% rename from cockpit-starter-kit.spec rename to cockpit-starter-kit.spec.in index 41a9dc5..373c770 100644 --- a/cockpit-starter-kit.spec +++ b/cockpit-starter-kit.spec.in @@ -1,10 +1,10 @@ Name: cockpit-starter-kit -Version: 1 +Version: @VERSION@ Release: 0 Summary: Cockpit Starter Kit Example Module License: LGPLv2.1+ -Source: cockpit-starter-kit.tar.gz +Source: cockpit-starter-kit-%{version}.tar.gz BuildArch: noarch %define debug_package %{nil}