From 6c6c6bc62d6757bbf5b669386d815907eb369645 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Fri, 7 Oct 2022 15:44:12 -0700 Subject: [PATCH] More snapcraft troubleshooting (#1622) Finally got the snap to successfully run --- .github/workflows/build.yml | 36 ++++++++++++------------ .github/workflows/tests.yml | 4 +-- snap/snapcraft.yaml | 55 ++++++++++++++++++++++++++++++++----- 3 files changed, 68 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f6f4bec..0420b288 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -305,24 +305,6 @@ jobs: name: mac-build path: ~/onionshare-macos.tar.gz - # build-snap: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - - # - name: Install dependencies - # run: | - # sudo lxd init --auto - # sudo snap install snapcraft --classic - - # - name: Build snap - # run: sudo snapcraft --use-lxd - - # - uses: actions/upload-artifact@v3 - # with: - # name: snapcraft-build - # path: onionshare_*.snap - build-flatpak: runs-on: ubuntu-latest steps: @@ -356,3 +338,21 @@ jobs: with: name: flatpak-build path: ~/OnionShare.flatpak + + build-snap: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install dependencies + run: | + sudo lxd init --auto + sudo snap install snapcraft --classic + + - name: Build snap + run: sudo snapcraft --use-lxd + + - uses: actions/upload-artifact@v3 + with: + name: snapcraft-build + path: onionshare_*.snap diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0aa7108b..68ea4644 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.9' + python-version: "3.9" - name: Install dependencies run: | sudo apt-get update @@ -34,7 +34,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.9' + python-version: "3.9" - name: Install dependencies run: | sudo apt-get update diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 790acbe1..ffc56d6e 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -19,7 +19,7 @@ architectures: apps: onionshare: common-id: org.onionshare.OnionShare - command: bin/onionshare + command: bin/onionshare-launcher extensions: [gnome-3-38] plugs: - desktop @@ -32,7 +32,7 @@ apps: cli: common-id: org.onionshare.OnionShareCli - command: bin/onionshare-cli + command: bin/onionshare-cli-launcher plugs: - home - network @@ -42,12 +42,45 @@ apps: LANG: C.UTF-8 parts: + # Launcher scripts, in order to set PYTHONPATH + launcher: + plugin: nil + override-build: | + mkdir -p $SNAPCRAFT_PART_INSTALL/bin + + cat > $SNAPCRAFT_PART_INSTALL/bin/launcher-setup << EOF + #!/bin/sh + export PATH=\$SNAP/bin:\$SNAP/usr/bin:\$SNAP/usr/local/bin:\$PATH + export PYTHONPATH=\$SNAP/lib/python3.8/site-packages:\$SNAP/usr/lib/python3/dist-packages + export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$SNAP/usr/local/lib + ORIG_IFS=\$IFS + IFS=":" + LIB_BASE=\$(for D in \$LD_LIBRARY_PATH; do echo \$D; done | grep \$SNAP/usr/lib/) + IFS=\$ORIGIN_IFS + export QT_PLUGIN_PATH=\$LIB_BASE/qt5/plugins + EOF + + cat > $SNAPCRAFT_PART_INSTALL/bin/onionshare-launcher << EOF + #!/bin/sh + . \$SNAP/bin/launcher-setup + onionshare \$@ + EOF + + cat > $SNAPCRAFT_PART_INSTALL/bin/onionshare-cli-launcher << EOF + #!/bin/sh + . \$SNAP/bin/launcher-setup + onionshare-cli \$@ + EOF + + chmod 755 $SNAPCRAFT_PART_INSTALL/bin/launcher-setup + chmod 755 $SNAPCRAFT_PART_INSTALL/bin/onionshare-launcher + chmod 755 $SNAPCRAFT_PART_INSTALL/bin/onionshare-cli-launcher onionshare: source: ./desktop plugin: python - python-packages: - - qrcode - - pyside2 == 5.15.2.1 + build-environment: + - PATH: /usr/bin:$PATH + - PYTHONPATH: "" stage-packages: - libasound2 - libatk1.0-0 @@ -109,19 +142,28 @@ parts: - libxslt1.1 - libxtst6 - qtwayland5 + - python3-pyside2.qtcore + - python3-pyside2.qtgui + - python3-pyside2.qtwidgets override-build: | + python3 -m pip install qrcode --prefix $SNAPCRAFT_PART_INSTALL python3 setup.py install --prefix $SNAPCRAFT_PART_INSTALL after: [onionshare-cli] onionshare-cli: source: ./cli plugin: python + build-environment: + - PATH: /usr/bin:$PATH + - PYTHONPATH: "" build-packages: - build-essential - libssl-dev - libffi-dev - python3-dev - python3-pip + - rustc + - cargo override-build: | python3 -m pip install poetry python3 -m pip install setuptools @@ -136,8 +178,7 @@ parts: source-type: tar plugin: autotools autotools-configure-parameters: - - "--with-libevent-dir=/build/onionshare/parts/libevent/install/usr/local" - # - "--with-libevent-dir=/root/parts/libevent/install/usr/local" + - "--with-libevent-dir=$SNAPCRAFT_PROJECT_DIR/../parts/libevent/install/usr/local" build-packages: - libssl-dev - zlib1g-dev