Remove deprecated mod_image_for_test.sh and references.

mod_image_for_test.sh doesn't work anymore so nobody should be using it.
There are a few places where scripts try to use mod_image_for_test.sh,
and these are timebombs because they fail if a test image needs to actually
be produced.

BUG=chromium-os:31183
TEST=Tested that this script doesn't produce any images anymore, so
     it should be fine to delete it.

Change-Id: If80337407023d62f76117dc44cadfa46801ca236
Reviewed-on: https://gerrit.chromium.org/gerrit/40955
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
This commit is contained in:
David James 2013-01-09 15:25:58 -08:00 committed by ChromeBot
parent 90e3b25914
commit 7efb76cde5
5 changed files with 11 additions and 191 deletions

View File

@ -585,9 +585,6 @@ def main(argv):
(options, args) = parser.parse_args(argv)
# we can build the test image if it doesn't exist, so remember if we want to
build_test_image = False
verbosity = CrosEnv.SILENT
if options.verbose:
verbosity = CrosEnv.INFO
@ -631,9 +628,6 @@ def main(argv):
# auto-select the correct image
if options.test:
options.image_name = DEFAULT_IMAGE_NAME_TEST
# we will build the test image if not found
build_test_image = True
else:
options.image_name = DEFAULT_IMAGE_NAME
@ -642,18 +636,6 @@ def main(argv):
image_file = os.path.join(options.src, options.image_name)
if not os.path.exists(image_file):
if build_test_image:
# we want a test image but it doesn't exist
# try to build it if we can
cros_env.Info('Creating test image')
test_output = cros_env.cmd.Output(
'cros_sdk',
'--', './mod_image_for_test.sh',
'--board=%s' % options.board, '-y')
if not os.path.exists(image_file):
print test_output
cros_env.Fatal('Failed to create test image - please run '
'./mod_image_for_test.sh manually inside the chroot')
parser.error('Image file %s does not exist' % image_file)
else:
image_file = options.src

View File

@ -853,53 +853,6 @@ get_board_and_variant() {
fi
}
# This function converts a chromiumos image into a test image, either
# in place or by copying to a new test image filename first. It honors
# the following flags (see mod_image_for_test.sh)
#
# --factory
# --factory_install
# --force_copy
#
# On entry, pass the directory containing the image, and the image filename
# On exit, it puts the pathname of the resulting test image into
# CHROMEOS_RETURN_VAL
# (yes this is ugly, but perhaps less ugly than the alternatives)
#
# Usage:
# SRC_IMAGE=$(prepare_test_image "directory" "imagefile")
prepare_test_image() {
# If we're asked to modify the image for test, then let's make a copy and
# modify that instead.
# Check for manufacturing image.
local args
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then
args="--factory"
fi
# Check for install shim.
if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then
args="--factory_install"
fi
# Check for forcing copy of image
if [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ]; then
args="${args} --force_copy"
fi
# Modify the image for test, creating a new test image
"${SCRIPTS_DIR}/mod_image_for_test.sh" --board=${FLAGS_board} \
--image="$1/$2" --noinplace ${args}
# From now on we use the just-created test image
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then
CHROMEOS_RETURN_VAL="$1/${CHROMEOS_FACTORY_TEST_IMAGE_NAME}"
else
CHROMEOS_RETURN_VAL="$1/${CHROMEOS_TEST_IMAGE_NAME}"
fi
}
# Check that the specified file exists. If the file path is empty or the file
# doesn't exist on the filesystem generate useful error messages. Otherwise
# show the user the name and path of the file that will be used. The padding

View File

@ -36,13 +36,13 @@ DEFINE_boolean force_copy ${FLAGS_FALSE} \
DEFINE_boolean force_non_usb ${FLAGS_FALSE} \
"force writing even if target device doesn't appear to be a USB/MMC disk"
DEFINE_boolean factory_install ${FLAGS_FALSE} \
"generate a factory install shim"
"Install the factory install shim"
DEFINE_boolean factory ${FLAGS_FALSE} \
"generate a factory runing image, implies autotest and test"
"Install a factory test image"
DEFINE_boolean copy_kernel ${FLAGS_FALSE} \
"copy the kernel to the fourth partition"
DEFINE_boolean test_image "${FLAGS_FALSE}" \
"copy normal image to ${CHROMEOS_TEST_IMAGE_NAME} and modify it for test"
"Install a test image"
DEFINE_string image_name "" \
"image base name (empty: auto-detect)" \
i
@ -241,14 +241,10 @@ STATEFUL_DIR="${FLAGS_from}/stateful_partition"
mkdir -p "${STATEFUL_DIR}"
# Figure out which image to use.
if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ]; then
# Test image requested: pass the provided (or otherwise default) image name
# to the method that's in charge of preparing a test image (note that this
# image may or may not exist). The test image filename is returned in
# CHROMEOS_RETURN_VAL.
prepare_test_image "${FLAGS_from}" \
"${FLAGS_image_name:=${CHROMEOS_IMAGE_NAME}}"
SRC_IMAGE="${CHROMEOS_RETURN_VAL}"
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then
SRC_IMAGE="${FLAGS_from}/${CHROMEOS_FACTORY_TEST_IMAGE_NAME}"
elif [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ]; then
SRC_IMAGE="${FLAGS_from}/${CHROMEOS_TEST_IMAGE_NAME}"
else
# Auto-detect and select an image name if none provided.
if [ -z "${FLAGS_image_name}" ]; then

View File

@ -91,10 +91,10 @@ if [ -z "${FLAGS_to}" ] ; then
FLAGS_to="${FLAGS_from}"
fi
if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then
# Make a test image - this returns the test filename in CHROMEOS_RETURN_VAL
prepare_test_image "${FLAGS_from}" "${CHROMEOS_IMAGE_NAME}"
SRC_IMAGE="${CHROMEOS_RETURN_VAL}"
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then
SRC_IMAGE="${FLAGS_from}/${CHROMEOS_FACTORY_TEST_IMAGE_NAME}"
elif [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ]; then
SRC_IMAGE="${FLAGS_from}/${CHROMEOS_TEST_IMAGE_NAME}"
else
# Use the standard image
SRC_IMAGE="${FLAGS_from}/${CHROMEOS_IMAGE_NAME}"

View File

@ -1,111 +0,0 @@
#!/bin/bash
# Copyright (c) 2011 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 modify a keyfob-based chromeos system image for testability.
#
# N.B. This script duplicates function provided by
# "build_image --test"; that command option is the preferred
# command line interface for creating a test image. Please don't
# add features (options, command line syntax, whatever) to this
# script, unless it's necessary to maintain compatibility with
# "build_image".
#
# TODO(vlaviano): delete this script.
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
. "${SCRIPT_ROOT}/build_library/build_common.sh" || exit 1
DEFINE_string board "$DEFAULT_BOARD" "Board for which the image was built" b
DEFINE_boolean factory $FLAGS_FALSE \
"Modify the image for manufacturing testing" f
DEFINE_string image "" "Location of the rootfs raw image file" i
DEFINE_integer jobs -1 \
"How many packages to build in parallel at maximum." j
DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" y
DEFINE_boolean fast $DEFAULT_FAST "Call many emerges in parallel"
DEFINE_boolean inplace $FLAGS_TRUE \
"Modify/overwrite the image $CHROMEOS_IMAGE_NAME in place. \
Otherwise the image will be copied to $CHROMEOS_TEST_IMAGE_NAME \
(or $CHROMEOS_FACTORY_TEST_IMAGE_NAME for --factory) if needed, and \
modified there"
DEFINE_boolean force_copy $FLAGS_FALSE \
"Always rebuild test image if --noinplace"
DEFINE_boolean standard_backdoor ${FLAGS_TRUE} \
"Install standard backdoor credentials for testing"
# Parse command line
FLAGS "$@" || exit 1
eval set -- "$FLAGS_ARGV"
# Only now can we die on error. shflags functions leak non-zero error codes,
# so will die prematurely if 'switch_to_strict_mode' is specified before now.
switch_to_strict_mode
. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/mount_gpt_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/test_image_util.sh" || exit 1
sleep 5
# No image was provided. Use the standard latest image
if [ -z "$FLAGS_image" ]; then
IMAGES_DIR="$($SCRIPT_ROOT/get_latest_image.sh --board=$BOARD)"
FLAGS_image="$IMAGES_DIR/$CHROMEOS_IMAGE_NAME"
fi
# Turn path into an absolute path.
FLAGS_image=$(eval readlink -f "$FLAGS_image")
# Setting for build scripts.
BUILD_DIR="$(dirname "$FLAGS_image")"
ROOT_FS_DIR="${BUILD_DIR}/rootfs"
STATEFUL_FS_DIR="${BUILD_DIR}/stateful_partition"
# Copy the image to a test location if required
if [ $FLAGS_inplace -eq $FLAGS_FALSE ]; then
if [ $FLAGS_factory -eq $FLAGS_TRUE ]; then
TEST_PATHNAME="$BUILD_DIR/$CHROMEOS_FACTORY_TEST_IMAGE_NAME"
else
TEST_PATHNAME="$BUILD_DIR/$CHROMEOS_TEST_IMAGE_NAME"
fi
if [ ! -f "$TEST_PATHNAME" -o $FLAGS_force_copy -eq $FLAGS_TRUE ]; then
copy_image $(basename "$FLAGS_image") $(basename "$TEST_PATHNAME")
FLAGS_image="$TEST_PATHNAME"
else
echo "Using cached $(basename "${TEST_PATHNAME}")"
exit
fi
# No need to confirm now, since we are not overwriting the main image
FLAGS_yes=$FLAGS_TRUE
fi
# Abort early if we can't find the image
if [ ! -f "$FLAGS_image" ]; then
echo "No image found at $FLAGS_image"
exit 1
fi
# Make sure this is really what the user wants, before nuking the device
if [ $FLAGS_yes -ne $FLAGS_TRUE ]; then
read -p "Modifying image $FLAGS_image for test; are you sure (y/N)? " SURE
SURE="${SURE:0:1}" # Get just the first character
if [ "$SURE" != "y" ]; then
echo "Ok, better safe than sorry."
exit 1
fi
else
echo "Modifying image $FLAGS_image for test..."
fi
warn "THIS SCRIPT HAS BEEN DEPRECATED. IT MAY PRODUCE AN UN-BOOTABLE TEST" \
"IMAGE. TO BUILD A TEST IMAGE, USE build_image [FLAGS] test"
mod_image_for_test $(basename "$FLAGS_image")
print_time_elapsed