Skip to content

deb: DKMS packaging improvements#331

Open
changchinlan wants to merge 6 commits into
Xilinx-CNS:masterfrom
changchinlan:deb/packaging-improvements
Open

deb: DKMS packaging improvements#331
changchinlan wants to merge 6 commits into
Xilinx-CNS:masterfrom
changchinlan:deb/packaging-improvements

Conversation

@changchinlan

Copy link
Copy Markdown

I've been packaging onload as .deb for internal use (Ubuntu 20.04 through 24.04) and ran into a few issues with the current debian templates that this series tries to address.

Problems I hit:

  • DKMS modules weren't making it into the initramfs, so in-tree sfc would load instead of the DKMS-built one at boot.
  • No way to customise the DKMS build (extra dkms.conf options, quilt patches, Makefile override) without forking the templates.
  • The postinst/prerm scripts hand-roll dkms calls instead of using dh_dkms.
  • pybuild calls are unconditional, which breaks builds for <=9.1 (no pyproject.toml).

The commits are split roughly by feature:

  • env pwd portability fix (minor, separate concern)
  • Configurable debian revision via --debian-revision / DEBIAN_REVISION
  • Hooks for debian/Makefile, debian/dkms.append.conf, and debian/patches applied into the DKMS source tree. dkms.append.conf lets downstream extend dkms.conf at build time without patching upstream (e.g. declaring BUILD_DEPENDS on out-of-tree drivers like xilinx-efct, or setting BUILD_EXCLUSIVE_KERNEL).
  • dh_dkms integration with backwards compat for 20.04
  • initramfs-tools hook + modules-load.d + dpkg trigger on xilinx-efct-dkms
  • Guard pybuild behind pyproject.toml existence check. Restore --python-layout=deb for older releases that still use setup.py.

Tested with onload 9.1.0.24 on Ubuntu 24.04. All five packages built successfully.

Ubuntu 26.04 support: The initramfs hook targets initramfs-tools (24.04 and earlier). Ubuntu 26.04 defaults to dracut, which handles DKMS module priority natively via updates/dkms/, so a dracut module may not be needed.

@changchinlan changchinlan requested a review from a team as a code owner June 3, 2026 03:18

i_prefix=$(CURDIR)/debian/$(userpackage) scripts/onload_install --verbose \
--packaged --userfiles --modprobe --modulesloadd --udev \
$(if $(wildcard pyproject.toml),,--python-layout=deb) \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will this help if it is for older releases as this code is only for newer releases by definition? Or did we miss compat for older OSs? Bear in mind the current master branch targets Debian 12+ and Ubuntu 24.04 plus and we'd probably happily bump to Trixie if we found anything that needed it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The motivation is to reuse the same debian templates across multiple onload versions without maintaining a separate fork of the templates (as we are still packaging 8.1.3.40 and 9.1.0.24 dkms alongside master). I'm happy to drop them if that's not something upstream wants to carry.

Comment thread scripts/mmaketool Outdated

do-find-top() {
mytoppath=$(cd "$bin/.." && /bin/pwd)
mytoppath=$(cd "$bin/.." && /usr/bin/env pwd)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For compatibility with what? pwd is a POSIX API command defined to be at /bin/pwd, regardless of what the OS might do in respect to usrmerge. Is there a particular scenario you have in mind where the original path would fail? Otherwise I see no need to invoke an additional tool.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped. That was a habit from working on NixOS where /bin/pwd doesn't exist, but it's POSIX and onload doesn't need to worry about that.

Add --debian-revision flag to onload_mksrcdeb and onload_mkpackage,
and replace the hard-coded "-1" in the changelog template with a

This also honours the DEBIAN_REVISION environment variable as a
default, and accepts extra arguments via the mksrcdeb_args env var,
making it possible to drive the source-package build from external
scripts without patching onload_mksrcdeb.sh.
Allow downstream packagers to customise the DKMS build without
forking the debian templates:

- If debian/Makefile exists, use it instead of the upstream Makefile
  for both the -source and -dkms packages.
- If debian/dkms.append.conf exists, append it to the installed
  dkms.conf (useful for BUILD_DEPENDS, BUILD_EXCLUSIVE_KERNEL, etc.).
- If debian/patches/series exists, apply the quilt series into the
  DKMS source tree at package-build time.
- Pass --udev to onload_install so udev rules are shipped in the
  -user package.
Let debhelper's dh_dkms generate proper maintainer scripts instead of
hand-rolling dkms add/build/install calls:

- Add dh-sequence-dkms | dh-dkms | dkms to Build-Depends (the
  three-way alternative covers Ubuntu 24.04, 22.04, and 20.04).
- Call dh_dkms in binary-indep to produce dkms-aware postinst/prerm.
- Symlink dkms.conf for releases that ship it under
  scripts/onload_misc/ rather than the source root (onload 8.x).
- Add libcap-dev as a runtime dependency of the -dkms package, since
  the DKMS build requires it.
Ensure DKMS-built modules are actually used at boot:

- Install an initramfs-tools hook that copies DKMS-built sfc and
  xilinx_efct modules into the initramfs, replacing any in-tree
  copies so the DKMS versions take priority.
- Ship a modules-load.d snippet so onload kernel modules are loaded
  automatically on boot.
- Declare a dpkg trigger on xilinx-efct-dkms so that onload-dkms is
  rebuilt whenever the efct driver is updated.
- Rework postinst to handle both configure and triggered cases, with
  a forced initramfs update after trigger-driven rebuilds.
- Add dh_installinitramfs call in rules.
Guard the pybuild build/install calls and PYBUILD_SYSTEM export behind
a pyproject.toml existence check, so the same debian templates work for
both older releases (which lack pyproject.toml) and v9.2+ (which ship
one). Without this, building v9.1 or earlier with these templates fails
with 'Source does not appear to be a Python project'.
Releases up to v9.1 ship a setup.py and rely on onload_install's
--python-layout=deb flag to place Python modules under
/usr/lib/python3/dist-packages/ (the Debian convention). The previous
pybuild commit removed this flag because v9.2 handles Python packaging
via pybuild, but that left older releases installing to /usr/local/
instead. Use the same pyproject.toml existence check to restore the
flag when pybuild is not in use.
@changchinlan changchinlan force-pushed the deb/packaging-improvements branch from 50289c2 to 8a031c3 Compare June 8, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants