Skip to content

Commit

Permalink
Upgrades webview builder from Buster to Bookworm (#1982)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nicomiguelino authored Jul 19, 2024
1 parent 65ea8b5 commit ec710ed
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 34 deletions.
23 changes: 15 additions & 8 deletions webview/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 \
Expand Down Expand Up @@ -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 && \
Expand All @@ -112,6 +112,7 @@ RUN apt-get update && \
build-essential \
ccache \
cowsay \
curl \
flex \
freetds-dev \
g++ \
Expand Down Expand Up @@ -153,8 +154,7 @@ RUN apt-get update && \
libsnappy-dev \
libsrtp2-dev \
libssl-dev \
libssl1.1 \
libtiff5 \
libtiff6 \
libts-dev \
libudev-dev \
libvpx-dev \
Expand All @@ -165,14 +165,23 @@ RUN apt-get update && \
lsb-release \
ninja-build \
nodejs \
python \
rsync \
ruby \
subversion \
wget \
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 \
Expand All @@ -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
Expand All @@ -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
22 changes: 19 additions & 3 deletions webview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).

Expand Down
49 changes: 26 additions & 23 deletions webview/build_qt5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit ec710ed

Please sign in to comment.