From 443c5591a0fac3ef21c9db2d2fccec863c793dd7 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Mon, 10 Apr 2017 11:28:07 -0400 Subject: [PATCH] SPEC file: sync how we build snapshot and release packages Downstream (Fedora and EPEL) RPM packages have had a different way of building release (by default) and snapshot packages by editing the SPEC file. Let's sync with them, while also allowing snapshot packages to be built from our usual `make rpm` command. Release builds are still supported with `make rpm-release`. Signed-off-by: Cleber Rosa --- Makefile | 14 ++++++++------ python-avocado.spec | 37 ++++++++++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 8c6529c7..35a384b0 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ AVOCADO_PLUGINS=$(AVOCADO_OPTIONAL_PLUGINS) $(AVOCADO_EXTERNAL_PLUGINS) RELEASE_COMMIT=$(shell git log --pretty=format:'%H' -n 1 $(VERSION)) RELEASE_SHORT_COMMIT=$(shell git log --pretty=format:'%h' -n 1 $(VERSION)) COMMIT=$(shell git log --pretty=format:'%H' -n 1) +COMMIT_DATE=$(shell git log --pretty='format:%cd' --date='format:%Y%m%d' -n 1) SHORT_COMMIT=$(shell git log --pretty=format:'%h' -n 1) MOCK_CONFIG=default @@ -64,11 +65,11 @@ all: source: clean if test ! -d SOURCES; then mkdir SOURCES; fi - git archive --prefix="avocado-$(COMMIT)/" -o "SOURCES/avocado-$(VERSION)-$(SHORT_COMMIT).tar.gz" HEAD + git archive --prefix="avocado-$(COMMIT)/" -o "SOURCES/avocado-$(SHORT_COMMIT).tar.gz" HEAD source-release: clean if test ! -d SOURCES; then mkdir SOURCES; fi - git archive --prefix="avocado-$(RELEASE_COMMIT)/" -o "SOURCES/avocado-$(VERSION)-$(RELEASE_SHORT_COMMIT).tar.gz" $(VERSION) + git archive --prefix="avocado-$(VERSION)/" -o "SOURCES/avocado-$(VERSION).tar.gz" $(VERSION) source-pypi: clean if test ! -d PYPI_UPLOAD; then mkdir PYPI_UPLOAD; fi @@ -103,19 +104,19 @@ install: srpm: source if test ! -d BUILD/SRPM; then mkdir -p BUILD/SRPM; fi - mock -r $(MOCK_CONFIG) --resultdir BUILD/SRPM -D "commit $(COMMIT)" --buildsrpm --spec python-avocado.spec --sources SOURCES + mock -r $(MOCK_CONFIG) --resultdir BUILD/SRPM -D "rel_build 0" -D "commit $(COMMIT)" -D "commit_date $(COMMIT_DATE)" --buildsrpm --spec python-avocado.spec --sources SOURCES rpm: srpm if test ! -d BUILD/RPM; then mkdir -p BUILD/RPM; fi - mock -r $(MOCK_CONFIG) --resultdir BUILD/RPM -D "commit $(COMMIT)" --rebuild BUILD/SRPM/python-avocado-$(VERSION)-*.src.rpm + mock -r $(MOCK_CONFIG) --resultdir BUILD/RPM -D "rel_build 0" -D "commit $(COMMIT)" -D "commit_date $(COMMIT_DATE)" --rebuild BUILD/SRPM/python-avocado-$(VERSION)-*.src.rpm srpm-release: source-release if test ! -d BUILD/SRPM; then mkdir -p BUILD/SRPM; fi - mock -r $(MOCK_CONFIG) --resultdir BUILD/SRPM -D "commit $(RELEASE_COMMIT)" --buildsrpm --spec python-avocado.spec --sources SOURCES + mock -r $(MOCK_CONFIG) --resultdir BUILD/SRPM -D "rel_build 1" --buildsrpm --spec python-avocado.spec --sources SOURCES rpm-release: srpm-release if test ! -d BUILD/RPM; then mkdir -p BUILD/RPM; fi - mock -r $(MOCK_CONFIG) --resultdir BUILD/RPM -D "commit $(RELEASE_COMMIT)" --rebuild BUILD/SRPM/python-avocado-$(VERSION)-*.src.rpm + mock -r $(MOCK_CONFIG) --resultdir BUILD/RPM -D "rel_build 1" --rebuild BUILD/SRPM/python-avocado-$(VERSION)-*.src.rpm clean: $(PYTHON) setup.py clean @@ -204,6 +205,7 @@ variables: @echo "RELEASE_COMMIT: $(RELEASE_COMMIT)" @echo "RELEASE_SHORT_COMMIT: $(RELEASE_SHORT_COMMIT)" @echo "COMMIT: $(COMMIT)" + @echo "COMMIT_DATE: $(COMMIT_DATE)" @echo "SHORT_COMMIT: $(SHORT_COMMIT)" @echo "MOCK_CONFIG: $(MOCK_CONFIG)" @echo "PYTHON_DEVELOP_ARGS: $(PYTHON_DEVELOP_ARGS)" diff --git a/python-avocado.spec b/python-avocado.spec index 6a4b067d..82c49eed 100644 --- a/python-avocado.spec +++ b/python-avocado.spec @@ -1,8 +1,24 @@ %global srcname avocado + +# Conditional for release vs. snapshot builds. Set to 1 for release build. +%if ! 0%{?rel_build:1} +%global rel_build 1 +%endif + +# Settings used for build from snapshots. +%if 0%{?rel_build} +%global gittar %{srcname}-%{version}.tar.gz +%else %if ! 0%{?commit:1} - %define commit 1d717446d28ff852fe5de895f14c7985c63ada3e +%global commit 817c25c2bbedb6d43e5fa2ad0a78698f1416ab49 +%endif +%if ! 0%{?commit_date:1} +%global commit_date 20170407 +%endif +%global shortcommit %(c=%{commit};echo ${c:0:7}) +%global gitrel .%{commit_date}git%{shortcommit} +%global gittar %{srcname}-%{shortcommit}.tar.gz %endif -%global shortcommit %(c=%{commit}; echo ${c:0:7}) # selftests are provided but may need to skipped because many of # functional tests are time and resource sensitive and can @@ -13,11 +29,15 @@ Summary: Framework with tools and libraries for Automated Testing Name: python-%{srcname} Version: 48.0 -Release: 1%{?dist} +Release: 2%{?gitrel}%{?dist} License: GPLv2 Group: Development/Tools URL: http://avocado-framework.github.io/ -Source0: https://github.com/avocado-framework/%{srcname}/archive/%{commit}/%{srcname}-%{version}-%{shortcommit}.tar.gz +%if 0%{?rel_build} +Source0: https://github.com/avocado-framework/%{srcname}/archive/%{version}.tar.gz#/%{gittar} +%else +Source0: https://github.com/avocado-framework/%{srcname}/archive/%{commit}.tar.gz#/%{gittar} +%endif BuildArch: noarch BuildRequires: fabric BuildRequires: procps-ng @@ -85,7 +105,11 @@ Avocado is a set of tools and libraries (what people call these days a framework) to perform automated testing. %prep +%if 0%{?rel_build} +%setup -q -n %{srcname}-%{version} +%else %setup -q -n %{srcname}-%{commit} +%endif # package plugins-runner-vm requires libvirt-python, but the RPM # version of libvirt-python does not publish the egg info and this # causes that dep to be attempted to be installed by pip @@ -259,7 +283,10 @@ examples of how to write tests on your own. %{_datadir}/avocado/wrappers %changelog -* Mon Apr 3 2017 Cleber Rosa - 48.0-1 +* Mon Apr 10 2017 Cleber Rosa - 48.0-2 +- Update how release and snapshot packages are built + +* Mon Apr 3 2017 Cleber Rosa - 48.0-1 - Updated exclude directives and files for optional plugins * Mon Apr 3 2017 Cleber Rosa - 48.0-0 -- GitLab