[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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 redhat com>
---
 .gitignore                                  |   16 +++++++-
 Makefile                                    |   17 --------
 Makefile.am                                 |   45 +++++++++++++++++++++
 autogen.sh                                  |   58 +++++++++++++++++++++++++++
 configure.ac                                |   11 +++++
 ovirt-release.spec => ovirt-release.spec.in |   16 +++----
 ovirt.mk                                    |   18 +++------
 release.mk                                  |   58 ---------------------------
 version                                     |    1 -
 9 files changed, 142 insertions(+), 98 deletions(-)
 delete mode 100644 Makefile
 create mode 100644 Makefile.am
 create mode 100755 autogen.sh
 create mode 100644 configure.ac
 rename ovirt-release.spec => ovirt-release.spec.in (77%)
 delete mode 100644 release.mk
 delete mode 100644 version

diff --git a/.gitignore b/.gitignore
index 5895b46..ad65319 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,15 @@
-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-release*.gz
+ovirt-release.spec
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 452ba45..0000000
--- a/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-pkg_name = ovirt-release
-subpackage_names = ovirt-build
-FILES = ovirt-release.spec ovirt.repo version ovirt.mk
-
-all: rpms
-include release.mk
-
-distclean: clean
-	rm -rf rpm-build
-
-clean:
-
-tar: clean
-	mkdir -p rpm-build
-	cp $(FILES) rpm-build/
-
-.PHONY: all clean tar
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..ede2cfd
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,45 @@
+# 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-release.spec		\
+  ovirt-release.spec.in		\
+  ovirt.mk					\
+  ovirt.repo				\
+  misc-scripts
+
+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)")
+# FEDORA_URL env var can be set to the root of a fedora mirror
+RPM_FLAGS	+= $(if $(FEDORA_URL),--define "fedora_url $(FEDORA_URL)")
+# OVIRT_URL env var can be set to the root of an ovirt.org mirror
+RPM_FLAGS	+= $(if $(OVIRT_URL),--define "ovirt_url $(OVIRT_URL)")
+
+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
+
+.PHONY: rpms publish
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..cca9761
--- /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-release.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..c053339
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,11 @@
+AC_INIT([ovirt-release], [0.93], [ovirt-devel 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-release.spec)
diff --git a/ovirt-release.spec b/ovirt-release.spec.in
similarity index 77%
rename from ovirt-release.spec
rename to ovirt-release.spec.in
index 851f5b1..8dd05de 100644
--- a/ovirt-release.spec
+++ b/ovirt-release.spec.in
@@ -1,11 +1,9 @@
 Summary:        ovirt.org Repository Configuration
 Name:           ovirt-release
-Source0:        ovirt.repo
-Source1:        version
-Source2:        ovirt.mk
-Version:        %(echo `awk '{ print $1 }' %{SOURCE1}`)
-Release:        %(echo `awk '{ print $2 }' %{SOURCE1}`)%{?dist}%{?extra_release}
-License:        GPLv2
+Version:        @VERSION@
+Release:        0%{?git_release}%{?dist}%{?extra_release}
+Source0:        %{name}-%{version}.tar.gz
+License:        GPLv2+
 Group:          System Environment/Base
 URL:            http://ovirt.org
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -28,7 +26,7 @@ Developer makefile and scripts to help automate the building of
 oVirt from source repositories.
 
 %prep
-%setup -c -T
+%setup -q
 
 %build
 
@@ -36,9 +34,9 @@ oVirt from source repositories.
 %{__rm} -rf %{buildroot}
 
 install -dm 755 %{buildroot}%{_sysconfdir}/yum.repos.d
-install -pm 644 %{SOURCE0} %{buildroot}%{_sysconfdir}/yum.repos.d
+install -pm 644 ovirt.repo %{buildroot}%{_sysconfdir}/yum.repos.d
 install -dm 755 %{buildroot}%{app_build_root}
-install -pm 644 %{SOURCE2} %{buildroot}%{app_build_root}
+install -pm 644 ovirt.mk %{buildroot}%{app_build_root}
 
 %clean
 %{__rm} -rf %{buildroot}
diff --git a/ovirt.mk b/ovirt.mk
index df5e0a0..a2f1da8 100644
--- a/ovirt.mk
+++ b/ovirt.mk
@@ -1,7 +1,3 @@
-# The version/release used for the SRPM tarball is the appliance
-VERSION		= $(shell awk '{ print $$1 }' appliance/version)
-RELEASE		= $(shell awk '{ print $$2 }' appliance/version)
-
 # For read-only access
 OVIRT_GIT_SERVER ?= git://ovirt.org
 # For users with write access
@@ -39,7 +35,7 @@ define for_each_subdir
   done
 endef
 
-all: dev-build
+all: build
 
 update: $(SUBDIRS)
 
@@ -51,7 +47,7 @@ $(SUBDIRS):
 	@cd $@ && git config format.subjectprefix "PATCH $@"
 	@cd $@ && git pull -v && git checkout $(OVIRT_BRANCH)
 
-clean distclean bumpgit:
+clean distclean:
 	@$(for_each_subdir)
 
 status diff branch:
@@ -73,13 +69,11 @@ publish:
 	rm -f rpms
 	ln -s $(OVIRT_CACHE_DIR)/ovirt rpms
 
-dev-build: bumpgit build
-
 update-host:
 	@cd $(OVIRT_CACHE_DIR)/ovirt && \
 	  sudo yum localinstall -y --nogpgcheck \
-	    ovirt-appliance-*$(shell uname -i).rpm \
-	    ovirt-build-*noarch.rpm ovirt-release-*noarch.rpm
+	  noarch/ovirt-build-*noarch.rpm noarch/ovirt-release-*noarch.rpm \
+	  $(shell uname -i)/ovirt-appliance-*$(shell uname -i).rpm
 
 tar-src:
 	@mkdir -p $(OVIRT_CACHE_DIR)
@@ -108,7 +102,7 @@ tar-src:
 	cd $(OVIRT_CACHE_DIR) && \
 	  $(BUILD_DIR)/release/misc-scripts/getsrpms.py $(SRC_KS) $(OVIRT_CACHE_DIR)/yum
 	cd $(OVIRT_CACHE_DIR)/source && \
-	  tar cf ovirt-source-$(VERSION)-$(RELEASE).tar SRPMS
+	  tar cf ovirt-source.tar SRPMS
 
 .PHONY: all build clean distclean publish $(SUBDIRS) update status \
-	bumpgit dev-build tar-src
+	dev-build tar-src
diff --git a/release.mk b/release.mk
deleted file mode 100644
index d618404..0000000
--- a/release.mk
+++ /dev/null
@@ -1,58 +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
-	+for subpackage_name in $(subpackage_names); do \
-		rm -f $(OVIRT_CACHE_DIR)/ovirt/$${subpackage_name}*.rpm ; \
-		cp -a rpm-build/$${subpackage_name}*.rpm $(OVIRT_CACHE_DIR)/ovirt ; \
-	done
-	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 4395223..0000000
--- a/version
+++ /dev/null
@@ -1 +0,0 @@
-0.92 4
-- 
1.5.5.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]