blob: d88482fe12d9584ecc3603061dc4fb9de003aff6 [file] [log] [blame]
# 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/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 (optional)
# [string] url of the Omaha server.
#
# 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"
action(eager_package_config_script_label) {
script = "//src/sys/pkg/scripts/eager_package_config.py"
inputs = invoker.sources
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",
]
}
}