| #!/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. | |
| #### CATEGORY=Software delivery | |
| ### make a zedboot USB key | |
| ## usage: fx mkzedboot [options] <usb device> | |
| ## -f force writing to a non-usb target | |
| set -e | |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? | |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/fx-mkzedboot.sh || exit $? | |
| fx-config-read | |
| force=false | |
| if [[ "$1" == "-f" ]]; then | |
| shift | |
| force=true | |
| fi | |
| USB_DEVICE="$1" | |
| if [[ -z "${USB_DEVICE}" ]]; then | |
| echo >&2 "device argument required" | |
| echo "USB disks:" | |
| fx-command-run list-usb-disks | |
| exit 1 | |
| fi | |
| image="" | |
| type="" | |
| # Try to get image for efi, if not found, try to get vboot image for chromebook | |
| image="$(fx-command-run list-build-artifacts --expect-one --type blk mkzedboot)" | |
| type="efi" | |
| if [[ -z "${image}" ]]; then | |
| image="$(fx-command-run list-build-artifacts --expect-one --type zbi.signed mkzedboot)" | |
| type="vboot" | |
| fi | |
| if [[ -z "${image}" ]]; then | |
| fx-error "Cannot find image to run mkzedboot. Re-check build board and product." | |
| exit 1 | |
| fi | |
| if [[ ! -f "${FUCHSIA_BUILD_DIR}/${image}" ]]; then | |
| fx-warn "Cannot find image to run mkzedboot: $image. Attempting to build it..." | |
| fx-command-run build "${image}" | |
| fi | |
| fx-mkzedboot "${USB_DEVICE}" "${type}" "${FUCHSIA_BUILD_DIR}/${image}" $force |