* [PATCH] dracut, dracut-functions: better vercmp; credits go to V. Lowther
@ 2010-06-11 19:10 Amadeusz Żołnowski
[not found] ` <20100611211034.609135f8-YdJE6FOikKfe60hTmSeVGxfX6IwIUJvj@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Amadeusz Żołnowski @ 2010-06-11 19:10 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 2484 bytes --]
---
dracut | 2 +-
dracut-functions | 47 ++++++++++++++++++++---------------------------
2 files changed, 21 insertions(+), 28 deletions(-)
diff --git a/dracut b/dracut
index 139d0e0..3b1e7e8 100755
--- a/dracut
+++ b/dracut
@@ -184,7 +184,7 @@ abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile"
srcmods="/lib/modules/$kernel/"
[[ $drivers_dir ]] && {
- if verlt $(modprobe --version | cut -d' ' -f3) 3.7; then
+ if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.5; then
derror 'To use --kmoddir option module-init-tools >= 3.7 is required.'
exit 1
fi
diff --git a/dracut-functions b/dracut-functions
index 500e3ae..58f119f 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -24,38 +24,31 @@ IF_dynamic=""
# Generic substring function. If $2 is in $1, return 0.
strstr() { [[ $1 =~ $2 ]]; }
-# Version comparision function. Returns result similar to C strcmp,
-# but instead of -1 is 2. Function assumes version scheme like does
-# Linux kernel.
-# $1 < $2 -> 2
-# $1 = $2 -> 0
-# $1 > $2 -> 1
-# To remember it easy, ask the question: Which argument is greater? ;-)
+# Version comparision function. Assumes Linux style version scheme.
+# $1 = version a
+# $2 = comparision op (gt, ge, eq, le, lt, ne)
+# $3 = version b
vercmp() {
- local i n1=(${1//./ }) n2=(${2//./ })
+ local n1=(${1//./ }) op=$2 n2=(${3//./ }) i res
for ((i=0; ; i++))
- do
- [[ ${n1[i]} && ! ${n2[i]} ]] && return 1
- [[ ! ${n1[i]} && ${n2[i]} ]] && return 2
- [[ ${n1[i]} && ${n2[i]} ]] || return 0
- ((${n1[i]} > ${n2[i]})) && return 1
- ((${n1[i]} < ${n2[i]})) && return 2
+ do
+ if [[ ! ${n1[i]}${n2[i]} ]]; then res=0
+ elif ((${n1[i]:-0} > ${n2[i]:-0})); then res=1
+ elif ((${n1[i]:-0} < ${n2[i]:-0})); then res=2
+ else continue
+ fi
+ break
done
-}
-# Variation of version comparision function. If $1 >= $2, return 0.
-verge() {
- vercmp $1 $2
-
- [[ $? = 0 || $? = 1 ]]
-}
-
-# Variation of version comparision function. If $1 < $2, return 0.
-verlt() {
- vercmp $1 $2
-
- [[ $? = 2 ]]
+ case $op in
+ gt) ((res == 1));;
+ ge) ((res != 2));;
+ eq) ((res == 0));;
+ le) ((res != 1));;
+ lt) ((res == 2));;
+ ne) ((res != 0));;
+ esac
}
# Log initrd creation.
--
1.7.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <20100611211034.609135f8-YdJE6FOikKfe60hTmSeVGxfX6IwIUJvj@public.gmane.org>]
* Re: [PATCH] dracut, dracut-functions: better vercmp; credits go to V. Lowther [not found] ` <20100611211034.609135f8-YdJE6FOikKfe60hTmSeVGxfX6IwIUJvj@public.gmane.org> @ 2010-06-11 19:23 ` Adam Spragg [not found] ` <201006112023.01475.adam-2iSS7ArDF14@public.gmane.org> 2010-06-11 19:47 ` Amadeusz Żołnowski 1 sibling, 1 reply; 5+ messages in thread From: Adam Spragg @ 2010-06-11 19:23 UTC (permalink / raw) To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Amadeusz Żołnowski On Friday 11 Jun 2010 20:10:34 Amadeusz Żołnowski wrote: > diff --git a/dracut b/dracut > index 139d0e0..3b1e7e8 100755 > --- a/dracut > +++ b/dracut > @@ -184,7 +184,7 @@ abs_outfile=$(readlink -f "$outfile") && > outfile="$abs_outfile" > > srcmods="/lib/modules/$kernel/" > [[ $drivers_dir ]] && { > - if verlt $(modprobe --version | cut -d' ' -f3) 3.7; then > + if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.5; then > derror 'To use --kmoddir option module-init-tools >= 3.7 is > required.' exit 1 > fi Which version? 3.7? Or 3.5 ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <201006112023.01475.adam-2iSS7ArDF14@public.gmane.org>]
* Re: [PATCH] dracut, dracut-functions: better vercmp; credits go to V. Lowther [not found] ` <201006112023.01475.adam-2iSS7ArDF14@public.gmane.org> @ 2010-06-11 19:57 ` Amadeusz Żołnowski 0 siblings, 0 replies; 5+ messages in thread From: Amadeusz Żołnowski @ 2010-06-11 19:57 UTC (permalink / raw) To: Adam Spragg; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 767 bytes --] Adam Spragg <adam-2iSS7ArDF14@public.gmane.org>: > On Friday 11 Jun 2010 20:10:34 Amadeusz Żołnowski wrote: > > diff --git a/dracut b/dracut > > index 139d0e0..3b1e7e8 100755 > > --- a/dracut > > +++ b/dracut > > @@ -184,7 +184,7 @@ abs_outfile=$(readlink -f "$outfile") && > > outfile="$abs_outfile" > > > > srcmods="/lib/modules/$kernel/" > > [[ $drivers_dir ]] && { > > - if verlt $(modprobe --version | cut -d' ' -f3) 3.7; then > > + if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.5; then > > derror 'To use --kmoddir option module-init-tools >= 3.7 is > > required.' exit 1 > > fi > > Which version? 3.7? Or 3.5 3.7. Thanks for being alert! Cheers, Amadeusz Żołnowski -- PGP key: 1024D/C284750D [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] dracut, dracut-functions: better vercmp; credits go to V. Lowther [not found] ` <20100611211034.609135f8-YdJE6FOikKfe60hTmSeVGxfX6IwIUJvj@public.gmane.org> 2010-06-11 19:23 ` Adam Spragg @ 2010-06-11 19:47 ` Amadeusz Żołnowski [not found] ` <20100611214721.58062841-YdJE6FOikKfe60hTmSeVGxfX6IwIUJvj@public.gmane.org> 1 sibling, 1 reply; 5+ messages in thread From: Amadeusz Żołnowski @ 2010-06-11 19:47 UTC (permalink / raw) To: initramfs-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 639 bytes --] Left incorrect module-init-tools version in the patch, here's the fix: --- dracut | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/dracut b/dracut index 3b1e7e8..3be4989 100755 --- a/dracut +++ b/dracut @@ -184,7 +184,7 @@ abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile" srcmods="/lib/modules/$kernel/" [[ $drivers_dir ]] && { - if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.5; then + if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.7; then derror 'To use --kmoddir option module-init-tools >= 3.7 is required.' exit 1 fi -- 1.7.1 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <20100611214721.58062841-YdJE6FOikKfe60hTmSeVGxfX6IwIUJvj@public.gmane.org>]
* Re: [PATCH] dracut, dracut-functions: better vercmp; credits go to V. Lowther [not found] ` <20100611214721.58062841-YdJE6FOikKfe60hTmSeVGxfX6IwIUJvj@public.gmane.org> @ 2010-06-17 7:44 ` Harald Hoyer 0 siblings, 0 replies; 5+ messages in thread From: Harald Hoyer @ 2010-06-17 7:44 UTC (permalink / raw) To: Amadeusz Żołnowski; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA On 06/11/2010 09:47 PM, Amadeusz Żołnowski wrote: > Left incorrect module-init-tools version in the patch, here's the fix: > --- > dracut | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/dracut b/dracut > index 3b1e7e8..3be4989 100755 > --- a/dracut > +++ b/dracut > @@ -184,7 +184,7 @@ abs_outfile=$(readlink -f "$outfile")&& outfile="$abs_outfile" > > srcmods="/lib/modules/$kernel/" > [[ $drivers_dir ]]&& { > - if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.5; then > + if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.7; then > derror 'To use --kmoddir option module-init-tools>= 3.7 is required.' > exit 1 > fi pushed ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-06-17 7:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-11 19:10 [PATCH] dracut, dracut-functions: better vercmp; credits go to V. Lowther Amadeusz Żołnowski
[not found] ` <20100611211034.609135f8-YdJE6FOikKfe60hTmSeVGxfX6IwIUJvj@public.gmane.org>
2010-06-11 19:23 ` Adam Spragg
[not found] ` <201006112023.01475.adam-2iSS7ArDF14@public.gmane.org>
2010-06-11 19:57 ` Amadeusz Żołnowski
2010-06-11 19:47 ` Amadeusz Żołnowski
[not found] ` <20100611214721.58062841-YdJE6FOikKfe60hTmSeVGxfX6IwIUJvj@public.gmane.org>
2010-06-17 7:44 ` Harald Hoyer
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.