3 # kmodtool - Helper script for building kernel module RPMs
4 # Copyright (c) 2003-2007 Ville Skyttä <ville.skytta@iki.fi>,
5 # Thorsten Leemhuis <fedora@leemhuis.info>
7 # Modified by Simon Wilkinson for OpenAFS
9 # Permission is hereby granted, free of charge, to any person obtaining
10 # a copy of this software and associated documentation files (the
11 # "Software"), to deal in the Software without restriction, including
12 # without limitation the rights to use, copy, modify, merge, publish,
13 # distribute, sublicense, and/or sell copies of the Software, and to
14 # permit persons to whom the Software is furnished to do so, subject to
15 # the following conditions:
17 # The above copyright notice and this permission notice shall be
18 # included in all copies or substantial portions of the Software.
20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 knownvariants=@(BOOT|PAE?(-debug)|@(big|huge)mem|debug|enterprise|kdump|?(large)smp?(-debug)|uml|xen?([0U])?(-PAE))
40 verrel=${1:-$(uname -r)}
41 verrel=${verrel%%$knownvariants}
43 *.el6.elrepo*) verrel="`echo ${verrel} | sed -e 's/^\(.*.el6.elrepo[^\.]*\)\.[^\.]\+.\?$/\1/'`" ;;
44 *.el6*) verrel="`echo ${verrel} | sed -e 's/^\(.*.el6[^\.]*\)\.[^\.]\+.\?$/\1/'`" ;;
45 *.fc9*) verrel="`echo ${verrel} | sed -e 's/^\(.*.fc9[^\.]*\)\.[^\.]\+.\?$/\1/'`" ;;
46 *.fc1?*) verrel="`echo ${verrel} | sed -e 's/^\(.*.fc1[0-9][^\.]*\)\.[^\.]\+.\?$/\1/'`" ;;
59 variant=${1:-$(uname -r)}
60 variant=${variant##$verrel}
61 variant=${variant:-'""'}
74 local dashvariant="${variant:+-${variant}}"
76 *.el6*) kdep="kernel-%{_target_cpu} = ${verrel}${variant}" ;;
77 *.EL*) kdep="kernel${dashvariant}-%{_target_cpu} = ${verrel}" ;;
78 *) kdep="kernel-%{_target_cpu} = ${verrel}${variant}" ;;
81 *.el6*) kname="${verrel}.%{_target_cpu}${variant:+.${variant}}" ;;
82 *.fc9*) kname="${verrel}.%{_target_cpu}${variant:+.${variant}}" ;;
83 *.fc1?*) kname="${verrel}.%{_target_cpu}${variant:+.${variant}}" ;;
84 *) kname="${verrel}${variant}" ;;
88 %package -n kmod-${kmod_name}${dashvariant}
89 Summary: ${kmod_name} kernel module(s)
90 Group: System Environment/Kernel
91 Provides: kernel-modules = ${kname}
92 Provides: ${kmod_name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
93 Provides: openafs-kernel = %{PACKAGE_VERSION}
95 Requires: ${kmod_name}-kmod-common >= %{?epoch:%{epoch}:}%{version}
96 Requires(post): /sbin/depmod
97 Requires(postun): /sbin/depmod
98 Release: %{pkgrel}.%(echo ${verrel} | tr - _)
99 BuildRequires: kernel${dashvariant}-devel-%{_target_cpu} = ${verrel}
100 %description -n kmod-${kmod_name}${dashvariant}
101 This package provides the ${kmod_name} kernel modules built for the Linux
102 kernel ${kname} for the %{_target_cpu} family of processors.
103 %post -n kmod-${kmod_name}${dashvariant}
104 /sbin/depmod -aeF /boot/System.map-${kname} ${kname} > /dev/null || :
105 %postun -n kmod-${kmod_name}${dashvariant}
106 /sbin/depmod -aF /boot/System.map-${kname} ${kname} &> /dev/null || :
107 %files -n kmod-${kmod_name}${dashvariant}
108 %defattr(644,root,root,755)
109 /lib/modules/${kname}/extra/${kmod_name}/
121 if [ -z "${kmod_name}" ] ; then
122 echo "Please provide the kmodule-name as first parameter." >&2
124 elif [ -z "${kver}" ] ; then
125 echo "Please provide the kver as second parameter." >&2
127 elif [ -z "${verrel}" ] ; then
128 echo "Couldn't find out the verrel." >&2
132 for variant in "$@" ; do
133 get_rpmtemplate "${variant}"
140 You called: ${invocation}
142 Usage: ${myprog} <command> <option>+
145 - Get "base" version-release.
147 - Get variant from uname.
148 rpmtemplate <mainpgkname> <uname> <variants>
149 - Return a template for
151 - Output version number and exit.
155 invocation="$(basename ${0}) $@"
156 while [ "${1}" ] ; do
170 print_rpmtemplate "$@"
174 echo "${myprog} ${myver}"
178 echo "Error: Unknown option '${1}'." >&2
188 # indent-tabs-mode: nil