aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/build/fuchsia.go
diff options
context:
space:
mode:
authorMarco Vanotti <mvanotti@google.com>2019-07-10 15:53:04 -0700
committerDmitry Vyukov <dvyukov@google.com>2019-07-23 08:44:20 +0200
commit5aec592bda6468d616f6fa6a6c1fa2d9e6c6895a (patch)
tree67ab5901c1c93bf691aeb1a6c220904e68e63b06 /pkg/build/fuchsia.go
parent55e0c07757deebc0c6094915fae19fc0959849e4 (diff)
pkg/build: Add ssh keys for fuchsia
This change modifies the way fuchsia is built to add the ssh keys to the zbi image after building it. Previously that was done via the "extra_ssh_keys" argument to the build system, but that was removed recently.
Diffstat (limited to 'pkg/build/fuchsia.go')
-rw-r--r--pkg/build/fuchsia.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/pkg/build/fuchsia.go b/pkg/build/fuchsia.go
index b8a7a8556..8553fbf99 100644
--- a/pkg/build/fuchsia.go
+++ b/pkg/build/fuchsia.go
@@ -22,21 +22,29 @@ func (fu fuchsia) build(targetArch, vmType, kernelDir, outputDir, compiler, user
}
arch := sysTarget.KernelHeaderArch
product := fmt.Sprintf("%s.%s", "core", arch)
- if _, err := osutil.RunCmd(time.Hour, kernelDir, "scripts/fx", "set", product,
- "--args", `extra_authorized_keys_file="//.ssh/authorized_keys"`,
- "--with-base", "//bundles:tools",
- "--build-dir", "out/"+arch); err != nil {
+ if _, err := osutil.RunCmd(time.Hour, kernelDir, "scripts/fx", "--dir", "out/"+arch,
+ "set", product, "--with-base", "//bundles:tools"); err != nil {
return err
}
if _, err := osutil.RunCmd(time.Hour, kernelDir, "scripts/fx", "clean-build"); err != nil {
return err
}
+
+ // Fuchsia images no longer include ssh keys. Manually append the ssh public key to the zbi.
+ sshZBI := filepath.Join(kernelDir, "out", arch, "fuchsia-ssh.zbi")
+ kernelZBI := filepath.Join(kernelDir, "out", arch, "fuchsia.zbi")
+ authorizedKeys := fmt.Sprintf("data/ssh/authorized_keys=%s", filepath.Join(kernelDir, ".ssh", "authorized_keys"))
+ if _, err := osutil.RunCmd(time.Minute, kernelDir, "out/"+arch+".zircon/tools/zbi",
+ "-o", sshZBI, kernelZBI, "--entry", authorizedKeys); err != nil {
+ return err
+ }
+
for src, dst := range map[string]string{
"out/" + arch + "/obj/build/images/fvm.blk": "image",
".ssh/pkey": "key",
"out/" + arch + ".zircon/kernel-" + arch + "-gcc/obj/kernel/zircon.elf": "obj/zircon.elf",
"out/" + arch + ".zircon/multiboot.bin": "kernel",
- "out/" + arch + "/fuchsia.zbi": "initrd",
+ "out/" + arch + "/fuchsia-ssh.zbi": "initrd",
} {
fullSrc := filepath.Join(kernelDir, filepath.FromSlash(src))
fullDst := filepath.Join(outputDir, filepath.FromSlash(dst))