On CI use common install prefix named 'dep_prefix' for installing local packages
authorRalf Habacker <ralf.habacker@freenet.de>
Mon, 9 Nov 2020 09:58:22 +0000 (10:58 +0100)
committerSimon McVittie <smcv@collabora.com>
Fri, 25 Feb 2022 14:17:01 +0000 (14:17 +0000)
With this commit a new variable 'ci_local_packages' has been introduced
to have a choice for using development packages from a local installation
or from the distribution.

(cherry picked from commit 9c5734fe9019dd40a5c7491206aa820f430035d6)

.gitlab-ci.yml
tools/ci-build.sh
tools/ci-install.sh

index 65f05da..1e65c1e 100644 (file)
@@ -41,6 +41,7 @@ cache:
 
 variables:
   ci_in_docker: "yes"
+  ci_local_packages: "yes"
   ci_parallel: "2"
   ci_sudo: "yes"
   ci_distro: "debian"
index 1db4edf..28e6452 100755 (executable)
@@ -49,6 +49,11 @@ NULL=
 # See ci-install.sh
 : "${ci_host:=native}"
 
+# ci_local_packages:
+# prefer local packages instead of distribution
+# See ci-install.sh
+: "${ci_local_packages:=yes}"
+
 # ci_parallel:
 # A number of parallel jobs, passed to make -j
 : "${ci_parallel:=1}"
@@ -118,14 +123,24 @@ esac
 #
 case "$ci_host" in
     (*-w64-mingw32)
-        if [ "${ci_host%%-*}" = i686 ]; then
-            mingw="$(pwd)/mingw32"
+        if [ "$ci_local_packages" = yes ]; then
+            dep_prefix=$(pwd)/${ci_host}-prefix
         else
-            mingw="$(pwd)/mingw64"
+            # assume the compiler was configured with a sysroot (e.g. openSUSE)
+            sysroot=$("${ci_host}-gcc" --print-sysroot)
+            # check if the prefix is a subdir of sysroot (e.g. openSUSE)
+            if [ -d "${sysroot}/${ci_host}" ]; then
+                dep_prefix="${sysroot}/${ci_host}"
+            else
+                # fallback: assume the dependency libraries were built with --prefix=/${ci_host}
+                dep_prefix="/${ci_host}"
+                export PKG_CONFIG_SYSROOT_DIR="${sysroot}"
+            fi
         fi
-        export PKG_CONFIG_LIBDIR="${mingw}/lib/pkgconfig"
+
+        export PKG_CONFIG_LIBDIR="${dep_prefix}/lib/pkgconfig"
         export PKG_CONFIG_PATH=
-        export PKG_CONFIG="pkg-config --define-variable=prefix=${mingw}"
+        export PKG_CONFIG="pkg-config --define-variable=prefix=${dep_prefix}"
         unset CC
         unset CXX
         export TMPDIR=/tmp
@@ -293,13 +308,15 @@ case "$ci_buildsys" in
             (*-w64-mingw32)
                 set _ "$@"
                 set "$@" -D CMAKE_TOOLCHAIN_FILE="${srcdir}/cmake/${ci_host}.cmake"
-                set "$@" -D CMAKE_PREFIX_PATH="${mingw}"
-                set "$@" -D CMAKE_INCLUDE_PATH="${mingw}/include"
-                set "$@" -D CMAKE_LIBRARY_PATH="${mingw}/lib"
-                set "$@" -D EXPAT_LIBRARY="${mingw}/lib/libexpat.dll.a"
-                set "$@" -D GLIB2_LIBRARIES="${mingw}/lib/libglib-2.0.dll.a"
-                set "$@" -D GOBJECT_LIBRARIES="${mingw}/lib/libgobject-2.0.dll.a"
-                set "$@" -D GIO_LIBRARIES="${mingw}/lib/libgio-2.0.dll.a"
+                set "$@" -D CMAKE_PREFIX_PATH="${dep_prefix}"
+                if [ "$ci_local_packages" = yes ]; then
+                    set "$@" -D CMAKE_INCLUDE_PATH="${dep_prefix}/include"
+                    set "$@" -D CMAKE_LIBRARY_PATH="${dep_prefix}/lib"
+                    set "$@" -D EXPAT_LIBRARY="${dep_prefix}/lib/libexpat.dll.a"
+                    set "$@" -D GLIB2_LIBRARIES="${dep_prefix}/lib/libglib-2.0.dll.a"
+                    set "$@" -D GOBJECT_LIBRARIES="${dep_prefix}/lib/libgobject-2.0.dll.a"
+                    set "$@" -D GIO_LIBRARIES="${dep_prefix}/lib/libgio-2.0.dll.a"
+                fi
                 shift
                 # don't run tests yet, Wine needs Xvfb and more
                 # msys2 libraries
index 2d3d3af..6ee6251 100755 (executable)
@@ -48,6 +48,10 @@ NULL=
 # (ci_docker is empty in this case).
 : "${ci_in_docker:=no}"
 
+# ci_local_packages:
+# prefer local packages instead of distribution
+: "${ci_local_packages:=yes}"
+
 # ci_suite:
 # OS suite (release, branch) in which we are testing.
 # Typical values for ci_distro=debian: sid, jessie
@@ -219,39 +223,6 @@ case "$ci_distro" in
                 ;;
         esac
 
-        case "$ci_host" in
-            (*-w64-mingw32)
-                mirror=http://repo.msys2.org/mingw/${ci_host%%-*}
-                if [ "${ci_host%%-*}" = i686 ]; then
-                    mingw="$(pwd)/mingw32"
-                else
-                    mingw="$(pwd)/mingw64"
-                fi
-                install -d "${mingw}"
-                for pkg in \
-                    bzip2-1.0.8-1 \
-                    expat-2.2.9-1 \
-                    gcc-libs-9.3.0-2 \
-                    gettext-0.19.8.1-8 \
-                    glib2-2.64.2-1 \
-                    iconv-1.16-1 \
-                    libffi-3.3-1 \
-                    libiconv-1.16-1 \
-                    libwinpthread-git-8.0.0.5814.9dbf4cc1-1 \
-                    pcre-8.44-1 \
-                    zlib-1.2.11-7 \
-                ; do
-                    wget ${mirror}/mingw-w64-${ci_host%%-*}-${pkg}-any.pkg.tar.xz
-                    tar -xvf mingw-w64-${ci_host%%-*}-${pkg}-any.pkg.tar.xz
-                done
-
-                # limit access rights
-                if [ "$ci_in_docker" = yes ]; then
-                    chown -R user "${mingw}"
-                fi
-                ;;
-        esac
-
         # Make sure we have a messagebus user, even if the dbus package
         # isn't installed
         $sudo adduser --system --quiet --home /nonexistent --no-create-home \
@@ -264,4 +235,35 @@ case "$ci_distro" in
         ;;
 esac
 
+if [ "$ci_local_packages" = yes ]; then
+    case "$ci_host" in
+        (*-w64-mingw32)
+            mirror=http://repo.msys2.org/mingw/${ci_host%%-*}
+            dep_prefix=$(pwd)/${ci_host}-prefix
+            install -d "${dep_prefix}"
+            for pkg in \
+                bzip2-1.0.8-1 \
+                expat-2.2.9-1 \
+                gcc-libs-9.3.0-2 \
+                gettext-0.19.8.1-8 \
+                glib2-2.64.2-1 \
+                iconv-1.16-1 \
+                libffi-3.3-1 \
+                libiconv-1.16-1 \
+                libwinpthread-git-8.0.0.5814.9dbf4cc1-1 \
+                pcre-8.44-1 \
+                zlib-1.2.11-7 \
+            ; do
+                wget ${mirror}/mingw-w64-${ci_host%%-*}-${pkg}-any.pkg.tar.xz
+                tar -C ${dep_prefix} --strip-components=1 -xvf mingw-w64-${ci_host%%-*}-${pkg}-any.pkg.tar.xz
+            done
+
+            # limit access rights
+            if [ "$ci_in_docker" = yes ]; then
+                chown -R user "${dep_prefix}"
+            fi
+            ;;
+    esac
+fi
+
 # vim:set sw=4 sts=4 et: