summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2019-07-24 22:25:38 +0200
committerRuben Pollan <meskio@sindominio.net>2019-08-05 11:46:19 -0400
commite709b4209e710eb1bb5e7facff73f72adae66d65 (patch)
tree913005efa1d1adf763b5f499a689c71cb40316f4
parentba05fbef8501d4dc09c1d41051ca1e820d25bf1d (diff)
[pkg] snap template
-rw-r--r--Makefile17
-rwxr-xr-xbranding/scripts/generate-snap.py43
-rwxr-xr-xbranding/templates/snap/generate.py27
-rw-r--r--branding/templates/snap/snapcraft-template.yaml83
4 files changed, 164 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 5e92a21..3c9e5fc 100644
--- a/Makefile
+++ b/Makefile
@@ -48,7 +48,7 @@ prepare: generate relink_default
# FIXME trouble in win - better get into repo
#-@make icon
-prepare_win:
+gen_pkg_win:
mkdir -p build/${PROVIDER}/windows/
cp -r branding/templates/windows build/${PROVIDER}
VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} branding/scripts/generate-win.py build/${PROVIDER}/windows/data.json
@@ -56,7 +56,7 @@ prepare_win:
# TODO create/copy build/PROVIDER/assets/
# TODO create/copy build/PROVIDER/staging/
-prepare_osx:
+gen_pkg_osx:
mkdir -p build/${PROVIDER}/osx/scripts
mkdir -p build/${PROVIDER}/staging
ifeq (,$(wildcard build/${PROVIDER}/assets))
@@ -70,13 +70,18 @@ endif
cd build/${PROVIDER}/osx && python3 generate.py
cd build/${PROVIDER}/osx/scripts && chmod +x preinstall postinstall
-prepare_snap:
- echo "snap..."
+gen_pkg_snap:
+ cp -r branding/templates/snap build/${PROVIDER}
+ VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} branding/scripts/generate-snap.py build/${PROVIDER}/snap/data.json
+ 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
-prepare_debian:
+gen_pkg_deb:
echo "debian..."
-prepare_all: prepare prepare_win prepare_osx prepare_snap
+gen_pkg_all: prepare gen_pkg_win gen_pkg_osx gen_pkg_snap gen_pkg_deb
build: $(foreach path,$(wildcard cmd/*),build_$(patsubst cmd/%,%,$(path)))
diff --git a/branding/scripts/generate-snap.py b/branding/scripts/generate-snap.py
new file mode 100755
index 0000000..c3c5419
--- /dev/null
+++ b/branding/scripts/generate-snap.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+
+import json
+import os
+import sys
+
+import configparser
+
+from provider import getDefaultProvider
+from provider import getProviderData
+
+
+VERSION = os.environ.get('VERSION', 'unknown')
+SCRIPT = 'generate-snap.py'
+
+
+def writeOutput(data, outfile):
+
+ with open(outfile, 'w') as outf:
+ outf.write(json.dumps(data))
+
+
+if __name__ == "__main__":
+ env_provider_conf = os.environ.get('PROVIDER_CONFIG')
+ if env_provider_conf:
+ if os.path.isfile(env_provider_conf):
+ print("[+] Overriding provider config per "
+ "PROVIDER_CONFIG variable")
+ configfile = env_provider_conf
+
+ config = configparser.ConfigParser()
+ config.read(configfile)
+ provider = getDefaultProvider(config)
+ data = getProviderData(provider, config)
+
+ if len(sys.argv) != 2:
+ print('Usage: {} <output_file>'.format(SCRIPT))
+ sys.exit(1)
+
+ outputf = sys.argv[1]
+
+ data['version'] = VERSION
+ writeOutput(data, outputf)
diff --git a/branding/templates/snap/generate.py b/branding/templates/snap/generate.py
new file mode 100755
index 0000000..41d563d
--- /dev/null
+++ b/branding/templates/snap/generate.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+"""
+generate.py
+
+Generate a snap package for a given provider.
+"""
+
+import json
+import os
+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')))
+
+
+template = Template(open(TEMPLATE).read())
+
+with open(SNAPCRAFT, 'w') as output:
+ output.write(template.safe_substitute(data))
+
+print("[+] Snapcraft spec written to {path}".format(
+ path=os.path.abspath(SNAPCRAFT)))
diff --git a/branding/templates/snap/snapcraft-template.yaml b/branding/templates/snap/snapcraft-template.yaml
new file mode 100644
index 0000000..df9c135
--- /dev/null
+++ b/branding/templates/snap/snapcraft-template.yaml
@@ -0,0 +1,83 @@
+name: ${binaryName}
+version: ${version}
+summary: ${applicationName}, secure VPN. Powered by Bitmask.
+description: |
+ ${applicationName} is an easy, fast, and secure VPN service from ${providerURL}.
+ ${applicationName} does not require a user account, keep logs, or track you in
+ any way. The service is paid for entirely by donations from users like you.
+grade: stable
+confinement: classic
+icon: snap/gui/icon.svg
+base: core18
+
+parts:
+ desktop-gtk3:
+ plugin: nil
+ stage-packages:
+ - libc6
+ prime:
+ - '*'
+ - -usr/include
+ - -usr/lib/locale
+ - -usr/share/X11/locale
+ - -usr/share/doc
+ - -usr/share/locale
+ - -usr/share/man
+
+ bitmask-root:
+ after: [desktop-gtk3]
+ plugin: dump
+ source: https://0xacab.org/leap/bitmask-dev/
+ source-type: git
+ build-packages:
+ - wget
+ override-prime: |
+ echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+ mkdir -p bin
+ wget -O bin/bitmask-root https://0xacab.org/leap/bitmask-dev/raw/master/src/leap/bitmask/vpn/helpers/linux/bitmask-root
+ chmod +x bin/bitmask-root
+ echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+
+ openvpn:
+ plugin: nil
+ stage-packages:
+ - openvpn
+ - libc6
+ prime:
+ - -usr/share/doc
+ - -usr/share/man
+
+ bitmask-vpn:
+ after: [desktop-gtk3]
+ plugin: go
+ source-type: git
+ 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
+ snapcraftctl build
+ echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+ build-packages:
+ - pkg-config
+ - patchelf
+ - libpcre3-dev
+ - libappindicator3-dev
+ - libgtk-3-dev
+ stage-packages:
+ - libc6
+ - libpcre3
+ - libappindicator3-1
+ - zlib1g
+
+apps:
+ launcher:
+ command: bin/bitmask-vpn
+ desktop: ${binaryName}.desktop
+ environment:
+ LD_LIBRARY_PATH: "$SNAP/usr/lib/$(gcc -print-multiarch):$SNAP/lib/$(gcc -print-multiarch):$LD_LIBRARY_PATH"
+ openvpn:
+ command: usr/sbin/openvpn
+ bitmask-root:
+ command: bin/bitmask-root