[openwrt/openwrt] base-files: introduce a function to get kernel version number
LEDE Commits
lede-commits at lists.infradead.org
Mon Jul 14 13:33:21 PDT 2025
hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/a0fe3cfb62fbf0b5f599c90e488727f493223429
commit a0fe3cfb62fbf0b5f599c90e488727f493223429
Author: Shiji Yang <yangshiji66 at outlook.com>
AuthorDate: Tue Jun 17 22:06:38 2025 +0800
base-files: introduce a function to get kernel version number
A new function "get_linux_version()" to normalize and print the
kernel version as an integer. In some migration scripts, it is
useful for checking the Linux kernel version.
Signed-off-by: Shiji Yang <yangshiji66 at outlook.com>
Link: https://github.com/openwrt/openwrt/pull/19172
Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
package/base-files/files/lib/functions/system.sh | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh
index f43281b5dc..eaed0fba11 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -315,3 +315,10 @@ macaddr_canonicalize() {
dt_is_enabled() {
grep -q okay "/proc/device-tree/$1/status"
}
+
+get_linux_version() {
+ local ver=$(uname -r)
+ local minor=${ver%\.*}
+
+ printf "%d%02d%03d" ${ver%%\.*} ${minor#*\.} ${ver##*\.} 2>/dev/null
+}
More information about the lede-commits
mailing list