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