/[smecontribs]/rpms/bmcsensors-kmod/contribs7/kmodtool2
ViewVC logotype

Annotation of /rpms/bmcsensors-kmod/contribs7/kmodtool2

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


Revision 1.1 - (hide annotations) (download)
Tue Mar 3 15:24:18 2009 UTC (15 years, 2 months ago) by slords
Branch: MAIN
CVS Tags: bmcsensors-kmod-1_0-20050320_2_6_9_78_0_13_EL, HEAD
Initial import of bmcsensors-kmod

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     #
7     # Permission is hereby granted, free of charge, to any person obtaining
8     # a copy of this software and associated documentation files (the
9     # "Software"), to deal in the Software without restriction, including
10     # without limitation the rights to use, copy, modify, merge, publish,
11     # distribute, sublicense, and/or sell copies of the Software, and to
12     # permit persons to whom the Software is furnished to do so, subject to
13     # the following conditions:
14     #
15     # The above copyright notice and this permission notice shall be
16     # included in all copies or substantial portions of the Software.
17     #
18     # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19     # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20     # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21     # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22     # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23     # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24     # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25    
26     shopt -s extglob
27    
28     myprog="kmodtool"
29     myver="0.10.10"
30     knownvariants=@(BOOT|PAE|@(big|huge)mem|debug|enterprise|kdump|?(large)smp|uml|xen[0U]?(-PAE))
31     kmod_name=
32     kver=
33     verrel=
34     variant=
35    
36     get_verrel ()
37     {
38     verrel=${1:-$(uname -r)}
39     verrel=${verrel%%$knownvariants}
40     }
41    
42     print_verrel ()
43     {
44     get_verrel $@
45     echo "${verrel}"
46     }
47    
48     get_variant ()
49     {
50     get_verrel $@
51     variant=${1:-$(uname -r)}
52     variant=${variant##$verrel}
53     variant=${variant:-'""'}
54     }
55    
56     print_variant ()
57     {
58     get_variant $@
59     echo "${variant}"
60     }
61    
62    
63     get_rpmtemplate ()
64     {
65     local variant="${1}"
66     local dashvariant="${variant:+-${variant}}"
67     case "$verrel" in
68     *.EL*) kdep="kernel${dashvariant}-%{_target_cpu} = ${verrel}" ;;
69     *) kdep="kernel-%{_target_cpu} = ${verrel}${variant}" ;;
70     esac
71     cat <<EOF
72     %package -n kmod-${kmod_name}${dashvariant}
73     Summary: ${kmod_name} kernel module(s)
74     Group: System Environment/Kernel
75     Provides: kernel-modules = ${verrel}${variant}
76     Provides: ${kmod_name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
77     Requires: ${kdep}
78     #Requires: ${kmod_name}-kmod-common >= %{?epoch:%{epoch}:}%{version}
79     Requires(post): /sbin/depmod
80     Requires(postun): /sbin/depmod
81     BuildRequires: kernel${dashvariant}-devel-%{_target_cpu} = ${verrel}
82     %description -n kmod-${kmod_name}${dashvariant}
83     This package provides the ${kmod_name} kernel modules built for the Linux
84     kernel ${verrel}${variant} for the %{_target_cpu} family of processors.
85     %post -n kmod-${kmod_name}${dashvariant}
86     test -f /boot/System.map-${verrel}${variant} && /sbin/depmod -aeF /boot/System.map-${verrel}${variant} ${verrel}${variant} > /dev/null || :
87     %postun -n kmod-${kmod_name}${dashvariant}
88     test -f /boot/System.map-${verrel}${variant} && /sbin/depmod -aF /boot/System.map-${verrel}${variant} ${verrel}${variant} &> /dev/null || :
89     %files -n kmod-${kmod_name}${dashvariant}
90     %defattr(644,root,root,755)
91     /lib/modules/${verrel}${variant}/updates/${kmod_name}/
92    
93     EOF
94     }
95    
96     print_rpmtemplate ()
97     {
98     kmod_name="${1}"
99     shift
100     kver="${1}"
101     get_verrel "${1}"
102     shift
103     if [ -z "${kmod_name}" ] ; then
104     echo "Please provide the kmodule-name as first parameter." >&2
105     exit 2
106     elif [ -z "${kver}" ] ; then
107     echo "Please provide the kver as second parameter." >&2
108     exit 2
109     elif [ -z "${verrel}" ] ; then
110     echo "Couldn't find out the verrel." >&2
111     exit 2
112     fi
113    
114     for variant in "$@" ; do
115     get_rpmtemplate "${variant}"
116     done
117     }
118    
119     usage ()
120     {
121     cat <<EOF
122     You called: ${invocation}
123    
124     Usage: ${myprog} <command> <option>+
125     Commands:
126     verrel <uname>
127     - Get "base" version-release.
128     variant <uname>
129     - Get variant from uname.
130     rpmtemplate <mainpgkname> <uname> <variants>
131     - Return a template for
132     version
133     - Output version number and exit.
134     EOF
135     }
136    
137     invocation="$(basename ${0}) $@"
138     while [ "${1}" ] ; do
139     case "${1}" in
140     verrel)
141     shift
142     print_verrel $@
143     exit $?
144     ;;
145     variant)
146     shift
147     print_variant $@
148     exit $?
149     ;;
150     rpmtemplate)
151     shift
152     print_rpmtemplate "$@"
153     exit $?
154     ;;
155     version)
156     echo "${myprog} ${myver}"
157     exit 0
158     ;;
159     *)
160     echo "Error: Unknown option '${1}'." >&2
161     usage >&2
162     exit 2
163     ;;
164     esac
165     done
166    
167     # Local variables:
168     # mode: sh
169     # sh-indentation: 2
170     # indent-tabs-mode: nil
171     # End:
172     # ex: ts=2 sw=2 et

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