blob: 3bef6df79e50de5c46c325d7fc2ce660d82cfe59 [file] [log] [blame]
# Copyright 2019 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}")
export LC_ALL=C
if [[ ! -e /etc/cros_chroot_version ]]; then
echo "This script must be run inside the chroot."
exit 1
if [[ "$#" -lt 2 ]]; then
echo "Usage: ${SCRIPT} base_name variant_name [bug_number]"
echo "e.g. ${SCRIPT} hatch kohaku b:140261109"
echo "Creates the initial EC image as a copy of the base board's EC."
exit 1
# This is the name of the base board that we're cloning to make the variant.
# ${var,,} converts to all lowercase.
# This is the name of the variant that is being cloned.
# Assign BUG= text, or "None" if that parameter wasn't specified.
# All of the necessary files are in platform/ec/board
cd ~/trunk/src/platform/ec/board || exit 1
# Make sure that the base exists.
if [[ ! -e "${BASE}" ]]; then
echo "${BASE} does not exist; please specify a valid baseboard."
exit 1
# Make sure the variant doesn't already exist.
if [[ -e "${VARIANT}" ]]; then
echo "${VARIANT} already exists; have you already created this variant?"
exit 1
# Start a branch. Use YMD timestamp to avoid collisions.
DATE=$(date +%Y%m%d)
repo start "create_${VARIANT}_${DATE}" . || exit 1
mkdir "${VARIANT}"
cp "${BASE}"/* "${VARIANT}"
# TODO (pfagerburg@) replace the base name with the variant name in the
# copied files, except for the BASEBOARD=${BASE^^} line in
# Update copyright notice to current year.
YEAR=$(date +%Y)
find "${VARIANT}" -type f -exec \
sed -i -e "s/Copyright.*20[0-9][0-9]/Copyright ${YEAR}/" {} +
# Build the code; exit if it fails.
pushd .. || exit 1
make -j BOARD="${VARIANT}" || exit 1
popd || exit 1
git add "${VARIANT}"/*
# Now commit the files.
git commit -sm "${VARIANT}: Initial EC image
Create the initial EC image for the ${VARIANT} variant of the
${BASE} baseboard by copying the baseboard EC files into a new
directory named for the variant.
(Auto-Generated by ${SCRIPT} version ${VERSION}).