Changes to use default board when set by setup_board

Review URL: http://codereview.chromium.org/656023
This commit is contained in:
Chris Sosa 2010-02-23 15:20:03 -08:00
parent d185da4ee0
commit acada7387b
5 changed files with 63 additions and 11 deletions

View File

@ -4,7 +4,12 @@
#
# Provides common commands for dealing running/building autotest
DEFINE_string board "" "The board for which you are building autotest"
. "$(dirname "$0")/common.sh"
get_default_board
DEFINE_string board "$DEFAULT_BOARD" \
"The board for which you are building autotest"
function check_board() {
local board_names=""

View File

@ -11,7 +11,7 @@
# The user can later run autotest against an ssh enabled test client system, or
# install the compiled client tests directly onto the rootfs image.
. "$(dirname "$0")/common.sh"
# Includes common already
. "$(dirname $0)/autotest_lib.sh"
# Script must be run inside the chroot

View File

@ -141,6 +141,28 @@ esac
# -----------------------------------------------------------------------------
# Functions
function setup_board_warning {
echo
echo "$V_REVERSE================= WARNING ======================$V_VIDOFF"
echo
echo "*** No default board detected in " \
"$GCLIENT_ROOT/src/scripts/.default_board"
echo "*** Either run setup_board with default flag set"
echo "*** or echo |board_name| > $GCLIENT_ROOT/src/scripts/.default_board"
echo
}
# Sets the default board variable for calling script
function get_default_board {
DEFAULT_BOARD=
if [ -f "$GCLIENT_ROOT/src/scripts/.default_board" ] ; then
DEFAULT_BOARD=`cat "$GCLIENT_ROOT/src/scripts/.default_board"`
fi
}
# Make a package
function make_pkg_common {
# Positional parameters from calling script. :? means "fail if unset".

View File

@ -10,9 +10,10 @@
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
get_default_board
# Flags
DEFINE_string board "" "Board for which the image was built"
DEFINE_string board "$DEFAULT_BOARD" "Board for which the image was built"
DEFINE_string from "" \
"Directory containing rootfs.image and mbr.image"
DEFINE_string to "" "$DEFAULT_TO_HELP"
@ -38,12 +39,23 @@ fi
# Die on any errors.
set -e
# If from isn't explicitly set
# No board, no default and no image set then we can't find the image
if [ -z $FLAGS_from ] && [ -z $FLAGS_board ] ; then
setup_board_warning
exit 1
fi
# We have a board name but no image set. Use image at default location
if [ -z "$FLAGS_from" ]; then
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}"
FLAGS_from="${IMAGES_DIR}/$(ls -t $IMAGES_DIR 2>&-| head -1)"
fi
if [ ! -d "$FLAGS_from" ] ; then
echo "Cannot find image directory $FLAGS_from"
exit 1
fi
# If to isn't explicitly set
if [ -z "$FLAGS_to" ]; then
# Script can be run either inside or outside the chroot.

View File

@ -10,21 +10,34 @@
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
DEFAULT_BOARD=x86-generic
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${DEFAULT_BOARD}"
DEFAULT_IMAGE="${IMAGES_DIR}/$(ls -t $IMAGES_DIR 2>&-| head -1)/rootfs.image"
get_default_board
DEFINE_string board "$DEFAULT_BOARD" "Board for which the image was built"
DEFINE_string image "$DEFAULT_IMAGE" \
"Location of the rootfs raw image file"
DEFINE_string image "" "Location of the rootfs raw image file"
DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" "y"
# Parse command line
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${DEFAULT_BOARD}"
DEFAULT_IMAGE="${IMAGES_DIR}/$(ls -t $IMAGES_DIR 2>&-| head -1)/rootfs.image"
# No board, no default and no image set then we can't find the image
if [ -z $FLAGS_IMAGE ] && [ -z $FLAGS_board ] ; then
setup_board_warning
echo "*** mod_image_for_test failed. No board set and no image set"
exit 1
fi
# We have a board name but no image set. Use image at default location
if [ -z $FLAGS_image ] ; then
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}"
FLAGS_image="${IMAGES_DIR}/$(ls -t $IMAGES_DIR 2>&-| head -1)/rootfs.image"
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 anything mounted in the rootfs is cleaned up ok on exit.
cleanup_rootfs_mounts() {