blob: 7555aacdf292ae02078f2cfbaebaf03c24d22387 [file] [log] [blame]
# Copyright (c) 2013 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.
# Description:
# Script modifies a chromiumos image so that it will work with test
# instances of the DM Server and GAIA in the staging environment.
# When run, the script will mount the specified image, update the
# file, and then re-sign the image with devkey.
. "/usr/lib/crosutils/" || { echo "Unable to load"; exit 1; }
DEFINE_string dmserver \
"" \
"Complete URL for the DM Server" d
DEFINE_string gaiaserver "" \
"Complete URL for the GAIA server" g
DEFINE_string image "$FLAGS_image" \
"Path and name of the chromiumos image file" i
# Parse command line.
FLAGS "$@" || exit 1
eval set -- "$FLAGS_ARGV"
set -e
FLAGS_image=$(eval readlink -f "${FLAGS_image}")
IMAGE_DIR=$(dirname "${FLAGS_image}")
IMAGE_NAME=$(basename "${FLAGS_image}")
PAD=" "
ARGS="${PAD}--gaia-url=${FLAGS_gaiaserver} ${NL}"\
"${PAD}--lso-url= ${NL}"\
"${PAD} ${NL}"\
"${PAD} ${NL}"\
"${PAD}--oauth2-client-secret=RsKv5AwFKSzNgE0yjnurkPVI ${NL}"\
"${PAD}--ignore-urlfetcher-cert-requests \\\\"
cleanUp() {
"${SCRIPTS_DIR}/" -u -r "$ROOT_FS_DIR"
if [ ! -d "$VBOOT_DIR" ]; then
die "The required path: $VBOOT_DIR does not exist. This directory needs"\
"to be sync'd into your chroot.\n $ cros_workon start vboot_reference"
trap cleanUp EXIT
# Mount gpt (GUID partition table) image, and sets up var, /usr/local,
# and symlinks.
"$SCRIPTS_DIR/" --image="$IMAGE_NAME" --from="$IMAGE_DIR" \
# Create backup of session manager setup file.
sudo cp ${SMS_FILE} ${SMS_FILE}.bak
# Update DMSERVER to user-specified URI.
sudo sed -i 's@^DMSERVER=.*@DMSERVER="'${FLAGS_dmserver}'"@' ${SMS_FILE}
# Insert Staging Server arguments.
sudo sed -i '/--device-management-url/i\'"${ARGS}"'' ${SMS_FILE}
trap - EXIT
"${VBOOT_DIR}/" usb "${FLAGS_image}" \
echo "Renaming from ${TMP_BIN_PATH} to ${FLAGS_image}."
mv "${TMP_BIN_PATH}" "${FLAGS_image}"