| Index: bin/cros_tag_image.sh
|
| diff --git a/bin/cros_tag_image.sh b/bin/cros_tag_image.sh
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..c23bb23c22b83e1d58cc7a2db7cf2f89f497feaa
|
| --- /dev/null
|
| +++ b/bin/cros_tag_image.sh
|
| @@ -0,0 +1,118 @@
|
| +#!/bin/bash
|
| +
|
| +# Copyright (c) 2010 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 to manipulate the tag files in the output of build_image
|
| +
|
| +# Load common constants. This should be the first executable line.
|
| +# The path to common.sh should be relative to your script's location.
|
| +. "$(dirname "$0")/../common.sh"
|
| +. "$(dirname "$0")/../chromeos-common.sh" # for partoffset and partsize
|
| +
|
| +DEFINE_string from "chromiumos_image.bin" \
|
| + "Input file name of Chrome OS image to tag/stamp."
|
| +DEFINE_boolean enable_update_firmware ${FLAGS_FALSE} \
|
| + "Tag to force updating firmware"
|
| +DEFINE_boolean disable_update_firmware ${FLAGS_FALSE} \
|
| + "Remove firmware update tag"
|
| +DEFINE_boolean enable_dev_mode ${FLAGS_FALSE} \
|
| + "Tag to enable developer mode"
|
| +DEFINE_boolean disable_dev_mode ${FLAGS_FALSE} \
|
| + "Remove developer mode tag"
|
| +
|
| +# Parse command line
|
| +FLAGS "$@" || exit 1
|
| +eval set -- "${FLAGS_ARGV}"
|
| +
|
| +# Abort on error
|
| +set -e
|
| +
|
| +if [ -z $FLAGS_from ] || [ ! -f $FLAGS_from ] ; then
|
| + echo "Error: invalid flag --from"
|
| + exit 1
|
| +fi
|
| +
|
| +# Global variable to track if image is modified.
|
| +g_modified=${FLAGS_FALSE}
|
| +
|
| +function process_tag() {
|
| + # syntax: process_tag name file_path enable disable
|
| + local tag_status_text
|
| +
|
| + if [ $3 = ${FLAGS_TRUE} -a $4 = ${FLAGS_TRUE} ]; then
|
| + echo "Error: you cannot request to enable and disable tag '$1' at one time"
|
| + exit 1
|
| + fi
|
| +
|
| + if [ -f "$2" ]; then
|
| + tag_status_text="Enabled"
|
| + if [ "$4" = "${FLAGS_TRUE}" ]; then
|
| + # disable the tag
|
| + sudo rm "$2"
|
| + g_modified=${FLAGS_TRUE}
|
| + tag_status_text="$tag_status_text => disabled"
|
| + fi
|
| + else
|
| + tag_status_text="disabled"
|
| + if [ "$3" = "${FLAGS_TRUE}" ]; then
|
| + # enable the tag
|
| + sudo touch "$2"
|
| + g_modified=${FLAGS_TRUE}
|
| + tag_status_text="$tag_status_text => Enabled"
|
| + fi
|
| + fi
|
| +
|
| + # report tag status
|
| + echo "$1: $tag_status_text"
|
| +}
|
| +
|
| +IMAGE=$( readlink -f ${FLAGS_from} )
|
| +IMAGE_DIR=$( dirname ${IMAGE} )
|
| +
|
| +if [[ -z "${IMAGE}" || ! -f ${IMAGE} ]]; then
|
| + echo "Missing required argument: --from (image to update)"
|
| + usage
|
| + exit 1
|
| +fi
|
| +
|
| +pushd ${IMAGE_DIR} >/dev/null
|
| +if ! [[ -x ./unpack_partitions.sh && -x ./pack_partitions.sh ]]; then
|
| + echo "Could not find image manipulation scripts (*pack_partitions.sh)."
|
| + popd >/dev/null
|
| + exit 1
|
| +fi
|
| +
|
| +mkdir -p ./rootfs
|
| +mkdir -p ./stateful_part
|
| +INSTALL_ROOT=./rootfs
|
| +
|
| +# we don't have tags in stateful partition yet, so comment it it now.
|
| +
|
| +./unpack_partitions.sh ${IMAGE} 2>/dev/null
|
| +#sudo mount -o loop part_1 stateful_part
|
| +sudo mount -o loop part_3 rootfs
|
| +#sudo mount --bind stateful_part/dev_image rootfs/usr/local
|
| +#sudo mount --bind stateful_part/var rootfs/var
|
| +
|
| +# modify/list tags here
|
| +process_tag "Update Firmware" \
|
| + ${INSTALL_ROOT}/root/.force_update_firmware \
|
| + ${FLAGS_enable_update_firmware} \
|
| + ${FLAGS_disable_update_firmware}
|
| +process_tag "Developer Mode" \
|
| + ${INSTALL_ROOT}/root/.dev_mode \
|
| + ${FLAGS_enable_dev_mode} \
|
| + ${FLAGS_disable_dev_mode}
|
| +
|
| +#sudo umount rootfs/var
|
| +#sudo umount rootfs/usr/local
|
| +sudo umount rootfs
|
| +#sudo umount stateful_part
|
| +
|
| +if [ $g_modified = ${FLAGS_TRUE} ]; then
|
| + ./pack_partitions.sh ${IMAGE} 2>/dev/null
|
| + echo "Image is modified. Please remember to resign your image."
|
| +fi
|
| +popd >/dev/null
|
|
|