diff mbox series

[UNSTABLE] UBUNTU: [Packaging] Support skipped dkms modules

Message ID 20221019160306.22429-1-dimitri.ledkov@canonical.com
State New
Headers show
Series [UNSTABLE] UBUNTU: [Packaging] Support skipped dkms modules | expand

Commit Message

Dimitri John Ledkov Oct. 19, 2022, 4:03 p.m. UTC
In recent releases we have fixed up most dkms modules to correctly
detect, and skip building dkms modules when compiling against
incompatible kernels. For example, trying to build a WiFi driver
against a kernel without 80221 config enabled, results in dkms
returning error code 9 skipped build, due to incompatibility. Our DKMS
autopkgtests already honor such cases, and mark test results as
passing for skipped {kernel, dkms-module} combinations.

Improve kernel's dkms-build script to distinguish failed versus
skipped builds, by propagating exact status code. For standalone
skipped dkms modules, skip generating an empty deb packages.

Also do not fail over missing make.log for the skipped dkms builds,
which do not have one.

This change will enable us to use a static list of dkms-versions
across all kernels, without need to do anything special for cases were
a vendored dkms module is declared incompatible in dkms.conf for a
given kernel.

For example, v4l2loopback incompatible with cloud kernels that do not
enable CONFIG_VIDEO, or backports-iwlwifi incompatible with kvm
kernel.

This patch is tested against working, skipepd, and FTBFS dkms modules,
which correctly built the full kernel, skipped some dkms modules, or
failed the overall build.

Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
---
 debian/rules.d/2-binary-arch.mk | 3 ++-
 debian/scripts/dkms-build       | 5 ++---
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Andrea Righi Oct. 20, 2022, 6:28 a.m. UTC | #1
On Wed, Oct 19, 2022 at 05:03:06PM +0100, Dimitri John Ledkov wrote:
> In recent releases we have fixed up most dkms modules to correctly
> detect, and skip building dkms modules when compiling against
> incompatible kernels. For example, trying to build a WiFi driver
> against a kernel without 80221 config enabled, results in dkms
> returning error code 9 skipped build, due to incompatibility. Our DKMS
> autopkgtests already honor such cases, and mark test results as
> passing for skipped {kernel, dkms-module} combinations.
> 
> Improve kernel's dkms-build script to distinguish failed versus
> skipped builds, by propagating exact status code. For standalone
> skipped dkms modules, skip generating an empty deb packages.
> 
> Also do not fail over missing make.log for the skipped dkms builds,
> which do not have one.
> 
> This change will enable us to use a static list of dkms-versions
> across all kernels, without need to do anything special for cases were
> a vendored dkms module is declared incompatible in dkms.conf for a
> given kernel.
> 
> For example, v4l2loopback incompatible with cloud kernels that do not
> enable CONFIG_VIDEO, or backports-iwlwifi incompatible with kvm
> kernel.
> 
> This patch is tested against working, skipepd, and FTBFS dkms modules,
> which correctly built the full kernel, skipped some dkms modules, or
> failed the overall build.
> 
> Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>

This looks very useful to me. Applied to kinetic/linux-unstable.

Thanks,
-Andrea

> ---
>  debian/rules.d/2-binary-arch.mk | 3 ++-
>  debian/scripts/dkms-build       | 5 ++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
> index eb3acba7d7..46cf3499bc 100644
> --- a/debian/rules.d/2-binary-arch.mk
> +++ b/debian/rules.d/2-binary-arch.mk
> @@ -66,7 +66,7 @@ define build_dkms_sign =
>  	)
>  endef
>  define build_dkms =
> -	ARCH=$(build_arch) CROSS_COMPILE=$(CROSS_COMPILE) $(SHELL) $(DROOT)/scripts/dkms-build $(dkms_dir) $(abi_release)-$* '$(call build_dkms_sign,$(builddir)/build-$*)' $(1) $(2) $(3) $(4) $(5)
> +	rc=0; ARCH=$(build_arch) CROSS_COMPILE=$(CROSS_COMPILE) $(SHELL) $(DROOT)/scripts/dkms-build $(dkms_dir) $(abi_release)-$* '$(call build_dkms_sign,$(builddir)/build-$*)' $(1) $(2) $(3) $(4) $(5) || rc=$$?; if [ "$$rc" = "9" ]; then echo do_$(4)_$*=false >> $(builddir)/skipped-dkms.mk; rc=0; fi; if [ "$$rc" != "0" ]; then exit $$rc; fi
>  endef
>  
>  define install_control =
> @@ -604,6 +604,7 @@ endif
>  	$(call dh_all,linux-libc-dev)
>  endif
>  
> +-include $(builddir)/skipped-dkms.mk
>  binary-%: pkgimg = $(bin_pkg_name)-$*
>  binary-%: pkgimg_mods = $(mods_pkg_name)-$*
>  binary-%: pkgimg_ex = $(mods_extra_pkg_name)-$*
> diff --git a/debian/scripts/dkms-build b/debian/scripts/dkms-build
> index 67566a47df..6690322476 100755
> --- a/debian/scripts/dkms-build
> +++ b/debian/scripts/dkms-build
> @@ -166,14 +166,13 @@ $fakeroot /usr/sbin/dkms build --no-prepare-kernel --no-clean-kernel \
>  	--sourcetree "$dkms_dir/source" \
>  	--dkmstree "$dkms_dir/build" \
>  	--kernelsourcedir "$dkms_dir/headers/linux-headers-$abi_flavour" \
> -	"$dkms_conf" || rc=1
> +	"$dkms_conf" || rc=$?
>  
>  # Find the log and add it to our own.
>  for log in "$dkms_dir/build/$dkms_package/$dkms_version/$abi_flavour"/*/"log/make.log" "$dkms_dir/build/$dkms_package/$dkms_version/build/make.log"
>  do
> -	[ -f "$log" ] && break
> +	[ -f "$log" ] && sed -e "s@$dkms_dir@<<DKMSDIR>>@g" <"$log"
>  done
> -sed -e "s@$dkms_dir@<<DKMSDIR>>@g" <"$log"
>  
>  # If this build failed then exit here.
>  [ "$rc" != 0 ] && exit "$rc"
> -- 
> 2.34.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Timo Aaltonen Dec. 8, 2022, 4:31 p.m. UTC | #2
Dimitri John Ledkov kirjoitti 19.10.2022 klo 19.03:
> In recent releases we have fixed up most dkms modules to correctly
> detect, and skip building dkms modules when compiling against
> incompatible kernels. For example, trying to build a WiFi driver
> against a kernel without 80221 config enabled, results in dkms
> returning error code 9 skipped build, due to incompatibility. Our DKMS
> autopkgtests already honor such cases, and mark test results as
> passing for skipped {kernel, dkms-module} combinations.
> 
> Improve kernel's dkms-build script to distinguish failed versus
> skipped builds, by propagating exact status code. For standalone
> skipped dkms modules, skip generating an empty deb packages.
> 
> Also do not fail over missing make.log for the skipped dkms builds,
> which do not have one.
> 
> This change will enable us to use a static list of dkms-versions
> across all kernels, without need to do anything special for cases were
> a vendored dkms module is declared incompatible in dkms.conf for a
> given kernel.
> 
> For example, v4l2loopback incompatible with cloud kernels that do not
> enable CONFIG_VIDEO, or backports-iwlwifi incompatible with kvm
> kernel.
> 
> This patch is tested against working, skipepd, and FTBFS dkms modules,
> which correctly built the full kernel, skipped some dkms modules, or
> failed the overall build.
> 
> Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
> ---
>   debian/rules.d/2-binary-arch.mk | 3 ++-
>   debian/scripts/dkms-build       | 5 ++---
>   2 files changed, 4 insertions(+), 4 deletions(-)

Hi, this breaks building lrm:

https://launchpadlibrarian.net/638018034/buildlog_ubuntu-jammy-amd64.linux-restricted-modules-oem-6.1_6.1.0-1002.2_BUILDING.txt.gz


II: dkms-build override dkms-build--nvidia-N found, executing
II: copying support files ...
II: copying support files ... found 
/<<PKGBUILDDIR>>/__________dkms/headers/linux-headers-6.1.0-1002-oem/scripts/module.lds
grep: 
/<<PKGBUILDDIR>>/__________dkms/build/nvidia/510.108.03/build/make.log: 
No such file or directory
sha256sum: '*.ko': No such file or directory

and after reverting this back to normal:

II: dkms-build override dkms-build--nvidia-N found, executing
II: copying support files ...
II: copying support files ... found 
/<<PKGBUILDDIR>>/__________dkms/headers/linux-headers-6.1.0-1002-oem/scripts/module.lds
II: dkms-build build nvidia-510 complete
Dimitri John Ledkov Dec. 8, 2022, 4:41 p.m. UTC | #3
Very odd. Are the Nvidia modules actually building successfully or they too
need skipping? Would not think that 510 has support for 6.0 yet, does it?

On Thu, 8 Dec 2022, 16:31 Timo Aaltonen, <tjaalton@ubuntu.com> wrote:

> Dimitri John Ledkov kirjoitti 19.10.2022 klo 19.03:
> > In recent releases we have fixed up most dkms modules to correctly
> > detect, and skip building dkms modules when compiling against
> > incompatible kernels. For example, trying to build a WiFi driver
> > against a kernel without 80221 config enabled, results in dkms
> > returning error code 9 skipped build, due to incompatibility. Our DKMS
> > autopkgtests already honor such cases, and mark test results as
> > passing for skipped {kernel, dkms-module} combinations.
> >
> > Improve kernel's dkms-build script to distinguish failed versus
> > skipped builds, by propagating exact status code. For standalone
> > skipped dkms modules, skip generating an empty deb packages.
> >
> > Also do not fail over missing make.log for the skipped dkms builds,
> > which do not have one.
> >
> > This change will enable us to use a static list of dkms-versions
> > across all kernels, without need to do anything special for cases were
> > a vendored dkms module is declared incompatible in dkms.conf for a
> > given kernel.
> >
> > For example, v4l2loopback incompatible with cloud kernels that do not
> > enable CONFIG_VIDEO, or backports-iwlwifi incompatible with kvm
> > kernel.
> >
> > This patch is tested against working, skipepd, and FTBFS dkms modules,
> > which correctly built the full kernel, skipped some dkms modules, or
> > failed the overall build.
> >
> > Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
> > ---
> >   debian/rules.d/2-binary-arch.mk | 3 ++-
> >   debian/scripts/dkms-build       | 5 ++---
> >   2 files changed, 4 insertions(+), 4 deletions(-)
>
> Hi, this breaks building lrm:
>
>
> https://launchpadlibrarian.net/638018034/buildlog_ubuntu-jammy-amd64.linux-restricted-modules-oem-6.1_6.1.0-1002.2_BUILDING.txt.gz
>
>
> II: dkms-build override dkms-build--nvidia-N found, executing
> II: copying support files ...
> II: copying support files ... found
>
> /<<PKGBUILDDIR>>/__________dkms/headers/linux-headers-6.1.0-1002-oem/scripts/module.lds
> grep:
> /<<PKGBUILDDIR>>/__________dkms/build/nvidia/510.108.03/build/make.log:
> No such file or directory
> sha256sum: '*.ko': No such file or directory
>
> and after reverting this back to normal:
>
> II: dkms-build override dkms-build--nvidia-N found, executing
> II: copying support files ...
> II: copying support files ... found
>
> /<<PKGBUILDDIR>>/__________dkms/headers/linux-headers-6.1.0-1002-oem/scripts/module.lds
> II: dkms-build build nvidia-510 complete
>
>
> --
> t
>
>
Timo Aaltonen Dec. 8, 2022, 4:46 p.m. UTC | #4
If you look at the build log then yes, they all built fine. And this is 
6.1, the latest upstream versions added support for it.

Dimitri John Ledkov kirjoitti 8.12.2022 klo 18.41:
> Very odd. Are the Nvidia modules actually building successfully or they 
> too need skipping? Would not think that 510 has support for 6.0 yet, 
> does it?
> 
> On Thu, 8 Dec 2022, 16:31 Timo Aaltonen, <tjaalton@ubuntu.com 
> <mailto:tjaalton@ubuntu.com>> wrote:
> 
>     Dimitri John Ledkov kirjoitti 19.10.2022 klo 19.03:
>      > In recent releases we have fixed up most dkms modules to correctly
>      > detect, and skip building dkms modules when compiling against
>      > incompatible kernels. For example, trying to build a WiFi driver
>      > against a kernel without 80221 config enabled, results in dkms
>      > returning error code 9 skipped build, due to incompatibility. Our
>     DKMS
>      > autopkgtests already honor such cases, and mark test results as
>      > passing for skipped {kernel, dkms-module} combinations.
>      >
>      > Improve kernel's dkms-build script to distinguish failed versus
>      > skipped builds, by propagating exact status code. For standalone
>      > skipped dkms modules, skip generating an empty deb packages.
>      >
>      > Also do not fail over missing make.log for the skipped dkms builds,
>      > which do not have one.
>      >
>      > This change will enable us to use a static list of dkms-versions
>      > across all kernels, without need to do anything special for cases
>     were
>      > a vendored dkms module is declared incompatible in dkms.conf for a
>      > given kernel.
>      >
>      > For example, v4l2loopback incompatible with cloud kernels that do not
>      > enable CONFIG_VIDEO, or backports-iwlwifi incompatible with kvm
>      > kernel.
>      >
>      > This patch is tested against working, skipepd, and FTBFS dkms
>     modules,
>      > which correctly built the full kernel, skipped some dkms modules, or
>      > failed the overall build.
>      >
>      > Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com
>     <mailto:dimitri.ledkov@canonical.com>>
>      > ---
>      >   debian/rules.d/2-binary-arch.mk <http://2-binary-arch.mk> | 3 ++-
>      >   debian/scripts/dkms-build       | 5 ++---
>      >   2 files changed, 4 insertions(+), 4 deletions(-)
> 
>     Hi, this breaks building lrm:
> 
>     https://launchpadlibrarian.net/638018034/buildlog_ubuntu-jammy-amd64.linux-restricted-modules-oem-6.1_6.1.0-1002.2_BUILDING.txt.gz <https://launchpadlibrarian.net/638018034/buildlog_ubuntu-jammy-amd64.linux-restricted-modules-oem-6.1_6.1.0-1002.2_BUILDING.txt.gz>
> 
> 
>     II: dkms-build override dkms-build--nvidia-N found, executing
>     II: copying support files ...
>     II: copying support files ... found
>     /<<PKGBUILDDIR>>/__________dkms/headers/linux-headers-6.1.0-1002-oem/scripts/module.lds
>     grep:
>     /<<PKGBUILDDIR>>/__________dkms/build/nvidia/510.108.03/build/make.log:
>     No such file or directory
>     sha256sum: '*.ko': No such file or directory
> 
>     and after reverting this back to normal:
> 
>     II: dkms-build override dkms-build--nvidia-N found, executing
>     II: copying support files ...
>     II: copying support files ... found
>     /<<PKGBUILDDIR>>/__________dkms/headers/linux-headers-6.1.0-1002-oem/scripts/module.lds
>     II: dkms-build build nvidia-510 complete
> 
> 
>     -- 
>     t
>
diff mbox series

Patch

diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index eb3acba7d7..46cf3499bc 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -66,7 +66,7 @@  define build_dkms_sign =
 	)
 endef
 define build_dkms =
-	ARCH=$(build_arch) CROSS_COMPILE=$(CROSS_COMPILE) $(SHELL) $(DROOT)/scripts/dkms-build $(dkms_dir) $(abi_release)-$* '$(call build_dkms_sign,$(builddir)/build-$*)' $(1) $(2) $(3) $(4) $(5)
+	rc=0; ARCH=$(build_arch) CROSS_COMPILE=$(CROSS_COMPILE) $(SHELL) $(DROOT)/scripts/dkms-build $(dkms_dir) $(abi_release)-$* '$(call build_dkms_sign,$(builddir)/build-$*)' $(1) $(2) $(3) $(4) $(5) || rc=$$?; if [ "$$rc" = "9" ]; then echo do_$(4)_$*=false >> $(builddir)/skipped-dkms.mk; rc=0; fi; if [ "$$rc" != "0" ]; then exit $$rc; fi
 endef
 
 define install_control =
@@ -604,6 +604,7 @@  endif
 	$(call dh_all,linux-libc-dev)
 endif
 
+-include $(builddir)/skipped-dkms.mk
 binary-%: pkgimg = $(bin_pkg_name)-$*
 binary-%: pkgimg_mods = $(mods_pkg_name)-$*
 binary-%: pkgimg_ex = $(mods_extra_pkg_name)-$*
diff --git a/debian/scripts/dkms-build b/debian/scripts/dkms-build
index 67566a47df..6690322476 100755
--- a/debian/scripts/dkms-build
+++ b/debian/scripts/dkms-build
@@ -166,14 +166,13 @@  $fakeroot /usr/sbin/dkms build --no-prepare-kernel --no-clean-kernel \
 	--sourcetree "$dkms_dir/source" \
 	--dkmstree "$dkms_dir/build" \
 	--kernelsourcedir "$dkms_dir/headers/linux-headers-$abi_flavour" \
-	"$dkms_conf" || rc=1
+	"$dkms_conf" || rc=$?
 
 # Find the log and add it to our own.
 for log in "$dkms_dir/build/$dkms_package/$dkms_version/$abi_flavour"/*/"log/make.log" "$dkms_dir/build/$dkms_package/$dkms_version/build/make.log"
 do
-	[ -f "$log" ] && break
+	[ -f "$log" ] && sed -e "s@$dkms_dir@<<DKMSDIR>>@g" <"$log"
 done
-sed -e "s@$dkms_dir@<<DKMSDIR>>@g" <"$log"
 
 # If this build failed then exit here.
 [ "$rc" != 0 ] && exit "$rc"