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