summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-10-09 22:35:45 +0200
committerRuben Pollan <meskio@sindominio.net>2020-10-13 19:08:59 +0200
commit481bd7db1d9c3937373c643d6d6aa3164b179839 (patch)
treed927d50290e4de77de625a80cf54aa327d7f60cf
parentaabd6d00acd34273902929bd02dbae47f10a96cc (diff)
[pkg] some extra branding refactor
-rw-r--r--Makefile38
-rwxr-xr-x[-rw-r--r--]branding/scripts/gen-providers-json (renamed from branding/scripts/gen-providers-json.py)20
-rwxr-xr-xbranding/scripts/generate-debian (renamed from branding/scripts/generate-debian.py)12
-rwxr-xr-xbranding/scripts/generate-osx.py44
-rwxr-xr-xbranding/scripts/generate-snap (renamed from branding/scripts/generate-snap.py)11
-rwxr-xr-xbranding/scripts/generate-vendor-make (renamed from branding/scripts/generate-vendor-make.py)13
-rwxr-xr-xbranding/scripts/generate-win.py44
-rw-r--r--branding/scripts/provider.py9
8 files changed, 42 insertions, 149 deletions
diff --git a/Makefile b/Makefile
index f2c462d..1483a9f 100644
--- a/Makefile
+++ b/Makefile
@@ -78,8 +78,8 @@ EXTRA_GO_LDFLAGS = "-H windowsgui"
endif
golib:
- # TODO stop building golib in gui/build.sh, it's redundant.
- # we should port the buildGoLib parts of the gui/build.sh script here
+ # TODO port the buildGoLib parts of the gui/build.sh script here (issue #363)
+ # or at least call that function from here --
@echo "doing nothing"
build_gui:
@@ -90,8 +90,7 @@ build: golib build_helper build_openvpn build_gui
build_helper:
@echo "PLATFORM: ${PLATFORM}"
@mkdir -p build/bin/${PLATFORM}
-
- go build -o build/bin/${PLATFORM}/bitmask-helper -ldflags "-X main.AppName=${APPNAME} -X main.Version=${VERSION} ${EXTRA_GO_LDFLAGS}" ./cmd/bitmask-helper/
+ @go build -o build/bin/${PLATFORM}/bitmask-helper -ldflags "-X main.AppName=${APPNAME} -X main.Version=${VERSION} ${EXTRA_GO_LDFLAGS}" ./cmd/bitmask-helper/
@echo "build helper done."
build_openvpn:
@@ -100,15 +99,13 @@ build_openvpn:
debug_installer:
@VERSION=${VERSION} ${SCRIPTS}/gen-qtinstaller osx ${INSTALLER}
-build_installer: # TODO re-add check_qtifw build
- echo "mkdir osx data"
+build_installer: check_qtifw build
@mkdir -p ${INST_DATA}
@cp -r ${TEMPLATES}/qtinstaller/packages ${INSTALLER}
@cp -r ${TEMPLATES}/qtinstaller/installer.pro ${INSTALLER}
@cp -r ${TEMPLATES}/qtinstaller/config ${INSTALLER}
ifeq (${PLATFORM}, darwin)
@mkdir -p ${INST_DATA}/helper
- # TODO need to write this
@VERSION=${VERSION} ${SCRIPTS}/gen-qtinstaller osx ${INSTALLER}
@cp "${TEMPLATES}/osx/bitmask.pf.conf" ${INST_DATA}helper/bitmask.pf.conf
@cp "${TEMPLATES}/osx/client.up.sh" ${INST_DATA}
@@ -120,9 +117,9 @@ ifeq (${PLATFORM}, darwin)
# FIXME our static openvpn build fails with an "Assertion failed at crypto.c". Needs to be fixed!!! - kali
# a working (old) version:
#@curl -L https://downloads.leap.se/thirdparty/osx/openvpn/openvpn -o build/${PROVIDER}/staging/openvpn-osx
- #@cp $(OPENVPN_BIN) ${INST_DATA}/openvpn.leap
- @echo "WARNING: workaround for broken static build. Shipping homebrew dynamically linked instead"
+ #FIXME FIXME @cp $(OPENVPN_BIN) ${INST_DATA}/openvpn.leap
@rm -f ${INST_DATA}openvpn.leap && cp /usr/local/bin/openvpn ${OSX_DATA}openvpn.leap
+ @echo "WARNING: workaround for broken static build. Shipping homebrew dynamically linked instead"
@echo "[+] Running macdeployqt"
@macdeployqt ${QTBUILD}/release/${PROVIDER}-vpn.app ${MACDEPLOYQT_OPTS}
@cp -r "${QTBUILD}/release/${TARGET}.app"/ ${OSX_DATA}/
@@ -159,7 +156,7 @@ PLATFORM_WIN = PLATFORM=windows
EXTRA_LDFLAGS_WIN = EXTRA_LDFLAGS="-H windowsgui"
build_cross_win:
@echo "[+] Cross-building for windows..."
- $(CROSS_WIN_FLAGS) $(PLATFORM_WIN) $(EXTRA_LDFLAGS_WIN) $(MAKE) _buildparts
+ @$(CROSS_WIN_FLAGS) $(PLATFORM_WIN) $(EXTRA_LDFLAGS_WIN) $(MAKE) _buildparts
# workaround for helper: we use the go compiler
@echo "[+] Compiling helper with the Go compiler to work around missing stdout bug..."
cd cmd/bitmask-helper && GOOS=windows GOARCH=386 go build -ldflags "-X main.version=`git describe --tags` -H windowsgui" -o ../../build/bin/windows/bitmask-helper-go
@@ -213,12 +210,12 @@ endif
vendor: gen_providers_json prepare_templates gen_pkg_snap gen_pkg_deb
gen_providers_json:
- @python3 branding/scripts/gen-providers-json.py branding/config/vendor.conf gui/providers/providers.json
+ @VENDOR_PATH=${VENDOR_PATH} branding/scripts/gen-providers-json gui/providers/providers.json
-prepare_templates: generate relink_default tgz
+prepare_templates: generate tgz
@mkdir -p build/${PROVIDER}/bin/ deploy
@cp ${TEMPLATES}/makefile/Makefile build/${PROVIDER}/Makefile
- @VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} ${SCRIPTS}/generate-vendor-make.py build/${PROVIDER}/vendor.mk
+ @VERSION=${VERSION} VENDOR_PATH=${VENDOR_PATH} ${SCRIPTS}/generate-vendor-make build/${PROVIDER}/vendor.mk
generate:
@go generate gui/backend.go
@@ -232,25 +229,26 @@ tgz:
@cd build/ && tar czf bitmask-vpn_$(VERSION).tgz ${TGZ_NAME}
@rm -rf $(TGZ_PATH)
-# XXX port/deprecate --------------------------------------------------------------------------------------------------
+# FIXME port --------------------------------------------------------------------------------------------------
gen_pkg_deb:
@cp -r ${TEMPLATES}/debian build/${PROVIDER}
- @VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} ${SCRIPTS}/generate-debian.py build/${PROVIDER}/debian/data.json
- @mkdir -p build/${PROVIDER}/debian/icons/scalable && cp branding/assets/default/icon.svg build/${PROVIDER}/debian/icons/scalable/icon.svg
+ @VERSION=${VERSION} VENDOR_PATH=${VENDOR_PATH} ${SCRIPTS}/generate-debian build/${PROVIDER}/debian/data.json
+ @mkdir -p build/${PROVIDER}/debian/icons/scalable && cp ${VENDOR_PATH}/${PROVIDER}/assets/icon.svg build/${PROVIDER}/debian/icons/scalable/icon.svg
@cd build/${PROVIDER}/debian && python3 generate.py
@cd build/${PROVIDER}/debian && rm app.desktop-template changelog-template rules-template control-template generate.py data.json && chmod +x rules
gen_pkg_snap:
@cp -r ${TEMPLATES}/snap build/${PROVIDER}
- @VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} ${SCRIPTS}/generate-snap.py build/${PROVIDER}/snap/data.json
+ @VERSION=${VERSION} VENDOR_PATH=${VENDOR_PATH} ${SCRIPTS}/generate-snap 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
- @cp branding/assets/default/icon.png build/${PROVIDER}/snap/gui/${PROVIDER}-vpn.png
- rm build/${PROVIDER}/snap/generate.py
+ @mkdir -p build/${PROVIDER}/snap/gui && cp ${VENDOR_PATH}/${PROVIDER}/assets/icon.svg build/${PROVIDER}/snap/gui/icon.svg
+ # FIXME is this png needed?? then add it to ASSETS_REQUIRED
+ @cp ${VENDOR_PATH}/${PROVIDER}/assets/icon.png build/${PROVIDER}/snap/gui/${PROVIDER}-vpn.png
+ @rm build/${PROVIDER}/snap/generate.py
# ---------------------------------------------------------------------------------------------------------------------
diff --git a/branding/scripts/gen-providers-json.py b/branding/scripts/gen-providers-json
index c89217a..0c95cb9 100644..100755
--- a/branding/scripts/gen-providers-json.py
+++ b/branding/scripts/gen-providers-json
@@ -23,6 +23,7 @@ def generateProvidersJSON(configPath, outputJSONPath):
providers = {}
defaultProvider = getDefaultProvider(config)
+
providers['default'] = defaultProvider
providers['providers'] = []
providerData = getProviderData(defaultProvider, config)
@@ -35,7 +36,7 @@ def generateProvidersJSON(configPath, outputJSONPath):
def addCaData(data, configfile):
provider = data.get('name').lower()
folder, f = os.path.split(configfile)
- caFile = os.path.join(folder, provider + '-ca.crt')
+ caFile = os.path.join(folder, provider, provider + '-ca.crt')
if not os.path.isfile(caFile):
bail('[!] Cannot find CA file in {path}'.format(path=caFile))
with open(caFile) as ca:
@@ -44,7 +45,7 @@ def addCaData(data, configfile):
def bail(msg=None):
if not msg:
print("ERROR: not enough arguments!")
- print('Usage: {scriptname}.py <config> <output>'.format(
+ print('Usage: {scriptname}.py <output>'.format(
scriptname=SCRIPT_NAME))
else:
print(msg)
@@ -52,13 +53,10 @@ def bail(msg=None):
if __name__ == "__main__":
print("[+] Generating providers.json...")
- if len(sys.argv) != 3:
+ if len(sys.argv) != 2:
bail()
- # TODO get BITMASK_BRANDING folder - get config from there, if possible.
- 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
- generateProvidersJSON(sys.argv[1], sys.argv[2])
+
+ VENDOR_PATH = os.environ.get('VENDOR_PATH')
+ conf = os.path.join(VENDOR_PATH, 'vendor.conf')
+ output = sys.argv[1]
+ generateProvidersJSON(conf, output)
diff --git a/branding/scripts/generate-debian.py b/branding/scripts/generate-debian
index 56e533b..0db1fde 100755
--- a/branding/scripts/generate-debian.py
+++ b/branding/scripts/generate-debian
@@ -19,17 +19,11 @@ 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
-
+ VENDOR_PATH = os.environ.get('VENDOR_PATH')
+ configFile = os.path.join(VENDOR_PATH, 'vendor.conf')
config = configparser.ConfigParser()
- config.read(configfile)
+ config.read(configFile)
provider = getDefaultProvider(config)
data = getProviderData(provider, config)
diff --git a/branding/scripts/generate-osx.py b/branding/scripts/generate-osx.py
deleted file mode 100755
index 4430762..0000000
--- a/branding/scripts/generate-osx.py
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/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')
-
-
-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: generate-osx.py <output_file>')
- sys.exit(1)
-
- outputf = sys.argv[1]
-
- data['applicationNameLower'] = data.get('applicationName').lower()
- data['URL'] = data.get('infoURL')
- data['version'] = VERSION
- writeOutput(data, outputf)
diff --git a/branding/scripts/generate-snap.py b/branding/scripts/generate-snap
index c3c5419..3271d9e 100755
--- a/branding/scripts/generate-snap.py
+++ b/branding/scripts/generate-snap
@@ -21,15 +21,10 @@ def writeOutput(data, outfile):
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
-
+ VENDOR_PATH = os.environ.get('VENDOR_PATH')
+ configFile = os.path.join(VENDOR_PATH, 'vendor.conf')
config = configparser.ConfigParser()
- config.read(configfile)
+ config.read(configFile)
provider = getDefaultProvider(config)
data = getProviderData(provider, config)
diff --git a/branding/scripts/generate-vendor-make.py b/branding/scripts/generate-vendor-make
index e7794c3..60dc180 100755
--- a/branding/scripts/generate-vendor-make.py
+++ b/branding/scripts/generate-vendor-make
@@ -36,20 +36,15 @@ def writeOutput(data, outfile):
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
-
+ VENDOR_PATH = os.environ.get('VENDOR_PATH')
+ configFile = os.path.join(VENDOR_PATH, 'vendor.conf')
config = configparser.ConfigParser()
- config.read(configfile)
+ config.read(configFile)
provider = getDefaultProvider(config)
data = getProviderData(provider, config)
if len(sys.argv) != 2:
- print('Usage: generate-vendor-make.py <output_file>')
+ print('Usage: generate-vendor-make <output_file>')
sys.exit(1)
outputf = sys.argv[1]
diff --git a/branding/scripts/generate-win.py b/branding/scripts/generate-win.py
deleted file mode 100755
index fb15f22..0000000
--- a/branding/scripts/generate-win.py
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/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')
-
-
-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: generate-win.py <output_file>')
- sys.exit(1)
-
- outputf = sys.argv[1]
-
- data['applicationNameLower'] = data.get('applicationName').lower()
- data['URL'] = data.get('infoURL')
- data['version'] = VERSION
- writeOutput(data, outputf)
diff --git a/branding/scripts/provider.py b/branding/scripts/provider.py
index ec8c80a..9f6bb08 100644
--- a/branding/scripts/provider.py
+++ b/branding/scripts/provider.py
@@ -3,12 +3,13 @@ import os
def getDefaultProvider(config):
- provider = os.environ.get('PROVIDER')
- if provider:
- print('[+] Got provider {} from environment'.format(provider))
- else:
+ if os.environ.get('VENDOR_PATH'):
print('[+] Using default provider from config file')
provider = config['default']['provider']
+ else:
+ provider = os.environ.get('PROVIDER')
+ if provider:
+ print('[+] Got provider {} from environment'.format(provider))
return provider