[git-buildpackage] [PATCH 1/3] gbp-buildpackage-rpm: pass commands to mock
Guido Günther
agx at sigxcpu.org
Wed Jul 20 12:13:19 CEST 2016
On Sat, Jul 09, 2016 at 05:44:03PM +0200, tzafrir at debian.org wrote:
> 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])
This must be moved to setup_mock() since this function is available for
setting up the mock usage and otherwise we might fail to set the paths
if someone sets another builder than rpmbuild.
If you then swap the setup_builder() and setup_mock() calls as outlined
in my other mail most of the if/else goes away.
Good to apply after this change.
Cheers,
-- Guido
>
>
> def packaging_tag_data(repo, commit, name, version, options):
> --
> 2.8.1
>
> _______________________________________________
> git-buildpackage mailing list
> git-buildpackage at lists.sigxcpu.org
> http://lists.sigxcpu.org/mailman/listinfo/git-buildpackage
>
More information about the git-buildpackage
mailing list