xref: /freebsd/sys/contrib/openzfs/scripts/kmodtool (revision 27bb8830d555621d4292da8a83f3bc09176fd00d)
1#!/usr/bin/env bash
2# shellcheck disable=SC2086
3
4# kmodtool - Helper script for building kernel module RPMs
5# Copyright (c) 2003-2012 Ville Skyttä <ville.skytta@iki.fi>,
6#                         Thorsten Leemhuis <fedora@leemhuis.info>
7#                         Nicolas Chauvet <kwizart@gmail.com>
8#
9# Permission is hereby granted, free of charge, to any person obtaining
10# a copy of this software and associated documentation files (the
11# "Software"), to deal in the Software without restriction, including
12# without limitation the rights to use, copy, modify, merge, publish,
13# distribute, sublicense, and/or sell copies of the Software, and to
14# permit persons to whom the Software is furnished to do so, subject to
15# the following conditions:
16#
17# The above copyright notice and this permission notice shall be
18# included in all copies or substantial portions of the Software.
19#
20# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28shopt -s extglob
29
30myprog="kmodtool-${repo}"
31myver="0.12.1"
32
33kmodname=
34build_kernels="current"
35kernels_known_variants=
36kernel_versions=
37kernel_versions_to_build_for=
38prefix=
39filterfile=
40target=
41buildroot=
42dashvariant=
43
44error_out()
45{
46	local errorlevel=${1}
47	shift
48	echo "Error: $*" >&2
49	# the next line is not multi-line safe -- not needed *yet*
50	echo "%global kmodtool_check echo \"kmodtool error: $*\"; exit ${errorlevel};"
51	exit "${errorlevel}"
52}
53
54print_rpmtemplate_header()
55{
56	echo
57	echo '%global kmodinstdir_prefix  '${prefix}/lib/modules/
58	echo '%global kmodinstdir_postfix '/extra/${kmodname}/
59	echo '%global kernel_versions     '${kernel_versions}
60	echo
61}
62
63print_akmodtemplate ()
64{
65	echo
66	cat <<EOF
67
68%global akmod_install mkdir -p \$RPM_BUILD_ROOT/%{_usrsrc}/akmods/; \\\
69LANG=C rpmbuild --define "_sourcedir %{_sourcedir}" \\\
70--define "_srcrpmdir \$RPM_BUILD_ROOT/%{_usrsrc}/akmods/" \\\
71-bs --nodeps %{_specdir}/%{name}.spec ; \\\
72ln -s \$(ls \$RPM_BUILD_ROOT/%{_usrsrc}/akmods/) \$RPM_BUILD_ROOT/%{_usrsrc}/akmods/${kmodname}-kmod.latest
73
74%package -n akmod-${kmodname}
75Summary:	Akmod package for ${kmodname} kernel module(s) 
76Group: 		System Environment/Kernel
77Requires:   kmodtool
78Requires: 	akmods
79%{?AkmodsBuildRequires:Requires: %{AkmodsBuildRequires}}
80# same requires and provides as a kmods package would have
81Requires: 	${kmodname}-kmod-common >= %{?epoch:%{epoch}:}%{version}
82Provides: 	${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
83EOF
84
85	if [[ ${obsolete_name} ]]; then
86		echo "Provides:   akmod-${obsolete_name} = ${obsolete_version}"
87		echo "Obsoletes:  akmod-${obsolete_name} < ${obsolete_version}"
88	fi
89
90	cat <<EOF
91
92%description -n akmod-${kmodname}
93This package provides the akmod package for the ${kmodname} kernel modules.
94
95%posttrans -n akmod-${kmodname}
96nohup ${prefix}/sbin/akmods --from-akmod-posttrans --akmod ${kmodname} &> /dev/null &
97
98%files -n akmod-${kmodname}
99%defattr(-,root,root,-)
100%{_usrsrc}/akmods/*
101
102EOF
103}
104
105print_akmodmeta ()
106{
107		cat <<EOF
108%package      -n kmod-${kmodname}
109Summary:         Metapackage which tracks in ${kmodname} kernel module for newest kernel${dashvariant}
110Group:           System Environment/Kernel
111
112Provides:        ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
113Provides:        kmod-${kmodname}-xen = %{?epoch:%{epoch}:}%{version}-%{release}
114Provides:        kmod-${kmodname}-smp = %{?epoch:%{epoch}:}%{version}-%{release}
115Provides:        kmod-${kmodname}-PAE = %{?epoch:%{epoch}:}%{version}-%{release}
116Requires:        akmod-${kmodname} = %{?epoch:%{epoch}:}%{version}-%{release}
117EOF
118
119	if [[ ${obsolete_name} ]]; then
120		echo "Provides:        kmod-${obsolete_name} = ${obsolete_version}"
121		echo "Obsoletes:       kmod-${obsolete_name} < ${obsolete_version}"
122	fi
123cat <<EOF
124
125%description  -n kmod-${kmodname}${dashvariant}
126This is a meta-package without payload which sole purpose is to require the
127${kmodname} kernel module(s) for the newest kernel${dashvariant},
128to make sure you get it together with a new kernel.
129
130%files        -n kmod-${kmodname}${dashvariant}
131%defattr(644,root,root,755)
132EOF
133}
134
135print_rpmtemplate_per_kmodpkg ()
136{
137	if [[ "${1}" == "--custom" ]]; then
138		shift
139		local customkernel=true
140	elif [[ "${1}" == "--redhat" ]]; then
141		# this is needed for akmods
142		shift
143		local redhatkernel=true
144	fi
145
146	local kernel_uname_r=${1}
147	local kernel_variant="${2:+-${2}}"
148
149	# Detect depmod install location
150	local depmod_path=/sbin/depmod
151	if [ ! -f ${depmod_path} ]; then
152		depmod_path=/usr/sbin/depmod
153	fi
154
155	# first part
156	cat <<EOF
157%package       -n kmod-${kmodname}-${kernel_uname_r}
158Summary:          ${kmodname} kernel module(s) for ${kernel_uname_r}
159Group:            System Environment/Kernel
160Provides:         kernel-modules-for-kernel = ${kernel_uname_r}
161Provides:         kmod-${kmodname}-uname-r = ${kernel_uname_r}
162Provides:         ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
163Requires:         ${kmodname}-kmod-common >= %{?epoch:%{epoch}:}%{version}
164
165%if 0%{?rhel} == 6 || 0%{?centos} == 6
166Requires(post):   module-init-tools
167Requires(postun): module-init-tools
168%else
169Requires(post):   kmod
170Requires(postun): kmod
171%endif
172EOF
173
174	if [[ ${obsolete_name} ]]; then
175		echo "Provides:        kmod-${obsolete_name}-${kernel_uname_r} = ${obsolete_version}"
176		echo "Obsoletes:       kmod-${obsolete_name}-${kernel_uname_r} < ${obsolete_version}"
177	fi
178
179	# second part
180	if [[ ! "${customkernel}" ]]; then
181	     cat <<EOF
182Requires:         kernel-uname-r = ${kernel_uname_r}
183BuildRequires:	  kernel-devel-uname-r = ${kernel_uname_r}
184%{?KmodsRequires:Requires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
185%{?KmodsRequires:BuildRequires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
186%post          -n kmod-${kmodname}-${kernel_uname_r}
187if [[ -f "/boot/System.map-${kernel_uname_r}" ]]; then
188	${prefix}${depmod_path} -aeF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} > /dev/null || :
189elif [[ -f "/lib/modules/${kernel_uname_r}/System.map" ]]; then
190	${prefix}${depmod_path} -aeF /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} > /dev/null || :
191else
192	${prefix}${depmod_path} -ae ${kernel_uname_r} &> /dev/null || :
193fi
194%postun        -n kmod-${kmodname}-${kernel_uname_r}
195if [[ -f "/boot/System.map-${kernel_uname_r}" ]]; then
196	${prefix}${depmod_path} -aF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} &> /dev/null || :
197elif [[ -f "/lib/modules/${kernel_uname_r}/System.map" ]]; then
198	${prefix}${depmod_path} -aF /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} &> /dev/null || :
199else
200	${prefix}${depmod_path} -a ${kernel_uname_r} &> /dev/null || :
201fi
202
203EOF
204	else
205	  cat <<EOF
206%post          -n kmod-${kmodname}-${kernel_uname_r}
207[[ "\$(uname -r)" == "${kernel_uname_r}"  ]] && ${prefix}${depmod_path} -a > /dev/null || :
208%postun        -n kmod-${kmodname}-${kernel_uname_r}
209[[ "\$(uname -r)" == "${kernel_uname_r}"  ]] && ${prefix}${depmod_path} -a > /dev/null || :
210
211EOF
212	fi
213
214  # third part
215	cat <<EOF
216%description  -n kmod-${kmodname}-${kernel_uname_r}
217This package provides the ${kmodname} kernel modules built for the Linux
218kernel ${kernel_uname_r} for the %{_target_cpu} family of processors.
219%files        -n kmod-${kmodname}-${kernel_uname_r}
220%defattr(644,root,root,755)
221%dir $prefix/lib/modules/${kernel_uname_r}/extra
222${prefix}/lib/modules/${kernel_uname_r}/extra/${kmodname}/
223
224
225EOF
226}
227
228print_rpmtemplate_kmoddevelpkg ()
229{
230	if [[ "${1}" == "--custom" ]]; then
231		shift
232		local customkernel=true
233	elif [[ "${1}" == "--redhat" ]]; then
234		shift
235		local redhatkernel=true
236	fi
237
238	local kernel_uname_r=${1}
239
240	cat <<EOF
241%package       -n kmod-${kmodname}-devel
242Summary:          ${kmodname} kernel module(s) devel common
243Group:            System Environment/Kernel
244Provides:         ${kmodname}-devel-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
245EOF
246
247	if [[ ! ${customkernel} ]] && [[ ! ${redhatkernel} ]]; then
248		echo "Requires:        kmod-${kmodname}-devel-${kernel_uname_r} >= %{?epoch:%{epoch}:}%{version}-%{release}"
249	fi
250
251	if [[ ${obsolete_name} ]]; then
252		echo "Provides:        kmod-${obsolete_name}-devel = ${obsolete_version}"
253		echo "Obsoletes:       kmod-${obsolete_name}-devel < ${obsolete_version}"
254	fi
255
256	cat <<EOF
257%description  -n kmod-${kmodname}-devel
258This package provides the common header files to build kernel modules
259which depend on the ${kmodname} kernel module.  It may optionally require
260the ${kmodname}-devel-<kernel> objects for the newest kernel.
261
262%files        -n kmod-${kmodname}-devel
263%defattr(644,root,root,755)
264%{_usrsrc}/${kmodname}-%{version}
265EOF
266	if [[ ${obsolete_name} ]]; then
267		echo "%{_usrsrc}/${obsolete_name}-%{version}"
268	fi
269
270	for kernel in ${1}; do
271		local kernel_uname_r=${kernel}
272		echo "%exclude %{_usrsrc}/${kmodname}-%{version}/${kernel_uname_r}"
273		if [[ ${obsolete_name} ]]; then
274			echo "%exclude %{_usrsrc}/${obsolete_name}-%{version}/${kernel_uname_r}"
275		fi
276	done
277
278	echo
279	echo
280}
281
282print_rpmtemplate_per_kmoddevelpkg ()
283{
284	if [[ "${1}" == "--custom" ]]; then
285		shift
286		local customkernel=true
287	elif [[ "${1}" == "--redhat" ]]; then
288		# this is needed for akmods
289		shift
290		local redhatkernel=true
291	fi
292
293	local kernel_uname_r=${1}
294	local kernel_variant="${2:+-${2}}"
295
296	# first part
297	cat <<EOF
298%package       -n kmod-${kmodname}-devel-${kernel_uname_r}
299Summary:          ${kmodname} kernel module(s) devel for ${kernel_uname_r}
300Group:            System Environment/Kernel
301Provides:         kernel-objects-for-kernel = ${kernel_uname_r}
302Provides:         ${kmodname}-devel-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
303Provides:         kmod-${kmodname}-devel-uname-r = ${kernel_uname_r}
304EOF
305
306	if [[ ${obsolete_name} ]]; then
307		echo "Provides:        kmod-${obsolete_name}-devel-${kernel_uname_r} = ${obsolete_version}"
308		echo "Obsoletes:       kmod-${obsolete_name}-devel-${kernel_uname_r} < ${obsolete_version}"
309	fi
310
311	# second part
312	if [[ ! "${customkernel}" ]]; then
313		cat <<EOF
314Requires:         kernel-devel-uname-r = ${kernel_uname_r}
315BuildRequires:    kernel-devel-uname-r = ${kernel_uname_r}
316%{?KmodsDevelRequires:Requires: %{KmodsDevelRequires}-uname-r = ${kernel_uname_r}}
317%{?KmodsDevelRequires:BuildRequires: %{KmodsDevelRequires}-uname-r = ${kernel_uname_r}}
318EOF
319	fi
320
321	# third part
322	cat <<EOF
323%description  -n kmod-${kmodname}-devel-${kernel_uname_r}
324This package provides objects and symbols required to build kernel modules
325which depend on the ${kmodname} kernel modules built for the Linux
326kernel ${kernel_uname_r} for the %{_target_cpu} family of processors.
327%files        -n kmod-${kmodname}-devel-${kernel_uname_r}
328%defattr(644,root,root,755)
329%{_usrsrc}/${kmodname}-%{version}/${kernel_uname_r}
330EOF
331	if [[ ${obsolete_name} ]]; then
332		echo "%{_usrsrc}/${obsolete_name}-%{version}/${kernel_uname_r}"
333	fi
334}
335
336print_rpmtemplate_kmodmetapkg ()
337{
338		local kernel_uname_r=${1}
339		local kernel_variant="${2:+-${2}}"
340
341		cat <<EOF
342%package      -n kmod-${kmodname}${kernel_variant}
343Summary:         Metapackage which tracks in ${kmodname} kernel module for newest kernel${kernel_variant}
344Group:           System Environment/Kernel
345
346Provides:        ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
347Requires:        kmod-${kmodname}-${kernel_uname_r} >= %{?epoch:%{epoch}:}%{version}-%{release}
348%{?KmodsMetaRequires:Requires: %{?KmodsMetaRequires}}
349EOF
350
351		if [[ ${obsolete_name} ]]; then
352			echo "Provides:        kmod-${obsolete_name}${kernel_variant} = ${obsolete_version}"
353			echo "Obsoletes:       kmod-${obsolete_name}${kernel_variant} < ${obsolete_version}"
354		fi
355
356		cat <<EOF
357
358%description  -n kmod-${kmodname}${kernel_variant}
359This is a meta-package without payload which sole purpose is to require the
360${kmodname} kernel module(s) for the newest kernel${kernel_variant}.
361to make sure you get it together with a new kernel.
362
363%files        -n kmod-${kmodname}${kernel_variant}
364%defattr(644,root,root,755)
365
366
367EOF
368}
369
370print_customrpmtemplate ()
371{
372	for kernel in ${1}
373	do
374		if [[ -e "${buildroot}/usr/src/kernels/${kernel}" ]] ; then
375			# this looks like a Fedora/RH kernel -- print a normal template (which includes the proper BR) and be happy :)
376			kernel_versions="${kernel_versions}${kernel}___${buildroot}%{_usrsrc}/kernels/${kernel} "
377
378			# parse kernel versions string and print template
379			local kernel_verrelarch=${kernel%%${kernels_known_variants}}
380			print_rpmtemplate_per_kmodpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
381
382			# create development package
383			if [[ "${devel}" ]]; then
384				# create devel package including common headers
385				print_rpmtemplate_kmoddevelpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
386
387				# create devel package
388				print_rpmtemplate_per_kmoddevelpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
389			fi
390		elif [[ -e ${prefix}/lib/modules/"${kernel}"/build/Makefile ]] ; then
391			# likely a user-build-kernel with available buildfiles
392			# fixme: we should check if uname from Makefile is the same as ${kernel}
393
394			kernel_versions="${kernel_versions}${kernel}___${prefix}/lib/modules/${kernel}/build/ "
395			print_rpmtemplate_per_kmodpkg --custom "${kernel}"
396
397			# create development package
398			if [[ "${devel}" ]]; then
399				# create devel package including common headers
400				print_rpmtemplate_kmoddevelpkg --custom "${kernel}"
401
402				# create devel package
403				print_rpmtemplate_per_kmoddevelpkg --custom "${kernel}"
404			fi
405		else
406			error_out 2 "Don't know how to handle ${kernel} -- ${prefix}/lib/modules/${kernel}/build/Makefile not found"
407		fi
408	done
409
410	# well, it's no header anymore, but who cares ;-)
411	print_rpmtemplate_header
412}
413
414
415print_rpmtemplate ()
416{
417	# create kernel_versions var
418	for kernel_version in ${kernel_versions_to_build_for}
419	do
420		kernel_versions="${kernel_versions}${kernel_version}___%{_usrsrc}/kernels/${kernel_version} "
421	done
422
423	# and print it and some other required stuff as macro
424	print_rpmtemplate_header
425
426	# now print the packages
427	for kernel in ${kernel_versions_to_build_for} ; do
428
429		local kernel_verrelarch=${kernel%%${kernels_known_variants}}
430
431		# create metapackage
432		print_rpmtemplate_kmodmetapkg ${kernel} ${kernel##${kernel_verrelarch}}
433
434		# create package
435		print_rpmtemplate_per_kmodpkg ${kernel} ${kernel##${kernel_verrelarch}}
436
437		if [[ "${devel}" ]]; then
438			# create devel package including common headers
439			print_rpmtemplate_kmoddevelpkg ${kernel} ${kernel##${kernel_verrelarch}}
440
441			# create devel package
442			print_rpmtemplate_per_kmoddevelpkg ${kernel} ${kernel##${kernel_verrelarch}}
443		fi
444	done
445}
446
447myprog_help ()
448{
449	echo "Usage: ${0##*/} [OPTIONS]"
450	echo $'\n'"Creates a template to be used during kmod building"
451	echo $'\n'"Available options:"
452	echo " --filterfile <file>  -- filter the results with grep --file <file>"
453	echo " --for-kernels <list> -- created templates only for these kernels"
454	echo " --kmodname <file>    -- name of the kmod (required)"
455	echo " --devel              -- make kmod-devel package"
456	echo " --noakmod            -- no akmod package"
457	echo " --repo <name>        -- use buildsys-build-<name>-kerneldevpkgs"
458	echo " --target <arch>      -- target-arch (required)"
459	echo " --buildroot <dir>    -- Build root (place to look for build files)"
460}
461
462while [ "${1}" ] ; do
463	case "${1}" in
464		--filterfile)
465			shift
466			if [[ ! "${1}" ]] ; then
467				error_out 2 "Please provide path to a filter-file together with --filterfile" >&2
468			elif [[ ! -e "${1}" ]]; then
469				error_out 2 "Filterfile ${1} not found" >&2
470			fi
471			filterfile="${1}"
472			shift
473			;;
474		--kmodname)
475			shift
476			if [[ ! "${1}" ]] ; then
477				error_out 2 "Please provide the name of the kmod together with --kmodname" >&2
478	 	    fi
479			# strip pending -kmod
480			kmodname="${1%%-kmod}"
481			shift
482			;;
483		--devel)
484			shift
485			devel="true"
486			;;
487		--prefix)
488			shift
489			if [[ ! "${1}" ]] ; then
490				error_out 2 "Please provide a prefix with --prefix" >&2
491		    fi
492			prefix="${1}"
493			shift
494			;;
495		--repo)
496			shift
497			if [[ ! "${1}" ]] ; then
498				error_out 2 "Please provide the name of the repo together with --repo" >&2
499	 	    fi
500			repo=${1}
501			shift
502			;;
503		--for-kernels)
504			shift
505			if [[ ! "${1}" ]] ; then
506				error_out 2 "Please provide the name of the kmod together with --kmodname" >&2
507	 		fi
508			for_kernels="${1}"
509			shift
510			;;
511		--noakmod)
512			shift
513			noakmod="true"
514			;;
515		--obsolete-name)
516			shift
517			if [[ ! "${1}" ]] ; then
518				error_out 2 "Please provide the name of the kmod to obsolete together with --obsolete-name" >&2
519	 		fi
520			obsolete_name="${1}"
521			shift
522			;;
523		--obsolete-version)
524			shift
525			if [[ ! "${1}" ]] ; then
526				error_out 2 "Please provide the version of the kmod to obsolete together with --obsolete-version" >&2
527	 		fi
528			obsolete_version="${1}"
529			shift
530			;;
531		--target)
532			shift
533			target="${1}"
534			shift
535			;;
536		--akmod)
537			shift
538			build_kernels="akmod"
539			;;
540		--newest)
541			shift
542			build_kernels="newest"
543			;;
544		--current)
545			shift
546			build_kernels="current"
547			;;
548		--buildroot)
549			shift
550			buildroot="${1}"
551			shift
552			;;
553		--help)
554			myprog_help
555			exit 0
556			;;
557		--version)
558			echo "${myprog} ${myver}"
559			exit 0
560			;;
561		*)
562			echo "Error: Unknown option '${1}'." >&2
563			usage >&2
564			exit 2
565			;;
566	esac
567done
568
569if [[ -e ./kmodtool-kernel-variants ]]; then
570	kernels_known_variants="$(cat ./kmodtool-kernel-variants)"
571elif [[ -e /usr/share/kmodtool/kernel-variants ]] ; then
572	kernels_known_variants="$(cat /usr/share/kmodtool/kernel-variants)"
573else
574	kernels_known_variants="@(smp?(-debug)|PAE?(-debug)|debug|kdump|xen|kirkwood|highbank|imx|omap|tegra)"
575fi
576
577# general sanity checks
578if [[ ! "${target}" ]]; then
579		error_out 2 "please pass target arch with --target"
580elif [[ ! "${kmodname}" ]]; then
581		error_out 2 "please pass kmodname with --kmodname"
582elif [[ ! "${kernels_known_variants}" ]] ; then
583		error_out 2 "could not determine known variants"
584elif { [[ "${obsolete_name}" ]] && [[ ! "${obsolete_version}" ]]; } ||  { [[ ! "${obsolete_name}" ]] && [[ "${obsolete_version}" ]]; } ; then
585		error_out 2 "you need to provide both --obsolete-name and --obsolete-version"
586fi
587
588# go
589if [[ "${for_kernels}" ]]; then
590	# this is easy:
591	print_customrpmtemplate "${for_kernels}"
592elif [[ "${build_kernels}" == "akmod" ]]; then
593	# do only a akmod package
594	print_akmodtemplate
595	print_akmodmeta
596else
597	# seems we are on out own to decide for which kernels to build
598
599	# we need more sanity checks in this case
600	if [[ ! "${repo}" ]]; then
601		error_out 2 "please provide repo name with --repo"
602	elif ! command -v "buildsys-build-${repo}-kerneldevpkgs" &> /dev/null ; then
603		error_out 2 "buildsys-build-${repo}-kerneldevpkgs not found"
604	fi
605
606	# call buildsys-build-${repo}-kerneldevpkgs to get the list of kernels
607	cmdoptions="--target ${target}"
608
609	# filterfile to filter list of kernels?
610	if [[ "${filterfile}" ]] ; then
611		 cmdoptions="${cmdoptions} --filterfile ${filterfile}"
612	fi
613
614	kernel_versions_to_build_for="$(buildsys-build-${repo}-kerneldevpkgs --${build_kernels} ${cmdoptions})"
615	returncode=$?
616	if (( returncode != 0 )); then
617		error_out 2 "buildsys-build-${repo}-kerneldevpkgs failed: $(buildsys-build-${repo}-kerneldevpkgs --${build_kernels} ${cmdoptions})"
618	fi
619
620	if [[ "${build_kernels}" == "current" ]] && [[ ! "${noakmod}" ]]; then
621		print_akmodtemplate
622	fi
623
624	print_rpmtemplate
625fi
626