summaryrefslogtreecommitdiff
path: root/branding/templates/snap
diff options
context:
space:
mode:
Diffstat (limited to 'branding/templates/snap')
-rw-r--r--branding/templates/snap/docs/launchpad.rst13
-rw-r--r--branding/templates/snap/docs/release.rst59
-rwxr-xr-xbranding/templates/snap/generate.py9
-rwxr-xr-xbranding/templates/snap/hooks/install26
-rwxr-xr-xbranding/templates/snap/hooks/remove6
-rw-r--r--branding/templates/snap/local/app.desktop15
-rwxr-xr-xbranding/templates/snap/local/pre/pack_installers61
-rw-r--r--branding/templates/snap/snapcraft-template.yaml9
8 files changed, 193 insertions, 5 deletions
diff --git a/branding/templates/snap/docs/launchpad.rst b/branding/templates/snap/docs/launchpad.rst
new file mode 100644
index 0000000..0a614f6
--- /dev/null
+++ b/branding/templates/snap/docs/launchpad.rst
@@ -0,0 +1,13 @@
+launchpad
+=========
+In launchpad, you need to configure a git source for your project, and define a snap recipe for that source.
+
+Be warned that launchpad does an automatic import every 6 hours.
+
+If you need to do manual builds, you first need to trigger an import. Look for the "import now" button in your source page:
+
+https://code.launchpad.net/~leapsnaps/riseupvpn/+git/riseup_vpn
+
+Then you can trigger a manual build:
+
+https://code.launchpad.net/~leapsnaps/+snap/riseup-vpn/+request-builds
diff --git a/branding/templates/snap/docs/release.rst b/branding/templates/snap/docs/release.rst
new file mode 100644
index 0000000..5211aea
--- /dev/null
+++ b/branding/templates/snap/docs/release.rst
@@ -0,0 +1,59 @@
+Automatic builds (snap)
+~~~~~~~~~~~~~~~~~~~~~~~
+Gitlab builds snap for amd64 for every push to master in bitmask-systray.
+
+Launchpad does up 4 daily builds if code is modified in bitmask-dev repo. We're
+building for amd64 and i386. They are pushed to beta channel in the snap store.
+If you need to force a build, trigger it by editing the version string in the
+snapcraft.yaml file.
+
+Releasing snaps
+----------------
+
+From the snap dashboard, you can see the revisions that are built.
+By default, we have riseupvpn-builds configured to upload builds to beta and
+edge channels. If you are going to be pushing to edge manually regularly,
+please configure the automated builds to push just to beta for some time and
+push your builds to edge channel.
+
+To publish a snap, click on "release" from the dashboard, and assign a channel to them.
+
+By convention, if you release to a channel, please release the revision to all
+the lower channels too. (For example, if you release a particular revision to
+"candidate", release it also to "beta" and "edge").
+
+Do note that the automated builds for different architectures do have different revision
+numbers, so when releasing you have to repeat the steps for each platform that
+we're building for.
+
+From the command line:
+
+ snapcraft login
+ snapcraft status riseup-vpn
+
+ # if we've built a release manually, we have to push it first. it gives us a
+ # revision number that we use in the next step.
+
+ snapcraft push riseup-vpn_0.10.6+git_amd64.snap
+ Preparing to push '/home/kali/leap/bitmask-dev/riseup-vpn_0.10.6+git_amd64.snap' to the store.
+ Found cached source snap /home/kali/.cache/snapcraft/projects/riseup-vpn/snap_hashes/amd64/b5e9d106c823e3c83fce1ef81ad95d68c33fcada859eeb98233fc766863d39205c192fe5ee53def71c43886e40d3ab5b.
+ Generating xdelta3 delta for riseup-vpn_0.10.6+git_amd64.snap.
+ Pushing delta /home/kali/leap/bitmask-dev/riseup-vpn_0.10.6+git_amd64.snap.xdelta3.
+ Pushing riseup-vpn_0.10.6+git_amd64.snap.xdelta3 [=================================================] 100%
+ Processing...|
+ Ready to release!
+ Revision 20 of 'riseup-vpn' created.
+
+ # otherwise I assume that you're just trying to release something
+ # that was already built and automatically uploaded.
+
+ # let's publish amd64 to candidate channel and the channels below
+ snapcraft release riseupv-vpn 20 candidate
+ snapcraft release riseupv-vpn 20 beta
+ snapcraft release riseupv-vpn 20 edge
+
+ # and now the i386 build
+ snapcraft release riseupv-vpn 19 candidate
+ snapcraft release riseupv-vpn 19 beta
+ snapcraft release riseupv-vpn 19 edge
+
diff --git a/branding/templates/snap/generate.py b/branding/templates/snap/generate.py
index 41d563d..b5ca641 100755
--- a/branding/templates/snap/generate.py
+++ b/branding/templates/snap/generate.py
@@ -13,15 +13,20 @@ from string import Template
TEMPLATE = 'snapcraft-template.yaml'
SNAPCRAFT = 'snapcraft.yaml'
-
here = os.path.split(os.path.realpath(__file__))[0]
data = json.load(open(os.path.join(here, 'data.json')))
+DESKTOP_TEMPLATE = 'local/app.desktop'
+DESKTOP = 'local/{}.desktop'.format(data['binaryName'])
template = Template(open(TEMPLATE).read())
-
with open(SNAPCRAFT, 'w') as output:
output.write(template.safe_substitute(data))
+template = Template(open(DESKTOP_TEMPLATE).read())
+with open(DESKTOP, 'w') as output:
+ output.write(template.safe_substitute(data))
+os.remove(DESKTOP_TEMPLATE)
+
print("[+] Snapcraft spec written to {path}".format(
path=os.path.abspath(SNAPCRAFT)))
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"
diff --git a/branding/templates/snap/local/app.desktop b/branding/templates/snap/local/app.desktop
new file mode 100644
index 0000000..7598fea
--- /dev/null
+++ b/branding/templates/snap/local/app.desktop
@@ -0,0 +1,15 @@
+[Desktop Entry]
+Version=1.0
+Type=Application
+Name=${applicationName}
+Comment=Anonymous VPN
+Comment[es]=VPN Anonima
+Comment[de]=Anonymous VPN
+Path=/snap/bin/
+Exec="/snap/bin/${binaryName}.launcher"
+Terminal=false
+Icon=/snap/${binaryName}/current/meta/gui/icon.svg
+Categories=Network;Application;
+StartupNotify=true
+Keywords=VPN;${name};leap
+
diff --git a/branding/templates/snap/local/pre/pack_installers b/branding/templates/snap/local/pre/pack_installers
new file mode 100755
index 0000000..9cf7b15
--- /dev/null
+++ b/branding/templates/snap/local/pre/pack_installers
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+import os
+import subprocess
+from base64 import encodestring as encode
+
+# we expect to find bitmask-dev cloned in the parent folder for this repo
+# we will clone it if not
+PARENT = '../../'
+BITMASK_FOLDER = PARENT + 'bitmask-dev/'
+BITMASK_GIT = 'https://0xacab.org/leap/bitmask-dev'
+HELPDIR = BITMASK_FOLDER + 'src/leap/bitmask/vpn/helpers/linux/'
+INSTALL = 'hooks/install'
+POLKIT_FILE = 'se.leap.bitmask.riseupvpn.policy'
+APP_NAME = 'riseup-vpn'
+
+if not os.path.isdir(BITMASK_FOLDER):
+ print('[+] Cloning bitmask-dev repo to get helpers...')
+ cmd = 'cd ../.. && git clone %s' % (BITMASK_GIT, )
+ os.system(cmd)
+else:
+ print('[+] Updating bitmask-dev repo to get helpers...')
+ cmd = 'cd ' + BITMASK_FOLDER + ' && git pull'
+ os.system(cmd)
+
+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 python3\n')
+ install.write('# DO NOT MODIFY MANUALLY\n')
+ install.write('# This helper installs the polkit policy file\n')
+ install.write('# for the RiseupVPN snap.\n')
+ install.write('# It is generated automatically\n')
+ install.write('# by the script at "snap/local/pre/pack_installers"\n')
+ install.write('import subprocess\n')
+ install.write('import os\n')
+ install.write('from base64 import decodestring as decode\n')
+ install.write("""
+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.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/{app_name}.desktop"
+ if os.path.exists(desktop_path):
+ os.remove(desktop_path)
+ os.symlink("/snap/{app_name}/current/snap/meta/gui/{app_name}.desktop", desktop_path)
+ subprocess.call(['update-desktop-database'])
+""".format(
+ polkit=b64_polkit,
+ polkit_file=POLKIT_FILE,
+ app_name=APP_NAME))
+
+subprocess.Popen(["chmod", "+x", INSTALL])
+print("[+] Done packing installers into the snap install hook...")
diff --git a/branding/templates/snap/snapcraft-template.yaml b/branding/templates/snap/snapcraft-template.yaml
index df9c135..8039a4a 100644
--- a/branding/templates/snap/snapcraft-template.yaml
+++ b/branding/templates/snap/snapcraft-template.yaml
@@ -51,12 +51,15 @@ parts:
after: [desktop-gtk3]
plugin: go
source-type: git
- go-packages:
- - 0xacab.org/leap/bitmask-vpn/cmd/bitmask-vpn
+ source: https://0xacab.org/leap/bitmask-vpn
+ # this does not seem to work with snapcraft package version in bionic
+ #go-packages:
+ # - 0xacab.org/leap/bitmask-vpn/cmd/bitmask-vpn
override-build: |
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
#cat $SNAPCRAFT_PROJECT_DIR/snap/local/bitmask-vpn.desktop
- cp ../../../gui/bitmask-vpn.desktop $SNAPCRAFT_PRIME/${binaryName}.desktop
+ cp $SNAPCRAFT_STAGE/../snap/local/${binaryName}.desktop $SNAPCRAFT_PRIME/${binaryName}.desktop
+ #cp ../../../gui/bitmask-vpn.desktop $SNAPCRAFT_PRIME/${binaryName}.desktop
snapcraftctl build
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
build-packages: