crosutils: build factory test image by emerge commands

The factory test image was created by using rsync from build artifacts
in chroot, which has some concerns:
 - Runtime dependencies of autotest-factory won't be picked into image.
 - If a developer skips build_package and builds image by using only pre-built
   binary packages, he will get nothing in factory test image.
 - It's hard for developers to figure out how and when his changes will be
   merged to next build_image (cros_workon does not really work).
 - Output image will be definitely different for every developers, also the
   official build bots.
 - If developers never wipes his chroot (setup_board), the factory test image
   will grow until out of space. (For example, my environment outputs a 825M
   image while the official buildbot generates only 563M for same ToT source).

This CL changes image build command to using portage emerge, so that output
image can be prepared faster and smaller, and easier for maintenance.

BUG=chromium-os:3335
TEST=./build_packages; ./build_image --factory  # Image starts factory UI successfully
     # Also tried tests in test_list.all, seems fine.

     time ./mod_image_for_test.sh --factory --force_copy --no_inplace
     # time: 3m2s => 1m55s, factory test image data: 825/563M => 378M

     ./build_image --factory_install # factory install shim is also fine

Change-Id: I82b4505c74cd31e718aaff4a319d50b69b2c852c
Reviewed-on: https://gerrit.chromium.org/gerrit/14473
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Richard Barnette <jrbarnette@chromium.org>
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
This commit is contained in:
Hung-Te Lin 2012-01-19 19:54:01 +08:00 committed by Gerrit
parent 08df4201a7
commit d32c59fe47
4 changed files with 50 additions and 43 deletions

View File

@ -123,7 +123,7 @@ parse_build_image_args
EXTRA_PACKAGES=""
if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then
# TODO: Build a separated ebuild for the install shim to reduce size.
INSTALL_MASK="${INSTALL_MASK} ${FACTORY_INSTALL_MASK}"
INSTALL_MASK="${FACTORY_SHIM_INSTALL_MASK}"
# Reduce the size of factory install shim.
info "Fixing the rootfs size at 320 MiB for install shim"

View File

@ -98,37 +98,6 @@ prepare_hwid_for_factory() {
fi
}
install_autotest_for_factory() {
local autotest_src="${BOARD_ROOT}/usr/local/autotest"
local stateful_root="${ROOT_FS_DIR}/usr/local"
local autotest_client="${stateful_root}/autotest"
echo "Install autotest into stateful partition from ${autotest_src}"
sudo mkdir -p "${autotest_client}"
# Remove excess files from stateful partition.
sudo rm -rf "${autotest_client}/"*
sudo rm -rf "${stateful_root}/autotest-pkgs"
sudo rm -rf "${stateful_root}/lib/icedtea6"
sudo rsync --delete --delete-excluded -au \
--exclude=deps/realtimecomm_playground \
--exclude=tests/ltp \
--exclude=site_tests/graphics_O3DSelenium \
--exclude=site_tests/realtimecomm_GTalk\* \
--exclude=site_tests/platform_StackProtector \
--exclude=deps/chrome_test \
--exclude=site_tests/desktopui_BrowserTest \
--exclude=site_tests/desktopui_PageCyclerTests \
--exclude=site_tests/desktopui_UITest \
--exclude=.svn \
"${autotest_src}/client/"* "${autotest_client}"
sudo chmod 755 "${autotest_client}"
sudo chown -R 1000:1000 "${autotest_client}"
}
# 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 () {
@ -153,9 +122,10 @@ mod_image_for_test () {
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; 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
prepare_hwid_for_factory "${BUILD_DIR}"
install_autotest_for_factory
local mod_factory_script
mod_factory_script="${SCRIPTS_DIR}/mod_for_factory_scripts/factory_setup.sh"

View File

@ -170,7 +170,7 @@ CHROOT_TRUNK_DIR="/home/$USER/trunk"
# Install make for portage ebuilds. Used by build_image and gmergefs.
# TODO: Is /usr/local/autotest-chrome still used by anyone?
DEFAULT_INSTALL_MASK="
COMMON_INSTALL_MASK="
*.a
*.la
/etc/init.d
@ -183,7 +183,6 @@ DEFAULT_INSTALL_MASK="
/usr/lib/gcc
/usr/lib/gtk-2.0/include
/usr/lib/pkgconfig
/usr/local/autotest
/usr/local/autotest-chrome
/usr/man
/usr/share/aclocal
@ -199,18 +198,38 @@ DEFAULT_INSTALL_MASK="
/usr/src
"
FACTORY_INSTALL_MASK="
/opt/Qualcomm
/opt/Synaptics
# Mask for base, dev, and test images (build_image, build_image --test)
DEFAULT_INSTALL_MASK="
$COMMON_INSTALL_MASK
/usr/local/autotest
"
# Mask for factory test image (build_image --factory)
FACTORY_TEST_INSTALL_MASK="
$COMMON_INSTALL_MASK
*/.svn
*/CVS
/usr/local/autotest/[^c]*
/usr/local/autotest/conmux
/usr/local/autotest/client/deps/chrome_test
/usr/local/autotest/client/deps/piglit
/usr/local/autotest/client/deps/pyauto_dep
/usr/local/autotest/client/deps/realtimecomm_*
/usr/local/autotest/client/site_tests/desktopui_PageCyclerTests
/usr/local/autotest/client/site_tests/graphics_WebGLConformance
/usr/local/autotest/client/site_tests/platform_ToolchainOptions
/usr/local/autotest/client/site_tests/realtimecomm_GTalk*
"
# Mask for factory install shim (build_image --factory_install)
FACTORY_SHIM_INSTALL_MASK="
$DEFAULT_INSTALL_MASK
/opt/[^g]*
/opt/google/chrome
/opt/google/o3d
/opt/google/talkplugin
/opt/netscape
/usr/lib/debug
/usr/lib/dri
/usr/lib/python2.6/test
/usr/local/autotest
/usr/local/autotest-chrome
/usr/local/autotest-pkgs
/usr/share/X11
/usr/share/chewing

View File

@ -0,0 +1,18 @@
#!/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.
die() {
echo "ERROR: $*"
exit 1
}
echo "Rebasing autotest/client folder for factory."
base_dir="${ROOT_FS_DIR}/usr/local/autotest"
[ -d "${base_dir}/client" ] || die "Missing client in root: ${base_dir}"
mv "${base_dir}/client/"* "${base_dir}" || die "Failed moving client folder."
rmdir "${base_dir}/client" || die "Failed removing client folder."
ln -s . "${base_dir}/client" || die "Failed creating symlink."