diff mbox series

kbuild: rpm-pkg: Add dtbs support

Message ID 20230712-kbuild_rpm_dtbs-v1-1-99693e8faaaf@jannau.net (mailing list archive)
State New, archived
Headers show
Series kbuild: rpm-pkg: Add dtbs support | expand

Commit Message

Janne Grunau via B4 Relay July 12, 2023, 6:42 a.m. UTC
From: Janne Grunau <j@jannau.net>

Based on the dtbs support in builddeb. Both Fedora and openSUSE kernel
rpm install their dtbs in "/boot/dtb-${KERNELRELEASE}". There seems no
other popular rpm based distributions which would benefit from dtbs
support and are not derived from those two.

Signed-off-by: Janne Grunau <j@jannau.net>
---
 scripts/package/mkspec | 11 +++++++++++
 1 file changed, 11 insertions(+)


---
base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
change-id: 20230712-kbuild_rpm_dtbs-d055a3780bbe

Best regards,

Comments

Nathan Chancellor July 12, 2023, 10:08 p.m. UTC | #1
On Wed, Jul 12, 2023 at 08:42:20AM +0200, Janne Grunau via B4 Relay wrote:
> From: Janne Grunau <j@jannau.net>
> 
> Based on the dtbs support in builddeb. Both Fedora and openSUSE kernel
> rpm install their dtbs in "/boot/dtb-${KERNELRELEASE}". There seems no
> other popular rpm based distributions which would benefit from dtbs
> support and are not derived from those two.
> 
> Signed-off-by: Janne Grunau <j@jannau.net>

Seems reasonable to me. I verified this works for at least arm64 and
x86_64.

$ rpm -qlp rpmbuild/RPMS/aarch64/kernel-6.5.0_rc1_next_20230712_00001_g5899d64b0f1b-1.aarch64.rpm | grep -q '^/boot/dtb'
/boot/dtb-6.5.0-rc1-next-20230712-00001-g5899d64b0f1b
/boot/dtb-6.5.0-rc1-next-20230712-00001-g5899d64b0f1b/allwinner
/boot/dtb-6.5.0-rc1-next-20230712-00001-g5899d64b0f1b/allwinner/sun50i-a100-allwinner-perf1.dtb
...

$ rpm -qlp rpmbuild/RPMS/x86_64/kernel-6.5.0_rc1_next_20230712_00001_g5899d64b0f1b-1.x86_64.rpm | grep -q '^/boot/dtb'

Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  scripts/package/mkspec | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/scripts/package/mkspec b/scripts/package/mkspec
> index 8049f0e2c110..a170b0c0a93f 100755
> --- a/scripts/package/mkspec
> +++ b/scripts/package/mkspec
> @@ -28,6 +28,14 @@ else
>  	M=DEL
>  fi
>  
> +# Only some architectures with OF support have the dtbs_install target
> +if grep -q CONFIG_OF_EARLY_FLATTREE=y include/config/auto.conf && \
> +   [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then
> +	D=
> +else
> +	D=DEL
> +fi
> +
>  __KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g")
>  EXCLUDES="$RCS_TAR_IGNORE --exclude=*vmlinux* --exclude=*.mod \
>  --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \
> @@ -38,6 +46,8 @@ EXCLUDES="$RCS_TAR_IGNORE --exclude=*vmlinux* --exclude=*.mod \
>  # Labels:
>  #  $S: this line is enabled only when building source package
>  #  $M: this line is enabled only when CONFIG_MODULES is enabled
> +#  $D: this line is enabled only when CONFIG_OF_EARLY_FLATTREE is enabled and
> +#      the arch has a dts directory
>  sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
>  	Name: kernel
>  	Summary: The Linux Kernel
> @@ -103,6 +113,7 @@ $S
>  	%endif
>  $M	$MAKE %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install
>  	$MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
> +$D	$MAKE %{?_smp_mflags} INSTALL_DTBS_PATH=%{buildroot}/boot/dtb-${KERNELRELEASE} dtbs_install
>  	cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
>  	cp .config %{buildroot}/boot/config-$KERNELRELEASE
>  $S$M	rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
> 
> ---
> base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
> change-id: 20230712-kbuild_rpm_dtbs-d055a3780bbe
> 
> Best regards,
> -- 
> Janne Grunau <j@jannau.net>
>
Masahiro Yamada July 20, 2023, 6:41 p.m. UTC | #2
On Wed, Jul 12, 2023 at 3:42 PM Janne Grunau via B4 Relay
<devnull+j.jannau.net@kernel.org> wrote:
>
> From: Janne Grunau <j@jannau.net>
>
> Based on the dtbs support in builddeb. Both Fedora and openSUSE kernel
> rpm install their dtbs in "/boot/dtb-${KERNELRELEASE}". There seems no
> other popular rpm based distributions which would benefit from dtbs
> support and are not derived from those two.
>
> Signed-off-by: Janne Grunau <j@jannau.net>
> ---
>  scripts/package/mkspec | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/scripts/package/mkspec b/scripts/package/mkspec
> index 8049f0e2c110..a170b0c0a93f 100755
> --- a/scripts/package/mkspec
> +++ b/scripts/package/mkspec
> @@ -28,6 +28,14 @@ else
>         M=DEL
>  fi
>
> +# Only some architectures with OF support have the dtbs_install target
> +if grep -q CONFIG_OF_EARLY_FLATTREE=y include/config/auto.conf && \
> +   [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then
> +       D=
> +else
> +       D=DEL
> +fi

This is unneeded. See below.



> +
>  __KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g")
>  EXCLUDES="$RCS_TAR_IGNORE --exclude=*vmlinux* --exclude=*.mod \
>  --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \
> @@ -38,6 +46,8 @@ EXCLUDES="$RCS_TAR_IGNORE --exclude=*vmlinux* --exclude=*.mod \
>  # Labels:
>  #  $S: this line is enabled only when building source package
>  #  $M: this line is enabled only when CONFIG_MODULES is enabled
> +#  $D: this line is enabled only when CONFIG_OF_EARLY_FLATTREE is enabled and
> +#      the arch has a dts directory
>  sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
>         Name: kernel
>         Summary: The Linux Kernel
> @@ -103,6 +113,7 @@ $S
>         %endif
>  $M     $MAKE %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install
>         $MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
> +$D     $MAKE %{?_smp_mflags} INSTALL_DTBS_PATH=%{buildroot}/boot/dtb-${KERNELRELEASE} dtbs_install



Like deb-pkg, you can check CONFIG_OF_EARLY_FLATTREE
while building the package instead of while creating the spec file.

 if grep -q CONFIG_OF_EARLY_FLATTREE=y include/config/auto.conf; then
     $MAKE %{?_smp_mflags}
INSTALL_DTBS_PATH=%{buildroot}/boot/dtb-${KERNELRELEASE} dtbs_install
 fi

(please note it is untested)


The reason for $S and $M is because they determine
whether the kernel-devel package is needed.
But, I regret the implementation was too ugly.
I will clean up mkspec.
Please submit v2 after the code clean-up.



>         cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
>         cp .config %{buildroot}/boot/config-$KERNELRELEASE
>  $S$M   rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
>
> ---
> base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
> change-id: 20230712-kbuild_rpm_dtbs-d055a3780bbe
>
> Best regards,
> --
> Janne Grunau <j@jannau.net>
>


--
Best Regards
Masahiro Yamada
diff mbox series

Patch

diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index 8049f0e2c110..a170b0c0a93f 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -28,6 +28,14 @@  else
 	M=DEL
 fi
 
+# Only some architectures with OF support have the dtbs_install target
+if grep -q CONFIG_OF_EARLY_FLATTREE=y include/config/auto.conf && \
+   [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then
+	D=
+else
+	D=DEL
+fi
+
 __KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g")
 EXCLUDES="$RCS_TAR_IGNORE --exclude=*vmlinux* --exclude=*.mod \
 --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \
@@ -38,6 +46,8 @@  EXCLUDES="$RCS_TAR_IGNORE --exclude=*vmlinux* --exclude=*.mod \
 # Labels:
 #  $S: this line is enabled only when building source package
 #  $M: this line is enabled only when CONFIG_MODULES is enabled
+#  $D: this line is enabled only when CONFIG_OF_EARLY_FLATTREE is enabled and
+#      the arch has a dts directory
 sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
 	Name: kernel
 	Summary: The Linux Kernel
@@ -103,6 +113,7 @@  $S
 	%endif
 $M	$MAKE %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install
 	$MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
+$D	$MAKE %{?_smp_mflags} INSTALL_DTBS_PATH=%{buildroot}/boot/dtb-${KERNELRELEASE} dtbs_install
 	cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
 	cp .config %{buildroot}/boot/config-$KERNELRELEASE
 $S$M	rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build