/[smeserver]/rpms/ppp-kmod/sme7/kmodtool-ppp
ViewVC logotype

Contents of /rpms/ppp-kmod/sme7/kmodtool-ppp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download)
Tue Jun 1 16:33:47 2010 UTC (14 years, 6 months ago) by slords
Branch: MAIN
CVS Tags: ppp-kmod-1_0_2-8_el4_sme, HEAD
Changes since 1.3: +2 -1 lines
Fix module overrides and removal scripts

1 #!/bin/bash
2
3 # kmodtool - Helper script for building kernel module RPMs
4 # Copyright (c) 2003-2006 Ville Skyttä <ville.skytta@iki.fi>,
5 # Thorsten Leemhuis <fedora@leemhuis.info>
6 # Jon Masters <jcm@redhat.com>
7 #
8 # Permission is hereby granted, free of charge, to any person obtaining
9 # a copy of this software and associated documentation files (the
10 # "Software"), to deal in the Software without restriction, including
11 # without limitation the rights to use, copy, modify, merge, publish,
12 # distribute, sublicense, and/or sell copies of the Software, and to
13 # permit persons to whom the Software is furnished to do so, subject to
14 # the following conditions:
15 #
16 # The above copyright notice and this permission notice shall be
17 # included in all copies or substantial portions of the Software.
18 #
19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
27 shopt -s extglob
28
29 myprog="kmodtool"
30 myver="0.10.10_kmp2"
31 knownvariants=@(BOOT|PAE|@(big|huge)mem|debug|enterprise|kdump|?(large)smp|uml|xen[0U]?(-PAE)|xen)
32 kmod_name=
33 kver=
34 verrel=
35 variant=
36 kmp=
37
38 get_verrel ()
39 {
40 verrel=${1:-$(uname -r)}
41 verrel=${verrel%%$knownvariants}
42 }
43
44 print_verrel ()
45 {
46 get_verrel $@
47 echo "${verrel}"
48 }
49
50 get_variant ()
51 {
52 get_verrel $@
53 variant=${1:-$(uname -r)}
54 variant=${variant##$verrel}
55 variant=${variant:-'""'}
56 }
57
58 print_variant ()
59 {
60 get_variant $@
61 echo "${variant}"
62 }
63
64 get_rpmtemplate ()
65 {
66 local variant="${1}"
67 local dashvariant="${variant:+-${variant}}"
68 case "$verrel" in
69 *.EL*) kdep="kernel${dashvariant}-%{_target_cpu} = ${verrel}" ;;
70 *.plus*) kdep="kernel${dashvariant}-%{_target_cpu} = ${verrel}" ;;
71 *) kdep="kernel-%{_target_cpu} = ${verrel}${variant}" ;;
72 esac
73
74 echo "%package -n kmod-${kmod_name}${dashvariant}"
75
76 if [ -z "$kmp_provides_summary" ]; then
77 echo "Summary: ${kmod_name} kernel module(s)"
78 fi
79
80 if [ -z "$kmp_provides_group" ]; then
81 echo "Group: System Environment/Kernel"
82 fi
83
84 if [ ! -z "$kmp_version" ]; then
85 echo "Version: %{kmp_version}"
86 fi
87
88 if [ ! -z "$kmp_release" ]; then
89 echo "Release: %{kmp_release}"
90 fi
91
92 if [ ! -z "$kmp" ]; then
93 echo "%global _use_internal_dependency_generator 0"
94 fi
95
96 cat <<EOF
97 Provides: kernel-modules = ${verrel}${variant}
98 Provides: ${kmod_name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
99 EOF
100
101 if [ -z "$kmp" ]; then
102 echo "Requires: ${kdep}"
103 fi
104
105 cat <<EOF
106 Requires(post): /sbin/depmod
107 Requires(postun): /sbin/depmod
108 Requires: module-init-tools >= 3.1-0.pre5.3.10
109 EOF
110
111 if [ "no" != "$kmp_nobuildreqs" ]
112 then
113 echo "BuildRequires: kernel${dashvariant}-devel-%{_target_cpu} = ${verrel}"
114 fi
115
116 if [ "" != "$kmp_override_preamble" ]
117 then
118 cat "$kmp_override_preamble"
119 fi
120
121 cat <<EOF
122
123 %description -n kmod-${kmod_name}${dashvariant}
124 This package provides the ${kmod_name} kernel modules built for the Linux
125 kernel ${verrel}${variant} for the %{_target_cpu} family of processors.
126 %post -n kmod-${kmod_name}${dashvariant}
127 if [ -e "/boot/System.map-${verrel}${variant}" ]; then
128 /sbin/depmod -aeF "/boot/System.map-${verrel}${variant}" "${verrel}${variant}" > /dev/null || :
129 fi
130 EOF
131
132 if [ ! -z "$kmp" ]; then
133 cat <<EOF
134 modules=( \$(cat /usr/share/doc/kmod-${kmod_name}/${verrel}/modules${dashvariant}) )
135 if [[ ! -z "\$modules" && -x "/sbin/weak-modules" ]]; then
136 printf '%s\n' "\${modules[@]}" \
137 | /sbin/weak-modules --add-modules
138 fi
139 %preun -n kmod-${kmod_name}${dashvariant}
140 cp /usr/share/doc/kmod-${kmod_name}/${verrel}/modules${dashvariant} \
141 /var/run/rpm-kmod-${kmod_name}${dashvariant}-modules
142 EOF
143
144 fi
145
146 cat <<EOF
147
148 %postun -n kmod-${kmod_name}${dashvariant}
149 /sbin/depmod -aF /boot/System.map-${verrel}${variant} ${verrel}${variant} &> /dev/null || :
150 EOF
151
152 if [ ! -z "$kmp" ]; then
153 cat <<EOF
154 modules=( \$(cat /var/run/rpm-kmod-${kmod_name}${dashvariant}-modules) )
155 if [[ ! -z "\$modules" && -x "/sbin/weak-modules" ]]; then
156 printf '%s\n' "\${modules[@]}" \
157 | /sbin/weak-modules --remove-modules
158 fi
159 EOF
160
161 fi
162
163 echo "%files -n kmod-${kmod_name}${dashvariant}"
164
165 if [ "" == "$kmp_override_filelist" ];
166 then
167 echo "%defattr(644,root,root,755)"
168 echo "/etc/depmod.d/${kmod_name}.conf"
169 echo "/lib/modules/${verrel}${variant}/"
170 echo "%dir /usr/share/doc/kmod-${kmod_name}/${verrel}/"
171 echo "/usr/share/doc/kmod-${kmod_name}/${verrel}/modules${dashvariant}"
172 else
173 cat "$kmp_override_filelist"
174 fi
175 }
176
177 print_rpmtemplate ()
178 {
179 kmod_name="${1}"
180 shift
181 kver="${1}"
182 get_verrel "${1}"
183 shift
184 if [ -z "${kmod_name}" ] ; then
185 echo "Please provide the kmodule-name as first parameter." >&2
186 exit 2
187 elif [ -z "${kver}" ] ; then
188 echo "Please provide the kver as second parameter." >&2
189 exit 2
190 elif [ -z "${verrel}" ] ; then
191 echo "Couldn't find out the verrel." >&2
192 exit 2
193 fi
194
195 for variant in "$@" ; do
196 if [ "default" == "$variant" ];
197 then
198 get_rpmtemplate ""
199 else
200 get_rpmtemplate "${variant}"
201 fi
202 done
203 }
204
205 usage ()
206 {
207 cat <<EOF
208 You called: ${invocation}
209
210 Usage: ${myprog} <command> <option>+
211 Commands:
212 verrel <uname>
213 - Get "base" version-release.
214 variant <uname>
215 - Get variant from uname.
216 rpmtemplate <mainpgkname> <uname> <variants>
217 - Return a template for use in a source RPM
218 rpmtemplate_kmp <mainpgkname> <uname> <variants>
219 - Return a template for use in a source RPM with KMP dependencies
220 version
221 - Output version number and exit.
222 EOF
223 }
224
225 invocation="$(basename ${0}) $@"
226 while [ "${1}" ] ; do
227 case "${1}" in
228 verrel)
229 shift
230 print_verrel $@
231 exit $?
232 ;;
233 variant)
234 shift
235 print_variant $@
236 exit $?
237 ;;
238 rpmtemplate)
239 shift
240 print_rpmtemplate "$@"
241 exit $?
242 ;;
243 rpmtemplate_kmp)
244 shift
245 kmp=1
246 print_rpmtemplate "$@"
247 exit $?
248 ;;
249 version)
250 echo "${myprog} ${myver}"
251 exit 0
252 ;;
253 *)
254 echo "Error: Unknown option '${1}'." >&2
255 usage >&2
256 exit 2
257 ;;
258 esac
259 done
260
261 # Local variables:
262 # mode: sh
263 # sh-indentation: 2
264 # indent-tabs-mode: nil
265 # End:
266 # ex: ts=2 sw=2 et

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed