[git-buildpackage] [PATCH 1/3] gbp-buildpackage-rpm: pass commands to mock

tzafrir at debian.org tzafrir at debian.org
Sat Jul 9 17:44:03 CEST 2016


From: Tzafrir Cohen <tzafrir at debian.org>

Fix gbp-buildpackage-rpm and the mock builder script to allow passing
extra command-line parameters to the mock wrapper build script.

Signed-off-by: Tzafrir Cohen <tzafrir at debian.org>
---
 bin/gbp-builder-mock                    | 13 ++++++++-----
 docs/manpages/gbp-buildpackage-rpm.sgml |  1 +
 gbp/scripts/buildpackage_rpm.py         |  9 +++++----
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/bin/gbp-builder-mock b/bin/gbp-builder-mock
index 1e93493..138353a 100755
--- a/bin/gbp-builder-mock
+++ b/bin/gbp-builder-mock
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Helper to invoke mock from 'gbp buildpackage-rpm'
 #
@@ -36,14 +36,18 @@ usage() {
 	exit $EXIT
 }
 
+declare -a EXTRA_ARGS
+
 while [ $# != 0 ]; do
 	case "$1" in
-		--help|-h|-?) usage 0;;
+		--help|-h) usage 0;;
 		*.spec) SPEC="$1";;
+		*) EXTRA_ARGS+=("$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
@@ -71,16 +75,15 @@ gbp_builder_mock() {
 	local resultdir="$export_dir/$pat"
 	local mock="mock -r $root --resultdir=$srpms --spec=$spec --sources=$sources"
 
-	$mock --buildsrpm
+	$mock "${EXTRA_ARGS[@]}" --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"
+	$mock "${EXTRA_ARGS[@]}" --no-cleanup-after --resultdir $resultdir --rebuild "$srpm"
 }
 
-
 fix_arch
 gbp_builder_mock
diff --git a/docs/manpages/gbp-buildpackage-rpm.sgml b/docs/manpages/gbp-buildpackage-rpm.sgml
index ac020f8..d5aa8f7 100644
--- a/docs/manpages/gbp-buildpackage-rpm.sgml
+++ b/docs/manpages/gbp-buildpackage-rpm.sgml
@@ -63,6 +63,7 @@
       <arg><option>--git-arch</option>=<replaceable>ARCHITECTURE</replaceable></arg>
       <arg><option>--git-mock-options</option>=<replaceable>OPTIONS</replaceable></arg>
       <arg><option>--git-mock-root</option>=<replaceable>ROOT</replaceable></arg>
+      <arg rep="repeat"><option>OPTION_PASSED_TO_BUILD_CMD</option></arg>
     </cmdsynopsis>
   </refsynopsisdiv>
   <refsect1>
diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py
index 8c131f3..d8c6da7 100644
--- a/gbp/scripts/buildpackage_rpm.py
+++ b/gbp/scripts/buildpackage_rpm.py
@@ -258,10 +258,11 @@ def setup_builder(options, builder_args):
     if options.builder == 'rpmbuild':
         if len(builder_args) == 0:
             builder_args.append('-ba')
-        builder_args.extend([
-            '--define "_topdir %s"' % os.path.abspath(options.export_dir),
-            '--define "_specdir %%_topdir/%s"' % options.export_specdir,
-            '--define "_sourcedir %%_topdir/%s"' % options.export_sourcedir])
+        if not options.use_mock:
+            builder_args.extend([
+                '--define "_topdir %s"' % os.path.abspath(options.export_dir),
+                '--define "_specdir %%_topdir/%s"' % options.export_specdir,
+                '--define "_sourcedir %%_topdir/%s"' % options.export_sourcedir])
 
 
 def packaging_tag_data(repo, commit, name, version, options):
-- 
2.8.1



More information about the git-buildpackage mailing list