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.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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 outside the chroot
assert_outside_chroot
@ -43,7 +60,8 @@ DEFINE_string acl "private" \
DEFINE_string gsutil_archive "" \
"Optional datastore archive location"
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 prebuilt_upload $FLAGS_FALSE "Upload prebuilt binary packages."
DEFINE_string to "$DEFAULT_TO" "Directory of build archive"
@ -57,8 +75,7 @@ eval set -- "${FLAGS_ARGV}"
DEFAULT_USED=
# Reset "default" FLAGS_from based on passed-in board if not set on cmd-line
if [ "$FLAGS_from" = "$DEFAULT_FROM" ]
then
if [ "$FLAGS_from" = "$DEFAULT_FROM" ]; then
# Keep the directory name of the current image set (*.bin).
IMG_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)"
FLAGS_from="${IMAGES_DIR}/${FLAGS_board}/${IMG_DIR}"
@ -68,8 +85,7 @@ fi
# Die on any errors.
set -e
if [ -z "$DEFAULT_USED" ]
then
if [ -z "$DEFAULT_USED" ]; then
if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] || \
[ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] || \
[ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ]
@ -81,14 +97,12 @@ then
fi
fi
if [ ! -d "$FLAGS_from" ]
then
if [ ! -d "$FLAGS_from" ]; then
echo "$FLAGS_from does not exist. Exiting..."
exit 1
fi
if [ $FLAGS_official_build -eq $FLAGS_TRUE ]
then
if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then
CHROMEOS_OFFICIAL=1
fi
@ -103,8 +117,7 @@ REVISION=${REVISION:0:8}
# Use the version number plus revision as the last change. (Need both, since
# trunk builds multiple times with the same version string.)
LAST_CHANGE="${CHROMEOS_VERSION_STRING}-r${REVISION}"
if [ -n "$FLAGS_build_number" ]
then
if [ -n "$FLAGS_build_number" ]; then
LAST_CHANGE="$LAST_CHANGE-b${FLAGS_build_number}"
fi
@ -141,8 +154,7 @@ function do_chroot_mod() {
}
# Modify image for test if flag set.
if [ $FLAGS_test_mod -eq $FLAGS_TRUE ]
then
if [ $FLAGS_test_mod -eq $FLAGS_TRUE ]; then
echo "Modifying image for test"
do_chroot_mod "${FLAGS_from}/chromiumos_test_image.bin" ""
@ -152,16 +164,14 @@ then
popd
fi
if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ]
then
if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ]; then
echo "Modifying image for factory test"
do_chroot_mod "${FLAGS_from}/chromiumos_factory_image.bin" \
"--factory"
fi
# Modify for recovery
if [ $FLAGS_official_build -eq $FLAGS_TRUE ]
then
if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then
BUILDVER="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)"
CHROOT_IMAGE_DIR=/home/$USER/trunk/src/build/images/$FLAGS_board/$BUILDVER
./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
# supported, TODO(tgao): Add developer shim.
if [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]
then
if [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then
echo "Building factory install shim."
# 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
@ -205,8 +214,7 @@ MANIFEST=`ls | grep -v factory`
zip -r "${ZIPFILE}" ${MANIFEST}
if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \
[ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]
then
[ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then
# We need to have directory structure for factory package, as
# signing and packaging utilities need unpack_partitions.sh.
echo "Compressing factory software"
@ -268,8 +276,7 @@ then
fi
if [ $FLAGS_prebuilt_upload -eq $FLAGS_TRUE ]
then
if [ $FLAGS_prebuilt_upload -eq $FLAGS_TRUE ]; then
# Construct prebuilt upload command.
# This will upload prebuilt packages to Google Storage.
prebuilt_cmd="${SCRIPTS_DIR}/prebuilt.py"
@ -287,8 +294,7 @@ fi
gsutil_archive "${ZIPFILE}" "${LAST_CHANGE}/${FLAGS_zipname}"
if [ $FLAGS_archive_debug -eq $FLAGS_TRUE ]
then
if [ $FLAGS_archive_debug -eq $FLAGS_TRUE ]; then
echo "Generating Breakpad symbols"
! ${SCRIPTS_DIR}/cros_generate_breakpad_symbols --board=${FLAGS_board}
echo "Creating debug archive"
@ -302,16 +308,14 @@ then
fi
if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \
[ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]
then
[ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then
gsutil_archive "${FACTORY_ZIPFILE}" \
"${LAST_CHANGE}/factory_${FLAGS_zipname}"
fi
gsutil_archive "${FLAGS_to}/LATEST" "LATEST"
# Purge old builds if necessary
if [ $FLAGS_keep_max -gt 0 ]
then
if [ $FLAGS_keep_max -gt 0 ]; then
echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..."
cd "$FLAGS_to"
# +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.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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 ---
# Flags
DEFINE_string from "" "Directory with build archive (zipname)"
@ -42,7 +59,7 @@ function main() {
FLAGS_to="${FLAGS_from}"
fi
local script_dir=$(dirname "$0")
local script_dir=${SCRIPTS_DIR}
script_dir=$(readlink -f "${script_dir}")
docgen_dir="autotest/utils/docgen"

View File

@ -6,8 +6,28 @@
# Returns the version of Chrome running on a remote machine.
. "$(dirname $0)/../common.sh"
. "$(dirname $0)/../remote_access.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_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh"
FLAGS "$@" || exit 1

View File

@ -7,21 +7,35 @@
# Script which ensures that a given image has an up-to-date
# kernel partition, rootfs integrity hashes, and legacy bootloader configs.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
COMMON_PATH="$(dirname "$0")/../common.sh"
if [ ! -r "${COMMON_PATH}" ]; then
echo "ERROR! Cannot find common.sh: ${COMMON_PATH}" 1>&2
exit 1
# --- 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
}
. "$(dirname "$0")/../common.sh"
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.
# 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
. "$(dirname "$0")/../chromeos-common.sh" # for partoffset and partsize
if [ $# -lt 2 ]; then
echo "Usage: ${0} /PATH/TO/IMAGE IMAGE.BIN [shflags overrides]"
@ -41,7 +55,7 @@ if [ ! -r "${BOOT_DESC_FILE}" ]; then
BOOT_DESC="${@}"
else
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
info " ${line}"
done
@ -138,7 +152,7 @@ make_image_bootable() {
fi
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}" \
-s "${FLAGS_statefulfs_mountpoint}"

View File

@ -6,24 +6,26 @@
# 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
# /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.
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
if [ -f "${path}/common.sh" ] ; then
COMMON_SH="${path}/common.sh"
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
if [ -z "${COMMON_SH}" ] ; then
error "common.sh not found in search path (${common_paths})"
exit 1
fi
. "${COMMON_SH}"
find_common_sh
. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
# --- END COMMON.SH BOILERPLATE ---
get_default_board

View File

@ -7,16 +7,28 @@
# Script to update a running device with an optionally built package out
# of your build directory
# 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 ---
# 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)
if [ -f ${script_root}/../common.sh ] ; then
script_root=${script_root}/..
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
. "${script_root}/common.sh"
. "${script_root}/remote_access.sh"
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
@ -89,8 +101,8 @@ for pkg in $@; do
echo "Could not find latest built version of ${pkg}"
exit 1
fi
pkg_dir=$(basename $(dirname $latest_pkg))
pkg_name=$(basename $latest_pkg)
pkg_dir=$(basename "$(dirname "$latest_pkg")")
pkg_name=$(basename "$latest_pkg")
echo "Installing ${latest_pkg}..."
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
# with keys of our choosing.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/../common.sh"
# --- 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
. "$(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

View File

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

View File

@ -6,9 +6,30 @@
#
# Runs a given test case under a VM.
. "$(dirname $0)/../common.sh"
. "$(dirname $0)/../lib/cros_vm_lib.sh"
. "$(dirname "$0")/../lib/cros_vm_constants.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_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
@ -73,7 +94,7 @@ retry_until_ssh ${MAX_RETRIES}
if [ -n "${FLAGS_verify_chrome_version}" ]; then
info "Verifying version of Chrome matches what we expect."
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 \
--ssh_port=${FLAGS_ssh_port})
[[ ${chrome_version_on_vm} == ${FLAGS_verify_chrome_version} ]] || \
@ -83,7 +104,7 @@ if [ -n "${FLAGS_verify_chrome_version}" ]; then
fi
fi
"$(dirname $0)"/../run_remote_tests.sh \
"${SCRIPTS_DIR}/run_remote_tests.sh" \
--board=${FLAGS_board} \
--ssh_port=${FLAGS_ssh_port} \
--remote=127.0.0.1 \

View File

@ -6,8 +6,28 @@
#
# Updates an existing vm image with another image.
. "$(dirname $0)/../common.sh"
. "$(dirname $0)/../lib/cros_vm_lib.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_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 proxy_port "" \
@ -43,7 +63,7 @@ if [ -n "${FLAGS_proxy_port}" ]; then
IMAGE_ARGS="${IMAGE_ARGS} --proxy_port=${FLAGS_proxy_port}"
fi
$(dirname $0)/../image_to_live.sh \
"${SCRIPTS_DIR}/image_to_live.sh" \
--for_vm \
--remote=127.0.0.1 \
--ssh_port=${FLAGS_ssh_port} \

View File

@ -7,17 +7,26 @@
# Wrapper script around run_remote_tests.sh that knows how to find
# 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
# src/scripts to src/scripts/bin. However this state has existed
# for months now, therefore we need to look for the common libs in
# both places
script_root=$(dirname $0)
if [ -f ${script_root}/../common.sh ] ; then
script_root=${script_root}/..
SCRIPT_ROOT=
for path in "${common_paths[@]}"; do
if [ -r "${path}/common.sh" ]; then
SCRIPT_ROOT=${path}
break
fi
done
}
. "${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
# work correctly, you have to:
@ -145,10 +154,10 @@ fi
set $ret
remote=$1
shift
for arg in $*; do
for arg in "$@"; do
append_arg $arg
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 \
$FLAGS_ARGV"

View File

@ -7,11 +7,33 @@
# Script to resign the kernel partition generated in the output of build_image
# with SSD keys.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/../common.sh"
# --- 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
. "$(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
@ -44,7 +66,7 @@ fi
# ../../tests/devkeys/ \
# /.../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
die "VBOOT DIR NOT FOUND at \'${VBOOT_DIR}\' .."
fi

View File

@ -6,9 +6,30 @@
#
# Simple wrapper scipt to start a vm using the vm lib.
. "$(dirname $0)/../common.sh"
. "$(dirname $0)/../lib/cros_vm_lib.sh"
. "$(dirname "$0")/../lib/cros_vm_constants.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_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

View File

@ -6,8 +6,28 @@
#
# Simple wrapper scipt to stop a vm specified from a pid file.
. "$(dirname $0)/../common.sh"
. "$(dirname $0)/../lib/cros_vm_lib.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_ROOT}/lib/cros_vm_lib.sh" || die "Unable to load cros_vm_lib.sh"
set -e

View File

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

View File

@ -7,7 +7,26 @@
# Simple wrapper script to build a cros_workon package incrementally.
# 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.
restart_in_chroot_if_needed "$@"

View File

@ -11,14 +11,31 @@
# chroot environment.
#
# SCRIPT_DIR="$(cd "$(dirname $0)/.." ; pwd)"
SCRIPT_DIR=$HOME/trunk/src/scripts
. "$SCRIPT_DIR/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 ---
DEFINE_string output_dir "" "output directory for results" o
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
TMP_RESULTS="/tmp/bootperf.$(date '+%Y%j%H%M').$$"
RESULTS_DIR=platform_BootPerfServer/platform_BootPerfServer/results

View File

@ -3,16 +3,38 @@
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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 ---
# 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.
restart_in_chroot_if_needed $*
restart_in_chroot_if_needed "$@"
get_default_board

View File

@ -9,15 +9,39 @@
# the given target's root with binary packages turned on. This script will
# build the Chrome OS image using only pre-built binary packages.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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 ---
# 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
# Script must be run inside the chroot.
restart_in_chroot_if_needed $*
restart_in_chroot_if_needed "$@"
get_default_board

View File

@ -6,7 +6,26 @@
# 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

View File

@ -9,7 +9,26 @@
# Set pipefail so it will capture any nonzer exit codes
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
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.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@ -7,9 +8,26 @@
# failures. This script only affects mountpoints and loopback devices
# that were created within this chroot.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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.
assert_inside_chroot
@ -24,8 +42,7 @@ OUTPUT_DIR="${FLAGS_output_root}/${FLAGS_board}"
echo "This will unmount any directory under $OUTPUT_DIR:"
read -p "Are you sure (y/N)? " SURE
SURE="${SURE:0:1}" # Get just the first character
if [ "${SURE}" != "y" ]
then
if [ "${SURE}" != "y" ]; then
echo "Ok, better safe than sorry."
exit 1
fi

View File

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

View File

@ -6,7 +6,26 @@
# 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

View File

@ -6,7 +6,26 @@
# 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

View File

@ -7,9 +7,26 @@
# Downloads the latest buildbot image and prints the path to it.
# This script only works if you have access to buildbot images.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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

View File

@ -9,12 +9,29 @@
# NOTE: This script must be run from the chromeos build chroot environment.
#
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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
restart_in_chroot_if_needed $*
restart_in_chroot_if_needed "$@"
get_default_board
@ -39,7 +56,7 @@ function cleanup() {
# Given path to a debug file, return its text file
function get_text_for_debug() {
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)
echo ${text_path}
}

View File

@ -7,12 +7,33 @@
# 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.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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
. "$(dirname "$0")/chromeos-common.sh"
. "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
SRC_MNT=""
DST_MNT=""
@ -233,7 +254,7 @@ else
fi
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"
mv "$(dirname "$DST_KERNEL")/update.gz" "$FLAGS_output"

View File

@ -27,9 +27,26 @@
#
# Example usage: ./cros_mark_branch_as_stable
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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 is_workon() { xargs grep -lE '^inherit.*cros-workon'; }
function is_stable() { xargs grep -lE '^KEYWORDS=[^~]*$'; }
@ -38,8 +55,8 @@ function is_unstable() { xargs grep -lE '^KEYWORDS=.*~'; }
function get_workon_commit() {
# Get the latest workon commit associated with an ebuild.
ebuild="$1"
dir=$(dirname $ebuild)
CATEGORY=$(basename $(dirname "$dir"))
dir=$(dirname "$ebuild")
CATEGORY=$(basename "$(dirname "$dir")")
CROS_WORKON_LOCALNAME=$(basename "$dir")
CROS_WORKON_SUBDIR=
@ -65,7 +82,7 @@ function get_workon_commit() {
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")
if [[ -n "$BLACKLIST" ]]; then
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.
. "$(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
@ -76,7 +95,7 @@ if [ -z "${FLAGS_package_file}" -a -z "${FLAGS_packages}" ]; then
egrep '^chromeos-base' )
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
export USE="${USE} -cros-debug"

View File

@ -6,11 +6,28 @@
# Script to generate stackdumps from a machine or dmp files.
# 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 ---
# 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"
. "$(dirname $0)/remote_access.sh"
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"
assert_inside_chroot

View File

@ -10,12 +10,29 @@
# is intended to support development. The current source tip is fetched,
# source modified and built using the unstable 'live' (9999) ebuild.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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
restart_in_chroot_if_needed $*
restart_in_chroot_if_needed "$@"
get_default_board
DEFINE_string board "${DEFAULT_BOARD}" \
@ -42,7 +59,6 @@ eval set -- "${FLAGS_ARGV}"
WORKON_CMD=$1
shift
# Board dir config
# If both are specified, just use host, because board does not
@ -98,7 +114,8 @@ if [ ! -L "${UNMASK_FILE}" ]; then
fi
find_keyword_workon_ebuilds() {
keyword="${1}"
local keyword="${1}"
local overlay
local cros_overlays=$("${PORTAGEQCMD}" envvar PORTDIR_OVERLAY)
@ -112,7 +129,7 @@ find_keyword_workon_ebuilds() {
}
show_workon_ebuilds() {
keyword=$1
local keyword=$1
find_keyword_workon_ebuilds ${keyword} | \
sed -e 's/.*\/\([^/]*\)\/\([^/]*\)\/.*\.ebuild/\1\/\2/' | \
@ -150,6 +167,7 @@ canonicalize_name () {
canonicalize_names () {
local atoms=$1
local names=""
local atom
for atom in ${atoms}; do
local name=$(canonicalize_name "${atom}")
@ -168,6 +186,7 @@ show_live_ebuilds () {
# Display ebuilds currently part of the live branch and open for development
# for any board that currently has live ebuilds.
show_all_live_ebuilds () {
local workon_file
for workon_file in ${WORKON_DIR}/*; do
if [ -s "${workon_file}" ]; then
echo -e "${V_BOLD_GREEN}$(basename ${workon_file}):${V_VIDOFF}"
@ -177,7 +196,10 @@ show_all_live_ebuilds () {
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() {
# Nothing to do unless you are working on the minilayout
local manifest=${CHROOT_TRUNK_DIR}/.repo/manifest.xml
@ -185,6 +207,7 @@ regen_manifest_and_sync() {
return
fi
local pkgname
for pkgname in $(show_live_ebuilds); do
eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info)
local srcdir=$(readlink -m ${CROS_WORKON_SRCDIR})
@ -201,6 +224,7 @@ regen_manifest_and_sync() {
ebuild_to_live () {
local atoms=$1
local atoms_success=""
local atom
for atom in ${atoms}; do
if ! grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then
@ -219,6 +243,7 @@ ebuild_to_live () {
ebuild_to_stable () {
local atoms=$1
local atoms_success=""
local atom
for atom in ${atoms}; do
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.
ebuild_iterate() {
local atoms=$1
local atom
for atom in ${atoms}; do
info "Running \"${FLAGS_command}\" on ${atom}"
@ -249,7 +275,7 @@ if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then
case ${WORKON_CMD} in
start) ATOM_LIST=$(show_workon_ebuilds ${BOARD_KEYWORD});;
stop|iterate) ATOM_LIST=$(show_live_ebuilds);;
list|list-all) ;;
list) ;;
*) die "--all is invalid for the given command";;
esac
else # not selected --all
@ -268,7 +294,8 @@ fi
case ${WORKON_CMD} in
start) ebuild_to_live "${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 ;;
iterate) ebuild_iterate "${ATOM_LIST}" ;;
*) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;;

View File

@ -5,10 +5,33 @@
#
# Emit scripts to pack and unpack the partitions from a GPT disk image.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
. "$(dirname "$0")/chromeos-common.sh"
# --- 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"
set -e

View File

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

View File

@ -6,9 +6,26 @@
# Script to enter the chroot environment
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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 outside the chroot and as a regular user.
assert_outside_chroot
@ -87,8 +104,7 @@ eval set -- "${_FLAGS_FIXED}"
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
if [ $FLAGS_official_build -eq $FLAGS_TRUE ]
then
if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then
CHROMEOS_OFFICIAL=1
fi
@ -117,31 +133,26 @@ function setup_env {
# Mount only if not already mounted
MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/proc")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then
sudo mount none -t proc "$MOUNTED_PATH" || \
die "Could not mount $MOUNTED_PATH"
fi
MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/sys")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then
sudo mount none -t sysfs "$MOUNTED_PATH" || \
die "Could not mount $MOUNTED_PATH"
fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}/dev")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then
sudo mount --bind /dev "$MOUNTED_PATH" || \
die "Could not mount $MOUNTED_PATH"
fi
if [ $FLAGS_ssh_agent -eq $FLAGS_TRUE ]; then
TARGET_DIR="$(readlink -f "${FLAGS_chroot}/home/${USER}/.ssh")"
if [ -n "${SSH_AUTH_SOCK}" \
-a -d "${HOME}/.ssh" ]
then
if [ -n "${SSH_AUTH_SOCK}" -a -d "${HOME}/.ssh" ]; then
mkdir -p "${TARGET_DIR}"
cp -r "${HOME}/.ssh/known_hosts" "${TARGET_DIR}"
cp -r "${HOME}/.ssh/config" "${TARGET_DIR}"
@ -153,22 +164,19 @@ function setup_env {
fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}/dev/pts")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then
sudo mount none -t devpts "$MOUNTED_PATH" || \
die "Could not mount $MOUNTED_PATH"
fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}$CHROOT_TRUNK_DIR")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then
sudo mount --bind "$FLAGS_trunk" "$MOUNTED_PATH" || \
die "Could not mount $MOUNTED_PATH"
fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${INNER_CHROME_ROOT}")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then
! CHROME_ROOT="$(readlink -f "$FLAGS_chrome_root")"
if [ -z "$CHROME_ROOT" ]; then
! CHROME_ROOT="$(cat "${FLAGS_chroot}${CHROME_ROOT_CONFIG}" \
@ -188,11 +196,10 @@ function setup_env {
fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${INNER_DEPOT_TOOLS_ROOT}")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]; then
if [ $(which gclient 2>/dev/null) ]; then
info "Mounting depot_tools"
DEPOT_TOOLS=$(dirname $(which gclient) )
DEPOT_TOOLS=$(dirname "$(which gclient)")
mkdir -p "$MOUNTED_PATH"
if ! sudo mount --bind "$DEPOT_TOOLS" "$MOUNTED_PATH"; then
warn "depot_tools failed to mount; perhaps it's on NFS?"
@ -271,8 +278,7 @@ function teardown_env {
) 200>>"$LOCKFILE" || die "teardown_env failed"
}
if [ $FLAGS_mount -eq $FLAGS_TRUE ]
then
if [ $FLAGS_mount -eq $FLAGS_TRUE ]; then
setup_env
info "Make sure you run"
info " $0 --unmount"
@ -281,8 +287,7 @@ then
exit 0
fi
if [ $FLAGS_unmount -eq $FLAGS_TRUE ]
then
if [ $FLAGS_unmount -eq $FLAGS_TRUE ]; then
teardown_env
exit 0
fi

View File

@ -6,9 +6,26 @@
# Prints the path to the most recently built image to stdout.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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

View File

@ -7,7 +7,26 @@
# Lists all package dependencies of a particular package. Useful to find out
# 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.
assert_inside_chroot

View File

@ -6,10 +6,28 @@
# Run gmergefs from the scripts directory.
COMMON_SH="$(dirname "$0")/common.sh"
. "$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.
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 --------#
# --- 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() {
$(dirname ${0})/mod_image_for_test.sh $* || return $?
"${SCRIPTS_DIR}/mod_image_for_test.sh" "$@" || return $?
}
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() {
$(dirname ${0})/mod_image_for_dev_recovery.sh $* || return $?
"${SCRIPTS_DIR}/mod_image_for_dev_recovery.sh" "$@" || return $?
}
function customize_rootfs() {
$(dirname ${0})/customize_rootfs $* || return $?
"${SCRIPTS_DIR}/customize_rootfs" "$@" || return $?
}
#-------------------------- Tools -------------------------#
@ -73,7 +94,6 @@ function corrupt_for_test() {
}
function main() {
. "$(dirname "$0")/common.sh"
get_default_board
# Flag definitions:
@ -116,10 +136,10 @@ function main() {
}
case "$(basename $0)" in
# (mod_image_for_test.sh) mod_image_for_test $* || return $?;;
# (mod_image_for_recovery.sh) mod_image_for_recovery $* || return $?;;
# (mod_image_for_dev_recovery.sh) mod_image_for_dev_recovery $* || return $?;;
# (customize_rootfs) customize_rootfs $* || return $?;;
(image_hacks.sh) main $* || return $?;; # normal invocation
# (mod_image_for_test.sh) mod_image_for_test "$@" || return $?;;
# (mod_image_for_recovery.sh) mod_image_for_recovery "$@" || return $?;;
# (mod_image_for_dev_recovery.sh) mod_image_for_dev_recovery "$@" || return $?;;
# (customize_rootfs) customize_rootfs "$@" || return $?;;
(image_hacks.sh) main "$@" || return $?;; # normal invocation
(*) echo "$0: Unknown invocation!"; exit 1 ;;
esac

View File

@ -6,11 +6,28 @@
# Script to update an image onto a live running ChromiumOS instance.
# 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 ---
# 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"
. "$(dirname $0)/remote_access.sh"
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 to control image_to_live.
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
# the target.
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"
devserver_flags="${devserver_flags} \
--image $(reinterpret_path_for_chroot ${IMAGE_PATH})"
@ -160,8 +177,7 @@ function start_dev_server {
info "Waiting on devserver to start"
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
do
until netstat -anp 2>&1 | grep 0.0.0.0:${FLAGS_devserver_port} > /dev/null; do
sleep 5
echo -n "."
if ! pgrep -f start_devserver > /dev/null; then
@ -314,7 +330,7 @@ function run_auto_update {
function verify_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})" \
--read_only
@ -345,7 +361,7 @@ function find_root_dev {
function main() {
assert_outside_chroot
cd $(dirname "$0")
cd "${SCRIPTS_DIR}"
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"

View File

@ -6,12 +6,34 @@
# Script to convert the output of build_image.sh to a usb image.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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 ---
# 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
@ -183,8 +205,7 @@ fi
# Let's do it.
if [ -b "${FLAGS_to}" ]
then
if [ -b "${FLAGS_to}" ]; then
# Output to a block device (i.e., a real USB key), so need sudo dd
if [ ${FLAGS_install} -ne ${FLAGS_TRUE} ]; then
echo "Copying USB image ${SRC_IMAGE} to device ${FLAGS_to}..."
@ -205,24 +226,21 @@ then
fi
# Make sure this is really what the user wants, before nuking the device
if [ ${FLAGS_yes} -ne ${FLAGS_TRUE} ]
then
if [ ${FLAGS_yes} -ne ${FLAGS_TRUE} ]; then
sudo fdisk -l "${FLAGS_to}" 2>/dev/null | grep Disk | head -1
[ -n "$disk_manufacturer" ] && echo "Manufacturer: $disk_manufacturer"
[ -n "$disk_product" ] && echo "Product: $disk_product"
echo "This will erase all data on this device:"
read -p "Are you sure (y/N)? " SURE
SURE="${SURE:0:1}" # Get just the first character
if [ "${SURE}" != "y" ]
then
if [ "${SURE}" != "y" ]; then
echo "Ok, better safe than sorry."
exit 1
fi
fi
echo "Attempting to unmount any mounts on the USB device..."
for i in $(mount | grep ^"${FLAGS_to}" | awk '{print $1}')
do
for i in $(mount | grep ^"${FLAGS_to}" | awk '{print $1}'); do
if sudo umount "$i" 2>&1 >/dev/null | grep "not found"; then
echo
echo "The device you have specified is already mounted at some point "

View File

@ -5,9 +5,27 @@
# found in the LICENSE file.
# 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.
. "$(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 ---
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images"
# Default to the most recent image
@ -41,5 +59,5 @@ for EXTERNAL_tools in qemu-img VBoxManage; do
fi
done
$(dirname "$0")/image_to_vmware.sh --format=virtualbox --from=$FLAGS_from \
--to=$(dirname "$FLAGS_to") --vbox_disk=$(basename "$FLAGS_to")
"${SCRIPTS_DIR}/image_to_vmware.sh" --format=virtualbox --from="$FLAGS_from" \
--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
# corresponding VMware config file.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
. "$(dirname "$0")/chromeos-common.sh"
. "$(dirname "$0")/lib/cros_vm_constants.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"
. "${SCRIPT_ROOT}/lib/cros_vm_constants.sh" || \
die "Unable to load ${SCRIPT_ROOT}/lib/cros_vm_constants.sh"
get_default_board
assert_inside_chroot
# Flags
DEFINE_string board "${DEFAULT_BOARD}" \
@ -120,7 +144,7 @@ if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then
fi
# 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 [ "${FLAGS_format}" != "vmware" ]; then
@ -189,11 +213,11 @@ mkdir -p "${TEMP_ESP_MNT}"
sudo mount -o loop "${TEMP_ESP}" "${TEMP_ESP_MNT}"
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}" \
--enable_tablet=true
else
sudo python "$(dirname $0)/fixup_image_for_qemu.py" \
sudo python "${SCRIPTS_DIR}/fixup_image_for_qemu.py" \
--mounted_dir="${TEMP_MNT}" \
--enable_tablet=false
fi

View File

@ -4,9 +4,26 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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 ---
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images"
@ -22,8 +39,7 @@ eval set -- "${FLAGS_ARGV}"
# Die on any errors.
set -e
if [ -z "${FLAGS_from}" -o -z "${FLAGS_to}" -o -z "${FLAGS_offset}" ]
then
if [ -z "${FLAGS_from}" -o -z "${FLAGS_to}" -o -z "${FLAGS_offset}" ]; then
echo "You must define all of from, to and offset."
exit 1
fi

View File

@ -69,7 +69,7 @@ function start_kvm() {
fi
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."
net_option="-net nic,model=e1000"
fi
@ -91,7 +91,7 @@ function start_kvm() {
# Checks to see if we can access the target virtual machine with ssh.
function ssh_ping() {
"$(dirname $0)"/../ssh_test.sh \
"${SCRIPT_ROOT}/ssh_test.sh" \
--ssh_port=${FLAGS_ssh_port} \
--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
# little is needed to create a developer shim to run a signed script.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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
. "$(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 \
"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
# in src/platform/dev/static.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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
. "$(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
. "$(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."
get_default_board

View File

@ -10,8 +10,31 @@
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
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."
exit 1
fi

View File

@ -9,19 +9,37 @@
# kernel. Alternatively, a signed recovery kernel can be used to
# create a Chromium OS recovery image.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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
. "$(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
. "$(dirname "$0")/resize_stateful_partition.sh"
# We need to be in the chroot to emerge test packages.
assert_inside_chroot
. "${SCRIPT_ROOT}/resize_stateful_partition.sh" || \
die "Unable to load ${SCRIPT_ROOT}/resize_stateful_partition.sh"
get_default_board
@ -371,7 +389,7 @@ RECOVERY_KERNEL_IMAGE=\
"${FLAGS_kernel_outfile:-${IMAGE_DIR}/recovery_vmlinuz.image}"
RECOVERY_KERNEL_VBLOCK="${RECOVERY_KERNEL_IMAGE}.vblock"
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.
# 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.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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
. "$(dirname "$0")/chromeos-common.sh"
# We need to be in the chroot to emerge test packages.
assert_inside_chroot
. "/usr/lib/installer/chromeos-common.sh" || \
die "Unable to load /usr/lib/installer/chromeos-common.sh"
get_default_board
@ -92,8 +110,7 @@ cleanup_mounts() {
# root/stateful image file system open. We do a best effort attempt to kill
# them.
PIDS=`sudo lsof -t "$1" | sort | uniq`
for pid in ${PIDS}
do
for pid in ${PIDS}; do
local cmdline=`cat /proc/$pid/cmdline`
echo "Killing process that has open file on the mounted directory: $cmdline"
sudo kill $pid || /bin/true
@ -169,11 +186,11 @@ fi
set -e
IMAGE_DIR="$(dirname "$FLAGS_image")"
IMAGE_DIR=$(dirname "$FLAGS_image")
IMAGE_NAME="$(basename "$FLAGS_image")"
ROOT_FS_DIR="$IMAGE_DIR/rootfs"
STATEFUL_DIR="$IMAGE_DIR/stateful_partition"
SCRIPTS_DIR=$(dirname "$0")
SCRIPTS_DIR=${SCRIPT_ROOT}
DEV_USER="chronos"
trap cleanup EXIT
@ -229,7 +246,7 @@ fi
cleanup
# 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}")
print_time_elapsed

View File

@ -7,10 +7,34 @@
# 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).
. "$(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
get_default_board

View File

@ -6,9 +6,33 @@
# Utility methods used to resize a stateful partition and update the GPT table
# Source constants and utility functions
. "$(dirname "$0")/common.sh"
. "$(dirname "$0")/chromeos-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"
locate_gpt

View File

@ -9,8 +9,28 @@
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname $0)/common.sh"
. "$(dirname $0)/remote_access.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_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh"
get_default_board
@ -33,8 +53,7 @@ function stop_ssh_agent() {
# Call this function from the exit trap of the main script.
# Iff we started ssh-agent, be nice and clean it up.
# Note, only works if called from the main script - no subshells.
if [[ 1 -eq ${OWN_SSH_AGENT} ]]
then
if [[ 1 -eq ${OWN_SSH_AGENT} ]]; then
kill ${SSH_AGENT_PID} 2>/dev/null
unset OWN_SSH_AGENT SSH_AGENT_PID SSH_AUTH_SOCK
fi
@ -129,7 +148,7 @@ autotest autotest-tests (or use --build)."
fi
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
AUTOTEST_DIR="${SRC_ROOT}/third_party/autotest/files"
FLAGS_build=${FLAGS_TRUE}
@ -165,7 +184,7 @@ autotest-tests to continue."
}
function main() {
cd $(dirname "$0")
cd "${SCRIPTS_DIR}"
FLAGS "$@" || exit 1
@ -261,7 +280,7 @@ function main() {
echo ""
info "Running ${test_type} test ${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.bvt --> testName.bvt

View File

@ -7,12 +7,29 @@
# Script to set the password for the shared user account. Stores the
# MD5crypt'd password to a file, for use by customize_rootfs.sh.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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
restart_in_chroot_if_needed $*
restart_in_chroot_if_needed "$@"
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
# scripts.
. "$(dirname "$0")/common.sh"
. "$(dirname "$0")/remote_access.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_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh"
function cleanup {
cleanup_remote_access
@ -17,7 +37,7 @@ function cleanup {
}
function main() {
cd $(dirname "$0")
cd "${SCRIPTS_DIR}"
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"

View File

@ -6,12 +6,30 @@
# 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.
if [[ "$1" != "--archive_dir" ]]
then
restart_in_chroot_if_needed $*
if [[ "$1" != "--archive_dir" ]]; then
restart_in_chroot_if_needed "$@"
fi
# Temporary workaround: to start devserver for update engine, pass in args
@ -23,4 +41,4 @@ if [ -z "${PKG_INSTALL_MASK+x}" ]; then
fi
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
#
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# Allow remote access (for learning board type)
. "$(dirname "$0")/remote_access.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_ROOT}/remote_access.sh"
DEFINE_string board "" "Board setting"
DEFINE_boolean build ${FLAGS_TRUE} \
@ -122,7 +139,7 @@ function validate_and_set_param_defaults() {
if [[ -z "${FLAGS_top}" ]]; then
# Use the top directory based on where this script runs from
FLAGS_top=$(dirname $(dirname $(dirname $0)))
FLAGS_top=${GCLIENT_ROOT}
fi
# Canonicalize any symlinks
@ -487,7 +504,7 @@ function grab_buildbot() {
export GSDCURL_USERNAME
read -s -p "Password: " 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
local latest=$(${CURL} "${FLAGS_buildbot_uri}/LATEST")
if [[ -z "${latest}" ]]; then
@ -507,7 +524,7 @@ function grab_buildbot() {
cd "${dl_dir}"
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_dir="${image_base_dir}/${image_basename}"
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
# found in the LICENSE file.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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 ---
# Flags
DEFINE_string target "x86" \

View File

@ -6,9 +6,26 @@
# Script to report issues from the command line
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh"
# --- 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 outside the chroot
assert_outside_chroot

View File

@ -7,8 +7,33 @@
# Helper script that generates the legacy/efi bootloader partitions.
# It does not populate the templates, but can update a loop device.
. "$(dirname "$0")/common.sh"
. "$(dirname "$0")/chromeos-common.sh" # installer
# --- 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"
get_default_board

View File

@ -6,14 +6,31 @@
# Script to update the kernel on a live running ChromiumOS instance.
# 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 ---
# 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"
. "$(dirname $0)/remote_access.sh"
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"
# 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 device "" "Override boot device reported by target"

View File

@ -7,16 +7,30 @@
# purposes. This script need only be used to upload release builds
# symbols or to debug crashes on non-release builds (in which case try
# 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.
# The path to common.sh should be relative to your script's location.
. "$(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
restart_in_chroot_if_needed $*
restart_in_chroot_if_needed "$@"
get_default_board
@ -118,7 +132,7 @@ function main() {
sudo rm -rf "${DEFAULT_BREAKPAD_ROOT}"
info "Generating all breakpad symbol files."
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"
if ! "${generate_script}" --board=${FLAGS_board} ${verbosity}; then
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
# Load functions and constants
. "$(dirname "$0")/common.sh" || exit 1
. "$(dirname "$0")/chromeos-common.sh" || exit 1
# --- 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 ---
# 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
locate_gpt
# 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)."
@ -58,8 +83,7 @@ function get_partitions() {
}
function cleanup() {
for i in ${KERNEL_IMG} ${ROOTFS_IMG}
do
for i in ${KERNEL_IMG} ${ROOTFS_IMG}; do
if [ ! -b ${i} ]; then
rm -f ${i}
fi