diff --git a/.github/autobuild/linux_deb.sh b/.github/autobuild/linux_deb.sh index 34b665680d..26adf41cc8 100755 --- a/.github/autobuild/linux_deb.sh +++ b/.github/autobuild/linux_deb.sh @@ -6,30 +6,72 @@ if [[ ! ${jamulus_buildversionstring:-} =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then exit 1 fi +TARGET_ARCH="${TARGET_ARCH:-amd64}" +case "${TARGET_ARCH}" in + amd64) + ABI_NAME="" + ;; + armhf) + ABI_NAME="arm-linux-gnueabihf" + ;; + *) + echo "Unsupported TARGET_ARCH ${TARGET_ARCH}" + exit 1 +esac + setup() { + setup_cross_compilation_apt_sources + echo "Update system..." sudo apt-get -qq update echo "Install dependencies..." - sudo apt-get -qq --no-install-recommends -y install devscripts build-essential debhelper libjack-jackd2-dev qtbase5-dev qttools5-dev-tools + sudo apt-get -qq --no-install-recommends -y install devscripts build-essential debhelper fakeroot libjack-jackd2-dev qtbase5-dev qttools5-dev-tools + + setup_cross_compiler +} + +setup_cross_compilation_apt_sources() { + if [[ "${TARGET_ARCH}" == amd64 ]]; then + return + fi + sudo dpkg --add-architecture "${TARGET_ARCH}" + sed -rne "s|^deb.*/ ([^ -]+(-updates)?) main.*|deb [arch=${TARGET_ARCH}] http://ports.ubuntu.com/ubuntu-ports \1 main universe multiverse restricted|p" /etc/apt/sources.list | sudo dd of=/etc/apt/sources.list.d/"${TARGET_ARCH}".list + sudo sed -re 's/^deb /deb [arch=amd64,i386] /' -i /etc/apt/sources.list +} + +setup_cross_compiler() { + if [[ "${TARGET_ARCH}" == amd64 ]]; then + return + fi + GCC_VERSION=7 # 7 is the default on 18.04, there is no reason not to update once 18.04 is out of support + sudo apt install -qq -y --no-install-recommends "g++-${GCC_VERSION}-${ABI_NAME}" "qt5-qmake:${TARGET_ARCH}" "qtbase5-dev:${TARGET_ARCH}" "libjack-jackd2-dev:${TARGET_ARCH}" + sudo update-alternatives --install "/usr/bin/${ABI_NAME}-g++" g++ "/usr/bin/${ABI_NAME}-g++-${GCC_VERSION}" 10 + sudo update-alternatives --install "/usr/bin/${ABI_NAME}-gcc" gcc "/usr/bin/${ABI_NAME}-gcc-${GCC_VERSION}" 10 + + if [[ "${TARGET_ARCH}" == armhf ]]; then + # Ubuntu's Qt version only ships a profile for gnueabi, but not for gnueabihf. Therefore, build a custom one: + sudo cp -R "/usr/lib/${ABI_NAME}/qt5/mkspecs/linux-arm-gnueabi-g++/" "/usr/lib/${ABI_NAME}/qt5/mkspecs/${ABI_NAME}-g++/" + sudo sed -re 's/-gnueabi/-gnueabihf/' -i "/usr/lib/${ABI_NAME}/qt5/mkspecs/${ABI_NAME}-g++/qmake.conf" + fi } build_app_as_deb() { - ./linux/deploy_deb.sh + TARGET_ARCH="${TARGET_ARCH}" ./linux/deploy_deb.sh } pass_artifacts_to_job() { mkdir deploy # rename headless first, so wildcard pattern matches only one file each - artifact_deploy_filename_1="jamulus_headless_${jamulus_buildversionstring}_ubuntu_amd64.deb" + artifact_deploy_filename_1="jamulus_headless_${jamulus_buildversionstring}_ubuntu_${TARGET_ARCH}.deb" echo "Moving headless build artifact to deploy/${artifact_deploy_filename_1}" - mv ../jamulus-headless*_amd64.deb "./deploy/${artifact_deploy_filename_1}" + mv ../jamulus-headless*"_${TARGET_ARCH}.deb" "./deploy/${artifact_deploy_filename_1}" echo "::set-output name=artifact_1::${artifact_deploy_filename_1}" - artifact_deploy_filename_2="jamulus_${jamulus_buildversionstring}_ubuntu_amd64.deb" + artifact_deploy_filename_2="jamulus_${jamulus_buildversionstring}_ubuntu_${TARGET_ARCH}.deb" echo "Moving regular build artifact to deploy/${artifact_deploy_filename_2}" - mv ../jamulus*_amd64.deb "./deploy/${artifact_deploy_filename_2}" + mv ../jamulus*_"${TARGET_ARCH}.deb" "./deploy/${artifact_deploy_filename_2}" echo "::set-output name=artifact_2::${artifact_deploy_filename_2}" } diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index ebac4d1e9e..33a18b53db 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -94,7 +94,7 @@ jobs: # Jamulus.pro needs to count git history length for android versioning: checkout_fetch_depth: '0' - - config_name: Linux .deb (artifacts+codeQL) + - config_name: Linux .deb amd64 (artifacts+codeQL) target_os: linux building_on_os: ubuntu-18.04 cmd1_prebuild: ./.github/autobuild/linux_deb.sh setup @@ -102,6 +102,14 @@ jobs: cmd3_postbuild: ./.github/autobuild/linux_deb.sh get-artifacts run_codeql: true + - config_name: Linux .deb armhf (artifacts) + target_os: linux + building_on_os: ubuntu-18.04 + cmd1_prebuild: TARGET_ARCH=armhf ./.github/autobuild/linux_deb.sh setup + cmd2_build: TARGET_ARCH=armhf ./.github/autobuild/linux_deb.sh build + cmd3_postbuild: TARGET_ARCH=armhf ./.github/autobuild/linux_deb.sh get-artifacts + run_codeql: false + - config_name: MacOS (artifacts+codeQL) target_os: macos # Stay on 10.15 as long as we use dmgbuild which does not work with 11's hdiutil (?): diff --git a/distributions/debian/rules b/distributions/debian/rules index e754ee294c..5c493fcc7a 100755 --- a/distributions/debian/rules +++ b/distributions/debian/rules @@ -1,13 +1,22 @@ #!/usr/bin/make -f export QT_SELECT=qt5 +DEB_TARGET_GNU_TYPE := $(shell dpkg-architecture -qDEB_TARGET_GNU_TYPE) +DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + +ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) + QMAKE := qmake +else + QMAKE := "/usr/lib/$(DEB_BUILD_GNU_TYPE)/qt5/bin/qmake" -qtconf "/usr/lib/$(DEB_TARGET_GNU_TYPE)/qt5/qt.conf" -spec "/usr/lib/$(DEB_TARGET_GNU_TYPE)/qt5/mkspecs/$(DEB_TARGET_GNU_TYPE)-g++" LIBS+="-lstdc++ -lm" +endif %: dh $@ override_dh_auto_configure: - mkdir -p build-gui && cd build-gui && qmake "CONFIG+=noupcasename" PREFIX=/usr ../Jamulus.pro - mkdir -p build-nox && cd build-nox && qmake "CONFIG+=nosound headless" TARGET=jamulus-headless PREFIX=/usr ../Jamulus.pro + mkdir -p build-gui && cd build-gui && $(QMAKE) "CONFIG+=noupcasename" PREFIX=/usr ../Jamulus.pro + mkdir -p build-nox && cd build-nox && $(QMAKE) "CONFIG+=nosound headless" TARGET=jamulus-headless PREFIX=/usr ../Jamulus.pro override_dh_auto_build: cd src/res/translation && lrelease *.ts diff --git a/linux/deploy_deb.sh b/linux/deploy_deb.sh index 7a4f12a59a..e59ad7e23d 100755 --- a/linux/deploy_deb.sh +++ b/linux/deploy_deb.sh @@ -1,7 +1,10 @@ -#!/bin/sh -e +#!/bin/bash +set -eu # Create deb files +TARGET_ARCH="${TARGET_ARCH:-amd64}" + cp -r distributions/debian . # get the jamulus version from pro file @@ -22,4 +25,7 @@ echo echo "${VERSION} building..." -debuild --preserve-env -b -us -uc +CC=$(dpkg-architecture -A"${TARGET_ARCH}" -qDEB_TARGET_GNU_TYPE)-gcc +# Note: debuild only handles -a, not the long form --host-arch +# There must be no space after -a either, otherwise debuild cannot recognize it and fails during Changelog checks. +CC="${CC}" debuild --preserve-env -b -us -uc -j -a"${TARGET_ARCH}" --target-arch "${TARGET_ARCH}"