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

Perry Myers pmyers at redhat.com
Fri Sep 19 05:36:01 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                                |   19 +++++++--
 Makefile                                  |   30 ---------------
 Makefile.am                               |   43 +++++++++++++++++++++
 autogen.sh                                |   58 +++++++++++++++++++++++++++++
 configure.ac                              |   11 +++++
 ovirt-server.spec => ovirt-server.spec.in |    7 +--
 release.mk                                |   54 ---------------------------
 repos.ks.in                               |    3 -
 version                                   |    1 -
 9 files changed, 130 insertions(+), 96 deletions(-)
 delete mode 100644 Makefile
 create mode 100644 Makefile.am
 create mode 100755 autogen.sh
 create mode 100644 configure.ac
 rename ovirt-server.spec => ovirt-server.spec.in (97%)
 delete mode 100644 release.mk
 delete mode 100644 repos.ks.in
 delete mode 100644 version

diff --git a/.gitignore b/.gitignore
index d159812..0fd1d9b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,15 @@
-src/log/*
-src/tmp/*
-src/db/schema.rb
-rpm-build
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+config.h
+config.h.in
+config.log
+config.status
+configure
+depcomp
+install-sh
+missing
+stamp-h1
+ovirt-server*.gz
+ovirt-server.spec
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 5cd213f..0000000
--- a/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-pkg_name = ovirt-server
-
-all: rpms
-include release.mk
-
-clean:
-	rm -f ovirt*.gz ovirt*.rpm
-	rm -rf ovirt-server-* dist build
-
-distclean: clean
-	rm -rf rpm-build
-
-genlangs:
-	cd src; rake updatepo; rake makemo
-
-tar: clean
-	mkdir -p $(NV)
-	cp -a src conf scripts $(NV)
-	find $(NV) \( -name '*~' -o -name '#*#' \) -print0 | xargs --no-run-if-empty --null rm -vf
-	find $(NV)/src/tmp -type f -print0 | xargs --no-run-if-empty --null rm -vf
-	mkdir -p rpm-build
-	tar zcvf rpm-build/$(NV).tar.gz $(NV)
-	cp version rpm-build/
-	rm -rf $(NV)
-
-# convience method to simulate make install, not for production use
-install: rpms
-	rpm -Uvh rpm-build/ovirt-server-$(VERSION)-$(RELEASE)$(DIST).$(ARCH).rpm --force
-
-.PHONY: all clean distclean genlangs tar install
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..c9bf8b6
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,43 @@
+# Copyright (C) 2008 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# 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
+
+EXTRA_DIST =			\
+  .gitignore			\
+  ovirt-server.spec		\
+  ovirt-server.spec.in	\
+  scripts				\
+  conf					\
+  src
+
+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	= $(if $(OVIRT_DEV),--define "git_release .$(GIT_RELEASE)")
+
+rpms: dist
+	rpmbuild $(RPM_FLAGS) -ta $(distdir).tar.gz
+
+publish: rpms
+	rsync -aq $(shell rpm --eval '%{_rpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/
+	createrepo $(OVIRT_CACHE_DIR)/ovirt
+
+genlangs:
+	cd src && rake updatepo && rake makemo
+
+.PHONY: rpms publish genlangs
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..7f0ca85
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+# Run this to generate configure and Makefile
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+THEDIR=`pwd`
+(
+  cd $srcdir
+  die=0
+
+  (autoconf --version) < /dev/null > /dev/null 2>&1 || {
+	  echo
+	  echo "You must have autoconf installed."
+	  echo "Download the appropriate package for your distribution,"
+	  echo "or see http://www.gnu.org/software/autoconf"
+	  die=1
+  }
+
+  (libtool --version) < /dev/null > /dev/null 2>&1 || {
+	  echo
+	  echo "You must have libtool installed."
+	  echo "Download the appropriate package for your distribution,"
+	  echo "or see http://www.gnu.org/software/libtool"
+	  die=1
+  }
+
+  (automake --version) < /dev/null > /dev/null 2>&1 || {
+	  echo
+	  die=1
+	  echo "You must have automake installed."
+	  echo "Download the appropriate package for your distribution,"
+	  echo "or see http://www.gnu.org/software/automake"
+  }
+
+  test $die = 1 && exit 1
+
+  test -f ovirt-server.spec.in || {
+	  echo "You must run this script in the top-level directory"
+	  exit 1
+  }
+
+  if test -z "$*"; then
+	  echo "I am going to run ./configure with no arguments - if you wish "
+	  echo "to pass any to it, please specify them on the $0 command line."
+  fi
+
+  aclocal
+  autoheader
+  automake --add-missing
+  autoconf
+  ./configure "$@"
+)
+
+if test "x$OBJ_DIR" != x; then
+    mkdir -p "$OBJ_DIR"
+    cd "$OBJ_DIR"
+fi
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..2576a2d
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,11 @@
+AC_INIT([ovirt-server], [0.93], [ovirt-devel at redhat.com])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability])
+AC_PROG_CC
+AC_CONFIG_HEADERS([config.h])
+
+# If using gcc and default CFLAGS, enable some warnings.
+test x"$ac_ct_CC:$CFLAGS" = 'xgcc:-g -O2' \
+  && CFLAGS="$CFLAGS -Wshadow -Wall -Werror"
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT(ovirt-server.spec)
diff --git a/ovirt-server.spec b/ovirt-server.spec.in
similarity index 97%
rename from ovirt-server.spec
rename to ovirt-server.spec.in
index 749189d..34e615c 100644
--- a/ovirt-server.spec
+++ b/ovirt-server.spec.in
@@ -3,14 +3,13 @@
 
 Summary: oVirt Server Suite
 Name: ovirt-server
-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
 #Entire source code is GPL except for vendor/plugins/will_paginate and 
 #vendor/plugins/betternestedset, which are MIT, and
 #public/javascripts/jquery.*, which is both MIT and GPL
-License: GPL and MIT
+License: GPLv2+ and MIT
 Group: Applications/System
 Requires: ruby >= 1.8.1
 Requires: ruby(abi) = 1.8
diff --git a/release.mk b/release.mk
deleted file mode 100644
index b89bd86..0000000
--- a/release.mk
+++ /dev/null
@@ -1,54 +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.
-
-ARCH		:= $(shell uname -i)
-VERSION		:= $(shell awk '{ print $$1 }' version)
-RELEASE		:= $(shell awk '{ print $$2 }' 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) }' 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/repos.ks.in b/repos.ks.in
deleted file mode 100644
index ba5ee20..0000000
--- a/repos.ks.in
+++ /dev/null
@@ -1,3 +0,0 @@
-repo --name=f9 --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-9&arch=$basearch
-repo --name=f9-updates --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f9&arch=$basearch
-repo --name=ovirt-org --baseurl=http://ovirt.org/repos/ovirt/9/$basearch
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