summaryrefslogtreecommitdiff
path: root/branding
diff options
context:
space:
mode:
Diffstat (limited to 'branding')
-rw-r--r--branding/README.rst2
-rwxr-xr-xbranding/templates/snap/generate.py17
-rwxr-xr-xbranding/templates/snap/local/pre/pack_installers29
3 files changed, 25 insertions, 23 deletions
diff --git a/branding/README.rst b/branding/README.rst
index d7bc385..e52160b 100644
--- a/branding/README.rst
+++ b/branding/README.rst
@@ -25,7 +25,7 @@ Package
NOTE: Some of the following scripts need network access, since they will check
whether the configuration published by your provider matches what is configured
-before the build.
+before the build. If you want to skip this check, pass `SKIP_CACHECK=yes`
Run::
diff --git a/branding/templates/snap/generate.py b/branding/templates/snap/generate.py
index b5ca641..e62b220 100755
--- a/branding/templates/snap/generate.py
+++ b/branding/templates/snap/generate.py
@@ -16,8 +16,14 @@ SNAPCRAFT = 'snapcraft.yaml'
here = os.path.split(os.path.realpath(__file__))[0]
data = json.load(open(os.path.join(here, 'data.json')))
+binaryName = data['binaryName']
+
DESKTOP_TEMPLATE = 'local/app.desktop'
-DESKTOP = 'local/{}.desktop'.format(data['binaryName'])
+DESKTOP = 'local/{}.desktop'.format(binaryName)
+
+POLKIT_TEMPLATE = 'local/pre/se.leap.bitmask.snap.policy'
+POLKIT_FILE = 'se.leap.bitmask.{}.policy'.format(binaryName)
+POLKIT = 'local/pre/' + POLKIT_FILE
template = Template(open(TEMPLATE).read())
with open(SNAPCRAFT, 'w') as output:
@@ -28,5 +34,14 @@ with open(DESKTOP, 'w') as output:
output.write(template.safe_substitute(data))
os.remove(DESKTOP_TEMPLATE)
+template = Template(open(POLKIT_TEMPLATE).read())
+with open(POLKIT, 'w') as output:
+ output.write(template.safe_substitute(data))
+os.remove(POLKIT_TEMPLATE)
+
+os.putenv('POLKIT_FILE', POLKIT_FILE)
+os.putenv('APP_NAME', binaryName)
+os.system('cd local/pre && ./pack_installers')
+
print("[+] Snapcraft spec written to {path}".format(
path=os.path.abspath(SNAPCRAFT)))
diff --git a/branding/templates/snap/local/pre/pack_installers b/branding/templates/snap/local/pre/pack_installers
index 9cf7b15..58134cc 100755
--- a/branding/templates/snap/local/pre/pack_installers
+++ b/branding/templates/snap/local/pre/pack_installers
@@ -3,33 +3,20 @@ 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/'
+HELPDIR = '../../../../../helpers'
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)
+POLKIT_FILE = os.environ.get('POLKIT_FILE')
+APP_NAME = os.environ.get('APP_NAME')
-with open(os.path.join(HELPDIR, POLKIT_FILE)) as polkit:
+with open(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('# for the ${applicationName} 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')
@@ -53,9 +40,9 @@ if 'ID=debian' in release:
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))
+ 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...")