blob: e26a3b786ca1edfe3b0f672120d92ae71c4eee1d [file] [log] [blame]
# Copyright (c) 2014 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.
# --board=[board]
# This script builds a factory toolkit, which is a self-extracting shellball,
# and can be installed onto a device running test image.
SCRIPT_ROOT=$(dirname "$(readlink -f "$0")")
. "${SCRIPT_ROOT}/" || exit 1
# Script must be run inside the chroot.
restart_in_chroot_if_needed "$@"
DEFINE_string board "${DEFAULT_BOARD}" \
"The board to build a factory toolkit for."
DEFINE_string output_dir "" "Path to the folder to store the factory toolkit."
DEFINE_string version "" \
"The version tag to be included in the identification string."
cleanup() {
sudo rm -rf "${temp_pack_root}"
main() {
# Parse command line.
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
trap cleanup EXIT
local default_dir="${CHROOT_TRUNK_DIR}/src/build/images/${FLAGS_board}/latest"
if [[ -n "${FLAGS_output_dir}" ]]; then
local output_dir="${FLAGS_output_dir}"
local output_dir="${default_dir}"
cd "${output_dir}"
temp_pack_root="$(mktemp -d toolkit_XXXXXX)"
if [[ ! -d "${temp_pack_root}" ]]; then
die "Failed to create temporary directory."
emerge-${FLAGS_board} --root="${temp_pack_root}" --nodeps --usepkgonly -v \
chromeos-factory chromeos-factory-board autotest-factory-install
if [[ -n "${FLAGS_version}" ]]; then
local id_str="${FLAGS_board} Factory Toolkit ${FLAGS_version}"
local id_str="${FLAGS_board} Factory Toolkit"
local output_toolkit="${output_dir}/"
makeself --bzip2 --nox11 "${temp_pack_root}" "${output_toolkit}" "${id_str}" \
echo "
Factory toolkit generated at ${output_toolkit}.
To install factory toolkit on a live device running a test image, copy this
to the device and execute it as root.
Alternatively, the factory toolkit can be used to patch a test image. For
more information, run:
${output_toolkit} -- --help
main "$@"