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

Annotation of /rpms/appletalk-kmod/sme7/kmodtool-appletalk

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


Revision 1.1 - (hide annotations) (download)
Tue May 26 17:12:40 2009 UTC (15 years, 6 months ago) by slords
Branch: MAIN
CVS Tags: appletalk-kmod-1_0-4_el4_sme
Update to kABI tracking module

1 slords 1.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=( \$(rpm -ql kmod-${kmod_name}${dashvariant} | grep '\.ko$') )
135     if [ -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     rpm -ql kmod-${kmod_name}${dashvariant} | grep '\.ko$' \
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     #rm /var/run/rpm-kmod-${kmod_name}${dashvariant}-modules
156     if [ -x "/sbin/weak-modules" ]; then
157     printf '%s\n' "\${modules[@]}" \
158     | /sbin/weak-modules --remove-modules
159     fi
160     EOF
161    
162     fi
163    
164     echo "%files -n kmod-${kmod_name}${dashvariant}"
165    
166     if [ "" == "$kmp_override_filelist" ];
167     then
168     echo "%defattr(644,root,root,755)"
169     echo "/lib/modules/${verrel}${variant}/"
170     else
171     cat "$kmp_override_filelist"
172     fi
173     }
174    
175     print_rpmtemplate ()
176     {
177     kmod_name="${1}"
178     shift
179     kver="${1}"
180     get_verrel "${1}"
181     shift
182     if [ -z "${kmod_name}" ] ; then
183     echo "Please provide the kmodule-name as first parameter." >&2
184     exit 2
185     elif [ -z "${kver}" ] ; then
186     echo "Please provide the kver as second parameter." >&2
187     exit 2
188     elif [ -z "${verrel}" ] ; then
189     echo "Couldn't find out the verrel." >&2
190     exit 2
191     fi
192    
193     for variant in "$@" ; do
194     if [ "default" == "$variant" ];
195     then
196     get_rpmtemplate ""
197     else
198     get_rpmtemplate "${variant}"
199     fi
200     done
201     }
202    
203     usage ()
204     {
205     cat <<EOF
206     You called: ${invocation}
207    
208     Usage: ${myprog} <command> <option>+
209     Commands:
210     verrel <uname>
211     - Get "base" version-release.
212     variant <uname>
213     - Get variant from uname.
214     rpmtemplate <mainpgkname> <uname> <variants>
215     - Return a template for use in a source RPM
216     rpmtemplate_kmp <mainpgkname> <uname> <variants>
217     - Return a template for use in a source RPM with KMP dependencies
218     version
219     - Output version number and exit.
220     EOF
221     }
222    
223     invocation="$(basename ${0}) $@"
224     while [ "${1}" ] ; do
225     case "${1}" in
226     verrel)
227     shift
228     print_verrel $@
229     exit $?
230     ;;
231     variant)
232     shift
233     print_variant $@
234     exit $?
235     ;;
236     rpmtemplate)
237     shift
238     print_rpmtemplate "$@"
239     exit $?
240     ;;
241     rpmtemplate_kmp)
242     shift
243     kmp=1
244     print_rpmtemplate "$@"
245     exit $?
246     ;;
247     version)
248     echo "${myprog} ${myver}"
249     exit 0
250     ;;
251     *)
252     echo "Error: Unknown option '${1}'." >&2
253     usage >&2
254     exit 2
255     ;;
256     esac
257     done
258    
259     # Local variables:
260     # mode: sh
261     # sh-indentation: 2
262     # indent-tabs-mode: nil
263     # End:
264     # ex: ts=2 sw=2 et

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