From 78bcf5e946c0c7237ab2cbf97f82d75f5bb34d79 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Tue, 15 Sep 2009 13:40:55 +0200 Subject: catch config file parse errors Closes: #545690 --- git-buildpackage | 12 +++++++++--- git-dch | 15 ++++++++++----- git-import-dsc | 9 +++++++-- git-import-dscs | 11 +++++------ git-import-orig | 15 ++++++++++----- 5 files changed, 41 insertions(+), 21 deletions(-) diff --git a/git-buildpackage b/git-buildpackage index 527aa838..8ccd7c44 100755 --- a/git-buildpackage +++ b/git-buildpackage @@ -18,10 +18,11 @@ # """run commands to build a debian package out of a git repository""" -import sys -import os, os.path +import ConfigParser import errno +import os, os.path import pipes +import sys import time import gbp.deb as du from gbp.git import (GitRepositoryError, GitRepository, build_tag) @@ -168,7 +169,12 @@ def main(argv): if arg in dpkg_args: args.append(arg) - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix=prefix) + try: + parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix=prefix) + except ConfigParser.ParsingError, err: + print >>sys.stderr, err + return 1 + tag_group = GbpOptionGroup(parser, "tag options", "options related to git tag creation") branch_group = GbpOptionGroup(parser, "branch options", "branch layout options") cmd_group = GbpOptionGroup(parser, "external command options", "how and when to invoke external commands and hooks") diff --git a/git-dch b/git-dch index 7680a785..1051f82b 100755 --- a/git-dch +++ b/git-dch @@ -1,7 +1,7 @@ #!/usr/bin/python -u # vim: set fileencoding=utf-8 : # -# (C) 2007,2008 Guido Guenther +# (C) 2007, 2008, 2009 Guido Guenther # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -18,9 +18,10 @@ # """Generate Debian changelog entries from git commit messages""" -import sys -import re +import ConfigParser import os.path +import re +import sys import shutil import subprocess import gbp.command_wrappers as gbpc @@ -274,8 +275,12 @@ def main(argv): found_snapshot_header = False first_commit = None - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', - usage='%prog [options] paths') + try: + parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', + usage='%prog [options] paths') + except ConfigParser.ParsingError, err: + print >>sys.stderr, err + return 1 range_group = GbpOptionGroup(parser, "commit range options", "which commits to add to the changelog") version_group = GbpOptionGroup(parser, "release & version number options", "what version number and release to use") commit_group = GbpOptionGroup(parser, "commit message formatting", "howto format the changelog entries") diff --git a/git-import-dsc b/git-import-dsc index bb664814..a5a12a61 100755 --- a/git-import-dsc +++ b/git-import-dsc @@ -17,6 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Import a Debian source package into a git repository""" +import ConfigParser import sys import re import os @@ -93,8 +94,12 @@ def main(argv): needs_repo = False ret = 0 - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', - usage='%prog [options] /path/to/package.dsc') + try: + parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', + usage='%prog [options] /path/to/package.dsc') + except ConfigParser.ParsingError, err: + print >>sys.stderr, err + return 1 import_group = GbpOptionGroup(parser, "import options", "pristine-tar and filtering") diff --git a/git-import-dscs b/git-import-dscs index c4cbc1c0..e7ca7d1d 100755 --- a/git-import-dscs +++ b/git-import-dscs @@ -1,7 +1,7 @@ #!/usr/bin/python -u # vim: set fileencoding=utf-8 : # -# (C) 2008 Guido Guenther +# (C) 2008, 2009 Guido Guenther # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -17,15 +17,14 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Import multiple dsc files in one go""" -import sys -import re -import os -import tempfile import glob +import os import pipes +import re +import sys +import tempfile import gbp.command_wrappers as gbpc from gbp.deb import parse_dsc, DscFile -from gbp.config import GbpOptionParser from gbp.errors import GbpError from gbp.git import GitRepository, GitRepositoryError diff --git a/git-import-orig b/git-import-orig index 63d12f97..9438e6aa 100755 --- a/git-import-orig +++ b/git-import-orig @@ -18,14 +18,15 @@ # """Import a new upstream version into a git repository""" -import sys +import ConfigParser +import glob import os -import tempfile +import sys import re -import glob import subprocess import tarfile import time +import tempfile import gbp.command_wrappers as gbpc from gbp.deb import (parse_changelog, unpack_orig, repack_orig, NoChangelogError, has_epoch, tar_toplevel, @@ -210,8 +211,12 @@ def main(argv): tmpdir = '' pristine_orig = None - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', - usage='%prog [-u version] /path/to/upstream-version.tar.gz') + try: + parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', + usage='%prog [-u version] /path/to/upstream-version.tar.gz') + except ConfigParser.ParsingError, err: + print >>sys.stderr, err + return 1 cl_group = GbpOptionGroup(parser, "changelog mangling", "options for mangling the changelog after the import") -- cgit v1.2.3