| #!/bin/bash | |
| # 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. | |
| ### start fuchsia in qemu with a FVM disk | |
| set -e | |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/image_build_vars.sh || exit $? | |
| source "${FUCHSIA_DIR}/buildtools/vars.sh" | |
| qemu_dir="${BUILDTOOLS_QEMU_DIR}/bin" | |
| # Construction of a qcow image prevents qemu from writing back to the | |
| # build-produced image file, which could cause timestamp issues with that file. | |
| # Construction of the new ZBI adds //.ssh/authorized_keys for SSH access. | |
| imgdir="$(mktemp -d)" | |
| if [[ ! -d "${imgdir}" ]]; then | |
| echo >&2 "Failed to create temporary directory" | |
| exit 1 | |
| fi | |
| qimg="${imgdir}/fuchsia.qcow2" | |
| kernelzbi="${imgdir}/fuchsia-ssh.zbi" | |
| trap 'rm "${qimg}" "${kernelzbi}" && rmdir "${imgdir}"' EXIT | |
| "${qemu_dir}/qemu-img" create -f qcow2 -b "${FUCHSIA_BUILD_DIR}/${IMAGE_FVM_RAW}" \ | |
| "${qimg}" | |
| "${ZIRCON_TOOLS_DIR}/zbi" -o "${kernelzbi}" "${FUCHSIA_BUILD_DIR}/${IMAGE_ZIRCONA_ZBI}" \ | |
| --entry "data/ssh/authorized_keys=${FUCHSIA_DIR}/.ssh/authorized_keys" | |
| "${FUCHSIA_DIR}/zircon/scripts/run-zircon" \ | |
| -a "${FUCHSIA_ARCH}" \ | |
| -q "${qemu_dir}" \ | |
| -G 3 \ | |
| -t "${FUCHSIA_BUILD_DIR}/${IMAGE_QEMU_KERNEL_RAW}" \ | |
| -z "${kernelzbi}" \ | |
| -d \ | |
| -D "${qimg}" \ | |
| --diskfmt="qcow2" \ | |
| "$@" |