[elbe-devel] [PATCH 1/1] Make Debianize kernel firmware depending on kernel's version

Bastian Germann bage at linutronix.de
Fri Jul 26 11:30:17 CEST 2019


> From: Olivier Dion <dion at linutronix.de>
> 
> Commit 5620a0d1aacd ("firmware: delete in-kernel firmware") in the
> kernel has removed support for in-kernel firmware.
> 
> Thus, kernels with version greater than 4.13 should not try to call
> 'firmware_install'.
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>
> ---
>  elbepack/debianize/kernel.py                   | 17 +++++++++++++++--
>  elbepack/makofiles/debianize/kernel/rules.mako | 14 ++++++++++++--
>  2 files changed, 27 insertions(+), 4 deletions(-)
> 
> diff --git a/elbepack/debianize/kernel.py b/elbepack/debianize/kernel.py
> index aad2cc5e..e6715c0c 100644
> --- a/elbepack/debianize/kernel.py
> +++ b/elbepack/debianize/kernel.py
> @@ -86,8 +86,14 @@ class Kernel (DebianizeBase):
>              ' "generated by elbe debianize"'
>          system(cmd)
>  
> -        copyfile(os.path.join(self.tmpl_dir, 'linux-image.install'),
> -                 'debian/linux-image-' + pkg_name + '.install')
> +        image_src = os.path.join(self.tmpl_dir, 'linux-image.install')
> +        image_dst = 'debian/linux-image-%s.install' % pkg_name
> +
> +        copyfile(image_src, image_dst)
> +
> +        if not in_kernel_firmware(self.deb['k_version']):
> +            sed_delete(image_dst, "firmware")
> +
>          copyfile(os.path.join(self.tmpl_dir, 'linux-headers.install'),
>                   'debian/linux-headers-' + pkg_name + '.install')
>  
> @@ -96,3 +102,10 @@ class Kernel (DebianizeBase):
>  
>  
>  DebianizeBase.register(Kernel)
> +
> +
> +def in_kernel_firmware(k_version):
> +    return float(k_version) <= 4.13

Is k_version guaranteed to have only a minor version number (no patch
number)? If not the conversion fails. I would suggest a typical version
number comparison. Python should have some in the stdlib. I suggest
avoiding an extra shell comparison and instead give a new boolean var to
the Mako template that is used for IN_KERNEL_FIRMWARE.

> +
> +def sed_delete(filename, pattern):
> +    system("sed --in-place --expression='/%s/d' '%s'" % (pattern, filename))
> diff --git a/elbepack/makofiles/debianize/kernel/rules.mako b/elbepack/makofiles/debianize/kernel/rules.mako
> index 01e55491..40cec6b2 100755
> --- a/elbepack/makofiles/debianize/kernel/rules.mako
> +++ b/elbepack/makofiles/debianize/kernel/rules.mako
> @@ -10,13 +10,18 @@
>  
>  PWD:=$(shell pwd)
>  REL:=${k_version}-${p_name}
> +IN_KERNEL_FIRMWARE:=$(shell echo "${k_version} <= 4.13" | bc)
>  
>  DEB_DIR:=$(PWD)/debian
>  TMP_DIR:=$(DEB_DIR)/tmp
>  BUILD_DIR:=$(DEB_DIR)/build
>  
>  MOD_PATH:=$(TMP_DIR)
> +ifeq ($(IN_KERNEL_FIRMWARE), 1)
>  FW_PATH:=$(TMP_DIR)/lib/firmware
> +else
> +FW_PATH:=
> +endif
>  KERNEL_PATH:=$(TMP_DIR)/boot
>  HDR_PATH:=$(TMP_DIR)/usr
>  KERNEL_HDR_PATH:=$(TMP_DIR)/usr/src/linux-headers-$(REL)
> @@ -38,12 +43,15 @@ CROSS_COMPILE=${cross_compile} \
>  KERNELRELEASE=$(REL) \
>  LOADADDR=${loadaddr} \
>  INSTALL_MOD_PATH=$(MOD_PATH) \
> -INSTALL_FW_PATH=$(FW_PATH) \
>  INSTALL_HDR_PATH=$(HDR_PATH) \
>  INSTALL_PATH=$(KERNEL_PATH) \
>  INSTALL_DTBS_PATH=$(DTBS_PATH) \
>  O=$(BUILD_DIR)
>  
> +ifeq ($(IN_KERNEL_FIRMWARE), 1)
> +MAKE_OPTS += INSTALL_FW_PATH=$(FW_PATH)
> +endif
> +
>  ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
>      NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
>      MAKE_OPTS += -j$(NUMJOBS)
> @@ -70,7 +78,9 @@ override_dh_auto_install:
>  	mkdir -p $(MOD_PATH) $(FW_PATH) $(HDR_PATH) $(KERNEL_PATH) $(DTBS_PATH)
>  	$(MAKE) $(MAKE_OPTS) ${imgtype_install}
>  	$(MAKE) $(MAKE_OPTS) INSTALL_MOD_STRIP=1 modules_install
> -	$(MAKE) $(MAKE_OPTS) firmware_install
> +	if test $(IN_KERNEL_FIRMWARE) -eq 1; then \
> +		$(MAKE) $(MAKE_OPTS) firmware_install; \
> +	fi
>  	$(MAKE) $(MAKE_OPTS) headers_install
>  	(test ${k_arch} = arm || test ${k_arch} = arm64) && make $(MAKE_OPTS) dtbs_install || true
>  	# Build kernel header package
> 



More information about the elbe-devel mailing list