From ec710ed9b355fc10a758f03058e10d01176f3bd6 Mon Sep 17 00:00:00 2001 From: Nico Miguelino Date: Thu, 18 Jul 2024 21:21:41 -0700 Subject: [PATCH] Upgrades webview builder from Buster to Bookworm (#1982) * fix: bump Qt minor and patch version * fix: update webview Dockerfile * docs: update README.md * fix: add check for Debian version before calling fetch_rpi_firmware --- webview/Dockerfile | 23 +++++++++++++-------- webview/README.md | 22 +++++++++++++++++--- webview/build_qt5.sh | 49 +++++++++++++++++++++++--------------------- 3 files changed, 60 insertions(+), 34 deletions(-) diff --git a/webview/Dockerfile b/webview/Dockerfile index 8eae07911..cc89d5a81 100644 --- a/webview/Dockerfile +++ b/webview/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=linux/arm/v7 balenalib/raspberrypi3:buster as builder +FROM --platform=linux/arm/v7 balenalib/raspberrypi3:bookworm as builder # There are likely a large number of dependencies that can be stripped out here # depending on your needs (and probably in general). My primary objective was just @@ -8,7 +8,7 @@ RUN apt-get update && \ apt-utils \ firebird-dev \ freetds-dev \ - gstreamer-tools \ + gstreamer1.0-tools \ gstreamer1.0-plugins-base \ gstreamer1.0-plugins-good \ gstreamer1.0-plugins-ugly \ @@ -103,7 +103,7 @@ RUN apt-get update && \ # https://www.enricozini.org/blog/2020/qt5/build-qt5-cross-builder-with-raspbian-sysroot-compiling-with-the-sysroot-continued/ RUN dpkg --purge libraspberrypi-dev -FROM debian:buster +FROM debian:bookworm # This list can most likely be slimmed down *a lot* but that's for another day. RUN apt-get update && \ @@ -112,6 +112,7 @@ RUN apt-get update && \ build-essential \ ccache \ cowsay \ + curl \ flex \ freetds-dev \ g++ \ @@ -153,8 +154,7 @@ RUN apt-get update && \ libsnappy-dev \ libsrtp2-dev \ libssl-dev \ - libssl1.1 \ - libtiff5 \ + libtiff6 \ libts-dev \ libudev-dev \ libvpx-dev \ @@ -165,7 +165,6 @@ RUN apt-get update && \ lsb-release \ ninja-build \ nodejs \ - python \ rsync \ ruby \ subversion \ @@ -173,6 +172,16 @@ RUN apt-get update && \ make && \ apt-get clean +# Install pyenv +RUN curl https://pyenv.run | bash && \ + echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc && \ + echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc && \ + echo 'eval "$(pyenv init -)"' >> ~/.bashrc + +# Install Python 2.7.18. This is needed to compile hthe QTWebEngine. +RUN /root/.pyenv/bin/pyenv install 2.7.18 && \ + /root/.pyenv/bin/pyenv global 2.7.18 + WORKDIR /build RUN wget -q https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py \ @@ -183,7 +192,6 @@ RUN mkdir -p /sysroot/usr /sysroot/opt /sysroot/lib COPY --from=builder /lib/ /sysroot/lib/ COPY --from=builder /usr/include/ /sysroot/usr/include/ COPY --from=builder /usr/lib/ /sysroot/usr/lib/ -COPY --from=builder /opt/vc/ /sysroot/opt/vc/ ENV BUILD_WEBVIEW 1 ENV CCACHE_MAXSIZE 10G @@ -192,4 +200,3 @@ ARG GIT_HASH=0 ENV GIT_HASH=$GIT_HASH COPY build_qt5.sh /usr/local/bin/ -CMD /usr/local/bin/build_qt5.sh diff --git a/webview/README.md b/webview/README.md index 0348f9f12..48a9a039d 100644 --- a/webview/README.md +++ b/webview/README.md @@ -12,17 +12,33 @@ $ docker buildx build \ -t qt-builder . ``` -You should now be able to invoke a run executing the following command: +Start the builder container with the following command: ```bash -$ docker run --rm -t \ +$ docker run -itd \ + --name qt-builder-instance \ -v ~/tmp/qt-src:/src:Z \ -v ~/tmp/qt-build:/build:Z \ -v $(pwd):/webview:ro \ + -e TARGET=${TARGET_PLATFORM} \ qt-builder ``` -This will launch `build-qt5.sh` and start the process of building QT for *all* Raspberry Pi boards. The resulting files will be placed in `~/tmp/qt-build/`. +You should now be able to invoke a run executing the following command: + +```bash +$ docker exec -it qt-builder-instance /webview/build_qt5.sh +``` + +This will start the process of building QT for *all* Raspberry Pi boards if you don't specify a `TARGET` environment variable. +The resulting files will be placed in `~/tmp/qt-build/`. + +When you're done, you can stop and remove the container with the following commands: + +```bash +$ docker stop qt-builder-instance +$ docker rm qt-builder-instance +``` You can learn more about this process in the blog post [Compiling Qt with Docker multi-stage and multi-platform](https://www.docker.com/blog/compiling-qt-with-docker-multi-stage-and-multi-platform/). diff --git a/webview/build_qt5.sh b/webview/build_qt5.sh index 5af889204..f224f9bf7 100755 --- a/webview/build_qt5.sh +++ b/webview/build_qt5.sh @@ -9,7 +9,7 @@ BUILD_TARGET=/build SRC=/src QT_MAJOR="5" QT_MINOR="15" -QT_BUG_FIX="2" +QT_BUG_FIX="14" QT_VERSION="$QT_MAJOR.$QT_MINOR.$QT_BUG_FIX" DEBIAN_VERSION=$(lsb_release -cs) MAKE_CORES="$(expr $(nproc) + 2)" @@ -37,6 +37,13 @@ function fetch_cross_compile_tool () { } function fetch_rpi_firmware () { + # Check Debian version. Return early if newer than Debian 10, as they don't have /opt/vc anymore. + _DEBIAN_VERSION=$(lsb_release -rs) + if [ "${_DEBIAN_VERSION}" -gt "10" ]; then + echo "Debian version is newer than 10. Skipping firmware fetch." + return + fi + if [ ! -d "/src/opt" ]; then pushd /src @@ -90,8 +97,8 @@ function fetch_qt () { if [ ! -d "$SRC_DIR" ]; then - if [ ! -f "qt-everywhere-src-$QT_VERSION.tar.xz" ]; then - wget https://download.qt.io/archive/qt/$QT_MAJOR.$QT_MINOR/$QT_VERSION/single/qt-everywhere-src-$QT_VERSION.tar.xz + if [ ! -f "qt-everywhere-opensource-src-$QT_VERSION.tar.xz" ]; then + wget https://download.qt.io/archive/qt/$QT_MAJOR.$QT_MINOR/$QT_VERSION/single/qt-everywhere-opensource-src-$QT_VERSION.tar.xz fi if [ ! -f "md5sums.txt" ]; then @@ -100,7 +107,7 @@ function fetch_qt () { md5sum --ignore-missing -c md5sums.txt # Extract and make a clone - tar xf qt-everywhere-src-$QT_VERSION.tar.xz + tar xf qt-everywhere-opensource-src-$QT_VERSION.tar.xz rsync -aqP qt-everywhere-src-$QT_VERSION/ qt$QT_MAJOR else rsync -aqP --delete qt-everywhere-src-$QT_VERSION/ qt$QT_MAJOR @@ -243,30 +250,26 @@ function build_qt () { echo "QT Build already exist." fi - if [ ! -f "$BUILD_TARGET/webview-$QT_VERSION-$DEBIAN_VERSION-$1-$GIT_HASH.tar.gz" ]; then - if [ "${BUILD_WEBVIEW-x}" == "1" ]; then - cp -rf /webview "$SRC_DIR/" + if [ "${BUILD_WEBVIEW-x}" == "1" ]; then + cp -rf /webview "$SRC_DIR/" - pushd "$SRC_DIR/webview" + pushd "$SRC_DIR/webview" - "$SRC_DIR/qt${QT_MAJOR}pi/bin/qmake" - make -j"$MAKE_CORES" - make install + "$SRC_DIR/qt${QT_MAJOR}pi/bin/qmake" + make -j"$MAKE_CORES" + make install - mkdir -p fakeroot/bin fakeroot/share/ScreenlyWebview - mv ScreenlyWebview fakeroot/bin/ - cp -rf /webview/res fakeroot/share/ScreenlyWebview/ + mkdir -p fakeroot/bin fakeroot/share/ScreenlyWebview + mv ScreenlyWebview fakeroot/bin/ + cp -rf /webview/res fakeroot/share/ScreenlyWebview/ - pushd fakeroot - tar cfz "$BUILD_TARGET/webview-$QT_VERSION-$DEBIAN_VERSION-$1-$GIT_HASH.tar.gz" . - popd + pushd fakeroot + tar cfz "$BUILD_TARGET/webview-$QT_VERSION-$DEBIAN_VERSION-$1-$GIT_HASH.tar.gz" . + popd - pushd "$BUILD_TARGET" - sha256sum "webview-$QT_VERSION-$DEBIAN_VERSION-$1-$GIT_HASH.tar.gz" > "webview-$QT_VERSION-$DEBIAN_VERSION-$1-$GIT_HASH.tar.gz.sha256" - popd - fi - else - echo "Webview Build already exist." + pushd "$BUILD_TARGET" + sha256sum "webview-$QT_VERSION-$DEBIAN_VERSION-$1-$GIT_HASH.tar.gz" > "webview-$QT_VERSION-$DEBIAN_VERSION-$1-$GIT_HASH.tar.gz.sha256" + popd fi }