Skip to content

Instantly share code, notes, and snippets.

@cl0ne
Created December 6, 2019 22:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cl0ne/9a3f2b5a4208df3b2e96ed4e9b879292 to your computer and use it in GitHub Desktop.
Save cl0ne/9a3f2b5a4208df3b2e96ed4e9b879292 to your computer and use it in GitHub Desktop.
r8168-dkms PKGBUILD
PACKAGE_NAME="@PKGNAME@"
PACKAGE_VERSION="@PKGVER@"
MAKE[0]="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build/src EXTRA_CFLAGS='-DCONFIG_R8168_NAPI -DCONFIG_R8168_VLAN' modules"
CLEAN="rm src/@PKGNAME@.ko src/*.o || true"
BUILT_MODULE_NAME[0]="@PKGNAME@"
BUILT_MODULE_LOCATION[0]="src/"
DEST_MODULE_LOCATION[0]="/kernel/drivers/net/ethernet/realtek"
AUTOINSTALL="yes"
diff -u -r r8168-8.047.05/src/r8168_n.c r8168-8.047.05-5.4/src/r8168_n.c
--- r8168-8.047.05/src/r8168_n.c 2019-11-25 18:01:38.000000000 +0000
+++ r8168-8.047.05-5.4/src/r8168_n.c 2019-11-25 23:36:15.427988367 +0000
@@ -56,7 +56,7 @@
#include <linux/rtnetlink.h>
#include <linux/completion.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) && LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0)
#include <linux/pci-aspm.h>
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,37)
_pkgbase=r8168
pkgname=${_pkgbase}-dkms
pkgver=8.047.05
pkgrel=2
pkgdesc="A kernel module for Realtek 8168 network cards"
url="http://www.realtek.com.tw"
license=("GPL")
arch=('i686' 'x86_64')
depends=('glibc' 'dkms')
conflicts=("${_pkgbase}")
optdepends=('linux-headers: Needed for build the module for Arch kernel'
'linux-lts-headers: Needed for build the module for LTS Arch kernel'
'linux-zen-headers: Needed for build the module for ZEN Arch kernel')
source=(https://github.com/mtorromeo/r8168/archive/$pkgver/$pkgname-$pkgver.tar.gz
dkms.conf
kernel-5.4.patch)
install=r8168-dkms.install
prepare() {
cd "r8168-$pkgver"
patch -Np1 -i "${srcdir}/kernel-5.4.patch"
}
package() {
install -Dm644 dkms.conf "${pkgdir}/usr/src/${_pkgbase}-${pkgver}/dkms.conf"
sed -e "s/@PKGNAME@/${_pkgbase}/g" \
-e "s/@PKGVER@/${_pkgbase}/g" \
-i "${pkgdir}/usr/src/${_pkgbase}-${pkgver}/dkms.conf"
cd "${_pkgbase}-$pkgver"
rm src/Makefile_linux24x
cp -dr --no-preserve='ownership' src "${pkgdir}/usr/src/${_pkgbase}-${pkgver}/src"
}
sha256sums=('1344bf3d8a1d01a1be8805b48940be1b946b5e694ca75bd14ed1c76fd4c3d67b'
'e33abcbc8fbe3129459ebc60be3b2f8ed55ddc53755f4956d6feb16c61c43250'
'be79c151c6323bb4d340e31e44fae25a36a93d317812fe5d75c54649ed2508b0')
post_install() {
dkms add r8168/${1%-*}
cat << EOF
==> To build and install your modules run: dkms install r8168/${1%-*}
==> To do this automatically at startup run: systemctl enable dkms.service
==> The module r8168 conflicts with r8169. You can blacklist it with:
==> echo "blacklist r8169" > /etc/modprobe.d/r8169_blacklist.conf
EOF
}
pre_upgrade() {
pre_remove "$2"
}
post_upgrade() {
post_install "$1"
}
pre_remove() {
[ -n "${1%-*}" ] && dkms remove r8168/${1%-*} --all &>/dev/null || true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment