From fa0c6fba574181ac946bd81a1a892090feec6ccd Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Mon, 21 Oct 2024 12:51:33 +0200 Subject: [PATCH] frontend/qt: update to Qt6 on linux - Needs a newer linuxdeployqt version that supports Qt6 and Qt6 WebEngine. since linuxdeployqt is not maintained anymore and the commit that adds support for it does not have a permanent tag/release, we re-release their latest `continuous` release at https://github.com/BitBoxSwiss/linuxdeployqt/releases/tag/bitbox-1 and use that. - We don't compile Qt from sources anymore, as it does not work with the Ubuntu 20 cmake (too old) and it doesn't work with the newest cmake (currently 3.31) - there is some webengine cmake incompatibility. Instead of trying to figure all of this out, we use the excellent aqtinstall tool instead to fetch binaries. We also use pre-built binaries on macOS/Windows already, compiling from source on linux was an exception. --- Dockerfile | 8 +- frontends/qt/Makefile | 5 +- frontends/qt/docker-qt5base/Dockerfile | 121 ------------------------- frontends/qt/main.cpp | 4 + scripts/docker_install.sh | 45 ++++++++- 5 files changed, 51 insertions(+), 132 deletions(-) delete mode 100644 frontends/qt/docker-qt5base/Dockerfile diff --git a/Dockerfile b/Dockerfile index e03aac18a0..d40bf283b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,9 @@ # limitations under the License. FROM thyrlian/android-sdk:4.0 as android -FROM shiftcrypto/qt5:4 +FROM ubuntu:20.04 + +ENV DEBIAN_FRONTEND noninteractive # Android COPY --from=android /opt/android-sdk /opt/android-sdk @@ -26,8 +28,8 @@ ENV GOROOT /opt/go_dist/go ENV PATH $GOROOT/bin:$GOPATH/bin:$PATH ADD Makefile /tmp/ -RUN make -C /tmp/ envinit +# RUN make -C /tmp/ envinit -ENV PATH /opt/qt5/bin:$PATH +ENV PATH /opt/qt6/6.2.4/gcc_64/bin:/opt/qt6/6.2.4/gcc_64/libexec:$PATH CMD ["bash"] diff --git a/frontends/qt/Makefile b/frontends/qt/Makefile index bd0e668e59..2164c93c9f 100644 --- a/frontends/qt/Makefile +++ b/frontends/qt/Makefile @@ -31,7 +31,7 @@ linux: mv build/BitBox build/linux-tmp cp build/assets.rcc build/linux-tmp/ cp server/libserver.so build/linux-tmp - cd build/linux-tmp && /opt/linuxdeployqt-7-x86_64.AppImage BitBox -bundle-non-qt-libs -unsupported-allow-new-glibc + cd build/linux-tmp && /opt/linuxdeployqt-continuous-x86_64.AppImage BitBox -bundle-non-qt-libs -unsupported-allow-new-glibc cp /usr/lib/x86_64-linux-gnu/nss/* build/linux-tmp/lib cp -aR resources/linux build/tmp-deb cp resources/linux/usr/share/applications/bitbox.desktop build/linux-tmp @@ -41,9 +41,8 @@ linux: cd build/linux && fpm --after-install ../../resources/deb-afterinstall.sh -s dir -t deb -n bitbox -v 4.45.0 -C ../tmp-deb/ cd build/linux && fpm --after-install ../../resources/deb-afterinstall.sh -s dir -t rpm -n bitbox -v 4.45.0 -C ../tmp-deb/ # create AppImage - cd build/linux-tmp && /opt/linuxdeployqt-7-x86_64.AppImage BitBox -appimage -unsupported-allow-new-glibc + cd build/linux-tmp && /opt/linuxdeployqt-continuous-x86_64.AppImage BitBox -appimage -unsupported-allow-new-glibc mv build/linux-tmp/BitBoxApp-*-x86_64.AppImage build/linux/ - rm build/linux-tmp/libserver.so osx: $(MAKE) clean cd server && $(MAKE) macosx diff --git a/frontends/qt/docker-qt5base/Dockerfile b/frontends/qt/docker-qt5base/Dockerfile deleted file mode 100644 index d7d25cfa69..0000000000 --- a/frontends/qt/docker-qt5base/Dockerfile +++ /dev/null @@ -1,121 +0,0 @@ -# Copyright 2018 Shift Devices AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM ubuntu:20.04 as qt5base - -ENV DEBIAN_FRONTEND noninteractive - -Run apt-get update - -# qt5 build deps and convenience tools. -RUN apt-get -y install --no-install-recommends \ - sudo \ - bash-completion \ - git \ - wget \ - build-essential \ - ccache \ - python \ - libfontconfig1-dev \ - libfreetype6-dev \ - libx11-dev \ - libxext-dev \ - libxfixes-dev \ - libxi-dev \ - libxrender-dev \ - libx11-xcb-dev \ - '^libxcb.*' \ - libx11-xcb-dev \ - libglu1-mesa-dev \ - libxrender-dev \ - libxi-dev \ - libatspi2.0-dev \ - libdbus-1-dev \ - flex \ - bison \ - gperf \ - libicu-dev \ - libxslt-dev \ - ruby \ - libssl-dev \ - libxcursor-dev \ - libxcomposite-dev \ - libxdamage-dev \ - libxrandr-dev \ - libfontconfig1-dev \ - libcap-dev \ - libbz2-dev \ - libgcrypt20-dev \ - libpci-dev \ - libnss3-dev \ - libxcursor-dev \ - libxcomposite-dev \ - libxdamage-dev \ - libxrandr-dev \ - libdrm-dev \ - libfontconfig1-dev \ - libxtst-dev \ - libasound2-dev \ - libcups2-dev \ - libpulse-dev \ - libudev-dev \ - libssl-dev \ - libegl1-mesa-dev \ - ninja-build \ - gyp \ - libxss-dev \ - libasound2-dev \ - libgstreamer1.0-dev \ - libwayland-dev \ - libgstreamer-plugins-base1.0-dev - -# Get the source code -RUN cd /tmp && \ - git clone git://code.qt.io/qt/qt5.git && \ - cd qt5 && \ - git checkout 5.15.2 && \ - git submodule update --init --recursive - -RUN apt-get -y install --no-install-recommends libxkbcommon-dev libxkbcommon-x11-dev - -RUN cd /tmp/qt5 && \ - ./configure \ - -prefix /opt/qt5 \ - -opensource \ - -confirm-license \ - -nomake tests \ - -nomake examples \ - -skip qtdocgallery \ - -skip qtquick3d \ - -dbus \ - -xcb -xcb-xlib -bundled-xcb-xinput \ - -qpa xcb \ - -release \ - -reduce-relocations \ - -optimized-qmake - -RUN cd /tmp/qt5 && make -j1 - -RUN cd /tmp/qt5 && make install - -FROM ubuntu:20.04 - -ENV DEBIAN_FRONTEND noninteractive - -COPY --from=qt5base /opt/qt5 /opt/qt5 - -Run apt-get update - -# This is needed for compiling apps depending on the qt5 libs. -RUN apt-get -y install --no-install-recommends libxcb-xinerama0 libxcb-xkb-dev libxcb-render-util0 libxcb-image0 libxcb-keysyms1 libxcb-icccm4 libxcb-randr0 libxcb-shape0 libxcb-xinput0 libcups2 libgl1-mesa-dev libegl1-mesa-dev libfontconfig1-dev libfreetype6-dev libxi-dev libxcursor-dev libxrender-dev libxss-dev libxcomposite-dev libasound2-dev libxtst-dev libxslt-dev libnss3-dev libicu-dev libpcre2-16-0 diff --git a/frontends/qt/main.cpp b/frontends/qt/main.cpp index a9ccb4e04b..9914d82245 100644 --- a/frontends/qt/main.cpp +++ b/frontends/qt/main.cpp @@ -174,7 +174,11 @@ class WebEngineView : public QWebEngineView { page()->action(QWebEnginePage::SelectAll), page()->action(QWebEnginePage::Unselect), }; +#if QT_VERSION_MAJOR >= 6 + QMenu *menu = createStandardContextMenu(); +#else QMenu *menu = page()->createStandardContextMenu(); +#endif for (const auto action : menu->actions()) { if (whitelist.find(action) == whitelist.cend()) { menu->removeAction(action); diff --git a/scripts/docker_install.sh b/scripts/docker_install.sh index a475b53863..f5feae5f00 100755 --- a/scripts/docker_install.sh +++ b/scripts/docker_install.sh @@ -40,7 +40,42 @@ apt-get install -y --no-install-recommends \ file \ libtiff-dev \ libxkbcommon-x11-dev \ - libxrandr-dev + libxrandr-dev \ + libxcb-xinerama0 \ + libxcb-xkb-dev \ + libxcb-render-util0 \ + libxcb-image0 \ + libxcb-keysyms1 \ + libxcb-icccm4 \ + libxcb-randr0 \ + libxcb-shape0 \ + libxcb-xinput0 \ + libcups2 \ + libgl1-mesa-dev \ + libegl1-mesa-dev \ + libfontconfig1-dev \ + libfreetype6-dev \ + libxi-dev \ + libxcursor-dev \ + libxrender-dev \ + libxss-dev \ + libxcomposite-dev \ + libasound2-dev \ + libxtst-dev \ + libxslt-dev \ + libnss3-dev \ + libicu-dev \ + libpcre2-16-0 \ + libxkbfile-dev + +# Install Qt libs. python3-dev is needed to compile aqtinstall. +apt-get -y install --no-install-recommends python3-pip python3-dev +pip install -U pip && pip install aqtinstall +# Not sure why we need qtpositioning - app compilation fails without. Maybe the webengine depends on it. +# qtpositioning depends on qtserialport. +# qtwebechannel is for the JS/backend bridge. +# qtwebengine is for rendering the frontend. +aqt install-qt linux desktop 6.2.4 -m qtpositioning qtserialport qtwebchannel qtwebengine --outputdir /opt/qt6 npm install -g npm@10 npm install -g locize-cli @@ -48,12 +83,12 @@ npm install -g locize-cli mkdir -p /opt/go_dist curl https://dl.google.com/go/go1.22.4.linux-amd64.tar.gz | tar -xz -C /opt/go_dist -# Needed for qt5. fuse is needed to run the linuxdeployqt appimage. +# fuse is needed to run the linuxdeployqt appimage. apt-get install -y --no-install-recommends fuse cd /opt && \ - wget https://github.com/probonopd/linuxdeployqt/releases/download/7/linuxdeployqt-7-x86_64.AppImage && \ - echo "645276306a801d7154d59e5b4b3c2fac3d34e09be57ec31f6d9a09814c6c162a /opt/linuxdeployqt-7-x86_64.AppImage" | sha256sum -c - && \ - chmod +x /opt/linuxdeployqt-7-x86_64.AppImage + wget https://github.com/BitBoxSwiss/linuxdeployqt/releases/download/bitbox-1/linuxdeployqt-continuous-x86_64.AppImage && \ + echo "3850e767986be94cfb0818983df2da2d82bea6d8742aa373d810fba90eb5c65c /opt/linuxdeployqt-continuous-x86_64.AppImage" | sha256sum -c - && \ + chmod +x /opt/linuxdeployqt-continuous-x86_64.AppImage # Install fpm to create deb/rpm packages apt-get install -y --no-install-recommends \