[Libguestfs] [PATCH] tests: use /etc/os-release in test-harder

Pino Toscano ptoscano at redhat.com
Wed Aug 31 13:53:03 UTC 2016


Check the ID in /etc/os-release before checking the other release files,
so it's possible to handle distros without them.

Also, make sure it is skipped if the value read from os-release is not
handled when getting the list of packages.
---
 tests/test-harder.sh | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tests/test-harder.sh b/tests/test-harder.sh
index ea5dfc8..7e1b8df 100755
--- a/tests/test-harder.sh
+++ b/tests/test-harder.sh
@@ -25,7 +25,14 @@ set -e
 # NOTE:  This test will only work if the $pkgs listed below
 # for your distro are installed on the host.  SEE LIST BELOW.
 
-if [ -f /etc/arch-release ]; then
+if [ -f /etc/os-release ]; then
+    distro=$(. /etc/os-release && echo $ID)
+    case "$distro" in
+        fedora|rhel|centos) distro=redhat ;;
+        opensuse|sled|sles) distro=suse ;;
+        ubuntu) distro=debian ;;
+    esac
+elif [ -f /etc/arch-release ]; then
     distro=arch
 elif [ -f /etc/debian_version ]; then
     distro=debian
@@ -63,6 +70,10 @@ case $distro in
     ibm-powerkvm)
 	pkgs="augeas hivex tar"
 	;;
+    *)
+	echo "Unhandled distro '$distro'"
+	exit 77
+	;;
 esac
 
 test "$USE_NETWORK" = 1 || USE_INSTALLED=--use-installed
-- 
2.7.4




More information about the Libguestfs mailing list