kpatch-build: replace special characters in module name

Having a '.' in the kmod name confuses lsmod, which prints "Size" and
"Used by" values of -2.  Prevent any special characters other than '_'
and '-', so that our patch module names will be consistent with typical
kmod names.
This commit is contained in:
Josh Poimboeuf 2014-05-05 10:27:26 -05:00
parent 8bce2712c7
commit 5e4ac36253
1 changed files with 4 additions and 0 deletions

View File

@ -146,6 +146,10 @@ if [[ "$PATCHNAME" =~ \.patch ]] || [[ "$PATCHNAME" =~ \.diff ]]; then
PATCHNAME="${PATCHNAME%.*}"
fi
# Only allow alphanumerics and '_' and '-' in the module name.
# Everything else is replaced with '-'.
PATCHNAME=${PATCHNAME//[^a-zA-Z0-9_-]/-}
TEMPDIR="$(mktemp -d /tmp/kpatch-build-XXXXXX)" || die "mktemp failed"
trap cleanup EXIT INT TERM