From: "Daniel P. Berrange" <berrange(a)redhat.com>
The
http://autobuild.org/ tool is a framework for doing automated
builds from upstream source, including builds of RPMs. The file
autobuild.sh is a simple script that integrates with this tool.
It can also be run directly by developers
export AUTOBUILD_INSTALL_ROOT=$HOME/builder
./autobuild.sh
* vdsm.spec.in: Add a unique counter for automated builds
* .gitignore: Ignore results.log file
* autobuild.sh: Add script for doing automated builds of source
and RPM
---
.gitignore | 1 +
autobuild.sh | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
vdsm.spec.in | 2 +-
3 files changed, 56 insertions(+), 1 deletions(-)
create mode 100755 autobuild.sh
diff --git a/.gitignore b/.gitignore
index acab38d..b273bb1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,3 +32,4 @@ vdsm_cli/vdsClient
vdsm_cli/vdscli.py
vdsm_reg/deployUtil.py
vdsm_reg/vdsm-reg.conf
+results.log
diff --git a/autobuild.sh b/autobuild.sh
new file mode 100755
index 0000000..d1020cd
--- /dev/null
+++ b/autobuild.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+set -e
+set -v
+
+# Make things clean.
+
+test -n "$1" && RESULTS=$1 || RESULTS=results.log
+: ${AUTOBUILD_INSTALL_ROOT=$HOME/builder}
+
+test -f Makefile && make -k distclean || :
+
+./autogen.sh --prefix="$AUTOBUILD_INSTALL_ROOT"
+
+# If the MAKEFLAGS envvar does not yet include a -j option,
+# add -jN where N depends on the number of processors.
+case $MAKEFLAGS in
+ *-j*) ;;
+ *) n=$(getconf _NPROCESSORS_ONLN 2> /dev/null)
+ test "$n" -gt 0 || n=1
+ n=$(expr $n + 1)
+ MAKEFLAGS="$MAKEFLAGS -j$n"
+ export MAKEFLAGS
+ ;;
+esac
+
+make
+make install
+
+# set -o pipefail is a bashism; this use of exec is the POSIX alternative
+exec 3>&1
+st=$(
+ exec 4>&1 >&3
+ { make check 2>&1 3>&- 4>&-; echo $? >&4; } | tee
"$RESULTS"
+)
+exec 3>&-
+test "$st" = 0
+
+rm -f *.tar.gz
+make dist
+
+if [ -n "$AUTOBUILD_COUNTER" ]; then
+ EXTRA_RELEASE=".auto$AUTOBUILD_COUNTER"
+else
+ NOW=`date +"%s"`
+ EXTRA_RELEASE=".$USER$NOW"
+fi
+
+if [ -f /usr/bin/rpmbuild ]; then
+ rpmbuild --nodeps \
+ --define "extra_release $EXTRA_RELEASE" \
+ --define "_sourcedir `pwd`" \
+ -ba --clean vdsm.spec
+fi
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 83d40e4..2ffbc02 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -10,7 +10,7 @@ Source: %{vdsm_name}-%{version}.tar.gz
# tarball built from internal git repo with
# make tarball rpmversion=<version> rpmrelease=<release>
Version: @PACKAGE_VERSION@
-Release: @PACKAGE_RELEASE@%{?dist}
+Release: @PACKAGE_RELEASE@%{?dist}%{?extra_release}
License: GPLv2+
Group: Applications/System
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
--
1.7.6