[PATCH 1/2] aiaiai: move most of the aiaiai-email-test-patchset options to the file
Artem Bityutskiy
dedekind1 at gmail.com
Thu Mar 6 03:49:18 PST 2014
From: Jacob Keller <jacob.e.keller at intel.com>
Currently, the options supplied by the aiaiai-email-test-patchset were
supplied on the command line, with no way to override them per project,
or even easily specify or change them. (You had to muck with the
validator command.) This patch adds two helper functions for reading
multiple configuration variables, and modifies the script to work with
the options from the configuration file instead of the command line.
This also enables the first options which have global settings
overridden by project settings. This enables a simple default set for
all projects that can be tweaked per-project if desired (which was
impossible before).
This also adds an always_cc which merges with the per-project always_cc,
and cleans up the use of merge_addresses, now that we can support an
arbitrary number of parameters.
Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
---
doc/TODO.txt | 10 +++---
doc/email/example-aiaiai.cfg | 54 +++++++++++++++++++++++++++++-
email/aiaiai-email-sh-functions | 68 +++++++++++++++++++++++++++++++++++--
email/aiaiai-email-test-patchset | 72 ++++++++++++----------------------------
4 files changed, 144 insertions(+), 60 deletions(-)
diff --git a/doc/TODO.txt b/doc/TODO.txt
index adc9a97..64bbbf7 100644
--- a/doc/TODO.txt
+++ b/doc/TODO.txt
@@ -10,12 +10,10 @@ implementing them.
containing the text for end-users to refer instead. Just like
email.preamble refers the file, which contains the preamble. This is more
flexible and consistent.
- * Move command-line options of 'aiaiai-email-*' scripts to the configuration
- file. This should make it simpler for users to configure the whole thing
- when all the knobs are in one place. Just make each script to parse the
- config file and pick own configuration from there. Namely, most of
- the 'aiaiai-email-dispatcher', 'aiaiai-email-testpatchset', and
- 'aiaiai-email-lda' options have to go away.
+ * Move remaining command-line options of 'aiaiai-email-*' scripts to the
+ configuration file. This work has been partially completed, but still
+ needs more to finish making the configuration file the only place for
+ tuning.
* Eventually make non-email scripts (aiaiai-test-patchset) also
support the config file. This could be an alternative to specifying
everythig via options. E.g., would could run
diff --git a/doc/email/example-aiaiai.cfg b/doc/email/example-aiaiai.cfg
index 4636e28..744dfaa 100644
--- a/doc/email/example-aiaiai.cfg
+++ b/doc/email/example-aiaiai.cfg
@@ -40,6 +40,56 @@
# is put after the preamble text.
built_preamble = I have tested your changes
+ # Comma-separated list of e-mail addresses to always CC when replying.
+ # These are maintainers or other project supervisors. This may be a
+ # separate mailing list for replies from Aiaiai. Combined with the
+ # project specific settings, but does not get overwritten.
+ always_cc = ""
+
+# Default settings for the validator program including various static checkers
+# and other settings. Each project can specify these values as well, which will
+# override the settings here.
+[validator]
+ # List of targets (space seperated) for which to run a kernel make.
+ # Default is "all". Can include any kernel make target, such as
+ # "namespacecheck" etc.
+ targets = "all"
+
+ # Path to the directory containing the deconfig files (those specified
+ # for each project); by default the defconfig files are assumed to be
+ # in the <kernel-tree>; this option allows specifying stand-alone
+ # defconfig files instead. Leave empty to use the <kernel-tree>
+ defconfigdir =
+
+ # Whether to test bisectability between patches in a series, or only to
+ # check results of the final result. 1 to enable, 0 to disable.
+ bisectability = 0
+
+ # Enables sparse static analyzer during kernel builds
+ sparse = 1
+
+ # Enables smatch static analyzer during kernel builds
+ smatch = 0
+
+ # Enables ccpcheck static analysis tool during kernel builds
+ cppcheck = 0
+
+ # Enables coccinelle scripts checking during kernel builds
+ coccinelle = 1
+
+ # Path to the file containing unwanted keywords (one keyword per line).
+ # Aiaiai will check the patch against this list and notify if any of
+ # the keywords was found. This may be useful to help making sure some
+ # internal confidential information does not leak through commit
+ # messages or commentaries. The file can be selected per-project which
+ # will override the file selected here.
+ unwanted_keywords =
+
+ # Additional kernel build options which are appended to the end of the
+ # "make" command. For example, W=2 KALLSYMS_EXTRA_PASS=1. This will be
+ # overridden by the per-project setting.
+ kmake_opts =
+
# The e-mail front-end may operate on several project. Each project has its
# own kernel tree, kernel configuration, and some other settings. These are
# configured in per-project sections. Section names have to start with "prj_"
@@ -82,7 +132,9 @@
# Comma-separated list of e-mail addresses to always CC when replying.
# These are maintainers or other project supervisors. This may be a
- # separate mailing list for replies from Aiaiai.
+ # separate mailing list for replies from Aiaiai. This list does not
+ # override the list from the email section above. Instead the lists are
+ # cumulative.
always_cc = "Artem Bityutskiy" <artem.bityutskiy at fake.domain.com>, "Aiaiai archives" <aiaiai-archives at fake.comain.com>
# Reply only to the sender (0) or to everyone in To: and Cc: (1)
diff --git a/email/aiaiai-email-sh-functions b/email/aiaiai-email-sh-functions
index bb77b4d..3e3115c 100644
--- a/email/aiaiai-email-sh-functions
+++ b/email/aiaiai-email-sh-functions
@@ -139,7 +139,9 @@ ini_config_get_or_die()
# configuration file:
#
# cfg_ownname, cfg_ownmail, cfg_adminname, cfg_adminmail, cfg_workdir,
-# cfg_jobs, cfg_signature, cfg_built_preamble.
+# cfg_jobs, cfg_signature, cfg_built_preamble, cfg_always_cc, cfg_defconfigdir,
+# cfg_targets, cfg_bisectability, cfg_sparse, cfg_smatch, cfg_cppcheck,
+# cfg_coccinelle, cfg_unwanted_keywords, cfg_kmake_opts
#
# Additinally, the following variables are defined:
# o cfg_preamble - contains the email preamble read from the file definded
@@ -161,19 +163,34 @@ parse_config()
ini_config_get_or_die cfg_preamble "$cfgfile" "email" "preamble"
ini_config_get_or_die cfg_built_preamble "$cfgfile" "email" "built_preamble"
+ # Global Email Options
+ cfg_always_cc="$(ini_config_get "$cfgfile" "email" "always_cc")"
+
cfg_preamble="$(cat "$cfg_preamble")"
# Get the local and domain parts of own e-mail address
cfg_ownmail_local="$(printf "%s" "$cfg_ownmail" | LC_ALL=C sed "s/@.*//g")"
cfg_ownmail_domain="$(printf "%s" "$cfg_ownmail" | LC_ALL=C sed "s/.*@//g")"
+
+ # Validator Options
+ cfg_defconfigdir="$(ini_config_get "$cfgfile" "validator" "defconfigdir")"
+ cfg_targets="$(ini_config_get "$cfgfile" "validator" "targets")"
+ cfg_bisectability="$(ini_config_get "$cfgfile" "validator" "bisectability")"
+ cfg_sparse="$(ini_config_get "$cfgfile" "validator" "sparse")"
+ cfg_smatch="$(ini_config_get "$cfgfile" "validator" "smatch")"
+ cfg_cppcheck="$(ini_config_get "$cfgfile" "validator" "cppcheck")"
+ cfg_coccinelle="$(ini_config_get "$cfgfile" "validator" "coccinelle")"
+ cfg_unwanted_keywords="$(ini_config_get "$cfgfile" "validator" "unwanted_keywords")"
+ cfg_kmake_opts="$(ini_config_get "$cfgfile" "validator" "kmake_opts")"
}
# Similar to "parse_config", but parses a project configuration section. If the
# project is found, the following variables are defined:
#
# cfg_name. pcfg_description, pcfg_path, pcfg_configs, pcfg_branch,
-# pcfg_reply_to_all, pcfg_accept_notify, pcfg_always_cc,
-# pcfg_unwanted_keywords, and pcfg_kmake_opts.
+# pcfg_reply_to_all, pcfg_accept_notify, pcfg_always_cc, pcfg_defconfigdir,
+# pcfg_targets, pcfg_bisectability, pcfg_sparse, pcfg_smatch, pcfg_cppcheck,
+# pcfg_coccinelle, pcfg_unwanted_keywords, and pcfg_kmake_opts,
#
# If the project is not found, this function only defined an empty "pcfg_name"
# variable.
@@ -195,10 +212,55 @@ parse_prj_config()
ini_config_get_or_die pcfg_accept_notify "$cfgfile" "prj_$prj" "accept_notify"
pcfg_always_cc="$(ini_config_get "$cfgfile" "prj_$prj" "always_cc")"
+
+ # Per-Project Validator Options
+ # These values take precedence over the cfg_* options
+ pcfg_defconfigdir="$(ini_config_get "$cfgfile" "validator" "defconfigdir")"
+ pcfg_bisectability="$(ini_config_get "$cfgfile" "prj_$prj" "bisectability")"
+ pcfg_targets="$(ini_config_get "$cfgfile" "prj_$prj" "targets")"
+ pcfg_sparse="$(ini_config_get "$cfgfile" "prj_$prj" "sparse")"
+ pcfg_smatch="$(ini_config_get "$cfgfile" "prj_$prj" "smatch")"
+ pcfg_cppcheck="$(ini_config_get "$cfgfile" "prj_$prj" "cppcheck")"
+ pcfg_coccinelle="$(ini_config_get "$cfgfile" "prj_$prj" "coccinelle")"
pcfg_unwanted_keywords="$(ini_config_get "$cfgfile" ""prj_$prj"" "unwanted_keywords")"
pcfg_kmake_opts="$(ini_config_get "$cfgfile" "prj_$prj" "kmake_opts")"
}
+# Get the correct value or default, where pcfg_* overrides cfg_* overrides the default
+#
+# Usage cfg_get_value <var> <default>
+cfg_get_value()
+{
+ local var="$1"; shift
+ local default="$2"; shift
+
+ if [ -z $(eval "echo \$pcfg_$var") ]; then
+ eval "echo \$pcfg_$var"
+ elif [ -z $(eval "echo \$cfg_$var") ]; then
+ eval "echo \$cfg_$var"
+ else
+ echo "$default"
+ fi
+}
+
+# Check a flag variable, and return the if-true or if-false depending on flag
+# setting. pcfg_* overrides cfg_*, and assumes unspecified variables are false.
+#
+# Usage: cfg_get_flag <var> <if-true> <if-false>
+cfg_get_flag()
+{
+ local var="$1"; shift
+ local iftrue="$1"; shift
+ local iffalse="$1"; shift
+
+ if [ "$(cfg_get_value "$var" "0")" = "1" ]; then
+ echo "$iftrue"
+ else
+ echo "$iffalse"
+ fi
+}
+
+
# Compose (but not send) e-mail reply. This function assumes that the following
# variables are defined: cfg_ownname, cfg_ownmail, cfg_adminname,
# cfg_adminmail, cfg_preamble, cfg_signature. See "parse_config()" function.
diff --git a/email/aiaiai-email-test-patchset b/email/aiaiai-email-test-patchset
index 03d747a..fa6cf25 100755
--- a/email/aiaiai-email-test-patchset
+++ b/email/aiaiai-email-test-patchset
@@ -35,20 +35,9 @@ The mbox file containing the patches to test is expected to come from stdin
Options:
-i, --input=MBOX use the MBOX file instead of stdin;
- -C, --confdir=CDIR path to the directory containing the defconfig files
- (those you specify in the config file); by default the
- defconfig files are assumed to be part of the
- <kernel-tree>; this option makes it possible to use
- stand-alone defconfig files instead;
-p, --preserve preserve all the temporary files - do not clean up;
--test-mode test mode - work as usually, but do not actually
send replies;
- --bisectability test bisectability;
- --targets list of make targets to build (defaults to all);
- --sparse check with sparse while building;
- --smatch check with smatch while building;
- --cppcheck check with cppcheck;
- --coccinelle check with coccinelle;
-v, --verbose be verbose;
-h, --help show this text and exit.
EOF
@@ -187,19 +176,12 @@ $(cat -- $tmpdir/test-patchset.log)
EOF
}
-TEMP=`getopt -n $PROG -o i:,C:,p,v,h --long test-mode,input:,confdir:,preserve,bisectability,targets,sparse,smatch,cppcheck,coccinelle,verbose,help -- "$@"` ||
+TEMP=`getopt -n $PROG -o i:,C:,p,v,h --long test-mode,input:,preserve,verbose,help -- "$@"` ||
fail_usage ""
eval set -- "$TEMP"
mbox=
-confdir=
test_mode=
-bisectability=
-targets="all"
-sparse=
-smatch=
-cppcheck=
-coccinelle=
while true; do
case "$1" in
@@ -207,35 +189,12 @@ while true; do
mbox="$(opt_check_read "$1" "$2")"
shift
;;
- -C|--confdir)
- confdir="$(opt_check_dir "$1" "$2")"
- shift
- ;;
-p|--preserve)
preserve="--preserve"
;;
--test-mode)
test_mode=y
;;
- --bisectability)
- bisectability="--bisectability"
- ;;
- --targets)
- targets="$2"
- shift
- ;;
- --sparse)
- sparse="--sparse"
- ;;
- --smatch)
- smatch="--smatch"
- ;;
- --cppcheck)
- cppcheck="--cppcheck"
- ;;
- --coccinelle)
- coccinelle="--coccinelle"
- ;;
-v|--verbose) verbose=-v
;;
-h|--help)
@@ -325,14 +284,24 @@ if [ -z "$pcfg_name" ]; then
error_project_not_found
fi
+# Get the default values based on pcfg, cfg, or default settings
+bisectability="$(cfg_get_flag "bisectability" "--bisectability" "")"
+sparse="$(cfg_get_flag "sparse" "--sparse" "")"
+smatch="$(cfg_get_flag "smatch" "--smatch" "")"
+cppcheck="$(cfg_get_flag "cppcheck" "--cppcheck" "")"
+coccinelle="$(cfg_get_flag "coccinelle" "--coccinelle" "")"
+
+defconfigdir="$(cfg_get_value "defconfigdir" "")"
+targets="$(cfg_get_value "targets" "all")"
+unwanted_keywards="$(cfg_get_value "unwanted_keywords" "")"
+kmake_opts="$(cfg_get_value "kmake_opts" "")"
+
# Create the Cc list for replies that we'll be sending
if [ "$pcfg_reply_to_all" = "1" ]; then
# All the patch recipients will be CCed
- reply_cc="$(merge_addresses "$to" "$cc")"
- reply_cc="$(merge_addresses "$reply_cc" "$pcfg_always_cc")"
- reply_cc=$(strip_address "$reply_cc" "$cfg_ownmail")
+ reply_cc="$(merge_addresses "$to" "$cc" "$pcfg_always_cc" "$cfg_always_cc" "$cfg_ownmail")"
else
- reply_cc="$pcfg_always_cc"
+ reply_cc="$(merge_addresses "$pcfg_always_cc" "$cfg_always_cc")"
fi
# Notify the sender that the patches have been accepted
@@ -344,11 +313,14 @@ fi
# Test the path (or patch-set)
verbose "Test configs \"$pcfg_configs\" branch \"$pcfg_branch\" of \"$pcfg_path\""
aiaiai-test-patchset $verbose $preserve \
- $bisectability ${targets:--targets "$targets"} $sparse $smatch $cppcheck $coccinelle \
+ ${targets:+--targets "$targets"} \
+ ${bisectability:+--bisectability} \
+ ${sparse:+--sparse} ${smatch:+--smatch} \
+ ${cppcheck:+--cppcheck} ${coccinelle:+--coccinelle} \
-i "$mbox" -j "$cfg_jobs" -c "$pcfg_branch" -w "$tmpdir" \
- ${confdir:+-C "$confdir"} \
- ${pcfg_unwanted_keywords:+-K "$pcfg_unwanted_keywords"} -- \
- ${pcfg_kmake_opts:+-M "$pcfg_kmake_opts"} \
+ ${defconfigdir:+-C "$defconfigdir"} \
+ ${unwanted_keywords:+-K "$unwanted_keywords"} -- \
+ ${kmake_opts:+-M "$kmake_opts"} \
"$pcfg_path" "$pcfg_configs" > "$tmpdir/test-patchset.log" ||
{
verbose "aiaiai-test-patchset failed"
--
1.8.5.3
More information about the aiaiai
mailing list