mirror of
https://github.com/amnezia-vpn/amneziawg-linux-kernel-module.git
synced 2026-05-17 08:26:30 +03:00
Build fixes for newer kernels (#13)
* Hotfix: installation on modern kernels * Cleanup kernel sources and final RPM package fix * Notice in README regarding EPEL and DKMS.
This commit is contained in:
@@ -58,6 +58,8 @@ sudo apt-get install -y amneziawg
|
||||
|
||||
### RHEL/CentOS/SUSE/Fedora Core
|
||||
|
||||
*If you use release that doesn't have DKMS support out of the box, you may need to install [EPEL](https://docs.fedoraproject.org/en-US/epel/#_quickstart) first.*
|
||||
|
||||
Open `Terminal` and run:
|
||||
|
||||
```shell
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
%global debug_package %{nil}
|
||||
|
||||
Name: amneziawg-dkms
|
||||
Version: 1.0.20240213
|
||||
Version: 1.0.20240711
|
||||
Release: 1%{?dist}
|
||||
Epoch: 1
|
||||
URL: https://www.wireguard.com/
|
||||
@@ -24,6 +24,7 @@ Requires: make
|
||||
Requires: bc
|
||||
Requires: yum-utils
|
||||
Requires: rpm-build
|
||||
Requires: python3-devel
|
||||
|
||||
%description
|
||||
WireGuard is a novel VPN that runs inside the Linux Kernel and uses
|
||||
@@ -42,10 +43,8 @@ sed -i 's/install .* -D -t\(.\+\) /mkdir -p \1 \&\& \0/' %{_builddir}/amneziawg-
|
||||
|
||||
# Set version in dkms.conf and Makefile
|
||||
sed -i "s/^PACKAGE_VERSION=.*/PACKAGE_VERSION=\"%{version}\"/" %{_builddir}/amneziawg-linux-kernel-module-%{version}/src/dkms.conf
|
||||
sed -i "s/^MAKE\[0\]=\"make -C \/var\/lib\/dkms\/amneziawg\/.*/MAKE[0]=\"make -C \/var\/lib\/dkms\/amneziawg\/%{version}\/build\"/" %{_builddir}/amneziawg-linux-kernel-module-%{version}/src/dkms.conf
|
||||
sed -i "s/^WIREGUARD_VERSION = .*/WIREGUARD_VERSION = %{version}/" %{_builddir}/amneziawg-linux-kernel-module-%{version}/src/Makefile
|
||||
|
||||
|
||||
%build
|
||||
|
||||
%install
|
||||
|
||||
8
kernel-tree-scripts/cleanup-sources.sh
Executable file
8
kernel-tree-scripts/cleanup-sources.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
AWG_TEMP_DIR="$(cat /var/lib/amnezia/amneziawg/.tempdir 2>/dev/null)"
|
||||
PREFIX=${AWG_TEMP_DIR:-/tmp}
|
||||
WORKDIR="${PREFIX}/amneziawg"
|
||||
|
||||
[ -e kernel ] && rm -f kernel
|
||||
[ -d "${WORKDIR}" ] && rm -rf "${WORKDIR}"
|
||||
@@ -59,8 +59,10 @@ echo "Downloading source for Linux kernel version ${KERNEL_VERSION}"
|
||||
|
||||
if [[ "${DISTRO_FLAVOR}" =~ debian ]]; then
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
ac=$(apt-cache search --names-only linux-image "${KERNEL_VERSION}" unsigned 2>/dev/null|head -n 1)
|
||||
[ "${ac}" == "" ] && ac=$(apt-cache search --names-only linux-image "${KERNEL_VERSION}" 2>/dev/null|head -n 1)
|
||||
VERSION_MAIN="${KERNEL_VERSION%+*}"
|
||||
VERSION_SUFFIX="${KERNEL_VERSION#*+}"
|
||||
ac=$(apt-cache search --names-only linux-image "${VERSION_MAIN}" "${VERSION_SUFFIX}" unsigned 2>/dev/null|head -n 1)
|
||||
[ "${ac}" == "" ] && ac=$(apt-cache search --names-only linux-image "${VERSION_MAIN}" "${VERSION_SUFFIX}" 2>/dev/null|head -n 1)
|
||||
if [ "${ac}" == "" ]; then
|
||||
echo "Could not find suitable image for your Linux distribution!"
|
||||
exit 255
|
||||
@@ -82,7 +84,7 @@ else
|
||||
[ -f "${HOME}/.rpmmacros.orig" ] && mv "${HOME}/.rpmmacros.orig" "${HOME}/.rpmmacros"
|
||||
cd ../BUILD || exit 255
|
||||
cd "$(ls -d */)" || exit 255
|
||||
cd "$(ls -d */)" || exit 255
|
||||
cd "$(ls -d linux*/)" || exit 255
|
||||
fi
|
||||
|
||||
KERNEL_PATH="$(pwd)"
|
||||
|
||||
10
src/Makefile
10
src/Makefile
@@ -15,8 +15,8 @@ DEPMODBASEDIR ?= /
|
||||
|
||||
PWD := $(shell pwd)
|
||||
|
||||
all: apply-patches module module-copy
|
||||
debug: apply-patches module-debug module-copy
|
||||
all: apply-patches module
|
||||
debug: apply-patches module-debug
|
||||
|
||||
rwildcard=$(foreach d,$(if $3,$(filter-out $3,$(wildcard $1*)),$(wildcard $1*)),$(call rwildcard,$d/,$2,$3) $(filter $(subst *,%,$2),$d))
|
||||
|
||||
@@ -91,11 +91,12 @@ endif
|
||||
|
||||
module:
|
||||
@$(MAKE) -C $(KERNELDIR) M=$(TARGET_BUILD_DIR) WIREGUARD_VERSION="$(WIREGUARD_VERSION)" modules
|
||||
if [ "$(TARGET_BUILD_DIR)" != "$(PWD)" ]; then \
|
||||
cp $(TARGET_BUILD_DIR)/amneziawg.ko $(PWD)/amneziawg.ko; \
|
||||
fi
|
||||
|
||||
module-debug:
|
||||
@$(MAKE) -C $(KERNELDIR) M=$(TARGET_BUILD_DIR) V=1 CONFIG_AMNEZIAWG_DEBUG=y WIREGUARD_VERSION="$(WIREGUARD_VERSION)" modules
|
||||
|
||||
module-copy:
|
||||
if [ "$(TARGET_BUILD_DIR)" != "$(PWD)" ]; then \
|
||||
cp $(TARGET_BUILD_DIR)/amneziawg.ko $(PWD)/amneziawg.ko; \
|
||||
fi
|
||||
@@ -116,6 +117,7 @@ DKMS_SOURCES := Makefile Kbuild Kconfig dkms.conf $(call rwildcard,,*.c *.h *.S
|
||||
dkms-install: $(DKMS_SOURCES)
|
||||
@$(foreach f,$(DKMS_SOURCES),install -v -m0644 -D $(f) $(DESTDIR)$(DKMSDIR)/$(f);)
|
||||
@install -v -m 0755 ../kernel-tree-scripts/prepare-sources.sh "$(DESTDIR)$(DKMSDIR)/prepare-sources.sh"
|
||||
@install -v -m 0755 ../kernel-tree-scripts/cleanup-sources.sh "$(DESTDIR)$(DKMSDIR)/cleanup-sources.sh"
|
||||
if [ "$(realpath $(WG_SOURCE_DIR))" != "" ]; then \
|
||||
ln -s "$(KERNEL_SOURCE_DIR)" "$(DESTDIR)$(DKMSDIR)/kernel"; \
|
||||
fi
|
||||
|
||||
@@ -4,7 +4,8 @@ AUTOINSTALL=yes
|
||||
REMAKE_INITRD=yes
|
||||
|
||||
PRE_BUILD="prepare-sources.sh $kernelver"
|
||||
MAKE[0]="make -C /var/lib/dkms/amneziawg/1.0.0/build"
|
||||
POST_BUILD="cleanup-sources.sh"
|
||||
MAKE[0]="make -C /var/lib/dkms/amneziawg/${PACKAGE_VERSION}/build"
|
||||
|
||||
BUILT_MODULE_NAME="amneziawg"
|
||||
DEST_MODULE_LOCATION="/kernel/net"
|
||||
|
||||
Reference in New Issue
Block a user