Add a GN arg to include additional SSH keys.

There's now a GN arg extra_authorized_keys_file that can include the
path to an authorized_keys file. This will be combined with the
authorized keys generated by the build.

For example:
  fset x86-64 --args extra_authorized_keys_file=\"$HOME/.ssh/id_rsa.pub\"

TO-385 #done

Change-Id: I39831ca80b5df382d5c30f86825f3342e5cb2b2a
diff --git a/fuchsia/developer-keys/BUILD.gn b/fuchsia/developer-keys/BUILD.gn
index 89491b1..8371094 100644
--- a/fuchsia/developer-keys/BUILD.gn
+++ b/fuchsia/developer-keys/BUILD.gn
@@ -4,6 +4,13 @@
 
 import("//packages/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") {
   deps = [
     ":all",
@@ -64,16 +71,22 @@
   ]
 }
 
-copy("authorized_keys") {
-  sources = [
+action("authorized_keys") {
+  inputs = [
     "${keys_dir}/id_ed25519.pub",
   ]
+  if (extra_authorized_keys != "") {
+    inputs += [ extra_authorized_keys ]
+  }
   outputs = [
     "${keys_dir}/authorized_keys",
   ]
   deps = [
     ":id_key",
   ]
+
+  script = "concat_authorized_keys.sh"
+  args = rebase_path(outputs + inputs)
 }
 
 action("ssh_config") {
diff --git a/fuchsia/developer-keys/concat_authorized_keys.sh b/fuchsia/developer-keys/concat_authorized_keys.sh
new file mode 100755
index 0000000..e21771a
--- /dev/null
+++ b/fuchsia/developer-keys/concat_authorized_keys.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# A trivial helper script to concat authorized_key files
+
+if [[ $# -lt 2 ]]; then
+  echo "$0 <output-file> <input-files>..."
+  exit 1
+fi
+
+cat "${@:2}" > $1