diff --git a/README.md b/README.md new file mode 100644 index 0000000..d8cf084 --- /dev/null +++ b/README.md @@ -0,0 +1,134 @@ +# Realtek r8125 DKMS + +![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/awesometic/realtek-r8125-dkms?sort=semver&style=for-the-badge) + +This provides Realtek r8125 driver in DKMS way so that you can keep the latest driver even after the kernel upgrade. + +## Before use + +This DKMS package is for Realtek RTL8125 (r8125 in module name) Ethernet, which is designed for the PCI interface. + +If you are searching for the Realtek 2.5 Gbits **USB Ethernet**, which may use RTL8156 (r8152 in module name), you are in the wrong place. Please refer to another DKMS project for that Realtek driver. + +- [Realtek R8152 DKMS](https://github.com/awesometic/realtek-r8152-dkms) + +## Installation + +There are 3 ways to install this DKMS module. Choose one as your tastes. + +Those are not interfering with each other. So you can do all 3 methods but absolutely you don't need to. + +Installation using the Debian package is recommended for the sake of getting the newer driver. + +### Debian package + +#### Released package file + +Download the latest Debian package from the Release tab on the Github repository. + +Then enter the following command. + +```bash +sudo dpkg -i realtek-r8125-dkms*.deb +``` + +> If multiple files selected by the wild card, you should type the specific version of the file. +> +> ```bash +> sudo dpkg -i realtek-r8125-dkms_9.016.01-1_amd64.deb +> ``` + +If dependency error occurs, try to fix that with `apt` command. + +```bash +sudo apt install --fix-broken +``` + +#### Launchpad PPA (Recommended) + +Add the Launchpad PPA. + +```bash +sudo add-apt-repository ppa:awesometic/ppa +``` + +Then install the package using `apt` tool. + +```bash +sudo apt install realtek-r8125-dkms +``` + +### autorun.sh + +Using the `autorun.sh` script that Realtek provides on their original driver package. This is **not installed as a DKMS**, only efforts to the current kernel. + +Download or clone this repository and move to the extracted directory, then run the script. + +```bash +sudo ./autorun.sh +``` + +### dkms-install.sh + +This script is from aircrack-ng team. You can install the DKMS module by a simple command. + +Download or clone this repository and move to the extracted directory, then run the script. + +```bash +sudo ./dkms-install.sh +``` + +## Verify the module is loaded successfully + +After installing the DKMS package, you may not be able to use the new `r8125` module on the fly. This because the existing `r8169` module will be loaded priority to `r8125` so that it prevents working of the `r8125` module. + +Check if the `r8169` module loaded currently. + +```bash +lsmod | grep -i r8169 +``` + +If there is a result, maybe the `r8125` module wasn't loaded properly. You can check out modules currently in use via `lspci -k` or `dmesg` too. + +To use the `r8125` module explicitly you can add the `r8169` module to not be loaded by adding it to a blacklist file. + +Enter the following command to configure the blacklist. + +```bash +sudo tee -a /etc/modprobe.d/blacklist-r8169.conf > /dev/null < - If you need to load both r8169 and r8125, maybe removing r8125 firmware could make it work. Please enter `sudo rm -f /lib/firmware/rtl_nic/rtl8125*` to remove all the r8125 firmwares on the system. But it is just a workaround, you should have to do this every time installing the new kernel version or new Linux firmware. +> - In the case of the Debian package, I will update the scripts to make it do this during the installation. + +## Debian package build + +You can build yourself this after installing some dependencies including `dkms`. + +```bash +sudo apt install devscripts debmake debhelper build-essential dkms dh-dkms +``` + +```bash +dpkg-buildpackage -b -rfakeroot -us -uc +``` + +## LICENSE + +GPL-2 on Realtek driver and the debian packaing. + +## References + +- [Realtek r8125 driver release page](https://www.realtek.com/Download/List?cate_id=584) +- [ParrotSec's realtek-rtl88xxau-dkms, where got hint from](https://github.com/ParrotSec/realtek-rtl88xxau-dkms) diff --git a/README b/REALTEK_README.txt similarity index 100% rename from README rename to REALTEK_README.txt diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..b618b34 --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,5 @@ +realtek-r8125-dkms for Debian + +This installs a DKMS for Realtek r8125 drivers. + + -- Deokgyu Yang Fri, 12 Jun 2020 12:27:29 +0900 diff --git a/debian/README.source b/debian/README.source new file mode 100644 index 0000000..16af43f --- /dev/null +++ b/debian/README.source @@ -0,0 +1,6 @@ +realtek-r8125-dkms for Debian + +The driver source can be found here: + https://www.realtek.com/en/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software + + -- Deokgyu Yang Fri, 12 Jun 2020 12:27:29 +0900 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..a963bab --- /dev/null +++ b/debian/changelog @@ -0,0 +1,7 @@ +realtek-r8168-dkms (8.055.00) UNRELEASED; urgency=low + + * Initial release + * This package will be installed but DKMS won't work + Do not install this version, otherwise your system will be corrupted + + -- Mario Fetka Fri, 12 Jun 2020 12:27:29 +0900 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..b4de394 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +11 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..640a4cb --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: realtek-r8168-dkms +Section: contrib/kernel +Priority: optional +Maintainer: Mario Fetka +Build-Depends: debhelper (>=11~), dkms (<< 3.0.3-3~) | dh-sequence-dkms +Standards-Version: 4.6.2.1 +Homepage: https://github.com/awesometic/realtek-r8125-dkms + +Package: realtek-r8168-dkms +Architecture: any +Multi-Arch: foreign +Depends: dkms (>= 1.95), ${misc:Depends} +Description: Realtek RTL8168 driver in DKMS format + This package provides the source code for RTL8168 Linux driver that may + include supporting other Realtek GbE chipsets to be build with dkms. + Kernel sources or headers are required to compile this module. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..1aceec8 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,50 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: realtek-r8168-dkms +Source: https://gitea.disconnected-by-peer.at/deb/realtek-r8168-dkms + +Files: * +Copyright: 2019-2022 Realtek Semiconductor Corp. +License: GPL-2 + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + . + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + . + You should have received a copy of the GNU General Public License along with + this program; if not, see . + . + Author: + Realtek NIC software team + No. 2, Innovation Road II, Hsinchu Science Park, Hsinchu 300, Taiwan + . + This product is covered by one or more of the following patents: + US6,570,884, US6,115,776, and US6,327,625. + . + On Debian systems, the complete text of the GNU General Public License + Version 2 can be found in `/usr/share/common-licenses/GPL-2'. + +Files: debian/* +Copyright: 2020-2022 Deokgyu Yang +License: GPL-2 + +License: GPL-2 + This program is free software; you can redistribute it and/or modify it + under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + . + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + . + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., 51 + Franklin Street, Fifth Floor, Boston, MA 02110, USA + . + On Debian systems, the complete text of the GNU General Public License + version 2 can be found in "/usr/share/common-licenses/GPL-2" diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..0cd1d4c --- /dev/null +++ b/debian/dirs @@ -0,0 +1 @@ +usr/src \ No newline at end of file diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..41ab5b0 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +README.md REALTEK_README.txt LICENSE \ No newline at end of file diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..d693a68 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,49 @@ +#!/bin/sh +# Copyright (C) 2002-2005 Flavio Stanchina +# Copyright (C) 2005-2006 Aric Cyr +# Copyright (C) 2007 Mario Limonciello +# Copyright (C) 2009 Alberto Milone + +set -e + +NAME=realtek-r8168 +PACKAGE_NAME=$NAME-dkms +DEB_NAME=$(echo $PACKAGE_NAME | sed 's,_,-,') +CVERSION=`dpkg-query -W -f='${Version}' $DEB_NAME | awk -F "-" '{print $1}' | cut -d\: -f2` +ARCH=`dpkg --print-architecture` + +dkms_configure () { + for POSTINST in /usr/lib/dkms/common.postinst "/usr/share/$PACKAGE_NAME/postinst"; do + if [ -f "$POSTINST" ]; then + "$POSTINST" "$NAME" "$CVERSION" "/usr/share/$PACKAGE_NAME" "$ARCH" "$2" + return $? + fi + echo "WARNING: $POSTINST does not exist." >&2 + done + echo "ERROR: DKMS version is too old and $PACKAGE_NAME was not" >&2 + echo "built with legacy DKMS support." >&2 + echo "You must either rebuild $PACKAGE_NAME with legacy postinst" >&2 + echo "support or upgrade DKMS to a more current version." >&2 + return 1 +} + +case "$1" in + configure) + dkms_configure + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 0000000..be7ec0d --- /dev/null +++ b/debian/prerm @@ -0,0 +1,26 @@ +#!/bin/sh + +NAME=realtek-r8168 +VERSION=8.055.00 + +set -e + +case "$1" in + remove|upgrade|deconfigure) + if [ "`dkms status -m $NAME`" ]; then + dkms remove -m $NAME -v $VERSION --all + fi + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + + + +exit 0 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..2ff08de --- /dev/null +++ b/debian/rules @@ -0,0 +1,30 @@ +#!/usr/bin/make -f + +#export DH_VERBOSE=1 + +#just use base version +VERSION := $(shell dpkg-parsechangelog -S Version | sed 's/-.*//' | sed 's/+pristine//') + +%: + dh $@ --parallel --with dkms + +override_dh_install: + dh_install dkms.conf REALTEK_README.txt Makefile usr/src/realtek-r8168-$(VERSION) + dh_install src/* usr/src/realtek-r8168-$(VERSION)/src + +override_dh_dkms: + dh_dkms -V $(VERSION) + +override_dh_fixperms: + dh_fixperms + find debian/realtek-r8125-dkms/usr/src -type f -exec chmod -x {} \; + +override_dh_builddeb: + dh_builddeb -- -Zxz + +# Nothing to configure, build or auto-install +override_dh_auto_configure: +override_dh_auto_build: +override_dh_auto_test: +override_dh_auto_install: +override_dh_auto_clean: diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/dkms-install.sh b/dkms-install.sh new file mode 100755 index 0000000..d7b7e29 --- /dev/null +++ b/dkms-install.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +if [[ $EUID -ne 0 ]]; then + echo "You must run this with superuser privileges. Try \"sudo ./dkms-install.sh\"" 2>&1 + exit 1 +else + echo "About to run dkms install steps..." +fi + +DRV_DIR="$(pwd)" +DRV_NAME=r8168 +DRV_VERSION=8.055.00 +KERNEL_VERSION="${KERNEL_VERSION:-$(uname -r)}" + +cp -r ${DRV_DIR} /usr/src/${DRV_NAME}-${DRV_VERSION} + +dkms add -m ${DRV_NAME} -v ${DRV_VERSION} -k ${KERNEL_VERSION} +dkms build -m ${DRV_NAME} -v ${DRV_VERSION} -k ${KERNEL_VERSION} +dkms install -m ${DRV_NAME} -v ${DRV_VERSION} -k ${KERNEL_VERSION} +RESULT=$? + +echo "Finished running dkms install steps." + +exit $RESULT diff --git a/dkms-remove.sh b/dkms-remove.sh new file mode 100755 index 0000000..4a7b56b --- /dev/null +++ b/dkms-remove.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +if [[ $EUID -ne 0 ]]; then + echo "You must run this with superuser priviliges. Try \"sudo ./dkms-remove.sh\"" 2>&1 + exit 1 +else + echo "About to run dkms removal steps..." +fi + +DRV_DIR="$(pwd)" +DRV_NAME=r8168 +DRV_VERSION=8.055.00 + +dkms remove ${DRV_NAME}/${DRV_VERSION} --all +rm -rf /usr/src/${DRV_NAME}-${DRV_VERSION} + +RESULT=$? +if [[ "$RESULT" != "0" ]]; then + echo "Error occurred while running dkms remove." 2>&1 +else + echo "Finished running dkms removal steps." +fi + +exit $RESULT diff --git a/dkms.conf b/dkms.conf new file mode 100644 index 0000000..43fbe7c --- /dev/null +++ b/dkms.conf @@ -0,0 +1,10 @@ +PACKAGE_NAME="realtek-r8168" +PACKAGE_VERSION="8.055.00" +PROCS_NUM=`nproc` +[ $PROCS_NUM -gt 16 ] && PROCS_NUM=16 +MAKE="'make' -j$PROCS_NUM KVER=${kernelver} BSRC=/lib/modules/${kernelver} modules" +CLEAN="'make' KVER=${kernelver} BSRC=/lib/modules/${kernelver} clean" +BUILT_MODULE_NAME[0]="r8168" +BUILT_MODULE_LOCATION[0]="src" +DEST_MODULE_LOCATION[0]="/updates" +AUTOINSTALL="yes"