forked from rpms/kernel
		
	Add DoModules to kernel build
There's upcoming work to build kernel variants without modules. Add the infrastructure to support this.
This commit is contained in:
		
							parent
							
								
									5769e27048
								
							
						
					
					
						commit
						f691fd9d87
					
				
							
								
								
									
										67
									
								
								kernel.spec
									
									
									
									
									
								
							
							
						
						
									
										67
									
								
								kernel.spec
									
									
									
									
									
								
							| @ -1106,6 +1106,8 @@ BuildKernel() { | ||||
|     Flav=${Flavour:++${Flavour}} | ||||
|     InstallName=${5:-vmlinuz} | ||||
| 
 | ||||
|     DoModules=1 | ||||
| 
 | ||||
|     # Pick the right config file for the kernel we're building | ||||
|     Config=kernel-%{version}-%{_target_cpu}${Flavour:+-${Flavour}}.config | ||||
|     DevelDir=/usr/src/kernels/%{KVERREL}${Flav} | ||||
| @ -1155,7 +1157,9 @@ BuildKernel() { | ||||
|     # This ensures build-ids are unique to allow parallel debuginfo | ||||
|     perl -p -i -e "s/^CONFIG_BUILD_SALT.*/CONFIG_BUILD_SALT=\"%{KVERREL}\"/" .config | ||||
|     %{make} %{?make_opts} HOSTCFLAGS="%{?build_hostcflags}" HOSTLDFLAGS="%{?build_hostldflags}" ARCH=$Arch %{?_smp_mflags} $MakeTarget %{?sparse_mflags} %{?kernel_mflags} | ||||
|     %{make} %{?make_opts} HOSTCFLAGS="%{?build_hostcflags}" HOSTLDFLAGS="%{?build_hostldflags}" ARCH=$Arch %{?_smp_mflags} modules %{?sparse_mflags} || exit 1 | ||||
|     if [ $DoModules -eq 1 ]; then | ||||
| 	%{make} %{?make_opts} HOSTCFLAGS="%{?build_hostcflags}" HOSTLDFLAGS="%{?build_hostldflags}" ARCH=$Arch %{?_smp_mflags} modules %{?sparse_mflags} || exit 1 | ||||
|     fi | ||||
| 
 | ||||
|     mkdir -p $RPM_BUILD_ROOT/%{image_install_path} | ||||
|     mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer | ||||
| @ -1203,18 +1207,21 @@ BuildKernel() { | ||||
|     sha512hmac $RPM_BUILD_ROOT/%{image_install_path}/$InstallName-$KernelVer | sed -e "s,$RPM_BUILD_ROOT,," > $RPM_BUILD_ROOT/%{image_install_path}/.vmlinuz-$KernelVer.hmac; | ||||
|     cp $RPM_BUILD_ROOT/%{image_install_path}/.vmlinuz-$KernelVer.hmac $RPM_BUILD_ROOT/lib/modules/$KernelVer/.vmlinuz.hmac | ||||
| 
 | ||||
|     # Override $(mod-fw) because we don't want it to install any firmware | ||||
|     # we'll get it from the linux-firmware package and we don't want conflicts | ||||
|     %{make} %{?make_opts} ARCH=$Arch INSTALL_MOD_PATH=$RPM_BUILD_ROOT modules_install KERNELRELEASE=$KernelVer mod-fw= | ||||
| 
 | ||||
|     if [ $DoModules -eq 1 ]; then | ||||
| 	# Override $(mod-fw) because we don't want it to install any firmware | ||||
| 	# we'll get it from the linux-firmware package and we don't want conflicts | ||||
| 	%{make} %{?make_opts} ARCH=$Arch INSTALL_MOD_PATH=$RPM_BUILD_ROOT modules_install KERNELRELEASE=$KernelVer mod-fw= | ||||
|     fi | ||||
| 
 | ||||
|     # add an a noop %%defattr statement 'cause rpm doesn't like empty file list files | ||||
|     echo '%%defattr(-,-,-)' > ../kernel${Flavour:+-${Flavour}}-ldsoconf.list | ||||
|     if [ $DoVDSO -ne 0 ]; then | ||||
|         %{make} %{?make_opts} ARCH=$Arch INSTALL_MOD_PATH=$RPM_BUILD_ROOT vdso_install KERNELRELEASE=$KernelVer | ||||
|         if [ -s ldconfig-kernel.conf ]; then | ||||
|             install -D -m 444 ldconfig-kernel.conf \ | ||||
|              install -D -m 444 ldconfig-kernel.conf \ | ||||
|                 $RPM_BUILD_ROOT/etc/ld.so.conf.d/kernel-$KernelVer.conf | ||||
|             echo /etc/ld.so.conf.d/kernel-$KernelVer.conf >> ../kernel${Flavour:+-${Flavour}}-ldsoconf.list | ||||
| 	     echo /etc/ld.so.conf.d/kernel-$KernelVer.conf >> ../kernel${Flavour:+-${Flavour}}-ldsoconf.list | ||||
|         fi | ||||
|         rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/vdso/.build-id | ||||
|     fi | ||||
| @ -1387,22 +1394,36 @@ BuildKernel() { | ||||
|     # don't include anything going into k-m-e in the file lists | ||||
|     rm -rf lib/modules/$KernelVer/extra | ||||
| 
 | ||||
|     # Find all the module files and filter them out into the core and modules | ||||
|     # lists.  This actually removes anything going into -modules from the dir. | ||||
|     find lib/modules/$KernelVer/kernel -name *.ko | sort -n > modules.list | ||||
|     cp $RPM_SOURCE_DIR/filter-*.sh . | ||||
|     %{SOURCE99} modules.list %{_target_cpu} | ||||
|     rm filter-*.sh | ||||
| 
 | ||||
|     # Run depmod on the resulting module tree and make sure it isn't broken | ||||
|     depmod -b . -aeF ./System.map $KernelVer &> depmod.out | ||||
|     if [ -s depmod.out ]; then | ||||
|         echo "Depmod failure" | ||||
|         cat depmod.out | ||||
|         exit 1 | ||||
|     if [ $DoModules -eq 1 ]; then | ||||
| 	# Find all the module files and filter them out into the core and | ||||
| 	# modules lists.  This actually removes anything going into -modules | ||||
| 	# from the dir. | ||||
| 	find lib/modules/$KernelVer/kernel -name *.ko | sort -n > modules.list | ||||
| 	cp $RPM_SOURCE_DIR/filter-*.sh . | ||||
| 	%{SOURCE99} modules.list %{_target_cpu} | ||||
| 	rm filter-*.sh | ||||
| 
 | ||||
| 	# Run depmod on the resulting module tree and make sure it isn't broken | ||||
| 	depmod -b . -aeF ./System.map $KernelVer &> depmod.out | ||||
| 	if [ -s depmod.out ]; then | ||||
| 	    echo "Depmod failure" | ||||
| 	    cat depmod.out | ||||
| 	    exit 1 | ||||
| 	else | ||||
| 	    rm depmod.out | ||||
| 	fi | ||||
|     else | ||||
|         rm depmod.out | ||||
| 	# Ensure important files/directories exist to let the packaging succeed | ||||
| 	echo '%%defattr(-,-,-)' > modules.list | ||||
| 	echo '%%defattr(-,-,-)' > k-d.list | ||||
| 	mkdir -p lib/modules/$KernelVer/kernel | ||||
| 	# Add files usually created by make modules, needed to prevent errors | ||||
| 	# thrown by depmod during package installation | ||||
| 	touch lib/modules/$KernelVer/modules.order | ||||
| 	touch lib/modules/$KernelVer/modules.builtin | ||||
|     fi | ||||
| 
 | ||||
|     # remove files that will be auto generated by depmod at rpm -i time | ||||
|     pushd $RPM_BUILD_ROOT/lib/modules/$KernelVer/ | ||||
|         rm -f modules.{alias*,builtin.bin,dep*,*map,symbols*,devname,softdep} | ||||
| @ -1430,9 +1451,11 @@ BuildKernel() { | ||||
|     rm -f $RPM_BUILD_ROOT/module-dirs.list | ||||
| 
 | ||||
| %if %{signmodules} | ||||
|     # Save the signing keys so we can sign the modules in __modsign_install_post | ||||
|     cp certs/signing_key.pem certs/signing_key.pem.sign${Flav} | ||||
|     cp certs/signing_key.x509 certs/signing_key.x509.sign${Flav} | ||||
|     if [ $DoModules -eq 1 ]; then | ||||
| 	# Save the signing keys so we can sign the modules in __modsign_install_post | ||||
| 	cp certs/signing_key.pem certs/signing_key.pem.sign${Flav} | ||||
| 	cp certs/signing_key.x509 certs/signing_key.x509.sign${Flav} | ||||
|     fi | ||||
| %endif | ||||
| 
 | ||||
|     # Move the devel headers out of the root file system | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user