blob: d7692fa2764837dab531a168673742ad917c7539 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/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'
POLKIT_FILE = 'se.leap.bitmask.riseupvpn.policy'
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 "pkg/riseupvpn/pack_installers" \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")
""".format(polkit=b64_polkit, polkit_file=POLKIT_FILE))
subprocess.Popen(["chmod", "+x", INSTALL])
print("done packing installers into the snap install hook...")
|