From 89765bc374903bfe2461e58983100a18707055ab Mon Sep 17 00:00:00 2001
From: Niels Thykier <niels@thykier.net>
Date: Sat, 11 Nov 2017 22:07:23 +0000
Subject: [PATCH] BuildDependsPolicy: Keep block_txt and block in sync

If a package had:

  Build-Depends: foo [i386], uninstallable-pkg

Then the excuses for amd64 would point to "foo [i386]" rather than
"uninstallable-pkg".

Signed-off-by: Niels Thykier <niels@thykier.net>
---
 britney2/policies/policy.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/britney2/policies/policy.py b/britney2/policies/policy.py
index a5b3b7f..8a548a2 100644
--- a/britney2/policies/policy.py
+++ b/britney2/policies/policy.py
@@ -653,7 +653,15 @@ class BuildDependsPolicy(BasePolicy):
             binaries_s_a, provides_s_a = britney.binaries[suite][arch]
             binaries_t_a, provides_t_a = britney.binaries['testing'][arch]
             # for every dependency block (formed as conjunction of disjunction)
-            for block, block_txt in zip(parse_src_depends(deps, False, arch), deps.split(',')):
+            for block_txt in deps.split(','):
+                block = parse_src_depends(block_txt, False, arch)
+                # Unlike regular dependencies, some clauses of the Build-Depends(-Arch|-Indep) can be
+                # filtered out by (e.g.) architecture restrictions.  We need to cope with this while
+                # keeping block_txt and block aligned.
+                if not block:
+                    # Relation is not relevant for this architecture.
+                    continue
+                block = block[0]
                 # if the block is satisfied in testing, then skip the block
                 if get_dependency_solvers(block, binaries_t_a, provides_t_a):
                     # Satisfied in testing; all ok.