From 14c77d935aa059e9cad906f996885c163ed17f3f Mon Sep 17 00:00:00 2001 From: Nicolas Dechesne Date: Tue, 24 Jan 2017 22:02:15 +0100 Subject: automated: sh-test-lib: add support for /etc/os-release file /etc/os-release is a standard file in most distro now, [1] and [2]. Let's use it as the default mechanism to detect the distro at run time, and keep the old mechanisms as fallback. Also * defines 'oe-based' name for any known OE based releases, so that we can adapt test cases accordingly. * convert the ID name found in /etc/os-release into the one we used to have in lsb_release (e.g. Ubuntu vs ubuntu, ... ). [1] https://www.freedesktop.org/software/systemd/man/os-release.html [2] http://0pointer.de/blog/projects/os-release.html Change-Id: I1c9e11b449f8532450c8343bc29eb0aeec58c229 Signed-off-by: Nicolas Dechesne --- automated/lib/sh-test-lib | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/automated/lib/sh-test-lib b/automated/lib/sh-test-lib index 39b65cd..32c481f 100755 --- a/automated/lib/sh-test-lib +++ b/automated/lib/sh-test-lib @@ -151,7 +151,10 @@ detect_abi() { } dist_name() { - if [ -x /usr/bin/lsb_release ]; then + if [ -f /etc/os-release ]; then + # shellcheck disable=SC1091 + dist=$(. /etc/os-release && echo "${ID}") + elif [ -x /usr/bin/lsb_release ]; then dist="$(lsb_release -si)" elif [ -f /etc/lsb-release ]; then # shellcheck disable=SC1091 @@ -166,6 +169,14 @@ dist_name() { dist="Unknown" warn_msg "Unsupported distro: cannot determine distribution name" fi + + case "${dist}" in + debian) dist="Debian" ;; + ubuntu) dist="Ubuntu" ;; + fedora) dist="Fedora" ;; + centos) dist="CentOS" ;; + rpb|rpb-wayland|rpb-eglfs) dist="oe-based" ;; + esac } install_deps() { -- cgit v1.2.3