summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2022-10-15 11:58:04 +0200
committerMichał Górny <mgorny@gentoo.org>2022-10-19 13:51:51 +0200
commit31885dcc9d0a8743903846c61d4aeb575693ca0d (patch)
tree99602d2538481d6cb4ffe822666d89e490721c31 /eclass/dist-kernel-utils.eclass
parentdev-python/traitlets: Fix doc-deps (diff)
downloadgentoo-31885dcc9d0a8743903846c61d4aeb575693ca0d.tar.gz
gentoo-31885dcc9d0a8743903846c61d4aeb575693ca0d.tar.bz2
gentoo-31885dcc9d0a8743903846c61d4aeb575693ca0d.zip
dist-kernel-utils.eclass: Add a PV → KV conversion function
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/dist-kernel-utils.eclass')
-rw-r--r--eclass/dist-kernel-utils.eclass16
1 files changed, 16 insertions, 0 deletions
diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass
index 8c1b56f41506..439bdc87695d 100644
--- a/eclass/dist-kernel-utils.eclass
+++ b/eclass/dist-kernel-utils.eclass
@@ -155,5 +155,21 @@ dist-kernel_reinstall_initramfs() {
"${kernel_dir}/System.map"
}
+# @FUNCTION: dist-kernel_PV_to_KV
+# @USAGE: <pv>
+# @DESCRIPTION:
+# Convert a Gentoo-style ebuild version to kernel "x.y.z[-rcN]" version.
+dist-kernel_PV_to_KV() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ [[ ${#} -ne 1 ]] && die "${FUNCNAME}: invalid arguments"
+ local pv=${1}
+
+ local kv=${pv%%_*}
+ [[ -z $(ver_cut 3- "${kv}") ]] && kv+=".0"
+ [[ ${pv} == *_* ]] && kv+=-${pv#*_}
+ echo "${kv}"
+}
+
_DIST_KERNEL_UTILS=1
fi