Lines Matching +full:in +full:- +full:kernel
2 # SPDX-License-Identifier: MIT
5 # kmodtool - Helper script for building kernel module RPMs
6 # Copyright (c) 2003-2012 Ville Skyttä <ville.skytta@iki.fi>,
12 # "Software"), to deal in the Software without restriction, including
19 # included in all copies or substantial portions of the Software.
24 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 shopt -s extglob
31 myprog="kmodtool-${repo}"
50 # the next line is not multi-line safe -- not needed *yet*
69 %global akmod_install mkdir -p \$RPM_BUILD_ROOT/%{_usrsrc}/akmods/; \\\
70 LANG=C rpmbuild --define "_sourcedir %{_sourcedir}" \\\
71 --define "_srcrpmdir \$RPM_BUILD_ROOT/%{_usrsrc}/akmods/" \\\
72 -bs --nodeps %{_specdir}/%{name}.spec ; \\\
73 ln -s \$(ls \$RPM_BUILD_ROOT/%{_usrsrc}/akmods/) \$RPM_BUILD_ROOT/%{_usrsrc}/akmods/${kmodname}-kmo…
75 %package -n akmod-${kmodname}
76 Summary: Akmod package for ${kmodname} kernel module(s)
77 Group: System Environment/Kernel
82 Requires: ${kmodname}-kmod-common >= %{?epoch:%{epoch}:}%{version}
83 Provides: ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
88 %description -n akmod-${kmodname}
89 This package provides the akmod package for the ${kmodname} kernel modules.
91 %posttrans -n akmod-${kmodname}
92 nohup ${prefix}/sbin/akmods --from-akmod-posttrans --akmod ${kmodname} &> /dev/null &
94 %files -n akmod-${kmodname}
95 %defattr(-,root,root,-)
104 %package -n kmod-${kmodname}
105 Summary: Metapackage which tracks in ${kmodname} kernel module for newest kernel${dashvaria…
106 Group: System Environment/Kernel
108 Provides: ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
109 Provides: kmod-${kmodname}-xen = %{?epoch:%{epoch}:}%{version}-%{release}
110 Provides: kmod-${kmodname}-smp = %{?epoch:%{epoch}:}%{version}-%{release}
111 Provides: kmod-${kmodname}-PAE = %{?epoch:%{epoch}:}%{version}-%{release}
112 Requires: akmod-${kmodname} = %{?epoch:%{epoch}:}%{version}-%{release}
117 %description -n kmod-${kmodname}${dashvariant}
118 This is a meta-package without payload which sole purpose is to require the
119 ${kmodname} kernel module(s) for the newest kernel${dashvariant},
120 to make sure you get it together with a new kernel.
122 %files -n kmod-${kmodname}${dashvariant}
129 if [[ "${1}" = "--custom" ]]; then
132 elif [[ "${1}" = "--redhat" ]]; then
139 local kernel_variant="${2:+-${2}}"
143 if [[ ! -f "${depmod_path}" ]]; then
149 %package -n kmod-${kmodname}-${kernel_uname_r}
150 Summary: ${kmodname} kernel module(s) for ${kernel_uname_r}
151 Group: System Environment/Kernel
152 Provides: kernel-modules-for-kernel = ${kernel_uname_r}
153 Provides: kmod-${kmodname}-uname-r = ${kernel_uname_r}
154 Provides: ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
155 Requires: ${kmodname}-kmod-common >= %{?epoch:%{epoch}:}%{version}
158 Requires(post): module-init-tools
159 Requires(postun): module-init-tools
167 if [[ -z "${customkernel}" ]]; then
169 Requires: kernel-uname-r = ${kernel_uname_r}
170 BuildRequires: kernel-devel-uname-r = ${kernel_uname_r}
171 %{?KmodsRequires:Requires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
172 %{?KmodsRequires:BuildRequires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
173 %post -n kmod-${kmodname}-${kernel_uname_r}
174 if [[ -f "/boot/System.map-${kernel_uname_r}" ]]; then
175 ${prefix}${depmod_path} -aeF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} > /dev/null || :
176 elif [[ -f "/lib/modules/${kernel_uname_r}/System.map" ]]; then
177 …${prefix}${depmod_path} -aeF /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} > /dev/nu…
179 ${prefix}${depmod_path} -ae ${kernel_uname_r} &> /dev/null || :
181 %postun -n kmod-${kmodname}-${kernel_uname_r}
182 if [[ -f "/boot/System.map-${kernel_uname_r}" ]]; then
183 ${prefix}${depmod_path} -aF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} &> /dev/null || :
184 elif [[ -f "/lib/modules/${kernel_uname_r}/System.map" ]]; then
185 …${prefix}${depmod_path} -aF /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} &> /dev/nu…
187 ${prefix}${depmod_path} -a ${kernel_uname_r} &> /dev/null || :
193 %post -n kmod-${kmodname}-${kernel_uname_r}
194 [ "\$(uname -r)" = "${kernel_uname_r}" ] && ${prefix}${depmod_path} -a > /dev/null || :
195 %postun -n kmod-${kmodname}-${kernel_uname_r}
196 [ "\$(uname -r)" = "${kernel_uname_r}" ] && ${prefix}${depmod_path} -a > /dev/null || :
203 %description -n kmod-${kmodname}-${kernel_uname_r}
204 This package provides the ${kmodname} kernel modules built for the Linux
205 kernel ${kernel_uname_r} for the %{_target_cpu} family of processors.
206 %files -n kmod-${kmodname}-${kernel_uname_r}
217 if [[ "${1}" = "--custom" ]]; then
220 elif [[ "${1}" = "--redhat" ]]; then
228 %package -n kmod-${kmodname}-devel
229 Summary: ${kmodname} kernel module(s) devel common
230 Group: System Environment/Kernel
231 Provides: ${kmodname}-devel-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
234 if [[ -z "${customkernel}" ]] && [[ -z "${redhatkernel}" ]]; then
235 …echo "Requires: kmod-${kmodname}-devel-${kernel_uname_r} >= %{?epoch:%{epoch}:}%{version}-%…
239 %description -n kmod-${kmodname}-devel
240 This package provides the common header files to build kernel modules
241 which depend on the ${kmodname} kernel module. It may optionally require
242 the ${kmodname}-devel-<kernel> objects for the newest kernel.
244 %files -n kmod-${kmodname}-devel
246 %{_usrsrc}/${kmodname}-%{version}
249 for kernel in ${1}; do
250 local kernel_uname_r=${kernel}
251 echo "%exclude %{_usrsrc}/${kmodname}-%{version}/${kernel_uname_r}"
260 if [[ "${1}" = "--custom" ]]; then
263 elif [[ "${1}" = "--redhat" ]]; then
270 local kernel_variant="${2:+-${2}}"
274 %package -n kmod-${kmodname}-devel-${kernel_uname_r}
275 Summary: ${kmodname} kernel module(s) devel for ${kernel_uname_r}
276 Group: System Environment/Kernel
277 Provides: kernel-objects-for-kernel = ${kernel_uname_r}
278 Provides: ${kmodname}-devel-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
279 Provides: kmod-${kmodname}-devel-uname-r = ${kernel_uname_r}
283 if [[ -z "${customkernel}" ]]; then
285 Requires: kernel-devel-uname-r = ${kernel_uname_r}
286 BuildRequires: kernel-devel-uname-r = ${kernel_uname_r}
287 %{?KmodsDevelRequires:Requires: %{KmodsDevelRequires}-uname-r = ${kernel_uname_r}}
288 %{?KmodsDevelRequires:BuildRequires: %{KmodsDevelRequires}-uname-r = ${kernel_uname_r}}
294 %description -n kmod-${kmodname}-devel-${kernel_uname_r}
295 This package provides objects and symbols required to build kernel modules
296 which depend on the ${kmodname} kernel modules built for the Linux
297 kernel ${kernel_uname_r} for the %{_target_cpu} family of processors.
298 %files -n kmod-${kmodname}-devel-${kernel_uname_r}
300 %{_usrsrc}/${kmodname}-%{version}/${kernel_uname_r}
307 local kernel_variant="${2:+-${2}}"
310 %package -n kmod-${kmodname}${kernel_variant}
311 Summary: Metapackage which tracks in ${kmodname} kernel module for newest kernel${kernel_va…
312 Group: System Environment/Kernel
314 Provides: ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
315 Requires: kmod-${kmodname}-${kernel_uname_r} >= %{?epoch:%{epoch}:}%{version}-%{release}
321 %description -n kmod-${kmodname}${kernel_variant}
322 This is a meta-package without payload which sole purpose is to require the
323 ${kmodname} kernel module(s) for the newest kernel${kernel_variant}.
324 to make sure you get it together with a new kernel.
326 %files -n kmod-${kmodname}${kernel_variant}
335 for kernel in ${1}
337 if [[ -e "${prefix}/lib/modules/${kernel}/build/Makefile" ]]; then
338 # likely a user-build-kernel with available buildfiles
339 # fixme: we should check if uname from Makefile is the same as ${kernel}
341 kernel_versions="${kernel_versions}${kernel}___${prefix}/lib/modules/${kernel}/build/ "
342 print_rpmtemplate_per_kmodpkg --custom "${kernel}"
345 if [[ -n "${devel}" ]]; then
347 print_rpmtemplate_kmoddevelpkg --custom "${kernel}"
350 print_rpmtemplate_per_kmoddevelpkg --custom "${kernel}"
352 elif [[ -e "${buildroot}/usr/src/kernels/${kernel}" ]]; then
353 …# this looks like a Fedora/RH kernel -- print a normal template (which includes the proper BR) and…
354 kernel_versions="${kernel_versions}${kernel}___${buildroot}%{_usrsrc}/kernels/${kernel} "
356 # parse kernel versions string and print template
357 local kernel_verrelarch=${kernel%%${kernels_known_variants}}
358 print_rpmtemplate_per_kmodpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
361 if [[ -n "${devel}" ]]; then
363 print_rpmtemplate_kmoddevelpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
366 print_rpmtemplate_per_kmoddevelpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
369 …error_out 2 "Don't know how to handle ${kernel} -- ${prefix}/lib/modules/${kernel}/build/Makefile …
373 # well, it's no header anymore, but who cares ;-)
381 for kernel_version in ${kernel_versions_to_build_for}
390 for kernel in ${kernel_versions_to_build_for} ; do
392 local kernel_verrelarch=${kernel%%${kernels_known_variants}}
395 print_rpmtemplate_kmodmetapkg "${kernel}" "${kernel##${kernel_verrelarch}}"
398 print_rpmtemplate_per_kmodpkg "${kernel}" "${kernel##${kernel_verrelarch}}"
400 if [[ -n "${devel}" ]]; then
402 print_rpmtemplate_kmoddevelpkg "${kernel}" "${kernel##${kernel_verrelarch}}"
405 print_rpmtemplate_per_kmoddevelpkg "${kernel}" "${kernel##${kernel_verrelarch}}"
417 echo " --filterfile <file> -- filter the results with grep --file <file>"
418 echo " --for-kernels <list> -- created templates only for these kernels"
419 echo " --kmodname <file> -- name of the kmod (required)"
420 echo " --devel -- make kmod-devel package"
421 echo " --noakmod -- no akmod package"
422 echo " --repo <name> -- use buildsys-build-<name>-kerneldevpkgs"
423 echo " --target <arch> -- target-arch (required)"
424 echo " --buildroot <dir> -- Build root (place to look for build files)"
427 while [[ -n "${1}" ]] ; do
428 case "${1}" in
429 --filterfile)
431 if [[ -z "${1}" ]] ; then
432 error_out 2 "Please provide path to a filter-file together with --filterfile" >&2
433 elif [[ ! -e "${1}" ]]; then
439 --kmodname)
441 if [[ -z "${1}" ]] ; then
442 error_out 2 "Please provide the name of the kmod together with --kmodname" >&2
444 # strip pending -kmod
445 kmodname="${1%%-kmod}"
448 --devel)
452 --prefix)
454 if [[ -z "${1}" ]] ; then
455 error_out 2 "Please provide a prefix with --prefix" >&2
460 --repo)
462 if [[ -z "${1}" ]] ; then
463 error_out 2 "Please provide the name of the repo together with --repo" >&2
468 --for-kernels)
470 if [[ -z "${1}" ]] ; then
471 error_out 2 "Please provide the name of the kmod together with --kmodname" >&2
476 --noakmod)
480 --target)
485 --akmod)
489 --newest)
493 --current)
497 --buildroot)
502 --help)
506 --version)
518 if [[ -e ./kmodtool-kernel-variants ]]; then
519 kernels_known_variants="$(cat ./kmodtool-kernel-variants)"
520 elif [[ -e /usr/share/kmodtool/kernel-variants ]] ; then
521 kernels_known_variants="$(cat /usr/share/kmodtool/kernel-variants)"
523 …kernels_known_variants="@(smp?(-debug)|PAE?(-debug)|debug|kdump|xen|kirkwood|highbank|imx|omap|teg…
527 if [[ -z "${target}" ]]; then
528 error_out 2 "please pass target arch with --target"
529 elif [[ -z "${kmodname}" ]]; then
530 error_out 2 "please pass kmodname with --kmodname"
531 elif [[ -z "${kernels_known_variants}" ]] ; then
536 if [[ -n "${for_kernels}" ]]; then
546 # we need more sanity checks in this case
547 if [[ -z "${repo}" ]]; then
548 error_out 2 "please provide repo name with --repo"
549 elif ! command -v "buildsys-build-${repo}-kerneldevpkgs" > /dev/null 2>&1; then
550 error_out 2 "buildsys-build-${repo}-kerneldevpkgs not found"
553 # call buildsys-build-${repo}-kerneldevpkgs to get the list of kernels
554 cmdoptions="--target ${target}"
557 if [[ -n "${filterfile}" ]] ; then
558 cmdoptions="${cmdoptions} --filterfile ${filterfile}"
561 …kernel_versions_to_build_for=$(buildsys-build-${repo}-kerneldevpkgs "--${build_kernels}" ${cmdopti…
562 error_out 2 "buildsys-build-${repo}-kerneldevpkgs failed: ${kernel_versions_to_build_for}"
564 if [[ "${build_kernels}" = "current" ]] && [[ -z "${noakmod}" ]]; then