summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2022-03-30 10:50:29 +0200
committerRalf Habacker <ralf.habacker@freenet.de>2022-04-04 09:24:31 +0200
commit82f1aaeea06d40de6da467b07206ba8abadf48a0 (patch)
tree66061b2df4a44738de02a64a1c7d2f035dd6138e
parent7060b64287a109ba90d0563b1f6fe578816e9dfe (diff)
downloaddbus-82f1aaeea06d40de6da467b07206ba8abadf48a0.tar.gz
Add automatic detection of distribution to CI scripts
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>
-rw-r--r--.gitlab-ci.yml3
-rwxr-xr-xtools/ci-build.sh12
-rwxr-xr-xtools/ci-install.sh19
3 files changed, 22 insertions, 12 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4ab3ed58..70f8dd58 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -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
diff --git a/tools/ci-build.sh b/tools/ci-build.sh
index d6951cb8..bfb60726 100755
--- a/tools/ci-build.sh
+++ b/tools/ci-build.sh
@@ -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
diff --git a/tools/ci-install.sh b/tools/ci-install.sh
index a331f931..c3dd2a6a 100755
--- a/tools/ci-install.sh
+++ b/tools/ci-install.sh
@@ -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
;;