Development builds are versioned using 'git describe' instead of static numbers extracted from spec file. This allows us to easily build new RPMs from every commit and deploy them to staging server (automatically some day).
Devel builds are created like this: `make mock DEVEL=1` --- Makefile | 86 ++++++++++++++++++++++++++++++++++++------------------------- 1 files changed, 51 insertions(+), 35 deletions(-)
diff --git a/Makefile b/Makefile index 8ddbc62..15cbc17 100644 --- a/Makefile +++ b/Makefile @@ -29,13 +29,11 @@ PYTHON=python # Packaging defaults WORKDIR := $(shell pwd)/build SRCRPMDIR = $(WORKDIR)/SRPMS -## SRCRPMDIR_MD5 = $(WORKDIR)/SRPMS_MD5 BUILDDIR = $(WORKDIR)/BUILD BUILDROOTDIR = $(WORKDIR)/BUILDROOT SOURCEDIR = $(WORKDIR)/SOURCES SPECDIR = $(WORKDIR)/SPECS RPMDIR = $(WORKDIR)/RPMS -## RPMDIR_MD5 = $(WORKDIR)/RPMS_MD5 MOCKDIR = $(WORKDIR)/MOCK RPM_DEFINES = --define "_specdir $(SPECDIR)" \ --define "_sourcedir $(SOURCEDIR)" \ @@ -48,8 +46,16 @@ EL5_DEFINES= --define "_source_filedigest_algorithm 1" \
# Variables used for packaging SPECFILE=autoqa.spec -BASEARCH=$(shell uname -i) -VERSION=$(shell echo `gawk '$$1~/^Version:/{print $$2}' $(SPECFILE)`) +BASEARCH:=$(shell uname -i) +VERSION:=$(shell echo `gawk '$$1~/^Version:/{print $$2}' $(SPECFILE)`) + +# Redefine VERSION if we are doing a development release +DEVEL= +ifneq (,$(DEVEL)) +GIT_DESC:=$(shell git describe --tags) +GIT_DESC:=$(subst -,_,$(GIT_DESC)) +VERSION:=$(VERSION)_devel_$(GIT_DESC) +endif
# If a DIST was provided, use it in all rpm commands ifneq (,$(DIST)) @@ -64,11 +70,6 @@ ifeq (,$(VER_REL)) $(error "Unable to parse $(SPECFILE) using 'rpm --specfile', is rpm-build package installed?") endif
-# Do the Makefile and SPECFILE agree? -ifneq ($(strip $(VERSION)),$(strip $(word 1, $(VER_REL)))) -$(error "VERSION in Makefile does not match VERSION in spec file") -endif - # Determine DIST DIST := $(shell rpm --eval '%{dist}') # Does the DIST provided look sane? @@ -80,9 +81,12 @@ endif RELEASE= $(subst $(DIST),,$(word 2,$(VER_REL)))
# Variables for requirements handling -REQS = $$(grep ^Requires: $(SPECFILE) | cut -d ' ' -f 2-) -BUILD_REQS = $$(grep ^BuildRequires: $(SPECFILE) | cut -d ' ' -f 2-) +REQS := $$(grep ^Requires: $(SPECFILE) | cut -d ' ' -f 2-) +BUILD_REQS := $$(grep ^BuildRequires: $(SPECFILE) | cut -d ' ' -f 2-)
+# +# Build and install +#
.PHONY: all
@@ -146,6 +150,10 @@ build: lib/autoqa/build lib/autoqa/build: ( cd lib/autoqa; $(PYTHON) setup.py build )
+# +# Test +# + test: bash runtests.sh
@@ -153,23 +161,31 @@ test: # Tarball #
-archive: $(SOURCEDIR)/autoqa-$(VERSION).tar.gz +nvr: + @echo autoqa-$(VERSION)-$(RELEASE)$(DIST)
-upload: $(SOURCEDIR)/autoqa-$(VERSION).tar.gz - @scp $(SOURCEDIR)/autoqa-$(VERSION).tar.gz fedorahosted.org:autoqa +# Extra level of indirection to allow for pre-processing (aka variable +# substitution) of the spec file +$(SPECDIR)/$(SPECFILE): $(SPECFILE) + @mkdir -p $(SPECDIR) + @cp $(SPECFILE) $(SPECDIR)/ + # change Version in DEVEL mode + if [ -n "$(DEVEL)" ]; then sed -i 's/^Version:.*/Version: $(VERSION)/' $(SPECDIR)/$(SPECFILE); fi + +archive: $(SOURCEDIR)/autoqa-$(VERSION).tar.gz
$(SOURCEDIR)/autoqa-$(VERSION).tar.gz: $(SPECDIR)/$(SPECFILE) [ -d .git ] # CHECKING TO SEE IF THIS IS A GIT TREE mkdir -p $(SOURCEDIR) git archive HEAD --prefix=autoqa-$(VERSION)/ | gzip -c9 > /$@
+upload: $(SOURCEDIR)/autoqa-$(VERSION).tar.gz + @scp $(SOURCEDIR)/autoqa-$(VERSION).tar.gz fedorahosted.org:autoqa + # -# BUILD RPMS either with or without the EL5_DEFINES (EPEL-5) +# List or install (build) requirements #
-nvr: - @echo autoqa-$(VERSION)-$(RELEASE)$(DIST) - list-requires: @echo "$(REQS)"
@@ -182,11 +198,9 @@ install-requires: install-buildrequires: (IFS=$$'\n'; yum install $$(echo "$(BUILD_REQS)"))
-# Extra level of indirection to allow for pre-processing (aka variable -# substitution) of the spec file -$(SPECDIR)/$(SPECFILE): $(SPECFILE) - @mkdir -p $(SPECDIR) - @cp $(SPECFILE) $(SPECDIR)/ +# +# Build RPMS +#
$(SRCRPMDIR)/autoqa-$(VERSION)-$(RELEASE).fc%.src.rpm: $(SPECDIR)/$(SPECFILE) $(SOURCEDIR)/autoqa-$(VERSION).tar.gz mkdir -p $(SRCRPMDIR) $(BUILDDIR) $(RPMDIR) @@ -207,8 +221,6 @@ $(RPMDIR)/noarch/autoqa-$(VERSION)-$(RELEASE).el%.noarch.rpm: $(SPECDIR)/$(SPECF srpm: $(SRCRPMDIR)/autoqa-$(VERSION)-$(RELEASE)$(DIST).src.rpm rpm: $(RPMDIR)/noarch/autoqa-$(VERSION)-$(RELEASE)$(DIST).noarch.rpm
-srpm.el5: $(SRCRPMDIR)/autoqa-$(VERSION)-$(RELEASE).el5.src.rpm -rpm.el5: $(RPMDIR)/noarch/autoqa-$(VERSION)-$(RELEASE).el5.noarch.rpm srpm.el6: $(SRCRPMDIR)/autoqa-$(VERSION)-$(RELEASE).el6.src.rpm rpm.el6: $(RPMDIR)/noarch/autoqa-$(VERSION)-$(RELEASE).el6.noarch.rpm
@@ -232,12 +244,13 @@ $(MOCKDIR)/$(RELEASEVER)-$(BASEARCH): $(SRCRPMDIR)/autoqa-$(VERSION)-$(RELEASE)$
mock: $(MOCKDIR)/$(RELEASEVER)-$(BASEARCH)
-mock.el5: - $(MAKE) DIST=.el5 mock - mock.el6: $(MAKE) DIST=.el6 mock
+# +# Help +# + help: @echo "Usage: make <target>" @echo @@ -251,11 +264,15 @@ help: @echo " upload Upload source tarball to https://fedorahosted.org/released/autoqa/" @echo @echo "RPM targets:" - @echo " srpm [DIST=<val>]" + @echo " srpm [DIST=<val>] [DEVEL=1]" @echo " Create a srpm ($(SRCRPMDIR)/autoqa-$(VERSION)-$(RELEASE)$(DIST).src.rpm)" - @echo " rpm [DIST=<val>]" - @echo " Create a rpm ($(RPMDIR)/noarch/autoqa-$(VERSION)-$(RELEASE)$(DIST).noarch.rpm" - @echo " nvr [DIST=<val>]" + @echo " DIST values are described at https://fedoraproject.org/wiki/Packaging:DistTag" + @echo " (defaults to current system)" + @echo " DEVEL=1 uses a development versioning scheme instead of" + @echo " extracting version from $(SPECFILE)" + @echo " rpm [DIST=<val>] [DEVEL=1]" + @echo " Create a rpm ($(RPMDIR)/noarch/autoqa-$(VERSION)-$(RELEASE)$(DIST).noarch.rpm)" + @echo " nvr [DIST=<val>] [DEVEL=1]" @echo " Display '%{name}-%{version}-%{release}' used for packaging" @echo " list-requires " @echo " List package requirements listed in $(SPECFILE)" @@ -267,9 +284,8 @@ help: @echo " Install package build dependencies listed in $(SPECFILE)" @echo @echo "MOCK build targets:" - @echo " mock [DIST=<val>]" - @echo " Build packages inside a mock chroot for the" - @echo " specified DIST (defaults to current system)" + @echo " mock [DIST=<val>] [DEVEL=1]" + @echo " Build packages inside a mock chroot for the specified DIST" @echo @echo "For guidance on building and releasing AutoQA, consult" @echo "https://fedoraproject.org/wiki/AutoQA_Release_Process"