File indexing completed on 2024-07-21 04:35:18

0001 #!/bin/bash
0002 
0003 # SPDX-FileCopyrightText: 2015-2016 Collabora Ltd.
0004 # SPDX-FileCopyrightText: 2020-2024 Ralf Habacker ralf.habacker @freenet.de
0005 #
0006 # SPDX-License-Identifier: MIT
0007 
0008 set -euo pipefail
0009 set -x
0010 
0011 # ci_distro:
0012 # OS distribution in which we are testing
0013 # Typical values: auto opensuse ubuntu
0014 : "${ci_distro:=auto}"
0015 
0016 # ci_host:
0017 # the host to build for native, mingw32, mingw64
0018 : "${ci_host:=native}"
0019 
0020 # ci_distro_variant:
0021 # Typical values: leap tumbleweed
0022 : "${ci_distro_variant:=leap}"
0023 
0024 # ci_variant:
0025 # One of kf5, kf4
0026 : "${ci_variant:=kf5}"
0027 
0028 # setup install command; use sudo outside of docker
0029 sudo=
0030 if ! [ -f /.dockerenv ]; then
0031     sudo=sudo
0032 fi
0033 zypper="$sudo /usr/bin/zypper --non-interactive"
0034 
0035 install=
0036 source_install=
0037 
0038 if [ "$ci_distro" = "auto" ]; then
0039     ci_distro=$(. /etc/os-release; echo ${ID})
0040 fi
0041 
0042 case "$ci_distro" in
0043     (opensuse*)
0044         # add required repos
0045         repo_name=$(. /etc/os-release; echo $PRETTY_NAME | sed 's, ,_,g')
0046         repos=()
0047         case "$ci_variant-$ci_host" in
0048             (*-mingw*)
0049                 bits=$(echo $ci_host | sed 's,mingw,,g')
0050                 repos=(
0051                     "${repos[@]}"
0052                     https://download.opensuse.org/repositories/windows:/mingw:/win${bits}/${repo_name}/windows:mingw:win${bits}.repo
0053                     https://download.opensuse.org/repositories/windows:/mingw/${repo_name}/windows:mingw.repo
0054                     https://download.opensuse.org/repositories/security:/tls/openSUSE_Tumbleweed/security:tls.repo
0055                 )
0056                 ;;
0057             (kf4-native)
0058                 repos=(
0059                     "${repos[@]}"
0060                     https://download.opensuse.org/repositories/windows:/mingw/${repo_name}/windows:mingw.repo
0061                 )
0062                 ;;
0063         esac
0064 
0065         # setup packages
0066         packages=(
0067             cmake
0068             AppStream
0069         )
0070         source_packages=()
0071 
0072         # misc packages
0073         packages=(
0074            "${packages[@]}"
0075             gettext-runtime
0076             # prevents crashing of mingwxx-windres (https://bugzilla.opensuse.org/show_bug.cgi?id=1198923)
0077             glibc-locale-base
0078             # xvfb-run does not have added all required tools
0079             openbox
0080             psmisc # killall
0081             shadow # useradd
0082             sharutils # uuencode
0083             sudo # sudoers
0084             xvfb-run
0085             which
0086             xauth
0087             xterm
0088         )
0089 
0090         # for screenshots
0091         packages=(
0092            "${packages[@]}"
0093             xwd ImageMagick
0094         )
0095         case "$ci_variant-$ci_host" in
0096             (kf5*-native)
0097                 source_packages=(
0098                     "${source_packages[@]}"
0099                     alkimia
0100                 )
0101                 packages=(
0102                     "${packages[@]}"
0103                     kinit
0104                 )
0105                 ;;
0106             (kf5*-mingw*)
0107                 prefix=${ci_host}
0108                 packages=(
0109                     "${packages[@]}"
0110                     doxygen
0111                     "$prefix-extra-cmake-modules"
0112                     "$prefix-gmp-devel"
0113                     "$prefix(cmake:KF5Completion)"
0114                     "$prefix(cmake:KF5Config)"
0115                     "$prefix(cmake:KF5CoreAddons)"
0116                     "$prefix(cmake:KF5I18n)"
0117                     "$prefix(cmake:KF5IconThemes)"
0118                     "$prefix(cmake:KF5KIO)"
0119                     "$prefix(cmake:KF5NewStuff)"
0120                     "$prefix(cmake:KF5Package)"
0121                     "$prefix(cmake:KF5TextWidgets)"
0122                     "$prefix(cmake:Qt5Core)"
0123                     "$prefix(cmake:Qt5DBus)"
0124                     "$prefix(cmake:Qt5Qml)"
0125                     "$prefix(cmake:Qt5Test)"
0126                     "$prefix(cmake:Qt5WebKit)"
0127                     "$prefix(cmake:Qt5Widgets)"
0128                     wine
0129                 )
0130                 ;;
0131             (kf4-native)
0132                 # for libQtWebKit-devel
0133                 packages=(
0134                     "${packages[@]}"
0135                     gcc-c++
0136                     extra-cmake-modules
0137                     libkde4-devel
0138                     libQtWebKit-devel
0139                     kdebase4-runtime
0140                     gmp-devel
0141                 )
0142                 ;;
0143             (kf4-mingw*)
0144                 prefix=${ci_host}
0145                 packages=(
0146                     "${packages[@]}"
0147                     ${prefix}-cross-gcc-c++
0148                     ${prefix}-extra-cmake-modules
0149                     ${prefix}-libkf4-devel
0150                     ${prefix}-gmp-devel
0151                     wine
0152                 )
0153                 ;;
0154             (*)
0155                 echo "unsupported combination '$ci_variant=${ci_variant} ci_host=${ci_host}'"
0156                 exit 1
0157                 ;;
0158         esac
0159 
0160         case "$ci_variant" in
0161             (kf5-webkit)
0162                 packages=(
0163                     "${packages[@]}"
0164                     libQt5WebKitWidgets-devel
0165                 )
0166                 ;;
0167             (kf5-webengine)
0168                 packages=(
0169                     "${packages[@]}"
0170                     libqt5-qtwebengine-devel
0171                 )
0172                 ;;
0173         esac
0174 
0175         # add repos
0176         for r in ${repos[@]}; do
0177             $zypper ar --no-refresh --no-check --no-gpgcheck $r || true
0178         done
0179 
0180         if test -v "source_packages"; then
0181             # enable source repo
0182             $zypper modifyrepo --enable repo-source
0183             # install source dependencies
0184             $zypper source-install -d "${source_packages[@]}"
0185         fi
0186 
0187         # install remaining packages
0188         $zypper install "${packages[@]}"
0189         ;;
0190 esac
0191 
0192 # Add the user that we will use to do the build inside the
0193 # Docker container, and let them use sudo
0194 if [ -f /.dockerenv ] && [ -z `getent passwd | grep ^user` ]; then
0195     useradd -m user
0196     passwd -ud user
0197     echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nopasswd
0198     chmod 0440 /etc/sudoers.d/nopasswd
0199 fi