Blame SOURCES/brp-kmod-restore-perms

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