summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-04-02 04:22:31 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-04-02 04:22:31 (EDT)
commite37dd9295e0d1c842f33a0502d2af0612015543f (patch)
treeb87a9ab0e50bf5082fe369640ba7354740cf3f4e /lib
parente00306551ce9fa1ed709eedd581c98dd29481b28 (diff)
ob_set_binary_substvar(), ob_substvars(): Clean up binary package names
Fixes substvars for binary packages with non-alphanumeric characters in their names.
Diffstat (limited to 'lib')
-rw-r--r--lib/control.sh5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/control.sh b/lib/control.sh
index 0fdd715..248b422 100644
--- a/lib/control.sh
+++ b/lib/control.sh
@@ -244,6 +244,9 @@ ob_set_binary_substvar()
# Trim leading and trailing whitespace from value.
value="$(printf '%s' "${value}" | sed -n "${_OB_SUBSTVAR_TRIM_SED}")"
+ # Convert package name to clean form.
+ package="$(printf '%s' "${package}" | tr 'a-z' 'A-Z' | tr -dC 'A-Z0-9')"
+
# TODO: Maybe disallow variable names beginning with hyphens, and/or
# otherwise make this safer.
eval "_OB_SUBSTVAR_BIN_${package}__${name}=\"\${value}\""
@@ -322,6 +325,8 @@ ob_substvars()
# Perform the substitution.
name_tr="$(printf '%s' "${name}" | tr 'a-z-' 'A-Z_')"
+ package="$(printf '%s' "${package}" | tr 'a-z' 'A-Z' | \
+ tr -dC 'A-Z0-9')"
if eval "[ x\"\${_OB_SUBSTVAR_SRC_${name_tr}:+set}\" = x'set' ]"
then
name_tr="_OB_SUBSTVAR_SRC_${name_tr}"