]> git.pld-linux.org Git - projects/template-specs.git/blob - kernel-module.spec
- alt kernel stuff
[projects/template-specs.git] / kernel-module.spec
1 #
2 # Replace:
3 # MODULE_NAME with real module name
4 # MODULE_DIR with required directory name
5 # PACKAGE_NAME with package name
6 #
7 # Conditional build:
8 %bcond_without  dist_kernel     # allow non-distribution kernel
9 %bcond_without  kernel          # don't build kernel modules
10 %bcond_without  userspace       # don't build userspace programs
11 %bcond_with     verbose         # verbose build (V=1)
12
13 %if %{without kernel}
14 %undefine       with_dist_kernel
15 %endif
16 %if "%{_alt_kernel}" != "%{nil}"
17 %undefine       with_userspace
18 %endif
19 %if %{without userspace}
20 # nothing to be placed to debuginfo package
21 %define         _enable_debug_packages  0
22 %endif
23
24 #
25 # main package.
26 #
27 %define         rel     0.1
28 %define         pname   PACKAGE_NAME
29 Summary:        -
30 Summary(pl.UTF-8):      -
31 Name:           -
32 Version:        0.1
33 Release:        %{rel}
34 Epoch:          0
35 #License:       - (enter GPL/LGPL/BSD/BSD-like/other license name here)
36 Group:          -
37 Source0:        %{pname}-%{version}.tar.gz
38 # Source0-md5:  -
39 #Source1:       -
40 # Source1-md5:  -
41 #Patch0:        %{pname}-what.patch
42 #URL:           -
43 %if %{with kernel}
44 %{?with_dist_kernel:BuildRequires:      kernel%{_alt_kernel}-module-build >= 3:2.6.20.2}
45 BuildRequires:  rpmbuild(macros) >= 1.379
46 %endif
47 #BuildRequires: -
48 #Requires(postun):      -
49 #Requires(pre,post):    -
50 #Requires(preun):       -
51 #Requires:      -
52 #Provides:      -
53 #Obsoletes:     -
54 #Conflicts:     -
55 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
56
57 %description
58
59 %description -l pl.UTF-8
60
61 # kernel subpackages.
62
63 %package -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
64 Summary:        Linux driver for MODULE_NAME
65 Summary(pl.UTF-8):      Sterownik dla Linuksa do MODULE_NAME
66 Release:        %{rel}@%{_kernel_ver_str}
67 Group:          Base/Kernel
68 Requires(post,postun):  /sbin/depmod
69 %if %{with dist_kernel}
70 %requires_releq_kernel
71 Requires(postun):       %releq_kernel
72 %endif
73
74 %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
75 This is driver for MODULE_NAME for Linux.
76
77 This package contains Linux module.
78
79 %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME -l pl.UTF-8
80 Sterownik dla Linuksa do MODULE_NAME.
81
82 Ten pakiet zawiera moduł jądra Linuksa.
83
84 %prep
85 %setup -q -n %{pname}-%{version}
86
87 # prepare makefile:
88 cat > path/to/dir/Makefile << EOF
89
90 obj-m += MODULE_NAME.o MODULE2.o
91
92 MODULE_NAME-objs := file1.o file2.o \
93         file3.o file4.o file5.o
94
95 MODULE2-objs := file6.o file7.o file8.o
96
97 CFLAGS += -DCONFIG_MODULE_NAME_SOME_OPTION=1
98 %{?debug:CFLAGS += -DCONFIG_MODULE_NAME_DEBUG=1}
99 EOF
100
101 %build
102 %if %{with userspace}
103
104
105 %endif
106
107 %if %{with kernel}
108 %build_kernel_modules -m MODULE_NAME
109
110 # modules placed in subdirectory:
111 %build_kernel_modules -C path/to/dir -m MODULE_NAME,MODULE2
112
113 # need to pass additional options to make modules:
114 %build_kernel_modules VAR1=value1 VAR2=value2 -m MODULE_NAME
115
116 # optional patching:
117 %build_kernel_modules -m MODULE_NAME <<'EOF'
118 # Your script here:
119 if grep -q "CONFIG_SOME_OPTION" o/.config; then
120         sed 's/some/change/' file.c.orig > file.c
121 else
122         cat file.c.orig > file.c
123 fi
124 # Don't do it this way unless it depends on kernel options or something
125 # you can't check before
126 EOF
127
128 %endif
129
130 %install
131 rm -rf $RPM_BUILD_ROOT
132
133 %if %{with userspace}
134
135
136 %endif
137
138 %if %{with kernel}
139 %install_kernel_modules -m MODULE_NAME -d kernel/MODULE_DIR
140
141 # to avoid conflict with in-kernel modules, and prepare modprobe config:
142 %install_kernel_modules -s current -n NAME -m MODULE_NAME -d kernel/MODULE_DIR
143 %endif
144
145 %clean
146 rm -rf $RPM_BUILD_ROOT
147
148 %post   -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
149 %depmod %{_kernel_ver}
150
151 %postun -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
152 %depmod %{_kernel_ver}
153
154 %if %{with kernel}
155 %files -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
156 %defattr(644,root,root,755)
157 /lib/modules/%{_kernel_ver}/kernel/MODULE_DIR/*.ko*
158 %endif
159
160 %if %{with userspace}
161 %files
162 %defattr(644,root,root,755)
163
164 %endif
This page took 0.080325 seconds and 3 git commands to generate.