summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2013-08-14 12:54:33 +0200
committerHarald Hoyer <harald@redhat.com>2013-08-14 15:04:05 +0200
commitf06c2b58529cc1ffa97b5f918edc3b27b0b75140 (patch)
treec5c09dc4e394d5f6a7820a992285ff9bbf5beb67
parent613ed5cd764d54cac082a1e7b7e8d1f1fed29d35 (diff)
downloaddracut-f06c2b58529cc1ffa97b5f918edc3b27b0b75140.tar.gz
dracut-f06c2b58529cc1ffa97b5f918edc3b27b0b75140.tar.bz2
dracut-f06c2b58529cc1ffa97b5f918edc3b27b0b75140.zip
dracut-functions.sh: fixed vercmp()
-rwxr-xr-xdracut-functions.sh57
1 files changed, 29 insertions, 28 deletions
diff --git a/dracut-functions.sh b/dracut-functions.sh
index ec31cf15..7fab2b88 100755
--- a/dracut-functions.sh
+++ b/dracut-functions.sh
@@ -91,9 +91,37 @@ if ! [[ $kernel ]]; then
export kernel
fi
+# 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 _n1=(${1//./ }) _op=$2 _n2=(${3//./ }) _i _res
+
+ for ((_i=0; ; _i++))
+ 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
+
+ case $_op in
+ gt) ((_res == 1));;
+ ge) ((_res != 2));;
+ eq) ((_res == 0));;
+ le) ((_res != 1));;
+ lt) ((_res == 2));;
+ ne) ((_res != 0));;
+ esac
+}
+
srcmods="/lib/modules/$kernel/"
+
[[ $drivers_dir ]] && {
- if vercmp "$(modprobe --version | cut -d' ' -f3)" lt 3.7; then
+ if ! command -v kmod &>/dev/null && vercmp "$(modprobe --version | cut -d' ' -f3)" lt 3.7; then
dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.'
exit 1
fi
@@ -134,33 +162,6 @@ mksubdirs() {
[[ -e ${1%/*} ]] || mkdir -m 0755 -p -- "${1%/*}"
}
-# 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 _n1=${1//./ } _op=$2 _n2=${3//./ } _i _res
-
- for ((_i=0; ; _i++))
- 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
-
- case $_op in
- gt) ((_res == 1));;
- ge) ((_res != 2));;
- eq) ((_res == 0));;
- le) ((_res != 1));;
- lt) ((_res == 2));;
- ne) ((_res != 0));;
- esac
-}
-
# is_func <command>
# Check whether $1 is a function.
is_func() {