mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-04 11:51:14 +02:00
Update factory installer, factory test
* Fix build breaks * Update to work with EFI bios Review URL: http://codereview.chromium.org/2132008
This commit is contained in:
parent
9d2a7980cf
commit
7c982f7398
@ -26,8 +26,6 @@ DEFINE_boolean factory_install ${FLAGS_FALSE} \
|
||||
"Whether to generate a factory install shim."
|
||||
DEFINE_boolean factory ${FLAGS_FALSE} \
|
||||
"Whether to generate a factory runin image. Implies aututest and test"
|
||||
DEFINE_boolean install_autotest ${FLAGS_FALSE} \
|
||||
"Whether to install autotest to the stateful partition."
|
||||
DEFINE_boolean copy_kernel ${FLAGS_FALSE} \
|
||||
"Copy the kernel to the fourth partition."
|
||||
DEFINE_boolean test_image "${FLAGS_FALSE}" \
|
||||
@ -48,8 +46,7 @@ fi
|
||||
|
||||
# Require autotest for manucaturing image.
|
||||
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then
|
||||
echo "Factory image requires --install_autotest and --test_image, setting."
|
||||
FLAGS_install_autotest=${FLAGS_TRUE}
|
||||
echo "Factory image requires --test_image, setting."
|
||||
FLAGS_test_image=${FLAGS_TRUE}
|
||||
fi
|
||||
|
||||
@ -60,19 +57,6 @@ if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then
|
||||
fi
|
||||
|
||||
|
||||
# Inside the chroot, so output to usb.img in the same dir as the other
|
||||
# Script can be run either inside or outside the chroot.
|
||||
if [ ${INSIDE_CHROOT} -eq 1 ]
|
||||
then
|
||||
SYSROOT="${FLAGS_build_root}/${FLAGS_board}"
|
||||
else
|
||||
SYSROOT="${DEFAULT_CHROOT_DIR}${FLAGS_build_root}/${FLAGS_board}"
|
||||
echo "Caching sudo authentication"
|
||||
sudo -v
|
||||
echo "Done"
|
||||
fi
|
||||
AUTOTEST_SRC="${SYSROOT}/usr/local/autotest"
|
||||
|
||||
# Die on any errors.
|
||||
set -e
|
||||
|
||||
@ -119,50 +103,6 @@ function do_cleanup {
|
||||
fi
|
||||
}
|
||||
|
||||
if [ ${FLAGS_install_autotest} -eq ${FLAGS_TRUE} ] ; then
|
||||
echo "Detecting autotest at ${AUTOTEST_SRC}"
|
||||
if [ -d ${AUTOTEST_SRC} ]
|
||||
then
|
||||
# Figure out how to loop mount the stateful partition. It's always
|
||||
# partition 1 on the disk image.
|
||||
offset=$(partoffset "${SRC_IMAGE}" 1)
|
||||
|
||||
stateful_loop_dev=$(sudo losetup -f)
|
||||
if [ -z "${stateful_loop_dev}" ]
|
||||
then
|
||||
echo "No free loop device. Free up a loop device or reboot. exiting."
|
||||
exit 1
|
||||
fi
|
||||
STATEFUL_LOOP_DEV=$stateful_loop_dev
|
||||
trap do_cleanup INT TERM EXIT
|
||||
|
||||
echo "Mounting ${STATEFUL_DIR} loopback"
|
||||
sudo losetup -o $(( $offset * 512 )) "${stateful_loop_dev}" "${SRC_IMAGE}"
|
||||
sudo mount "${stateful_loop_dev}" "${STATEFUL_DIR}"
|
||||
stateful_root="${STATEFUL_DIR}/dev_image"
|
||||
|
||||
echo "Install autotest into stateful partition..."
|
||||
autotest_client="/home/autotest-client"
|
||||
sudo mkdir -p "${stateful_root}${autotest_client}"
|
||||
sudo ln -sf /mnt/stateful_partition/dev_image${autotest_client} \
|
||||
${stateful_root}/autotest
|
||||
|
||||
sudo cp -fpru ${AUTOTEST_SRC}/client/* \
|
||||
"${stateful_root}/${autotest_client}"
|
||||
sudo chmod 755 "${stateful_root}/${autotest_client}"
|
||||
sudo chown -R 1000:1000 "${stateful_root}/${autotest_client}"
|
||||
|
||||
sudo umount ${STATEFUL_DIR}
|
||||
sudo losetup -d "${stateful_loop_dev}"
|
||||
trap - INT TERM EXIT
|
||||
rmdir "${STATEFUL_DIR}"
|
||||
else
|
||||
echo "/usr/local/autotest under ${DEFAULT_CHROOT_DIR} is not installed."
|
||||
echo "Please call build_autotest.sh inside chroot first."
|
||||
exit -1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# If we're asked to modify the image for test, then let's make a copy and
|
||||
# modify that instead.
|
||||
|
||||
155
make_factory_package.sh
Executable file
155
make_factory_package.sh
Executable file
@ -0,0 +1,155 @@
|
||||
#!/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.
|
||||
|
||||
# Script to generate a factory install partition set and miniomaha.conf
|
||||
# file from a release image and a factory image. This creates a server
|
||||
# configuration that can be installed using a factory install shim.
|
||||
#
|
||||
# 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"
|
||||
|
||||
# Load functions and constants for chromeos-install
|
||||
. "$(dirname "$0")/chromeos-common.sh"
|
||||
|
||||
get_default_board
|
||||
|
||||
# Flags
|
||||
DEFINE_string board "${DEFAULT_BOARD}" "Board for which the image was built"
|
||||
DEFINE_string factory "" \
|
||||
"Directory and file containing factory image: /path/chromiumos_test_image.bin"
|
||||
DEFINE_string release "" \
|
||||
"Directory and file containing release image: /path/chromiumos_image.bin"
|
||||
|
||||
|
||||
# Parse command line
|
||||
FLAGS "$@" || exit 1
|
||||
eval set -- "${FLAGS_ARGV}"
|
||||
|
||||
if [ ! -f "${FLAGS_release}" ] ; then
|
||||
echo "Cannot find image file ${FLAGS_release}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "${FLAGS_factory}" ] ; then
|
||||
echo "Cannot find image file ${FLAGS_factory}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Convert args to paths. Need eval to un-quote the string so that shell
|
||||
# chars like ~ are processed; just doing FOO=`readlink -f ${FOO}` won't work.
|
||||
OMAHA_DIR=${SRC_ROOT}/platform/dev
|
||||
OMAHA_DATA_DIR=${OMAHA_DIR}/static/
|
||||
|
||||
if [ ${INSIDE_CHROOT} -eq 0 ]; then
|
||||
echo "Caching sudo authentication"
|
||||
sudo -v
|
||||
echo "Done"
|
||||
fi
|
||||
|
||||
# Use this image as the source image to copy
|
||||
RELEASE_DIR=`dirname ${FLAGS_release}`
|
||||
FACTORY_DIR=`dirname ${FLAGS_factory}`
|
||||
RELEASE_IMAGE=`basename ${FLAGS_release}`
|
||||
FACTORY_IMAGE=`basename ${FLAGS_factory}`
|
||||
|
||||
|
||||
prepare_omaha() {
|
||||
sudo rm -rf ${OMAHA_DATA_DIR}/rootfs-test.gz
|
||||
sudo rm -rf ${OMAHA_DATA_DIR}/rootfs-release.gz
|
||||
rm -rf ${OMAHA_DATA_DIR}/efi.gz
|
||||
rm -rf ${OMAHA_DATA_DIR}/oem.gz
|
||||
rm -rf ${OMAHA_DATA_DIR}/state.gz
|
||||
rm -rf ${OMAHA_DIR}/miniomaha.conf
|
||||
}
|
||||
|
||||
prepare_dir() {
|
||||
sudo rm -rf rootfs-test.gz
|
||||
sudo rm -rf rootfs-release.gz
|
||||
rm -rf efi.gz
|
||||
rm -rf oem.gz
|
||||
rm -rf state.gz
|
||||
}
|
||||
|
||||
|
||||
# Clean up stale config and data files.
|
||||
prepare_omaha
|
||||
|
||||
# Get the release image.
|
||||
pushd ${RELEASE_DIR}
|
||||
echo "Generating omaha release image from ${FLAGS_release}"
|
||||
echo "Generating omaha factory image from ${FLAGS_factory}"
|
||||
echo "Output omaha image to ${OMAHA_DATA_DIR}"
|
||||
echo "Output omaha config to ${OMAHA_DIR}/miniomaha.conf"
|
||||
|
||||
prepare_dir
|
||||
|
||||
sudo ./unpack_partitions.sh ${RELEASE_IMAGE} &> /dev/null
|
||||
release_hash=`sudo ${SCRIPTS_DIR}/mk_memento_images.sh part_2 part_3 \
|
||||
| grep hash | awk '{print $4}'`
|
||||
sudo chmod a+rw update.gz
|
||||
mv update.gz rootfs-release.gz
|
||||
mv rootfs-release.gz ${OMAHA_DATA_DIR}
|
||||
echo "release: ${release_hash}"
|
||||
|
||||
cat part_8 | gzip -9 > oem.gz
|
||||
oem_hash=`cat oem.gz | openssl sha1 -binary | openssl base64`
|
||||
mv oem.gz ${OMAHA_DATA_DIR}
|
||||
echo "oem: ${oem_hash}"
|
||||
|
||||
cat part_12 | gzip -9 > efi.gz
|
||||
efi_hash=`cat efi.gz | openssl sha1 -binary | openssl base64`
|
||||
mv efi.gz ${OMAHA_DATA_DIR}
|
||||
echo "efi: ${efi_hash}"
|
||||
|
||||
popd
|
||||
|
||||
# Go to retrieve the factory test image.
|
||||
pushd ${FACTORY_DIR}
|
||||
prepare_dir
|
||||
|
||||
|
||||
sudo ./unpack_partitions.sh ${FACTORY_IMAGE} &> /dev/null
|
||||
test_hash=`sudo ${SCRIPTS_DIR}//mk_memento_images.sh part_2 part_3 \
|
||||
| grep hash | awk '{print $4}'`
|
||||
sudo chmod a+rw update.gz
|
||||
mv update.gz rootfs-test.gz
|
||||
mv rootfs-test.gz ${OMAHA_DATA_DIR}
|
||||
echo "test: ${test_hash}"
|
||||
|
||||
cat part_1 | gzip -9 > state.gz
|
||||
state_hash=`cat state.gz | openssl sha1 -binary | openssl base64`
|
||||
mv state.gz ${OMAHA_DATA_DIR}
|
||||
echo "state: ${state_hash}"
|
||||
|
||||
echo "
|
||||
config = [
|
||||
{
|
||||
'qual_ids': set([\"${FLAGS_board}\"]),
|
||||
'factory_image': 'rootfs-test.gz',
|
||||
'factory_checksum': '${test_hash}',
|
||||
'release_image': 'rootfs-release.gz',
|
||||
'release_checksum': '${release_hash}',
|
||||
'oempartitionimg_image': 'oem.gz',
|
||||
'oempartitionimg_checksum': '${oem_hash}',
|
||||
'efipartitionimg_image': 'efi.gz',
|
||||
'efipartitionimg_checksum': '${efi_hash}',
|
||||
'stateimg_image': 'state.gz',
|
||||
'stateimg_checksum': '${state_hash}'
|
||||
},
|
||||
]
|
||||
" > ${OMAHA_DIR}/miniomaha.conf
|
||||
|
||||
popd
|
||||
echo "The miniomaha server lives in src/platform/dev"
|
||||
echo "to validate the configutarion, run:"
|
||||
echo " python2.6 devserver.py --factory_config miniomaha.conf \
|
||||
--validate_factory_config"
|
||||
echo "To run the server:"
|
||||
echo " python2.6 devserver.py --factory_config miniomaha.conf"
|
||||
@ -7,6 +7,7 @@
|
||||
echo "Applying patch to init scripts."
|
||||
pushd ${ROOT_FS_DIR}
|
||||
|
||||
touch ${ROOT_FS_DIR}/root/.factory_test
|
||||
patch -d ${ROOT_FS_DIR} -Np1 <<EOF
|
||||
--- old/etc/init/ui.conf 2010-04-28 21:28:38.886069000 -0700
|
||||
+++ new/etc/init/ui.conf 2010-04-28 21:29:42.676163000 -0700
|
||||
@ -74,30 +75,4 @@ tail -n 48 -F /var/log/factory.log > /dev/tty1
|
||||
end script
|
||||
EOF
|
||||
|
||||
patch -d ${ROOT_FS_DIR} -Np1 <<EOF
|
||||
diff -Naur old/sbin/chromeos_startup new/sbin/chromeos_startup
|
||||
--- old/sbin/chromeos_startup 2010-04-05 21:33:52.000000000 -0700
|
||||
+++ new/sbin/chromeos_startup 2010-04-05 21:38:02.000000000 -0700
|
||||
@@ -20,18 +20,12 @@
|
||||
|
||||
# Moblin trick: Disable blinking cursor. Without this a splash screen
|
||||
# will show a distinct cursor shape even when the cursor is set to none.
|
||||
-echo 0 > /sys/devices/virtual/graphics/fbcon/cursor_blink
|
||||
+# echo 0 > /sys/devices/virtual/graphics/fbcon/cursor_blink
|
||||
|
||||
# Since we defer udev until later in the boot process, we pre-populate /dev
|
||||
# with the set of devices needed for X and other early services to run.
|
||||
cp -a -f /lib/chromiumos/devices/* /dev
|
||||
|
||||
-# Splash screen!
|
||||
-if [ -x /usr/bin/ply-image ]
|
||||
-then
|
||||
- /usr/bin/ply-image /usr/share/chromeos-assets/images/login_splash.png &
|
||||
-fi
|
||||
-
|
||||
mount -n -t tmpfs tmp /tmp
|
||||
mount -n -t tmpfs -onosuid,nodev shmfs /dev/shm
|
||||
mount -n -t devpts -onoexec,nosuid,gid=5,mode=0620 devpts /dev/pts
|
||||
EOF
|
||||
|
||||
popd
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
|
||||
echo "Create global_config.ini in autotest directory."
|
||||
|
||||
GLOBAL_CONFIG="${STATEFUL_DIR}/home/autotest-client/global_config.ini"
|
||||
GLOBAL_CONFIG="${ROOT_FS_DIR}/usr/local/autotest/global_config.ini"
|
||||
|
||||
if [ -f "${GLOBAL_CONFIG}" ]; then
|
||||
echo -e "File ${GLOBAL_CONFIG} already exists."
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
# QUALDB can be a full path of the file, or a specified directory
|
||||
# /tmp/run_remote_tests.XXXX, or a default wildcard one /tmp/run_remote_tests.*.
|
||||
|
||||
COMPONENTS_FILE="${STATEFUL_DIR}/usr/local/autotest/site_tests/"\
|
||||
COMPONENTS_FILE="${ROOT_FS_DIR}/usr/local/autotest/site_tests/"\
|
||||
"hardware_Components/qualified_components"
|
||||
|
||||
# If QUALDB is a default wildcard directory, try to use the most recent one.
|
||||
|
||||
@ -20,17 +20,20 @@ get_default_board
|
||||
|
||||
DEFINE_string board "$DEFAULT_BOARD" "Board for which the image was built" b
|
||||
DEFINE_boolean factory $FLAGS_FALSE \
|
||||
"Modify the image for manufacturing testing" f
|
||||
"Modify the image for manufacturing testing" f
|
||||
DEFINE_boolean factory_install $FLAGS_FALSE \
|
||||
"Modify the image for factory install shim"
|
||||
DEFINE_string image "" "Location of the rootfs raw image file" i
|
||||
DEFINE_boolean installmask $FLAGS_TRUE \
|
||||
"Use INSTALL_MASK to shrink the resulting image." m
|
||||
"Use INSTALL_MASK to shrink the resulting image." m
|
||||
DEFINE_integer jobs -1 \
|
||||
"How many packages to build in parallel at maximum." j
|
||||
"How many packages to build in parallel at maximum." j
|
||||
DEFINE_string qualdb "/tmp/run_remote_tests.*" \
|
||||
"Location of qualified component file" d
|
||||
DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" y
|
||||
DEFINE_string build_root "/build" \
|
||||
"The root location for board sysroots."
|
||||
|
||||
|
||||
# Parse command line
|
||||
FLAGS "$@" || exit 1
|
||||
@ -91,6 +94,35 @@ emerge_chromeos_test() {
|
||||
--usepkgonly chromeos-test $EMERGE_JOBS
|
||||
}
|
||||
|
||||
|
||||
install_autotest() {
|
||||
SYSROOT="${FLAGS_build_root}/${FLAGS_board}"
|
||||
AUTOTEST_SRC="${SYSROOT}/usr/local/autotest"
|
||||
stateful_root="${ROOT_FS_DIR}/usr/local"
|
||||
autotest_client="/autotest"
|
||||
|
||||
echo "Install autotest into stateful partition from $AUTOTEST_SRC"
|
||||
|
||||
sudo mkdir -p "${stateful_root}${autotest_client}"
|
||||
sudo mkdir -p "/tmp/autotest"
|
||||
sudo rm -rf /tmp/autotest/*
|
||||
|
||||
sudo cp -fpru ${AUTOTEST_SRC}/client/* \
|
||||
"/tmp/autotest"
|
||||
# Remove outrageously large tests.
|
||||
# TODO(nsanders): is there a better way to do this?
|
||||
sudo rm -rf /tmp/autotest/deps/realtimecomm_playground
|
||||
sudo rm -rf /tmp/autotest/tests/ltp
|
||||
sudo rm -rf /tmp/autotest/site_tests/graphics_O3DSelenium
|
||||
sudo rm -rf /tmp/autotest/realtimecomm_GTalk*
|
||||
sudo rm -rf /tmp/autotest/site_tests/platform_StackProtector
|
||||
|
||||
sudo cp -fpru /tmp/autotest/* \
|
||||
"${stateful_root}/${autotest_client}"
|
||||
sudo chmod 755 "${stateful_root}/${autotest_client}"
|
||||
sudo chown -R 1000:1000 "${stateful_root}/${autotest_client}"
|
||||
}
|
||||
|
||||
# main process begins here.
|
||||
|
||||
# Make sure this is really what the user wants, before nuking the device
|
||||
@ -125,7 +157,7 @@ if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then
|
||||
|
||||
# Run factory setup script to modify the image.
|
||||
sudo emerge-${FLAGS_board} --root=$ROOT_FS_DIR --usepkgonly \
|
||||
--root-deps=rdeps chromeos-factoryinstall
|
||||
--root-deps=rdeps --nodeps chromeos-factoryinstall
|
||||
|
||||
# Set factory server if necessary.
|
||||
if [ "${FACTORY_SERVER}" != "" ]; then
|
||||
@ -143,14 +175,23 @@ else
|
||||
"${MOD_TEST_ROOT}/test_setup.sh"
|
||||
|
||||
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then
|
||||
install_autotest
|
||||
|
||||
MOD_FACTORY_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_factory_scripts"
|
||||
# Run factory setup script to modify the image
|
||||
sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \
|
||||
STATEFUL_DIR="${STATEFUL_DIR}/dev_image" QUALDB="${FLAGS_qualdb}" \
|
||||
QUALDB="${FLAGS_qualdb}" \
|
||||
"${MOD_FACTORY_ROOT}/factory_setup.sh"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Let's have a look at the image just in case..
|
||||
if [ "${VERIFY}" = "true" ]; then
|
||||
pushd "${ROOT_FS_DIR}"
|
||||
bash
|
||||
popd
|
||||
fi
|
||||
|
||||
cleanup
|
||||
trap - EXIT
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user