From 94a00856f51788075e26642d1fe42783ff472135 Mon Sep 17 00:00:00 2001 From: Ken Gaillot Date: Mon, 21 Nov 2022 11:27:24 -0600 Subject: [PATCH 1/4] Doc: abi-check: bail if not in git checkout --- doc/abi-check.in | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/abi-check.in b/doc/abi-check.in index 168ab0c42ba..5a5e253f74f 100755 --- a/doc/abi-check.in +++ b/doc/abi-check.in @@ -1,4 +1,13 @@ #!@BASH_PATH@ +# +# Copyright 2011-2022 the Pacemaker project contributors +# +# The version control history for this file may have further details. +# +# This source code is licensed under the GNU General Public License version 2 +# or later (GPLv2+) WITHOUT ANY WARRANTY. +# + # # abi-check [-u] [...] # @@ -113,6 +122,15 @@ extract_all() { done } +die() { + echo "$@" 1>&2 + exit 1 +} + +which git 2>/dev/null || die "abi-check: git must be installed" +git rev-parse --git-dir >/dev/null 2>/dev/null \ + || die "abi-check: must be run from git checkout" + UPLOAD=0 if [ "$1" = "-u" ]; then UPLOAD=1; shift From 981e5351ddd1052eea8d49ab53c44617d126a3f1 Mon Sep 17 00:00:00 2001 From: Ken Gaillot Date: Mon, 21 Nov 2022 11:41:20 -0600 Subject: [PATCH 2/4] Build: release.mk: don't output git errors when setting release variables ... in case we're not in a git checkout. Also, add a CHECKOUT variable to know when we're in a git checkout, replace the LAST_FINAL variable with a reasonable default for VERSION, and improve comments and formatting. --- mk/release.mk | 63 ++++++++++++++++++++++++++++++++++++------------- rpm/Makefile.am | 5 ++-- 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/mk/release.mk b/mk/release.mk index 9e4df2e166c..5b679109c73 100644 --- a/mk/release.mk +++ b/mk/release.mk @@ -1,5 +1,5 @@ # -# Copyright 2008-2021 the Pacemaker project contributors +# Copyright 2008-2022 the Pacemaker project contributors # # The version control history for this file may have further details. # @@ -9,27 +9,56 @@ # Define variables related to release version and such -COMMIT ?= HEAD +COMMIT ?= HEAD -# TAG defaults to DIST when not in a git checkout (e.g. from a distribution), +# TAG defaults to DIST when in a source distribution instead of a git checkout, # the tag name if COMMIT is tagged, and the full commit ID otherwise. -TAG ?= $(shell T=$$(git describe --tags --exact-match '$(COMMIT)' 2>/dev/null); \ - test -n "$${T}" && echo "$${T}" \ - || git log --pretty=format:%H -n 1 '$(COMMIT)' 2>/dev/null || echo DIST) +TAG ?= $(shell \ + T=$$(git describe --tags --exact-match '$(COMMIT)' 2>/dev/null); \ + [ -n "$${T}" ] && echo "$${T}" \ + || git log --pretty=format:%H -n 1 '$(COMMIT)' 2>/dev/null \ + || echo DIST) # If DIRTY=anything is passed to make, generated versions will end in ".mod" -# as long as there are uncommitted changes and COMMIT is not set. -DIRTY_EXT = $(shell if [ -n "$(DIRTY)" ] && [ "$(COMMIT)" == "HEAD" ] \ - && ! git diff-index --quiet HEAD --; then \ - echo .mod ; fi) +# as long as there are uncommitted changes and COMMIT is not changed from the +# default. +DIRTY_EXT = $(shell [ -n "$(DIRTY)" ] \ + && [ "$(COMMIT)" == "HEAD" ] \ + && ! git diff-index --quiet HEAD -- 2>/dev/null \ + && echo .mod) +# These can be used in case statements to avoid make interpreting parentheses lparen = ( rparen = ) -LAST_RC ?= $(shell git tag -l|sed -n -e 's/^\(Pacemaker-[0-9.]*-rc[0-9]*\)$$/\1/p'|sort -Vr|head -n 1) -LAST_FINAL ?= $(shell git tag -l|sed -n -e 's/^\(Pacemaker-[0-9.]*\)$$/\1/p'|sort -Vr|head -n 1) -LAST_RELEASE ?= $(shell test "Pacemaker-$(VERSION)" = "Pacemaker-" && echo "$(LAST_FINAL)" || echo "Pacemaker-$(VERSION)") -NEXT_RELEASE ?= $(shell echo $(LAST_RELEASE) | awk -F. '/[0-9]+\./{$$3+=1;OFS=".";print $$1,$$2,$$3}') +# git tag of highest-versioned release candidate (such as "Pacemaker-2.1.5-rc2") +# or empty if not in git checkout +LAST_RC ?= $(shell git tag -l 2>/dev/null \ + | sed -n -e 's/^\(Pacemaker-[0-9.]*-rc[0-9]*\)$$/\1/p' \ + | sort -Vr | head -n 1) + +# true if in a git checkout +CHECKOUT = $(shell git rev-parse --git-dir >/dev/null 2>/dev/null \ + && echo true) + +# VERSION is set by configure, but we allow some make targets to be run without +# running configure first, so set a reasonable default in that case. +VERSION ?= $(shell if [ -z "$(CHECKOUT)" ]; then \ + echo 0.0.0; \ + else \ + git tag -l \ + | sed -n -e 's/^\(Pacemaker-[0-9.]*\)$$/\1/p' \ + | sort -Vr | head -n 1; \ + fi) + +# What the git tag would be for configured VERSION (such as "Pacemaker-2.1.5") +LAST_RELEASE ?= Pacemaker-$(VERSION) + +# What the git tag would be for configured VERSION with minor-minor version bump +# (such as "Pacemaker-2.1.6"; this should be manually overriden when bumping +# the major or minor version) +NEXT_RELEASE ?= $(shell echo $(LAST_RELEASE) \ + | awk -F. '/[0-9]+\./{$$3+=1;OFS=".";print $$1,$$2,$$3}') # We have two make targets for creating distributions: # @@ -43,9 +72,9 @@ NEXT_RELEASE ?= $(shell echo $(LAST_RELEASE) | awk -F. '/[0-9]+\./{$$3+=1;OFS=". # Both targets use the same name for the result, though they generate different # contents. # -# The directory is named pacemaker-DIST when not in a git checkout (e.g. -# from a distribution itself), pacemaker- for tagged -# commits, and pacemaker- otherwise. +# The directory is named pacemaker-DIST when in a source distribution instead +# of a git checkout, pacemaker- for tagged commits, and +# pacemaker- otherwise. top_distdir = $(PACKAGE)-$(shell \ case $(TAG) in \ DIST$(rparen) \ diff --git a/rpm/Makefile.am b/rpm/Makefile.am index a901d3f1941..39e6df24489 100644 --- a/rpm/Makefile.am +++ b/rpm/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2003-2021 the Pacemaker project contributors +# Copyright 2003-2022 the Pacemaker project contributors # # The version control history for this file may have further details. # @@ -238,12 +238,13 @@ mock-clean: # Make debugging makefile issues easier vars: + @echo "CHECKOUT=$(CHECKOUT)" + @echo "VERSION=$(VERSION)" @echo "COMMIT=$(COMMIT)" @echo "TAG=$(TAG)" @echo "DIRTY=$(DIRTY)" @echo "DIRTY_EXT=$(DIRTY_EXT)" @echo "LAST_RC=$(LAST_RC)" - @echo "LAST_FINAL=$(LAST_FINAL)" @echo "LAST_RELEASE=$(LAST_RELEASE)" @echo "NEXT_RELEASE=$(NEXT_RELEASE)" @echo "top_distdir=$(top_distdir)" From 56a2f7d69df96cbe471b99d5ae4e56ffdebee3fe Mon Sep 17 00:00:00 2001 From: Ken Gaillot Date: Mon, 21 Nov 2022 12:12:18 -0600 Subject: [PATCH 3/4] Build: rpm: restore ability to build RPMs without a git checkout regression introduced in 2.1.2 by a3c5ca5741e --- rpm/Makefile.am | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/rpm/Makefile.am b/rpm/Makefile.am index 39e6df24489..9622e82cdd6 100644 --- a/rpm/Makefile.am +++ b/rpm/Makefile.am @@ -113,9 +113,16 @@ MOCK_CFG ?= $(shell test -e /etc/fedora-release && echo fedora-$(F)-$(ARCH)) distdir = $(top_distdir)/rpm TARFILE = $(abs_builddir)/../$(top_distdir).tar.gz +# Create a source distribution based on a git archive. (If we aren't in a git +# checkout, do a make dist instead.) export: cd $(abs_srcdir)/..; \ - if [ -n "$(DIRTY_EXT)" ]; then \ + if [ -z "$(CHECKOUT)" ] && [ -f "$(TARFILE)" ]; then \ + echo "`date`: Using existing tarball: $(TARFILE)"; \ + elif [ -z "$(CHECKOUT)" ]; then \ + $(MAKE) $(AM_MAKEFLAGS) dist; \ + echo "`date`: Rebuilt tarball: $(TARFILE)"; \ + elif [ -n "$(DIRTY_EXT)" ]; then \ git commit -m "DO-NOT-PUSH" -a; \ git archive --prefix=$(top_distdir)/ -o "$(TARFILE)" HEAD^{tree}; \ git reset --mixed HEAD^; \ @@ -188,7 +195,12 @@ release: .PHONY: rc rc: - $(MAKE) $(AM_MAKEFLAGS) TAG=$(LAST_RC) rpm + if [ -n "$(LAST_RC)" ]; then \ + @echo 'rc can only be used in git checkout'; \ + false; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) TAG=$(LAST_RC) rpm; \ + fi .PHONY: chroot chroot: mock-$(MOCK_CFG) mock-install-$(MOCK_CFG) mock-sh-$(MOCK_CFG) From 5df0932ce72e2d30a7b8969aa724d1ab85f1d384 Mon Sep 17 00:00:00 2001 From: Ken Gaillot Date: Mon, 21 Nov 2022 14:15:49 -0600 Subject: [PATCH 4/4] Build: rpm: use correct tarfile name when in source distribution --- mk/release.mk | 9 +++++---- rpm/pacemaker.spec.in | 10 ++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/mk/release.mk b/mk/release.mk index 5b679109c73..9bf96515045 100644 --- a/mk/release.mk +++ b/mk/release.mk @@ -72,13 +72,14 @@ NEXT_RELEASE ?= $(shell echo $(LAST_RELEASE) \ # Both targets use the same name for the result, though they generate different # contents. # -# The directory is named pacemaker-DIST when in a source distribution instead -# of a git checkout, pacemaker- for tagged commits, and -# pacemaker- otherwise. +# The directory is named pacemaker- when in a source distribution +# instead of a git checkout, pacemaker- for tagged +# commits, and pacemaker- otherwise. top_distdir = $(PACKAGE)-$(shell \ case $(TAG) in \ DIST$(rparen) \ - echo DIST;; \ + [ -n "$(VERSION)" ] && echo "$(VERSION)" \ + || echo DIST;; \ Pacemaker-*$(rparen) \ echo '$(TAG)' | cut -c11-;; \ *$(rparen) \ diff --git a/rpm/pacemaker.spec.in b/rpm/pacemaker.spec.in index 21dd8835bda..49f9f42f9f0 100644 --- a/rpm/pacemaker.spec.in +++ b/rpm/pacemaker.spec.in @@ -117,6 +117,15 @@ echo 0.%{specversion}.${c: -3} ;; *%{rparen} echo %{specversion} ;; esac) %else +%if "%{commit}" == "DIST" +%define archive_version %{pcmkversion} +%define archive_github_url %{archive_version}#/%{name}-%{pcmkversion}.tar.gz +%if %{with pre_release} +%define pcmk_release 0.%{specversion} +%else +%define pcmk_release %{specversion} +%endif +%else %define archive_version %(c=%{commit}; echo ${c:0:%{commit_abbrev}}) %define archive_github_url %{archive_version}#/%{name}-%{archive_version}.tar.gz %if %{with pre_release} @@ -125,6 +134,7 @@ %define pcmk_release %{specversion}.%{archive_version}.git %endif %endif +%endif ## Whether this platform defaults to using systemd as an init system ## (needs to be evaluated prior to BuildRequires being enumerated and