From 158d79999f7b96d090ea8b681f87308187d98cf2 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 27 Jan 2016 09:57:55 +0100 Subject: [PATCH] Fix KeyError crash with NBS binaries in testing Traceback (most recent call last): File "/var/lib/britney/britney.py", line 3390, in Britney().main() File "/var/lib/britney/britney.py", line 295, in __init__ self.merge_binaries('testing', 'unstable', arch) File "/var/lib/britney/britney.py", line 785, in merge_binaries target_version = target_sources[value[SOURCE]][VERSION] KeyError: 'insighttoolkit4' --- britney.py | 6 +++++- tests/test_autopkgtest.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/britney.py b/britney.py index 941989d..6d66d74 100755 --- a/britney.py +++ b/britney.py @@ -781,7 +781,11 @@ class Britney(object): # that have built on this architecture. if value[SOURCE] not in oodsrcs: source_version = source_sources[value[SOURCE]][VERSION] - target_version = target_sources[value[SOURCE]][VERSION] + try: + target_version = target_sources[value[SOURCE]][VERSION] + except KeyError: + self.__log("merge_binaries: pkg %s has no source, NBS?" % pkg) + continue if source_version != target_version: current_arch = value[ARCHITECTURE] built = False diff --git a/tests/test_autopkgtest.py b/tests/test_autopkgtest.py index d0c8f14..f857f4c 100755 --- a/tests/test_autopkgtest.py +++ b/tests/test_autopkgtest.py @@ -1216,6 +1216,22 @@ class T(TestBase): {'lightgreen': [('old-version', '1'), ('new-version', '2')]} ) + def test_nbs(self): + '''source-less binaries do not cause harm''' + + # NBS in testing + self.data.add('liboldgreen0', False, add_src=False) + # NBS in unstable + self.data.add('liboldgreen1', True, add_src=False) + self.do_test( + [('libgreen1', {'Version': '2', 'Source': 'green'}, 'autopkgtest')], + {'green': (True, {'green 2': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'}, + 'lightgreen 1': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'}, + 'darkgreen 1': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'}, + }), + }, + {'green': [('old-version', '1'), ('new-version', '2')]}) + ################################################################ # Tests for hint processing ################################################################