[elbe-devel] [PATCH v2 1/1] Make Debianize kernel firmware depending on kernel's version
dion at linutronix.de
dion at linutronix.de
Mon Jul 29 11:02:58 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 | 21 +++++++++++++++++++--
elbepack/makofiles/debianize/kernel/rules.mako | 13 +++++++++++--
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/elbepack/debianize/kernel.py b/elbepack/debianize/kernel.py
index aad2cc5e..cd97a2c8 100644
--- a/elbepack/debianize/kernel.py
+++ b/elbepack/debianize/kernel.py
@@ -10,6 +10,7 @@ import os
from shutil import copyfile
from npyscreen import TitleText, TitleSelectOne
+from pkg_resources import parse_version
from elbepack.directories import mako_template_dir
from elbepack.debianize.base import DebianizeBase, template
@@ -65,6 +66,7 @@ class Kernel (DebianizeBase):
self.imgtype.get_value()[0]]
self.deb['cross_compile'] = self.cross.get_value()
self.deb['k_version'] = self.k_version.get_value()
+ self.deb['in_kernel_firmware'] = in_kernel_firmware(self.deb['k_version'])
self.tmpl_dir = os.path.join(mako_template_dir, 'debianize/kernel')
pkg_name = self.deb['k_version'] + '-' + self.deb['p_name']
@@ -86,8 +88,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 self.deb['in_kernel_firmware']:
+ sed_delete(image_dst, "firmware")
+
copyfile(os.path.join(self.tmpl_dir, 'linux-headers.install'),
'debian/linux-headers-' + pkg_name + '.install')
@@ -96,3 +104,12 @@ class Kernel (DebianizeBase):
DebianizeBase.register(Kernel)
+
+
+# See 5620a0d1aacd554ebebcff373e31107bb1ef7769 on kernel mainline
+firmware_threshold = parse_version('v4.13')
+def in_kernel_firmware(k_version):
+ return int(parse_version(k_version) <= parse_version(firmware_threshold))
+
+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..f4222b4b 100755
--- a/elbepack/makofiles/debianize/kernel/rules.mako
+++ b/elbepack/makofiles/debianize/kernel/rules.mako
@@ -16,7 +16,11 @@ 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 +42,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 +77,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
--
2.11.0
More information about the elbe-devel
mailing list