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
This commit is contained in:
zsdc 2023-08-30 16:11:21 +03:00
parent 53131ce567
commit 0073533968
2 changed files with 56 additions and 2 deletions

View File

@ -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)

View File

@ -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