Skip to contentSkip to conversation

kbuild: deb-pkg: fixes for use on Debian systems

PATCH New Sascha Silbe 1 participant 3 messages Oct 24, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw

cover kbuild: deb-pkg: fixes for use on Debian systems

When building binary .deb packages directly from a source tree using "make deb-pkg" or "make bindeb-pkg", they don't work as well as the vendor-provided (i.e. Debian) kernel packages because some dependencies and integrations are missing. This series fixes some of the shortcomings so the locally built packages can be used in place of the vendor-provided ones.

Sascha Silbe (2):
kbuild: deb-pkg: set dependencies for kernel image package
kbuild: deb-pkg: invoke linux-base scripts if installed

 scripts/package/builddeb | 22 ++++++++++++++++++++++
 scripts/package/mkdebian |  9 +++++++++
 2 files changed, 31 insertions(+)

base-commit: 9c0c4d24ac000e52d55348961d3a3ba42065e0cf
prerequisite-patch-id: d2d09cbe2907cd6c1ece0fcc6b576faf1ef8dd37

Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/2 kbuild: deb-pkg: set dependencies for kernel image package

From: Sascha Silbe <[email protected]>

When built with module support, we'll need the kmod package to handle the user space side of kernel module management.

When built with initramfs support but not building an initramfs directly into the kernel, we'll need initramfs-tools to build the initramfs that will be loaded.

If a the official kernel package of the distribution was installed first the dependencies are already installed and it will happen to work. However on a fresh install base system with just the kernel package built by deb-pkg installed the dependencies will be missing and the system will fail to boot.

---
 scripts/package/mkdebian | 9 +++++++++
 1 file changed, 9 insertions(+)
scripts/package/mkdebian +9 -0
index 60a2a63a5e900..a3becd9d402e1 100755
@@ -132,6 +132,14 @@ else
         echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly"
 fi
 
+image_depends=
+if is_enabled MODULES; then
+    image_depends=kmod
+fi
+if is_enabled BLK_DEV_INITRD && ! is_enabled INITRAMFS_SOURCE; then
+    image_depends="${image_depends}${image_depends:+, }initramfs-tools | linux-initramfs-tool"
+fi
+
 mkdir -p debian/source/
 echo "1.0" > debian/source/format
 
@@ -180,6 +188,7 @@ Homepage: https://www.kernel.org/
 
 Package: $packagename-$version
 Architecture: $debarch
+Depends: $image_depends
 Description: Linux kernel, version $version
  This package contains the Linux kernel, modules and corresponding other
  files, version: $version.
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/2 kbuild: deb-pkg: invoke linux-base scripts if installed

In reply to Sascha Silbe

From: Sascha Silbe <[email protected]>

Kernel images built from source can be installed and used manually. On systems where "flash-kernel" is used, new versions will be picked up automatically and used on next boot. However on systems relying on symlinks this does not happen as the symlinks are not updated, unlike with stock Debian kernels.

To fix this invoke the scripts from linux-base if they are installed just like the maintainer scripts of the stock Debian kernel packages do.

---
 scripts/package/builddeb | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
scripts/package/builddeb +22 -0
index 91a502bb97e8a..69e0c51d324e0 100755
@@ -202,6 +202,28 @@ export DEB_MAINT_PARAMS="\$*"
 # Tell initramfs builder whether it's wanted
 export INITRD=$(if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No)
 
+# Call linux-base scripts if they are installed
+if command -v linux-update-symlinks > /dev/null; then
+    if [ $script = preinst ] && [ "\$1" = install ]; then
+        mkdir -p /lib/modules/$version
+        touch /lib/modules/$version/.fresh-install
+    elif [ $script = postinst ] && [ "\$1" = configure ]; then
+        if [ -f /lib/modules/$version/.fresh-install ]; then
+            linux-update-symlinks install $version /$installed_image_path
+            rm /lib/modules/$version/.fresh-install
+        else
+            linux-update-symlinks upgrade $version /$installed_image_path
+        fi
+    elif [ $script = prerm ] && [ "\$1" = remove ]; then
+        linux-check-removal $version
+    elif [ $script = postrm ]; then
+        rm -f /lib/modules/$version/.fresh-install
+        if [ "\$1" != upgrade ]; then
+            linux-update-symlinks remove $version /$installed_image_path
+        fi
+    fi
+fi
+
 test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d
 exit 0
 EOF
Signature · 1 line
2.30.2