| # Copyright 2022 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/compiled_action.gni") |
| import("//build/config.gni") |
| |
| # eager_package_config produces config-data for omaha-client and pkg-resolver to |
| # to support eager package updates. |
| # |
| # Parameters |
| # |
| # key_config |
| # [string] path to JSON config for key config. Required. |
| # |
| # Should be a scope with a map from [string] service_url to [scope] of |
| # Omaha server public keys. |
| # |
| # Each scope has two keys, 'latest' and 'historical'. The value of |
| # 'latest' should be a scope with keys 'id' and 'key'. The value of |
| # 'historical' should be a list of scopes, each with keys 'id' and 'key'. |
| # |
| # Nothing is optional, but 'historical' may be empty. |
| # |
| # Example: |
| # { |
| # "https://example.com": { |
| # "latest": |
| # { "id": 123, "key": "foo", }, |
| # "historical": |
| # [ |
| # { "id": 246, "key": "bar", }, |
| # { "id": 369, "key": "baz", }, |
| # ... |
| # ], |
| # }, |
| # ... |
| # } |
| # |
| # id: [int] The Omaha server public key ID. |
| # key: [string] The value of the public key, encoded as a .pem. No |
| # validation of the contents is performed here. |
| # |
| # sources |
| # [list of string] list of path to JSON config for each eager package. |
| # |
| # Each JSON config should include the following |
| # url |
| # [string] url of the package. |
| # |
| # flavor (optional) |
| # [string] flavor of the package. |
| # |
| # executable (optional) |
| # [bool] executability of the package. |
| # |
| # default_channel (optional) |
| # [string] if set, this channel will be the default channel. The |
| # channel must appear in channels in at least one realm. |
| # |
| # realms |
| # [list of objects] list of realms. Each realm contains the |
| # the following. Nothing is optional. |
| # app_id: The Omaha App ID for the realm |
| # channels: [list of strings] The list of channels for the realm. |
| # |
| # service_url (required) |
| # [string] url of the Omaha server. |
| # |
| # minimum_required_version (required) |
| # [string] the minimum required version for this package, in |
| # "1.2.3.4"-style notation. |
| # The string can also be a path like "//path/to/VERSION", which will be |
| # read and parsed as version number, this path MUST also be specified in |
| # `inputs` for hermeticity. |
| # If there is a fallback version of the eager package in a build, this |
| # version MUST match the fallback version. |
| # |
| # cache_fallback (optional) |
| # [bool] if fallback to the version in cache packages is allowed. |
| # |
| # inputs |
| # [list of string] paths to additional input file to the config, see |
| # minimum_required_version for more detail. |
| # |
| # data_deps (optional) |
| # deps (optional) |
| # Same as for any GN target. |
| template("eager_package_config") { |
| input_paths = [] |
| foreach(source, invoker.sources) { |
| input_paths += [ rebase_path(source, root_build_dir) ] |
| } |
| |
| omaha_client_config_path = |
| "$target_gen_dir/$target_name/omaha_client/eager_package_config.json" |
| pkg_resolver_config_path = |
| "$target_gen_dir/$target_name/pkg_resolver/eager_package_config.json" |
| |
| eager_package_config_script_label = |
| "${target_name}_eager_package_config_script" |
| compiled_action(eager_package_config_script_label) { |
| tool = "//src/sys/pkg/scripts/gen_eager_package_config" |
| inputs = invoker.sources + [ invoker.key_config ] |
| if (defined(invoker.inputs)) { |
| inputs += invoker.inputs |
| } |
| outputs = [ |
| omaha_client_config_path, |
| pkg_resolver_config_path, |
| ] |
| args = [ |
| "--out-omaha-client-config", |
| rebase_path(omaha_client_config_path, root_build_dir), |
| "--out-pkg-resolver-config", |
| rebase_path(pkg_resolver_config_path, root_build_dir), |
| "--key-config-file", |
| rebase_path(invoker.key_config, root_build_dir), |
| ] + input_paths |
| } |
| |
| omaha_client_config_label = "${target_name}_omaha_client_config" |
| config_data(omaha_client_config_label) { |
| for_pkg = "omaha-client" |
| outputs = [ "eager_package_config.json" ] |
| sources = [ omaha_client_config_path ] |
| deps = [ ":$eager_package_config_script_label" ] |
| } |
| |
| pkg_resolver_config_label = "${target_name}_pkg_resolver_config" |
| config_data(pkg_resolver_config_label) { |
| for_pkg = "pkg-resolver" |
| outputs = [ "eager_package_config.json" ] |
| sources = [ pkg_resolver_config_path ] |
| deps = [ ":$eager_package_config_script_label" ] |
| } |
| |
| group(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "data_deps", |
| ]) |
| if (!defined(data_deps)) { |
| data_deps = [] |
| } |
| data_deps += [ |
| ":$omaha_client_config_label", |
| ":$pkg_resolver_config_label", |
| ] |
| } |
| } |