Skip to content

Commit

Permalink
ON-15113: Simplify DKMS using pure mkdist tarball
Browse files Browse the repository at this point in the history
  • Loading branch information
pcolledg-amd committed Nov 4, 2024
1 parent 1957083 commit 310033b
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 371 deletions.
23 changes: 4 additions & 19 deletions scripts/debian/debian-templ/rules
Original file line number Diff line number Diff line change
Expand Up @@ -194,26 +194,11 @@ ifneq (,$(filter #TYPE#-source,$(DOPACKAGES)))
cd debian/$(psource)/usr/src && tar c modules | bzip2 -9 > $(sname).tar.bz2 && rm -rf modules
endif

# perform above operations also for the DKMS build:
ifneq (,$(filter #TYPE#-dkms,$(DOPACKAGES)))
# Create the directories to install the source into
dh_installdirs -p$(pdkms) usr/src/modules/$(sname)-#VERSION#/debian

# Copy only the driver source to the proper location
cp Makefile debian/$(pdkms)/usr/src/modules/$(sname)-#VERSION#
cp -r src debian/$(pdkms)/usr/src/modules/$(sname)-#VERSION#
cp -r scripts debian/$(pdkms)/usr/src/modules/$(sname)-#VERSION#
cp -r mk debian/$(pdkms)/usr/src/modules/$(sname)-#VERSION#
# Copy the needed debian/ pieces to the proper location
cp debian/*modules.in* \
debian/$(pdkms)/usr/src/modules/$(sname)-#VERSION#/debian
cp debian/control \
debian/$(pdkms)/usr/src/modules/$(sname)-#VERSION#/debian
cp debian/rules debian/changelog debian/copyright \
debian/compat debian/$(pdkms)/usr/src/modules/$(sname)-#VERSION#/debian/
sed -e "s,#BUILDFLAGS#,$(BUILD_FLAGS),g" \
< debian/#TYPE#-dkms.dkms > debian/$(pdkms)/usr/src/modules/$(sname)-#VERSION#/debian/#TYPE#-dkms.dkms
cd debian/$(pdkms)/usr/src && tar c modules | bzip2 -9 > $(sname).tar.bz2 && rm -rf modules
echo "ONLOAD_INSTALL_ARGS=\"$(BUILD_FLAGS)\"" > dkms_override.conf
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/
endif

# Add here commands to install the package into debian/#TYPE#.
Expand Down
48 changes: 0 additions & 48 deletions scripts/debian/debian-templ/type-dkms.dkms

This file was deleted.

18 changes: 3 additions & 15 deletions scripts/debian/debian-templ/type-dkms.postinst
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
# SPDX-License-Identifier: BSD-2-Clause
# SPDX-FileCopyrightText: (c) Copyright 2023 Advanced Micro Devices, Inc.

# Unpack onload.tar.bz2
cd /usr/src && bzip2 -d #TYPE#.tar.bz2 && tar xf #TYPE#.tar
rm -f /usr/src/#TYPE#.tar

# Put the DKMS config file in the right place
sed -e "s/^PACKAGE_VERSION=.*/PACKAGE_VERSION=#VERSION#/" -e "s/openonload/#TYPE#/g" \
< /usr/src/modules/#TYPE#-#VERSION#/debian/#TYPE#-dkms.dkms \
> /usr/src/modules/#TYPE#-#VERSION#/dkms.conf
# 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

# Build and install
dkms add -m #TYPE# -v #VERSION# --sourcetree /usr/src/modules
dkms add -m #TYPE# -v #VERSION#
dkms build -m #TYPE# -v #VERSION#
dkms install -m #TYPE# -v #VERSION#

# Reload drivers
onload_tool reload
dkms install -m #TYPE# -v #VERSION# --force
2 changes: 0 additions & 2 deletions scripts/debian/debian-templ/type-dkms.prerm
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# SPDX-License-Identifier: BSD-2-Clause
# SPDX-FileCopyrightText: (c) Copyright 2023 Advanced Micro Devices, Inc.

onload_tool unload
dkms remove -m #TYPE# -v #VERSION#
rm -rf /usr/src/modules/#TYPE#-#VERSION#
7 changes: 6 additions & 1 deletion scripts/lib/mkdist/preprocess_source
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: BSD-2-Clause
# X-SPDX-Copyright-Text: (c) Copyright 2017-2023 Xilinx, Inc.
# X-SPDX-Copyright-Text: (c) Copyright 2017-2024 Advanced Micro Devices, Inc.

# This file is included by scripts that need to prepare Onload source files
# for distribution to customers.
Expand Down Expand Up @@ -65,6 +65,11 @@ update_product_strings() {
-e "/^Name: */ s/openonload/$product/" \
scripts/onload_misc/openonload.spec
fi
try sed -i \
-e "/^PACKAGE_NAME=/ s/.*/PACKAGE_NAME=$product/" \
-e "/^PACKAGE_VERSION=/ s/.*/PACKAGE_VERSION=$version/" \
scripts/onload_misc/dkms.conf
mv scripts/onload_misc/dkms.conf dkms.conf
}

# This is a wrapper around the various preprocessing stages for environments
Expand Down
6 changes: 3 additions & 3 deletions scripts/onload_misc/dkms.conf
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# SPDX-License-Identifier: GPL-2.0
# X-SPDX-Copyright-Text: (c) Copyright 2012-2020 Xilinx, Inc.
# X-SPDX-Copyright-Text: (c) Copyright 2012-2024 Advanced Micro Devices, Inc.
PACKAGE_NAME=openonload
PACKAGE_VERSION=

# Items below here should not have to change with each driver version.
# We quote make to avoid a misfeature of DKMS which adds a definition
# of KERNELRELEASE, which should only be defined by kbuild.
if which onload_uninstall >/dev/null 2>&1; then
MAKE[0]="unset CC; ${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build/scripts/onload_install --newkernel ${kernelver}"
MAKE[0]="unset CC; ${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build/scripts/onload_install --newkernel ${kernelver} $ONLOAD_INSTALL_ARGS"
else
MAKE[0]="unset CC; ${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build/scripts/onload_install"
MAKE[0]="unset CC; ${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build/scripts/onload_install --kernelfiles --kernelver ${kernelver} $ONLOAD_INSTALL_ARGS"
fi

#CLEAN="${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/source/scripts/onload_misc/onload_uninstall"
Expand Down
87 changes: 0 additions & 87 deletions scripts/onload_misc/openonload.dkms-spec

This file was deleted.

79 changes: 72 additions & 7 deletions scripts/onload_misc/openonload.spec
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
# If you don't want to build the kernel module package, use:
# --without kmod
#
# If you want to build the kernel module Akmods package, use:
# --with akmod
# If you don't want to build the kernel module Akmods package, use:
# --without akmod
#
# If you don't want to build the kernel module DKMS package, use:
# --without dkms
#
# If you don't want to build the userland package, use:
# --without user
Expand Down Expand Up @@ -65,10 +68,11 @@
# is unavailable at build time:
# --define "have_efct 1"

%bcond_without user # add option to skip userland builds
%bcond_without kmod # add option to skip kmod builds
%bcond_without devel # add option to skip devel builds
%bcond_with akmod # add option to include Akmods package
%bcond_without user # add option to skip userland package
%bcond_without kmod # add option to skip kmod package
%bcond_without devel # add option to skip devel package
%bcond_without akmod # add option to skip Akmods package
%bcond_without dkms # add option to skip DKMS package

%define pkgversion 20100910

Expand Down Expand Up @@ -264,7 +268,61 @@ This package comprises development headers for the components of OpenOnload.
%{_includedir}/etherfabric
%{_includedir}/onload
%endif

###############################################################################

%if %{with dkms}
%package dkms
Summary: OpenOnload kernel modules as DKMS source
Group: System Environment/Kernel
Requires: dkms >= 2.6
Requires: openonload = %{version}-%{release}
Provides: openonload-kmod = %{version}-%{release}
Provides: sfc-kmod-symvers = %{version}-%{release}
BuildArch: noarch

%description dkms
OpenOnload is a high performance user-level network stack. Please see
www.openonload.org for more information.

This package comprises the kernel module components of OpenOnload as DKMS.

%post dkms
dkms add -m %{name} -v %{pkgversion} --rpm_safe_upgrade
if [ `uname -r | grep -c "BOOT"` -eq 0 ] && [ -e /lib/modules/`uname -r`/build/include ]; then
dkms build -m %{name} -v %{pkgversion}
dkms install -m %{name} -v %{pkgversion} --force
elif [ `uname -r | grep -c "BOOT"` -gt 0 ]; then
echo -e ""
echo -e "Module build for the currently running kernel was skipped since you"
echo -e "are running a BOOT variant of the kernel."
else
echo -e ""
echo -e "Module build for the currently running kernel was skipped since the"
echo -e "kernel headers for this kernel do not seem to be installed."
fi
exit 0

%preun dkms
echo -e
echo -e "Uninstall of %{name} module (version %{pkgversion}) beginning:"
dkms remove -m %{name} -v %{pkgversion} --all --rpm_safe_upgrade

%files dkms
%defattr(-,root,root)
%{_usrsrc}/%{name}-%{pkgversion}/
%config(noreplace) %{_sysconfdir}/dkms/%{name}.conf
%if 0%{?license:1}
%license LICENSE*
%else
%doc LICENSE*
%endif
%doc README* ChangeLog*

%endif

###############################################################################

%prep
[ "$RPM_BUILD_ROOT" != / ] && rm -rf "$RPM_BUILD_ROOT"
%setup -q -n %{name}-%{pkgversion}
Expand Down Expand Up @@ -330,6 +388,7 @@ sed \
-e "/bcond_without user/ {s/without/with/; s/skip/include/}" \
-e "/bcond_without devel/ {s/without/with/; s/skip/include/}" \
-e "/bcond_without akmod/ {s/without/with/; s/skip/include/}" \
-e "/bcond_without dkms/ {s/without/with/; s/skip/include/}" \
-e "/bcond_with kernel_package_deps/ {s/with/without/; s/include/skip/}" \
-e '/define "moddir extra"/ s/.*/%%global moddir extra\/onload/' \
%{?debug:-e '/define "debug true"/ s/.*/%%global debug true/'} \
Expand All @@ -344,6 +403,12 @@ rpmbuild \
-bs --nodeps %{_specdir}/%{name}-akmod.spec
ln -s $(ls %{buildroot}/%{_usrsrc}/akmods/) %{buildroot}/%{_usrsrc}/akmods/%{name}-kmod.latest
%endif
%if %{with dkms}
echo "ONLOAD_INSTALL_ARGS=\"%{?debug:--debug}%{?build_profile: --build-profile %build_profile}%{?moddir: --moddir=%moddir}\"" > dkms_overrides.conf
install -D -m 644 dkms_overrides.conf %{buildroot}%{_sysconfdir}/dkms/%{name}.conf
mkdir -p %{buildroot}%{_usrsrc}
tar xf %{SOURCE0} -C %{buildroot}%{_usrsrc}
%endif

%post

Expand Down Expand Up @@ -403,7 +468,7 @@ rm -fR $RPM_BUILD_ROOT
%else
%doc LICENSE*
%endif
%doc README* ChangeLog* ReleaseNotes*
%doc README* ChangeLog*

%attr(644, -, -) %{_sysconfdir}/modprobe.d/onload.conf
%attr(644, -, -) %{_sysconfdir}/depmod.d/onload.conf
Expand Down
Loading

0 comments on commit 310033b

Please sign in to comment.