summaryrefslogtreecommitdiff
path: root/branding/templates/snap/generate.py
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2019-08-16 12:50:45 +0200
committerKali Kaneko (leap communications) <kali@leap.se>2019-08-16 12:58:00 +0200
commit3120b855ac31158a52c9263f522615b4c3a0aa20 (patch)
tree624837ece395e563286a54cbb050f4f21ae48cd2 /branding/templates/snap/generate.py
parent4aa6fd4109aa9e92a1ade72885d7c99effcd7c76 (diff)
[pkg] add helpers to repo, generate hooks in snap
Diffstat (limited to 'branding/templates/snap/generate.py')
-rwxr-xr-xbranding/templates/snap/generate.py17
1 files changed, 16 insertions, 1 deletions
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)))