File openvpn-dco.spec of Package openvpn-dco
%define realname ovpn-dco
%define realver 0.2.20231010
%define srcext tar.gz
# Common info
Name: openvpn-dco-dkms
Version: %{realver}
Release: wiz%{?extraver:0.}1%{?dist}
License: GPL-2.0
Group: System/Kernel
URL: https://github.com/OpenVPN/ovpn-dco
Summary: OpenVPN Data Channel Offload in the linux kernel
# Install-time parameters
Provides: %{realname}-dkms = %{version}-%{release}
Requires: dkms
# Build-time parameters
BuildRoot: %{_tmppath}/%{name}-root
BuildArch: noarch
Source0: https://github.com/OpenVPN/ovpn-dco/archive/refs/tags/v%{realver}.%{srcext}#/%{realname}-%{realver}.%{srcext}
%description
A linux kernel module implementing the data channel of the OpenVPN protocol in
the linux kernel.
This kernel module allows OpenVPN to offload any data plane management to the
linux kernel, thus allowing it to exploit any Linux low level API, while
avoiding expensive and slow payload transfer between kernel space
and user space.
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}
%build
%install
%{__install} -d -m755 %{buildroot}/usr/src/%{realname}-%{realver}
%{__sed} -ri 's/\$\(CONFIG_OVPN_DCO.*\)/m/' drivers/net/ovpn-dco/Makefile
cat >> drivers/net/ovpn-dco/Makefile <<EOF
ccflags-y += -I\$(src) -include \$(src)/linux-compat.h
ccflags-y += -DOVPN_DCO_VERSION=\"%{version}\"
ccflags-y += -Wno-error=incompatible-pointer-types
EOF
%{__cp} -r compat-include/net %{buildroot}/usr/src/%{realname}-%{realver}/
%{__cp} -r drivers/net/ovpn-dco/* %{buildroot}/usr/src/%{realname}-%{realver}/
%{__cp} -r include/uapi %{buildroot}/usr/src/%{realname}-%{realver}/
%{__cp} linux-compat.h %{buildroot}/usr/src/%{realname}-%{realver}/
cat > %{buildroot}/usr/src/%{realname}-%{realver}/dkms.conf <<EOF
PACKAGE_NAME=%{realname}
PACKAGE_VERSION=%{realver}
AUTOINSTALL=yes
BUILT_MODULE_NAME=ovpn-dco-v2
DEST_MODULE_LOCATION=/updates
EOF
%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
%files
%defattr(-,root,root)
%doc README
%dir /usr/src/%{realname}-%{realver}
/usr/src/%{realname}-%{realver}/*
%pre
# $1 == 2 means upgrade
if [ "$1" = '2' ]; then
OLDMOD=$(dkms status | awk -F, '{print $1}')
OLDVER=${OLDMOD##*/}
if [ ! "$OLDVER" = '%{version}' ]; then
/usr/sbin/dkms remove -q --all -m $OLDMOD || :
fi
fi
%post
/usr/sbin/dkms add -q -m %{realname} -v %{version} || :
/usr/sbin/dkms autoinstall -q -m %{realname} -v %{version} --force || :
%preun
# $1 == 0 means uninstall
if [ "$1" = '0' ]; then
/usr/sbin/dkms remove -q --all -m %{realname} -v %{version} || :
fi
%changelog