diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2019-08-07 22:49:24 +0200 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2019-08-07 23:03:45 +0200 |
commit | dbe330b8796ca9f403b5d5fe2133726ba504a803 (patch) | |
tree | a7b0ff095ebf574239719b316af0b204fad0b312 /branding/templates/snap/hooks | |
parent | cefd0857d1f6d798fedd2e6495a026d0b1de936b (diff) |
[pkg] missing snap boilerplate
Diffstat (limited to 'branding/templates/snap/hooks')
-rwxr-xr-x | branding/templates/snap/hooks/install | 26 | ||||
-rwxr-xr-x | branding/templates/snap/hooks/remove | 6 |
2 files changed, 32 insertions, 0 deletions
diff --git a/branding/templates/snap/hooks/install b/branding/templates/snap/hooks/install new file mode 100755 index 0000000..c34abf4 --- /dev/null +++ b/branding/templates/snap/hooks/install @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# DO NOT MODIFY MANUALLY +# This helper installs the polkit policy file +# for the RiseupVPN snap. +# It is generated automatically +# by the script at "snap/pre/pack_installers" +import subprocess +import os +from base64 import decodestring as decode + +POLKIT = b'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBvbGljeWNv\nbmZpZyBQVUJMSUMKICItLy9mcmVlZGVza3RvcC8vRFREIFBvbGljeUtpdCBQb2xpY3kgQ29uZmln\ndXJhdGlvbiAxLjAvL0VOIgogImh0dHA6Ly93d3cuZnJlZWRlc2t0b3Aub3JnL3N0YW5kYXJkcy9Q\nb2xpY3lLaXQvMS9wb2xpY3ljb25maWcuZHRkIj4KPHBvbGljeWNvbmZpZz4KCiAgPHZlbmRvcj5M\nRUFQIFByb2plY3Q8L3ZlbmRvcj4KICA8dmVuZG9yX3VybD5odHRwOi8vbGVhcC5zZS88L3ZlbmRv\ncl91cmw+CgogIDxhY3Rpb24gaWQ9InNlLmxlYXAuYml0bWFzay5yaXNldXB2cG4ucG9saWN5Ij4K\nICAgIDxkZXNjcmlwdGlvbj5SdW5zIGJpdG1hc2sgaGVscGVyIHRvIGxhdW5jaCBmaXJld2FsbCBh\nbmQgb3BlbnZwbiAoUmlzZXVwVlBOKTwvZGVzY3JpcHRpb24+CiAgICA8ZGVzY3JpcHRpb24geG1s\nOmxhbmc9ImVzIj5FamVjdXRhIGVsIGFzaXN0ZW50ZSBkZSBiaXRtYXNrIHBhcmEgbGFuemFyIGVs\nIGZpcmV3YWxsIHkgb3BlbnZwbiAoUmlzZXVwVlBOKTwvZGVzY3JpcHRpb24+CiAgICA8bWVzc2Fn\nZT5SaXNldXBWUE4gbmVlZHMgdGhhdCB5b3UgYXV0aGVudGljYXRlIHRvIHN0YXJ0PC9tZXNzYWdl\nPgogICAgPG1lc3NhZ2UgeG1sOmxhbmc9ImVzIj5SaXNldXBWUE4gbmVjZXNpdGEgYXV0b3JpemFj\naW9uIHBhcmEgY29tZW56YXI8L21lc3NhZ2U+CiAgICA8aWNvbl9uYW1lPnBhY2thZ2UteC1nZW5l\ncmljPC9pY29uX25hbWU+IAogICAgPGRlZmF1bHRzPgogICAgICA8YWxsb3dfYW55PnllczwvYWxs\nb3dfYW55PgogICAgICA8YWxsb3dfaW5hY3RpdmU+eWVzPC9hbGxvd19pbmFjdGl2ZT4KICAgICAg\nPGFsbG93X2FjdGl2ZT55ZXM8L2FsbG93X2FjdGl2ZT4KICAgIDwvZGVmYXVsdHM+CiAgICA8YW5u\nb3RhdGUga2V5PSJvcmcuZnJlZWRlc2t0b3AucG9saWN5a2l0LmV4ZWMucGF0aCI+L3NuYXAvYmlu\nL3Jpc2V1cC12cG4uYml0bWFzay1yb290PC9hbm5vdGF0ZT4KICA8L2FjdGlvbj4KPC9wb2xpY3lj\nb25maWc+Cg==\n' + +with open('/usr/share/polkit-1/actions/se.leap.bitmask.riseupvpn.policy', 'w') as polkit: + lines = decode(POLKIT).split(b"\n") + for line in lines: + polkit.write(line.decode() + "\n") + +with open('/etc/os-release') as f: + release = f.read() +# this is a workaround for the fact that debian does not place snap desktop entries in a system+wide path. +if 'ID=debian' in release: + desktop_path = "/usr/share/applications/riseup-vpn.desktop" + if os.path.exists(desktop_path): + os.remove(desktop_path) + os.symlink("/snap/riseup-vpn/current/snap/meta/gui/riseup-vpn.desktop", desktop_path) + subprocess.call(['update-desktop-database']) diff --git a/branding/templates/snap/hooks/remove b/branding/templates/snap/hooks/remove new file mode 100755 index 0000000..fd27b85 --- /dev/null +++ b/branding/templates/snap/hooks/remove @@ -0,0 +1,6 @@ +#!/bin/sh + +echo "Executing remove hook for RiseupVPN" +rm "/usr/share/polkit-1/actions/se.leap.bitmask.riseupvpn.policy" +unlink "/usr/share/applications/riseup-vpn.desktop" || echo "did not remove workaround for global desktop entry" +echo "done" |