kernel-source/kernel-module-subpackage

122 lines
3.3 KiB
Plaintext

%package -n %{-n*}-%1
Version: %(echo %{-v*}-%3 | tr - _)
Release: %{-r*}
%(
for spec in {%_sourcedir,%_specdir}/%name.spec /dev/null; do
[ -e $spec ] && break
done
awk '
BEGIN { tags["summary"] = "Summary: %summary"
tags["group"] = "Group: %group" }
/^%%/ { in_pkg_header = \
($0 ~ /^%%package[ \t]+KMP[ \t]*$/ ||
$0 ~ /^%%package[ \t]+-n[ \t]*%name-KMP[ \t]*$/)
next }
in_pkg_header && /^(Summary|Group):[ \t]*/ \
{ tag = tolower($1) ; sub(/:$/, "", tag)
tags[tag] = $0 }
END { print tags["summary"]
print tags["group"] }
' $spec
)
Provides: %{-n*} = %(echo %{-v*}-%3 | tr - _)
Requires: kernel-%1 coreutils grep
AutoReqProv: on
%{-p:%{expand:%(cd %_sourcedir; cat %{-p*})}}
%description -n %{-n*}-%1
%(
for spec in {%_sourcedir,%_specdir}/%name.spec /dev/null; do
[ -e $spec ] && break
done
awk '
/^%%/ { in_desc = \
($0 ~ /^%%description[ \t]+KMP[ \t]*$/ ||
$0 ~ /^%%description[ \t]+-n[ \t]*%name-KMP[ \t]*$/)
next }
in_desc { print; good = 1 }
END { exit(! good) }
' $spec || \
awk '
/^%%/ { in_desc = \
($0 ~ /^%%description[ \t]*$/ ||
$0 ~ /^%%description[ \t]+-n[ \t]*%name[ \t]*$/)
next }
in_desc { print; good = 1 }
END { exit(! good) }
' $spec
)
%post -n %{-n*}-%1
version=%(echo %{-v*}-%3 | tr - _)
if [ -e /boot/System.map-%2 ]; then
/sbin/depmod -a -F /boot/System.map-%2 %2
fi
modules=( $(rpm -ql %{-n*}-%1-$version-%{-r*} | grep '\.ko$') )
if [ -x /usr/lib/module-init-tools/weak-modules ]; then
printf '%s\n' "${modules[@]}" \
| /usr/lib/module-init-tools/weak-modules --add-modules
fi
if [ -e /etc/sysconfig/kernel -a -e /boot/initrd-%2 ]; then
source /etc/sysconfig/kernel
run_mkinitrd=
set -- "${modules[@]##*/}" ; set -- "${@%.ko}"
for module in $INITRD_MODULES; do
case " $* " in
*" $module "*)
run_mkinitrd=1
break ;;
esac
done
if [ -n "$run_mkinitrd" ]; then
for image in vmlinuz image vmlinux linux bzImage; do
if [ -f /boot/$image-%2 ]; then
/sbin/mkinitrd -k /boot/$image-%2 \
-i /boot/initrd-%2 \
|| exit 1
break
fi
done
fi
fi
%preun -n %{-n*}-%1
version=%(echo %{-v*}-%3 | tr - _)
set -o noclobber
rpm -ql %{-n*}-%1-$version-%{-r*} | grep '\.ko$' \
> /var/run/rpm-%{-n*}-%1-$version-%{-r*}-modules
%postun -n %{-n*}-%1
version=%(echo %{-v*}-%3 | tr - _)
modules=( $(cat /var/run/rpm-%{-n*}-%1-$version-%{-r*}-modules) )
rm -f /var/run/rpm-%{-n*}-%1-$version-%{-r*}-modules
if [ -e /boot/System.map-%2 ]; then
/sbin/depmod -a -F /boot/System.map-%2 %2
fi
if [ -x /usr/lib/module-init-tools/weak-modules ]; then
printf '%s\n' "${modules[@]}" \
| /usr/lib/module-init-tools/weak-modules --remove-modules
fi
if [ -e /etc/sysconfig/kernel -a -e /boot/initrd-%2 ]; then
source /etc/sysconfig/kernel
run_mkinitrd=
set -- "${modules[@]##*/}" ; set -- "${@%.ko}"
for module in $INITRD_MODULES; do
case " $* " in
*" $module "*)
run_mkinitrd=1
break ;;
esac
done
if [ -n "$run_mkinitrd" ]; then
for image in vmlinuz image vmlinux linux bzImage; do
if [ -f /boot/$image-%2 ]; then
/sbin/mkinitrd -k /boot/$image-%2 \
-i /boot/initrd-%2 \
|| exit 1
break
fi
done
fi
fi
%files -n %{-n*}-%1
%{-f:%{expand:%(cd %_sourcedir; cat %{-f*})}}
%{!-f:%defattr (-,root,root)}
%{!-f:/lib/modules/%2}