summaryrefslogtreecommitdiff
path: root/branding
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 /branding
parentaabd6d00acd34273902929bd02dbae47f10a96cc (diff)
[pkg] some extra branding refactor
Diffstat (limited to 'branding')
-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
7 files changed, 24 insertions, 129 deletions
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