[Ovirt-devel] [PATCH node] Restructured makefile and rpmbuilding to simplify it

Perry Myers pmyers at redhat.com
Thu Sep 18 21:59:45 UTC 2008


Removed customized rpm macros that should really be set by users
~/.rpmmacros directory.  This removed need for custom tar target,
as we can now use dist and rpmbuild -ta instead.

Still need to have custom RPM_FLAGS for ovirt specific overrides
like OVIRT_CACHE_DIR (used by appliance and node-image spec files)

Removed unused bumprelease, bumpversion and setversion targets
Removed other unused make variables
Simplified publish to just rsync all RPMS frpm the rpmdir.
Added seconds granularity to git tag for bumpgit target.

Made it so version file is no longer edited by makefile.
Instead configure.ac file is used to store version.  For
developers setting OVIRT_DEV env var causes extra_dist to be
passed to rpmbuild adding the git tag onto the RPM.

Signed-off-by: Perry Myers <pmyers at redhat.com>
---
 .gitignore                            |    2 +-
 Makefile.am                           |   25 +++++++++-----
 autogen.sh                            |    2 +-
 configure.ac                          |    5 +--
 ovirt-node.spec => ovirt-node.spec.in |    7 ++--
 release.mk                            |   55 ---------------------------------
 version                               |    1 -
 7 files changed, 23 insertions(+), 74 deletions(-)
 rename ovirt-node.spec => ovirt-node.spec.in (96%)
 delete mode 100644 release.mk
 delete mode 100644 version

diff --git a/.gitignore b/.gitignore
index 7824d79..26a0210 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,5 +11,5 @@ depcomp
 install-sh
 missing
 stamp-h1
-rpm-build
 ovirt-node*.gz
+ovirt-node.spec
diff --git a/Makefile.am b/Makefile.am
index f9478db..be1ba52 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,16 +15,16 @@
 # MA  02110-1301, USA.  A copy of the GNU General Public License is
 # also available at http://www.gnu.org/copyleft/gpl.html.
 
+OVIRT_CACHE_DIR	?= $(HOME)/ovirt-cache
 SUBDIRS = ovirt-identify-node ovirt-listen-awake
 
 EXTRA_DIST =			\
   .gitignore			\
   ovirt-node.spec		\
-  release.mk			\
-  version			\
+  ovirt-node.spec.in	\
   scripts/collectd		\
   scripts/collectd.conf.in	\
-  scripts/ovirt			\
+  scripts/ovirt				\
   scripts/ovirt-awake		\
   scripts/ovirt-early		\
   scripts/ovirt-functions	\
@@ -32,10 +32,17 @@ EXTRA_DIST =			\
   logrotate/ovirt-logrotate	\
   logrotate/ovirt-logrotate.conf
 
-include release.mk
+git_head	= $$(git log -1 --pretty=format:%h)
+GIT_RELEASE	= $$(date --utc +%Y%m%d%H%M%S)git$(git_head)
+RPMDIR		= $$(rpm --eval '%{_rpmdir}')
+RPM_FLAGS	= --define "ovirt_cache_dir $(OVIRT_CACHE_DIR)"
+RPM_FLAGS	+= $(if $(OVIRT_DEV),--define "git_release .$(GIT_RELEASE)")
 
-pkg_name = $(PACKAGE_NAME)
-.PHONY: tar
-tar: dist
-	mkdir -p rpm-build/BUILDROOT
-	cp version $(distdir).tar.gz rpm-build
+rpms: dist
+	rpmbuild $(RPM_FLAGS) -ta $(distdir).tar.gz
+
+publish: rpms
+	rsync -aq --delete $(shell rpm --eval '%{_rpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/
+	createrepo $(OVIRT_CACHE_DIR)/ovirt
+
+.PHONY: rpms publish
diff --git a/autogen.sh b/autogen.sh
index b8828fe..d018b64 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -35,7 +35,7 @@ THEDIR=`pwd`
 
   test $die = 1 && exit 1
 
-  test -f ovirt-node.spec || {
+  test -f ovirt-node.spec.in || {
 	  echo "You must run this script in the top-level directory"
 	  exit 1
   }
diff --git a/configure.ac b/configure.ac
index c7a274f..6a36910 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,4 @@
-# note: the version number here is overridden by the one in release.mk
-AC_INIT([ovirt-node], [0.1], [ovirt-devel at redhat.com])
+AC_INIT([ovirt-node], [0.92], [ovirt-devel at redhat.com])
 AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability])
 AC_PROG_CC
 AC_CONFIG_HEADERS([config.h])
@@ -14,4 +13,4 @@ test x"$ac_ct_CC:$CFLAGS" = 'xgcc:-g -O2' \
   && CFLAGS="$CFLAGS -Wshadow -Wall -Werror"
 
 AC_CONFIG_FILES([Makefile ovirt-identify-node/Makefile ovirt-listen-awake/Makefile])
-AC_OUTPUT
+AC_OUTPUT(ovirt-node.spec)
diff --git a/ovirt-node.spec b/ovirt-node.spec.in
similarity index 96%
rename from ovirt-node.spec
rename to ovirt-node.spec.in
index 303d353..92905fd 100644
--- a/ovirt-node.spec
+++ b/ovirt-node.spec.in
@@ -1,10 +1,9 @@
 Summary:        The oVirt Node daemons/scripts
 Name:           ovirt-node
-Source1:        version
-Version:        %(echo `awk '{ print $1 }' %{SOURCE1}`)
-Release:        %(echo `awk '{ print $2 }' %{SOURCE1}`)%{?dist}%{?extra_release}
+Version:        @VERSION@
+Release:        0%{?git_release}%{?dist}%{?extra_release}
 Source0:        %{name}-%{version}.tar.gz
-License:        GPL
+License:        GPLv2+
 Group:          Applications/System
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-buildroot
diff --git a/release.mk b/release.mk
deleted file mode 100644
index 7d9ddd0..0000000
--- a/release.mk
+++ /dev/null
@@ -1,55 +0,0 @@
-# Release/version-related Makefile variables and rules.
-# It expects the including Makefile to define the "pkg_name" 
-# variable, as well as a file named "version" in the current directory.
-
-srcdir		?= .
-ARCH		= $(shell uname -i)
-VERSION		= $(shell awk '{ print $$1 }' $(srcdir)/version)
-RELEASE		= $(shell awk '{ print $$2 }' $(srcdir)/version)
-NEWVERSION	= $$(awk 'BEGIN { printf "%.2f", $(VERSION) + .01 }')
-NEWRELEASE	= $$(($(RELEASE) + 1))
-X		= $$(awk '{ split($$2,r,"."); \
-			  printf("%d.%d\n", r[1], r[2]+1) }' $(srcdir)/version)
-git_head	= $$(git log -1 --pretty=format:%h)
-GITRELEASE	= $(X).$$(date --utc +%Y%m%d%H%M)git$(git_head)
-DIST		= $$(rpm --eval '%{dist}')
-
-SPEC_FILE	= $(pkg_name).spec
-
-OVIRT_CACHE_DIR	?= $(HOME)/ovirt-cache
-
-NV		= $(pkg_name)-$(VERSION)
-RPM_FLAGS	= \
-  --define "_topdir	%(pwd)/rpm-build" \
-  --define "_builddir	%{_topdir}" \
-  --define "_rpmdir	%{_topdir}" \
-  --define "_srcrpmdir	%{_topdir}" \
-  --define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' \
-  --define "_specdir	%{_topdir}" \
-  --define "_sourcedir	%{_topdir}" \
-  --define "ovirt_cache_dir $(OVIRT_CACHE_DIR)"
-
-bumpgit:
-	echo "$(VERSION) $(GITRELEASE)" > version
-
-bumprelease:
-	echo "$(VERSION) $(NEWRELEASE)" > version
-
-bumpversion:
-	echo "$(NEWVERSION) 1" > version
-
-setversion:
-	echo "$(VERSION) $(RELEASE)" > version
-
-new-rpms: bumprelease rpms
-
-rpms: tar
-	rpmbuild $(RPM_FLAGS) -ba $(SPEC_FILE)
-
-publish: rpms
-	rm -f $(OVIRT_CACHE_DIR)/ovirt/$(pkg_name)*
-	mkdir -p $(OVIRT_CACHE_DIR)/ovirt
-	cp -a rpm-build/$(pkg_name)*.rpm $(OVIRT_CACHE_DIR)/ovirt
-	createrepo $(OVIRT_CACHE_DIR)/ovirt
-
-.PHONY: rpms new-rpms publish setversion bumprelease bumpversion bumpgit
diff --git a/version b/version
deleted file mode 100644
index 187ac7a..0000000
--- a/version
+++ /dev/null
@@ -1 +0,0 @@
-0.92 1
-- 
1.5.5.1




More information about the ovirt-devel mailing list