diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 63598e89..d0b1a01f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,6 +41,7 @@ cache: variables: ci_in_docker: "yes" + ci_local_packages: "yes" ci_parallel: "2" ci_sudo: "yes" ci_distro: "debian" diff --git a/tools/ci-build.sh b/tools/ci-build.sh index 94caa370..f77f11c2 100755 --- a/tools/ci-build.sh +++ b/tools/ci-build.sh @@ -95,6 +95,11 @@ init_wine() { # 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}" @@ -154,10 +159,12 @@ NOCONFIGURE=1 ./autogen.sh case "$ci_buildsys" in (cmake-dist) + # clean up directories from possible previous builds + rm -rf ci-build-dist # Do an Autotools `make dist`, then build *that* with CMake, # to assert that our official release tarballs will be enough # to build with CMake. - mkdir ci-build-dist + mkdir -p ci-build-dist ( cd ci-build-dist; ../configure ) make -C ci-build-dist dist tar --xz -xvf ci-build-dist/dbus-1.*.tar.xz @@ -165,46 +172,43 @@ case "$ci_buildsys" in ;; esac -srcdir="$(pwd)" -mkdir ci-build-${ci_variant}-${ci_host} -cd ci-build-${ci_variant}-${ci_host} - -make="make -j${ci_parallel} V=1 VERBOSE=1" - +# +# cross compile setup +# case "$ci_host" in (*-w64-mingw32) - mirror=http://repo.msys2.org/mingw/${ci_host%%-*} - 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 - install -d "${mingw}" - 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 - 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 export TMPDIR=/tmp ;; esac +srcdir="$(pwd)" +# clean up directories from possible previous builds +rm -rf ci-build-${ci_variant}-${ci_host} +mkdir -p ci-build-${ci_variant}-${ci_host} +cd ci-build-${ci_variant}-${ci_host} + +make="make -j${ci_parallel} V=1 VERBOSE=1" + case "$ci_buildsys" in (autotools) case "$ci_variant" in @@ -370,16 +374,18 @@ case "$ci_buildsys" in if [ "$ci_runtime" = "shared" ]; then libgcc_path=$(dirname "$("${ci_host}-gcc" -print-libgcc-file-name)") fi - init_wine "${mingw}/bin" "$(pwd)/bin" ${libgcc_path:+"$libgcc_path"} + init_wine "${dep_prefix}/bin" "$(pwd)/bin" ${libgcc_path:+"$libgcc_path"} cmdwrapper="xvfb-run -a" fi 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 ${mingw}/lib/libgobject-2.0.dll.a ${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 ${dep_prefix}/lib/libgobject-2.0.dll.a ${dep_prefix}/lib/libgio-2.0.dll.a" + fi if [ "$ci_test" = yes ]; then set "$@" -D DBUS_USE_WINE=1 fi diff --git a/tools/ci-install.sh b/tools/ci-install.sh index 10a0e1d3..b026d4d3 100755 --- a/tools/ci-install.sh +++ b/tools/ci-install.sh @@ -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 @@ -105,68 +109,85 @@ case "$ci_distro" in esac $sudo apt-get -qq -y update + packages=() case "$ci_host" in (i686-w64-mingw32) - $sudo apt-get -qq -y --no-install-recommends install \ - binutils-mingw-w64-i686 \ - g++-mingw-w64-i686 \ - $wine32 wine \ - ${NULL} + packages=( + "${packages[@]}" + binutils-mingw-w64-i686 + g++-mingw-w64-i686 + $wine32 wine + ) ;; (x86_64-w64-mingw32) - $sudo apt-get -qq -y --no-install-recommends install \ - binutils-mingw-w64-x86-64\ - g++-mingw-w64-x86-64 \ - $wine64 wine \ - ${NULL} + packages=( + "${packages[@]}" + binutils-mingw-w64-x86-64 + g++-mingw-w64-x86-64 + $wine64 wine + ) ;; esac if [ "$ci_host/$ci_variant/$ci_suite" = "native/production/buster" ]; then - $sudo apt-get -qq -y --no-install-recommends install \ - qttools5-dev-tools qt5-default \ - ${NULL} + packages=( + "${packages[@]}" + qttools5-dev-tools + qt5-default + ) fi - $sudo apt-get -qq -y --no-install-recommends install \ - adduser \ - autoconf-archive \ - automake \ - autotools-dev \ - ccache \ - cmake \ - debhelper \ - dh-autoreconf \ - dh-exec \ - docbook-xml \ - docbook-xsl \ - doxygen \ - dpkg-dev \ - g++ \ - gcc \ - gnome-desktop-testing \ - libapparmor-dev \ - libaudit-dev \ - libcap-ng-dev \ - libexpat-dev \ - libglib2.0-dev \ - libselinux1-dev \ - libsystemd-dev \ - libx11-dev \ - sudo \ - valgrind \ - wget \ - xauth \ - xmlto \ - xsltproc \ - xvfb \ - ${NULL} + packages=( + "${packages[@]}" + adduser + autoconf-archive + automake + autotools-dev + ccache + cmake + debhelper + dh-autoreconf + dh-exec + docbook-xml + docbook-xsl + doxygen + dpkg-dev + g++ + gcc + gnome-desktop-testing + libapparmor-dev + libaudit-dev + libcap-ng-dev + libexpat-dev + libglib2.0-dev + libselinux1-dev + libsystemd-dev + libx11-dev + sudo + valgrind + wget + xauth + xmlto + xsltproc + xvfb + ) - # Make sure we have a messagebus user, even if the dbus package - # isn't installed - $sudo adduser --system --quiet --home /nonexistent --no-create-home \ - --disabled-password --group messagebus + case "$ci_suite" in + (stretch) + # Debian 9 'stretch' didn't have the ducktype package + ;; + + (*) + # assume Ubuntu 18.04 'bionic', Debian 10 'buster' or newer + packages=( + "${packages[@]}" + ducktype yelp-tools + ) + ;; + esac + + $sudo apt-get -qq -y --no-install-recommends install "${packages[@]}" if [ "$ci_in_docker" = yes ]; then # Add the user that we will use to do the build inside the @@ -176,6 +197,7 @@ case "$ci_distro" in chmod 0440 /etc/sudoers.d/nopasswd fi + # manual package setup case "$ci_suite" in (jessie|xenial) # autoconf-archive in Debian 8 and Ubuntu 16.04 is too old, @@ -184,16 +206,12 @@ case "$ci_distro" in $sudo dpkg -i autoconf-archive_*_all.deb rm autoconf-archive_*_all.deb ;; - - (stretch) - # Debian 9 'stretch' didn't have the ducktype package - ;; - - (*) - # assume Ubuntu 18.04 'bionic', Debian 10 'buster' or newer - $sudo apt-get -qq -y --no-install-recommends install ducktype yelp-tools - ;; 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 \ + --disabled-password --group messagebus ;; (*) @@ -202,4 +220,36 @@ 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}" + packages=( + 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 + ) + for pkg in "${packages[@]}" ; 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: