From 029fe4d463b674dae0e9e460084d920ab2384717 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Wed, 16 Jul 2014 17:15:44 +0300 Subject: [PATCH] buildpackage-rpm: handle invalid keys in orig prefix Gracefully handle invalid keys in the --git-orig-prefix format string. Signed-off-by: Markus Lehtonen --- gbp/scripts/buildpackage_rpm.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py index be938aa..efc344d 100755 --- a/gbp/scripts/buildpackage_rpm.py +++ b/gbp/scripts/buildpackage_rpm.py @@ -599,10 +599,13 @@ def main(argv): spec.specdir = os.path.abspath(spec_dir) if options.orig_prefix != 'auto': - options.orig_prefix = options.orig_prefix % dict(spec.version, - version=RpmPkgPolicy.compose_full_version(spec.version), - name=spec.name, - vendor=options.vendor) + try: + options.orig_prefix %= dict(spec.version, + version=RpmPkgPolicy.compose_full_version(spec.version), + name=spec.name, vendor=options.vendor) + except KeyError as err: + raise GbpError("Unknown key %s in orig prefix format " + "string" % err) elif spec.orig_src: options.orig_prefix = spec.orig_src['prefix'] -- 2.7.4