/[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.3 - (hide annotations) (download)
Wed Apr 21 16:05:43 2010 UTC (14 years, 6 months ago) by slords
Branch: MAIN
CVS Tags: appletalk-kmod-1_0-6_el4_sme
Changes since 1.2: +5 -4 lines
* Wed Apr 21 2010 Shad L. Lords <slords@mail.com> 1.0-6.sme
- Update scriptlets to not call rpm [SME: 5448]

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

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