* Add new version env vars to example * Remove test file * Move CMake packaging to separate module and configure OpenSSL path for Windows * Make VS Code CMake build task default * Generate Microsoft-friendly 4-digit version number * Update macOS bundle .plist with build year variable * Use correct OpenSSL path and fixed various MSI variables * Use correct rest/dist dir for MSI * Add version .rc file for Windows * Use macro instead of over-complicated version query command * Made cmd_utils more secure by defaulting to no-shell and no-print * Add certificate management module * Implement packaging script on Windows * Refactor Mac packaging script to use new cmd_utils args and new cert module * Update ChangeLog * Change PFX env vars and add to CI * Use import as instead of from lib to solve resolve issue * Allow custom certificate extensions * Check for package version when using gdrive * Make version number required * Add missing shell * Add missing gdrive value in test * Find OpenSSL dir based on openssl binary * Only use first OpenSSL entry * More verbose logging * Improve logging * Only use env var if not empty * Fixed wrong var * Fixed macOS GitHub artefact name * Change filename format to match new convention
80 lines
2.4 KiB
Python
80 lines
2.4 KiB
Python
import lib.env as env
|
|
import lib.cmd_utils as cmd_utils
|
|
|
|
config_file = "config.yml"
|
|
root_key = "config"
|
|
deps_key = "dependencies"
|
|
|
|
|
|
class ConfigKeyError(RuntimeError):
|
|
def __init__(self, config_file, key):
|
|
self.config_file = config_file
|
|
self.key = key
|
|
|
|
def __str__(self):
|
|
return f"Not found in {self.config_file}: {self.key}"
|
|
|
|
|
|
def _get(dict, key, key_parent=None):
|
|
value = dict.get(key)
|
|
|
|
if not value:
|
|
key_path = f"{root_key}:{key_parent}:{key}" if key_parent else key
|
|
raise ConfigKeyError(f"Missing key in {config_file}: {key_path}")
|
|
|
|
return value
|
|
|
|
|
|
class Config:
|
|
"""Reads the project configuration YAML file."""
|
|
|
|
def __init__(self):
|
|
env.ensure_module("yaml", "pyyaml")
|
|
import yaml
|
|
|
|
with open(config_file, "r") as f:
|
|
data = yaml.safe_load(f)
|
|
|
|
self.os_name = env.get_os()
|
|
root = _get(data, root_key)
|
|
self.os = _get(root, self.os_name)
|
|
|
|
def get_os_value(self, key):
|
|
return _get(self.os, key, f"{self.os_name}:{key}")
|
|
|
|
def get_qt_config(self):
|
|
qt_key = "qt"
|
|
qt = self.get_os_deps_value(qt_key)
|
|
|
|
parent_key = f"{self.os_name}:{deps_key}"
|
|
mirror_url = _get(qt, "mirror", parent_key)
|
|
version = _get(qt, "version", parent_key)
|
|
base_dir = _get(qt, "install-dir", parent_key)
|
|
|
|
return mirror_url, version, base_dir
|
|
|
|
def get_os_deps_value(self, key):
|
|
deps = self.get_os_value(deps_key)
|
|
return _get(deps, key, f"{self.os_name}:{deps_key}")
|
|
|
|
def get_deps_command(self):
|
|
deps = self.get_os_value(deps_key)
|
|
command = _get(deps, "command", f"{self.os_name}:{deps_key}")
|
|
return cmd_utils.strip_continuation_sequences(command)
|
|
|
|
def get_linux_deps_command(self, distro):
|
|
distro_data = self.get_os_value(distro)
|
|
deps = _get(distro_data, deps_key, f"{self.os_name}:{distro}")
|
|
command = _get(deps, "command", f"{self.os_name}:{distro}:{deps_key}")
|
|
return cmd_utils.strip_continuation_sequences(command)
|
|
|
|
def get_choco_ci_config(self):
|
|
choco_ci_key = "choco-ci"
|
|
choco_ci = self.get_os_deps_value(choco_ci_key)
|
|
|
|
choco_ci_path = f"{self.os_name}:{deps_key}:{choco_ci_key}"
|
|
edit_config = _get(choco_ci, "edit-config", choco_ci_path)
|
|
skip_packages = _get(choco_ci, "skip-packages", choco_ci_path)
|
|
|
|
return edit_config, skip_packages
|