blob: 00adb8ef3ff040c5083c1c06e27db5e368ab3ddd [file] [log] [blame]
#!/usr/bin/env bash
# Copyright 2018 The Fuchsia Authors
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file or at
set -eo pipefail
usage() {
echo "usage: ${0} {source_image} {destination_image} {depfile}"
exit 1
if [ "$#" -ne 3 ]; then
declare -r SOURCE_IMAGE=${1}
declare -r TARGET_IMAGE=${2}
declare -r DEPFILE=${3}
# Ensure that the source image exists even if it is a dummy.
mkdir -p $(dirname ${SOURCE_IMAGE})
if [ ! -f "${SOURCE_IMAGE}" ]; then
echo "WARNING: ${SOURCE_IMAGE} not found, using a dummy image. See" \
"src/virtualization/docs/ for manual build instructions."
touch "${SOURCE_IMAGE}"
# Copy source to target.
rm -f "${TARGET_IMAGE}"
# Write a depfile to force the copy to happen when the image file changes.
# See comments in "guest_package.gni" as to why this is required.