summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2023-04-27 16:06:33 +0100
committerGitHub <noreply@github.com>2023-04-27 16:06:33 +0100
commit8e5e747687ec83f1bbf13e39fbc4f4b74ee22b2f (patch)
treefb872fef618291c640fbcd2161f86be9de3ce4d2
parent97ed73bf355451088ba025b6a022e1d86dc11b37 (diff)
parent56c5dfe8c6ce76b0fddd9a55351fec27fd6f78ed (diff)
downloadvyos-build-8e5e747687ec83f1bbf13e39fbc4f4b74ee22b2f.tar.gz
vyos-build-8e5e747687ec83f1bbf13e39fbc4f4b74ee22b2f.zip
Merge pull request #343 from zdc/T5187-equuleus
r8152: T5187: Updated Realtek r8152 driver
-rw-r--r--data/package-lists/vyos-x86.list.chroot1
-rw-r--r--packages/linux-kernel/Jenkinsfile16
-rwxr-xr-xpackages/linux-kernel/build-driver-realtek-r8152.py86
3 files changed, 103 insertions, 0 deletions
diff --git a/data/package-lists/vyos-x86.list.chroot b/data/package-lists/vyos-x86.list.chroot
index 8824e134..bb78f0a3 100644
--- a/data/package-lists/vyos-x86.list.chroot
+++ b/data/package-lists/vyos-x86.list.chroot
@@ -8,3 +8,4 @@ vyos-linux-firmware
vyos-intel-qat
wireguard-modules
vyos-drivers-intel-ice
+vyos-drivers-realtek-r8152
diff --git a/packages/linux-kernel/Jenkinsfile b/packages/linux-kernel/Jenkinsfile
index d7b6d36d..7825ce9d 100644
--- a/packages/linux-kernel/Jenkinsfile
+++ b/packages/linux-kernel/Jenkinsfile
@@ -252,6 +252,22 @@ pipeline {
}
}
}
+ stage('Realtek r8152 driver') {
+ when {
+ beforeOptions true
+ beforeAgent true
+ anyOf {
+ changeset pattern: "**/packages/linux-kernel/*"
+ changeset pattern: "**/data/defaults.json"
+ triggeredBy cause: "UserIdCause"
+ }
+ }
+ steps {
+ dir(env.BASE_DIR) {
+ sh "./build-driver-realtek-r8152.py"
+ }
+ }
+ }
}
}
// This stage should not be run in the parallel section as it will call "make"
diff --git a/packages/linux-kernel/build-driver-realtek-r8152.py b/packages/linux-kernel/build-driver-realtek-r8152.py
new file mode 100755
index 00000000..5d65fd29
--- /dev/null
+++ b/packages/linux-kernel/build-driver-realtek-r8152.py
@@ -0,0 +1,86 @@
+#!/usr/bin/env python3
+
+from json import loads as json_loads
+from requests import get
+from pathlib import Path
+from subprocess import run
+
+
+# dependency modifier
+def add_depends(package_dir: str, package_name: str, depends) -> None:
+ """Add dependencies to a package
+
+ Args:
+ package_dir (str): a directory where package sources are located
+ package_name (str): a name of package
+ depends (list[str]): a list of dependencies to add
+ """
+ depends_list: str = ', '.join(depends)
+ depends_line: str = f'misc:Depends={depends_list}\n'
+
+ substvars_file = Path(f'{package_dir}/debian/{package_name}.substvars')
+ substvars_file.write_text(depends_line)
+
+
+# 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')
+KERNEL_FLAVOR: str = json_loads(defaults_file).get('kernel_flavor')
+KERNEL_SRC: str = Path.cwd().as_posix() + '/linux'
+
+# define variables
+PACKAGE_NAME: str = 'vyos-drivers-realtek-r8152'
+PACKAGE_VERSION: str = '2.16.3'
+PACKAGE_DIR: str = f'{PACKAGE_NAME}-{PACKAGE_VERSION}'
+SOURCES_ARCHIVE: str = 'r8152-2.16.3.tar.bz2'
+SOURCES_URL: str = f'https://dev.packages.vyos.net/source-mirror/{SOURCES_ARCHIVE}'
+
+# download sources
+sources_archive = Path(SOURCES_ARCHIVE)
+sources_archive.write_bytes(get(SOURCES_URL).content)
+
+# prepare sources
+debmake_cmd = [
+ 'debmake', '-e', 'support@vyos.io', '-f', 'VyOS Support', '-p',
+ PACKAGE_NAME, '-u', PACKAGE_VERSION, '-a', SOURCES_ARCHIVE
+]
+run(debmake_cmd)
+
+# add kernel to dependencies
+add_depends(PACKAGE_DIR, PACKAGE_NAME,
+ [f'linux-image-{KERNEL_VER}-{KERNEL_FLAVOR}'])
+
+# configure build rules
+build_rules_text: str = f'''#!/usr/bin/make -f
+# config
+export KERNELDIR := {KERNEL_SRC}
+PACKAGE_BUILD_DIR := debian/{PACKAGE_NAME}
+KVER := {KERNEL_VER}-{KERNEL_FLAVOR}
+MODULES_DIR := updates/drivers/net/usb
+
+# main packaging script based on dh7 syntax
+%:
+ dh $@
+
+override_dh_clean:
+ dh_clean --exclude=debian/{PACKAGE_NAME}.substvars
+
+override_dh_prep:
+ dh_prep --exclude=debian/{PACKAGE_NAME}.substvars
+
+override_dh_auto_clean:
+ make clean
+
+override_dh_auto_build:
+ make modules
+
+override_dh_auto_install:
+ install -D -m 644 r8152.ko ${{PACKAGE_BUILD_DIR}}/lib/modules/${{KVER}}/${{MODULES_DIR}}/r8152.ko
+ install -D -m 644 50-usb-realtek-net.rules ${{PACKAGE_BUILD_DIR}}/etc/udev/rules.d/50-usb-realtek-net.rules
+'''
+bild_rules = Path(f'{PACKAGE_DIR}/debian/rules')
+bild_rules.write_text(build_rules_text)
+
+# build a package
+debuild_cmd = ['debuild']
+run(debuild_cmd, cwd=PACKAGE_DIR)