Package: git-buildpackage
Version: 0.8.12.2
Severity: normal
Tags: patch

Dear Maintainer,

I have had quite a bit of difficulty figuring out how to use
pbuilder/cowbuilder --basepath with gbp-buildpackage.  After a bit of
digging I have figured out that my problems were caused by two issues.
First is that --git-pbuilder-options='--basepath foo' is overridden by
the default basepath because git-pbuilder supplies a default if
--basepath does not appear in "$@" (which it can't for
gbp-buildpackage).  Attached patch 0001 fixes this.

The second issue is that --git-pbuilder-options is ignored when using
--git-builder without --git-pbuilder.  Attached patch 0002 fixes this by
setting the pbuilder environment variables whenever the corresponding
option is configured.  I think this is reasonable/expected, but if there
is a reason that these shouldn't be set, updating the man page to make
it clear which options are ignored when --git-pbuilder could be
workable.

Thanks for considering,
Kevin


-- System Information:
Debian Release: 9.0
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (101, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0+kevinoid1 (SMP w/4 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages git-buildpackage depends on:
ii  devscripts            2.17.1
ii  git                   1:2.11.0-2
ii  man-db                2.7.6.1-2
ii  python-dateutil       2.5.3-2
ii  python-pkg-resources  33.1.1-1
ii  python-six            1.10.0-3
pn  python:any            <none>

Versions of packages git-buildpackage recommends:
ii  cowbuilder       0.85
ii  pbuilder         0.228.4
ii  pristine-tar     1.38
ii  python-requests  2.12.4-1

Versions of packages git-buildpackage suggests:
pn  python-notify  <none>
ii  sudo           1.8.19p1-1
ii  unzip          6.0-21

-- no debconf information
>From d4060ff8cb31a008247edd639c45a129f8f5a302 Mon Sep 17 00:00:00 2001
Message-Id: 
<d4060ff8cb31a008247edd639c45a129f8f5a302.1488181743.git.ke...@kevinlocke.name>
From: Kevin Locke <ke...@kevinlocke.name>
Date: Mon, 27 Feb 2017 00:16:57 -0700
Subject: [PATCH 1/2] Set pbuilder env vars whenever configured

The previous behavior of only setting the pbuilder environment variables
when --git-pbuilder or --git-qemubuilder are configured leads to
difficult to debug issues when --git-builder is set to git-pbuilder but
--git-pbuilder is not set.  This may seem like an odd corner case, but
it occurs in one of the top search results for [gbp.conf pbuilder][1].
This commit fixes that by setting the environment variables whenever
the corresponding options are configured.

1:  https://github.com/russell/dotfiles/blob/master/gbp.conf

Signed-off-by: Kevin Locke <ke...@kevinlocke.name>
---
 gbp/scripts/buildpackage.py | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py
index e14122a..ceb272a 100755
--- a/gbp/scripts/buildpackage.py
+++ b/gbp/scripts/buildpackage.py
@@ -481,22 +481,24 @@ def setup_pbuilder(options, repo, native):
         pr_builder = os.getenv("BUILDER") or '(cowbuilder)'
         options.cleaner = '/bin/true'
 
-        dist = get_pbuilder_dist(options, repo, native)
-        pbd_env['GBP_PBUILDER_DIST'] = pbd_env['DIST'] = dist
-        pr_dist = dist or 'sid'
-        if options.pbuilder_arch:
-            arch = options.pbuilder_arch
-            pbd_env['GBP_PBUILDER_ARCH'] = pbd_env['ARCH'] = arch
-            pr_arch = ":%s" % arch
-        else:
-            pr_arch = ""
-        if options.use_qemubuilder:
-            pbd_env['GBP_PBUILDER_BUILDER'] = pbd_env['BUILDER'] = 
"qemubuilder"
-            pr_builder = pbd_env["GBP_PBUILDER_BUILDER"]
-        if not options.pbuilder_autoconf:
-            pbd_env['GBP_PBUILDER_AUTOCONF'] = 
pbd_env['GIT_PBUILDER_AUTOCONF'] = "no"
-        if options.pbuilder_options:
-            pbd_env['GBP_PBUILDER_OPTIONS'] = pbd_env['GIT_PBUILDER_OPTIONS'] 
= options.pbuilder_options
+    dist = get_pbuilder_dist(options, repo, native)
+    pbd_env['GBP_PBUILDER_DIST'] = pbd_env['DIST'] = dist
+    pr_dist = dist or 'sid'
+    if options.pbuilder_arch:
+        arch = options.pbuilder_arch
+        pbd_env['GBP_PBUILDER_ARCH'] = pbd_env['ARCH'] = arch
+        pr_arch = ":%s" % arch
+    else:
+        pr_arch = ""
+    if options.use_qemubuilder:
+        pbd_env['GBP_PBUILDER_BUILDER'] = pbd_env['BUILDER'] = "qemubuilder"
+        pr_builder = pbd_env["GBP_PBUILDER_BUILDER"]
+    if not options.pbuilder_autoconf:
+        pbd_env['GBP_PBUILDER_AUTOCONF'] = pbd_env['GIT_PBUILDER_AUTOCONF'] = 
"no"
+    if options.pbuilder_options:
+        pbd_env['GBP_PBUILDER_OPTIONS'] = pbd_env['GIT_PBUILDER_OPTIONS'] = 
options.pbuilder_options
+
+    if options.use_pbuilder or options.use_qemubuilder:
         gbp.log.info("Building with %s for %s%s" % (pr_builder, pr_dist, 
pr_arch))
 
     hook_env = dict([(k, pbd_env[k]) for k in pbd_env if k.startswith("GBP_")])
-- 
2.11.0

>From bc8b66e1828aef7c242c363d1ddad15f24c1b2d0 Mon Sep 17 00:00:00 2001
Message-Id: 
<bc8b66e1828aef7c242c363d1ddad15f24c1b2d0.1488181743.git.ke...@kevinlocke.name>
In-Reply-To: 
<d4060ff8cb31a008247edd639c45a129f8f5a302.1488181743.git.ke...@kevinlocke.name>
References: 
<d4060ff8cb31a008247edd639c45a129f8f5a302.1488181743.git.ke...@kevinlocke.name>
From: Kevin Locke <ke...@kevinlocke.name>
Date: Mon, 27 Feb 2017 00:22:46 -0700
Subject: [PATCH 2/2] git-pbuilder: Check $OPTIONS for --basepath

Previously only the arguments were checked for --basepath.  This
resulted in --basepath being ignored and overridden by the default when
passed in --git-pbuilder-options (either via command arguments or from
the configuration file).  Since this is required when invoking
gbp-buildpackage (because args are passed to --debbuildopts), it's a
significant use case.  This commit fixes the issue by searching both
args and $OPTIONS.

Signed-off-by: Kevin Locke <ke...@kevinlocke.name>
---
 bin/git-pbuilder | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/git-pbuilder b/bin/git-pbuilder
index a3bd282..30100ce 100644
--- a/bin/git-pbuilder
+++ b/bin/git-pbuilder
@@ -160,7 +160,7 @@ if [ no != "$GIT_PBUILDER_AUTOCONF" ]; then
             # that and that alone, since if it's specified more than once,
             # cowbuilder will fail.
             bp_found=""
-            for opt in $@; do
+            for opt in "$@" "${OPTIONS[@]}"; do
                 case $opt in
                     --basepath|--basepath=*) bp_found="yes" ;;
                 esac
-- 
2.11.0

Reply via email to