Skip to content
Snippets Groups Projects
Unverified Commit 3120b855 authored by Kali Kaneko's avatar Kali Kaneko
Browse files

[pkg] add helpers to repo, generate hooks in snap

parent 4aa6fd41
Branches
Tags
1 merge request!80Feat/snap missing boiler
......@@ -138,10 +138,6 @@ TGZ_PATH = $(shell pwd)/build/${TGZ_NAME}
tgz:
@mkdir -p $(TGZ_PATH)
@git archive HEAD | tar -x -C $(TGZ_PATH)
-@mkdir -p $(TGZ_PATH)/helpers
@wget -O $(TGZ_PATH)/helpers/bitmask-root https://0xacab.org/leap/bitmask-dev/raw/master/src/leap/bitmask/vpn/helpers/linux/bitmask-root
@chmod +x $(TGZ_PATH)/helpers/bitmask-root
@wget -O $(TGZ_PATH)/helpers/se.leap.bitmask.policy https://0xacab.org/leap/bitmask-dev/raw/master/src/leap/bitmask/vpn/helpers/linux/se.leap.bitmask.policy
@cd build/ && tar cvzf bitmask-vpn_$(VERSION).tgz ${TGZ_NAME}
@rm -rf $(TGZ_PATH)
......@@ -170,10 +166,11 @@ endif
gen_pkg_snap:
@cp -r ${TEMPLATES}/snap build/${PROVIDER}
@VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} ${SCRIPTS}/generate-snap.py build/${PROVIDER}/snap/data.json
@cp helpers/se.leap.bitmask.snap.policy build/${PROVIDER}/snap/local/pre/
@cp helpers/bitmask-root build/${PROVIDER}/snap/local/pre/
@cd build/${PROVIDER}/snap && python3 generate.py
@rm build/${PROVIDER}/snap/data.json build/${PROVIDER}/snap/snapcraft-template.yaml
@mkdir -p build/${PROVIDER}/snap/gui && cp branding/assets/default/icon.svg build/${PROVIDER}/snap/gui/icon.svg
# TODO missing hooks
gen_pkg_deb:
@cp -r ${TEMPLATES}/debian build/${PROVIDER}
......
......@@ -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::
......
......@@ -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)))
......@@ -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...")
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<vendor>LEAP Encryption Access Project</vendor>
<vendor_url>http://leap.se/</vendor_url>
<action id="se.leap.bitmask.policy">
<description>Runs bitmask helper to launch firewall and openvpn</description>
<description xml:lang="es">Ejecuta el asistente de bitmask para lanzar el firewall y openvpn</description>
<message>Bitmask needs that you authenticate to start</message>
<message xml:lang="es">Bitmask necesita autorizacion para comenzar</message>
<icon_name>package-x-generic</icon_name>
<defaults>
<allow_any>yes</allow_any>
<allow_inactive>yes</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/sbin/bitmask-root</annotate>
</action>
</policyconfig>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<vendor>LEAP Encryption Access Project Project</vendor>
<vendor_url>http://leap.se/</vendor_url>
<action id="se.leap.bitmask.${applicationName}.policy">
<description>Runs bitmask helper to launch firewall and openvpn (${applicationName})</description>
<description xml:lang="es">Ejecuta el asistente de bitmask para lanzar el firewall y openvpn (${applicationName})</description>
<message>${applicationName} needs that you authenticate to start</message>
<message xml:lang="es">${applicationName} necesita autorizacion para comenzar</message>
<icon_name>package-x-generic</icon_name>
<defaults>
<allow_any>yes</allow_any>
<allow_inactive>yes</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/snap/bin/${binaryName}.bitmask-root</annotate>
</action>
</policyconfig>
// Code generated by go generate; DO NOT EDIT.
// This file was generated by vendorize.py
// At 2019-08-07 22:35:39
// At 2019-08-16 12:44:37
package config
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment