blob: cb4e7a8c08c1d8611d15378c258ec707cf59d51b [file] [log] [blame]
#!/bin/bash
# Copyright 2017 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.
# Loads script libraries.
SCRIPT_ROOT=$(dirname "$(readlink -f "$0")")
. "${SCRIPT_ROOT}/common.sh" || exit 1
FLAGS_HELP="
Command to rebuild firmware after a config change.
After you make a change to the firmware version in the master configuration,
run this script to test it. It will rebuild the master configuration, update
the Manifest and build the new firmware. You can then submit your CL to update
the master configuration, safe in the knowledge that you have tested it.
Usage:
cros_update_firmware <board>
where <board> is the board whose firmware needs updating (e.g. 'coral').
"
# Script must be run inside the chroot.
restart_in_chroot_if_needed "$@"
# Flags
DEFINE_string board "${DEFAULT_BOARD}" "Which board the firmware is for" b
# Parse command line.
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
switch_to_strict_mode
update_firmware() {
local board="$1"
local base ebuild srcuris cfg_bsp_pkg cfg_bsp_baseboard_pkg
set -e
# check if chromeos-config-bsp is a virtual package
cfg_bsp_pkg="chromeos-config-bsp"
equery-${board} w chromeos-base/chromeos-config-bsp > /dev/null 2>&1 \
|| cfg_bsp_pkg="chromeos-config-bsp-${board}-private"
# check if chromeos-config-bsp-baseboard is in use
cfg_bsp_baseboard_pkg="chromeos-config-bsp-baseboard"
equery-${board} w chromeos-base/chromeos-config-bsp-baseboard > /dev/null 2>&1 \
|| cfg_bsp_baseboard_pkg=
cros_workon --board="${board}" start ${cfg_bsp_baseboard_pkg} "${cfg_bsp_pkg}" \
"chromeos-firmware-${board}"
base="${GCLIENT_ROOT}/src/private-overlays/overlay-${board}-private/chromeos-base"
ebuild="${base}/chromeos-firmware-${board}/chromeos-firmware-${board}-9999.ebuild"
srcuris="${base}/chromeos-firmware-${board}/files/srcuris"
"emerge-${board}" ${cfg_bsp_baseboard_pkg} "${cfg_bsp_pkg}" chromeos-config
cros_config_host -c "/build/${board}/usr/share/chromeos-config/config.dtb" \
get-firmware-uris > "${srcuris}"
touch "${ebuild}"
"ebuild-${board}" "${ebuild}" manifest
"emerge-${board}" "chromeos-firmware-${board}"
}
main() {
if [[ -z "${FLAGS_board}" ]]; then
die_notrace "-b or --board required."
fi
update_firmware "${FLAGS_board}"
}
main "$@"