blob: 2433271b3031a1663b4b908711e23f4b7040d5ed [file] [log] [blame]
# Copyright 2020 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
SCRIPT=$(basename -- "${0}")
set -e
export LC_ALL=C
if [[ ! -e /etc/cros_chroot_version ]]; then
echo "This script must be run inside the chroot."
exit 1
if ! hash gen_config 2>/dev/null; then
echo "gen_config is not on your PATH."
echo "Run the following before continuing:"
echo "echo 'export PATH=\$PATH:~/trunk/src/config/bin' >> ~/.bashrc && source ~/.bashrc"
exit 1
if [[ "$#" -lt 2 ]]; then
echo "Usage: ${SCRIPT} base_name variant_name [bug_number]"
echo "e.g. ${SCRIPT} puff wyvern b:158269582"
echo "Updates the to add a default _FW_BUILD_CONFIG"
exit 1
# shellcheck
# shellcheck disable=SC1091
source "${BASH_SOURCE%/*}/"
# shellcheck
# shellcheck disable=SC1091
source "${BASH_SOURCE%/*}/"
# This is the name of the base board.
# ${var,,} converts to all lowercase.
# This is the name of the variant that we are enabling _FW_BUILD_CONFIG for.
# We need all uppercase version, too, so ${var^^}
# Assign BUG= text, or "None" if that parameter wasn't specified.
# The file will be located here
cd "${HOME}/trunk/src/project/${BASE}/${VARIANT}"
# If there are pending changes, exit the script (unless overridden)
check_pending_changes "$(pwd)"
# Start a branch. Use YMD timestamp to avoid collisions.
DATE=$(date +%Y%m%d)
repo start "${BRANCH}" . "${NEW_VARIANT_WIP:+--head}"
# ${parameter:+word}" substitutes "word" if $parameter is set to a non-null
# value, or substitutes null if $parameter is null or unset.
cleanup() {
# If there is an error after the `repo start`, then restore modified files
# to clean up. `git restore --staged` will remove files added to a commit,
# and `git restore` will restore the file to its unmodified state. Then
# `repo abandon` the new branch.
git restore --staged
git restore
git restore --staged generated/config.jsonproto
git restore generated/config.jsonproto
git restore --staged sw_build_config/platform/chromeos-config/generated/project-config.json
git restore sw_build_config/platform/chromeos-config/generated/project-config.json
repo abandon "$1" .
trap 'cleanup "${BRANCH}"' ERR
# Change the _FW_BUILD_CONFIG from None to _${VARIANT_UPPER}.
sed -i -e "s/_FW_BUILD_CONFIG = None/_FW_BUILD_CONFIG = program.firmware_build_config(_${VARIANT_UPPER})/"
# Regenerate the config.
# Add modified files.
git add
git add generated/config.jsonproto
git add sw_build_config/platform/chromeos-config/generated/project-config.json
# Now commit the files.
git commit -m "${VARIANT}: enable default firmware build
Add a default _FW_BUILD_CONFIG.
(Auto-Generated by ${SCRIPT} version ${VERSION}).
TEST=Verify the ${VARIANT} firmware builds"