Skip to content

Commit 097f120

Browse files
jtornosmmasahir0y
authored andcommitted
kbuild: rpm-pkg: add dtb files in kernel rpm
Some architectures, like aarch64 ones, need a dtb file to configure the hardware. The default dtb file can be preloaded from u-boot, but the final and/or more complete dtb file needs to be able to be loaded later from rootfs. Add the possible dtb files to the kernel rpm and mimic Fedora shipping process, storing the dtb files in the module directory. These dtb files will be copied to /boot directory by the install scripts, but add fallback just in case, checking if the content in /boot directory is correct. Mark the files installed to /boot as %ghost to make sure they will be removed when the package is uninstalled. Tested with Fedora Rawhide (x86_64 and aarch64) with dnf and rpm tools. In addition, fallback was also tested after modifying the install scripts. Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com> Tested-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent b27a913 commit 097f120

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

scripts/package/kernel.spec

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEAS
6161
%{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
6262
cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE}
6363
cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
64+
if %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='test -d ${srctree}/arch/${SRCARCH}/boot/dts' 2>/dev/null; then
65+
%{make} %{makeflags} INSTALL_DTBS_PATH=%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb dtbs_install
66+
fi
6467
ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build
6568
%if %{with_devel}
6669
%{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}'
@@ -81,6 +84,11 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA
8184
echo "%ghost /boot/${x}-%{KERNELRELEASE}"
8285
done
8386

87+
if [ -d "%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb" ];then
88+
echo "/lib/modules/%{KERNELRELEASE}/dtb"
89+
find "%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb" -printf "%%%ghost /boot/dtb-%{KERNELRELEASE}/%%P\n"
90+
fi
91+
8492
echo "%exclude /lib/modules/%{KERNELRELEASE}/build"
8593
} > %{buildroot}/kernel.list
8694

@@ -96,6 +104,11 @@ for file in vmlinuz System.map config; do
96104
cp "/lib/modules/%{KERNELRELEASE}/${file}" "/boot/${file}-%{KERNELRELEASE}"
97105
fi
98106
done
107+
if [ -d "/lib/modules/%{KERNELRELEASE}/dtb" ] && \
108+
! diff -rq "/lib/modules/%{KERNELRELEASE}/dtb" "/boot/dtb-%{KERNELRELEASE}" >/dev/null 2>&1; then
109+
rm -rf "/boot/dtb-%{KERNELRELEASE}"
110+
cp -r "/lib/modules/%{KERNELRELEASE}/dtb" "/boot/dtb-%{KERNELRELEASE}"
111+
fi
99112
if [ ! -e "/lib/modules/%{KERNELRELEASE}/modules.dep" ]; then
100113
/usr/sbin/depmod %{KERNELRELEASE}
101114
fi

0 commit comments

Comments
 (0)