projects
/
openwrt
/
openwrt.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b626262
)
base-files: introduce a function to get kernel version number
author
Shiji Yang
<
[email protected]
>
Tue, 17 Jun 2025 14:06:38 +0000
(22:06 +0800)
committer
Hauke Mehrtens
<
[email protected]
>
Mon, 14 Jul 2025 20:30:20 +0000
(22:30 +0200)
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 <
[email protected]
>
Link:
https://github.com/openwrt/openwrt/pull/19172
Signed-off-by: Hauke Mehrtens <
[email protected]
>
package/base-files/files/lib/functions/system.sh
patch
|
blob
|
history
diff --git
a/package/base-files/files/lib/functions/system.sh
b/package/base-files/files/lib/functions/system.sh
index f43281b5dceb071b8e586b8d1931a2836162378a..eaed0fba110448ded33a98606942d66d79075158 100644
(file)
--- 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
+}