mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-25 07:31:01 +02:00
Allow boot directly into mfg test.
Add feature to mod_image_for_test to patch rootfs. Change initctl path to get network but no chrome. ./image_to_usb.sh --install_mfg --install_autotest --test_image which calls ./mod_image_for_test.sh --manuf Review URL: http://codereview.chromium.org/1542011
This commit is contained in:
parent
acee63274c
commit
3c8023380e
@ -21,6 +21,9 @@ DEFINE_string from "" \
|
||||
"Directory containing chromiumos_image.bin"
|
||||
DEFINE_string to "" "${DEFAULT_TO_HELP}"
|
||||
DEFINE_boolean yes ${FLAGS_FALSE} "Answer yes to all prompts" "y"
|
||||
DEFINE_boolean force_copy ${FLAGS_FALSE} "Always rebuild test image"
|
||||
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} \
|
||||
@ -34,6 +37,13 @@ DEFINE_string build_root "/build" \
|
||||
FLAGS "$@" || exit 1
|
||||
eval set -- "${FLAGS_ARGV}"
|
||||
|
||||
# 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}
|
||||
FLAGS_test_image=${FLAGS_TRUE}
|
||||
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 ]
|
||||
@ -84,22 +94,42 @@ fi
|
||||
FLAGS_from=`eval readlink -f ${FLAGS_from}`
|
||||
FLAGS_to=`eval readlink -f ${FLAGS_to}`
|
||||
|
||||
# Done evaluating arguments, lets go!
|
||||
echo "Caching sudo authentication"
|
||||
sudo -v
|
||||
echo "Done"
|
||||
|
||||
# Use this image as the source image to copy
|
||||
SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin"
|
||||
|
||||
# If we're asked to modify the image for test, then let's make a copy and
|
||||
# modify that instead.
|
||||
if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then
|
||||
if [ ! -f "${FLAGS_from}/chromiumos_test_image.bin" ] ; then
|
||||
if [ ! -f "${FLAGS_from}/chromiumos_test_image.bin" ] || \
|
||||
[ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then
|
||||
# Copy it.
|
||||
echo "Creating test image from original..."
|
||||
cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_test_image.bin"
|
||||
|
||||
# Check for manufacturing image.
|
||||
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then
|
||||
FACTORY_ARGS="--factory"
|
||||
fi
|
||||
# Check for yes
|
||||
if [ ${FLAGS_yes} -eq ${FLAGS_TRUE} ] ; then
|
||||
YES="--yes"
|
||||
fi
|
||||
|
||||
|
||||
# Modify it.
|
||||
"${SCRIPTS_DIR}/mod_image_for_test.sh" --image \
|
||||
"${FLAGS_from}/chromiumos_test_image.bin" --yes
|
||||
"${FLAGS_from}/chromiumos_test_image.bin" ${FACTORY_ARGS} ${YES}
|
||||
echo "Done with mod_image_for_test."
|
||||
else
|
||||
echo "Using cached test image."
|
||||
fi
|
||||
# Use it.
|
||||
SRC_IMAGE="${FLAGS_from}/chromiumos_test_image.bin"
|
||||
echo "Source test image is: ${SRC_IMAGE}"
|
||||
fi
|
||||
|
||||
STATEFUL_DIR="${FLAGS_from}/stateful_partition"
|
||||
@ -140,6 +170,8 @@ if [ ${FLAGS_install_autotest} -eq ${FLAGS_TRUE} ] ; then
|
||||
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}"
|
||||
@ -152,7 +184,7 @@ if [ ${FLAGS_install_autotest} -eq ${FLAGS_TRUE} ] ; then
|
||||
rmdir "${STATEFUL_DIR}"
|
||||
else
|
||||
echo "/usr/local/autotest under ${DEFAULT_CHROOT_DIR} is not installed."
|
||||
echo "Please call make_autotest.sh inside chroot first."
|
||||
echo "Please call build_autotest.sh inside chroot first."
|
||||
exit -1
|
||||
fi
|
||||
fi
|
||||
@ -166,7 +198,7 @@ then
|
||||
|
||||
# Warn if it looks like they supplied a partition as the destination.
|
||||
if echo "${FLAGS_to}" | grep -q '[0-9]$'; then
|
||||
local drive=$(echo "${FLAGS_to}" | sed -re 's/[0-9]+$//')
|
||||
drive=$(echo "${FLAGS_to}" | sed -re 's/[0-9]+$//')
|
||||
if [ -b "${drive}" ]; then
|
||||
echo
|
||||
echo "NOTE: It looks like you may have supplied a partition as the "
|
||||
|
88
mod_for_factory_scripts/factory.patch
Normal file
88
mod_for_factory_scripts/factory.patch
Normal file
@ -0,0 +1,88 @@
|
||||
diff -Naur old/etc/init/dump-boot-stats.conf new/etc/init/dump-boot-stats.conf
|
||||
--- old/etc/init/dump-boot-stats.conf 2010-04-05 21:33:11.000000000 -0700
|
||||
+++ new/etc/init/dump-boot-stats.conf 2010-04-05 21:00:48.000000000 -0700
|
||||
@@ -7,7 +7,7 @@
|
||||
# when login-prompt-ready is received, grabs the current uptime and
|
||||
# disk stats. Also sends uptime to metrics client for perf dashboard
|
||||
|
||||
-start on login-prompt-ready
|
||||
+start on stopping startup
|
||||
|
||||
# This is run-once rather than a service.
|
||||
task
|
||||
diff -Naur old/etc/init/factory.conf new/etc/init/factory.conf
|
||||
--- old/etc/init/factory.conf 1969-12-31 16:00:00.000000000 -0800
|
||||
+++ new/etc/init/factory.conf 2010-04-05 20:59:07.000000000 -0700
|
||||
@@ -0,0 +1,17 @@
|
||||
+
|
||||
+description "Chrome OS factory startup stub"
|
||||
+author "chromium-os-dev@googlegroups.com"
|
||||
+
|
||||
+start on stopping autotest
|
||||
+
|
||||
+script
|
||||
+
|
||||
+cd /usr/local/autotest
|
||||
+if [ ! -e factory_started ]; then
|
||||
+ touch factory_started
|
||||
+ date >> /var/log/factory.log
|
||||
+ cp -f site_tests/suite_Factory/control.full control
|
||||
+ ./bin/autotest control >> /var/log/factory.log 2>&1
|
||||
+fi
|
||||
+end script
|
||||
+
|
||||
diff -Naur old/etc/init/autotest.conf new/etc/init/autotest.conf
|
||||
--- old/etc/init/autotest.conf 1969-12-31 16:00:00.000000000 -0800
|
||||
+++ new/etc/init/autotest.conf 2010-04-05 20:59:07.000000000 -0700
|
||||
@@ -0,0 +1,15 @@
|
||||
+
|
||||
+description "Chrome OS autotest startup stub"
|
||||
+author "chromium-os-dev@googlegroups.com"
|
||||
+
|
||||
+start on started udev
|
||||
+
|
||||
+script
|
||||
+# Sleep as the current upstart sequence gives no clear completion signal.
|
||||
+# TODO: investigate generating authoritative bootup finished event.
|
||||
+sleep 10
|
||||
+cd /usr/local/autotest
|
||||
+date >> /var/log/factory.log
|
||||
+./tools/autotest >> /var/log/factory.log 2>&1
|
||||
+end script
|
||||
+
|
||||
diff -Naur old/etc/init/tty1.conf new/etc/init/tty1.conf
|
||||
--- old/etc/init/tty1.conf 1969-12-31 16:00:00.000000000 -0800
|
||||
+++ new/etc/init/tty1.conf 2010-04-05 20:59:07.000000000 -0700
|
||||
@@ -0,0 +1,9 @@
|
||||
+start on startup
|
||||
+stop on starting halt or starting reboot
|
||||
+
|
||||
+respawn
|
||||
+script
|
||||
+cd /
|
||||
+/sbin/agetty 38400 tty1 linux -l /bin/bash -n
|
||||
+end script
|
||||
+
|
||||
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
|
@ -19,7 +19,7 @@ DEFINE_string board "$DEFAULT_BOARD" "Board for which the image was built"
|
||||
DEFINE_string qualdb "/tmp/run_remote_tests.*" \
|
||||
"Location of qualified component file"
|
||||
DEFINE_string image "" "Location of the rootfs raw image file"
|
||||
DEFINE_boolean manuf $FLAGS_FALSE "Modify the image for manufacturing testing"
|
||||
DEFINE_boolean factory $FLAGS_FALSE "Modify the image for manufacturing testing"
|
||||
DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" "y"
|
||||
|
||||
# Parse command line
|
||||
@ -120,9 +120,25 @@ sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \
|
||||
"${MOD_SCRIPTS_ROOT}/test_setup.sh"
|
||||
|
||||
# Run manufacturing test setup
|
||||
if [ ${FLAGS_manuf} -eq ${FLAGS_TRUE} ]; then
|
||||
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then
|
||||
echo "Modifying image ${FLAGS_image} for manufacturing test..."
|
||||
|
||||
echo "Disabling ui.conf, don't do chrome startup on boot."
|
||||
sudo mv ${ROOT_FS_DIR}/etc/init/ui.conf \
|
||||
${ROOT_FS_DIR}/etc/init/ui.conf.disabled
|
||||
|
||||
echo "Applying patch to init scripts"
|
||||
MOD_MFG_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_factory_scripts"
|
||||
pushd ${ROOT_FS_DIR}
|
||||
sudo patch -d ${ROOT_FS_DIR} -p1 < ${MOD_MFG_ROOT}/factory.patch
|
||||
popd
|
||||
|
||||
echo "Modifying Release Description for Factory."
|
||||
FILE="${ROOT_FS_DIR}/etc/lsb-release"
|
||||
sudo sed -i 's/Test/Factory/' $FILE
|
||||
|
||||
echo "Done applying patch."
|
||||
|
||||
# Try to use the sytem component file in the most recent autotest result
|
||||
FLAGS_qualdb=$(ls -dt ${FLAGS_qualdb} 2>&-| head -1)
|
||||
|
||||
@ -142,7 +158,6 @@ if [ ${FLAGS_manuf} -eq ${FLAGS_TRUE} ]; then
|
||||
${ROOT_FS_DIR}/usr/local/manufacturing/qualified_components
|
||||
else
|
||||
echo "No qualified component file found at: ${FLAGS_qualdb}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user