From b1da643ad5def4651b088b5e0f49d8edabb6c720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= Date: Fri, 29 May 2015 16:51:20 +0200 Subject: [PATCH] Makefile: added support for nightly development builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is supported by 'nightly' makefile target. It creates snapshot from the GIT HEAD, makes mockbuild, creates repo and uploads result on the fedorapeople. Also fixed makefile to support parallel builds, added couple of hopefully useful targets, implemented local RPM build target 'rpm'. Other targets (e.g. 'srpm') can be also used to work with snapshots. It is controlled by BUILD makefile varible. If set to 'release' normal release is done. If set to anything else (e.g. 'snapshot') snapshot is done. There is also support for GIT snapshots in the upstream provided SPEC file. Snapshot build is done if built with '--with snapshot', normal (release) build is done otherwise. Signed-off-by: Jaroslav Škarvada --- Makefile | 75 +++++++++++++++++++++++++++++++++++++++++------------- tuned.spec | 9 +++---- 2 files changed, 62 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 022878c..91165a6 100644 --- a/Makefile +++ b/Makefile @@ -1,39 +1,86 @@ NAME = tuned +# set to devel for nightly GIT snapshot +BUILD = release +# which config to use in mock-build target +MOCK_CONFIG = rhel-7-x86_64 VERSION = $(shell awk '/^Version:/ {print $$2}' tuned.spec) -RELEASE = $(shell awk '/^Release:/ {print $$2}' tuned.spec) +ifeq ($(BUILD), release) + RPM_ARGS += --without snapshot + MOCK_ARGS += --without=snapshot + RPM_VERSION = $(NAME)-$(VERSION)-1 +else + RPM_ARGS += --with snapshot + MOCK_ARGS += --with=snapshot + GIT_SHORT_COMMIT = $(shell git rev-parse --short=8 --verify HEAD) + GIT_DATE = $(shell date +'%Y%m%d') + GIT_SUFFIX = $(GIT_DATE)git$(GIT_SHORT_COMMIT) + GIT_PSUFFIX = .$(GIT_SUFFIX) + RPM_VERSION = $(NAME)-$(VERSION)-1$(GIT_PSUFFIX) +endif UNITDIR = $(shell rpm --eval '%{_unitdir}' 2>/dev/null || echo /usr/lib/systemd/system) TMPFILESDIR = $(shell rpm --eval '%{_tmpfilesdir}' 2>/dev/null || echo /usr/lib/tmpfiles.d) -VERSIONED_NAME = $(NAME)-$(VERSION) +VERSIONED_NAME = $(NAME)-$(VERSION)$(GIT_PSUFFIX) DOCDIR = /usr/share/doc/$(NAME) PYTHON_SITELIB = $(shell python -c 'from distutils.sysconfig import get_python_lib; print get_python_lib();' || echo /usr/lib/python2.7/site-packages) TUNED_PROFILESDIR = /usr/lib/tuned BASH_COMPLETIONS = /usr/share/bash-completion/completions -archive: clean +release-dir: mkdir -p $(VERSIONED_NAME) - cp AUTHORS COPYING INSTALL README $(VERSIONED_NAME) +release-cp: release-dir + cp -a AUTHORS COPYING INSTALL README $(VERSIONED_NAME) - cp tuned.py tuned.spec tuned.service tuned.tmpfiles Makefile tuned-adm.py \ + cp -a tuned.py tuned.spec tuned.service tuned.tmpfiles Makefile tuned-adm.py \ tuned-adm.bash dbus.conf recommend.conf tuned-main.conf 00_tuned \ bootcmdline org.tuned.gui.policy tuned-gui.py tuned-gui.glade \ $(VERSIONED_NAME) cp -a doc experiments libexec man profiles systemtap tuned contrib $(VERSIONED_NAME) +archive: clean release-cp tar cjf $(VERSIONED_NAME).tar.bz2 $(VERSIONED_NAME) -srpm: archive +rpm-build-dir: mkdir rpm-build-dir + +srpm: archive rpm-build-dir rpmbuild --define "_sourcedir `pwd`/rpm-build-dir" --define "_srcrpmdir `pwd`/rpm-build-dir" \ - --define "_specdir `pwd`/rpm-build-dir" --nodeps -ts $(VERSIONED_NAME).tar.bz2 + --define "_specdir `pwd`/rpm-build-dir" --nodeps $(RPM_ARGS) -ts $(VERSIONED_NAME).tar.bz2 -build: - # nothing to build +build: archive rpm-build-dir + rpmbuild --define "_sourcedir `pwd`/rpm-build-dir" --define "_srcrpmdir `pwd`/rpm-build-dir" \ + --define "_specdir `pwd`/rpm-build-dir" --nodeps $(RPM_ARGS) -tb $(VERSIONED_NAME).tar.bz2 -install: - # library +clean-mock-result-dir: + rm -f mock-result-dir/* + +mock-result-dir: clean-mock-result-dir + mkdir mock-result-dir + +mock-build: srpm + mock -r $(MOCK_CONFIG) $(MOCK_ARGS) --resultdir=`pwd`/mock-result-dir `ls rpm-build-dir/*$(RPM_VERSION).*.src.rpm | head -n 1`&& \ + rm -f mock-result-dir/*.log + +mock-devel-build: srpm + mock -r $(MOCK_CONFIG) --with=snapshot --resultdir=`pwd`/mock-result-dir `ls rpm-build-dir/*$(RPM_VERSION).*.src.rpm | head -n 1`&& \ + rm -f mock-result-dir/*.log + +createrepo: mock-devel-build + createrepo mock-result-dir + +nightly: createrepo + scp `mock-result-dir-dir/*` jskarvad@fedorapeople.org:/home/fedora/jskarvad/public_html/tuned/devel/repo/ + +install-dirs: mkdir -p $(DESTDIR)$(PYTHON_SITELIB) + mkdir -p $(DESTDIR)$(TUNED_PROFILESDIR) + mkdir -p $(DESTDIR)/var/log/tuned + mkdir -p $(DESTDIR)/run/tuned + mkdir -p $(DESTDIR)$(DOCDIR) + +install: install-dirs + # library cp -a tuned $(DESTDIR)$(PYTHON_SITELIB) # binaries @@ -56,18 +103,13 @@ install: install -Dpm 0644 bootcmdline $(DESTDIR)/etc/tuned/bootcmdline # profiles & system config - mkdir -p $(DESTDIR)$(TUNED_PROFILESDIR) cp -a profiles/* $(DESTDIR)$(TUNED_PROFILESDIR)/ install -pm 0644 recommend.conf $(DESTDIR)$(TUNED_PROFILESDIR)/recommend.conf # bash completion install -Dpm 0644 tuned-adm.bash $(DESTDIR)$(BASH_COMPLETIONS)/tuned-adm - # log dir - mkdir -p $(DESTDIR)/var/log/tuned - # runtime directory - mkdir -p $(DESTDIR)/run/tuned install -Dpm 0644 tuned.tmpfiles $(DESTDIR)$(TMPFILESDIR)/tuned.conf # systemd units @@ -87,7 +129,6 @@ install: install -Dpm 0644 $(file) $(DESTDIR)/usr/share/man/man$(man_section)/$(notdir $(file));)) # documentation - mkdir -p $(DESTDIR)$(DOCDIR) cp -a doc/* $(DESTDIR)$(DOCDIR) cp AUTHORS COPYING README $(DESTDIR)$(DOCDIR) diff --git a/tuned.spec b/tuned.spec index 90582e2..5f4f55e 100644 --- a/tuned.spec +++ b/tuned.spec @@ -1,16 +1,15 @@ -%bcond_with release +%bcond_with snapshot -%if %{without release} -%global git_commit %(git rev-parse --verify HEAD) +%if %{with snapshot} +%global git_short_commit %(git rev-parse --short=8 --verify HEAD) %global git_date %(date +'%Y%m%d') -%global git_short_commit %(echo %{git_commit} | cut -c -8) %global git_suffix %{git_date}git%{git_short_commit} %endif Summary: A dynamic adaptive system tuning daemon Name: tuned Version: 2.4.1 -Release: 1%{!?with_release:.%{git_suffix}}%{?dist} +Release: 1%{?with_snapshot:.%{git_suffix}}%{?dist} License: GPLv2+ Source: https://fedorahosted.org/releases/t/u/tuned/tuned-%{version}.tar.bz2 URL: https://fedorahosted.org/tuned/