From a8e599e6b3d8adb31a17de892088ea57d861a3cc Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 12 May 2012 08:28:38 -0400 Subject: [PATCH 1/1] Initial version, incomplete, no tarbal build or upload yet. --- coverity-submit | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 coverity-submit diff --git a/coverity-submit b/coverity-submit new file mode 100755 index 0000000..82100a2 --- /dev/null +++ b/coverity-submit @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 +# +# coverity-submit - submit project to Coverity for scanning +# +import os, sys, configparser, getopt + +config = configparser.RawConfigParser() +config.read(os.path.expanduser("~/.coverity-submit")) + +def die(complaint): + sys.stderr.write(complaint + "\n") + sys.exit(1) + +# Gather information that is not project-specific +if not config.defaults(): + die("A defaults section with 'name' and 'userid' options is required.") +elif not config.has_option("DEFAULT", "name"): + die("A 'name' option is required.") +elif not config.has_option("DEFAULT", "userid"): + die("A 'userid' option is required.") +name = config.get("DEFAULT", "name") +userid = config.get("DEFAULT", "userid") +if config.has_option("DEFAULT", "tools"): + tools = config.get("DEFAULT", "tools") + os.environ["PATH"] += ":"+tools + +# Deduce what project and directory to operate on (and go there). +noexec = False +(opts, args) = getopt.getopt(sys.argv[1:], "d:n") +for (opt, arg) in opts: + if opt == '-d': + os.chdir(arg) + elif opt == '-n': + noexec = True +where = os.path.basename(os.getcwd()) +if args: + project = args[0] +else: + project = where +if project not in config.sections(): + die("No such project as %s" % project) + +# Collect project-specific variables +if config.has_option(project, "password"): + password = config.get(project, "password") +else: + die("Every project requires a password option.") +if config.has_option(project, "upload"): + upload = config.get(project, "upload") +else: + die("Every project requires an upload option.") +if config.has_option(project, "advertise"): + advertise = config.get(project, "advertise") +else: + die("Every project requires an advertise option.") +if config.has_option(project, "prebuild"): + prebuild = config.get(project, "prebuild") +else: + prebuild = None +if config.has_option(project, "build"): + build = config.get(project, "build") +else: + die("Every project requires a build option.") +if config.has_option(project, "postbuild"): + postbuild = config.get(project, "postbuild") +else: + postbuild = None +if "%s" not in upload: + die("The upload option must contain a %s to plug a tarball name into.") +if "%s" not in advertise: + die("The advertise option must contain a %s to plug a tarball name into.") + +def do_or_die(cmd): + print(cmd) + if not noexec: + if os.system(cmd) != 0: + bailout("Command failed") + +# Build local stuff +if prebuild: + do_or_die(prebuild) +do_or_die("rm -fr cov-int && cov-build --dir cov-int " + build) +if postbuild: + do_or_die(postbuild) + +# Create the tarball + +# The following sets edit modes for GNU EMACS +# Local Variables: +# mode:python +# End: + -- 2.43.0