Skip to content

Commit

Permalink
Autobuild: Add Linux .deb armhf (Raspberry) 32bit builds
Browse files Browse the repository at this point in the history
This uses the existing build logic, but makes it cross-compiler aware.

Fixes jamulussoftware#1452
  • Loading branch information
hoffie committed Mar 19, 2022
1 parent 490ec39 commit def131a
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 9 deletions.
48 changes: 43 additions & 5 deletions .github/autobuild/linux_deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,68 @@ 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

setup_cross_compiler
}

setup_cross_compilation_apt_sources() {
[[ "${TARGET_ARCH}" != amd64 ]] || return true
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 tee /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() {
[[ "${TARGET_ARCH}" != amd64 ]] || return true
GCC_VERSION=7 # 7 is the default on focal, there is no reason not to update once focal 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/arm-linux-gnueabihf-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}"
}

Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/autobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,22 @@ 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 x86_64 (artifacts+codeQL)
target_os: linux
building_on_os: ubuntu-18.04
cmd1_prebuild: ./.github/autobuild/linux_deb.sh setup
cmd2_build: ./.github/autobuild/linux_deb.sh build
cmd3_postbuild: ./.github/autobuild/linux_deb.sh get-artifacts
run_codeql: true

- config_name: Linux .deb armhf (artifacts+codeQL)
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 (?):
Expand Down
12 changes: 10 additions & 2 deletions distributions/debian/rules
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
#!/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)

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_BUILD_GNU_TYPE)/qt5/qt.conf" -spec "/usr/lib/$(DEB_BUILD_GNU_TYPE)/qt5/mkspecs/$(DEB_BUILD_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
Expand Down
7 changes: 6 additions & 1 deletion linux/deploy_deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ set -eu

# Create deb files

TARGET_ARCH="${TARGET_ARCH:-amd64}"

cp -r distributions/debian .

# get the jamulus version from pro file
Expand All @@ -23,4 +25,7 @@ echo

echo "${VERSION} building..."

debuild --preserve-env -b -us -uc
CC=$(dpkg-architecture -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}"

0 comments on commit def131a

Please sign in to comment.