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

[Ovirt-devel] [PATCH appliance] 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                                      |    8 +---
 Makefile.am                                     |   43 ++++++++++-------
 autogen.sh                                      |    2 +-
 configure.ac                                    |    5 +-
 ovirt-appliance.spec => ovirt-appliance.spec.in |    7 +--
 release.mk                                      |   55 -----------------------
 version                                         |    1 -
 7 files changed, 33 insertions(+), 88 deletions(-)
 rename ovirt-appliance.spec => ovirt-appliance.spec.in (96%)
 delete mode 100644 release.mk
 delete mode 100644 version

diff --git a/.gitignore b/.gitignore
index 895edc4..a30b920 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,10 +11,6 @@ config.status
 configure
 install-sh
 missing
-ovirt-appliance-*.tar.gz
-ovirt-appliance-sda.qcow
-ovirt-appliance-sda.raw
-ovirt-appliance.xml
-repos.ks
 stamp-h1
-rpm-build
+ovirt-appliance-*.tar.gz
+ovirt-appliance.spec
diff --git a/Makefile.am b/Makefile.am
index a3553c2..61ec901 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,30 +15,37 @@
 # MA  02110-1301, USA.  A copy of the GNU General Public License is
 # also available at http://www.gnu.org/copyleft/gpl.html.
 
-EXTRA_DIST =			\
-  .gitignore			\
-  common-install.ks		\
-  common-pkgs.ks		\
-  common-post.ks		\
+OVIRT_CACHE_DIR	?= $(HOME)/ovirt-cache
+
+EXTRA_DIST =				\
+  .gitignore				\
+  common-install.ks			\
+  common-pkgs.ks			\
+  common-post.ks			\
   create-ovirt-appliance	\
-  gettree.sh			\
+  gettree.sh				\
   ovirt-appliance.ks		\
   ovirt-appliance.spec		\
-  release.mk			\
-  version
+  ovirt-appliance.spec.in
 
-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)")
 # 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)")
 # SKIP_COMPRESS_IMAGE env var an be set to 1 to skip qcow compression
-RPM_FLAGS += \
-  --define "fedora_url $(FEDORA_URL)" \
-  --define "ovirt_url $(OVIRT_URL)" \
-  --define "skip_compress_image $(SKIP_COMPRESS_IMAGE)"
+RPM_FLAGS	+= $(if $(SKIP_COMPRESS_IMAGE),--define "skip_compress_image $(SKIP_COMPRESS_IMAGE)")
+
+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
 
-pkg_name = $(PACKAGE_NAME)
-.PHONY: tar
-tar: dist
-	mkdir -p rpm-build/BUILDROOT
-	cp version $(distdir).tar.gz rpm-build
+.PHONY: rpms publish
diff --git a/autogen.sh b/autogen.sh
index 0d2c99c..8e77f25 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -35,7 +35,7 @@ THEDIR=`pwd`
 
   test $die = 1 && exit 1
 
-  test -f ovirt-appliance.spec || {
+  test -f ovirt-appliance.spec.in || {
 	  echo "You must run this script in the top-level directory"
 	  exit 1
   }
diff --git a/configure.ac b/configure.ac
index 3f0fa6e..160463e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,5 @@
-# note: the version number here is overridden by the one in release.mk
-AC_INIT([ovirt-appliance], [0.1], [ovirt-devel redhat com])
+AC_INIT([ovirt-appliance], [0.93], [ovirt-devel redhat com])
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 
 AC_CONFIG_FILES([Makefile])
-AC_OUTPUT
+AC_OUTPUT(ovirt-appliance.spec)
diff --git a/ovirt-appliance.spec b/ovirt-appliance.spec.in
similarity index 96%
rename from ovirt-appliance.spec
rename to ovirt-appliance.spec.in
index 8a2158e..a919d9a 100644
--- a/ovirt-appliance.spec
+++ b/ovirt-appliance.spec.in
@@ -8,11 +8,10 @@
 
 Summary: oVirt Appliance
 Name: ovirt-appliance
-Source1: version
-Version: %(echo `awk '{ print $1 }' %{SOURCE1}`)
-Release: %(echo `awk '{ print $2 }' %{SOURCE1}`)%{?dist}
+Version: @VERSION@
+Release: 0%{?git_release}%{?dist}%{?extra_release}
 Source0: %{name}-%{version}.tar.gz
-License: Fedora
+License: GPLv2+
 Group: Applications/System
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
 URL: http://ovirt.org/
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


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