# Because Red Hat broke this macro by not including kernel-rpm-macros in the base buildroot %{!?kernel_module_package_buildreqs:%global kernel_module_package_buildreqs kernel-devel kernel-abi-whitelists redhat-rpm-config kernel-rpm-macros elfutils-libelf-devel kmod} %global kmodname wireguard Name: %{kmodname}-kmod Version: 1.0.20200908 Release: 0%{?dist}.1 Summary: Kernel module (kmod) for WireGuard License: GPLv2 URL: https://wireguard.com/ Source0: https://git.zx2c4.com/wireguard-linux-compat/snapshot/wireguard-linux-compat-%{version}.tar.xz # For kmodtool Source10: kmod-wireguard.spec.preamble # patch dependencies BuildRequires: git-core # kernel module package macros were split out sometime after EL7... %if ! (0%{?rhel} && 0%{?rhel} < 8) BuildRequires: kernel-rpm-macros %endif # kmod dependencies BuildRequires: %kernel_module_package_buildreqs BuildRequires: gcc BuildRequires: make %{?kernel_module_package:%kernel_module_package -n %{kmodname} -p %{S:10}} %description WireGuard is a novel VPN that runs inside the Linux Kernel and utilizes state-of-the-art cryptography. It aims to be faster, simpler, leaner, and more useful than IPSec, while avoiding the massive headache. It intends to be considerably more performant than OpenVPN. WireGuard is designed as a general purpose VPN for running on embedded interfaces and super computers alike, fit for many different circumstances. It runs over UDP. This package contains the kernel module for WireGuard. %package -n dkms-%{kmodname} Summary: Kernel module (kmod) for WireGuard built using DKMS Provides: kmod(wireguard.ko) Requires: dkms Requires: elfutils-libelf-devel Requires: kernel-devel Requires: gcc Requires: make Requires: %{kmodname}-kmod = %{version}-%{release} Conflicts: kmod-%{kmodname} BuildArch: noarch %description -n dkms-%{kmodname} WireGuard is a novel VPN that runs inside the Linux Kernel and utilizes state-of-the-art cryptography. It aims to be faster, simpler, leaner, and more useful than IPSec, while avoiding the massive headache. It intends to be considerably more performant than OpenVPN. WireGuard is designed as a general purpose VPN for running on embedded interfaces and super computers alike, fit for many different circumstances. It runs over UDP. This package contains the kernel module sources for WireGuard that can build the kernel module using DKMS. %prep %autosetup -n wireguard-linux-compat-%{version} -S git_am %build mkdir kmodbuild for flavor in %{flavors_to_build}; do cp -a src kmodbuild/$flavor %make_build -C %{kernel_source $flavor} modules M=$PWD/kmodbuild/$flavor done %install export INSTALL_MOD_PATH=%{buildroot} for flavor in %{flavors_to_build}; do %{__make} V=1 -C %{kernel_source $flavor} modules_install M=$PWD/kmodbuild/$flavor done # DKMS code install mkdir -p %{buildroot}%{_usrsrc}/%{kmodname}-%{version} make -C src dkms-install DESTDIR=%{buildroot} DKMSDIR=%{_usrsrc}/%{kmodname}-%{version} %post -n dkms-%{kmodname} if [ "$1" -ge "1" ]; then if [ -f /usr/lib/dkms/common.postinst ]; then /usr/lib/dkms/common.postinst %{kmodname} %{version} exit $? fi fi %preun -n dkms-%{kmodname} if [ $1 -eq 0 ]; then lsmod | grep %{kmodname} >& /dev/null if [ $? -eq 0 ]; then modprobe -r %{kmodname} fi fi dkms status -m %{kmodname} -v %{version} | grep %{kmodname} >& /dev/null if [ $? -eq 0 ]; then dkms remove -m %{kmodname} -v %{version} --all --rpm_safe_upgrade fi %files %license COPYING %doc README.md %files -n dkms-%{kmodname} %{_usrsrc}/%{kmodname}-%{version}/ %changelog * Wed Jun 17 2020 Neal Gompa - Initial package