Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/debian/debian-templ/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#TYPE# (#VERSION#-1) unstable; urgency=low
#TYPE# (#VERSION#-#DEBIAN_REVISION#) unstable; urgency=low

* Initial release of Debian packages

Expand Down
4 changes: 2 additions & 2 deletions scripts/debian/debian-templ/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Source: #TYPE#
Section: net
Priority: extra
Maintainer: AMD Solarflare NIC Support <support-nic@amd.com>
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

Expand All @@ -26,7 +26,7 @@ Build-Profiles: <!pkg.#TYPE#.nosource>

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: <!pkg.#TYPE#.nodkms>
Expand Down
42 changes: 40 additions & 2 deletions scripts/debian/debian-templ/rules
Original file line number Diff line number Diff line change
Expand Up @@ -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!
#
Expand Down Expand Up @@ -188,7 +191,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)
Expand All @@ -207,11 +214,32 @@ 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/$(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

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#.

dh_install
dh_installinitramfs

# Build architecture-independent files here.
# Pass -i to all debhelper commands in this target to reduce clutter.
Expand All @@ -229,6 +257,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
Expand Down Expand Up @@ -260,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
Expand All @@ -272,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
Expand All @@ -295,7 +332,8 @@ 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 \
$(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.

$(BUILD_FLAGS) $(SETUID)
endif

Expand Down
64 changes: 64 additions & 0 deletions scripts/debian/debian-templ/type-dkms.initramfs-hook
Original file line number Diff line number Diff line change
@@ -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
42 changes: 36 additions & 6 deletions scripts/debian/debian-templ/type-dkms.postinst
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
#!/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
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)
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#

exit 0
2 changes: 1 addition & 1 deletion scripts/debian/debian-templ/type-dkms.prerm
Original file line number Diff line number Diff line change
@@ -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#
2 changes: 2 additions & 0 deletions scripts/debian/debian-templ/type-dkms.triggers
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
interest /usr/share/doc/xilinx-efct-dkms/changelog.gz
activate-noawait update-initramfs
12 changes: 10 additions & 2 deletions scripts/debian/onload_mksrcdeb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ usage() {
err "options:"
err " --tarball <path> - onload tarball to create packages for"
err " --out <path> - directory to write source package to"
err " --debian-revision <n>"
err " - Debian package revision (default 1)"
err
exit 1
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -112,4 +121,3 @@ try rm -rf "$tempfile"
echo ""
echo "Wrote $outdir/$package-debiansource.tgz"
echo ""

4 changes: 3 additions & 1 deletion scripts/onload_mkpackage
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down