kernel-srpm-macros/brp-kmod-restore-perms
Eugene Syromiatnikov 94c911bd0a brp-kmod-restore-perms: handle kmod compression done in post-install hooks
If a kernel module are compressed by a post-install hook, then its name
would differ from the one saved by brp-kmod-set-exec-bit;  try to
recover from this by guessing a possible name of the compressed kmod and
using it instead.

* brp-kmod-restore-perms (while read perm path): Check for
"$RPM_BUILD_ROOT/$path.gz", "$RPM_BUILD_ROOT/$path.bz2",
and "$RPM_BUILD_ROOT/$path.xz" if "$RPM_BUILD_ROOT/$path"
does not exist, add the respective suffix to the $path.

Resolves: #1942537
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:38:10 +01:00

28 lines
805 B
Bash
Executable File

#! /bin/bash -efu
## A counterpart of brp-kmod-set-exec-bits that restores original kmod
## file permissions
# If using normal root, avoid changing anything.
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != "/" ] || exit 0
# Checking for required programs
which chmod >/dev/null || exit 0
[ -r "$RPM_BUILD_ROOT/kmod-permissions.list" ] || exit 0
while read perm path; do
[ -n "$perm" ] || continue
# Account for possible kernel module compression
[ -e "$RPM_BUILD_ROOT/$path" ] || {
[ \! -e "$RPM_BUILD_ROOT/$path.gz" ] || path="$path.gz"
[ \! -e "$RPM_BUILD_ROOT/$path.bz2" ] || path="$path.bz2"
[ \! -e "$RPM_BUILD_ROOT/$path.xz" ] || path="$path.xz"
}
chmod "$perm" "$RPM_BUILD_ROOT/$path"
done < "$RPM_BUILD_ROOT/kmod-permissions.list"
rm -f "$RPM_BUILD_ROOT/kmod-permissions.list"