2008-07-18 12:15:21 +02:00
|
|
|
%package -n %{-n*}-%1
|
2009-09-28 17:23:22 +02:00
|
|
|
%define _this_kmp_version %{-v*}_%(echo %2 | sed -r 'y/-/_/; s/^(2\.6\.[0-9]+)_/\\1.0_/; # use 2.6.x.0 for mainline kernels')
|
|
|
|
Version: %_this_kmp_version
|
2008-07-18 12:15:21 +02:00
|
|
|
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
|
|
|
|
)
|
2009-09-28 17:23:22 +02:00
|
|
|
Provides: %{-n*} = %_this_kmp_version
|
2009-11-27 14:28:36 +01:00
|
|
|
Provides: multiversion(kernel)
|
2008-11-08 19:28:50 +01:00
|
|
|
Requires: coreutils grep
|
2009-06-08 23:58:20 +02:00
|
|
|
Enhances: kernel-%1
|
2008-07-18 12:15:21 +02:00
|
|
|
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
|
2009-09-28 17:23:22 +02:00
|
|
|
nvr=%{-n*}-%1-%_this_kmp_version-%{-r*}
|
2008-10-12 00:19:34 +02:00
|
|
|
wm2=/usr/lib/module-init-tools/weak-modules2
|
|
|
|
if [ -x $wm2 ]; then
|
2009-02-16 18:56:32 +01:00
|
|
|
/bin/bash -${-/e/} $wm2 --add-kmp $nvr
|
2008-07-18 12:15:21 +02:00
|
|
|
fi
|
|
|
|
%preun -n %{-n*}-%1
|
2009-09-28 17:23:22 +02:00
|
|
|
nvr=%{-n*}-%1-%_this_kmp_version-%{-r*}
|
2009-01-10 14:03:47 +01:00
|
|
|
rpm -ql $nvr | sed -n '/\.ko$/p' > /var/run/rpm-$nvr-modules
|
2008-07-18 12:15:21 +02:00
|
|
|
%postun -n %{-n*}-%1
|
2009-09-28 17:23:22 +02:00
|
|
|
nvr=%{-n*}-%1-%_this_kmp_version-%{-r*}
|
2008-10-12 00:19:34 +02:00
|
|
|
modules=( $(cat /var/run/rpm-$nvr-modules) )
|
|
|
|
rm -f /var/run/rpm-$nvr-modules
|
2009-01-10 14:03:47 +01:00
|
|
|
if [ ${#modules[*]} = 0 ]; then
|
|
|
|
echo "WARNING: $nvr does not contain any kernel modules" >&2
|
|
|
|
exit 0
|
|
|
|
fi
|
2008-10-12 00:19:34 +02:00
|
|
|
wm2=/usr/lib/module-init-tools/weak-modules2
|
|
|
|
if [ -x $wm2 ]; then
|
2009-02-16 18:56:32 +01:00
|
|
|
printf '%s\n' "${modules[@]}" | /bin/bash -${-/e/} $wm2 --remove-kmp $nvr
|
2008-07-18 12:15:21 +02:00
|
|
|
fi
|
|
|
|
%files -n %{-n*}-%1
|
|
|
|
%{-f:%{expand:%(cd %_sourcedir; cat %{-f*})}}
|
|
|
|
%{!-f:%defattr (-,root,root)}
|
2009-01-10 14:03:47 +01:00
|
|
|
%{!-f:/lib/modules/%2-%1}
|