From 3169015c5f5eaed5f2ad48e486b1fe96e1eb6bbe Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 3 Apr 2018 02:45:34 +0200 Subject: several fixes for riseupvpn snap - move snap folder to root folder, to allow automated builds - install only polkit file outside of snap - change path of bitmask-root accordingly in bitmask - fix check for polkit file inside snap - change and document the algorithm for picking bitmask-root in linux - add LD_LIBRARY_PATH as an environment entry for bitmask-systray --- pkg/riseupvpn/Makefile | 8 +-- pkg/riseupvpn/README.rst | 20 ++++--- pkg/riseupvpn/pack_installers | 34 ++++------- pkg/riseupvpn/snap/.snapcraft/state | 3 - pkg/riseupvpn/snap/gui/riseup-vpn.desktop | 15 ----- pkg/riseupvpn/snap/gui/riseupvpn.svg | 80 -------------------------- pkg/riseupvpn/snap/hooks/remove | 7 --- pkg/riseupvpn/snap/snapcraft.yaml | 94 ------------------------------- 8 files changed, 28 insertions(+), 233 deletions(-) delete mode 100644 pkg/riseupvpn/snap/.snapcraft/state delete mode 100644 pkg/riseupvpn/snap/gui/riseup-vpn.desktop delete mode 100644 pkg/riseupvpn/snap/gui/riseupvpn.svg delete mode 100755 pkg/riseupvpn/snap/hooks/remove delete mode 100644 pkg/riseupvpn/snap/snapcraft.yaml (limited to 'pkg') diff --git a/pkg/riseupvpn/Makefile b/pkg/riseupvpn/Makefile index 58079cc6..6c0e5855 100644 --- a/pkg/riseupvpn/Makefile +++ b/pkg/riseupvpn/Makefile @@ -3,13 +3,13 @@ # We have to use classic confinement because it does not seem to be another way, at the moment, # to use policykit. -build: helpers - # for speeding up build, see https://tribaal.io/making-lxd-fly-on-ubuntu-as-well.html - sudo snapcraft cleanbuild helpers: ./pack_installers +build: helpers + # for speeding up build, see https://tribaal.io/making-lxd-fly-on-ubuntu-as-well.html + cd ../.. && sudo snapcraft cleanbuild install: - sudo snap install riseup-vpn_*.snap --dangerous --classic + cd ../.. && sudo snap install riseup-vpn_*.snap --dangerous --classic uninstall: sudo snap remove riseup-vpn deps: diff --git a/pkg/riseupvpn/README.rst b/pkg/riseupvpn/README.rst index 085ffe39..29ced8f9 100644 --- a/pkg/riseupvpn/README.rst +++ b/pkg/riseupvpn/README.rst @@ -12,21 +12,25 @@ minimalistic systray written in golang https://0xacab.org/leap/bitmask-systray that makes use of libappindicator for displaying notifications. Currently, RiseupVPN is distributed as a snap package. It uses classic -confinement because it needs to install bitmask-root in the system, and a -polkit policy file so that bitmask-root and openvpn can be executed without -asking user for permission each time. +confinement because it needs to install a polkit policy file so that +bitmask-root and openvpn can be executed without asking user for permission +each time. Usage ----- -Until the snap package gets approved in the snap store, you can use the snap as follows:: +You can get the snap from the store:: - wget https://downloads.leap.se/RiseupVPN/linux/riseup-vpn_0.10.4_amd64.snap sudo apt install snapd - sudo snap install riseup-vpn_0.10.4_amd64.snap --dangerous --classic + sudo snap install riseup-vpn --classic -That should have made a new application called RiseupVPN in your launchers. -You can also launch it manually like this:: +If you want to build the local snap:: + + make build + sudo snap install riseup-vpn_*.snap --classic + +That should have added a new application called RiseupVPN in your desktop +launchers. You can also launch it manually like this:: /snap/bin/riseup-vpn.launcher diff --git a/pkg/riseupvpn/pack_installers b/pkg/riseupvpn/pack_installers index eb3a08bb..629e4157 100755 --- a/pkg/riseupvpn/pack_installers +++ b/pkg/riseupvpn/pack_installers @@ -1,37 +1,27 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os import subprocess from base64 import encodestring as encode HELPDIR = '../../src/leap/bitmask/vpn/helpers/linux/' -INSTALL = './snap/hooks/install' +INSTALL = '../../snap/hooks/install' +POLKIT_FILE = 'se.leap.bitmask.riseupvpn.policy' -with open(os.path.join(HELPDIR, 'bitmask-root')) as bmroot: - b64_bmroot = encode(bmroot.read()) - -with open(os.path.join(HELPDIR, 'se.leap.bitmask.bundle.policy')) as polkit: - b64_polkit = encode(polkit.read()) +with open(os.path.join(HELPDIR, POLKIT_FILE)) as polkit: + b64_polkit = encode(polkit.read().encode()) with open(INSTALL, 'w') as install: - install.write('#!/usr/bin/env python\n') + install.write('#!/usr/bin/env python3\n') install.write('# This helper installs bitmask-root and polkit policy file\n') install.write('import subprocess\n') install.write('from base64 import decodestring as decode\n') install.write(""" -BMROOT = \"\"\"{bmroot}\"\"\" -POLKIT = \"\"\"{polkit}\"\"\" -BMROOT_DEST = "/usr/local/sbin/bitmask-root" -with open(BMROOT_DEST, "w") as bmroot: - lines = str(decode(BMROOT)).split("\\n") - for i, line in enumerate(lines): - bmroot.write(line) - if i + 1 != len(lines): - bmroot.write("\\n") -with open('/usr/share/polkit-1/actions/se.leap.bitmask.bundle.policy', 'w') as polkit: - lines = str(decode(POLKIT)).split("\\n") +POLKIT = {polkit} + +with open('/usr/share/polkit-1/actions/{polkit_file}', 'w') as polkit: + lines = decode(POLKIT).split(b"\\n") for line in lines: - polkit.write(line + "\\n") -""".format(bmroot=b64_bmroot, polkit=b64_polkit)) - install.write('subprocess.Popen(["chmod", "+x", BMROOT_DEST])\n') + polkit.write(line.decode() + "\\n") +""".format(polkit=b64_polkit, polkit_file=POLKIT_FILE)) subprocess.Popen(["chmod", "+x", INSTALL]) print("done packing installers into the snap install hook...") diff --git a/pkg/riseupvpn/snap/.snapcraft/state b/pkg/riseupvpn/snap/.snapcraft/state deleted file mode 100644 index 34977889..00000000 --- a/pkg/riseupvpn/snap/.snapcraft/state +++ /dev/null @@ -1,3 +0,0 @@ -!GlobalState -assets: - build-packages: [] diff --git a/pkg/riseupvpn/snap/gui/riseup-vpn.desktop b/pkg/riseupvpn/snap/gui/riseup-vpn.desktop deleted file mode 100644 index e325b204..00000000 --- a/pkg/riseupvpn/snap/gui/riseup-vpn.desktop +++ /dev/null @@ -1,15 +0,0 @@ -[Desktop Entry] -Version=1.0 -Type=Application -Name=RiseupVPN -Comment=Anonymous VPN -Comment[es]=VPN Anonima -Comment[de]=Anonymous VPN -Path=/snap/bin -Exec=riseup-vpn.launcher -Terminal=false -Icon=/snap/riseup-vpn/current/snap/gui/riseupvpn.svg -Categories=Network;Application; -StartupNotify=true -Keywords=VPN;riseup;leap - diff --git a/pkg/riseupvpn/snap/gui/riseupvpn.svg b/pkg/riseupvpn/snap/gui/riseupvpn.svg deleted file mode 100644 index a19c6c61..00000000 --- a/pkg/riseupvpn/snap/gui/riseupvpn.svg +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/pkg/riseupvpn/snap/hooks/remove b/pkg/riseupvpn/snap/hooks/remove deleted file mode 100755 index c7442a26..00000000 --- a/pkg/riseupvpn/snap/hooks/remove +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -e - -echo "Executing remove hook for RiseupVPN" -rm "/usr/local/sbin/bitmask-root" -rm "/usr/share/polkit-1/actions/se.leap.bitmask.bundle.policy" -echo "done" diff --git a/pkg/riseupvpn/snap/snapcraft.yaml b/pkg/riseupvpn/snap/snapcraft.yaml deleted file mode 100644 index 064a48ae..00000000 --- a/pkg/riseupvpn/snap/snapcraft.yaml +++ /dev/null @@ -1,94 +0,0 @@ -name: riseup-vpn -version: '0.10.4' -epoch: 0 -summary: RiseupVPN, anonymous VPN. Powered by Bitmask. -description: | - RiseupVPN is an easy, fast, and secure VPN service from riseup.net. - RiseupVPN does not require a user account, keep logs, or track you in - any way. The service is paid for entirely by donations from users like - you. - -grade: stable # must be 'stable' to release into candidate/stable channels. switch to devel in snap branch. -confinement: classic -icon: snap/gui/riseupvpn.svg - -parts: - - bitmask: - plugin: python - python-version: python2 - source-branch: master - source: https://0xacab.org/leap/bitmask-dev.git - requirements: pkg/requirements-vpn.pip - stage-packages: - # this seems to trigger https://bugs.launchpad.net/snapcraft/+bug/1676684 - - python2.7-dev - - libsqlcipher-dev - - libffi-dev - - libsqlite3-dev - - libzmq3-dev - prime: - - -usr/include - - -usr/lib/locale - - -usr/share/X11/locale - - -usr/share/doc - - -usr/share/locale - - -usr/share/man - #- -usr/share/icons - openvpn: - plugin: nil - stage-packages: - - openvpn - prime: - - -usr/share/doc - - -usr/share/man - bitmask-systray: - plugin: go - source: https://0xacab.org/leap/bitmask-systray.git - build-packages: - - pkg-config - - patchelf - - libzmq5 - - libzmq3-dev - - libsodium-dev - - libappindicator3-dev - - libgtk-3-dev - stage-packages: - - libzmq5 - - libsodium18 - - libappindicator3-1 - install: | - TRIPLET_PATH="$SNAPCRAFT_PART_INSTALL/usr/lib/$(gcc -print-multiarch)" - LIBZMQ=$(readlink -n $TRIPLET_PATH/libzmq.so.5) - LIBSOD=$(readlink -n $TRIPLET_PATH/libsodium.so.18) - ln -s "../usr/lib/$(gcc -print-multiarch)/$LIBZMQ" $SNAPCRAFT_PART_INSTALL/bin/libzmq.so.5 - ln -s "../usr/lib/$(gcc -print-multiarch)/$LIBSOD" $SNAPCRAFT_PART_INSTALL/bin/libsodium.so.18 - patchelf --set-rpath /snap/riseup-vpn/current/bin/ $SNAPCRAFT_PART_INSTALL/bin/bitmask-systray.git - prime: - - -usr/include - - -usr/lib/locale - - -usr/share/X11/locale - - -usr/share/doc - - -usr/share/locale - - -usr/share/man - #- -usr/share/icons - desktop-gtk3: - prime: - - -usr/include - - -usr/lib/locale - - -usr/share/X11/locale - - -usr/share/doc - - -usr/share/locale - - -usr/share/man - #- -usr/share/icons - - '*' - -apps: - launcher: - command: ./bin/bitmask_anonvpn - openvpn: - command: ./usr/sbin/openvpn - bitmaskd: - command: ./bin/bitmaskd - bitmask-systray: - command: ./bin/bitmask-systray.git -- cgit v1.2.3