summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Keller <jacob.e.keller@intel.com>2014-03-06 16:31:12 -0800
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2014-03-10 17:03:35 +0200
commit9d1b83c78d1a9862713b448c7f8b5caa768ce0ac (patch)
tree2751c198890cf82310d3e0edfba23c35815db467
parent9ef69a4fdfc529f5c19f83c8284cbb7c3964e196 (diff)
downloadaiaiai-9d1b83c78d1a9862713b448c7f8b5caa768ce0ac.tar.gz
aiaiai-email: add [defaults] section to config
This patch adds a [defaults] section for the configuration file which allows setting shared project settings which might be overridden per-project. This will be used more in a follow-on patch which adds additional configuration options. - v2 * put ini_config_is_set into the libshell file * use __ instead of _ to indicate internal variable * update comment to better reflect per-project and default variable interaction Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
-rw-r--r--doc/email/example-aiaiai.cfg67
-rw-r--r--email/aiaiai-email-sh-functions61
-rw-r--r--helpers/libshell/shell-ini-config33
3 files changed, 130 insertions, 31 deletions
diff --git a/doc/email/example-aiaiai.cfg b/doc/email/example-aiaiai.cfg
index 4a0b611..8b3c9b3 100644
--- a/doc/email/example-aiaiai.cfg
+++ b/doc/email/example-aiaiai.cfg
@@ -38,26 +38,10 @@
# aiaiai will insert it for you.
built_preamble = I have tested your changes
-# 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_"
-# and follow with the name of the project.
-
-# This is the "android" project section.
-[prj_android]
- # Human-readable project name
- name = Android
-
- # Short, one line project description. Start it with a small letter.
- description = the Android x86 kernel
-
- # Path to the kernel tree of the project. Note, Aiaiai does treats this
- # directory as read-only and never changes anything there. This means
- # that you have to keep it up-to-date with other means. For example, you
- # may setup a cron job which will periodically execute 'git fetch -f' in
- # this directory in order to get the newest contents from the server.
- path = /home/aiaiai/work/git/android-x86
-
+# The "defaults" section specifies various default settings for projects. These
+# values are overridden by the same values in the prj_* sections, so you may
+# customize the settings per project if desired.
+[defaults]
# The kernel configurations to test. You may specify more than one
# configuration using blanks as a delimiter. The configuration consists
# of the following comma-separated components: the defconfig file to
@@ -69,26 +53,26 @@
#
# means: use the "omap2_defconfig" defconfig, use ARCH="arm", use
# CROSS_COMPILE="arm-eabi-". The last component is optional.
- configs = android_defconfig,i386 android_debug_defconfig,i386
+ configs = x86_64_defconfig,x86_64 i386_defconfig,i386
# Git refspec to validate the patches against. Usually this a the
# remote branch name. But may actually be any refspec.
#
# Note, the defconfig files specified in the "configs" option must be
# part of this git refspec.
- branch = origin/3.0-mid
+ branch = origin/master
# 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.
- always_cc = "Artem Bityutskiy" <artem.bityutskiy@fake.domain.com>, "Aiaiai archives" <aiaiai-archives@fake.comain.com>
+ always_cc = "Aiaiai archives" <aiaiai-archives@fake.domain.com>
# Reply only to the sender (0) or to everyone in To: and Cc: (1)
reply_to_all = 0
# Notify the sender that his/her e-mail has been accepted by the Aiaiai
# front-end and put to the queue for validation.
- accept_notify = 1
+ accept_notify = 0
# Path to the file containing unwanted keywords (one keyword per line).
# Aiaiai will check the patch against this list and notify if any of
@@ -101,4 +85,39 @@
# "make" command. For example, W=2 KALLSYMS_EXTRA_PASS=1.
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_"
+# and follow with the name of the project.
+
+# This is the "android" project section.
+[prj_android]
+ # Human-readable project name.
+ name = Android
+
+ # Short, one line project description. Start it with a small letter.
+ description = the Android x86 kernel
+
+ # Path to the kernel tree of the project. Note, Aiaiai does treats this
+ # directory as read-only and never changes anything there. This means
+ # that you have to keep it up-to-date with other means. For example,
+ # you may setup a cron job which will periodically execute 'git fetch
+ # -f' in this directory in order to get the newest contents from the
+ # server. No default value.
+ path = /home/aiaiai/work/git/android-x86
+
+ # See the [defaults] section above for detailed explanation of the
+ # options below, and their formats. Be aware that any value set here
+ # will override the default value, ignoring anything set there. For
+ # example, setting the value to empty here will ignore the default
+ # value and actually set the option to the empty value. To use the
+ # default, simply leave the option out of the per-project section.
+ configs = android_defconfig,i386 android_debug_defconfig,i386
+ branch = origin/3.0-mid
+ always_cc =
+ reply_to_all = 1
+ accept_notify = 1
+ unwanted_keywords =
+ kmake_opts = W=2 KALLSYMS_EXTRA_PASS=1
+
# More "prj_xyz" sections may be added
diff --git a/email/aiaiai-email-sh-functions b/email/aiaiai-email-sh-functions
index 2e815bb..c3d396c 100644
--- a/email/aiaiai-email-sh-functions
+++ b/email/aiaiai-email-sh-functions
@@ -169,16 +169,48 @@ parse_config()
cfg_ownmail_domain="$(printf "%s" "$cfg_ownmail" | LC_ALL=C sed "s/.*@//g")"
}
+# Parse the "defaults" section of the config file. The result is a set of
+# per-option variables and their values are exactly as in the configuration
+# file:
+#
+# __dcfg_configs, __dcfg_branch, __dcfg_always_cc, __dcfg_reply_to_all,
+# __dcfg_accept_notify, __dcfg_unwanted_keywords, __dcfg_kmake_opts
+#
+# It is expected that this is used internally by the parse_prj_config and
+# should not normally be called outside of this file.
+#
+# Usage: _parse_defaults_config <cfgfile>
+__parse_default_config()
+{
+ local cfgfile="$1"; shift
+
+ __dcfg_configs="$(ini_config_get "$cfgfile" "defaults" "configs")"
+ __dcfg_branch="$(ini_config_get "$cfgfile" "defaults" "branch")"
+ __dcfg_always_cc="$(ini_config_get "$cfgfile" "defaults" "always_cc")"
+ __dcfg_reply_to_all="$(ini_config_get "$cfgfile" "defaults" "reply_to_all")"
+ __dcfg_accept_notify="$(ini_config_get "$cfgfile" "defaults" "accept_notify")"
+ __dcfg_unwanted_keywords="$(ini_config_get "$cfgfile" "defaults" "unwanted_keywords")"
+ __dcfg_kmake_opts="$(ini_config_get "$cfgfile" "defaults" "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_name, pcfg_description, and pcfg_path.
+#
+# The following variables are defined, but receive default values from the
+# [defaults] section, if they are not specified in the project section:
+#
+# pcfg_configs, pcfg_branch, pcfg_reply_to_all, pcfg_accept_notify,
+# pcfg_always_cc, pcfg_unwanted_keywords, and pcfg_kmake_opts.
#
# If the project is not found, this function only defined an empty "pcfg_name"
# variable.
#
+# Note, this function implicitly uses _parse_defaults_config to grab the
+# default configurations, and if the variable is not defined in the project
+# section, it will use the default value.
+#
# Usage: parse_prj_config <cfgfile> <prj>
parse_prj_config()
{
@@ -190,14 +222,29 @@ parse_prj_config()
ini_config_get_or_die pcfg_description "$cfgfile" "prj_$prj" "description"
ini_config_get_or_die pcfg_path "$cfgfile" "prj_$prj" "path"
- ini_config_get_or_die pcfg_configs "$cfgfile" "prj_$prj" "configs"
- ini_config_get_or_die pcfg_branch "$cfgfile" "prj_$prj" "branch"
- ini_config_get_or_die pcfg_reply_to_all "$cfgfile" "prj_$prj" "reply_to_all"
- ini_config_get_or_die pcfg_accept_notify "$cfgfile" "prj_$prj" "accept_notify"
+ # The following options all take default value from the "defaults"
+ # section, and hence "override" those settings. First we need to populate those.
+ _parse_default_config "$cfgfile"
+
+ # ini_config_is_set is important here, so that defining a value as
+ # empty in the project section actually does define it as empty, rather
+ # than using the default. This allows defaults to only be used if the
+ # project config does not specify anything.
+ pcfg_configs="$(ini_config_get "$cfgfile" "prj_$prj" "configs")"
+ ini_config_is_set "$cfgfile" "prj_$prj" "configs" || pcfg_configs="$__dcfg_configs"
+ pcfg_branch="$(ini_config_get "$cfgfile" "prj_$prj" "branch")"
+ ini_config_is_set "$cfgfile" "prj_$prj" "branch" || pcfg_branch="$__dcfg_branch"
+ pcfg_reply_to_all="$(ini_config_get "$cfgfile" "prj_$prj" "reply_to_all")"
+ ini_config_is_set "$cfgfile" "prj_$prj" "reply_to_all" || pcfg_reply_to_all="$__dcfg_reply_to_all"
+ pcfg_accept_notify="$(ini_config_get "$cfgfile" "prj_$prj" "accept_notify")"
+ ini_config_is_set "$cfgfile" "prj_$prj" "accept_notify" || pcfg_accept_notify="$__dcfg_accept_notify"
pcfg_always_cc="$(ini_config_get "$cfgfile" "prj_$prj" "always_cc")"
+ ini_config_is_set "$cfgfile" "prj_$prj" "always_cc" || pcfg_always_cc="$__dcfg_always_cc"
pcfg_unwanted_keywords="$(ini_config_get "$cfgfile" "prj_$prj" "unwanted_keywords")"
+ ini_config_is_set "$cfgfile" "prj_$prj" "unwanted_keywords" || pcfg_unwanted_keywords="$__dcfg_unwanted_keywords"
pcfg_kmake_opts="$(ini_config_get "$cfgfile" "prj_$prj" "kmake_opts")"
+ ini_config_is_set "$cfgfile" "prj_$prj" "kmake_opts" || pcfg_kmake_opts="$__dcfg_kmake_opts"
}
# Compose (but not send) e-mail reply. This function assumes that the following
diff --git a/helpers/libshell/shell-ini-config b/helpers/libshell/shell-ini-config
index 5ed42f1..ba0bfbd 100644
--- a/helpers/libshell/shell-ini-config
+++ b/helpers/libshell/shell-ini-config
@@ -41,6 +41,39 @@ ini_config_get() {
done < "$fn"
}
+# Usage: ini_config_is_set file section var
+ini_config_is_set()
+{
+ local fn section var sect= str eof= n v
+ fn="$1" section="$2" var="$3"
+
+ while [ -z "$eof" ]; do
+ read -r str || eof=1
+
+ case "$str" in
+ "["*"]")
+ [ "$str" != "[$section]" ] ||
+ sect=1
+ ;;
+ "$shell_ini_config_comment"*|'')
+ ;;
+ *)
+ if [ -n "$sect" ]; then
+ shell_var_trim n "${str%%=*}"
+
+ if [ "$n" = "$var" ]; then
+ # Return success, since we found match.
+ return 0
+ fi
+ fi
+ ;;
+ esac
+ done < "$fn"
+
+ # We did not find match, so return failure.
+ return 1
+}
+
# Usage: ini_config_set file section var value
ini_config_set() {
local fn fn_tmp section var value sect= don= str eof= n v