blob: 3593ab038def73110bd6e201e772efc58832d6d6 [file] [log] [blame]
Stephen Barber3f7688f2017-02-16 11:23:44 -08001#!/bin/bash
2# Copyright 2017 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6SCRIPT_ROOT=$(dirname "$(readlink -f "$0")")
7. "${SCRIPT_ROOT}/build_library/build_common.sh" || exit 1
Stephen Barberf9e93a32017-05-17 15:41:57 -07008. "${SCRIPT_ROOT}/build_library/filesystem_util.sh" || exit 1
Stephen Barber3f7688f2017-02-16 11:23:44 -08009
Daniel Verkamp535ac932019-08-30 14:05:34 -070010TERMINA_BUILD_IMAGE_PY="${SCRIPT_ROOT}/../platform/container-guest-tools/termina/termina_build_image.py"
11TERMINA_BUILD_IMAGE_PY="$(readlink -f "${TERMINA_BUILD_IMAGE_PY}")"
12
Stephen Barber3f7688f2017-02-16 11:23:44 -080013assert_inside_chroot "$@"
14
Stephen Barberf9e93a32017-05-17 15:41:57 -070015DEFINE_string arch "amd64" \
16 "Architecture of the VM image"
17DEFINE_string filesystem "ext4" \
18 "Filesystem for the rootfs image"
19DEFINE_string image "" \
20 "Chromium OS disk image to build the Termina image from"
21DEFINE_string output "" \
22 "Output directory"
Stephen Barber3f7688f2017-02-16 11:23:44 -080023
24FLAGS_HELP="USAGE: ${SCRIPT_NAME} [flags]
25
Stephen Barberf9e93a32017-05-17 15:41:57 -070026To build a tatl test image, try:
27$ ./build_image --board=tatl test
28$ ${SCRIPT_NAME} --image=../build/images/tatl/latest/chromiumos_test_image.bin --output=tatl
Stephen Barber3f7688f2017-02-16 11:23:44 -080029"
30FLAGS "$@" || exit 1
31eval set -- "${FLAGS_ARGV}"
32switch_to_strict_mode
33
Stephen Barber3f7688f2017-02-16 11:23:44 -080034main() {
Daniel Verkamp535ac932019-08-30 14:05:34 -070035 warn "termina_build_image is deprecated. Please use termina_build_image.py."
36
Stephen Barberf9e93a32017-05-17 15:41:57 -070037 if [[ -z "${FLAGS_image}" ]]; then
38 die_notrace "Please provide an image using --image"
39 elif [[ ! -f "${FLAGS_image}" ]]; then
40 die_notrace "'${FLAGS_image}' does not exist"
Stephen Barber3f7688f2017-02-16 11:23:44 -080041 fi
42
Stephen Barberdebef582018-05-19 13:11:54 -070043 if [[ "${FLAGS_arch}" != "amd64" && "${FLAGS_arch}" != "arm" ]]; then
44 die_notrace "Architecture '${FLAGS_arch}' is not valid. Options are 'amd64' and 'arm'"
Stephen Barber3f7688f2017-02-16 11:23:44 -080045 fi
46
Daniel Verkamp535ac932019-08-30 14:05:34 -070047 if [[ "${FLAGS_filesystem}" != "ext4" ]]; then
48 die_notrace "Filesystem '${FLAGS_filesystem}' is not valid. 'ext4' is valid."
Stephen Barberf9e93a32017-05-17 15:41:57 -070049 fi
50
Daniel Verkamp535ac932019-08-30 14:05:34 -070051 info "Equivalent termina_build_image.py command:"
52 info "${TERMINA_BUILD_IMAGE_PY} ${FLAGS_image} ${FLAGS_output}"
Stephen Barberf9e93a32017-05-17 15:41:57 -070053
Daniel Verkamp535ac932019-08-30 14:05:34 -070054 sudo "${TERMINA_BUILD_IMAGE_PY}" "${FLAGS_image}" "${FLAGS_output}"
Stephen Barberf9e93a32017-05-17 15:41:57 -070055
Daniel Verkamp535ac932019-08-30 14:05:34 -070056 info "Done! The resulting image is in '${FLAGS_output}'"
Stephen Barber3f7688f2017-02-16 11:23:44 -080057}
58
59main "$@"