| #!/bin/bash |
| # 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. |
| |
| VERSION="1.0.0" |
| 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 |
| fi |
| |
| if [[ "$#" -lt 2 ]]; then |
| echo "Usage: ${SCRIPT} base_name variant_name [bug_number]" |
| echo "e.g. ${SCRIPT} hatch kohaku b:140261109" |
| echo "Adds a new coreboot configuation for the variant by copying the" |
| echo "baseboard config file and replaces the names in the config file." |
| exit 1 |
| fi |
| |
| # This is the name of the base board that we're using to make the variant. |
| # ${var,,} converts to all lowercase. |
| BASE="${1,,}" |
| # This is the name of the variant that is being cloned. |
| VARIANT="${2,,}" |
| # We need all uppercase version, too, so ${var^^} |
| BASE_UPPER="${BASE^^}" |
| VARIANT_UPPER="${VARIANT^^}" |
| |
| # Assign BUG= text, or "None" if that parameter wasn't specified. |
| BUG=${3:-None} |
| |
| # Work in third_party/chromiumos-overlay/sys-boot/coreboot/files/configs |
| cd ~/trunk/src/third_party/chromiumos-overlay/sys-boot/coreboot/files/configs || exit 1 |
| |
| # Make sure the variant doesn't already exist. |
| if [[ -e "config.${VARIANT}" ]]; then |
| echo "config.${VARIANT} already exists." |
| echo "Have you already created this variant?" |
| exit 1 |
| fi |
| |
| # Start a branch. Use YMD timestamp to avoid collisions. |
| DATE=$(date +%Y%m%d) |
| repo start "create_${VARIANT}_${DATE}" . || exit 1 |
| |
| # There are two usages of the baseboard name that we want to change, using |
| # the Hatch baseboard and the Kohaku variant in this example. |
| # CONFIG_BOARD_GOOGLE_HATCH=y |
| # --- |
| # CONFIG_BOARD_GOOGLE_KOHAKU=y |
| # That one is easy; replace all-uppercase of the baseboard with all-uppercase |
| # of the variant. The second one is |
| # CONFIG_IFD_BIN_PATH="3rdparty/blobs/baseboard/hatch/descriptor-hatch.bin" |
| # --- |
| # CONFIG_IFD_BIN_PATH="3rdparty/blobs/baseboard/hatch/descriptor-kohaku.bin" |
| # The "hatch" name occurs twice in the original path, and we only want to |
| # change the last occurrence, so we get 'descriptor-kohaku.bin'. |
| # |
| # Another possibility for the IFD is that the baseboard doesn't use a |
| # hyphenated name, so we also need to search for descriptor.bin, e.g. |
| # CONFIG_IFD_BIN_PATH="3rdparty/blobs/baseboard-octopus/descriptor.bin" |
| sed -e "s/${BASE_UPPER}/${VARIANT_UPPER}/" \ |
| -e "s/descriptor-${BASE}\.bin/descriptor-${VARIANT}.bin/" \ |
| -e "s/descriptor\.bin/descriptor-${VARIANT}.bin/" \ |
| "config.${BASE}" > "config.${VARIANT}" |
| git add "config.${VARIANT}" |
| |
| # Now commit the files. |
| git commit -sm "${BASE}: Add ${VARIANT} coreboot configuration |
| |
| (Auto-Generated by ${SCRIPT} version ${VERSION}). |
| |
| BUG=${BUG} |
| BRANCH=none |
| TEST=FW_NAME=${VARIANT} emerge-${BASE} coreboot chromeos-bootimage |
| Ensure that image-${VARIANT}.*.bin are created" |
| |
| echo "Please check all the files (git show), make any changes you want," |
| echo "and then repo upload." |