From e37dd9295e0d1c842f33a0502d2af0612015543f Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 02 Apr 2019 04:22:31 -0400 Subject: ob_set_binary_substvar(), ob_substvars(): Clean up binary package names Fixes substvars for binary packages with non-alphanumeric characters in their names. --- (limited to 'lib') 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}" -- cgit v0.9.1