cleanup(*): Remove unused/broken test and factory images

This commit is contained in:
Michael Marineau 2013-09-19 19:04:54 -04:00
parent c86eb16098
commit 207cc2f6a3
31 changed files with 12 additions and 1151 deletions

View File

@ -1,105 +0,0 @@
#!/bin/bash
# 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.
# Script to take an archived build result and prepare a hwqual release.
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
. "${SCRIPT_ROOT}/common.sh" || exit 1
# Flags
DEFINE_string from "" "Directory with autotest tarball"
DEFINE_string to "" "Directory to receive packaged hwqual"
DEFINE_string output_tag "chromeos-hwqual" "Name used in tar"
DEFINE_string image_dir "" "Directory containing test image."
DEFINE_string image "${CHROMEOS_TEST_IMAGE_NAME}" "Name of image file to use."
TMP=$(mktemp -d "/tmp/image.XXXX")
cleanup() {
rm -rf "${TMP}"
}
main() {
assert_outside_chroot
assert_not_root_user
# Parse command line
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
switch_to_strict_mode
if [[ -z "${FLAGS_from}" ]]; then
die "Please specify --from directory"
fi
if [[ -z "${FLAGS_image_dir}" ]]; then
die "Please specify --image_dir directory"
fi
FLAGS_from=$(readlink -f "${FLAGS_from}")
if [[ -z "${FLAGS_to}" ]]; then
FLAGS_to="${FLAGS_from}"
fi
local script_dir=${SCRIPTS_DIR}
script_dir=$(readlink -f "${script_dir}")
trap cleanup EXIT
cd "${TMP}"
echo "Extracting build artifacts..."
mkdir -p "tarball/${FLAGS_output_tag}"
if which pbzip2 >/dev/null 2>/dev/null; then
TAR_BZIP2="tar --use-compress-program=pbzip2"
else
TAR_BZIP2="tar --bzip2"
fi
echo "Extracting autotest from archived autotest tarball..."
${TAR_BZIP2} -xf "${FLAGS_from}/autotest.tar.bz2"
cd "${TMP}"
echo "Formatting rootfs as a USB image..."
"${script_dir}/image_to_usb.sh" --from="${FLAGS_image_dir}" \
--image="${FLAGS_image}" \
--to="tarball/${FLAGS_output_tag}/chromeos-hwqual-usb.img"
echo "Inserting documentation and autotest to tarball..."
ln -s \
"${FLAGS_output_tag}/autotest/client/site_tests/suite_HWQual/README.txt" \
tarball
ln -s autotest/client/site_tests/suite_HWQual/manual \
"tarball/${FLAGS_output_tag}"
cp "${script_dir}/mod_for_test_scripts/ssh_keys/testing_rsa" \
"tarball/${FLAGS_output_tag}"
chmod 0400 "tarball/${FLAGS_output_tag}/testing_rsa"
mv autotest "tarball/${FLAGS_output_tag}"
# Copy call_autoserv.py to tarball.
cp "${script_dir}/call_autoserv.py" "tarball/${FLAGS_output_tag}/."
cp "${script_dir}/generate_test_report" \
"tarball/${FLAGS_output_tag}/generate_test_report"
# Copy python lib used in generate_test_report.
mkdir -p "tarball/${FLAGS_output_tag}/lib"
cp "${script_dir}/lib/cros_build_lib.py" \
"tarball/${FLAGS_output_tag}/lib"
echo "Creating ${FLAGS_to}/${FLAGS_output_tag}.tar.bz2..."
mkdir -p "${FLAGS_to}"
cd tarball
${TAR_BZIP2} -cf "${FLAGS_to}/${FLAGS_output_tag}.tar.bz2" .
trap - EXIT
cleanup
echo "Done."
cd "${script_dir}"
}
main "$@"

View File

@ -75,8 +75,6 @@ DEFINE_string adjust_part "" \
"Adjustments to apply to the partition table"
DEFINE_string board "${DEFAULT_BOARD}" \
"Board we're building for."
DEFINE_string image_type "base" \
"Type of image we're building for (base/factory_install)."
DEFINE_string output_dir "/tmp" \
"Directory to place output in."
DEFINE_string image "coreos_base.img" \

View File

@ -25,8 +25,6 @@ DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/images" \
"Directory in which to place image result directories (named by version)"
DEFINE_string disk_layout "default" \
"The disk layout type to use for this image."
DEFINE_boolean standard_backdoor ${FLAGS_TRUE} \
"Install standard backdoor credentials for testing"
# include upload options
. "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1
@ -38,12 +36,10 @@ different forms. This scripts can be used to build the following:
base - Pristine CoreOS image for generating update payloads or a dev/prod image.
prod - Production image for CoreOS. This image is for booting.
dev - Developer image. Like base but with additional developer packages.
test - Like dev, but with additional test specific packages and can be easily
used for automated testing using scripts like run_remote_tests, etc.
Examples:
build_image --board=<board> dev test - builds developer and test images.
build_image --board=<board> dev prod - builds developer and production images.
...
"
show_help_if_requested "$@"
@ -81,7 +77,6 @@ check_gsutil_opts
. "${BUILD_LIBRARY_DIR}/build_image_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/base_image_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/dev_image_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/test_image_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/test_image_content.sh" || exit 1
parse_build_image_args
@ -142,8 +137,7 @@ if type board_setup &>/dev/null; then
fi
# Create a developer image if an image that is based on it is requested.
if should_build_image ${CHROMEOS_DEVELOPER_IMAGE_NAME} \
${CHROMEOS_TEST_IMAGE_NAME}; then
if should_build_image ${CHROMEOS_DEVELOPER_IMAGE_NAME}; then
if should_build_image ${COREOS_PRODUCTION_IMAGE_NAME}; then
cp "${BUILD_DIR}/${PRISTINE_IMAGE_NAME}" \
"${BUILD_DIR}/${CHROMEOS_DEVELOPER_IMAGE_NAME}"
@ -170,13 +164,6 @@ if ! should_build_image ${PRISTINE_IMAGE_NAME}; then
rm -f "${BUILD_DIR}/${PRISTINE_IMAGE_NAME}"
fi
# From a developer image create a test|factory_test image.
if should_build_image ${CHROMEOS_TEST_IMAGE_NAME}; then
copy_image ${CHROMEOS_DEVELOPER_IMAGE_NAME} ${CHROMEOS_TEST_IMAGE_NAME}
mod_image_for_test ${CHROMEOS_TEST_IMAGE_NAME}
upload_image "${BUILD_DIR}/${CHROMEOS_TEST_IMAGE_NAME}"
fi
# Generating AU generator zip file to run outside chroot
generate_au_zip || echo "Failed generating AU zip file - ignoring Error..."
@ -222,10 +209,6 @@ if should_build_image ${CHROMEOS_DEVELOPER_IMAGE_NAME}; then
echo "Developer image created as ${CHROMEOS_DEVELOPER_IMAGE_NAME}"
print_image_to_vm
fi
if should_build_image ${CHROMEOS_TEST_IMAGE_NAME}; then
echo "Test image created as ${CHROMEOS_TEST_IMAGE_NAME}"
print_image_to_vm "test"
fi
command_completed

View File

@ -195,12 +195,6 @@ create_base_image() {
copy_gcc_libs "${root_fs_dir}" $atom
done
if should_build_image ${CHROMEOS_FACTORY_INSTALL_SHIM_NAME}; then
# Install our custom factory install kernel with the appropriate use flags
# to the image.
emerge_custom_kernel "${root_fs_dir}"
fi
# We "emerge --root=${root_fs_dir} --root-deps=rdeps --usepkgonly" all of the
# runtime packages for chrome os. This builds up a chrome os image from
# binary packages with runtime dependencies only. We use INSTALL_MASK to
@ -221,16 +215,12 @@ create_base_image() {
# Create the boot.desc file which stores the build-time configuration
# information needed for making the image bootable after creation with
# cros_make_image_bootable.
create_boot_desc "${image_type}"
create_boot_desc
# Populates the root filesystem with legacy bootloader templates
# appropriate for the platform. The autoupdater and installer will
# use those templates to update the legacy boot partition (12/ESP)
# on update.
# (This script does not populate vmlinuz.A and .B needed by syslinux.)
# Factory install shims may be booted from USB by legacy EFI BIOS, which does
# not support verified boot yet (see create_legacy_bootloader_templates.sh)
# so rootfs verification is disabled if we are building with --factory_install
local enable_rootfs_verification=
if [[ ${rootfs_verification_enabled} -eq ${FLAGS_TRUE} ]]; then
enable_rootfs_verification="--enable_rootfs_verification"
@ -242,12 +232,9 @@ create_base_image() {
--boot_args="${FLAGS_boot_args}" \
${enable_rootfs_verification}
# Don't test the factory install shim
if ! should_build_image ${CHROMEOS_FACTORY_INSTALL_SHIM_NAME}; then
if [[ ${skip_test_image_content} -ne 1 ]]; then
# Check that the image has been correctly created.
test_image_content "$root_fs_dir"
fi
if [[ ${skip_test_image_content} -ne 1 ]]; then
# Check that the image has been correctly created.
test_image_content "$root_fs_dir"
fi
# Clean up symlinks so they work on a running target rooted at "/".
@ -275,14 +262,6 @@ create_base_image() {
# Emit helpful scripts for testers, etc.
emit_gpt_scripts "${BUILD_DIR}/${image_name}" "${BUILD_DIR}"
USE_DEV_KEYS=
if should_build_image ${CHROMEOS_FACTORY_INSTALL_SHIM_NAME}; then
USE_DEV_KEYS="--use_dev_keys"
fi
if [[ ${skip_kernelblock_install} -ne 1 ]]; then
# Place flags before positional args.
${SCRIPTS_DIR}/bin/cros_make_image_bootable "${BUILD_DIR}" \
${image_name} ${USE_DEV_KEYS} --adjust_part="${FLAGS_adjust_part}"
fi
${SCRIPTS_DIR}/bin/cros_make_image_bootable "${BUILD_DIR}" \
${image_name} --adjust_part="${FLAGS_adjust_part}"
}

View File

@ -45,9 +45,6 @@ get_images_to_build() {
\'dev\' )
IMAGES_TO_BUILD="${IMAGES_TO_BUILD} ${CHROMEOS_DEVELOPER_IMAGE_NAME}"
;;
\'test\' )
IMAGES_TO_BUILD="${IMAGES_TO_BUILD} ${CHROMEOS_TEST_IMAGE_NAME}"
;;
* )
die "${image_to_build} is not an image specification."
;;
@ -93,8 +90,6 @@ make_salt() {
}
create_boot_desc() {
local image_type=$1
local enable_rootfs_verification_flag=""
if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then
enable_rootfs_verification_flag="--enable_rootfs_verification"
@ -102,7 +97,6 @@ create_boot_desc() {
cat <<EOF > ${BUILD_DIR}/boot.desc
--board=${BOARD}
--image_type=${image_type}
--arch="${ARCH}"
--keys_dir="${DEVKEYSDIR}"
--boot_args="${FLAGS_boot_args}"

View File

@ -104,10 +104,8 @@ EOF
cleanup_mounts
trap - EXIT
if [[ ${skip_kernelblock_install} -ne 1 ]]; then
if should_build_image ${image_name}; then
${SCRIPTS_DIR}/bin/cros_make_image_bootable "${BUILD_DIR}" \
${image_name} --force_developer_mode
fi
if should_build_image ${image_name}; then
${SCRIPTS_DIR}/bin/cros_make_image_bootable "${BUILD_DIR}" \
${image_name} --force_developer_mode
fi
}

View File

@ -1,91 +0,0 @@
# 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.
# Shell function library for functions specific to creating test
# images from dev images. This file also contains additional
# functions and initialization shared between build_image and
# mod_image_for_test.sh.
#
# Emerges chromeos-test onto the image.
emerge_chromeos_test() {
# Determine the root dir for test packages.
local root_dev_dir="${root_fs_dir}/usr/local"
emerge_to_image --root="${root_fs_dir}" chromeos-test-init
emerge_to_image --root="${root_dev_dir}" chromeos-test
}
prepare_hwid_for_factory() {
local hwid_dest="$1/hwid"
local hwid_src="${BOARD_ROOT}/usr/share/chromeos-hwid"
# Force refreshing source folder in build root folder
sudo rm -rf "${hwid_src}" "${hwid_dest}"
emerge_to_image chromeos-hwid
if [ -d "${hwid_src}" ]; then
# TODO(hungte) After being archived by chromite, the HWID files will be in
# factory_test/hwid; we should move it to top level folder.
cp -r "${hwid_src}" "${hwid_dest}"
else
echo "Skipping HWID: No HWID bundles found."
fi
}
# Converts a dev image into a test or factory test image
# Takes as an arg the name of the image to be created.
mod_image_for_test () {
local image_name="$1"
trap unmount_image EXIT
mount_image "${BUILD_DIR}/${image_name}" \
"${root_fs_dir}" "${stateful_fs_dir}"
emerge_chromeos_test
BACKDOOR=0
if [ $FLAGS_standard_backdoor -eq $FLAGS_TRUE ]; then
BACKDOOR=1
fi
local mod_test_script="${SCRIPTS_DIR}/mod_for_test_scripts/test_setup.sh"
# Run test setup script to modify the image
sudo -E GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${root_fs_dir}" \
STATEFUL_DIR="${stateful_fs_dir}" ARCH="${ARCH}" BACKDOOR="${BACKDOOR}" \
BOARD_ROOT="${BOARD_ROOT}" \
"${mod_test_script}"
# Legacy parameter (used by mod_image_for_test.sh --factory)
[ -n "${FLAGS_factory}" ] || FLAGS_factory=${FLAGS_FALSE}
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ||
should_build_image "${CHROMEOS_FACTORY_TEST_IMAGE_NAME}"; then
emerge_to_image --root="${root_fs_dir}" factorytest-init
INSTALL_MASK="${FACTORY_TEST_INSTALL_MASK}"
emerge_to_image --root="${root_fs_dir}/usr/local" \
chromeos-base/autotest chromeos-base/autotest-all \
chromeos-base/chromeos-factory
prepare_hwid_for_factory "${BUILD_DIR}"
local mod_factory_script
mod_factory_script="${SCRIPTS_DIR}/mod_for_factory_scripts/factory_setup.sh"
# Run factory setup script to modify the image
sudo -E GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${root_fs_dir}" \
BOARD="${BOARD}" "${mod_factory_script}"
fi
# Re-run ldconfig to fix /etc/ldconfig.so.cache.
sudo ldconfig -r "${root_fs_dir}"
cleanup_mounts
trap - EXIT
if [[ ${skip_kernelblock_install} -ne 1 ]]; then
# Now make it bootable with the flags from build_image.
if should_build_image ${image_name}; then
"${SCRIPTS_DIR}/bin/cros_make_image_bootable" "${BUILD_DIR}" \
${image_name} --force_developer_mode
fi
fi
}

View File

@ -63,8 +63,6 @@ DEFINE_boolean withdev "${FLAGS_TRUE}" \
"Build useful developer friendly utilities."
DEFINE_boolean withdebug "${FLAGS_TRUE}" \
"Build debug versions of Chromium-OS-specific packages."
DEFINE_boolean withfactory "${FLAGS_TRUE}" \
"Build factory installer."
DEFINE_boolean withtest "${FLAGS_TRUE}" \
"Build packages required for testing."
@ -182,20 +180,6 @@ if [[ $# -eq 0 ]]; then
if [[ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]]; then
PACKAGES+=( coreos-base/coreos-dev )
fi
# TODO(ifup): re-enable this stuff for testing
# if [[ "${FLAGS_withfactory}" -eq "${FLAGS_TRUE}" ]]; then
# PACKAGES+=( coreos-base/chromeos-installshim )
# PACKAGES+=( coreos-base/coreos-installshim )
# PACKAGES+=( coreos-base/coreos-factory )
# PACKAGES+=( coreos-base/factorytest-init )
# PACKAGES+=( coreos-base/coreos-hwid )
# fi
# if [[ "${FLAGS_withtest}" -eq "${FLAGS_TRUE}" ]]; then
# PACKAGES+=( coreos-base/coreos-test )
# fi
# if [[ "${FLAGS_withautotest}" -eq "${FLAGS_TRUE}" ]]; then
# PACKAGES+=( coreos-base/autotest-all )
# fi
fi
# Verify that all packages can be emerged from scratch, without any

View File

@ -401,14 +401,12 @@ CHROMEOS_BASE_IMAGE_NAME="coreos_base_image.bin"
CHROMEOS_DEVELOPER_IMAGE_NAME="coreos_developer_image.bin"
CHROMEOS_IMAGE_NAME="$CHROMEOS_DEVELOPER_IMAGE_NAME"
CHROMEOS_RECOVERY_IMAGE_NAME="recovery_image.bin"
CHROMEOS_TEST_IMAGE_NAME="coreos_test_image.bin"
COREOS_BASE_IMAGE_NAME=${CHROMEOS_BASE_IMAGE_NAME}
COREOS_IMAGE_NAME=${CHROMEOS_IMAGE_NAME}
COREOS_DEVELOPER_IMAGE_NAME=${CHROMEOS_DEVELOPER_IMAGE_NAME}
COREOS_PRODUCTION_IMAGE_NAME="coreos_production_image.bin"
COREOS_RECOVERY_IMAGE_NAME=${CHROMEOS_RECOVERY_IMAGE_NAME}
COREOS_TEST_IMAGE_NAME=${CHROMEOS_TEST_IMAGE_NAME}
# Install make for portage ebuilds. Used by build_image and gmergefs.
# TODO: Is /usr/local/autotest-chrome still used by anyone?

View File

@ -32,7 +32,6 @@ DEFINE_string board "${DEFAULT_BOARD}" \
# We default to TRUE so the buildbot gets its image. Note this is different
# behavior from image_to_usb.sh
DEFINE_boolean force_copy ${FLAGS_FALSE} "Always rebuild test image"
DEFINE_string format "qemu" \
"Output format, one of: ${VALID_IMG_TYPES[*]}"
DEFINE_string from "" \
@ -43,10 +42,8 @@ DEFINE_integer mem "${DEFAULT_MEM}" \
"Memory size for the vm config in MBs."
DEFINE_string state_image "" \
"Stateful partition image (defaults to creating new statful partition)"
DEFINE_boolean test_image "${FLAGS_FALSE}" \
"Copies normal image to ${CHROMEOS_TEST_IMAGE_NAME}, modifies it for test."
DEFINE_boolean prod_image "${FLAGS_FALSE}" \
"Copies normal image to ${COREOS_OFFICIAL_IMAGE_NAME}, modifies it for test."
"Use the production image instead of the default developer image."
DEFINE_string to "" \
"Destination folder for VM output file(s)"
@ -98,8 +95,6 @@ fi
if [ ${FLAGS_prod_image} -eq ${FLAGS_TRUE} ]; then
set_vm_paths "${FLAGS_from}" "${FLAGS_to}" "${COREOS_PRODUCTION_IMAGE_NAME}"
elif [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ]; then
set_vm_paths "${FLAGS_from}" "${FLAGS_to}" "${CHROMEOS_TEST_IMAGE_NAME}"
else
# Use the standard image
set_vm_paths "${FLAGS_from}" "${FLAGS_to}" "${CHROMEOS_IMAGE_NAME}"

View File

@ -1 +0,0 @@
../platform/factory/setup/make_factory_package.sh

View File

@ -1,12 +0,0 @@
# Copyright (c) 2012 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.
# Drop this in as dbus.conf after renaming the normal dbus.conf to
# "realdbus.conf". That will ensure this attaches to dbus first.
start on started realdbus
respawn
exec dbus-spy -w /var/log/dbusspy.log

View File

@ -1,17 +0,0 @@
<busconfig>
<policy context="default">
<!-- Allow all messages to be sent to and received by eavesdropping
connections. This overrides any deny rules in system.d -->
<allow send_type="method_call" eavesdrop="true"/>
<allow receive_type="method_call" eavesdrop="true"/>
<allow send_type="method_return" eavesdrop="true"/>
<allow receive_type="method_return" eavesdrop="true"/>
<allow send_type="error" eavesdrop="true"/>
<allow receive_type="error" eavesdrop="true"/>
<allow send_type="signal" eavesdrop="true"/>
<allow receive_type="signal" eavesdrop="true"/>
</policy>
</busconfig>

View File

@ -1,22 +0,0 @@
#!/bin/bash
# Copyright (c) 2009 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.
#
# Record the original size of the image without modifications from
# mod_image_for_test.sh, for reporting and monitoring through autotest.
# Record the size, but don't overwrite the file as its existence indicates
# that this image is not a production image.
echo "Recording production image size."
FILE="${ROOT_FS_DIR}/root/bytes-rootfs-prod"
if [[ ! -f "${FILE}" ]]; then
# This will complain it cannot find a valid mtab so keep it quiet.
# Grep for rootfs mount at end of line otherwise we will get rootfs/var
# mount point as well.
df -B1 -P 2>/dev/null | grep "${ROOT_FS_DIR}$" | awk '{ print $3 }' > \
"${FILE}"
else
echo " Not modifying existing ${FILE}."
fi

View File

@ -1,12 +0,0 @@
#!/bin/bash
# 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.
#
# Changes the description of the image for test builds so that developers
# can tell immediately if they have a test build vs. a developer build.
echo "Modifying Release Description for Test."
FILE="${ROOT_FS_DIR}/etc/lsb-release"
sed -i 's/Developer/Test/' $FILE

View File

@ -1,12 +0,0 @@
#!/bin/bash
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Changes the channel of the image for test builds so that it will be
# identified as a test image to Omaha which will not give any updates.
echo "Modifying Release Track for Test (testimage-channel)."
FILE="${ROOT_FS_DIR}/etc/lsb-release"
sed -i 's/^\(COREOS_RELEASE_TRACK=\).*/\1testimage-channel/' $FILE

View File

@ -1,134 +0,0 @@
#!/bin/bash
# Copyright (c) 2009 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.
echo "Configuring for backchannel and test network devices"
testif=eth_test,wlan1,wlan2,managed0,managed1
modemif=pseudomodem0p
# Prevent shill from taking control of the backchannel network device.
ORIG_CONF=${ROOT_FS_DIR}/etc/init/shill.conf
TEMP_CONF=${ORIG_CONF}.tmp
sed -e "s@SHILL_TEST_ARGS=\"\"@SHILL_TEST_ARGS=\"--device-black-list=${testif},${modemif}\"@" \
${ORIG_CONF} > ${TEMP_CONF}
mv -f ${TEMP_CONF} ${ORIG_CONF}
# Arrange to run dhclient on the backchannel device but without
# installing the default route, and stashing said route away for later
# installation as a host route.
cat > ${ROOT_FS_DIR}/etc/udev/rules.d/50-backchannel-network.rules <<EOF
KERNEL=="eth*", SUBSYSTEMS=="usb", ACTION=="add", RUN+="/sbin/backchannel-setup %k"
KERNEL=="${testif}", SUBSYSTEMS=="usb", ACTION=="remove", RUN+="kill \$(cat /var/run/dhclient-%k.pid)"
EOF
cat > ${ROOT_FS_DIR}/sbin/backchannel-setup <<EOF
#!/bin/sh
testif=${testif}
if [ ! -f /mnt/stateful_partition/etc/enable_backchannel_network ]; then
# This mechanism has to be explicitly enabled on the device.
exit
fi
if [ -f /var/run/dhclient-\${testif}.pid ]; then
# Something else is already going on - perhaps a second
# USB Ethernet device has been inserted. Let's not mess with it.
exit
fi
if [ "\$1" != "\${testif}" ]; then
initctl stop shill
# \$1 is the current name of the backchannel device. Swap it with testif.
if ifconfig \${testif} > /dev/null 2>&1; then
orig_mac=\$(ifconfig \${testif} | awk '/HWaddr/ {print \$5}')
ifconfig \${testif} down # must be down for nameif to work
nameif eth_tmp \${orig_mac}
fi
bdev_mac=\$(ifconfig \$1 | awk '/HWaddr/ {print \$5}')
ifconfig \$1 down # must be down for nameif to work
nameif \${testif} \${bdev_mac}
if [ -n "\${orig_mac}" ]; then
nameif \$1 \${orig_mac}
fi
initctl start shill
fi
# Bring up the backchannel interface
dhclient -q -pf /var/run/dhclient-\${testif}.pid \\
-lf /var/run/dhclient-\${testif}.leases \\
-cf /etc/dhclient-backchannel.conf \\
-sf /sbin/dhclient-backchannel-script \\
\${testif}
EOF
chmod +x ${ROOT_FS_DIR}/sbin/backchannel-setup
cat > ${ROOT_FS_DIR}/etc/dhclient-backchannel.conf <<EOF
request subnet-mask, broadcast-address, routers;
EOF
cat > ${ROOT_FS_DIR}/sbin/dhclient-backchannel-script <<EOF
#!/bin/sh
if [ -n "\$new_broadcast_address" ]; then
new_broadcast_arg="broadcast \$new_broadcast_address"
fi
if [ -n "\$new_subnet_mask" ]; then
new_subnet_arg="netmask \$new_subnet_mask"
fi
case "\$reason" in
MEDIUM|ARPCHECK|ARPSEND)
# Do nothing
;;
PREINIT)
# The DHCP client is requesting that an interface be
# configured as required in order to send packets prior to
# receiving an actual address. - dhclient-script(8)
ifconfig \$interface inet 0 up
# We need to give the kernel some time to get the interface up.
sleep 1
;;
BOUND|RENEW|REBIND|REBOOT|TIMEOUT)
if [ -n "\$old_ip_address" -a \
"\$old_ip_address" != "\$new_ip_address" ]; then
# IP address changed. Bringing down the interface will delete all routes,
# and clear the ARP cache.
ifconfig \$interface inet 0
fi
if [ -z "\$old_ip_address" -o "\$old_ip_address" != "\$new_ip_address" -o \
"\$reason" = "BOUND" -o "\$reason" = "REBOOT" ]; then
ifconfig \$interface inet \$new_ip_address \$new_subnet_arg \
\$new_broadcast_arg \$mtu_arg
# Since this script is for the backchannel testing interface,
# we don't set the default route from here, but we do stash
# it for possible later use in setting up a host route.
cp /dev/null /var/run/dhclient-\${interface}.routers
for router in \$new_routers; do
echo \$router >> /var/run/dhclient-\${interface}.routers
done
fi
;;
EXPIRE|FAIL|RELEASE|STOP)
if [ -n "\$old_ip_address" ]; then
# Shut down interface, which will delete routes and clear arp cache.
ifconfig \$interface inet 0
fi
;;
esac
EOF
chmod +x ${ROOT_FS_DIR}/sbin/dhclient-backchannel-script

View File

@ -1,8 +0,0 @@
#!/bin/bash
# Copyright (c) 2009 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.
mkdir -p "${ROOT_FS_DIR}/usr/share/power_manager"
echo 1 > "${ROOT_FS_DIR}/usr/share/power_manager/disable_idle_suspend"

View File

@ -1,18 +0,0 @@
#!/bin/bash
# Copyright (c) 2009 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.
if [ "$BACKDOOR" -eq "0" ]; then
exit 0
fi
# reset root password to test0000 (4 zeroes).
TEMP_SHADOWFILE=${ROOT_FS_DIR}/etc/newshadow
CRYPTED_PASSWD="$(echo "test0000" | openssl passwd -1 -stdin)"
echo "root:${CRYPTED_PASSWD}:14500:0:::::" > ${TEMP_SHADOWFILE}
echo "chronos:${CRYPTED_PASSWD}:14500:0:99999::::" >> ${TEMP_SHADOWFILE}
sed '/^root/ d;/^chronos/ d' ${ROOT_FS_DIR}/etc/shadow >> ${TEMP_SHADOWFILE}
mv -f ${TEMP_SHADOWFILE} ${ROOT_FS_DIR}/etc/shadow

View File

@ -1,25 +0,0 @@
#!/bin/bash
# Copyright (c) 2009 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.
#
# Copy public keys to root's homedir for ssh pubkey auth, which
# is necessary for test automation.
echo "Copying public keys and changing PATH for ssh clients"
if [ "$BACKDOOR" -eq 1 ]; then
KEYS_DIR=${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts/ssh_keys
else
KEYS_DIR=${GCLIENT_ROOT}/../.ssh
fi
mkdir -p ${ROOT_FS_DIR}/root/.ssh
ROOT_AUTHKEYS=${ROOT_FS_DIR}/root/.ssh/authorized_keys
cat ${KEYS_DIR}/*.pub >> ${ROOT_AUTHKEYS}
# Environment on test machines for su and ssh now set to include
touch ${ROOT_FS_DIR}/etc/environment
echo "PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin" \
>> "${ROOT_FS_DIR}/etc/environment"

View File

@ -1,8 +0,0 @@
# Copyright (c) 2012 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.
#
# The PAGER variable defaults to /usr/bin/less but it will get installed
# to /usr/local/bin/less on a test image, so fix the default
sed -i 's:/usr/bin/less:/usr/local/bin/less:g' ${ROOT_FS_DIR}/etc/profile

View File

@ -1,65 +0,0 @@
#!/bin/bash
# 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.
echo "Adding mock Google Accounts server certs."
case "${ARCH}" in
arm*)
QEMU="/tmp/qemu-arm"
cp "/usr/bin/qemu-arm" "${ROOT_FS_DIR}/${QEMU}"
;;
*86|amd64)
QEMU=""
;;
*)
error "Invalid ARCH: ${ARCH}"
exit 1
esac
CERT_NAME="mock_server"
FAKE_CA_DIR="/etc/fake_root_ca"
FAKE_NSSDB="${FAKE_CA_DIR}/nssdb"
TMP_KEY=$(mktemp -p /tmp "${CERT_NAME}.key.XXXXX")
TMP_CERT=$(mktemp -p /tmp "${CERT_NAME}.pem.XXXXX")
mv -f "${TMP_KEY}" "${ROOT_FS_DIR}/${TMP_KEY}"
mv -f "${TMP_CERT}" "${ROOT_FS_DIR}/${TMP_CERT}"
# We need access to /dev/random and /dev/self/fd (which is /proc/self/fd)
# within the chrooted image
sudo mount --bind /dev "${ROOT_FS_DIR}"/dev
sudo mount --bind /proc "${ROOT_FS_DIR}"/proc
# Generate testing root cert on the fly.
sudo chroot "${ROOT_FS_DIR}" ${QEMU} /usr/bin/openssl req -x509 -days 21 \
-subj "/CN=*.google.com" \
-newkey rsa:1024 -nodes -keyout "${TMP_KEY}" -out "${TMP_CERT}"
mkdir -m 0755 -p "${ROOT_FS_DIR}/${FAKE_NSSDB}"
# Both bash and nsscertutil must be run under qemu-arm
sudo chroot "${ROOT_FS_DIR}" ${QEMU} /bin/bash -c "${QEMU} \
/usr/local/bin/nsscertutil -d sql:${FAKE_NSSDB} -N -f <(echo '')"
cp "${ROOT_FS_DIR}/${TMP_KEY}" "${ROOT_FS_DIR}/${FAKE_CA_DIR}/${CERT_NAME}.key"
cp "${ROOT_FS_DIR}/${TMP_CERT}" "${ROOT_FS_DIR}/${FAKE_CA_DIR}/${CERT_NAME}.pem"
echo "DO NOT MOVE THIS DATA OFF OF THE ROOTFS!" > "${ROOT_FS_DIR}/${FAKE_CA_DIR}/README"
sudo chroot "${ROOT_FS_DIR}" ${QEMU} \
/usr/local/bin/nsscertutil -d sql:"${FAKE_NSSDB}" -A \
-n FakeCert -t "C,," -a -i "${FAKE_CA_DIR}/${CERT_NAME}.pem"
chmod 0644 "${ROOT_FS_DIR}/${FAKE_NSSDB}"/*
CERT_FILE="${ROOT_FS_DIR}/etc/login_trust_root.pem"
mv -f "${ROOT_FS_DIR}/${TMP_CERT}" "${CERT_FILE}"
chmod 0644 "${CERT_FILE}"
if [ -n "${QEMU}" ] ; then
rm "${ROOT_FS_DIR}/${QEMU}"
fi
rm -f "${ROOT_FS_DIR}/${TMP_KEY}"
rm -f "${ROOT_FS_DIR}/${TMP_CERT}"
sudo umount "${ROOT_FS_DIR}"/dev
sudo umount "${ROOT_FS_DIR}"/proc

View File

@ -1,14 +0,0 @@
#!/bin/bash
# Copyright (c) 2012 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.
# session_manager_setup.sh checks for this USE flag.
# TODO(jimhebert) Once crosbug.com/13429 is fixed and test-builds can
# be produced with different USE flags, we can eliminate this
# mod_for_test script in favor of a real USE flag for
# chromeos-base/chromeos-login.
echo "Enabling use of SSLKEYLOGFILE in Chrome."
echo dangerous_sslkeylogfile >> \
"${ROOT_FS_DIR}/etc/session_manager_use_flags.txt"

View File

@ -1,17 +0,0 @@
#!/bin/bash
# Copyright (c) 2012 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.
#
# Add the kernel testcase modules into the image for test builds.
# This is for running various autotests needing specific kernel behaviors.
echo "Adding the kernel test modules for autotest runs."
MODULES_PATH="/lib/modules"
KERNEL_RELEASE=$(ls -tr "${ROOT_FS_DIR}${MODULES_PATH}" | tail -n1)
TESTCASES_PATH="${MODULES_PATH}/${KERNEL_RELEASE}"
SRC_DIR="${BOARD_ROOT}${TESTCASES_PATH}"
DST_DIR="${ROOT_FS_DIR}${TESTCASES_PATH}"
(cd "${SRC_DIR}" && find . -type f -name 'test_*.ko') | \
rsync -a --files-from=- "${SRC_DIR}" "${DST_DIR}"

View File

@ -1,21 +0,0 @@
#!/bin/bash
# Copyright (c) 2012 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.
#
# Add the uinput kernel module into the image for test builds.
# This is for running trackpad autotest in VM.
echo "Adding the uinput module for test builds."
MODULES_PATH="/lib/modules"
KERNEL_RELEASE=$(ls -tr "${ROOT_FS_DIR}${MODULES_PATH}" | tail -n1)
UINPUT_PATH="${MODULES_PATH}/${KERNEL_RELEASE}"/kernel/drivers/input/misc
SRC_FILE="${BOARD_ROOT}${UINPUT_PATH}"/uinput.ko
DST_DIR="${ROOT_FS_DIR}${UINPUT_PATH}"
if [ -f "${SRC_FILE}" ]; then
install -m 644 "${SRC_FILE}" "${DST_DIR}"
echo "The uinput module is installed."
else
echo "Cannot install the uinput module."
fi

View File

@ -1,27 +0,0 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEoAIBAAKCAQEAvsNpFdK5lb0GfKx+FgsrsM/2+aZVFYXHMPdvGtTz63ciRhq0
Jnw7nln1SOcHraSz3/imECBg8NHIKV6rA+B9zbf7pZXEv20x5Ul0vrcPqYWC44PT
tgsgvi8s0KZUZN93YlcjZ+Q7BjQ/tuwGSaLWLqJ7hnHALMJ3dbEM9fKBHQBCrG5H
OaWD2gtXj7jp04M/WUnDDdemq/KMg6E9jcrJOiQ39IuTpas4hLQzVkKAKSrpl6MY
2etHyoNarlWhcOwitArEDwf3WgnctwKstI/MTKB5BTpO2WXUNUv4kXzA+g8/l1al
jIG13vtd9A/IV3KFVx/sLkkjuZ7z2rQXyNKuJwIBIwKCAQA79EWZJPh/hI0CnJyn
16AEXp4T8nKDG2p9GpCiCGnq6u2Dvz/u1pZk97N9T+x4Zva0GvJc1vnlST7objW/
Y8/ET8QeGSCT7x5PYDqiVspoemr3DCyYTKPkADKn+cLAngDzBXGHDTcfNP4U6xfr
Qc5JK8BsFR8kApqSs/zCU4eqBtp2FVvPbgUOv3uUrFnjEuGs9rb1QZ0K6o08L4Cq
N+e2nTysjp78blakZfqlurqTY6iJb0ImU2W3T8sV6w5GP1NT7eicXLO3WdIRB15a
evogPeqtMo8GcO62wU/D4UCvq4GNEjvYOvFmPzXHvhTxsiWv5KEACtleBIEYmWHA
POwrAoGBAOKgNRgxHL7r4bOmpLQcYK7xgA49OpikmrebXCQnZ/kZ3QsLVv1QdNMH
Rx/ex7721g8R0oWslM14otZSMITCDCMWTYVBNM1bqYnUeEu5HagFwxjQ2tLuSs8E
SBzEr96JLfhwuBhDH10sQqn+OQG1yj5acs4Pt3L4wlYwMx0vs1BxAoGBANd9Owro
5ONiJXfKNaNY/cJYuLR+bzGeyp8oxToxgmM4UuA4hhDU7peg4sdoKJ4XjB9cKMCz
ZGU5KHKKxNf95/Z7aywiIJEUE/xPRGNP6tngRunevp2QyvZf4pgvACvk1tl9B3HH
7J5tY/GRkT4sQuZYpx3YnbdP5Y6Kx33BF7QXAoGAVCzghVQR/cVT1QNhvz29gs66
iPIrtQnwUtNOHA6i9h+MnbPBOYRIpidGTaqEtKTTKisw79JjJ78X6TR4a9ML0oSg
c1K71z9NmZgPbJU25qMN80ZCph3+h2f9hwc6AjLz0U5wQ4alP909VRVIX7iM8paf
q59wBiHhyD3J16QAxhsCgYBu0rCmhmcV2rQu+kd4lCq7uJmBZZhFZ5tny9MlPgiK
zIJkr1rkFbyIfqCDzyrU9irOTKc+iCUA25Ek9ujkHC4m/aTU3lnkNjYp/OFXpXF3
XWZMY+0Ak5uUpldG85mwLIvATu3ivpbyZCTFYM5afSm4StmaUiU5tA+oZKEcGily
jwKBgBdFLg+kTm877lcybQ04G1kIRMf5vAXcConzBt8ry9J+2iX1ddlu2K2vMroD
1cP/U/EmvoCXSOGuetaI4UNQwE/rGCtkpvNj5y4twVLh5QufSOl49V0Ut0mwjPXw
HfN/2MoO07vQrjgsFylvrw9A79xItABaqKndlmqlwMZWc9Ne
-----END RSA PRIVATE KEY-----

View File

@ -1 +0,0 @@
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvsNpFdK5lb0GfKx+FgsrsM/2+aZVFYXHMPdvGtTz63ciRhq0Jnw7nln1SOcHraSz3/imECBg8NHIKV6rA+B9zbf7pZXEv20x5Ul0vrcPqYWC44PTtgsgvi8s0KZUZN93YlcjZ+Q7BjQ/tuwGSaLWLqJ7hnHALMJ3dbEM9fKBHQBCrG5HOaWD2gtXj7jp04M/WUnDDdemq/KMg6E9jcrJOiQ39IuTpas4hLQzVkKAKSrpl6MY2etHyoNarlWhcOwitArEDwf3WgnctwKstI/MTKB5BTpO2WXUNUv4kXzA+g8/l1aljIG13vtd9A/IV3KFVx/sLkkjuZ7z2rQXyNKuJw== ChromeOS test key

View File

@ -1,14 +0,0 @@
#!/bin/bash
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -e
for SCRIPT in \
${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts/[0-9][0-9][0-9]*[!$~]
do
${SCRIPT}
done

View File

@ -1,73 +0,0 @@
#!/bin/bash
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Script to modify a keyfob-based chromeos test image to log all dbus
# activity from boot-time forward in a machine-readable replay format.
# This is not part of the main "mod-for-test" for several reasons:
# * it is overly invasive to the boot sequence,
# * it has major run-time performance downsides,
# * it consumes potentially huge amounts of disk space over time.
# Any one of these are too-great of a depature from "normal" Chrome OS
# to be appropriate for a "faithful" test-system. Note that dbus-monitor(1)
# is available for casual/interactive use in normal mod-for-test systems.
# Dbusspy-instrumented systems are only intended for narrow use cases, like
# corpus collection for fuzzing, where the above trade-offs are acceptable.
. "$(dirname "$0")/common.sh" || exit 1
assert_inside_chroot
DEFINE_string image "$FLAGS_image" "Location of the test image file" i
# Parse command line
FLAGS "$@" || exit 1
eval set -- "$FLAGS_ARGV"
FLAGS_image=$(eval readlink -f "${FLAGS_image}")
IMAGE_DIR=$(dirname "${FLAGS_image}")
IMAGE_NAME=$(basename "${FLAGS_image}")
ROOT_FS_DIR="${IMAGE_DIR}/rootfs"
DBUS_CONF="$(dirname "$0")/mod_for_dbusspy/dbus.conf"
SYSTEM_LOCAL_CONF="$(dirname "$0")/mod_for_dbusspy/system-local.conf"
DEVKEYS_DIR="/usr/share/vboot/devkeys"
VBOOT_DIR="${CHROOT_TRUNK_DIR}/src/platform/vboot_reference/scripts/"\
"image_signing"
cleanup() {
"${SCRIPTS_DIR}/mount_gpt_image.sh" -u -r "$ROOT_FS_DIR"
}
if [ ! -d "$VBOOT_DIR" ]; then
die_notrace \
"The required path: $VBOOT_DIR does not exist. This directory needs"\
"to be sync'd into your chroot.\n $ cros_workon start vboot_reference"
fi
trap cleanup EXIT
# Mounts gpt image and sets up var, /usr/local and symlinks.
"$SCRIPTS_DIR/mount_gpt_image.sh" --image="$IMAGE_NAME" --from="$IMAGE_DIR" \
--rootfs_mountpt="$ROOT_FS_DIR"
# A bunch of existing stuff is set to start up as soon as dbus is considered
# to have started. Instead of modifying all of those things to instead
# wait for dbus-spy to be started, drop dbus-spy in as "dbus" which,
# in turn, waits on "realdbus." This way we don't race other services
# and are guaranteed to capture all dbus events from boot onward.
sudo cp -a "${ROOT_FS_DIR}/etc/init/dbus.conf" \
"${ROOT_FS_DIR}/etc/init/realdbus.conf"
sudo cp "${DBUS_CONF}" "${ROOT_FS_DIR}/etc/init/dbus.conf"
sudo cp "${SYSTEM_LOCAL_CONF}" "${ROOT_FS_DIR}/etc/dbus-1/system-local.conf"
# Unmount and re-sign. See crosbug.com/18709 for why this isn't using
# cros_make_image_bootable.
cleanup
TMP_BIN_PATH="${FLAGS_image}.new"
"${VBOOT_DIR}/sign_official_build.sh" usb "${FLAGS_image}" \
"${DEVKEYS_DIR}" \
"${TMP_BIN_PATH}"
mv "${TMP_BIN_PATH}" "${FLAGS_image}"

View File

@ -1,189 +0,0 @@
#!/bin/bash
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Script to modify a keyfob-based chromeos test image to install pyauto.
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
. "${SCRIPT_ROOT}/common.sh" || exit 1
cleanup() {
"${SCRIPTS_DIR}/mount_gpt_image.sh" -u -r "$ROOT_FS_DIR" -s "$STATEFUL_FS_DIR"
}
# Need to be inside the chroot to load chromeos-common.sh
assert_inside_chroot
DEFINE_string board "$DEFAULT_BOARD" "Board for which the image was built" b
DEFINE_string image "$FLAGS_image" "Location of the test image file" i
DEFINE_boolean scrub "$FLAGS_FALSE" "Don't include pyauto tests and data" s
DEFINE_string build_root "/build" \
"The root location for board sysroots, override with autotest bundle"
# Parse command line
FLAGS "$@" || exit 1
eval set -- "$FLAGS_ARGV"
if [ "${FLAGS_build_root}" = "/build" ]; then
FLAGS_build_root="/build/${FLAGS_board}/usr/local/autotest"
fi
FLAGS_build_root=$(eval readlink -f "${FLAGS_build_root}")
FLAGS_image=$(eval readlink -f "${FLAGS_image}")
IMAGE_DIR=$(dirname "${FLAGS_image}")
IMAGE_NAME=$(basename "${FLAGS_image}")
ROOT_FS_DIR="${IMAGE_DIR}/rootfs"
STATEFUL_FS_DIR="${IMAGE_DIR}/stateful"
PYAUTO_DEP="${FLAGS_build_root}/client/deps/pyauto_dep"
CHROME_DEP="${FLAGS_build_root}/client/deps/chrome_test"
VBOOT_DIR="${CHROOT_TRUNK_DIR}/src/platform/vboot_reference/scripts/"\
"image_signing"
if [ ! -d $PYAUTO_DEP ]; then
die_notrace "The required path: $PYAUTO_DEP does not exist. Did you mean \
to pass --build_root and the path to the autotest bundle?"
fi
if [ ! -d $CHROME_DEP ]; then
die_notrace "The required path: $CHROME_DEP does not exist. Did you mean \
to pass --build_root and the path to the autotest bundle?"
fi
if [ ! -d $VBOOT_DIR ]; then
die_notrace "The required path: $VBOOT_DIR does not exist. This directory \
needs to be sync'd into your chroot.\n $ cros_workon start vboot_reference \
--board ${FLAGS_board}"
fi
if [ ! -d "${FLAGS_build_root}/client/cros" ]; then
die "The required path: ${FLAGS_build_root}/client/cros does not exist."
fi
trap cleanup EXIT
cleanup EXIT
# Mounts gpt image and sets up var, /usr/local and symlinks.
"$SCRIPTS_DIR/mount_gpt_image.sh" -i "$IMAGE_NAME" -f "$IMAGE_DIR" \
-r "$ROOT_FS_DIR" -s "$STATEFUL_FS_DIR"
STATEFUL_FS_AUTOTEST_DIR="${STATEFUL_FS_DIR}/dev_image/autotest"
IMAGE_TEST_SRC_DIR="${STATEFUL_FS_AUTOTEST_DIR}/deps/chrome_test/test_src"
IMAGE_RELEASE_DIR="${IMAGE_TEST_SRC_DIR}/out/Release"
sudo mkdir -p "${STATEFUL_FS_AUTOTEST_DIR}"
sudo mkdir -p "${IMAGE_TEST_SRC_DIR}"
sudo mkdir -p "${IMAGE_RELEASE_DIR}"
sudo cp -f -r "${FLAGS_build_root}/client/cros" "${STATEFUL_FS_AUTOTEST_DIR}"
# We want to copy everything that is in this directory except the out folder
# since it has very large test binaries that we don't need for pyauto.
info "Copying test source depedencies..."
for item in base chrome content net pdf third_party; do
info "Copying $item to ${IMAGE_TEST_SRC_DIR}"
sudo cp -f -r "${CHROME_DEP}/test_src/$item" "${IMAGE_TEST_SRC_DIR}"
done
info "Copying chrome dep components..."
sudo cp -f -r "${CHROME_DEP}/test_src/out/Release/setup_test_links.sh" \
"${IMAGE_RELEASE_DIR}/"
info "Copying pyauto dependencies..."
sudo cp -r $PYAUTO_DEP "${STATEFUL_FS_AUTOTEST_DIR}/deps"
if [ $FLAGS_scrub -eq $FLAGS_TRUE ]; then
IMAGE_TEST_DIR="${IMAGE_TEST_SRC_DIR}/chrome"
sudo rm -rf \
"${IMAGE_TEST_DIR}/data/" \
"${IMAGE_TEST_DIR}/functional/"
sudo mkdir \
"${IMAGE_TEST_DIR}/data/" \
"${IMAGE_TEST_DIR}/functional/"
sudo cp "${CHROME_DEP}/test_src/chrome/test/functional/pyauto_functional.py" \
"${IMAGE_TEST_DIR}/functional/"
# Create an example pyauto test.
echo -e "#!/usr/bin/python\n\
# Copyright (c) 2011 The Chromium Authors. All rights reserved.\n\
# Use of this source code is governed by a BSD-style license that can be\n\
# found in the LICENSE file.\n\
\n\
import os\n\
import subprocess\n\
\n\
import pyauto_functional # Must be imported before pyauto\n\
import pyauto\n\
\n\
class ChromeosDemo(pyauto.PyUITest):\n\
\"\"\"Example PyAuto test for ChromeOS.\n\
\n\
To run this test, you must be logged into the Chromebook as root. Then run\n\
the following command:\n\
$ python example.py\n\
\"\"\"\n\
\n\
assert os.geteuid() == 0, 'Need to run this test as root'\n\
\n\
def testLoginAsGuest(self):\n\
\"\"\"Test we can login with guest mode.\"\"\"\n\
self.LoginAsGuest()\n\
login_info = self.GetLoginInfo()\n\
self.assertTrue(login_info['is_logged_in'], msg='Not logged in at all.')\n\
self.assertTrue(login_info['is_guest'], msg='Not logged in as guest.')\n\
\n\
if __name__ == '__main__':\n\
pyauto_functional.Main()" > "/tmp/example.py"
sudo cp "/tmp/example.py" \
"${STATEFUL_FS_AUTOTEST_DIR}/deps/chrome_test/test_src/\
chrome/test/functional/example.py"
fi
# In some chroot configurations chronos is not configured, so we use 1000
sudo chown -R 1000 "${STATEFUL_FS_AUTOTEST_DIR}"
sudo chgrp -R 1000 "${STATEFUL_FS_AUTOTEST_DIR}"
# Based on how the autotest package is extracted, the user running in the chroot
# may not have access to navigate into this folder because only the owner
# (chronos) has access. This fixes that so anyone can access.
sudo chmod 747 -R "${STATEFUL_FS_AUTOTEST_DIR}"
# Setup permissions and symbolic links
for item in chrome_test pyauto_dep; do
pushd .
cd "${STATEFUL_FS_AUTOTEST_DIR}/deps/$item/test_src/out/Release"
sudo cp "${ROOT_FS_DIR}/usr/local/bin/python2.6" suid-python
sudo chown root:root suid-python
sudo chmod 4755 suid-python
popd
info "Setting up pyauto required symbolic links in $item..."
sudo chroot "${ROOT_FS_DIR}" sudo bash "/usr/local/autotest/deps/\
$item/test_src/out/Release/setup_test_links.sh"
done
# Add an easy link to get to the functional folder
sudo ln -f -s \
"/usr/local/autotest/deps/chrome_test/test_src/chrome/test/functional" \
"${ROOT_FS_DIR}/pyauto"
cleanup
# cros_make_image_bootable is unstable (crosbug.com/18709)
DEVKEYS_DIR="${CHROOT_TRUNK_DIR}/src/platform/vboot_reference/tests/devkeys/"
TMP_BIN_PATH="$(dirname "${FLAGS_image}")/pyauto_tmp.bin"
echo ${TMP_BIN_PATH}
rm -f "${TMP_BIN_PATH}"
"${VBOOT_DIR}/sign_official_build.sh" usb "${FLAGS_image}" \
"${DEVKEYS_DIR}" \
"${TMP_BIN_PATH}" \
rm -f "${FLAGS_image}"
mv "${TMP_BIN_PATH}" "${FLAGS_image}"

View File

@ -1,182 +0,0 @@
#!/usr/bin/python
# 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.
"""
This script runs inside chroot environment. It signs and build factory packages.
Then serves them using devserver. All paths should be specified relative to the
chroot environment.
E.g.: cros_sdk -- serve_factory_packages.py --board <board>
Always precede the call to the script with 'cros_sdk -- ".
"""
import gflags
import os
import shlex
import signal
import subprocess
import sys
CWD = os.getcwd()
USER = os.environ['USER']
HOME_DIR = '/home/%s/trunk/src' % USER
SCRIPTS_DIR = HOME_DIR + '/scripts'
DEVSERVER_DIR = HOME_DIR + '/platform/dev'
# Paths to image signing directory and dev key.
VBOOT_REF_DIR = HOME_DIR + '/platform/vboot_reference'
IMG_SIGN_DIR = VBOOT_REF_DIR + '/scripts/image_signing'
DEVKEYS = VBOOT_REF_DIR + '/tests/devkeys'
FLAGS = gflags.FLAGS
gflags.DEFINE_string('board', None, 'Platform to build.')
gflags.DEFINE_string('base_image', None, 'Path to base image.')
gflags.DEFINE_string('firmware_updater', None, 'Path to firmware updater.')
gflags.DEFINE_boolean('start_devserver', False, 'Start devserver.')
class KillableProcess():
"""A killable process.
"""
running_process = None
def __init__(self, cmd, timeout=60, cwd=CWD):
"""Initialize process
Args:
cmd: command to run.
"""
self.cmd = shlex.split(cmd)
self.cmd_timeout = timeout
self.cmd_cwd = cwd
def start(self, wait=True):
"""Start the process.
Args:
wait: wait for command to complete.
"""
self.running_process = subprocess.Popen(self.cmd,
cwd=self.cmd_cwd)
if wait:
self.running_process.wait()
def stop(self):
"""Stop the process.
This will only work for commands that do not exit.
"""
self.running_process.send_signal(signal.SIGINT)
self.running_process.wait()
def start_devserver():
"""Starts devserver."""
cmd = 'python devserver.py --factory_config miniomaha.conf'
print 'Running command: %s' % cmd
devserver_process = KillableProcess(cmd, cwd=DEVSERVER_DIR)
devserver_process.start(wait=False)
def assert_is_file(path, message):
"""Assert file exists.
Args:
path: path to file.
message: message to print if file does not exist.
"""
if not os.path.isfile(path):
error_message = '%s: %s is not a file!' % (message, path)
print error_message
sys.exit(1)
def setup_board(board):
"""Setup the board inside chroot.
"""
cmd = './setup_board --board %s' % board
print 'Setting up board: %s' % board
setup_board_process = KillableProcess(cmd, cwd=SCRIPTS_DIR)
setup_board_process.start()
def sign_build(image, output):
"""Make an SSD signed build.
Args:
image: image to sign.
output: destination path for signed image.
"""
assert_is_file(image, 'Asserting base image exists')
cmd = ('sudo ./sign_official_build.sh ssd %s %s %s'
% (image, DEVKEYS, output))
print 'IMG_SIGN_DIR: %s' % IMG_SIGN_DIR
print 'Signing image: %s' % cmd
sign_process = KillableProcess(cmd, cwd=IMG_SIGN_DIR)
sign_process.start()
def build_factory_packages(signed_image, base_image, fw_updater, folder, board):
"""Build factory packages and modify mini omaha config.
Args:
signed_image: signed image
base_image: base image
fw_updater: firmware updater
folder: destination folder to write packages
board: platform to build
"""
cmd = ('./make_factory_package.sh --release %s --factory %s'
' --subfolder %s --board %s'
% (signed_image, base_image, folder, board))
if fw_updater:
cmd = '%s --firmware_updater %s' % (cmd, fw_updater)
else:
print ('No --firmware_updater specified. Not including firmware shellball.')
print 'Building factory packages: %s' % cmd
build_packages_process = KillableProcess(cmd, cwd=SCRIPTS_DIR)
build_packages_process.start()
def exit(message):
print message
sys.exit(1)
def main(argv):
try:
argv = FLAGS(argv)
except gflags.FlagsError, e:
print '%s\nUsage: %s ARGS\n%s' % (e, sys.argv[0], FLAGS)
sys.exit(1)
if not FLAGS.base_image:
exit('No --base_image specified.')
if FLAGS.firmware_updater:
assert_is_file(FLAGS.firmware_updater,
'Invalid or missing firmware updater.')
assert_is_file(FLAGS.base_image, 'Invalid or missing base image.')
signed_image = os.path.join(os.path.dirname(FLAGS.base_image),
'%s_ssd_signed.bin' % FLAGS.board)
setup_board(FLAGS.board)
sign_build(FLAGS.base_image, signed_image)
build_factory_packages(signed_image, FLAGS.base_image,
FLAGS.firmware_updater,
folder=FLAGS.board, board=FLAGS.board)
if FLAGS.start_devserver:
start_devserver()
if __name__ == '__main__':
main(sys.argv)