aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sys-apps/openrc/files/0.3.0/0005-add-back-KV_-funcs.patch')
-rw-r--r--sys-apps/openrc/files/0.3.0/0005-add-back-KV_-funcs.patch120
1 files changed, 120 insertions, 0 deletions
diff --git a/sys-apps/openrc/files/0.3.0/0005-add-back-KV_-funcs.patch b/sys-apps/openrc/files/0.3.0/0005-add-back-KV_-funcs.patch
new file mode 100644
index 0000000..dfde845
--- /dev/null
+++ b/sys-apps/openrc/files/0.3.0/0005-add-back-KV_-funcs.patch
@@ -0,0 +1,120 @@
+From 77a1fb72523df6495ae526fbf4fd834ac15aae74 Mon Sep 17 00:00:00 2001
+From: Mike Frysinger <vapier@gentoo.org>
+Date: Mon, 24 Mar 2008 03:14:02 -0400
+Subject: [PATCH] add back KV_* funcs
+
+---
+ sh/functions.sh.in | 35 +++++++++++++++++++++++++++++++++++
+ sh/runtests.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 80 insertions(+), 0 deletions(-)
+
+diff --git a/sh/functions.sh.in b/sh/functions.sh.in
+index 680f534..f121564 100644
+--- a/sh/functions.sh.in
++++ b/sh/functions.sh.in
+@@ -64,6 +64,41 @@ get_bootparam()
+ return 1
+ }
+
++KV_major() {
++ [ -z "$*" ] && return 1
++ local KV="$*"
++ echo ${KV%%.*}
++}
++
++KV_minor() {
++ [ -z "$*" ] && return 1
++ local KV="$*"
++ KV=${KV#*.}
++ echo ${KV%%.*}
++}
++
++KV_micro() {
++ [ -z "$*" ] && return 1
++ local KV="$*"
++ KV=${KV#*.*.}
++ echo ${KV%%[![:digit:]]*}
++}
++
++KV_to_int() {
++ [ -z "$*" ] && return 1
++ local KV_MAJOR="$(KV_major "$*")"
++ local KV_MINOR="$(KV_minor "$*")"
++ local KV_MICRO="$(KV_micro "$*")"
++ local KV_int="$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO ))"
++ echo "${KV_int}"
++}
++
++_RC_GET_KV_CACHE=""
++get_KV() {
++ [ -z ${_RC_GET_KV_CACHE} ] && _RC_GET_KV_CACHE=$(uname -r)
++ echo $(KV_to_int "${_RC_GET_KV_CACHE}")
++}
++
+ _sanitize_path()
+ {
+ local IFS=":" p= path=
+diff --git a/sh/runtests.sh b/sh/runtests.sh
+index 110266b..9f6726d 100755
+--- a/sh/runtests.sh
++++ b/sh/runtests.sh
+@@ -3,6 +3,19 @@
+ top_srcdir=${top_srcdir:-..}
+ . ${top_srcdir}/test/setup_env.sh
+
++checkit() {
++ local output=$($1 $3)
++ local lret=$?
++ if [ ${lret} -ne 0 ] ; then
++ ((tret+=lret))
++ echo "FAIL: exec: $*"
++ fi
++ if [ "${output}" != "$2" ] ; then
++ ((tret+=lret))
++ echo "FAIL: output: $* : got='${output}' wanted='$2'"
++ fi
++}
++
+ ret=0
+
+ tret=0
+@@ -22,4 +35,36 @@ done
+ eend ${tret}
+ ret=$((${ret} + ${tret}))
+
++compare_int() {
++ local got=$(KV_to_int $1)
++ local exp=$(KV_to_int $3)
++ if ! [ ${got} $2 ${exp} ] ; then
++ ((tret+=1))
++ echo "FAIL: KV_to_int '${v}'(${got}) $2 '1.2.2'(${exp})"
++ fi
++}
++
++tret=0
++ebegin "Testing KV_{major,minor,micro,to_int}"
++for v in \
++ 1.2.3 1.2.3-rc0 1.2.3_rc0 "1.2.3 rc0" \
++ 1.2.3.4 1.2.3.4-rc0 1.2.3.4_rc0 "1.2.3.4 rc0"
++do
++ checkit KV_major 1 ${v}
++ checkit KV_minor 2 ${v}
++ checkit KV_micro 3 ${v}
++
++ compare_int 1.2.2 -lt ${v}
++ compare_int 1.2.2.10 -lt ${v}
++ compare_int 1.2.4 -gt ${v}
++ compare_int 1.2.4-rc0 -gt ${v}
++ compare_int 1.2.3 -eq ${v}
++ compare_int 1.2.3-rc0 -eq ${v}
++ compare_int 1.2.3.2 -eq ${v}
++ compare_int 1.2.3.3 -eq ${v}
++ compare_int 1.2.3.4 -eq ${v}
++done
++eend ${tret}
++((ret+=tret))
++
+ exit ${ret}
+--
+1.6.0.2
+