Blame SOURCES/brp-kmod-restore-perms

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