From c30b5475e798e4ab0dbdec226cd2cd8707c42f72 Mon Sep 17 00:00:00 2001 From: Siddarth Kumar Date: Tue, 25 Feb 2025 17:13:26 +0530 Subject: [PATCH] feat(keycard): use bundled pcscd and psclite --- AppRun | 13 +++++++++++++ Makefile | 1 + ci/Dockerfile | 26 +++++++++++++++++++++++++- ci/Jenkinsfile.linux | 2 +- scripts/init_app_dir.sh | 21 ++++++++++++++++++++- 5 files changed, 60 insertions(+), 3 deletions(-) diff --git a/AppRun b/AppRun index 87a2f47c8d..306e0cb3c1 100755 --- a/AppRun +++ b/AppRun @@ -11,6 +11,19 @@ export QT_QPA_PLATFORM="xcb" # Fixing bug: https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1944468 export QTWEBENGINE_CHROMIUM_FLAGS="${QTWEBENGINE_CHROMIUM_FLAGS} --disable-seccomp-filter-sandbox" +# Set up pcsc-lite environment +export PCSC_DRIVERS_DIR="${APPDIR}/usr/lib/pcsc/drivers" +export PCSCLITE_CONFIG_DIR="${APPDIR}/etc/reader.conf.d" + +# Start pcscd +# warning: needs to be same as ipcdir in ci/Dockerfile +# https://salsa.debian.org/rousseau/PCSC/-/blob/master/meson.options?ref_type=heads#L36 +PCSCD_RUN_DIR="/tmp/pcscd/run" +rm -rf "${PCSCD_RUN_DIR}" +mkdir -p "${PCSCD_RUN_DIR}" +echo "starting pcscd with ${APPDIR}/usr/bin/pcscd -f &" +"${APPDIR}/usr/bin/pcscd" -f & + DEFAULT_LANG=en_US.UTF-8 if [[ "$LANG" == "C.UTF-8" ]] then diff --git a/Makefile b/Makefile index 423be58998..f081d5f2d6 100644 --- a/Makefile +++ b/Makefile @@ -648,6 +648,7 @@ $(STATUS_CLIENT_APPIMAGE): nim_status_client $(APPIMAGE_TOOL) nim-status.desktop -bundle-non-qt-libs \ -exclude-libs=libgmodule-2.0.so.0,libgthread-2.0.so.0 \ -verbose=1 \ + -executable=$(APP_DIR)/usr/bin/pcscd \ -executable=$(APP_DIR)/usr/libexec/QtWebEngineProcess scripts/fix_app_dir.sh diff --git a/ci/Dockerfile b/ci/Dockerfile index fcc1893ac7..ff9f7f3def 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -22,6 +22,7 @@ FROM ubuntu:20.04 ARG LINUXDEPLOYQT_VERSION=20230423-8428c59 ARG QT_VERSION +ARG PCSCLITE_VERSION=2.2.3 # Adapted from a12e/docker-qt by Aurélien Brooke @@ -45,18 +46,41 @@ RUN apt update -yq && apt install -yq software-properties-common \ git make build-essential pkg-config extra-cmake-modules gcc-9 g++-9 \ libgl1-mesa-dev libsm6 libice6 libfontconfig1 libdbus-1-3 libssl-dev libz-dev \ zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev unixodbc-dev libpq-dev \ - libncurses5-dev libncursesw5-dev libpcsclite-dev libpcre3-dev libnss3 \ + libncurses5-dev libncursesw5-dev libpcre3-dev libnss3 \ gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \ gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-alsa libpulse-mainloop-glib0 \ gstreamer1.0-pulseaudio libgstreamer-plugins-base1.0-0 \ libxext6 libxrender1 libxkbcommon-dev libxkbcommon-x11-dev libxcomposite1 libxtst6 \ libxrandr2 libxcursor1 libxi6 libxcb-randr0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 \ libxcb-render-util0 libxcb-shape0 libxcb-render0 libxcb-xinerama0 \ + autoconf automake libtool gcc \ && update-alternatives \ --install /usr/bin/gcc gcc /usr/bin/gcc-9 100 \ --slave /usr/bin/g++ g++ /usr/bin/g++-9 \ && apt-get -qq clean +# To fix: https://github.com/status-im/status-desktop/issues/16768 +# https://blog.apdu.fr/posts/2024/05/pcsc-lite-now-uses-meson-build-tool/ +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential debhelper dpkg-dev libudev-dev libusb-1.0-0-dev pkg-config flex libsystemd-dev check git wget \ + meson ninja-build libglib2.0-dev libexpat1-dev python3-pip \ + && cd /tmp \ + && wget https://pcsclite.apdu.fr/files/pcsc-lite-${PCSCLITE_VERSION}.tar.xz \ + && tar -xJf pcsc-lite-${PCSCLITE_VERSION}.tar.xz \ + && cd pcsc-lite-${PCSCLITE_VERSION} \ + && meson setup builddir \ + -Dpolkit=false \ + -Dsystemd=false \ + -Dserial=false \ + -Dipcdir=/tmp/pcscd/run \ + && cd builddir \ + && ninja \ + && ninja install \ + && ldconfig \ + && cd / \ + && rm -rf /tmp/pcsc-lite* \ + && apt-get -qq clean + # Install linuxdeployqt RUN mkdir -p /usr/local/bin \ && curl -Lo/usr/local/bin/linuxdeployqt "https://status-misc.ams3.digitaloceanspaces.com/desktop/linuxdeployqt-${LINUXDEPLOYQT_VERSION}-x86_64.AppImage" \ diff --git a/ci/Jenkinsfile.linux b/ci/Jenkinsfile.linux index 6ff84a161a..95f0808aca 100644 --- a/ci/Jenkinsfile.linux +++ b/ci/Jenkinsfile.linux @@ -10,7 +10,7 @@ pipeline { /* Necessary image with Ubuntu 20.04 for older Glibc. */ docker { label 'linux' - image 'statusteam/nim-status-client-build:1.6.1-qt5.15.2' + image 'statusteam/nim-status-client-build:1.6.3-qt5.15.2' /* allows jenkins use cat and mounts '/dev/fuse' for linuxdeployqt */ args '--entrypoint="" --cap-add SYS_ADMIN --security-opt apparmor:unconfined --device /dev/fuse' } diff --git a/scripts/init_app_dir.sh b/scripts/init_app_dir.sh index 6711a93479..0ff5e06fe6 100755 --- a/scripts/init_app_dir.sh +++ b/scripts/init_app_dir.sh @@ -9,7 +9,10 @@ mkdir -p \ "${APP_DIR}/usr/lib" \ "${APP_DIR}/usr/qml" \ "${APP_DIR}/usr/i18n" \ - "${APP_DIR}/usr/plugins/platforminputcontexts" + "${APP_DIR}/usr/plugins/platforminputcontexts" \ + "${APP_DIR}/etc/reader.conf.d" \ + "${APP_DIR}/usr/lib/pcsc/drivers" \ + "${APP_DIR}/usr/bin" cp bin/nim_status_client "${APP_DIR}/usr/bin" cp bin/StatusQ/* "${APP_DIR}/usr/lib" @@ -29,6 +32,20 @@ if [[ -z "${IN_NIX_SHELL}" ]]; then cp -P /usr/lib/x86_64-linux-gnu/libgst* "${APP_DIR}/usr/lib/" cp -r /usr/lib/x86_64-linux-gnu/gstreamer-1.0 "${APP_DIR}/usr/lib/" cp -r /usr/lib/x86_64-linux-gnu/gstreamer1.0 "${APP_DIR}/usr/lib/" + + echo "Bundling pcsc-lite 2.2.3..." + cp -L /usr/local/lib/x86_64-linux-gnu/libpcsclite.so* "${APP_DIR}/usr/lib/" + cp -L /usr/local/lib/x86_64-linux-gnu/libpcsclite_real.so* "${APP_DIR}/usr/lib/" + cp -L /usr/local/lib/x86_64-linux-gnu/pkgconfig/libpcsclite.pc "${APP_DIR}/usr/lib/" + + chmod 755 "${APP_DIR}/usr/lib/libpcsclite.so"* + chmod 755 "${APP_DIR}/usr/lib/libpcsclite_real.so"* + chmod 755 "${APP_DIR}/usr/lib/libpcsclite.pc" + + echo "Bundling pcscd..." + cp -L "/usr/local/sbin/pcscd"* "${APP_DIR}/usr/bin/" + chmod 755 "${APP_DIR}/usr/bin/pcscd"* + else mkdir -p "${APP_DIR}"/usr/lib/{gstreamer1.0,gstreamer-1.0,nss} mkdir -p "${APP_DIR}"/usr/libexec @@ -41,5 +58,7 @@ else cp "${QTWEBENGINE_PATH}"/resources/* "${APP_DIR}/usr/libexec/" cp -r "${QTWEBENGINE_PATH}/translations/qtwebengine_locales" "${APP_DIR}/usr/libexec/" + #TODO: bundle pcsc-lite and pcscd in nix-shell + chmod -R u+w "${APP_DIR}/usr" fi