Skip to contentSkip to conversation

linux: support each linux latest lts version

PATCH In review James Knight 2 participants 3 messages Nov 8, 2024 – Aug 29, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 linux: support each linux latest lts version

Provides support for a board configuration to use the latest version of the Linux kernel for a specific LTS. While the existing BR2_LINUX_KERNEL_LATEST_VERSION allows desired configurations to roll with a latest stable release, in some scenarios, a user may want the same ability but for a specific Linux LTS. For example, if a user is using an external toolchain that is also tied to a specific Linux LTS.

Having these new options avoids the need for rolling configuration to rely on BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE with the BR2_DOWNLOAD_FORCE_CHECK_HASHES option disabled.

---
Changes v1 -> v2:
- Updated versions to use latest versions tracked in linux.hash.

See also: https://lore.kernel.org/buildroot/CALAjcgXZKYjpsFV1E7Ry-0N5NEGV01hebSb8tEgoAtHvkfvCOA@mail.gmail.com/

---
 linux/Config.ext.in                  |  4 +--
 linux/Config.in                      | 45 ++++++++++++++++++++++++++++
 linux/linux.mk                       |  2 +-
 package/linux-headers/Config.in.host |  4 +--
 4 files changed, 48 insertions(+), 7 deletions(-)
linux/Config.ext.in +1 -3
index 3cbf42d3447615105a67ca369fd728784c58ca8b..fe4abd779cfbb969dd1a865821b78fd62c7ca425 100644
@@ -48,9 +48,7 @@ comment "xenomai needs a uClibc or glibc toolchain w/ threads"
 # RTAI
 config BR2_LINUX_KERNEL_EXT_RTAI
 	bool "RTAI Real-time patch"
-	depends on !BR2_LINUX_KERNEL_LATEST_VERSION
-	depends on !BR2_LINUX_KERNEL_LATEST_CIP_VERSION
-	depends on !BR2_LINUX_KERNEL_LATEST_CIP_RT_VERSION
+	depends on !BR2_LINUX_KERNEL_LATEST_SERIES
 	select BR2_PACKAGE_RTAI
 	help
 	  RTAI Kernel part.
linux/Config.in +45 -0

73 lines not on this page · raw message

linux/linux.mk +1 -1
index 1d3d8fffa6085c58d024a8519377365d19766521..477d1e16143bea2f106e7f3f9212d0efefc98db1 100644
@@ -49,7 +49,7 @@ LINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v$(firstword $(subst ., ,$(LINUX_
 endif
 endif
 
-ifeq ($(BR2_LINUX_KERNEL)$(BR2_LINUX_KERNEL_LATEST_VERSION),y)
+ifeq ($(BR2_LINUX_KERNEL)$(BR2_LINUX_KERNEL_LATEST_SERIES),y)
 BR_NO_CHECK_HASH_FOR += $(LINUX_SOURCE)
 endif
 
package/linux-headers/Config.in.host +1 -3
index 2f7a731d369ad7ac8f2a353fefa1a94c3740e8b1..d47f9fde29e327a05287aa874a46337963f620aa 100644
@@ -114,9 +114,7 @@ endif
 choice
 	bool "Custom kernel headers series"
 	default BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_REALLY_OLD
-	depends on !BR2_LINUX_KERNEL_LATEST_VERSION || !BR2_KERNEL_HEADERS_AS_KERNEL
-	depends on !BR2_LINUX_KERNEL_LATEST_CIP_VERSION || !BR2_KERNEL_HEADERS_AS_KERNEL
-	depends on !BR2_LINUX_KERNEL_LATEST_CIP_RT_VERSION || !BR2_KERNEL_HEADERS_AS_KERNEL
+	depends on !BR2_LINUX_KERNEL_LATEST_SERIES || !BR2_KERNEL_HEADERS_AS_KERNEL
 	depends on BR2_KERNEL_HEADERS_VERSION || BR2_KERNEL_HEADERS_AS_KERNEL || \
 		   BR2_KERNEL_HEADERS_CUSTOM_TARBALL || BR2_KERNEL_HEADERS_CUSTOM_GIT
 	help
Signature · 6 lines
2.46.2.windows.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH v2 2/2 support: add a kernel version configuration helper script

Provides a helper script which can be used to quickly synchronize the kernel versions defined in the Linux's Config.in file based on the contents populated inside linux.hash.

The goal of this script is to help the maintenance effort required when possibly supporting all active Linux LTS versions in the tree at a given time.

---
Changes v1 -> v2:
- Introduced in the v2 of this series.

This is optional. No worries if not desired.

---
 support/scripts/sync-kernel-versions.py | 142 ++++++++++++++++++++++++
 1 file changed, 142 insertions(+)
 create mode 100755 support/scripts/sync-kernel-versions.py
support/scripts/sync-kernel-versions.py new file +142 -0
new file mode 100755
index 0000000000000000000000000000000000000000..2684b052657b0b98ac0265cd1b74a514d03ba9ca
@@ -0,0 +1,142 @@
+#!/usr/bin/env python3
+#
+# Provides a script to allow the automatic updating of a Linux
+# package's `Config.in` file based on the version information detailed
+# in a `linux.hash` file.
+
+from pathlib import Path
+import argparse
+import re
+
+
+# searching for a version pattern inside a `linux.hash` file
+LINUX_VERSION_PATTERN = r'.*-([1-9]+.*)\.t.*'
+
+
+def main():
+    # argument parsing
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--dry-run', action='store_true',
+                        help='Do not change any files')
+    parser.add_argument('--verbose', action='store_true',
+                        help='Output additional information')
+    args = parser.parse_args()
+
+    # helpers
+    def verbose(msg):
+        if args.verbose:
+            print(f'(verbose) {msg}')
+
+    # find the linux package folder
+    br_dir = Path(__file__).parent.parent.parent
+
+    linux_pkg_dir = br_dir / 'linux'
+    if not linux_pkg_dir.is_dir():
+        print('unable to find the linux package folder')
+        return 1
+
+    linux_conf = linux_pkg_dir / 'Config.in'
+    if not linux_conf.is_file():
+        print('unable to find the linux configuration file')
+        return 1
+
+    linux_hash = linux_pkg_dir / 'linux.hash'
+    if not linux_hash.is_file():
+        print('unable to find the linux hash file')
+        return 1
+
+    # extract expected linux entries from the hash file
+    try:
+        with linux_hash.open(encoding='utf-8') as f:
+            raw_hash_output = f.readlines()
+    except OSError as e:
+        print(f'error reading file {linux_hash}: {e}')
+        return 1
+
+    entries = {}
+    for hash_entry in raw_hash_output:
+        if hash_entry.startswith('sha'):
+            _, _, fname = hash_entry.strip().split(maxsplit=2)
+            if fname.startswith('linux-'):
+                verbose(f'detected linux entry: {fname}')
+
+                match = re.search(LINUX_VERSION_PATTERN, fname)
+                if match:
+                    vnum = match.group(1)
+                    ventry = extract_ventry(vnum)
+                    entries[ventry] = vnum
+                    verbose(f'detected linux version ({fname}): {vnum}')
+                else:
+                    verbose(f'unable to detect linux version: {fname}')
+
+    # read the existing Linux configuration file
+    conf_contents = []
+    has_updated = False
+    process_cfg = None
+    try:
+        with linux_conf.open(encoding='utf-8') as f:
+            lines = f.read().splitlines()
+            for line in lines:
+                # wait until we are processing the kernel version section
+                if process_cfg is None:
+                    if 'config BR2_LINUX_KERNEL_VERSION' in line:
+                        process_cfg = True
+
+                # if we are processing, check each version entry for any
+                # updates that are required
+                elif process_cfg:
+                    # stop if the section is done
+                    if not line:
+                        process_cfg = False
+                    # check if this is a linux configuration entry that
+                    # might need to be updated
+                    elif 'default "' in line:
+                        front, raw_version, tail = line.split(maxsplit=2)
+                        vnum = raw_version.replace('"', '')
+                        if '.' in vnum:
+                            ventry = extract_ventry(vnum)
+                            if ventry in entries:
+                                new_vnum = entries[ventry]
+                                # if the version is outdated, replace the line
+                                if vnum != new_vnum:
+                                    print(f'Sync: {vnum} -> {new_vnum}')
+                                    line = f'\t{front} "{new_vnum}" {tail}'
+                                    has_updated = True
+
+                conf_contents.append(line)
+
+    except OSError as e:
+        print(f'error reading file {linux_conf}: {e}')
+        return 1
+
+    # update the linux configuration file if we have new changes
+    if has_updated and not args.dry_run:
+        print(f'Updating: {linux_conf}')
+        try:
+            with linux_conf.open('w', encoding='utf-8', newline='') as f:
+                for line in conf_contents:
+                    f.write(f'{line}\n')
+
+        except OSError as e:
+            print(f'error writing file {linux_conf}: {e}')
+            return 1
+
+    if not has_updated:
+        print('No outdated versions.')
+
+    return 0
+
+
+def extract_ventry(vnum):
+    vmaj, vmin, _ = vnum.split('.', maxsplit=2)
+
+    ventry = f'{vmaj}.{vmin}'
+    if '-' in vnum:
+        _, postfix = vnum.split('-', maxsplit=1)
+        ventry += f'-{postfix}'
+
+    return ventry
+
+
+if __name__ == "__main__":
+    raise SystemExit(main())
Signature · 6 lines
2.46.2.windows.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [PATCH v2 2/2] support: add a kernel version configuration helper script

Quoted 9 lines · James Knight

Provides a helper script which can be used to quickly synchronize the kernel versions defined in the Linux's Config.in file based on the contents populated inside linux.hash.

The goal of this script is to help the maintenance effort required when possibly supporting all active Linux LTS versions in the tree at a given time.

I just merged a script that does it much better, because it downloads the sha
file from kernel.org and updates the hash file from that. See utils/bump-stable-kernel-versions

Regards,
Arnout

Quoted 148 lines

---
Changes v1 -> v2:
- Introduced in the v2 of this series.

This is optional. No worries if not desired.

---
  support/scripts/sync-kernel-versions.py | 142 ++++++++++++++++++++++++
  1 file changed, 142 insertions(+)

create mode 100755 support/scripts/sync-kernel-versions.py

support/scripts/sync-kernel-versions.py new file +132 -0
new file mode 100755
index 0000000000000000000000000000000000000000..2684b052657b0b98ac0265cd1b74a514d03ba9ca
@@ -0,0 +1,142 @@
+#!/usr/bin/env python3
+#
+# Provides a script to allow the automatic updating of a Linux
+# package's `Config.in` file based on the version information detailed
+# in a `linux.hash` file.
+
+from pathlib import Path
+import argparse
+import re
+
+
+# searching for a version pattern inside a `linux.hash` file
+LINUX_VERSION_PATTERN = r'.*-([1-9]+.*)\.t.*'
+
+
+def main():
+    # argument parsing
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--dry-run', action='store_true',
+                        help='Do not change any files')
+    parser.add_argument('--verbose', action='store_true',
+                        help='Output additional information')
+    args = parser.parse_args()
+
+    # helpers
+    def verbose(msg):
+        if args.verbose:
+            print(f'(verbose) {msg}')
+
+    # find the linux package folder
+    br_dir = Path(__file__).parent.parent.parent
+
+    linux_pkg_dir = br_dir / 'linux'
+    if not linux_pkg_dir.is_dir():
+        print('unable to find the linux package folder')
+        return 1
+
+    linux_conf = linux_pkg_dir / 'Config.in'
+    if not linux_conf.is_file():
+        print('unable to find the linux configuration file')
+        return 1
+
+    linux_hash = linux_pkg_dir / 'linux.hash'
+    if not linux_hash.is_file():
+        print('unable to find the linux hash file')
+        return 1
+
+    # extract expected linux entries from the hash file
+    try:
+        with linux_hash.open(encoding='utf-8') as f:
+            raw_hash_output = f.readlines()
+    except OSError as e:
+        print(f'error reading file {linux_hash}: {e}')
+        return 1
+
+    entries = {}
+    for hash_entry in raw_hash_output:
+        if hash_entry.startswith('sha'):
+            _, _, fname = hash_entry.strip().split(maxsplit=2)
+            if fname.startswith('linux-'):
+                verbose(f'detected linux entry: {fname}')
+
+                match = re.search(LINUX_VERSION_PATTERN, fname)
+                if match:
+                    vnum = match.group(1)
+                    ventry = extract_ventry(vnum)
+                    entries[ventry] = vnum
+                    verbose(f'detected linux version ({fname}): {vnum}')
+                else:
+                    verbose(f'unable to detect linux version: {fname}')
+
+    # read the existing Linux configuration file
+    conf_contents = []
+    has_updated = False
+    process_cfg = None
+    try:
+        with linux_conf.open(encoding='utf-8') as f:
+            lines = f.read().splitlines()
+            for line in lines:
+                # wait until we are processing the kernel version section
+                if process_cfg is None:
+                    if 'config BR2_LINUX_KERNEL_VERSION' in line:
+                        process_cfg = True
+
+                # if we are processing, check each version entry for any
+                # updates that are required
+                elif process_cfg:
+                    # stop if the section is done
+                    if not line:
+                        process_cfg = False
+                    # check if this is a linux configuration entry that
+                    # might need to be updated
+                    elif 'default "' in line:
+                        front, raw_version, tail = line.split(maxsplit=2)
+                        vnum = raw_version.replace('"', '')
+                        if '.' in vnum:
+                            ventry = extract_ventry(vnum)
+                            if ventry in entries:
+                                new_vnum = entries[ventry]
+                                # if the version is outdated, replace the line
+                                if vnum != new_vnum:
+                                    print(f'Sync: {vnum} -> {new_vnum}')
+                                    line = f'\t{front} "{new_vnum}" {tail}'
+                                    has_updated = True
+
+                conf_contents.append(line)
+
+    except OSError as e:
+        print(f'error reading file {linux_conf}: {e}')
+        return 1
+
+    # update the linux configuration file if we have new changes
+    if has_updated and not args.dry_run:
+        print(f'Updating: {linux_conf}')
+        try:
+            with linux_conf.open('w', encoding='utf-8', newline='') as f:
+                for line in conf_contents:
+                    f.write(f'{line}\n')
+
+        except OSError as e:
+            print(f'error writing file {linux_conf}: {e}')
+            return 1
+
+    if not has_updated:
+        print('No outdated versions.')
+
+    return 0
+
+
+def extract_ventry(vnum):
+    vmaj, vmin, _ = vnum.split('.', maxsplit=2)
+

support/scripts/sync-kernel-versions.py line 142

Quoted 10 lines
support/scripts/sync-kernel-versions.py new file +10 -0
+    ventry = f'{vmaj}.{vmin}'
+    if '-' in vnum:
+        _, postfix = vnum.split('-', maxsplit=1)
+        ventry += f'-{postfix}'
+
+    return ventry
+
+
+if __name__ == "__main__":
+    raise SystemExit(main())

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot