diff --git a/appimage/0001-qt-Support-building-with-Qt-5.9.patch b/appimage/0001-qt-Support-building-with-Qt-5.9.patch new file mode 100644 index 000000000..cc85a8ce8 --- /dev/null +++ b/appimage/0001-qt-Support-building-with-Qt-5.9.patch @@ -0,0 +1,104 @@ +From c68d80e23a860a06e7b22b6c0d72aed5d049faef Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= +Date: Tue, 14 Sep 2021 18:12:44 +0200 +Subject: [PATCH] qt: Support building with Qt 5.9 + +* qt/pinlineedit.cpp (class PinLineEdit::Private): Add field q. +(PinLineEdit::Private::Private): New. +(PinLineEdit::Private::copyToClipboard): Remove obsolete parameter. +Use new field q instead. +(PinLineEdit::Private::selectionEnd): New. +(PinLineEdit::PinLineEdit): Pass this to Private. +(PinLineEdit::setFormattedPassphrase): Use new selectionEnd. +(PinLineEdit::copy): Call copyToClipboard without parameter. +-- + +QLineEdit::selectionEnd() exists since Qt 5.10. Provide an alternative +implementation for Qt 5.9 and earlier. This makes it possible to build +pinentry-qt on CentOS 7 which is used for building an AppImage. + +GnuPG-bug-id: 5592 +--- + qt/pinlineedit.cpp | 27 +++++++++++++++++++++------ + 1 file changed, 21 insertions(+), 6 deletions(-) + +diff --git a/qt/pinlineedit.cpp b/qt/pinlineedit.cpp +index 54367ae..49751c6 100644 +--- a/qt/pinlineedit.cpp ++++ b/qt/pinlineedit.cpp +@@ -42,7 +42,13 @@ struct Selection + + class PinLineEdit::Private + { ++ PinLineEdit *const q; ++ + public: ++ Private(PinLineEdit *q) ++ : q{q} ++ {} ++ + QString formatted(QString text) const + { + const int dashCount = text.size() / FormattedPassphraseGroupSize; +@@ -83,13 +89,13 @@ public: + }; + } + +- void copyToClipboard(const PinLineEdit *edit) ++ void copyToClipboard() + { +- if (edit->echoMode() != QLineEdit::Normal) { ++ if (q->echoMode() != QLineEdit::Normal) { + return; + } + +- QString text = edit->selectedText(); ++ QString text = q->selectedText(); + if (mFormattedPassphrase) { + text.remove(FormattedPassphraseSeparator); + } +@@ -98,13 +104,22 @@ public: + } + } + ++ int selectionEnd() ++ { ++#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) ++ return q->selectionEnd(); ++#else ++ return q->selectionStart() + q->selectedText().size(); ++#endif ++ } ++ + public: + bool mFormattedPassphrase = false; + }; + + PinLineEdit::PinLineEdit(QWidget *parent) + : QLineEdit(parent) +- , d{new Private} ++ , d{new Private{this}} + { + connect(this, SIGNAL(textEdited(QString)), + this, SLOT(textEdited())); +@@ -118,7 +133,7 @@ void PinLineEdit::setFormattedPassphrase(bool on) + return; + } + d->mFormattedPassphrase = on; +- Selection selection{selectionStart(), selectionEnd()}; ++ Selection selection{selectionStart(), d->selectionEnd()}; + if (d->mFormattedPassphrase) { + setText(d->formatted(text())); + selection = d->formattedSelection(selection); +@@ -133,7 +148,7 @@ void PinLineEdit::setFormattedPassphrase(bool on) + + void PinLineEdit::copy() const + { +- d->copyToClipboard(this); ++ d->copyToClipboard(); + } + + void PinLineEdit::cut() +-- +2.33.0 + diff --git a/appimage/build-appimage-with-docker.sh b/appimage/build-appimage-with-docker.sh index 36c314593..37a511966 100755 --- a/appimage/build-appimage-with-docker.sh +++ b/appimage/build-appimage-with-docker.sh @@ -1,54 +1,65 @@ #!/bin/sh # Copyright (C) 2021 g10 Code GmbH # # Software engineering by Ingo Klöcker # # This file is part of GnuPG. # # GnuPG is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # GnuPG is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # SPDX-License-Identifier: GPL-3.0+ set -e +# Needed for below HACK +sourcedir=$(cd $(dirname $0)/..; pwd) + tag_or_branch=gnupg-2.2.30 buildroot=$(mktemp -d --tmpdir gnupg-appimage.XXXXXXXXXX) echo Using ${buildroot} cd ${buildroot} git clone -b ${tag_or_branch} https://dev.gnupg.org/source/gnupg # run autogen.sh outside of the container because automake in Centos 7 is too old cd gnupg ./autogen.sh # download swdb.lst outside of the container because gpgv in Centos 7 is too old # to verify the signature build-aux/getswdb.sh +# HACK copy appimage.desktop to make it available in the Docker container +mkdir -p ${buildroot}/gnupg/appimage +cp ${sourcedir}/appimage/appimage.desktop ${buildroot}/gnupg/appimage +# HACK replace with speedo.mk that supports appimage +cp ${sourcedir}/build-aux/speedo.mk ${buildroot}/gnupg/build-aux +# HACK copy patch to make it available in the Docker container +cp ${sourcedir}/appimage/0001-qt-Support-building-with-Qt-5.9.patch ${buildroot}/gnupg + cd ${buildroot} mkdir -p build # run the build-appimage.sh script in the Docker container to build the sources # using CentOS 7; run the container with the same user/group as the current # user to ensure that all files created inside the container are writeable # by the current user docker run -it --rm --user "$(id -u):$(id -g)" \ --volume ${buildroot}/gnupg:/src \ --volume ${buildroot}/build:/build \ g10-build-appimage-gnupg:centos7 \ /build-appimage.sh echo The AppImage should now be available at ${buildroot}/build: ls ${buildroot}/build/*.AppImage diff --git a/appimage/docker/Dockerfile b/appimage/docker/Dockerfile index 34957ad97..46e1ccdde 100644 --- a/appimage/docker/Dockerfile +++ b/appimage/docker/Dockerfile @@ -1,57 +1,61 @@ # Dockerfile - appimage/docker # Copyright (C) 2021 g10 Code GmbH # # Software engineering by Ingo Klöcker # # This file is part of GnuPG. # # GnuPG is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # GnuPG is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # SPDX-License-Identifier: GPL-3.0+ FROM centos:7 # Import the CentOS 7 package signing key after verifying its fingerprint. # Then add the software collections repository from the CentOS SCLo SIG and # import its package signing key after verifying the fingerprint. RUN test $(gpg --with-colons --with-fingerprint < /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 | grep ^pub: | wc -l) = 1 \ && gpg --with-colons --with-fingerprint < /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 | grep -q ^fpr:::::::::6341AB2753D78A78A7C27BB124C6A8A7F4A80EB5 \ && rpmkeys --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 \ && yum -y update \ && yum -y install \ centos-release-scl \ && test $(gpg --with-colons --with-fingerprint < /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo | grep ^pub: | wc -l) = 1 \ && gpg --with-colons --with-fingerprint < /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo | grep -q ^fpr:::::::::C4DBD535B1FBBA14F8BA64A84EB84E71F2EE9D55 \ && rpmkeys --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo \ && yum -y update RUN yum -y install \ automake \ bzip2 \ devtoolset-7-binutils \ devtoolset-7-gcc \ devtoolset-7-gcc-c++ \ devtoolset-7-make \ file \ gnutls-devel \ openldap-devel \ qt5-qtbase-devel \ readline-devel \ sqlite-devel \ wget +# Install patch; this is needed for a temporary HACK +RUN yum -y install \ + patch + COPY build-appimage.sh / RUN chmod +x build-appimage.sh diff --git a/appimage/docker/build-appimage.sh b/appimage/docker/build-appimage.sh index 0d3bde801..ef8fc9ff5 100644 --- a/appimage/docker/build-appimage.sh +++ b/appimage/docker/build-appimage.sh @@ -1,43 +1,50 @@ #!/bin/sh # Build an AppImage of gpg # Copyright (C) 2021 g10 Code GmbH # # Software engineering by Ingo Klöcker # # This file is part of GnuPG. # # GnuPG is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # GnuPG is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # SPDX-License-Identifier: GPL-3.0+ set -e mkdir -p /build/AppDir cd /src source /opt/rh/devtoolset-7/enable +# HACK disable "exit on error" for first make run because the released pinentry +# doesn't build with Qt 5.9 on CentOS 7 +set +e +make -f build-aux/speedo.mk INSTALL_PREFIX=/build/AppDir/usr CUSTOM_SWDB=1 appimage +set -e +# HACK patch pinentry and run make a second time +(cd PLAY/src/pinentry; patch -p1 <../../../0001-qt-Support-building-with-Qt-5.9.patch) make -f build-aux/speedo.mk INSTALL_PREFIX=/build/AppDir/usr CUSTOM_SWDB=1 appimage mkdir -p /build/download cd /build/download wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage wget https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage chmod +x linuxdeploy-* cd /build # extract the AppImages because we have no fuse in the container download/linuxdeploy-plugin-qt-x86_64.AppImage --appimage-extract download/linuxdeploy-x86_64.AppImage --appimage-extract export PATH=squashfs-root/usr/bin:$PATH export LD_LIBRARY_PATH=/build/AppDir/usr/lib linuxdeploy --appdir AppDir --desktop-file /src/appimage/appimage.desktop --icon-file /src/artwork/gnupg-lock-256x256tr.png --icon-filename gpg --plugin qt --output appimage