]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Add automatic detection of distribution to CI scripts
authorRalf Habacker <ralf.habacker@freenet.de>
Wed, 30 Mar 2022 08:50:29 +0000 (10:50 +0200)
committerRalf Habacker <ralf.habacker@freenet.de>
Mon, 4 Apr 2022 07:24:31 +0000 (09:24 +0200)
The detection is based on the variable ID from /etc/os-release,
which is supported by systemd. For further details see
https://www.freedesktop.org/software/systemd/man/os-release.html.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
.gitlab-ci.yml
tools/ci-build.sh
tools/ci-install.sh

index 4ab3ed587fc8611bcad013a3c309116162db8f16..70f8dd5823cc3776c22a1da928b7abc8795852dc 100644 (file)
@@ -31,7 +31,6 @@ variables:
   ci_local_packages: "yes"
   ci_parallel: "2"
   ci_sudo: "yes"
-  ci_distro: "debian"
   ci_suite: "bullseye"
   ###
   # IMPORTANT
@@ -158,8 +157,6 @@ debian buster autotools:
 .suse-build:
   extends: .unix-host-build
   image: "opensuse/leap:15"
-  variables:
-    ci_distro: "opensuse"
 
 opensuse cmake:
   extends: .suse-build
index d6951cb8131474a6dc846b8e86a6aaa7d8f4df7c..bfb6072677036b9ee81e4ee8165f6fb32fc0c021 100755 (executable)
@@ -79,8 +79,8 @@ init_wine() {
 
 # ci_distro:
 # OS distribution in which we are testing
-# Typical values: ubuntu, debian; maybe fedora in future
-: "${ci_distro:=ubuntu}"
+# Typical values: auto (detect at runtime), ubuntu, debian; maybe fedora in future
+: "${ci_distro:=auto}"
 
 # ci_docker:
 # If non-empty, this is the name of a Docker image. ci-install.sh will
@@ -132,6 +132,12 @@ init_wine() {
 
 echo "ci_buildsys=$ci_buildsys ci_distro=$ci_distro ci_docker=$ci_docker ci_host=$ci_host ci_local_packages=$ci_local_packages ci_parallel=$ci_parallel ci_suite=$ci_suite ci_test=$ci_test ci_test_fatal=$ci_test_fatal ci_variant=$ci_variant ci_runtime=$ci_runtime $0"
 
+# choose distribution
+if [ "$ci_distro" = "auto" ]; then
+    ci_distro=$(. /etc/os-release; echo ${ID} | sed 's, ,_,g')
+    echo "detected ci_distro as '${ci_distro}'"
+fi
+
 if [ -n "$ci_docker" ]; then
     exec docker run \
         --env=ci_buildsys="${ci_buildsys}" \
@@ -366,7 +372,7 @@ case "$ci_buildsys" in
                 # enable tests if supported
                 if [ "$ci_test" = yes ]; then
                     # choose correct wine architecture
-                    if [ "${ci_distro}" = opensuse ]; then
+                    if [ "${ci_distro%%-*}" = opensuse ]; then
                         if [ "${ci_host%%-*}" = x86_64 ]; then
                             export WINEARCH=win64
                             cmake=mingw64-cmake
index a331f931dbfa1a20f283c785043fc840bc622348..c3dd2a6a885768a2cbc6becd06069ce8373d91dd 100755 (executable)
@@ -29,8 +29,8 @@ NULL=
 
 # ci_distro:
 # OS distribution in which we are testing
-# Typical values: ubuntu, debian; maybe fedora in future
-: "${ci_distro:=ubuntu}"
+# Typical values: auto, ubuntu, debian, ; maybe fedora in future
+: "${ci_distro:=auto}"
 
 # ci_docker:
 # If non-empty, this is the name of a Docker image. ci-install.sh will
@@ -70,6 +70,13 @@ else
     sudo=sudo
 fi
 
+
+# choose distribution
+if [ "$ci_distro" = "auto" ]; then
+    ci_distro=$(. /etc/os-release; echo ${ID} | sed 's, ,_,g')
+    echo "detected ci_distro as '${ci_distro}'"
+fi
+
 if [ -n "$ci_docker" ]; then
     sed \
         -e "s/@ci_distro@/${ci_distro}/" \
@@ -80,7 +87,7 @@ if [ -n "$ci_docker" ]; then
 fi
 
 case "$ci_distro" in
-    (debian|ubuntu)
+    (debian*|ubuntu*)
         # Don't ask questions, just do it
         sudo="$sudo env DEBIAN_FRONTEND=noninteractive"
 
@@ -178,7 +185,7 @@ case "$ci_distro" in
         fi
         ;;
 
-    (opensuse)
+    (opensuse*)
         zypper="/usr/bin/zypper --non-interactive"
         # system
         packages=(
@@ -286,7 +293,7 @@ esac
 # manual package setup
 #
 case "$ci_distro" in
-    (debian|ubuntu)
+    (debian*|ubuntu*)
 
         # Make sure we have a messagebus user, even if the dbus package
         # isn't installed
@@ -294,7 +301,7 @@ case "$ci_distro" in
             --disabled-password --group messagebus
         ;;
 
-    (opensuse)
+    (opensuse*)
         # test-bus depends on group 'bin'
         $sudo getent group bin >/dev/null || /usr/sbin/groupadd -r bin
         ;;