blob: 5c541d51320942424a567b82cba23297ceca696e [file] [log] [blame]
#!/bin/bash
# Copyright 2018 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.
### verify the structure of the build package directory in a layer
## usage: fx verify-build-packages zircon|garnet|peridot|topaz|vendor/foo
set -e
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/../lib/vars.sh || exit $?
fx-config-read
if [[ "$#" -ne 1 ]]; then
fx-command-help
exit 1
fi
readonly layer="$1"
layer_arg=""
if [[ ${layer} =~ vendor/([a-zA-Z0-9_-]+) ]]; then
readonly vendor="${BASH_REMATCH[1]}"
layer_arg="--vendor-layer ${vendor}"
elif [[ "${layer}" == "zircon" ]]; then
# Zircon does not have build packages.
exit 0
elif [[ "${layer}" == "garnet" ]] ||
[[ "${layer}" == "peridot" ]] ||
[[ "${layer}" == "topaz" ]]; then
layer_arg="--layer ${layer}"
else
fx-command-help
exit 1
fi
readonly validator="${FUCHSIA_BUILD_DIR}/host_x64/json_validator"
if [[ ! -f ${validator} ]]; then
fx-error "Cannot find JSON validator at ${validator}."
fx-error "Try running 'fx build' first."
exit 1
fi
"${FUCHSIA_DIR}/scripts/packages/verify_layer.py" \
--json-validator "${validator}" \
${layer_arg}