diff options
author | Mike Frysinger <vapier@gentoo.org> | 2013-01-24 20:47:23 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2013-01-24 20:47:23 +0000 |
commit | 1b98c0cd8c08f8df8e77d9fe4e884d45bc58a299 (patch) | |
tree | cbe2d3f488b5243911c8ea3ecdf73bdce1ba2b9a /eclass | |
parent | fixed double-prefixed install paths, bug 336528 (diff) | |
download | historical-1b98c0cd8c08f8df8e77d9fe4e884d45bc58a299.tar.gz historical-1b98c0cd8c08f8df8e77d9fe4e884d45bc58a299.tar.bz2 historical-1b98c0cd8c08f8df8e77d9fe4e884d45bc58a299.zip |
handle more kernel versions like 3.7-trunk-amd64 and add a testsuite for it
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/linux-info.eclass | 15 | ||||
-rwxr-xr-x | eclass/tests/linux-info:get_running_version.sh | 35 |
2 files changed, 44 insertions, 6 deletions
diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass index 87c1012be9e8..45bd0f704ea8 100644 --- a/eclass/linux-info.eclass +++ b/eclass/linux-info.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.95 2013/01/16 14:29:01 zmedico Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.96 2013/01/24 20:47:23 vapier Exp $ # @ECLASS: linux-info.eclass # @MAINTAINER: @@ -586,11 +586,14 @@ get_running_version() { get_version return $? else - KV_MAJOR=$(get_version_component_range 1 ${KV_FULL}) - KV_MINOR=$(get_version_component_range 2 ${KV_FULL}) - KV_PATCH=$(get_version_component_range 3 ${KV_FULL}) - KV_PATCH=${KV_PATCH//-*} - KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}}" + # This handles a variety of weird kernel versions. Make sure to update + # tests/linux-info:get_running_version.sh if you want to change this. + local kv_full=${KV_FULL//[-+_]*} + KV_MAJOR=$(get_version_component_range 1 ${kv_full}) + KV_MINOR=$(get_version_component_range 2 ${kv_full}) + KV_PATCH=$(get_version_component_range 3 ${kv_full}) + KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}${KV_PATCH:+.${KV_PATCH}}}" + : ${KV_PATCH:=0} fi return 0 } diff --git a/eclass/tests/linux-info:get_running_version.sh b/eclass/tests/linux-info:get_running_version.sh new file mode 100755 index 000000000000..6d1bbb15f0b0 --- /dev/null +++ b/eclass/tests/linux-info:get_running_version.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +source tests-common.sh + +inherit linux-info + +test_get_running_version() { + local test_kv=$1 major=$2 minor=$3 patch=$4 extra=$5 + tbegin "get_running_version ${test_kv}" + uname() { echo "${test_kv}" ; } + ROOT=/:/:/:/: get_running_version + local r=$? + [[ ${r} -eq 0 && + ${major} == "${KV_MAJOR}" && + ${minor} == "${KV_MINOR}" && + ${patch} == "${KV_PATCH}" && + ${extra} == "${KV_EXTRA}" ]] + tend $? "FAIL: {ret: ${r}==0} {major: ${major}==${KV_MAJOR}} {minor: ${minor}==${KV_MINOR}} {patch: ${patch}==${KV_PATCH}} {extra: ${extra}==${KV_EXTRA}}" +} + +tests=( + # KV_FULL MAJOR MINOR PATCH EXTRA + 1.2.3 1 2 3 '' + 1.2.3.4 1 2 3 .4 + 1.2.3-ver+1.4 1 2 3 -ver+1.4 + 1.2-kern.3 1 2 0 -kern.3 + 1.2+kern.5 1 2 0 +kern.5 + 1.2.3_blah 1 2 3 _blah +) + +for (( i = 0; i < ${#tests[@]}; i += 5 )) ; do + test_get_running_version "${tests[@]:i:5}" +done + +texit |