| # Copyright 2020 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") |
| |
| # Define Omaha Client configuration data to be included in the |
| # config-data package. Invokers must configure at least one of |
| # periodic_interval_minutes, startupd_delay_seconds, or retry_delay_seconds. |
| # |
| # periodic_interval_minutes (optional) |
| # [int] The number of minutes between update checks. Defaults to 60. |
| # |
| # startup_delay_seconds (optional) |
| # [int] How many seconds to wait after system start before starting |
| # the OMCL state machine and checking for an update. |
| # |
| # retry_delay_seconds (optional) |
| # [int] The number of seconds to wait after a failed update check |
| # before retrying. |
| # |
| # allow_reboot_when_idle (optional) |
| # [bool] Whether or not to reboot when idle. Defaults to "true". |
| # |
| # fuzz_percentage_range (optional) |
| # [int] The percent that periodic intervals are to be fuzzed to |
| # provide for the spreading out of units over time, if a global- |
| # synchronization event (e.g. major power/net outage) were to occur. |
| # e.g. 25 is for 25%. |
| # see `fuzz_interval()` in `src/policy.rs` for details. |
| # |
| # for_pkg (optional) |
| # [string] The package to make a config_data blob for. Defaults to |
| # "omaha-client" |
| |
| template("omcl_policy_config") { |
| forward_variables_from(invoker, |
| [ |
| "for_pkg", |
| "testonly", |
| ]) |
| cfg = { |
| forward_variables_from(invoker, |
| [ |
| "periodic_interval_minutes", |
| "startup_delay_seconds", |
| "retry_delay_seconds", |
| "allow_reboot_when_idle", |
| "fuzz_percentage_range", |
| ]) |
| assert( |
| defined(periodic_interval_minutes) || defined(startup_delay_seconds) || |
| defined(retry_delay_seconds) || defined(allow_reboot_when_idle) || |
| defined(fuzz_percentage_range), |
| "at least one config parameter should be defined") |
| |
| if (defined(fuzz_percentage_range)) { |
| assert(fuzz_percentage_range >= 0, |
| "fuzz_percentage_range must be positive") |
| assert(fuzz_percentage_range < 200, |
| "fuzz_percentage_range must be < 200%") |
| } |
| } |
| |
| if (!defined(for_pkg)) { |
| for_pkg = "omaha-client" |
| } |
| |
| config_path = "$target_gen_dir/policy_config.json" |
| |
| generated_file("omcl_policy_config_json") { |
| outputs = [ config_path ] |
| contents = cfg |
| output_conversion = "json" |
| } |
| |
| config_data(target_name) { |
| outputs = [ "policy_config.json" ] |
| sources = [ config_path ] |
| } |
| } |