This starts to fix the scripts so that they load from /usr/lib/crosutils

from within the chroot.

It also fixes a number of style issues.

It changes the meaning of cros_workon "list-all" to list all available
packages, and adds "list-live" to list all live packages.

It changes things that load chromeos-common.sh from the installer to
load it from /usr/lib/installer.

BUG=chromium-os:4230
TEST=synced, rebuilt chroot, made packages, made images, built chrome
from source, and wrote an image to a USB stick.

Review URL: http://codereview.chromium.org/6240018

Change-Id: I90c34420af1a64020402bafef8e9e77f56837c02
This commit is contained in:
Greg Spencer 2011-02-01 22:04:49 -08:00
parent 24da49e6ee
commit 798d75f3be
63 changed files with 1470 additions and 417 deletions

View File

@ -6,9 +6,26 @@
# Script to archive build results. Used by the buildbots. # Script to archive build results. Used by the buildbots.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Script must be run outside the chroot # Script must be run outside the chroot
assert_outside_chroot assert_outside_chroot
@ -43,7 +60,8 @@ DEFINE_string acl "private" \
DEFINE_string gsutil_archive "" \ DEFINE_string gsutil_archive "" \
"Optional datastore archive location" "Optional datastore archive location"
DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)" DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)"
DEFINE_boolean official_build $FLAGS_FALSE "Set CHROMEOS_OFFICIAL=1 for release builds." DEFINE_boolean official_build $FLAGS_FALSE \
"Set CHROMEOS_OFFICIAL=1 for release builds."
DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes"
DEFINE_boolean prebuilt_upload $FLAGS_FALSE "Upload prebuilt binary packages." DEFINE_boolean prebuilt_upload $FLAGS_FALSE "Upload prebuilt binary packages."
DEFINE_string to "$DEFAULT_TO" "Directory of build archive" DEFINE_string to "$DEFAULT_TO" "Directory of build archive"
@ -57,8 +75,7 @@ eval set -- "${FLAGS_ARGV}"
DEFAULT_USED= DEFAULT_USED=
# Reset "default" FLAGS_from based on passed-in board if not set on cmd-line # Reset "default" FLAGS_from based on passed-in board if not set on cmd-line
if [ "$FLAGS_from" = "$DEFAULT_FROM" ] if [ "$FLAGS_from" = "$DEFAULT_FROM" ]; then
then
# Keep the directory name of the current image set (*.bin). # Keep the directory name of the current image set (*.bin).
IMG_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" IMG_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)"
FLAGS_from="${IMAGES_DIR}/${FLAGS_board}/${IMG_DIR}" FLAGS_from="${IMAGES_DIR}/${FLAGS_board}/${IMG_DIR}"
@ -68,8 +85,7 @@ fi
# Die on any errors. # Die on any errors.
set -e set -e
if [ -z "$DEFAULT_USED" ] if [ -z "$DEFAULT_USED" ]; then
then
if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] || \ if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] || \
[ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] || \ [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] || \
[ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ]
@ -81,14 +97,12 @@ then
fi fi
fi fi
if [ ! -d "$FLAGS_from" ] if [ ! -d "$FLAGS_from" ]; then
then
echo "$FLAGS_from does not exist. Exiting..." echo "$FLAGS_from does not exist. Exiting..."
exit 1 exit 1
fi fi
if [ $FLAGS_official_build -eq $FLAGS_TRUE ] if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then
then
CHROMEOS_OFFICIAL=1 CHROMEOS_OFFICIAL=1
fi fi
@ -103,8 +117,7 @@ REVISION=${REVISION:0:8}
# Use the version number plus revision as the last change. (Need both, since # Use the version number plus revision as the last change. (Need both, since
# trunk builds multiple times with the same version string.) # trunk builds multiple times with the same version string.)
LAST_CHANGE="${CHROMEOS_VERSION_STRING}-r${REVISION}" LAST_CHANGE="${CHROMEOS_VERSION_STRING}-r${REVISION}"
if [ -n "$FLAGS_build_number" ] if [ -n "$FLAGS_build_number" ]; then
then
LAST_CHANGE="$LAST_CHANGE-b${FLAGS_build_number}" LAST_CHANGE="$LAST_CHANGE-b${FLAGS_build_number}"
fi fi
@ -141,8 +154,7 @@ function do_chroot_mod() {
} }
# Modify image for test if flag set. # Modify image for test if flag set.
if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] if [ $FLAGS_test_mod -eq $FLAGS_TRUE ]; then
then
echo "Modifying image for test" echo "Modifying image for test"
do_chroot_mod "${FLAGS_from}/chromiumos_test_image.bin" "" do_chroot_mod "${FLAGS_from}/chromiumos_test_image.bin" ""
@ -152,16 +164,14 @@ then
popd popd
fi fi
if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ]; then
then
echo "Modifying image for factory test" echo "Modifying image for factory test"
do_chroot_mod "${FLAGS_from}/chromiumos_factory_image.bin" \ do_chroot_mod "${FLAGS_from}/chromiumos_factory_image.bin" \
"--factory" "--factory"
fi fi
# Modify for recovery # Modify for recovery
if [ $FLAGS_official_build -eq $FLAGS_TRUE ] if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then
then
BUILDVER="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" BUILDVER="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)"
CHROOT_IMAGE_DIR=/home/$USER/trunk/src/build/images/$FLAGS_board/$BUILDVER CHROOT_IMAGE_DIR=/home/$USER/trunk/src/build/images/$FLAGS_board/$BUILDVER
./enter_chroot.sh -- ./mod_image_for_recovery.sh --board $FLAGS_board \ ./enter_chroot.sh -- ./mod_image_for_recovery.sh --board $FLAGS_board \
@ -175,8 +185,7 @@ fi
# Build differently sized shims. Currently only factory install shim is # Build differently sized shims. Currently only factory install shim is
# supported, TODO(tgao): Add developer shim. # supported, TODO(tgao): Add developer shim.
if [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] if [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then
then
echo "Building factory install shim." echo "Building factory install shim."
# HACK: The build system can't currently handle more than one image size # HACK: The build system can't currently handle more than one image size
# at a time. Therefor eit's necessary to do another round of build after # at a time. Therefor eit's necessary to do another round of build after
@ -205,8 +214,7 @@ MANIFEST=`ls | grep -v factory`
zip -r "${ZIPFILE}" ${MANIFEST} zip -r "${ZIPFILE}" ${MANIFEST}
if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \
[ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then
then
# We need to have directory structure for factory package, as # We need to have directory structure for factory package, as
# signing and packaging utilities need unpack_partitions.sh. # signing and packaging utilities need unpack_partitions.sh.
echo "Compressing factory software" echo "Compressing factory software"
@ -268,8 +276,7 @@ then
fi fi
if [ $FLAGS_prebuilt_upload -eq $FLAGS_TRUE ] if [ $FLAGS_prebuilt_upload -eq $FLAGS_TRUE ]; then
then
# Construct prebuilt upload command. # Construct prebuilt upload command.
# This will upload prebuilt packages to Google Storage. # This will upload prebuilt packages to Google Storage.
prebuilt_cmd="${SCRIPTS_DIR}/prebuilt.py" prebuilt_cmd="${SCRIPTS_DIR}/prebuilt.py"
@ -287,8 +294,7 @@ fi
gsutil_archive "${ZIPFILE}" "${LAST_CHANGE}/${FLAGS_zipname}" gsutil_archive "${ZIPFILE}" "${LAST_CHANGE}/${FLAGS_zipname}"
if [ $FLAGS_archive_debug -eq $FLAGS_TRUE ] if [ $FLAGS_archive_debug -eq $FLAGS_TRUE ]; then
then
echo "Generating Breakpad symbols" echo "Generating Breakpad symbols"
! ${SCRIPTS_DIR}/cros_generate_breakpad_symbols --board=${FLAGS_board} ! ${SCRIPTS_DIR}/cros_generate_breakpad_symbols --board=${FLAGS_board}
echo "Creating debug archive" echo "Creating debug archive"
@ -302,16 +308,14 @@ then
fi fi
if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \
[ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then
then
gsutil_archive "${FACTORY_ZIPFILE}" \ gsutil_archive "${FACTORY_ZIPFILE}" \
"${LAST_CHANGE}/factory_${FLAGS_zipname}" "${LAST_CHANGE}/factory_${FLAGS_zipname}"
fi fi
gsutil_archive "${FLAGS_to}/LATEST" "LATEST" gsutil_archive "${FLAGS_to}/LATEST" "LATEST"
# Purge old builds if necessary # Purge old builds if necessary
if [ $FLAGS_keep_max -gt 0 ] if [ $FLAGS_keep_max -gt 0 ]; then
then
echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..."
cd "$FLAGS_to" cd "$FLAGS_to"
# +2 because line numbers start at 1 and need to skip LATEST file # +2 because line numbers start at 1 and need to skip LATEST file

View File

@ -6,9 +6,26 @@
# Script to take an archived build result and prepare a hwqual release. # Script to take an archived build result and prepare a hwqual release.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Flags # Flags
DEFINE_string from "" "Directory with build archive (zipname)" DEFINE_string from "" "Directory with build archive (zipname)"
@ -42,7 +59,7 @@ function main() {
FLAGS_to="${FLAGS_from}" FLAGS_to="${FLAGS_from}"
fi fi
local script_dir=$(dirname "$0") local script_dir=${SCRIPTS_DIR}
script_dir=$(readlink -f "${script_dir}") script_dir=$(readlink -f "${script_dir}")
docgen_dir="autotest/utils/docgen" docgen_dir="autotest/utils/docgen"

View File

@ -6,8 +6,28 @@
# Returns the version of Chrome running on a remote machine. # Returns the version of Chrome running on a remote machine.
. "$(dirname $0)/../common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
. "$(dirname $0)/../remote_access.sh" # Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..")
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
. "${SCRIPT_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh"
FLAGS "$@" || exit 1 FLAGS "$@" || exit 1

View File

@ -7,21 +7,35 @@
# Script which ensures that a given image has an up-to-date # Script which ensures that a given image has an up-to-date
# kernel partition, rootfs integrity hashes, and legacy bootloader configs. # kernel partition, rootfs integrity hashes, and legacy bootloader configs.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
COMMON_PATH="$(dirname "$0")/../common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
if [ ! -r "${COMMON_PATH}" ]; then # location.
echo "ERROR! Cannot find common.sh: ${COMMON_PATH}" 1>&2 find_common_sh() {
exit 1 local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..")
fi local path
. "$(dirname "$0")/../common.sh" SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
# Script must be run inside the chroot. find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Need to be inside the chroot to load chromeos-common.sh
assert_inside_chroot assert_inside_chroot
# Load functions and constants for chromeos-install
. "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
set -e set -e
. "$(dirname "$0")/../chromeos-common.sh" # for partoffset and partsize
if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then
echo "Usage: ${0} /PATH/TO/IMAGE IMAGE.BIN [shflags overrides]" echo "Usage: ${0} /PATH/TO/IMAGE IMAGE.BIN [shflags overrides]"
@ -41,7 +55,7 @@ if [ ! -r "${BOOT_DESC_FILE}" ]; then
BOOT_DESC="${@}" BOOT_DESC="${@}"
else else
BOOT_DESC="$(cat ${BOOT_DESC_FILE} | tr -s '\n' ' ')" BOOT_DESC="$(cat ${BOOT_DESC_FILE} | tr -s '\n' ' ')"
info "Boot-time configuration for $(dirname ${IMAGE}): " info "Boot-time configuration for $(dirname "${IMAGE}"): "
cat ${BOOT_DESC_FILE} | while read line; do cat ${BOOT_DESC_FILE} | while read line; do
info " ${line}" info " ${line}"
done done
@ -138,7 +152,7 @@ make_image_bootable() {
fi fi
trap "mount_gpt_cleanup" EXIT trap "mount_gpt_cleanup" EXIT
${SCRIPTS_DIR}/mount_gpt_image.sh --from "$(dirname ${image})" \ "${SCRIPTS_DIR}/mount_gpt_image.sh" --from "$(dirname "${image}")" \
--image "$(basename ${image})" -r "${FLAGS_rootfs_mountpoint}" \ --image "$(basename ${image})" -r "${FLAGS_rootfs_mountpoint}" \
-s "${FLAGS_statefulfs_mountpoint}" -s "${FLAGS_statefulfs_mountpoint}"

View File

@ -6,24 +6,26 @@
# This script generates the list of board overlays and variants. # This script generates the list of board overlays and variants.
# --- BEGIN COMMON.SH BOILERPLATE ---
# Load common CrOS utilities. Inside the chroot this file is installed in # Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the scripts # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location. # location.
common_paths="/usr/lib/crosutils $(dirname "$0")/.." find_common_sh() {
local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..")
local path
for path in ${common_paths} ; do SCRIPT_ROOT=
if [ -f "${path}/common.sh" ] ; then for path in "${common_paths[@]}"; do
COMMON_SH="${path}/common.sh" if [ -r "${path}/common.sh" ]; then
break SCRIPT_ROOT=${path}
fi break
done fi
done
}
if [ -z "${COMMON_SH}" ] ; then find_common_sh
error "common.sh not found in search path (${common_paths})" . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
exit 1 # --- END COMMON.SH BOILERPLATE ---
fi
. "${COMMON_SH}"
get_default_board get_default_board

View File

@ -7,16 +7,28 @@
# Script to update a running device with an optionally built package out # Script to update a running device with an optionally built package out
# of your build directory # of your build directory
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..")
local path
script_root=$(dirname $0) SCRIPT_ROOT=
if [ -f ${script_root}/../common.sh ] ; then for path in "${common_paths[@]}"; do
script_root=${script_root}/.. if [ -r "${path}/common.sh" ]; then
fi SCRIPT_ROOT=${path}
break
fi
done
}
. "${script_root}/common.sh" find_common_sh
. "${script_root}/remote_access.sh" . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
. "${SCRIPT_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh"
get_default_board get_default_board
@ -89,8 +101,8 @@ for pkg in $@; do
echo "Could not find latest built version of ${pkg}" echo "Could not find latest built version of ${pkg}"
exit 1 exit 1
fi fi
pkg_dir=$(basename $(dirname $latest_pkg)) pkg_dir=$(basename "$(dirname "$latest_pkg")")
pkg_name=$(basename $latest_pkg) pkg_name=$(basename "$latest_pkg")
echo "Installing ${latest_pkg}..." echo "Installing ${latest_pkg}..."
remote_sh "mktemp -d /tmp/cros_package_to_live.XXXX" remote_sh "mktemp -d /tmp/cros_package_to_live.XXXX"

View File

@ -7,11 +7,33 @@
# Script to resign the kernel partition generated in the output of build_image # Script to resign the kernel partition generated in the output of build_image
# with keys of our choosing. # with keys of our choosing.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/../common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..")
local path
. "$(dirname "$0")/../chromeos-common.sh" # for partoffset and partsize SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Need to be inside the chroot to load chromeos-common.sh
assert_inside_chroot
# Load functions and constants for chromeos-install
. "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
locate_gpt locate_gpt

View File

@ -1,4 +1,7 @@
#!/bin/bash #!/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.
# Usage: # Usage:
# revert_image.sh [image_to_revert] # revert_image.sh [image_to_revert]
@ -6,7 +9,7 @@
# This assumes the image has been updated by update_image.sh. # This assumes the image has been updated by update_image.sh.
usage() usage()
{ {
cat <<EOF cat <<EOF
usage: usage:
revert_image.sh [image_to_revert] revert_image.sh [image_to_revert]
@ -19,24 +22,23 @@ if [[ $# < 1 ]]; then
exit 1 exit 1
fi fi
IMAGE=$( readlink -f ${1} ) IMAGE=$(readlink -f "$1")
IMAGE_DIR=$( dirname ${IMAGE} ) IMAGE_DIR=$(dirname "$IMAGE")
if [[ -z "${IMAGE}" ]]; then if [[ -z "$IMAGE" ]]; then
echo "Missing required argument 'image_to_revert'" echo "Missing required argument 'image_to_revert'"
usage usage
exit 1 exit 1
fi fi
cd ${IMAGE_DIR} cd "$IMAGE_DIR"
if [[ ! -d "./orig_partitions" ]]; then if [[ ! -d "./orig_partitions" ]]; then
echo "Could not find original partitions." echo "Could not find original partitions."
exit 1 exit 1
fi fi
yes | cp ./orig_partitions/* ./ cp -f ./orig_partitions/* ./
./pack_partitions.sh ${IMAGE} ./pack_partitions.sh "$IMAGE"
rm -rf ./orig_partitions rm -rf ./orig_partitions
cd -

View File

@ -6,9 +6,30 @@
# #
# Runs a given test case under a VM. # Runs a given test case under a VM.
. "$(dirname $0)/../common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
. "$(dirname $0)/../lib/cros_vm_lib.sh" # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/../lib/cros_vm_constants.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..")
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
. "${SCRIPT_ROOT}/lib/cros_vm_lib.sh" || die "Unable to load cros_vm_lib.sh"
. "${SCRIPT_ROOT}/lib/cros_vm_constants.sh" || \
die "Unable to load cros_vm_constants.sh"
MAX_RETRIES=3 MAX_RETRIES=3
@ -73,7 +94,7 @@ retry_until_ssh ${MAX_RETRIES}
if [ -n "${FLAGS_verify_chrome_version}" ]; then if [ -n "${FLAGS_verify_chrome_version}" ]; then
info "Verifying version of Chrome matches what we expect." info "Verifying version of Chrome matches what we expect."
if chrome_version_is_valid "${FLAGS_verify_chrome_version}"; then if chrome_version_is_valid "${FLAGS_verify_chrome_version}"; then
chrome_version_on_vm=$("$(dirname $0)/cros_get_chrome_version" \ chrome_version_on_vm=$("${SCRIPTS_DIR}/bin/cros_get_chrome_version" \
--remote=127.0.0.1 \ --remote=127.0.0.1 \
--ssh_port=${FLAGS_ssh_port}) --ssh_port=${FLAGS_ssh_port})
[[ ${chrome_version_on_vm} == ${FLAGS_verify_chrome_version} ]] || \ [[ ${chrome_version_on_vm} == ${FLAGS_verify_chrome_version} ]] || \
@ -83,7 +104,7 @@ if [ -n "${FLAGS_verify_chrome_version}" ]; then
fi fi
fi fi
"$(dirname $0)"/../run_remote_tests.sh \ "${SCRIPTS_DIR}/run_remote_tests.sh" \
--board=${FLAGS_board} \ --board=${FLAGS_board} \
--ssh_port=${FLAGS_ssh_port} \ --ssh_port=${FLAGS_ssh_port} \
--remote=127.0.0.1 \ --remote=127.0.0.1 \

View File

@ -6,8 +6,28 @@
# #
# Updates an existing vm image with another image. # Updates an existing vm image with another image.
. "$(dirname $0)/../common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
. "$(dirname $0)/../lib/cros_vm_lib.sh" # Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..")
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
. "${SCRIPT_ROOT}/lib/cros_vm_lib.sh" || die "Unable to load cros_vm_lib.sh"
DEFINE_string payload "" "Full name of the payload to update with." DEFINE_string payload "" "Full name of the payload to update with."
DEFINE_string proxy_port "" \ DEFINE_string proxy_port "" \
@ -43,7 +63,7 @@ if [ -n "${FLAGS_proxy_port}" ]; then
IMAGE_ARGS="${IMAGE_ARGS} --proxy_port=${FLAGS_proxy_port}" IMAGE_ARGS="${IMAGE_ARGS} --proxy_port=${FLAGS_proxy_port}"
fi fi
$(dirname $0)/../image_to_live.sh \ "${SCRIPTS_DIR}/image_to_live.sh" \
--for_vm \ --for_vm \
--remote=127.0.0.1 \ --remote=127.0.0.1 \
--ssh_port=${FLAGS_ssh_port} \ --ssh_port=${FLAGS_ssh_port} \

View File

@ -7,17 +7,26 @@
# Wrapper script around run_remote_tests.sh that knows how to find # Wrapper script around run_remote_tests.sh that knows how to find
# device test cells. # device test cells.
# --- BEGIN COMMON.SH BOILERPLATE ---
# Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..")
local path
# TODO(pstew): Apparently the script files are in transition from SCRIPT_ROOT=
# src/scripts to src/scripts/bin. However this state has existed for path in "${common_paths[@]}"; do
# for months now, therefore we need to look for the common libs in if [ -r "${path}/common.sh" ]; then
# both places SCRIPT_ROOT=${path}
script_root=$(dirname $0) break
if [ -f ${script_root}/../common.sh ] ; then fi
script_root=${script_root}/.. done
fi }
. "${script_root}/common.sh" find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Figure out the default chromelab server name. In order for this to # Figure out the default chromelab server name. In order for this to
# work correctly, you have to: # work correctly, you have to:
@ -145,10 +154,10 @@ fi
set $ret set $ret
remote=$1 remote=$1
shift shift
for arg in $*; do for arg in "$@"; do
append_arg $arg append_arg $arg
done done
eval "exec ${script_root}/run_remote_tests.sh \ eval "exec ${SCRIPTS_DIR}/run_remote_tests.sh \
--args=\"${run_remote_args}\" --remote=${remote} $run_remote_flags \ --args=\"${run_remote_args}\" --remote=${remote} $run_remote_flags \
$FLAGS_ARGV" $FLAGS_ARGV"

View File

@ -7,11 +7,33 @@
# Script to resign the kernel partition generated in the output of build_image # Script to resign the kernel partition generated in the output of build_image
# with SSD keys. # with SSD keys.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/../common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..")
local path
. "$(dirname "$0")/../chromeos-common.sh" # for partoffset and partsize SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Need to be inside the chroot to load chromeos-common.sh
assert_inside_chroot
# Load functions and constants for chromeos-install
. "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
locate_gpt locate_gpt
@ -44,7 +66,7 @@ fi
# ../../tests/devkeys/ \ # ../../tests/devkeys/ \
# /.../build/images/x86-mario/0.8.68.2/chromiumos_test_ssd_image.bin # /.../build/images/x86-mario/0.8.68.2/chromiumos_test_ssd_image.bin
VBOOT_DIR="$(dirname "$0")/../../platform/vboot_reference" VBOOT_DIR="${SRC_ROOT}/platform/vboot_reference"
if [ ! -d "${VBOOT_DIR}" ]; then if [ ! -d "${VBOOT_DIR}" ]; then
die "VBOOT DIR NOT FOUND at \'${VBOOT_DIR}\' .." die "VBOOT DIR NOT FOUND at \'${VBOOT_DIR}\' .."
fi fi

View File

@ -6,9 +6,30 @@
# #
# Simple wrapper scipt to start a vm using the vm lib. # Simple wrapper scipt to start a vm using the vm lib.
. "$(dirname $0)/../common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
. "$(dirname $0)/../lib/cros_vm_lib.sh" # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/../lib/cros_vm_constants.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..")
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
. "${SCRIPT_ROOT}/lib/cros_vm_lib.sh" || die "Unable to load cros_vm_lib.sh"
. "${SCRIPT_ROOT}/lib/cros_vm_constants.sh" || \
die "Unable to load cros_vm_constants.sh"
get_default_board get_default_board

View File

@ -6,8 +6,28 @@
# #
# Simple wrapper scipt to stop a vm specified from a pid file. # Simple wrapper scipt to stop a vm specified from a pid file.
. "$(dirname $0)/../common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
. "$(dirname $0)/../lib/cros_vm_lib.sh" # Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..")
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
. "${SCRIPT_ROOT}/lib/cros_vm_lib.sh" || die "Unable to load cros_vm_lib.sh"
set -e set -e

View File

@ -1,4 +1,7 @@
#!/bin/bash #!/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.
# Usage: # Usage:
# update_image.sh [image_to_update] [packages...] # update_image.sh [image_to_update] [packages...]
@ -24,7 +27,7 @@ else
fi fi
IMAGE=$( readlink -f ${1} ) IMAGE=$( readlink -f ${1} )
IMAGE_DIR=$( dirname ${IMAGE} ) IMAGE_DIR=$( dirname "${IMAGE}" )
shift shift
PKGS=$@ PKGS=$@

View File

@ -7,7 +7,26 @@
# Simple wrapper script to build a cros_workon package incrementally. # Simple wrapper script to build a cros_workon package incrementally.
# You must already be cros_workon'ing the package in question. # You must already be cros_workon'ing the package in question.
. "$(dirname $0)/../common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
# Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..")
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Script must be run inside the chroot. # Script must be run inside the chroot.
restart_in_chroot_if_needed "$@" restart_in_chroot_if_needed "$@"

View File

@ -11,14 +11,31 @@
# chroot environment. # chroot environment.
# #
# SCRIPT_DIR="$(cd "$(dirname $0)/.." ; pwd)" # --- BEGIN COMMON.SH BOILERPLATE ---
SCRIPT_DIR=$HOME/trunk/src/scripts # Load common CrOS utilities. Inside the chroot this file is installed in
. "$SCRIPT_DIR/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..")
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
DEFINE_string output_dir "" "output directory for results" o DEFINE_string output_dir "" "output directory for results" o
DEFINE_boolean keep_logs "$FLAGS_FALSE" "keep autotest results" k DEFINE_boolean keep_logs "$FLAGS_FALSE" "keep autotest results" k
RUN_TEST="$SCRIPT_DIR/run_remote_tests.sh" RUN_TEST="$SCRIPTS_DIR/run_remote_tests.sh"
TEST=server/site_tests/platform_BootPerfServer/control TEST=server/site_tests/platform_BootPerfServer/control
TMP_RESULTS="/tmp/bootperf.$(date '+%Y%j%H%M').$$" TMP_RESULTS="/tmp/bootperf.$(date '+%Y%j%H%M').$$"
RESULTS_DIR=platform_BootPerfServer/platform_BootPerfServer/results RESULTS_DIR=platform_BootPerfServer/platform_BootPerfServer/results

View File

@ -3,16 +3,38 @@
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. # 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 # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
#
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Load functions and constants for chromeos-install # Load functions and constants for chromeos-install
. "$(dirname "$0")/chromeos-common.sh" [ -f /usr/lib/installer/chromeos-common.sh ] && \
INSTALLER_ROOT=/usr/lib/installer || \
INSTALLER_ROOT=$(dirname "$(readlink -f "$0")")
. "${INSTALLER_ROOT}/chromeos-common.sh" || \
die "Unable to load chromeos-common.sh"
# Script must be run inside the chroot. # Script must be run inside the chroot.
restart_in_chroot_if_needed $* restart_in_chroot_if_needed "$@"
get_default_board get_default_board

View File

@ -9,15 +9,39 @@
# the given target's root with binary packages turned on. This script will # the given target's root with binary packages turned on. This script will
# build the Chrome OS image using only pre-built binary packages. # build the Chrome OS image using only pre-built binary packages.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Load functions and constants for chromeos-install
[ -f /usr/lib/installer/chromeos-common.sh ] && \
INSTALLER_ROOT=/usr/lib/installer || \
INSTALLER_ROOT=$(dirname "$(readlink -f "$0")")
. "${INSTALLER_ROOT}/chromeos-common.sh" || \
die "Unable to load chromeos-common.sh"
. "$(dirname "$0")/chromeos-common.sh" # for partoffset
locate_gpt locate_gpt
# Script must be run inside the chroot. # Script must be run inside the chroot.
restart_in_chroot_if_needed $* restart_in_chroot_if_needed "$@"
get_default_board get_default_board

View File

@ -6,7 +6,26 @@
# Helper script that generates the signed kernel image # Helper script that generates the signed kernel image
. "$(dirname "$0")/common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
# Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
get_default_board get_default_board

View File

@ -9,7 +9,26 @@
# Set pipefail so it will capture any nonzer exit codes # Set pipefail so it will capture any nonzer exit codes
set -o pipefail set -o pipefail
. "$(dirname "$0")/common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
# Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
AUTOTEST_ROOT=${SRC_ROOT}/third_party/autotest/files AUTOTEST_ROOT=${SRC_ROOT}/third_party/autotest/files
CHECKSCRIPT=${AUTOTEST_ROOT}/utils/check_control_file_vars.py CHECKSCRIPT=${AUTOTEST_ROOT}/utils/check_control_file_vars.py

View File

@ -1,3 +1,4 @@
#!/bin/sh
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. # 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 # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
@ -7,9 +8,26 @@
# failures. This script only affects mountpoints and loopback devices # failures. This script only affects mountpoints and loopback devices
# that were created within this chroot. # that were created within this chroot.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Script must be run inside the chroot. # Script must be run inside the chroot.
assert_inside_chroot assert_inside_chroot
@ -24,8 +42,7 @@ OUTPUT_DIR="${FLAGS_output_root}/${FLAGS_board}"
echo "This will unmount any directory under $OUTPUT_DIR:" echo "This will unmount any directory under $OUTPUT_DIR:"
read -p "Are you sure (y/N)? " SURE read -p "Are you sure (y/N)? " SURE
SURE="${SURE:0:1}" # Get just the first character SURE="${SURE:0:1}" # Get just the first character
if [ "${SURE}" != "y" ] if [ "${SURE}" != "y" ]; then
then
echo "Ok, better safe than sorry." echo "Ok, better safe than sorry."
exit 1 exit 1
fi fi

View File

@ -12,10 +12,12 @@
# The number of jobs to pass to tools that can run in parallel (such as make # The number of jobs to pass to tools that can run in parallel (such as make
# and dpkg-buildpackage # and dpkg-buildpackage
NUM_JOBS=`grep -c "^processor" /proc/cpuinfo` NUM_JOBS=$(grep -c "^processor" /proc/cpuinfo)
# Store location of the calling script. # Make sure we have the location and name of the calling script, using
TOP_SCRIPT_DIR="${TOP_SCRIPT_DIR:-$(dirname $0)}" # the current value if it is already set.
SCRIPT_LOCATION=${SCRIPT_LOCATION:-$(dirname "$(readlink -f "$0")")}
SCRIPT_NAME=${SCRIPT_NAME:-$(basename "$0")}
# Detect whether we're inside a chroot or not # Detect whether we're inside a chroot or not
if [ -e /etc/debian_chroot ] if [ -e /etc/debian_chroot ]
@ -77,8 +79,8 @@ get_gclient_root
# FOO = "$(cd $FOO ; pwd)" # FOO = "$(cd $FOO ; pwd)"
# since that leaves symbolic links intact. # since that leaves symbolic links intact.
# Note that 'realpath' is equivalent to 'readlink -f'. # Note that 'realpath' is equivalent to 'readlink -f'.
TOP_SCRIPT_DIR=`readlink -f $TOP_SCRIPT_DIR` SCRIPT_LOCATION=$(readlink -f $SCRIPT_LOCATION)
GCLIENT_ROOT=`readlink -f $GCLIENT_ROOT` GCLIENT_ROOT=$(readlink -f $GCLIENT_ROOT)
# Other directories should always be pathed down from GCLIENT_ROOT. # Other directories should always be pathed down from GCLIENT_ROOT.
SRC_ROOT="$GCLIENT_ROOT/src" SRC_ROOT="$GCLIENT_ROOT/src"
@ -89,10 +91,9 @@ SCRIPTS_DIR="$SRC_ROOT/scripts"
# since that's available both inside and outside the chroot. By convention, # since that's available both inside and outside the chroot. By convention,
# settings from this file are variables starting with 'CHROMEOS_' # settings from this file are variables starting with 'CHROMEOS_'
CHROMEOS_DEV_SETTINGS="${CHROMEOS_DEV_SETTINGS:-$SCRIPTS_DIR/.chromeos_dev}" CHROMEOS_DEV_SETTINGS="${CHROMEOS_DEV_SETTINGS:-$SCRIPTS_DIR/.chromeos_dev}"
if [ -f $CHROMEOS_DEV_SETTINGS ] if [ -f $CHROMEOS_DEV_SETTINGS ]; then
then
# Turn on exit-on-error during custom settings processing # Turn on exit-on-error during custom settings processing
SAVE_OPTS=`set +o` SAVE_OPTS=$(set +o)
set -e set -e
# Read settings # Read settings
@ -106,7 +107,7 @@ fi
if [[ -f /usr/lib/shflags ]]; then if [[ -f /usr/lib/shflags ]]; then
. /usr/lib/shflags . /usr/lib/shflags
elif [ -f ./lib/shflags/shflags ]; then elif [ -f ./lib/shflags/shflags ]; then
. "./lib/shflags/shflags" . ./lib/shflags/shflags
else else
. "${SRC_ROOT}/scripts/lib/shflags/shflags" . "${SRC_ROOT}/scripts/lib/shflags/shflags"
fi fi
@ -142,7 +143,7 @@ ALL_BOARDS=$(echo $ALL_BOARDS)
DEFAULT_BOARD=$(echo $ALL_BOARDS | awk '{print $NF}') DEFAULT_BOARD=$(echo $ALL_BOARDS | awk '{print $NF}')
# Enable --fast by default. # Enable --fast by default.
DEFAULT_FAST="${FLAGS_TRUE}" DEFAULT_FAST=${FLAGS_TRUE}
# Directory locations inside the dev chroot # Directory locations inside the dev chroot
CHROOT_TRUNK_DIR="/home/$USER/trunk" CHROOT_TRUNK_DIR="/home/$USER/trunk"
@ -216,8 +217,7 @@ case "$(basename $0)" in
echo "RUNNING OLD BUILD SYSTEM SCRIPTS. RUN THE PORTAGE-BASED BUILD HERE:" echo "RUNNING OLD BUILD SYSTEM SCRIPTS. RUN THE PORTAGE-BASED BUILD HERE:"
echo "http://www.chromium.org/chromium-os/building-chromium-os/portage-based-build" echo "http://www.chromium.org/chromium-os/building-chromium-os/portage-based-build"
echo echo
if [ "$USER" != "chrome-bot" ] if [ "$USER" != "chrome-bot" ]; then
then
read -n1 -p "Press any key to continue using the OLD build system..." read -n1 -p "Press any key to continue using the OLD build system..."
echo echo
echo echo
@ -245,7 +245,7 @@ function get_default_board {
DEFAULT_BOARD= DEFAULT_BOARD=
if [ -f "$GCLIENT_ROOT/src/scripts/.default_board" ] ; then if [ -f "$GCLIENT_ROOT/src/scripts/.default_board" ] ; then
DEFAULT_BOARD=`cat "$GCLIENT_ROOT/src/scripts/.default_board"` DEFAULT_BOARD=$(cat "$GCLIENT_ROOT/src/scripts/.default_board")
fi fi
} }
@ -272,17 +272,17 @@ function make_pkg_common {
set -e set -e
# Make output dir # Make output dir
OUT_DIR="$FLAGS_build_root/x86/local_packages" local out_dir="$FLAGS_build_root/x86/local_packages"
mkdir -p "$OUT_DIR" mkdir -p "$out_dir"
# Remove previous package from output dir # Remove previous package from output dir
rm -f "$OUT_DIR"/${PKG_BASE}_*.deb rm -f "$out_dir"/${PKG_BASE}_*.deb
# Rebuild the package # Rebuild the package
pushd "$TOP_SCRIPT_DIR" pushd "$SCRIPT_LOCATION"
rm -f ../${PKG_BASE}_*.deb rm -f ../${PKG_BASE}_*.deb
dpkg-buildpackage -b -tc -us -uc -j$NUM_JOBS dpkg-buildpackage -b -tc -us -uc -j$NUM_JOBS
mv ../${PKG_BASE}_*.deb "$OUT_DIR" mv ../${PKG_BASE}_*.deb "$out_dir"
rm ../${PKG_BASE}_*.changes rm ../${PKG_BASE}_*.changes
popd popd
} }
@ -290,19 +290,19 @@ function make_pkg_common {
# Enter a chroot and restart the current script if needed # Enter a chroot and restart the current script if needed
function restart_in_chroot_if_needed { function restart_in_chroot_if_needed {
# NB: Pass in ARGV: restart_in_chroot_if_needed "$@" # NB: Pass in ARGV: restart_in_chroot_if_needed "$@"
if [ $INSIDE_CHROOT -ne 1 ] if [ $INSIDE_CHROOT -ne 1 ]; then
then local abspath=$(readlink -f "$0")
# Equivalent to enter_chroot.sh -- <current command> # strip everything up to (and including) /scripts/ from abspath
local path_from_scripts="${abspath##*/scripts/}"
exec $SCRIPTS_DIR/enter_chroot.sh -- \ exec $SCRIPTS_DIR/enter_chroot.sh -- \
$CHROOT_TRUNK_DIR/src/scripts/$(basename $0) "$@" "$CHROOT_TRUNK_DIR/src/scripts/$path_from_scripts" "$@"
fi fi
} }
# Fail unless we're inside the chroot. This guards against messing up your # Fail unless we're inside the chroot. This guards against messing up your
# workstation. # workstation.
function assert_inside_chroot { function assert_inside_chroot {
if [ $INSIDE_CHROOT -ne 1 ] if [ $INSIDE_CHROOT -ne 1 ]; then
then
echo "This script must be run inside the chroot. Run this first:" echo "This script must be run inside the chroot. Run this first:"
echo " $SCRIPTS_DIR/enter_chroot.sh" echo " $SCRIPTS_DIR/enter_chroot.sh"
exit 1 exit 1
@ -312,33 +312,19 @@ function assert_inside_chroot {
# Fail if we're inside the chroot. This guards against creating or entering # Fail if we're inside the chroot. This guards against creating or entering
# nested chroots, among other potential problems. # nested chroots, among other potential problems.
function assert_outside_chroot { function assert_outside_chroot {
if [ $INSIDE_CHROOT -ne 0 ] if [ $INSIDE_CHROOT -ne 0 ]; then
then
echo "This script must be run outside the chroot." echo "This script must be run outside the chroot."
exit 1 exit 1
fi fi
} }
function assert_not_root_user { function assert_not_root_user {
if [ `id -u` = 0 ]; then if [ $(id -u) = 0 ]; then
echo "This script must be run as a non-root user." echo "This script must be run as a non-root user."
exit 1 exit 1
fi fi
} }
# Install a package if it's not already installed
function install_if_missing {
# Positional parameters from calling script. :? means "fail if unset".
PKG_NAME=${1:?}
shift
if [ -z `which $PKG_NAME` ]
then
echo "Can't find $PKG_NAME; attempting to install it."
sudo apt-get --yes --force-yes install $PKG_NAME
fi
}
# Returns true if the input file is whitelisted. # Returns true if the input file is whitelisted.
# #
# $1 - The file to check # $1 - The file to check
@ -402,12 +388,12 @@ function die {
# Retry an emerge command according to $FLAGS_retries # Retry an emerge command according to $FLAGS_retries
# The $EMERGE_JOBS flags will only be added the first time the command is run # The $EMERGE_JOBS flags will only be added the first time the command is run
function eretry () { function eretry () {
local i= local i
for i in $(seq $FLAGS_retries); do for i in $(seq $FLAGS_retries); do
echo Retrying $* echo "Retrying $@"
$* $EMERGE_JOBS && return 0 "$@" $EMERGE_JOBS && return 0
done done
$* && return 0 "$@" && return 0
return 1 return 1
} }
@ -455,6 +441,7 @@ function safe_umount {
fix_broken_symlinks() { fix_broken_symlinks() {
local build_root="${1}" local build_root="${1}"
local symlinks=$(find "${build_root}/usr/local" -lname "${build_root}/*") local symlinks=$(find "${build_root}/usr/local" -lname "${build_root}/*")
local symlink
for symlink in ${symlinks}; do for symlink in ${symlinks}; do
echo "Fixing ${symlink}" echo "Fixing ${symlink}"
local target=$(ls -l "${symlink}" | cut -f 2 -d '>') local target=$(ls -l "${symlink}" | cut -f 2 -d '>')
@ -491,6 +478,7 @@ setup_symlinks_on_root() {
fi fi
# Set up symlinks that should point to ${dev_image_target}. # Set up symlinks that should point to ${dev_image_target}.
local path
for path in usr local; do for path in usr local; do
if [ -h "${dev_image_root}/${path}" ]; then if [ -h "${dev_image_root}/${path}" ]; then
sudo unlink "${dev_image_root}/${path}" sudo unlink "${dev_image_root}/${path}"
@ -556,10 +544,10 @@ start_time=$(date +%s)
# Print time elsapsed since start_time. # Print time elsapsed since start_time.
print_time_elapsed() { print_time_elapsed() {
end_time=$(date +%s) local end_time=$(date +%s)
elapsed_seconds="$(( $end_time - $start_time ))" local elapsed_seconds=$(($end_time - $start_time))
minutes="$(( $elapsed_seconds / 60 ))" local minutes=$(($elapsed_seconds / 60))
seconds="$(( $elapsed_seconds % 60 ))" local seconds=$(($elapsed_seconds % 60))
echo "Elapsed time: ${minutes}m${seconds}s" echo "Elapsed time: ${minutes}m${seconds}s"
} }
@ -574,7 +562,7 @@ print_time_elapsed() {
# ${1} specifies the location of the chroot. # ${1} specifies the location of the chroot.
chroot_hacks_from_outside() { chroot_hacks_from_outside() {
# Give args better names. # Give args better names.
local chroot_dir="${1}" local chroot_dir=$1
# Add root as a sudoer if not already done. # Add root as a sudoer if not already done.
if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then

View File

@ -6,7 +6,26 @@
# Creates an empty ESP image. # Creates an empty ESP image.
. "$(dirname "$0")/common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
# Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
get_default_board get_default_board

View File

@ -6,7 +6,26 @@
# Helper script that generates the signed kernel image # Helper script that generates the signed kernel image
. "$(dirname "$0")/common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
# Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
get_default_board get_default_board

View File

@ -7,9 +7,26 @@
# Downloads the latest buildbot image and prints the path to it. # Downloads the latest buildbot image and prints the path to it.
# This script only works if you have access to buildbot images. # This script only works if you have access to buildbot images.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
get_default_board get_default_board

View File

@ -9,12 +9,29 @@
# NOTE: This script must be run from the chromeos build chroot environment. # NOTE: This script must be run from the chromeos build chroot environment.
# #
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Script must be run inside the chroot # Script must be run inside the chroot
restart_in_chroot_if_needed $* restart_in_chroot_if_needed "$@"
get_default_board get_default_board
@ -39,7 +56,7 @@ function cleanup() {
# Given path to a debug file, return its text file # Given path to a debug file, return its text file
function get_text_for_debug() { function get_text_for_debug() {
local debug_file=$1 local debug_file=$1
local text_dir=$(dirname ${debug_file#$DEBUG_ROOT}) local text_dir=$(dirname "${debug_file#$DEBUG_ROOT}")
local text_path=${SYSROOT}${text_dir}/$(basename "${debug_file}" .debug) local text_path=${SYSROOT}${text_dir}/$(basename "${debug_file}" .debug)
echo ${text_path} echo ${text_path}
} }

View File

@ -7,12 +7,33 @@
# Script to generate a Chromium OS update for use by the update engine. # Script to generate a Chromium OS update for use by the update engine.
# If a source .bin is specified, the update is assumed to be a delta update. # If a source .bin is specified, the update is assumed to be a delta update.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Need to be inside the chroot to load chromeos-common.sh
assert_inside_chroot
# Load functions and constants for chromeos-install # Load functions and constants for chromeos-install
. "$(dirname "$0")/chromeos-common.sh" . "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
SRC_MNT="" SRC_MNT=""
DST_MNT="" DST_MNT=""
@ -233,7 +254,7 @@ else
fi fi
DST_ROOT=$(extract_partition_to_temp_file "$FLAGS_image" 3) DST_ROOT=$(extract_partition_to_temp_file "$FLAGS_image" 3)
GENERATOR="$(dirname "$0")/mk_memento_images.sh" GENERATOR="${SCRIPTS_DIR}/mk_memento_images.sh"
CROS_GENERATE_UPDATE_PAYLOAD_CALLED=1 "$GENERATOR" "$DST_KERNEL" "$DST_ROOT" CROS_GENERATE_UPDATE_PAYLOAD_CALLED=1 "$GENERATOR" "$DST_KERNEL" "$DST_ROOT"
mv "$(dirname "$DST_KERNEL")/update.gz" "$FLAGS_output" mv "$(dirname "$DST_KERNEL")/update.gz" "$FLAGS_output"

View File

@ -27,9 +27,26 @@
# #
# Example usage: ./cros_mark_branch_as_stable # Example usage: ./cros_mark_branch_as_stable
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
function is_workon() { xargs grep -lE '^inherit.*cros-workon'; } function is_workon() { xargs grep -lE '^inherit.*cros-workon'; }
function is_stable() { xargs grep -lE '^KEYWORDS=[^~]*$'; } function is_stable() { xargs grep -lE '^KEYWORDS=[^~]*$'; }
@ -38,8 +55,8 @@ function is_unstable() { xargs grep -lE '^KEYWORDS=.*~'; }
function get_workon_commit() { function get_workon_commit() {
# Get the latest workon commit associated with an ebuild. # Get the latest workon commit associated with an ebuild.
ebuild="$1" ebuild="$1"
dir=$(dirname $ebuild) dir=$(dirname "$ebuild")
CATEGORY=$(basename $(dirname "$dir")) CATEGORY=$(basename "$(dirname "$dir")")
CROS_WORKON_LOCALNAME=$(basename "$dir") CROS_WORKON_LOCALNAME=$(basename "$dir")
CROS_WORKON_SUBDIR= CROS_WORKON_SUBDIR=
@ -65,7 +82,7 @@ function get_workon_commit() {
cd $SRCDIR && git rev-parse HEAD cd $SRCDIR && git rev-parse HEAD
} }
BLACKLIST_FILE=$(dirname "$0")/cros_mark_as_stable_blacklist BLACKLIST_FILE="${SCRIPTS_DIR}/cros_mark_as_stable_blacklist"
BLACKLIST=$(cat "$BLACKLIST_FILE") BLACKLIST=$(cat "$BLACKLIST_FILE")
if [[ -n "$BLACKLIST" ]]; then if [[ -n "$BLACKLIST" ]]; then
die "$0 does not support cros_mark_as_stable_blacklist" die "$0 does not support cros_mark_as_stable_blacklist"

View File

@ -10,7 +10,26 @@
# This script requires that you run build_packages first. # This script requires that you run build_packages first.
. "$(dirname "$0")/common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
# Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
get_default_board get_default_board
@ -76,7 +95,7 @@ if [ -z "${FLAGS_package_file}" -a -z "${FLAGS_packages}" ]; then
egrep '^chromeos-base' ) egrep '^chromeos-base' )
fi fi
BLACK_LIST_FILE="$(dirname "$0")/unit_test_black_list.txt" BLACK_LIST_FILE="${SCRIPTS_DIR}/unit_test_black_list.txt"
if [ "${FLAGS_withdebug}" -eq "${FLAGS_FALSE}" ]; then if [ "${FLAGS_withdebug}" -eq "${FLAGS_FALSE}" ]; then
export USE="${USE} -cros-debug" export USE="${USE} -cros-debug"

View File

@ -6,11 +6,28 @@
# Script to generate stackdumps from a machine or dmp files. # Script to generate stackdumps from a machine or dmp files.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
. "$(dirname $0)/common.sh" SCRIPT_ROOT=
. "$(dirname $0)/remote_access.sh" for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
. "${SCRIPT_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh"
assert_inside_chroot assert_inside_chroot

View File

@ -10,12 +10,29 @@
# is intended to support development. The current source tip is fetched, # is intended to support development. The current source tip is fetched,
# source modified and built using the unstable 'live' (9999) ebuild. # source modified and built using the unstable 'live' (9999) ebuild.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Script must be run inside the chroot # Script must be run inside the chroot
restart_in_chroot_if_needed $* restart_in_chroot_if_needed "$@"
get_default_board get_default_board
DEFINE_string board "${DEFAULT_BOARD}" \ DEFINE_string board "${DEFAULT_BOARD}" \
@ -42,7 +59,6 @@ eval set -- "${FLAGS_ARGV}"
WORKON_CMD=$1 WORKON_CMD=$1
shift shift
# Board dir config # Board dir config
# If both are specified, just use host, because board does not # If both are specified, just use host, because board does not
@ -98,7 +114,8 @@ if [ ! -L "${UNMASK_FILE}" ]; then
fi fi
find_keyword_workon_ebuilds() { find_keyword_workon_ebuilds() {
keyword="${1}" local keyword="${1}"
local overlay
local cros_overlays=$("${PORTAGEQCMD}" envvar PORTDIR_OVERLAY) local cros_overlays=$("${PORTAGEQCMD}" envvar PORTDIR_OVERLAY)
@ -112,7 +129,7 @@ find_keyword_workon_ebuilds() {
} }
show_workon_ebuilds() { show_workon_ebuilds() {
keyword=$1 local keyword=$1
find_keyword_workon_ebuilds ${keyword} | \ find_keyword_workon_ebuilds ${keyword} | \
sed -e 's/.*\/\([^/]*\)\/\([^/]*\)\/.*\.ebuild/\1\/\2/' | \ sed -e 's/.*\/\([^/]*\)\/\([^/]*\)\/.*\.ebuild/\1\/\2/' | \
@ -150,6 +167,7 @@ canonicalize_name () {
canonicalize_names () { canonicalize_names () {
local atoms=$1 local atoms=$1
local names="" local names=""
local atom
for atom in ${atoms}; do for atom in ${atoms}; do
local name=$(canonicalize_name "${atom}") local name=$(canonicalize_name "${atom}")
@ -168,6 +186,7 @@ show_live_ebuilds () {
# Display ebuilds currently part of the live branch and open for development # Display ebuilds currently part of the live branch and open for development
# for any board that currently has live ebuilds. # for any board that currently has live ebuilds.
show_all_live_ebuilds () { show_all_live_ebuilds () {
local workon_file
for workon_file in ${WORKON_DIR}/*; do for workon_file in ${WORKON_DIR}/*; do
if [ -s "${workon_file}" ]; then if [ -s "${workon_file}" ]; then
echo -e "${V_BOLD_GREEN}$(basename ${workon_file}):${V_VIDOFF}" echo -e "${V_BOLD_GREEN}$(basename ${workon_file}):${V_VIDOFF}"
@ -177,7 +196,10 @@ show_all_live_ebuilds () {
done done
} }
# This is called only for "cros-workon start". We dont handle the "stop" case since the local changes are ignored anyway since the 9999.ebuild is masked and we dont want to deal with what to do with the user's local changes. # This is called only for "cros-workon start". We dont handle the
# "stop" case since the local changes are ignored anyway since the
# 9999.ebuild is masked and we dont want to deal with what to do with
# the user's local changes.
regen_manifest_and_sync() { regen_manifest_and_sync() {
# Nothing to do unless you are working on the minilayout # Nothing to do unless you are working on the minilayout
local manifest=${CHROOT_TRUNK_DIR}/.repo/manifest.xml local manifest=${CHROOT_TRUNK_DIR}/.repo/manifest.xml
@ -185,6 +207,7 @@ regen_manifest_and_sync() {
return return
fi fi
local pkgname
for pkgname in $(show_live_ebuilds); do for pkgname in $(show_live_ebuilds); do
eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info) eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info)
local srcdir=$(readlink -m ${CROS_WORKON_SRCDIR}) local srcdir=$(readlink -m ${CROS_WORKON_SRCDIR})
@ -201,6 +224,7 @@ regen_manifest_and_sync() {
ebuild_to_live () { ebuild_to_live () {
local atoms=$1 local atoms=$1
local atoms_success="" local atoms_success=""
local atom
for atom in ${atoms}; do for atom in ${atoms}; do
if ! grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then if ! grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then
@ -219,6 +243,7 @@ ebuild_to_live () {
ebuild_to_stable () { ebuild_to_stable () {
local atoms=$1 local atoms=$1
local atoms_success="" local atoms_success=""
local atom
for atom in ${atoms}; do for atom in ${atoms}; do
if grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then if grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then
@ -236,6 +261,7 @@ ebuild_to_stable () {
# Run a command on all or a set of repos. # Run a command on all or a set of repos.
ebuild_iterate() { ebuild_iterate() {
local atoms=$1 local atoms=$1
local atom
for atom in ${atoms}; do for atom in ${atoms}; do
info "Running \"${FLAGS_command}\" on ${atom}" info "Running \"${FLAGS_command}\" on ${atom}"
@ -249,7 +275,7 @@ if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then
case ${WORKON_CMD} in case ${WORKON_CMD} in
start) ATOM_LIST=$(show_workon_ebuilds ${BOARD_KEYWORD});; start) ATOM_LIST=$(show_workon_ebuilds ${BOARD_KEYWORD});;
stop|iterate) ATOM_LIST=$(show_live_ebuilds);; stop|iterate) ATOM_LIST=$(show_live_ebuilds);;
list|list-all) ;; list) ;;
*) die "--all is invalid for the given command";; *) die "--all is invalid for the given command";;
esac esac
else # not selected --all else # not selected --all
@ -266,10 +292,11 @@ else # not selected --all
fi fi
case ${WORKON_CMD} in case ${WORKON_CMD} in
start) ebuild_to_live "${ATOM_LIST}" ;; start) ebuild_to_live "${ATOM_LIST}" ;;
stop) ebuild_to_stable "${ATOM_LIST}" ;; stop) ebuild_to_stable "${ATOM_LIST}" ;;
list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ${BOARD_KEYWORD} ;; list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || \
show_workon_ebuilds ${BOARD_KEYWORD} ;;
list-all) show_all_live_ebuilds ;; list-all) show_all_live_ebuilds ;;
iterate)ebuild_iterate "${ATOM_LIST}" ;; iterate) ebuild_iterate "${ATOM_LIST}" ;;
*) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;;
esac esac

View File

@ -5,10 +5,33 @@
# #
# Emit scripts to pack and unpack the partitions from a GPT disk image. # Emit scripts to pack and unpack the partitions from a GPT disk image.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
. "$(dirname "$0")/chromeos-common.sh" # location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Need to be inside the chroot to load chromeos-common.sh
assert_inside_chroot
# Load functions and constants for chromeos-install
. "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
set -e set -e

View File

@ -4,8 +4,7 @@
# found in the LICENSE file. # found in the LICENSE file.
set -e set -e
if [ -z $1 ] if [ -z $1 ]; then
then
echo "Usage: $0 localaccount_username [chroot_path]" echo "Usage: $0 localaccount_username [chroot_path]"
exit 1 exit 1
fi fi

View File

@ -6,9 +6,26 @@
# Script to enter the chroot environment # Script to enter the chroot environment
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Script must be run outside the chroot and as a regular user. # Script must be run outside the chroot and as a regular user.
assert_outside_chroot assert_outside_chroot
@ -87,8 +104,7 @@ eval set -- "${_FLAGS_FIXED}"
FLAGS "$@" || exit 1 FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}" eval set -- "${FLAGS_ARGV}"
if [ $FLAGS_official_build -eq $FLAGS_TRUE ] if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then
then
CHROMEOS_OFFICIAL=1 CHROMEOS_OFFICIAL=1
fi fi
@ -117,31 +133,26 @@ function setup_env {
# Mount only if not already mounted # Mount only if not already mounted
MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/proc")" MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/proc")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then
then
sudo mount none -t proc "$MOUNTED_PATH" || \ sudo mount none -t proc "$MOUNTED_PATH" || \
die "Could not mount $MOUNTED_PATH" die "Could not mount $MOUNTED_PATH"
fi fi
MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/sys")" MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/sys")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then
then
sudo mount none -t sysfs "$MOUNTED_PATH" || \ sudo mount none -t sysfs "$MOUNTED_PATH" || \
die "Could not mount $MOUNTED_PATH" die "Could not mount $MOUNTED_PATH"
fi fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}/dev")" MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}/dev")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then
then
sudo mount --bind /dev "$MOUNTED_PATH" || \ sudo mount --bind /dev "$MOUNTED_PATH" || \
die "Could not mount $MOUNTED_PATH" die "Could not mount $MOUNTED_PATH"
fi fi
if [ $FLAGS_ssh_agent -eq $FLAGS_TRUE ]; then if [ $FLAGS_ssh_agent -eq $FLAGS_TRUE ]; then
TARGET_DIR="$(readlink -f "${FLAGS_chroot}/home/${USER}/.ssh")" TARGET_DIR="$(readlink -f "${FLAGS_chroot}/home/${USER}/.ssh")"
if [ -n "${SSH_AUTH_SOCK}" \ if [ -n "${SSH_AUTH_SOCK}" -a -d "${HOME}/.ssh" ]; then
-a -d "${HOME}/.ssh" ]
then
mkdir -p "${TARGET_DIR}" mkdir -p "${TARGET_DIR}"
cp -r "${HOME}/.ssh/known_hosts" "${TARGET_DIR}" cp -r "${HOME}/.ssh/known_hosts" "${TARGET_DIR}"
cp -r "${HOME}/.ssh/config" "${TARGET_DIR}" cp -r "${HOME}/.ssh/config" "${TARGET_DIR}"
@ -153,22 +164,19 @@ function setup_env {
fi fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}/dev/pts")" MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}/dev/pts")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then
then
sudo mount none -t devpts "$MOUNTED_PATH" || \ sudo mount none -t devpts "$MOUNTED_PATH" || \
die "Could not mount $MOUNTED_PATH" die "Could not mount $MOUNTED_PATH"
fi fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}$CHROOT_TRUNK_DIR")" MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}$CHROOT_TRUNK_DIR")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then
then
sudo mount --bind "$FLAGS_trunk" "$MOUNTED_PATH" || \ sudo mount --bind "$FLAGS_trunk" "$MOUNTED_PATH" || \
die "Could not mount $MOUNTED_PATH" die "Could not mount $MOUNTED_PATH"
fi fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${INNER_CHROME_ROOT}")" MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${INNER_CHROME_ROOT}")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then
then
! CHROME_ROOT="$(readlink -f "$FLAGS_chrome_root")" ! CHROME_ROOT="$(readlink -f "$FLAGS_chrome_root")"
if [ -z "$CHROME_ROOT" ]; then if [ -z "$CHROME_ROOT" ]; then
! CHROME_ROOT="$(cat "${FLAGS_chroot}${CHROME_ROOT_CONFIG}" \ ! CHROME_ROOT="$(cat "${FLAGS_chroot}${CHROME_ROOT_CONFIG}" \
@ -188,11 +196,10 @@ function setup_env {
fi fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${INNER_DEPOT_TOOLS_ROOT}")" MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${INNER_DEPOT_TOOLS_ROOT}")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then
then
if [ $(which gclient 2>/dev/null) ]; then if [ $(which gclient 2>/dev/null) ]; then
info "Mounting depot_tools" info "Mounting depot_tools"
DEPOT_TOOLS=$(dirname $(which gclient) ) DEPOT_TOOLS=$(dirname "$(which gclient)")
mkdir -p "$MOUNTED_PATH" mkdir -p "$MOUNTED_PATH"
if ! sudo mount --bind "$DEPOT_TOOLS" "$MOUNTED_PATH"; then if ! sudo mount --bind "$DEPOT_TOOLS" "$MOUNTED_PATH"; then
warn "depot_tools failed to mount; perhaps it's on NFS?" warn "depot_tools failed to mount; perhaps it's on NFS?"
@ -202,7 +209,7 @@ function setup_env {
fi fi
# Install fuse module. # Install fuse module.
if [ -c "${FUSE_DEVICE}" ] ; then if [ -c "${FUSE_DEVICE}" ]; then
sudo modprobe fuse 2> /dev/null ||\ sudo modprobe fuse 2> /dev/null ||\
warn "-- Note: modprobe fuse failed. gmergefs will not work" warn "-- Note: modprobe fuse failed. gmergefs will not work"
fi fi
@ -271,8 +278,7 @@ function teardown_env {
) 200>>"$LOCKFILE" || die "teardown_env failed" ) 200>>"$LOCKFILE" || die "teardown_env failed"
} }
if [ $FLAGS_mount -eq $FLAGS_TRUE ] if [ $FLAGS_mount -eq $FLAGS_TRUE ]; then
then
setup_env setup_env
info "Make sure you run" info "Make sure you run"
info " $0 --unmount" info " $0 --unmount"
@ -281,8 +287,7 @@ then
exit 0 exit 0
fi fi
if [ $FLAGS_unmount -eq $FLAGS_TRUE ] if [ $FLAGS_unmount -eq $FLAGS_TRUE ]; then
then
teardown_env teardown_env
exit 0 exit 0
fi fi

View File

@ -6,9 +6,26 @@
# Prints the path to the most recently built image to stdout. # Prints the path to the most recently built image to stdout.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
get_default_board get_default_board

View File

@ -7,7 +7,26 @@
# Lists all package dependencies of a particular package. Useful to find out # Lists all package dependencies of a particular package. Useful to find out
# all packages depended on by chromeos and chromeos-dev. # all packages depended on by chromeos and chromeos-dev.
. "$(dirname "$0")/common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
# Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Script must be run inside the chroot. # Script must be run inside the chroot.
assert_inside_chroot assert_inside_chroot

View File

@ -6,10 +6,28 @@
# Run gmergefs from the scripts directory. # Run gmergefs from the scripts directory.
COMMON_SH="$(dirname "$0")/common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
. "$COMMON_SH" # Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Script must be run inside the chroot. # Script must be run inside the chroot.
assert_inside_chroot assert_inside_chroot
cd ${GCLIENT_ROOT}/src/platform/dev && ./gmergefs $* cd ${GCLIENT_ROOT}/src/platform/dev && ./gmergefs "$@"

View File

@ -23,20 +23,41 @@
#------ These are the scripts we're trying to kill --------# #------ These are the scripts we're trying to kill --------#
# --- BEGIN COMMON.SH BOILERPLATE ---
# Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
function mod_image_for_test() { function mod_image_for_test() {
$(dirname ${0})/mod_image_for_test.sh $* || return $? "${SCRIPTS_DIR}/mod_image_for_test.sh" "$@" || return $?
} }
function mod_image_for_recovery() { function mod_image_for_recovery() {
$(dirname ${0})/mod_image_for_recovery.sh $* || return $? "${SCRIPTS_DIR}/mod_image_for_recovery.sh" "$@" || return $?
} }
function mod_image_for_dev_recovery() { function mod_image_for_dev_recovery() {
$(dirname ${0})/mod_image_for_dev_recovery.sh $* || return $? "${SCRIPTS_DIR}/mod_image_for_dev_recovery.sh" "$@" || return $?
} }
function customize_rootfs() { function customize_rootfs() {
$(dirname ${0})/customize_rootfs $* || return $? "${SCRIPTS_DIR}/customize_rootfs" "$@" || return $?
} }
#-------------------------- Tools -------------------------# #-------------------------- Tools -------------------------#
@ -73,7 +94,6 @@ function corrupt_for_test() {
} }
function main() { function main() {
. "$(dirname "$0")/common.sh"
get_default_board get_default_board
# Flag definitions: # Flag definitions:
@ -116,10 +136,10 @@ function main() {
} }
case "$(basename $0)" in case "$(basename $0)" in
# (mod_image_for_test.sh) mod_image_for_test $* || return $?;; # (mod_image_for_test.sh) mod_image_for_test "$@" || return $?;;
# (mod_image_for_recovery.sh) mod_image_for_recovery $* || return $?;; # (mod_image_for_recovery.sh) mod_image_for_recovery "$@" || return $?;;
# (mod_image_for_dev_recovery.sh) mod_image_for_dev_recovery $* || return $?;; # (mod_image_for_dev_recovery.sh) mod_image_for_dev_recovery "$@" || return $?;;
# (customize_rootfs) customize_rootfs $* || return $?;; # (customize_rootfs) customize_rootfs "$@" || return $?;;
(image_hacks.sh) main $* || return $?;; # normal invocation (image_hacks.sh) main "$@" || return $?;; # normal invocation
(*) echo "$0: Unknown invocation!"; exit 1 ;; (*) echo "$0: Unknown invocation!"; exit 1 ;;
esac esac

View File

@ -6,11 +6,28 @@
# Script to update an image onto a live running ChromiumOS instance. # Script to update an image onto a live running ChromiumOS instance.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
. "$(dirname $0)/common.sh" SCRIPT_ROOT=
. "$(dirname $0)/remote_access.sh" for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
. "${SCRIPT_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh"
# Flags to control image_to_live. # Flags to control image_to_live.
DEFINE_boolean ignore_hostname ${FLAGS_TRUE} \ DEFINE_boolean ignore_hostname ${FLAGS_TRUE} \
@ -130,7 +147,7 @@ function start_dev_server {
# IMAGE_PATH should be the newest image and learn the board from # IMAGE_PATH should be the newest image and learn the board from
# the target. # the target.
learn_board learn_board
IMAGE_PATH="$($(dirname "$0")/get_latest_image.sh --board="${FLAGS_board}")" IMAGE_PATH="$(${SCRIPTS_DIR}/get_latest_image.sh --board="${FLAGS_board}")"
IMAGE_PATH="${IMAGE_PATH}/chromiumos_image.bin" IMAGE_PATH="${IMAGE_PATH}/chromiumos_image.bin"
devserver_flags="${devserver_flags} \ devserver_flags="${devserver_flags} \
--image $(reinterpret_path_for_chroot ${IMAGE_PATH})" --image $(reinterpret_path_for_chroot ${IMAGE_PATH})"
@ -160,8 +177,7 @@ function start_dev_server {
info "Waiting on devserver to start" info "Waiting on devserver to start"
info "note: be patient as the server generates the update before starting." info "note: be patient as the server generates the update before starting."
until netstat -anp 2>&1 | grep 0.0.0.0:${FLAGS_devserver_port} > /dev/null until netstat -anp 2>&1 | grep 0.0.0.0:${FLAGS_devserver_port} > /dev/null; do
do
sleep 5 sleep 5
echo -n "." echo -n "."
if ! pgrep -f start_devserver > /dev/null; then if ! pgrep -f start_devserver > /dev/null; then
@ -314,7 +330,7 @@ function run_auto_update {
function verify_image { function verify_image {
info "Verifying image." info "Verifying image."
"${SCRIPTS_DIR}/mount_gpt_image.sh" --from "$(dirname ${IMAGE_PATH})" \ "${SCRIPTS_DIR}/mount_gpt_image.sh" --from "$(dirname "${IMAGE_PATH}")" \
--image "$(basename ${IMAGE_PATH})" \ --image "$(basename ${IMAGE_PATH})" \
--read_only --read_only
@ -345,7 +361,7 @@ function find_root_dev {
function main() { function main() {
assert_outside_chroot assert_outside_chroot
cd $(dirname "$0") cd "${SCRIPTS_DIR}"
FLAGS "$@" || exit 1 FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}" eval set -- "${FLAGS_ARGV}"

View File

@ -6,12 +6,34 @@
# Script to convert the output of build_image.sh to a usb image. # Script to convert the output of build_image.sh to a usb image.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Load functions and constants for chromeos-install # Load functions and constants for chromeos-install
. "$(dirname "$0")/chromeos-common.sh" [ -f /usr/lib/installer/chromeos-common.sh ] && \
INSTALLER_ROOT=/usr/lib/installer || \
INSTALLER_ROOT=$(dirname "$(readlink -f "$0")")
. "${INSTALLER_ROOT}/chromeos-common.sh" || \
die "Unable to load chromeos-common.sh"
get_default_board get_default_board
@ -183,8 +205,7 @@ fi
# Let's do it. # Let's do it.
if [ -b "${FLAGS_to}" ] if [ -b "${FLAGS_to}" ]; then
then
# Output to a block device (i.e., a real USB key), so need sudo dd # Output to a block device (i.e., a real USB key), so need sudo dd
if [ ${FLAGS_install} -ne ${FLAGS_TRUE} ]; then if [ ${FLAGS_install} -ne ${FLAGS_TRUE} ]; then
echo "Copying USB image ${SRC_IMAGE} to device ${FLAGS_to}..." echo "Copying USB image ${SRC_IMAGE} to device ${FLAGS_to}..."
@ -205,24 +226,21 @@ then
fi fi
# Make sure this is really what the user wants, before nuking the device # Make sure this is really what the user wants, before nuking the device
if [ ${FLAGS_yes} -ne ${FLAGS_TRUE} ] if [ ${FLAGS_yes} -ne ${FLAGS_TRUE} ]; then
then
sudo fdisk -l "${FLAGS_to}" 2>/dev/null | grep Disk | head -1 sudo fdisk -l "${FLAGS_to}" 2>/dev/null | grep Disk | head -1
[ -n "$disk_manufacturer" ] && echo "Manufacturer: $disk_manufacturer" [ -n "$disk_manufacturer" ] && echo "Manufacturer: $disk_manufacturer"
[ -n "$disk_product" ] && echo "Product: $disk_product" [ -n "$disk_product" ] && echo "Product: $disk_product"
echo "This will erase all data on this device:" echo "This will erase all data on this device:"
read -p "Are you sure (y/N)? " SURE read -p "Are you sure (y/N)? " SURE
SURE="${SURE:0:1}" # Get just the first character SURE="${SURE:0:1}" # Get just the first character
if [ "${SURE}" != "y" ] if [ "${SURE}" != "y" ]; then
then
echo "Ok, better safe than sorry." echo "Ok, better safe than sorry."
exit 1 exit 1
fi fi
fi fi
echo "Attempting to unmount any mounts on the USB device..." echo "Attempting to unmount any mounts on the USB device..."
for i in $(mount | grep ^"${FLAGS_to}" | awk '{print $1}') for i in $(mount | grep ^"${FLAGS_to}" | awk '{print $1}'); do
do
if sudo umount "$i" 2>&1 >/dev/null | grep "not found"; then if sudo umount "$i" 2>&1 >/dev/null | grep "not found"; then
echo echo
echo "The device you have specified is already mounted at some point " echo "The device you have specified is already mounted at some point "

View File

@ -5,9 +5,27 @@
# found in the LICENSE file. # found in the LICENSE file.
# Script to convert the output of build_image.sh to a VirtualBox image. # Script to convert the output of build_image.sh to a VirtualBox image.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location. # --- BEGIN COMMON.SH BOILERPLATE ---
. "$(dirname "$0")/common.sh" # Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images" IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images"
# Default to the most recent image # Default to the most recent image
@ -28,7 +46,7 @@ eval set -- "${FLAGS_ARGV}"
# Die on any errors. # Die on any errors.
set -e set -e
# Convert args to paths. Need eval to un-quote the string so that shell # Convert args to paths. Need eval to un-quote the string so that shell
# chars like ~ are processed; just doing FOO=`readlink -f $FOO` won't work. # chars like ~ are processed; just doing FOO=`readlink -f $FOO` won't work.
FLAGS_from=`eval readlink -f $FLAGS_from` FLAGS_from=`eval readlink -f $FLAGS_from`
FLAGS_to=`eval readlink -f $FLAGS_to` FLAGS_to=`eval readlink -f $FLAGS_to`
@ -41,5 +59,5 @@ for EXTERNAL_tools in qemu-img VBoxManage; do
fi fi
done done
$(dirname "$0")/image_to_vmware.sh --format=virtualbox --from=$FLAGS_from \ "${SCRIPTS_DIR}/image_to_vmware.sh" --format=virtualbox --from="$FLAGS_from" \
--to=$(dirname "$FLAGS_to") --vbox_disk=$(basename "$FLAGS_to") --to="$(dirname "$FLAGS_to")" --vbox_disk="$(basename "$FLAGS_to")"

View File

@ -7,14 +7,38 @@
# Script to convert the output of build_image.sh to a VMware image and write a # Script to convert the output of build_image.sh to a VMware image and write a
# corresponding VMware config file. # corresponding VMware config file.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
. "$(dirname "$0")/chromeos-common.sh" # location.
. "$(dirname "$0")/lib/cros_vm_constants.sh" find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Need to be inside the chroot to load chromeos-common.sh
assert_inside_chroot
# Load functions and constants for chromeos-install
. "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
. "${SCRIPT_ROOT}/lib/cros_vm_constants.sh" || \
die "Unable to load ${SCRIPT_ROOT}/lib/cros_vm_constants.sh"
get_default_board get_default_board
assert_inside_chroot
# Flags # Flags
DEFINE_string board "${DEFAULT_BOARD}" \ DEFINE_string board "${DEFAULT_BOARD}" \
@ -120,7 +144,7 @@ if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then
fi fi
# Memory units are in MBs # Memory units are in MBs
TEMP_IMG="$(dirname ${SRC_IMAGE})/vm_temp_image.bin" TEMP_IMG="$(dirname "${SRC_IMAGE}")/vm_temp_image.bin"
# If we're not building for VMWare, don't build the vmx # If we're not building for VMWare, don't build the vmx
if [ "${FLAGS_format}" != "vmware" ]; then if [ "${FLAGS_format}" != "vmware" ]; then
@ -189,11 +213,11 @@ mkdir -p "${TEMP_ESP_MNT}"
sudo mount -o loop "${TEMP_ESP}" "${TEMP_ESP_MNT}" sudo mount -o loop "${TEMP_ESP}" "${TEMP_ESP_MNT}"
if [ "${FLAGS_format}" = "qemu" ]; then if [ "${FLAGS_format}" = "qemu" ]; then
sudo python "$(dirname $0)/fixup_image_for_qemu.py" \ sudo python "${SCRIPTS_DIR}/fixup_image_for_qemu.py" \
--mounted_dir="${TEMP_MNT}" \ --mounted_dir="${TEMP_MNT}" \
--enable_tablet=true --enable_tablet=true
else else
sudo python "$(dirname $0)/fixup_image_for_qemu.py" \ sudo python "${SCRIPTS_DIR}/fixup_image_for_qemu.py" \
--mounted_dir="${TEMP_MNT}" \ --mounted_dir="${TEMP_MNT}" \
--enable_tablet=false --enable_tablet=false
fi fi

View File

@ -4,9 +4,26 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images" IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images"
@ -22,8 +39,7 @@ eval set -- "${FLAGS_ARGV}"
# Die on any errors. # Die on any errors.
set -e set -e
if [ -z "${FLAGS_from}" -o -z "${FLAGS_to}" -o -z "${FLAGS_offset}" ] if [ -z "${FLAGS_from}" -o -z "${FLAGS_to}" -o -z "${FLAGS_offset}" ]; then
then
echo "You must define all of from, to and offset." echo "You must define all of from, to and offset."
exit 1 exit 1
fi fi

View File

@ -69,7 +69,7 @@ function start_kvm() {
fi fi
local net_option="-net nic,model=virtio" local net_option="-net nic,model=virtio"
if [ -f "$(dirname $1)/.use_e1000" ]; then if [ -f "$(dirname "$1")/.use_e1000" ]; then
info "Detected older image, using e1000 instead of virtio." info "Detected older image, using e1000 instead of virtio."
net_option="-net nic,model=e1000" net_option="-net nic,model=e1000"
fi fi
@ -91,7 +91,7 @@ function start_kvm() {
# Checks to see if we can access the target virtual machine with ssh. # Checks to see if we can access the target virtual machine with ssh.
function ssh_ping() { function ssh_ping() {
"$(dirname $0)"/../ssh_test.sh \ "${SCRIPT_ROOT}/ssh_test.sh" \
--ssh_port=${FLAGS_ssh_port} \ --ssh_port=${FLAGS_ssh_port} \
--remote=127.0.0.1 >&2 --remote=127.0.0.1 >&2
} }

View File

@ -9,12 +9,33 @@
# It is very straight forward, top to bottom to show clearly what is # It is very straight forward, top to bottom to show clearly what is
# little is needed to create a developer shim to run a signed script. # little is needed to create a developer shim to run a signed script.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Need to be inside the chroot to load chromeos-common.sh
assert_inside_chroot
# Load functions and constants for chromeos-install # Load functions and constants for chromeos-install
. "$(dirname "$0")/chromeos-common.sh" . "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
DEFINE_integer statefulfs_size 2 \ DEFINE_integer statefulfs_size 2 \
"Number of mebibytes to use for the stateful filesystem" "Number of mebibytes to use for the stateful filesystem"

View File

@ -11,15 +11,36 @@
# miniomaha lives in src/platform/dev/ and miniomaha partition sets live # miniomaha lives in src/platform/dev/ and miniomaha partition sets live
# in src/platform/dev/static. # in src/platform/dev/static.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Need to be inside the chroot to load chromeos-common.sh
assert_inside_chroot
# Load functions and constants for chromeos-install # Load functions and constants for chromeos-install
. "$(dirname "$0")/chromeos-common.sh" . "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
# Load functions designed for image processing # Load functions designed for image processing
. "$(dirname "$0")/lib/cros_image_common.sh" || . "${SCRIPT_ROOT}/lib/cros_image_common.sh" ||
die "Cannot load required library: lib/cros_image_common.sh; Abort." die "Cannot load required library: lib/cros_image_common.sh; Abort."
get_default_board get_default_board

View File

@ -10,8 +10,31 @@
set -e set -e
# --- BEGIN COMMON.SH BOILERPLATE ---
# Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# Load functions designed for image processing # Load functions designed for image processing
if ! . "$(dirname "$0")/lib/cros_image_common.sh"; then if ! . "${SCRIPT_ROOT}/lib/cros_image_common.sh"; then
echo "ERROR: Cannot load required library: lib/cros_image_common.sh; Abort." echo "ERROR: Cannot load required library: lib/cros_image_common.sh; Abort."
exit 1 exit 1
fi fi

View File

@ -9,19 +9,37 @@
# kernel. Alternatively, a signed recovery kernel can be used to # kernel. Alternatively, a signed recovery kernel can be used to
# create a Chromium OS recovery image. # create a Chromium OS recovery image.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Need to be inside the chroot to load chromeos-common.sh
assert_inside_chroot
# Load functions and constants for chromeos-install # Load functions and constants for chromeos-install
. "$(dirname "$0")/chromeos-common.sh" . "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
# For update_partition_table # For update_partition_table
. "$(dirname "$0")/resize_stateful_partition.sh" . "${SCRIPT_ROOT}/resize_stateful_partition.sh" || \
die "Unable to load ${SCRIPT_ROOT}/resize_stateful_partition.sh"
# We need to be in the chroot to emerge test packages.
assert_inside_chroot
get_default_board get_default_board
@ -371,7 +389,7 @@ RECOVERY_KERNEL_IMAGE=\
"${FLAGS_kernel_outfile:-${IMAGE_DIR}/recovery_vmlinuz.image}" "${FLAGS_kernel_outfile:-${IMAGE_DIR}/recovery_vmlinuz.image}"
RECOVERY_KERNEL_VBLOCK="${RECOVERY_KERNEL_IMAGE}.vblock" RECOVERY_KERNEL_VBLOCK="${RECOVERY_KERNEL_IMAGE}.vblock"
STATEFUL_DIR="$IMAGE_DIR/stateful_partition" STATEFUL_DIR="$IMAGE_DIR/stateful_partition"
SCRIPTS_DIR=$(dirname "$0") SCRIPTS_DIR=${SCRIPT_ROOT}
# Mounts gpt image and sets up var, /usr/local and symlinks. # Mounts gpt image and sets up var, /usr/local and symlinks.
# If there's a dev payload, mount stateful # If there's a dev payload, mount stateful

View File

@ -6,15 +6,33 @@
# Script to modify a keyfob-based chromeos system image for testability. # Script to modify a keyfob-based chromeos system image for testability.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Need to be inside the chroot to load chromeos-common.sh
assert_inside_chroot
# Load functions and constants for chromeos-install # Load functions and constants for chromeos-install
. "$(dirname "$0")/chromeos-common.sh" . "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
# We need to be in the chroot to emerge test packages.
assert_inside_chroot
get_default_board get_default_board
@ -92,8 +110,7 @@ cleanup_mounts() {
# root/stateful image file system open. We do a best effort attempt to kill # root/stateful image file system open. We do a best effort attempt to kill
# them. # them.
PIDS=`sudo lsof -t "$1" | sort | uniq` PIDS=`sudo lsof -t "$1" | sort | uniq`
for pid in ${PIDS} for pid in ${PIDS}; do
do
local cmdline=`cat /proc/$pid/cmdline` local cmdline=`cat /proc/$pid/cmdline`
echo "Killing process that has open file on the mounted directory: $cmdline" echo "Killing process that has open file on the mounted directory: $cmdline"
sudo kill $pid || /bin/true sudo kill $pid || /bin/true
@ -169,11 +186,11 @@ fi
set -e set -e
IMAGE_DIR="$(dirname "$FLAGS_image")" IMAGE_DIR=$(dirname "$FLAGS_image")
IMAGE_NAME="$(basename "$FLAGS_image")" IMAGE_NAME="$(basename "$FLAGS_image")"
ROOT_FS_DIR="$IMAGE_DIR/rootfs" ROOT_FS_DIR="$IMAGE_DIR/rootfs"
STATEFUL_DIR="$IMAGE_DIR/stateful_partition" STATEFUL_DIR="$IMAGE_DIR/stateful_partition"
SCRIPTS_DIR=$(dirname "$0") SCRIPTS_DIR=${SCRIPT_ROOT}
DEV_USER="chronos" DEV_USER="chronos"
trap cleanup EXIT trap cleanup EXIT
@ -229,7 +246,7 @@ fi
cleanup cleanup
# Now make it bootable with the flags from build_image # Now make it bootable with the flags from build_image
${SCRIPTS_DIR}/bin/cros_make_image_bootable $(dirname "${FLAGS_image}") \ "${SCRIPTS_DIR}/bin/cros_make_image_bootable" "$(dirname "${FLAGS_image}")" \
$(basename "${FLAGS_image}") $(basename "${FLAGS_image}")
print_time_elapsed print_time_elapsed

View File

@ -7,10 +7,34 @@
# Helper script that mounts chromium os image from a device or directory # Helper script that mounts chromium os image from a device or directory
# and creates mount points for /var and /usr/local (if in dev_mode). # and creates mount points for /var and /usr/local (if in dev_mode).
. "$(dirname "$0")/common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
# Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Need to be inside the chroot to load chromeos-common.sh
assert_inside_chroot
# Load functions and constants for chromeos-install
. "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
# For functions related to gpt images.
. "$(dirname "$0")/chromeos-common.sh"
locate_gpt locate_gpt
get_default_board get_default_board

View File

@ -6,9 +6,33 @@
# Utility methods used to resize a stateful partition and update the GPT table # Utility methods used to resize a stateful partition and update the GPT table
# Source constants and utility functions # --- BEGIN COMMON.SH BOILERPLATE ---
. "$(dirname "$0")/common.sh" # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/chromeos-common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Need to be inside the chroot to load chromeos-common.sh
assert_inside_chroot
# Load functions and constants for chromeos-install
. "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
locate_gpt locate_gpt

View File

@ -9,8 +9,28 @@
# Load common constants. This should be the first executable line. # Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location. # The path to common.sh should be relative to your script's location.
. "$(dirname $0)/common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
. "$(dirname $0)/remote_access.sh" # Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
. "${SCRIPT_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh"
get_default_board get_default_board
@ -33,8 +53,7 @@ function stop_ssh_agent() {
# Call this function from the exit trap of the main script. # Call this function from the exit trap of the main script.
# Iff we started ssh-agent, be nice and clean it up. # Iff we started ssh-agent, be nice and clean it up.
# Note, only works if called from the main script - no subshells. # Note, only works if called from the main script - no subshells.
if [[ 1 -eq ${OWN_SSH_AGENT} ]] if [[ 1 -eq ${OWN_SSH_AGENT} ]]; then
then
kill ${SSH_AGENT_PID} 2>/dev/null kill ${SSH_AGENT_PID} 2>/dev/null
unset OWN_SSH_AGENT SSH_AGENT_PID SSH_AUTH_SOCK unset OWN_SSH_AGENT SSH_AGENT_PID SSH_AUTH_SOCK
fi fi
@ -129,7 +148,7 @@ autotest autotest-tests (or use --build)."
fi fi
if [ ${FLAGS_build} -eq ${FLAGS_FALSE} ] && if [ ${FLAGS_build} -eq ${FLAGS_FALSE} ] &&
$(dirname $0)/cros_workon --board=${FLAGS_board} list | "${SCRIPTS_DIR}/cros_workon" --board=${FLAGS_board} list |
grep -q autotest; then grep -q autotest; then
AUTOTEST_DIR="${SRC_ROOT}/third_party/autotest/files" AUTOTEST_DIR="${SRC_ROOT}/third_party/autotest/files"
FLAGS_build=${FLAGS_TRUE} FLAGS_build=${FLAGS_TRUE}
@ -165,7 +184,7 @@ autotest-tests to continue."
} }
function main() { function main() {
cd $(dirname "$0") cd "${SCRIPTS_DIR}"
FLAGS "$@" || exit 1 FLAGS "$@" || exit 1
@ -261,7 +280,7 @@ function main() {
echo "" echo ""
info "Running ${test_type} test ${control_file}" info "Running ${test_type} test ${control_file}"
local control_file_name=$(basename "${control_file}") local control_file_name=$(basename "${control_file}")
local short_name=$(basename $(dirname "${control_file}")) local short_name=$(basename "$(dirname "${control_file}")")
# testName/control --> testName # testName/control --> testName
# testName/control.bvt --> testName.bvt # testName/control.bvt --> testName.bvt

View File

@ -7,12 +7,29 @@
# Script to set the password for the shared user account. Stores the # Script to set the password for the shared user account. Stores the
# MD5crypt'd password to a file, for use by customize_rootfs.sh. # MD5crypt'd password to a file, for use by customize_rootfs.sh.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Script must be run inside the chroot # Script must be run inside the chroot
restart_in_chroot_if_needed $* restart_in_chroot_if_needed "$@"
FLAGS_HELP="USAGE: $0 [flags]" FLAGS_HELP="USAGE: $0 [flags]"

View File

@ -8,8 +8,28 @@
# a code of 0 if successful and non-zero otherwise. Used by test infrastructure # a code of 0 if successful and non-zero otherwise. Used by test infrastructure
# scripts. # scripts.
. "$(dirname "$0")/common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
. "$(dirname "$0")/remote_access.sh" # Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
. "${SCRIPT_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh"
function cleanup { function cleanup {
cleanup_remote_access cleanup_remote_access
@ -17,7 +37,7 @@ function cleanup {
} }
function main() { function main() {
cd $(dirname "$0") cd "${SCRIPTS_DIR}"
FLAGS "$@" || exit 1 FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}" eval set -- "${FLAGS_ARGV}"

View File

@ -6,12 +6,30 @@
# Start the Dev Server after making sure we are running under a chroot. # Start the Dev Server after making sure we are running under a chroot.
. "$(dirname "$0")/common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
# Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Script must be run inside the chroot if not in 'always serve' mode. # Script must be run inside the chroot if not in 'always serve' mode.
if [[ "$1" != "--archive_dir" ]] if [[ "$1" != "--archive_dir" ]]; then
then restart_in_chroot_if_needed "$@"
restart_in_chroot_if_needed $*
fi fi
# Temporary workaround: to start devserver for update engine, pass in args # Temporary workaround: to start devserver for update engine, pass in args
@ -23,4 +41,4 @@ if [ -z "${PKG_INSTALL_MASK+x}" ]; then
fi fi
echo PKG_INSTALL_MASK=$PKG_INSTALL_MASK echo PKG_INSTALL_MASK=$PKG_INSTALL_MASK
cd ${GCLIENT_ROOT}/src/platform/dev && python devserver.py $* cd ${GCLIENT_ROOT}/src/platform/dev && python devserver.py "$@"

View File

@ -41,11 +41,28 @@
# CHRONOS_PASSWD - default value for --chronos_passwd # CHRONOS_PASSWD - default value for --chronos_passwd
# #
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# Allow remote access (for learning board type) # location.
. "$(dirname "$0")/remote_access.sh" find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
. "${SCRIPT_ROOT}/remote_access.sh"
DEFINE_string board "" "Board setting" DEFINE_string board "" "Board setting"
DEFINE_boolean build ${FLAGS_TRUE} \ DEFINE_boolean build ${FLAGS_TRUE} \
@ -122,7 +139,7 @@ function validate_and_set_param_defaults() {
if [[ -z "${FLAGS_top}" ]]; then if [[ -z "${FLAGS_top}" ]]; then
# Use the top directory based on where this script runs from # Use the top directory based on where this script runs from
FLAGS_top=$(dirname $(dirname $(dirname $0))) FLAGS_top=${GCLIENT_ROOT}
fi fi
# Canonicalize any symlinks # Canonicalize any symlinks
@ -487,7 +504,7 @@ function grab_buildbot() {
export GSDCURL_USERNAME export GSDCURL_USERNAME
read -s -p "Password: " GSDCURL_PASSWORD read -s -p "Password: " GSDCURL_PASSWORD
export GSDCURL_PASSWORD export GSDCURL_PASSWORD
CURL="$(dirname $0)/bin/cros_gsdcurl.py" CURL="${SCRIPTS_DIR}/bin/cros_gsdcurl.py"
if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then
local latest=$(${CURL} "${FLAGS_buildbot_uri}/LATEST") local latest=$(${CURL} "${FLAGS_buildbot_uri}/LATEST")
if [[ -z "${latest}" ]]; then if [[ -z "${latest}" ]]; then
@ -507,7 +524,7 @@ function grab_buildbot() {
cd "${dl_dir}" cd "${dl_dir}"
unzip image.zip unzip image.zip
local image_basename=$(basename $(dirname "${FLAGS_grab_buildbot}")) local image_basename=$(basename "$(dirname "${FLAGS_grab_buildbot}")")
local image_base_dir="${FLAGS_top}/src/build/images/${FLAGS_board}" local image_base_dir="${FLAGS_top}/src/build/images/${FLAGS_board}"
local image_dir="${image_base_dir}/${image_basename}" local image_dir="${image_base_dir}/${image_basename}"
info "Copying in build image to ${image_dir}" info "Copying in build image to ${image_dir}"

View File

@ -4,9 +4,26 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Flags # Flags
DEFINE_string target "x86" \ DEFINE_string target "x86" \

View File

@ -6,9 +6,26 @@
# Script to report issues from the command line # Script to report issues from the command line
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Script must be run outside the chroot # Script must be run outside the chroot
assert_outside_chroot assert_outside_chroot
@ -36,7 +53,7 @@ FLAGS_HELP="
Assigned = In someone's queue, but not started Assigned = In someone's queue, but not started
Started = Work in progress Started = Work in progress
Upstream = Issue has been reported to another project Upstream = Issue has been reported to another project
Closed Statuses: Closed Statuses:
Fixed = Work completed, needs verification Fixed = Work completed, needs verification
Verified = Test or reporter verified that the fix works Verified = Test or reporter verified that the fix works
@ -44,13 +61,13 @@ FLAGS_HELP="
WontFix = Cannot reproduce, works as intended, or obsolete WontFix = Cannot reproduce, works as intended, or obsolete
FixUnreleased = Security bug fixed on all branches, not released FixUnreleased = Security bug fixed on all branches, not released
Invalid = Not a valid issue report Invalid = Not a valid issue report
Types: Types:
Bug = Software not working correctly Bug = Software not working correctly
Feature = Request for new or improved feature Feature = Request for new or improved feature
Task = Project or work that doesn't change code Task = Project or work that doesn't change code
Cleanup = Code maintenance unrelated to bugs Cleanup = Code maintenance unrelated to bugs
Priority: Priority:
0 = Critical. Resolve now. Blocks other work or users need immediate update. 0 = Critical. Resolve now. Blocks other work or users need immediate update.
1 = High. Required for the specified milestone release. 1 = High. Required for the specified milestone release.

View File

@ -7,8 +7,33 @@
# Helper script that generates the legacy/efi bootloader partitions. # Helper script that generates the legacy/efi bootloader partitions.
# It does not populate the templates, but can update a loop device. # It does not populate the templates, but can update a loop device.
. "$(dirname "$0")/common.sh" # --- BEGIN COMMON.SH BOILERPLATE ---
. "$(dirname "$0")/chromeos-common.sh" # installer # Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Need to be inside the chroot to load chromeos-common.sh
assert_inside_chroot
# Load functions and constants for chromeos-install
. "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
get_default_board get_default_board

View File

@ -6,14 +6,31 @@
# Script to update the kernel on a live running ChromiumOS instance. # Script to update the kernel on a live running ChromiumOS instance.
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
. "$(dirname $0)/common.sh" SCRIPT_ROOT=
. "$(dirname $0)/remote_access.sh" for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
. "${SCRIPT_ROOT}/remote_access.sh"
# Script must be run inside the chroot. # Script must be run inside the chroot.
restart_in_chroot_if_needed $* restart_in_chroot_if_needed "$@"
DEFINE_string board "" "Override board reported by target" DEFINE_string board "" "Override board reported by target"
DEFINE_string device "" "Override boot device reported by target" DEFINE_string device "" "Override boot device reported by target"

View File

@ -7,16 +7,30 @@
# purposes. This script need only be used to upload release builds # purposes. This script need only be used to upload release builds
# symbols or to debug crashes on non-release builds (in which case try # symbols or to debug crashes on non-release builds (in which case try
# to only upload the symbols for those executables involved). # to only upload the symbols for those executables involved).
#
# NOTE: This script must be run from the chromeos build chroot environment.
#
# Load common constants. This should be the first executable line. # --- BEGIN COMMON.SH BOILERPLATE ---
# The path to common.sh should be relative to your script's location. # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/common.sh" # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Script must be run inside the chroot # Script must be run inside the chroot
restart_in_chroot_if_needed $* restart_in_chroot_if_needed "$@"
get_default_board get_default_board
@ -118,7 +132,7 @@ function main() {
sudo rm -rf "${DEFAULT_BREAKPAD_ROOT}" sudo rm -rf "${DEFAULT_BREAKPAD_ROOT}"
info "Generating all breakpad symbol files." info "Generating all breakpad symbol files."
local verbosity="" local verbosity=""
local generate_script="$(dirname $0)/cros_generate_breakpad_symbols" local generate_script="${SCRIPTS_DIR}/cros_generate_breakpad_symbols"
[ ${FLAGS_verbose} -eq ${FLAGS_TRUE} ] && verbosity="--verbose" [ ${FLAGS_verbose} -eq ${FLAGS_TRUE} ] && verbosity="--verbose"
if ! "${generate_script}" --board=${FLAGS_board} ${verbosity}; then if ! "${generate_script}" --board=${FLAGS_board} ${verbosity}; then
error "Some errors while generating symbols; uploading anyway" error "Some errors while generating symbols; uploading anyway"

View File

@ -6,15 +6,40 @@
# Script to verify integrity of root file system for a GPT-based image # Script to verify integrity of root file system for a GPT-based image
# Load functions and constants # --- BEGIN COMMON.SH BOILERPLATE ---
. "$(dirname "$0")/common.sh" || exit 1 # Load common CrOS utilities. Inside the chroot this file is installed in
. "$(dirname "$0")/chromeos-common.sh" || exit 1 # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
find_common_sh() {
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
local path
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
# Load functions and constants for chromeos-install
[ -f /usr/lib/installer/chromeos-common.sh ] && \
INSTALLER_ROOT=/usr/lib/installer || \
INSTALLER_ROOT=$(dirname "$(readlink -f "$0")")
. "${INSTALLER_ROOT}/chromeos-common.sh" || \
die "Unable to load chromeos-common.sh"
# Needed for partoffset and partsize calls # Needed for partoffset and partsize calls
locate_gpt locate_gpt
# Script must be run inside the chroot. # Script must be run inside the chroot.
restart_in_chroot_if_needed $* restart_in_chroot_if_needed "$@"
DEFINE_string image "" "Device or an image path. Default: (empty)." DEFINE_string image "" "Device or an image path. Default: (empty)."
@ -58,8 +83,7 @@ function get_partitions() {
} }
function cleanup() { function cleanup() {
for i in ${KERNEL_IMG} ${ROOTFS_IMG} for i in ${KERNEL_IMG} ${ROOTFS_IMG}; do
do
if [ ! -b ${i} ]; then if [ ! -b ${i} ]; then
rm -f ${i} rm -f ${i}
fi fi