diff --git a/net-vpn/amneziawg-linux-kernel-module/Manifest b/net-vpn/amneziawg-linux-kernel-module/Manifest index 415c3bc..b6eb7b7 100644 --- a/net-vpn/amneziawg-linux-kernel-module/Manifest +++ b/net-vpn/amneziawg-linux-kernel-module/Manifest @@ -1,2 +1,2 @@ DIST amneziawg-linux-kernel-module-1.0.20241023.tar.gz 415325 BLAKE2B e56448d1793c060b57a8dece6d17f6fa372ac6b6242290ed87d777105876e228ed682b59f6f11eedeb7fc415bb35c48bfe82ecec99bc171175864be0a6ba39d2 SHA512 2154f749d91adc2be185a02b58a6b20a079b3985277b8cb874b4affda00bfaabe949e01088c157d71e7d4a6e2e073f07e9dc370d8165465156f30ed8c9178a25 -EBUILD amneziawg-linux-kernel-module-1.0.20241023.ebuild 3358 BLAKE2B 283a5d1c865fce52aa2f1867c0172582d02ae629128c6251599d54b2955c59cfa280db7a03c2dbb3e204d4abf57941029c219f867faa669c387086fbfebe4ef6 SHA512 eecd48c09788bfc3b701068575fb7211d4b81dc475f02b5a4800e3384a3eda05c9869a6a155991f8aef76f802c2e961b8a81e2c9cfc54cb4096a726a4d2c43a7 +EBUILD amneziawg-linux-kernel-module-1.0.20241023.ebuild 4520 BLAKE2B 47fee9a9876fda689674a5de469f7a8ac3bc8bcce5788a2705b08df3d699b6002c73a9759ee8dae256fd079c0b091ecc707785a944bbb3408b30e8831ba8d323 SHA512 83a13a223b99456e7425361b0eb10ae6c1ae3a086e9b2baaa68b7cb168f3a7e31fa1626a12dac11289cb09672cf4275535a1e9b87400361a8b91e72b1b2f7cfd diff --git a/net-vpn/amneziawg-linux-kernel-module/amneziawg-linux-kernel-module-1.0.20241023.ebuild b/net-vpn/amneziawg-linux-kernel-module/amneziawg-linux-kernel-module-1.0.20241023.ebuild index 4722a2e..e181b7a 100644 --- a/net-vpn/amneziawg-linux-kernel-module/amneziawg-linux-kernel-module-1.0.20241023.ebuild +++ b/net-vpn/amneziawg-linux-kernel-module/amneziawg-linux-kernel-module-1.0.20241023.ebuild @@ -1,4 +1,3 @@ -# Copyright 1999-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 @@ -24,6 +23,13 @@ IUSE="debug +module module-src" CONFIG_CHECK="NET INET NET_UDP_TUNNEL CRYPTO_ALGAPI" +# On modern kernels AmneziaWG needs Wireguard sources from kernel to generate +# own sources from. On a typical Gentoo installation 'sys-kernel/*-sources' +# package contains needed kernel sources. But installations based on +# distribution kernel (sys-kernel/*-kernel) have no kernel sources installed. +# That is why this ebuild has a build dependency on gentoo-sources or vanilla-sources. +BDEPEND="|| ( sys-kernel/gentoo-sources sys-kernel/vanilla-sources )" + pkg_setup() { if use module; then linux-mod-r1_pkg_setup @@ -34,12 +40,35 @@ pkg_setup() { } src_prepare() { - default + default - cd src - sed -i "s@^KERNELRELEASE ?= .*@KERNELRELEASE ?= ${KV_FULL}@" Makefile || die "Fail to set desired kernel verion in the Makefile" - ln -s "${KV_DIR}" kernel || die "Creation link to kernel sources directory fail" - emake apply-patches || die "Fail to apply amnezia patches over wireguard" + if kernel_is -ge 5 6 0; then + # We need to select a directory with kernel sources. + # Usually, /usr/src/linux is the right choise, so we check it first. + # If /usr/src/linux contains no sources (distribution kernel), we check + # other subdirectories in /usr/src sorted by version in reverse order. + echo "Searching for kernel sources..." + dirs=$(find /usr/src -maxdepth 1 -name 'linux-*' -type d | sort --reverse --version-sort --field-separator=- --key=2,2) + dirs="/usr/src/linux ${dirs}" + for kernel_dir in ${dirs}; do + [ -d "$kernel_dir" ] || continue + if [[ -f ${kernel_dir}/drivers/net/wireguard/main.c ]]; then + echo "- ${kernel_dir} -> found" + KERNEL_SOURCES_DIR=${KERNEL_SOURCES_DIR:-${kernel_dir}} + else + echo "- ${kernel_dir} -> not found" + fi + done + + if [[ -d ${KERNEL_SOURCES_DIR} ]]; then + einfo "Using kernel sources in ${KERNEL_SOURCES_DIR}" + else + die "Kernel sources not found, but required for building." + fi + + ln -s ${KERNEL_SOURCES_DIR} src/kernel + emake -C ${S}/src apply-patches + fi } src_compile() {