Re: [PATCH 6/6] kbuild: deb-pkg: use more debhelper commands in builddeb

From: Robert Nelson
Date: Tue Apr 02 2024 - 12:01:22 EST


On Tue, Dec 26, 2023 at 7:54 AM Masahiro Yamada <masahiroy@xxxxxxxxxx> wrote:
>
> Commit 36862e14e316 ("kbuild: deb-pkg: use dh_listpackages to know
> enabled packages") started to require the debhelper tool suite.
>
> Use more dh_* commands in create_package():
>
> - dh_installdocs to install copyright
> - dh_installchangelogs to install changelog
> - dh_compress to compress changelog
> - dh_fixperms to replace the raw chmod command
> - dh_gencontrol to replace the raw dpkg-gencontrol command
> - dh_md5sums to record the md5sum of included files
> - dh_builddeb to replace the raw dpkg-deb command
>
> Set DEB_RULES_REQUIRES_ROOT to 'no' in case debian/rules is executed
> directly.
>
> Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> Reviewed-by: Nicolas Schier <n.schier@xxxxxx>
> ---
>
> scripts/package/builddeb | 23 ++++++++---------------
> scripts/package/debian/rules | 2 ++
> scripts/package/mkdebian | 2 +-
> 3 files changed, 11 insertions(+), 16 deletions(-)
>
> diff --git a/scripts/package/builddeb b/scripts/package/builddeb
> index 2eb4910f0ef3..436d55a83ab0 100755
> --- a/scripts/package/builddeb
> +++ b/scripts/package/builddeb
> @@ -26,23 +26,16 @@ if_enabled_echo() {
>
> create_package() {
> local pname="$1" pdir="$2"
> - local dpkg_deb_opts
>
> - mkdir -m 755 -p "$pdir/DEBIAN"
> - mkdir -p "$pdir/usr/share/doc/$pname"
> - cp debian/copyright "$pdir/usr/share/doc/$pname/"
> - cp debian/changelog "$pdir/usr/share/doc/$pname/changelog.Debian"
> - gzip -n -9 "$pdir/usr/share/doc/$pname/changelog.Debian"
> - sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \
> - | xargs -r0 md5sum > DEBIAN/md5sums"
> + export DH_OPTIONS="-p${pname} -P${pdir}"
>
> - # a+rX in case we are in a restrictive umask environment like 0077
> - # ug-s in case we build in a setuid/setgid directory
> - chmod -R go-w,a+rX,ug-s "$pdir"
> -
> - # Create the package
> - dpkg-gencontrol -p$pname -P"$pdir"
> - dpkg-deb --root-owner-group ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" ..
> + dh_installdocs
> + dh_installchangelogs
> + dh_compress
> + dh_fixperms
> + dh_gencontrol
> + dh_md5sums
> + dh_builddeb -- ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS}
> }
>
> install_linux_image () {
> diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
> index 36d51f60f98d..1f56938ea5d4 100755
> --- a/scripts/package/debian/rules
> +++ b/scripts/package/debian/rules
> @@ -1,6 +1,8 @@
> #!/usr/bin/make -f
> # SPDX-License-Identifier: GPL-2.0-only
>
> +export DEB_RULES_REQUIRES_ROOT := no
> +
> include debian/rules.vars
>
> ifneq (,$(filter-out parallel=1,$(filter parallel=%,$(DEB_BUILD_OPTIONS))))
> diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
> index 93a24712b9a1..070149c985fe 100755
> --- a/scripts/package/mkdebian
> +++ b/scripts/package/mkdebian
> @@ -193,7 +193,7 @@ Section: kernel
> Priority: optional
> Maintainer: $maintainer
> Rules-Requires-Root: no
> -Build-Depends: debhelper
> +Build-Depends: debhelper-compat (= 12)

make ARCH=arm CROSS_COMPILE= bindeb-pkg

I'm seeing a fun issue with Ubuntu 24.04 (Noble)... 13.14.1ubuntu5:
https://launchpad.net/ubuntu/+source/debhelper

dpkg-buildpackage --build=binary --no-pre-clean --unsigned-changes
-R'make -f debian/rules' -j1 -a$(cat debian/arch)
dpkg-buildpackage: info: source package linux-upstream
dpkg-buildpackage: info: source version 1noble
dpkg-buildpackage: info: source distribution noble
dpkg-buildpackage: info: source changed by rcn-ee <robertcnelson@xxxxxxxxx>
dpkg-source --before-build .
dpkg-buildpackage: info: host architecture armhf
dpkg-checkbuilddeps: error: Unmet build dependencies: debhelper-compat (= 12)
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)

Where as Debian (testing) Trixie and Sid: 13.15.3
https://packages.debian.org/source/trixie/debhelper

dpkg-buildpackage --build=binary --no-pre-clean --unsigned-changes
-R'make -f debian/rules' -j1 -a$(cat debian/arch)
dpkg-buildpackage: info: source package linux-upstream
dpkg-buildpackage: info: source version 1trixie
dpkg-buildpackage: info: source distribution trixie
dpkg-buildpackage: info: source changed by rcn-ee <robertcnelson@xxxxxxxxx>
dpkg-source --before-build .
dpkg-buildpackage: info: host architecture armhf
make -f debian/rules binary

dpkg-buildpackage --build=binary --no-pre-clean --unsigned-changes
-R'make -f debian/rules' -j1 -a$(cat debian/arch)
dpkg-buildpackage: info: source package linux-upstream
dpkg-buildpackage: info: source version 1sid
dpkg-buildpackage: info: source distribution trixie
dpkg-buildpackage: info: source changed by rcn-ee <robertcnelson@xxxxxxxxx>
dpkg-source --before-build .
dpkg-buildpackage: info: host architecture armhf
make -f debian/rules binary


Not really sure why Noble is failing, but wonder if, would fix it..
Build-Depends: debhelper-compat (>= 12)

Regards,

--
Robert Nelson
https://rcn-ee.com/