summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsdc <taras@vyos.io>2023-08-30 16:11:21 +0300
committerzsdc <taras@vyos.io>2023-08-30 16:15:31 +0300
commit0073533968582c3e3f83d80e09ced38e254e1c29 (patch)
tree40b37043767e4548074e62b5b24ec340ac3b0647
parent53131ce567e4ab42ef703290c84b0e81f54b00ef (diff)
downloadvyos-build-0073533968582c3e3f83d80e09ced38e254e1c29.tar.gz
vyos-build-0073533968582c3e3f83d80e09ced38e254e1c29.zip
build: T5187: Fixed Realtek r8152 compatibility with 5.4 kernels
There is no need to define `eth_hw_addr_set()` in sources anymore because it is already backported into the 5.4.254 kernel: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/include/linux/etherdevice.h?h=v5.4.254&id=24f34f67be24674c5c3ef922de70ab95a0d7ce16
-rwxr-xr-xpackages/linux-kernel/build-driver-realtek-r8152.py31
-rw-r--r--packages/linux-kernel/patches/vyos-drivers-realtek-r8152/0001-Fixed-compatibility-with-kernel-5.4.254.patch27
2 files changed, 56 insertions, 2 deletions
diff --git a/packages/linux-kernel/build-driver-realtek-r8152.py b/packages/linux-kernel/build-driver-realtek-r8152.py
index 5d65fd29..3200bd9e 100755
--- a/packages/linux-kernel/build-driver-realtek-r8152.py
+++ b/packages/linux-kernel/build-driver-realtek-r8152.py
@@ -3,6 +3,7 @@
from json import loads as json_loads
from requests import get
from pathlib import Path
+from shutil import copy as copy_file
from subprocess import run
@@ -22,6 +23,29 @@ def add_depends(package_dir: str, package_name: str, depends) -> None:
substvars_file.write_text(depends_line)
+# copy patches
+def apply_deb_patches(package_name: str, sources_dir: str):
+ """Apply patches to sources directory
+
+ Args:
+ package_name (str): package name
+ sources_dir (str): sources dir
+ """
+ patches_dir = Path(f'patches/{package_name}')
+ if patches_dir.exists():
+ patches_list = list(patches_dir.iterdir())
+ patches_list.sort()
+ series_file = Path(f'{sources_dir}/debian/patches/series')
+ series_data = ''
+ for patch_file in patches_list:
+ print(f'Applying patch: {patch_file.name}')
+ copy_file(patch_file, f'{sources_dir}/debian/patches/')
+ if series_file.exists():
+ series_data = series_file.read_text()
+ series_data = f'{series_data}\n{patch_file.name}'
+ series_file.write_text(series_data)
+
+
# find kernel version and source path
defaults_file: str = Path('../../data/defaults.json').read_text()
KERNEL_VER: str = json_loads(defaults_file).get('kernel_version')
@@ -30,9 +54,9 @@ KERNEL_SRC: str = Path.cwd().as_posix() + '/linux'
# define variables
PACKAGE_NAME: str = 'vyos-drivers-realtek-r8152'
-PACKAGE_VERSION: str = '2.16.3'
+PACKAGE_VERSION: str = '2.17.1'
PACKAGE_DIR: str = f'{PACKAGE_NAME}-{PACKAGE_VERSION}'
-SOURCES_ARCHIVE: str = 'r8152-2.16.3.tar.bz2'
+SOURCES_ARCHIVE: str = 'r8152-2.17.1.tar.bz2'
SOURCES_URL: str = f'https://dev.packages.vyos.net/source-mirror/{SOURCES_ARCHIVE}'
# download sources
@@ -81,6 +105,9 @@ override_dh_auto_install:
bild_rules = Path(f'{PACKAGE_DIR}/debian/rules')
bild_rules.write_text(build_rules_text)
+# apply patches
+apply_deb_patches(PACKAGE_NAME, PACKAGE_DIR)
+
# build a package
debuild_cmd = ['debuild']
run(debuild_cmd, cwd=PACKAGE_DIR)
diff --git a/packages/linux-kernel/patches/vyos-drivers-realtek-r8152/0001-Fixed-compatibility-with-kernel-5.4.254.patch b/packages/linux-kernel/patches/vyos-drivers-realtek-r8152/0001-Fixed-compatibility-with-kernel-5.4.254.patch
new file mode 100644
index 00000000..d4e9321b
--- /dev/null
+++ b/packages/linux-kernel/patches/vyos-drivers-realtek-r8152/0001-Fixed-compatibility-with-kernel-5.4.254.patch
@@ -0,0 +1,27 @@
+From 65e00ae524f82cffb57abf3fa3f8dbac8a2bda7a Mon Sep 17 00:00:00 2001
+From: Taras Pudiak <taras@vyos.io>
+Date: Wed, 30 Aug 2023 14:59:38 +0300
+Subject: [PATCH] Fixed compatibility with kernel 5.4.254
+
+---
+ compatibility.h | 4 ----
+ 1 file changed, 4 deletions(-)
+
+diff --git a/compatibility.h b/compatibility.h
+index d1e044d..9eee6a9 100644
+--- a/compatibility.h
++++ b/compatibility.h
+@@ -612,10 +612,6 @@
+ #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0) */
+ #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,9,0) */
+ #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,12,0) */
+- static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
+- {
+- memcpy(dev->dev_addr, addr, 6);
+- }
+ #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,15,0) */
+ #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,19,0) */
+
+--
+2.34.1
+