2016-11-18 06:21:20 +08:00
|
|
|
# Makefile for constructing RPMs.
|
|
|
|
# Try "make" (for SRPMS) or "make rpm"
|
|
|
|
|
|
|
|
NAME = ceph-ansible
|
2017-03-08 02:01:15 +08:00
|
|
|
|
|
|
|
# Set the RPM package NVR from "git describe".
|
|
|
|
# Examples:
|
|
|
|
#
|
2018-01-12 01:06:21 +08:00
|
|
|
# A "git describe" value of "v2.2.0beta1" would create an NVR
|
2019-02-20 04:32:27 +08:00
|
|
|
# "ceph-ansible-2.2.0-0.beta1.1.el8"
|
2018-01-12 01:06:21 +08:00
|
|
|
#
|
2017-03-08 02:01:15 +08:00
|
|
|
# A "git describe" value of "v2.2.0rc1" would create an NVR
|
2019-02-20 04:32:27 +08:00
|
|
|
# "ceph-ansible-2.2.0-0.rc1.1.el8"
|
2017-03-08 02:01:15 +08:00
|
|
|
#
|
|
|
|
# A "git describe" value of "v2.2.0rc1-1-gc465f85" would create an NVR
|
2019-02-20 04:32:27 +08:00
|
|
|
# "ceph-ansible-2.2.0-0.rc1.1.gc465f85.el8"
|
2017-03-08 02:01:15 +08:00
|
|
|
#
|
|
|
|
# A "git describe" value of "v2.2.0" creates an NVR
|
2019-02-20 04:32:27 +08:00
|
|
|
# "ceph-ansible-2.2.0-1.el8"
|
2017-03-08 02:01:15 +08:00
|
|
|
|
2019-10-23 22:45:41 +08:00
|
|
|
DIST ?= "el8"
|
2022-02-02 18:09:55 +08:00
|
|
|
MOCK_CONFIG ?= "centos+epel-8-x86_64"
|
2018-05-11 07:08:05 +08:00
|
|
|
TAG := $(shell git describe --tags --abbrev=0 --match 'v*')
|
|
|
|
VERSION := $(shell echo $(TAG) | sed 's/^v//')
|
2016-11-18 06:21:20 +08:00
|
|
|
COMMIT := $(shell git rev-parse HEAD)
|
|
|
|
SHORTCOMMIT := $(shell echo $(COMMIT) | cut -c1-7)
|
|
|
|
RELEASE := $(shell git describe --tags --match 'v*' \
|
|
|
|
| sed 's/^v//' \
|
|
|
|
| sed 's/^[^-]*-//' \
|
|
|
|
| sed 's/-/./')
|
|
|
|
ifeq ($(VERSION),$(RELEASE))
|
2017-03-08 02:11:53 +08:00
|
|
|
RELEASE = 1
|
2016-11-18 06:21:20 +08:00
|
|
|
endif
|
2019-11-08 17:38:32 +08:00
|
|
|
ifneq (,$(findstring alpha,$(VERSION)))
|
|
|
|
ALPHA := $(shell echo $(VERSION) | sed 's/.*alpha/alpha/')
|
|
|
|
RELEASE := 0.$(ALPHA).$(RELEASE)
|
|
|
|
VERSION := $(subst $(ALPHA),,$(VERSION))
|
|
|
|
endif
|
2018-01-12 01:06:21 +08:00
|
|
|
ifneq (,$(findstring beta,$(VERSION)))
|
|
|
|
BETA := $(shell echo $(VERSION) | sed 's/.*beta/beta/')
|
|
|
|
RELEASE := 0.$(BETA).$(RELEASE)
|
|
|
|
VERSION := $(subst $(BETA),,$(VERSION))
|
|
|
|
endif
|
2017-03-08 02:01:15 +08:00
|
|
|
ifneq (,$(findstring rc,$(VERSION)))
|
|
|
|
RC := $(shell echo $(VERSION) | sed 's/.*rc/rc/')
|
|
|
|
RELEASE := 0.$(RC).$(RELEASE)
|
|
|
|
VERSION := $(subst $(RC),,$(VERSION))
|
|
|
|
endif
|
2018-05-11 04:39:07 +08:00
|
|
|
|
|
|
|
ifneq (,$(shell echo $(VERSION) | grep [a-zA-Z]))
|
|
|
|
# If we still have alpha characters in our Git tag string, we don't know
|
|
|
|
# how to translate that into a sane RPM version/release. Bail out.
|
|
|
|
$(error cannot translate Git tag version $(VERSION) to an RPM NVR)
|
|
|
|
endif
|
|
|
|
|
2019-10-23 22:45:41 +08:00
|
|
|
NVR := $(NAME)-$(VERSION)-$(RELEASE).$(DIST)
|
2016-11-18 06:21:20 +08:00
|
|
|
|
|
|
|
all: srpm
|
|
|
|
|
|
|
|
# Testing only
|
|
|
|
echo:
|
|
|
|
echo COMMIT $(COMMIT)
|
|
|
|
echo VERSION $(VERSION)
|
|
|
|
echo RELEASE $(RELEASE)
|
|
|
|
echo NVR $(NVR)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf dist/
|
|
|
|
rm -rf ceph-ansible-$(VERSION)-$(SHORTCOMMIT).tar.gz
|
|
|
|
rm -rf $(NVR).src.rpm
|
|
|
|
|
|
|
|
dist:
|
|
|
|
git archive --format=tar.gz --prefix=ceph-ansible-$(VERSION)/ HEAD > ceph-ansible-$(VERSION)-$(SHORTCOMMIT).tar.gz
|
|
|
|
|
|
|
|
spec:
|
|
|
|
sed ceph-ansible.spec.in \
|
|
|
|
-e 's/@COMMIT@/$(COMMIT)/' \
|
|
|
|
-e 's/@VERSION@/$(VERSION)/' \
|
|
|
|
-e 's/@RELEASE@/$(RELEASE)/' \
|
|
|
|
> ceph-ansible.spec
|
|
|
|
|
|
|
|
srpm: dist spec
|
2017-09-13 06:59:44 +08:00
|
|
|
rpmbuild -bs ceph-ansible.spec \
|
|
|
|
--define "_topdir ." \
|
|
|
|
--define "_sourcedir ." \
|
|
|
|
--define "_srcrpmdir ." \
|
2019-10-23 22:45:41 +08:00
|
|
|
--define "dist .$(DIST)"
|
2016-11-18 06:21:20 +08:00
|
|
|
|
|
|
|
rpm: dist srpm
|
2019-10-23 22:45:41 +08:00
|
|
|
mock -r $(MOCK_CONFIG) rebuild $(NVR).src.rpm \
|
2016-11-18 06:21:20 +08:00
|
|
|
--resultdir=. \
|
2019-10-23 22:45:41 +08:00
|
|
|
--define "dist .$(DIST)"
|
2016-11-18 06:21:20 +08:00
|
|
|
|
2018-05-11 07:08:05 +08:00
|
|
|
tag:
|
|
|
|
$(eval BRANCH := $(shell git rev-parse --abbrev-ref HEAD))
|
|
|
|
$(eval LASTNUM := $(shell echo $(TAG) \
|
|
|
|
| sed -E "s/.*[^0-9]([0-9]+)$$/\1/"))
|
|
|
|
$(eval NEXTNUM=$(shell echo $$(($(LASTNUM)+1))))
|
|
|
|
$(eval NEXTTAG=$(shell echo $(TAG) | sed "s/$(LASTNUM)$$/$(NEXTNUM)/"))
|
2018-05-31 17:25:49 +08:00
|
|
|
if [[ "$(TAG)" == "$(git describe --tags --match 'v*')" ]]; then \
|
2018-05-11 07:08:05 +08:00
|
|
|
echo "$(SHORTCOMMIT) on $(BRANCH) is already tagged as $(TAG)"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
if [[ "$(BRANCH)" != "master" ]] && \
|
|
|
|
! [[ "$(BRANCH)" =~ ^stable- ]]; then \
|
|
|
|
echo Cannot tag $(BRANCH); \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
@echo Tagging Git branch $(BRANCH)
|
|
|
|
git tag $(NEXTTAG)
|
|
|
|
@echo run \'git push origin $(NEXTTAG)\' to push to GitHub.
|
|
|
|
|
|
|
|
.PHONY: dist rpm srpm tag
|