blob: c1325be3b1fe453bedf2e9730261f8cb393d561e [file] [log] [blame]
# Copyright 2017 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/package.gni")
declare_args() {
# Additional SSH authorized_keys file to include in the build.
# For example:
# extra_authorized_keys_file=\"$HOME/.ssh/id_rsa.pub\"
extra_authorized_keys_file = ""
}
package("developer-keys") {
deprecated_system_image = true
deps = [
":all",
]
resources = [
{
path = rebase_path("$root_out_dir/ssh-keys/authorized_keys")
dest = "ssh/authorized_keys"
},
{
path = rebase_path("$root_out_dir/ssh-keys/ssh_host_ed25519_key")
dest = "ssh/ssh_host_ed25519_key"
},
{
path = rebase_path("$root_out_dir/ssh-keys/ssh_host_ed25519_key.pub")
dest = "ssh/ssh_host_ed25519_key.pub"
},
]
}
group("all") {
public_deps = [
":authorized_keys",
":host_key",
":id_key",
":ssh_config",
]
}
keys_dir = "${root_build_dir}/ssh-keys"
action("host_key") {
key_file = "${keys_dir}/ssh_host_ed25519_key"
script = "ssh-keygen-wrapper"
args = [
"ed25519",
rebase_path(key_file),
]
outputs = [
key_file,
key_file + ".pub",
]
}
action("id_key") {
key_file = "${keys_dir}/id_ed25519"
script = "ssh-keygen-wrapper"
args = [
"ed25519",
rebase_path(key_file),
]
outputs = [
key_file,
key_file + ".pub",
]
}
action("authorized_keys") {
inputs = [
"${keys_dir}/id_ed25519.pub",
]
if (extra_authorized_keys_file != "") {
inputs += [ extra_authorized_keys_file ]
}
outputs = [
"${keys_dir}/authorized_keys",
]
deps = [
":id_key",
]
script = "concat_authorized_keys.sh"
args = rebase_path(outputs + inputs)
}
action("ssh_config") {
config_file = "${keys_dir}/ssh_config"
script = "generate_ssh_config.sh"
args = [
rebase_path("${keys_dir}/id_ed25519"),
rebase_path(config_file),
]
outputs = [
config_file,
]
}