aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2015-11-16 08:57:27 +0100
committerGuido Günther <agx@sigxcpu.org>2015-11-16 08:57:27 +0100
commitbfe32f19e7a2a24b93b36467772254583c34b6ff (patch)
tree73691e068c34f3348a1dcf0274c45313627b9929 /bin
parent82a847df8a04f598dafa31af46b9493255a6f033 (diff)
buildpackage-rpm: add support for mock chroot builder
Try: gbp buildpackage-rpm --git-mock --git-dist=epel-6 Results will be under ../rpmbuild/results/ This is very heavily based on a patch from Tzafrir Cohen.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/gbp-builder-mock86
1 files changed, 86 insertions, 0 deletions
diff --git a/bin/gbp-builder-mock b/bin/gbp-builder-mock
new file mode 100755
index 00000000..1e934936
--- /dev/null
+++ b/bin/gbp-builder-mock
@@ -0,0 +1,86 @@
+#!/bin/sh
+#
+# Helper to invoke mock from 'gbp buildpackage-rpm'
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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, please see
+# <http://www.gnu.org/licenses/>
+#
+# Copyright (C) 2015 Tzafrir Cohen
+# (C) 2015 Guido Günther
+
+set -e
+
+# There must be a saner way to do that or a reason why this is not required
+fix_arch() {
+ GBP_BUILDER_MOCK_ARCH=${GBP_BUILDER_MOCK_ARCH:-`uname -m`}
+ case "$ARCH" in
+ amd64) ARCH='x86_64';;
+ esac
+}
+
+
+usage() {
+ EXIT=${1:-1}
+ echo >&2 "$0: Must be run via 'gbp buildpackage-rpm', see manpage for details"
+ exit $EXIT
+}
+
+while [ $# != 0 ]; do
+ case "$1" in
+ --help|-h|-?) usage 0;;
+ *.spec) SPEC="$1";;
+ esac
+ shift
+done
+
+# Make sure we have the necessary tools.
+if [ ! -x /usr/bin/mock ]; then
+ echo "mock not found; you need to install the mock package" >&2
+ exit 1
+fi
+
+gbp_builder_mock() {
+ if [ -z "$GBP_BUILDER_MOCK_DIST" ]; then
+ usage
+ fi
+ local root=${GBP_BUILDER_MOCK_ROOT:-${GBP_BUILDER_MOCK_DIST}-${GBP_BUILDER_MOCK_ARCH}}
+ if [ ! -d "$GBP_BUILDER_MOCK_EXPORT_DIR" ]; then
+ echo >&2 "$0: Missing output directory (GBP_BUILDER_MOCK_EXPORT_DIR). Aborting."
+ usage
+ fi
+ if [ -z "$SPEC" ]; then
+ echo >&2 "$0: No specfile given."
+ exit 1
+ fi
+ export_dir="$PWD"
+ spec="$export_dir/SPECS/$SPEC"
+ sources="$export_dir/SOURCES"
+ srpms="$export_dir/SRPMS"
+ pat="${GBP_BUILDER_MOCK_RESULTS_PAT-results/%(dist)s/%(target_arch)s/}"
+ local resultdir="$export_dir/$pat"
+ local mock="mock -r $root --resultdir=$srpms --spec=$spec --sources=$sources"
+
+ $mock --buildsrpm
+ # Assuming that nothing was built in this directory since the previous command:
+ local srpm=`ls -t $PWD/SRPMS/*.src.rpm 2>/dev/null| head -n1`
+ if [ -z $srpm ]; then
+ echo >&2 "$0: failed to create srpm"
+ exit 1
+ fi
+ $mock --no-cleanup-after --resultdir $resultdir --rebuild "$srpm"
+}
+
+
+fix_arch
+gbp_builder_mock