From 4fd31745fd43ce42360b297b2818952f7d713ba3 Mon Sep 17 00:00:00 2001 From: Chang Chin-lan <192761079+changchinlan@users.noreply.github.com> Date: Wed, 3 Jun 2026 10:07:37 +0800 Subject: [PATCH 1/6] deb: support configurable Debian revision in source packages 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. --- scripts/debian/debian-templ/changelog | 2 +- scripts/debian/onload_mksrcdeb.sh | 12 ++++++++++-- scripts/onload_mkpackage | 4 +++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/debian/debian-templ/changelog b/scripts/debian/debian-templ/changelog index 9c1b9cc15..942bb8e8c 100644 --- a/scripts/debian/debian-templ/changelog +++ b/scripts/debian/debian-templ/changelog @@ -1,4 +1,4 @@ -#TYPE# (#VERSION#-1) unstable; urgency=low +#TYPE# (#VERSION#-#DEBIAN_REVISION#) unstable; urgency=low * Initial release of Debian packages diff --git a/scripts/debian/onload_mksrcdeb.sh b/scripts/debian/onload_mksrcdeb.sh index 1f0a97582..fb78dc557 100755 --- a/scripts/debian/onload_mksrcdeb.sh +++ b/scripts/debian/onload_mksrcdeb.sh @@ -21,6 +21,8 @@ usage() { err "options:" err " --tarball - onload tarball to create packages for" err " --out - directory to write source package to" + err " --debian-revision " + err " - Debian package revision (default 1)" err exit 1 } @@ -36,11 +38,13 @@ onloadver= package= basename= outdir=$(pwd) +debian_revision=${DEBIAN_REVISION:-1} while [ $# -gt 0 ]; do case "$1" in --tarball) shift; tarball=$1;; --out) shift; outdir=$1;; + --debian-revision) shift; debian_revision=$1;; -*) usage;; *) break;; esac @@ -84,7 +88,12 @@ try mkdir -p "$tempfile/$onloaddir/debian" # control files for i in $(find "$TOP"/debian/debian-templ/* -type f); do ni="${tempfile}/${onloaddir}/debian/$(basename "$i")" - try sed -e "s/#VERSION#/$onloadver/g" -e "s/#TYPE#/$onloadtype/g" -e "s/#SOVERSION#/${soversion}/g" < "$i" > "$ni"; + try sed \ + -e "s/#VERSION#/$onloadver/g" \ + -e "s/#TYPE#/$onloadtype/g" \ + -e "s/#SOVERSION#/${soversion}/g" \ + -e "s/#DEBIAN_REVISION#/${debian_revision}/g" \ + < "$i" > "$ni"; done for i in $(find "${tempfile}"/"${onloaddir}"/debian/type-* -type f); do @@ -112,4 +121,3 @@ try rm -rf "$tempfile" echo "" echo "Wrote $outdir/$package-debiansource.tgz" echo "" - diff --git a/scripts/onload_mkpackage b/scripts/onload_mkpackage index 44cd97b73..40d33fd8b 100755 --- a/scripts/onload_mkpackage +++ b/scripts/onload_mkpackage @@ -215,7 +215,7 @@ build_sdeb() { try rm -rf "${sdeb_dir:?}/*" try mkdir -p "$sdeb_dir" maybe_install debuild - mksrcdeb_args=(--tarball "$tarball_path" --out "$sdeb_dir") + mksrcdeb_args+=(--tarball "$tarball_path" --out "$sdeb_dir") trylog "$sdeb_dir/build.log" \ "$bin/debian/onload_mksrcdeb.sh" "${mksrcdeb_args[@]}" local debiansource_paths=("$sdeb_dir"/*debiansource.tgz) @@ -373,6 +373,7 @@ read_args() { fi } read_args mkdist_args +read_args mksrcdeb_args read_args rpmbuild_args read_args rpmbuild_source_args read_args rpmbuild_binary_args @@ -431,6 +432,7 @@ usage() { err "Env vars:" err " KVER Sets kernel version (--kernelver)" err " mkdist_args Extra params for onload_mkdist" + err " mksrcdeb_args Extra params for onload_mksrcdeb" err " rpmbuild_args Extra params for all rpmbuild builds" err " rpmbuild_source_args Extra params for rpmbuild source build" err " rpmbuild_binary_args Extra params for rpmbuild binary build" From 8b7eff61568369fc99aaaff92612c218cc9885ec Mon Sep 17 00:00:00 2001 From: Chang Chin-lan <192761079+changchinlan@users.noreply.github.com> Date: Wed, 3 Jun 2026 10:07:37 +0800 Subject: [PATCH 2/6] deb: support Makefile overlay, dkms.append.conf, and quilt patches 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. --- scripts/debian/debian-templ/rules | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/scripts/debian/debian-templ/rules b/scripts/debian/debian-templ/rules index 27f3a836b..3d677730d 100755 --- a/scripts/debian/debian-templ/rules +++ b/scripts/debian/debian-templ/rules @@ -188,7 +188,11 @@ ifneq (,$(filter #TYPE#-source,$(DOPACKAGES))) dh_installdirs -p$(psource) usr/src/modules/$(sname)/debian # Copy only the driver source to the proper location - cp Makefile debian/$(psource)/usr/src/modules/$(sname) + if [ -f "debian/Makefile" ]; then \ + cp debian/Makefile debian/$(psource)/usr/src/modules/$(sname); \ + else \ + cp Makefile debian/$(psource)/usr/src/modules/$(sname); \ + fi cp -r src debian/$(psource)/usr/src/modules/$(sname) cp -r scripts debian/$(psource)/usr/src/modules/$(sname) cp -r mk debian/$(psource)/usr/src/modules/$(sname) @@ -207,6 +211,20 @@ ifneq (,$(filter #TYPE#-dkms,$(DOPACKAGES))) install -D -m 644 dkms_override.conf debian/$(pdkms)/etc/dkms/$(sname).conf dh_installdirs -p$(pdkms) usr/src/ tar xf ../#TYPE#_#VERSION#.orig.tar.gz -C debian/$(pdkms)/usr/src/ + if [ -f "debian/Makefile" ]; then \ + install -D -m 644 debian/Makefile debian/$(pdkms)/usr/src/#TYPE#-#VERSION#/Makefile; \ + fi + + if [ -f "debian/dkms.append.conf" ]; then \ + cat debian/dkms.append.conf >> debian/$(pdkms)/usr/src/#TYPE#-#VERSION#/dkms.conf; \ + fi + + if [ -f $(CURDIR)/debian/patches/series ]; then \ + ( cd debian/$(pdkms)/usr/src/#TYPE#-#VERSION# && \ + QUILT_PATCHES=$(CURDIR)/debian/patches \ + QUILT_SERIES=$(CURDIR)/debian/patches/series \ + quilt push -a ); \ + fi endif # Add here commands to install the package into debian/#TYPE#. @@ -295,7 +313,7 @@ ifneq (,$(filter #TYPE#-user,$(DOPACKAGES))) dh_installdirs -p$(userpackage) lib/onload i_prefix=$(CURDIR)/debian/$(userpackage) scripts/onload_install --verbose \ - --packaged --userfiles --modprobe --modulesloadd \ + --packaged --userfiles --modprobe --modulesloadd --udev \ $(BUILD_FLAGS) $(SETUID) endif From 2c6c27eae4c6ef98a70ab6b5fcae0aa0a714e159 Mon Sep 17 00:00:00 2001 From: Chang Chin-lan <192761079+changchinlan@users.noreply.github.com> Date: Wed, 3 Jun 2026 10:07:37 +0800 Subject: [PATCH 3/6] deb: integrate dh_dkms for DKMS lifecycle management 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. --- scripts/debian/debian-templ/control | 4 ++-- scripts/debian/debian-templ/rules | 8 ++++++++ .../debian/debian-templ/type-dkms.postinst | 19 +++++++++++++------ scripts/debian/debian-templ/type-dkms.prerm | 2 +- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/scripts/debian/debian-templ/control b/scripts/debian/debian-templ/control index 4d10cb3aa..e121a1c39 100644 --- a/scripts/debian/debian-templ/control +++ b/scripts/debian/debian-templ/control @@ -2,7 +2,7 @@ Source: #TYPE# Section: net Priority: extra Maintainer: AMD Solarflare NIC Support -Build-Depends: debhelper (>= 8.0.0), bzip2, gawk, libc6, dh-python, python3-all, python3-setuptools, libpcap-dev, libcap-dev, debhelper (>= 13.3) | dh-sysuser, pybuild-plugin-pyproject +Build-Depends: debhelper (>= 8.0.0), bzip2, gawk, libc6, dh-python, python3-all, python3-setuptools, libpcap-dev, libcap-dev, debhelper (>= 13.3) | dh-sysuser, pybuild-plugin-pyproject, dh-sequence-dkms | dh-dkms | dkms Standards-Version: 3.9.3 Homepage: http://www.openonload.org @@ -26,7 +26,7 @@ Build-Profiles: Package: #TYPE#-dkms Architecture: all -Depends: dkms, #TYPE#-user (>= ${source:Version}), #TYPE#-user (<< ${source:Version}.1~), ${misc:Depends} +Depends: dkms, #TYPE#-user (>= ${source:Version}), #TYPE#-user (<< ${source:Version}.1~), libcap-dev, ${misc:Depends} Description: Onload debian package with DKMS Conflicts: #TYPE#-modules Build-Profiles: diff --git a/scripts/debian/debian-templ/rules b/scripts/debian/debian-templ/rules index 3d677730d..a9279d7be 100755 --- a/scripts/debian/debian-templ/rules +++ b/scripts/debian/debian-templ/rules @@ -215,6 +215,9 @@ ifneq (,$(filter #TYPE#-dkms,$(DOPACKAGES))) install -D -m 644 debian/Makefile debian/$(pdkms)/usr/src/#TYPE#-#VERSION#/Makefile; \ fi + if [ ! -f "debian/$(pdkms)/usr/src/#TYPE#-#VERSION#/dkms.conf" ]; then \ + ln -s ./scripts/onload_misc/dkms.conf debian/$(pdkms)/usr/src/#TYPE#-#VERSION#/dkms.conf; \ + fi if [ -f "debian/dkms.append.conf" ]; then \ cat debian/dkms.append.conf >> debian/$(pdkms)/usr/src/#TYPE#-#VERSION#/dkms.conf; \ fi @@ -247,6 +250,11 @@ binary-indep: build install # dh_installpam -i # dh_installmime -i # dh_python3 -i +# Let dh_dkms generate dkms-aware maintainer scripts for the dkms subpackage +# https://manpages.debian.org/buster/dkms/dh_dkms.1 +ifneq (,$(filter #TYPE#-dkms,$(DOPACKAGES))) + dh_dkms -p #TYPE#-dkms -- "$(if $(wildcard dkms.conf),dkms.conf,scripts/onload_misc/dkms.conf)" +endif # dh_installinit -i # dh_installcron -i # dh_installinfo -i diff --git a/scripts/debian/debian-templ/type-dkms.postinst b/scripts/debian/debian-templ/type-dkms.postinst index df4940141..830312b10 100644 --- a/scripts/debian/debian-templ/type-dkms.postinst +++ b/scripts/debian/debian-templ/type-dkms.postinst @@ -1,10 +1,17 @@ +#!/bin/sh # SPDX-License-Identifier: BSD-2-Clause # SPDX-FileCopyrightText: (c) Copyright 2023-2024 Advanced Micro Devices, Inc. -# Remove if already exists -dkms remove -m #TYPE# -v #VERSION# --all > /dev/null 2>&1 || true +set -e -# Build and install -dkms add -m #TYPE# -v #VERSION# -dkms build -m #TYPE# -v #VERSION# -dkms install -m #TYPE# -v #VERSION# --force +case "$1" in + triggered) + dkms autoinstall -m #TYPE# -v #VERSION# --force + # HACK: Force initramfs update because x3522 package does not trigger it + dpkg-trigger update-initramfs + ;; +esac + +#DEBHELPER# + +exit 0 diff --git a/scripts/debian/debian-templ/type-dkms.prerm b/scripts/debian/debian-templ/type-dkms.prerm index a71a71a24..6e114daa9 100644 --- a/scripts/debian/debian-templ/type-dkms.prerm +++ b/scripts/debian/debian-templ/type-dkms.prerm @@ -1,4 +1,4 @@ # SPDX-License-Identifier: BSD-2-Clause # SPDX-FileCopyrightText: (c) Copyright 2023 Advanced Micro Devices, Inc. -dkms remove -m #TYPE# -v #VERSION# +#DEBHELPER# From c9bff3e1161fc6dd696f088f6f3e9527612104a9 Mon Sep 17 00:00:00 2001 From: Chang Chin-lan <192761079+changchinlan@users.noreply.github.com> Date: Wed, 3 Jun 2026 10:07:37 +0800 Subject: [PATCH 4/6] deb: add initramfs hook, module autoload, and dpkg triggers 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. --- scripts/debian/debian-templ/rules | 4 ++ .../debian-templ/type-dkms.initramfs-hook | 64 +++++++++++++++++++ .../debian/debian-templ/type-dkms.postinst | 25 +++++++- .../debian/debian-templ/type-dkms.triggers | 2 + 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 scripts/debian/debian-templ/type-dkms.initramfs-hook create mode 100644 scripts/debian/debian-templ/type-dkms.triggers diff --git a/scripts/debian/debian-templ/rules b/scripts/debian/debian-templ/rules index a9279d7be..a5b656040 100755 --- a/scripts/debian/debian-templ/rules +++ b/scripts/debian/debian-templ/rules @@ -218,6 +218,9 @@ ifneq (,$(filter #TYPE#-dkms,$(DOPACKAGES))) if [ ! -f "debian/$(pdkms)/usr/src/#TYPE#-#VERSION#/dkms.conf" ]; then \ ln -s ./scripts/onload_misc/dkms.conf debian/$(pdkms)/usr/src/#TYPE#-#VERSION#/dkms.conf; \ fi + if [ ! -f "debian/$(pdkms)/usr/lib/modules-load.d/onload.conf" ]; then \ + install -D -m 644 ./scripts/onload_misc/onload_modules-load.d.conf debian/$(pdkms)/usr/lib/modules-load.d/onload.conf; \ + fi if [ -f "debian/dkms.append.conf" ]; then \ cat debian/dkms.append.conf >> debian/$(pdkms)/usr/src/#TYPE#-#VERSION#/dkms.conf; \ fi @@ -233,6 +236,7 @@ endif # Add here commands to install the package into debian/#TYPE#. dh_install + dh_installinitramfs # Build architecture-independent files here. # Pass -i to all debhelper commands in this target to reduce clutter. diff --git a/scripts/debian/debian-templ/type-dkms.initramfs-hook b/scripts/debian/debian-templ/type-dkms.initramfs-hook new file mode 100644 index 000000000..d345de7f1 --- /dev/null +++ b/scripts/debian/debian-templ/type-dkms.initramfs-hook @@ -0,0 +1,64 @@ +#!/bin/sh +PREREQ="" +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +prereqs) + prereqs + exit 0 + ;; +esac + +. /usr/share/initramfs-tools/hook-functions +# Begin real processing below this line + +# In ther future, it's possible to extend this script to a split dkms-prefer package with something like +# +# CONF_FILE="/etc/initramfs-tools/dkms-prefer.modules" +# # Read module list +# MODULES_LIST="" +# if [ -f "$CONF_FILE" ]; then +# # strip comments and blanks +# MODULES_LIST="$(sed -e 's/#.*$//' -e '/^[[:space:]]*$/d' "$CONF_FILE")" +# fi +# +# But we keep it simple for now. +MODULES_LIST="xilinx_efct sfc" + +# Nothing to do? +[ -n "${MODULES_LIST:-}" ] || exit 0 + +# Provided by initramfs-tools +DKMS_BASE="/lib/modules/${version}/updates/dkms" +DEST_DKMS_DIR="${DESTDIR}${DKMS_BASE}" +KERNEL_BASE="${DESTDIR}/lib/modules/${version}/kernel" + +mkdir -p "$DEST_DKMS_DIR" + +for mod in $MODULES_LIST; do + # Does *any* DKMS file for this module exist (host filesystem)? + if find "/lib/modules/${version}/updates/dkms" -maxdepth 1 -type f -name "${mod}.ko*" -print -quit | grep -q .; then + # Copy all matching DKMS files into the image (no globbing in the shell) + find "/lib/modules/${version}/updates/dkms" -maxdepth 1 -type f -name "${mod}.ko*" \ + | while IFS= read -r f; do + [ -n "$f" ] && copy_file module "$f" "$DKMS_BASE/" + done + + + # Remove any in-tree copies of the same module from the image + if [ -d "$KERNEL_BASE" ]; then + find "$KERNEL_BASE" -type f -name "${mod}.ko*" -delete || true + fi + + # Ensure dependencies get pulled in + manual_add_modules "$mod" || true + echo "initramfs-tools: using DKMS '${mod}' (updates/dkms) for ${version}" >&2 + else + # No DKMS — warn and fall back to in-tree + echo "initramfs-tools: WARNING: DKMS module '${mod}' not found for ${version}; using in-tree if available" >&2 + manual_add_modules "$mod" || true + fi +done diff --git a/scripts/debian/debian-templ/type-dkms.postinst b/scripts/debian/debian-templ/type-dkms.postinst index 830312b10..31932ff23 100644 --- a/scripts/debian/debian-templ/type-dkms.postinst +++ b/scripts/debian/debian-templ/type-dkms.postinst @@ -4,12 +4,35 @@ set -e +install_dkms() { + # Remove if already exists + dkms remove -m #TYPE# -v #VERSION# --all > /dev/null 2>&1 || true + + # Build and install + dkms add -m #TYPE# -v #VERSION# + dkms build -m #TYPE# -v #VERSION# + dkms install -m #TYPE# -v #VERSION# --force +} + case "$1" in + configure) + install_dkms + ;; + triggered) - dkms autoinstall -m #TYPE# -v #VERSION# --force + install_dkms # HACK: Force initramfs update because x3522 package does not trigger it dpkg-trigger update-initramfs ;; + + abort-upgrade|abort-remove|abort-deconfigure) + exit 0 + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; esac #DEBHELPER# diff --git a/scripts/debian/debian-templ/type-dkms.triggers b/scripts/debian/debian-templ/type-dkms.triggers new file mode 100644 index 000000000..3b3369b8d --- /dev/null +++ b/scripts/debian/debian-templ/type-dkms.triggers @@ -0,0 +1,2 @@ +interest /usr/share/doc/xilinx-efct-dkms/changelog.gz +activate-noawait update-initramfs From 11d793d46b86bad2ff64cac1c626dd75e1cfd4d3 Mon Sep 17 00:00:00 2001 From: Chang Chin-lan <192761079+changchinlan@users.noreply.github.com> Date: Wed, 3 Jun 2026 10:21:16 +0800 Subject: [PATCH 5/6] deb: make pybuild conditional on pyproject.toml 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'. --- scripts/debian/debian-templ/rules | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/debian/debian-templ/rules b/scripts/debian/debian-templ/rules index a5b656040..590ab6c74 100755 --- a/scripts/debian/debian-templ/rules +++ b/scripts/debian/debian-templ/rules @@ -16,7 +16,10 @@ #export DH_VERBOSE=1 +# Only enable pybuild if the source ships a pyproject.toml +ifneq (,$(wildcard pyproject.toml)) export PYBUILD_SYSTEM=pyproject +endif # some default definitions, important! # @@ -290,7 +293,9 @@ endif # Build architecture-dependent files here. binary-arch: build install dh_lintian +ifneq (,$(wildcard pyproject.toml)) pybuild --verbose --build +endif dh_testdir -a dh_testroot -a dh_installsysusers -a --name=onload || dh_sysuser -a onload_cplane home=/run/openonload @@ -302,8 +307,10 @@ binary-arch: build install # dh_installemacsen -a # dh_installpam -a # dh_installmime -a +ifneq (,$(wildcard pyproject.toml)) pybuild --verbose --install --dest-dir debian/$(userpackage) dh_python3 -a +endif # dh_installinit -a dh_installcron -a # dh_installman -a From 8a031c3ce3cdc55f2c6e4c3ec09db106d2cb5616 Mon Sep 17 00:00:00 2001 From: Chang Chin-lan <192761079+changchinlan@users.noreply.github.com> Date: Wed, 3 Jun 2026 11:16:10 +0800 Subject: [PATCH 6/6] deb: pass --python-layout=deb for releases without pyproject.toml 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. --- scripts/debian/debian-templ/rules | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/debian/debian-templ/rules b/scripts/debian/debian-templ/rules index 590ab6c74..75c21fe5f 100755 --- a/scripts/debian/debian-templ/rules +++ b/scripts/debian/debian-templ/rules @@ -333,6 +333,7 @@ ifneq (,$(filter #TYPE#-user,$(DOPACKAGES))) i_prefix=$(CURDIR)/debian/$(userpackage) scripts/onload_install --verbose \ --packaged --userfiles --modprobe --modulesloadd --udev \ + $(if $(wildcard pyproject.toml),,--python-layout=deb) \ $(BUILD_FLAGS) $(SETUID) endif