From f87a3678dd11a902397c3c64db1b952adefc1830 Mon Sep 17 00:00:00 2001 From: Tom Wai-Hong Tam Date: Mon, 17 May 2010 16:06:33 +0800 Subject: [PATCH] Reduce the size of factory install shim. Temporary approach to using INSTALL_MASK to suppress some non-relevant paths. It reduces the size from ~426MB to ~163MB. Eventually, will remove it and create a clean and separated ebuild for chromeos-factoryinstall. Review URL: http://codereview.chromium.org/2084001 --- build_image | 30 +++++++++++++++++++++++------- common.sh | 6 ++++++ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/build_image b/build_image index 334de6348e..272ed424d9 100755 --- a/build_image +++ b/build_image @@ -39,6 +39,9 @@ DEFINE_boolean statefuldev $FLAGS_TRUE \ "Install development packages on stateful partition rather than the rootfs" DEFINE_string to "" \ "The target image file or device" +DEFINE_boolean factory_install $FLAGS_FALSE \ + "Build a smaller image to overlay the factory install shim on; this argument \ +is also required in image_to_usb." DEFINE_string arm_extra_bootargs "" \ "Additional command line options to pass to the ARM kernel." @@ -180,7 +183,12 @@ fi # Create root file system disk image to fit on a 1GB memory stick. # 1 GB in hard-drive-manufacturer-speak is 10^9, not 2^30. 950MB < 10^9 bytes. -ROOT_SIZE_BYTES=$((1024 * 1024 * 720)) +if [[ $FLAGS_factory_install -eq ${FLAGS_TRUE} ]] ; then + ROOT_SIZE_BYTES=$((1024 * 1024 * 180)) +else + ROOT_SIZE_BYTES=$((1024 * 1024 * 720)) +fi + dd if=/dev/zero of="$ROOT_FS_IMG" bs=1 count=1 seek=$((ROOT_SIZE_BYTES - 1)) sudo losetup "$LOOP_DEV" "$ROOT_FS_IMG" sudo mkfs.ext3 "$LOOP_DEV" @@ -259,6 +267,12 @@ if [[ $FLAGS_installmask -eq ${FLAGS_TRUE} ]] ; then INSTALL_MASK="$DEFAULT_INSTALL_MASK" fi +# Reduce the size of factory install shim. +# TODO: Build a separated ebuild for the factory install shim to reduce size. +if [[ $FLAGS_factory_install -eq ${FLAGS_TRUE} ]] ; then + INSTALL_MASK="$INSTALL_MASK $FACTORY_INSTALL_MASK" +fi + if [[ $FLAGS_jobs -ne -1 ]]; then EMERGE_JOBS="--jobs=$FLAGS_jobs" fi @@ -349,8 +363,7 @@ EOF # By default, dev mode should be activated for either development builds or # test builds. -if [[ $FLAGS_withdev -eq $FLAGS_TRUE ]] ||\ - [[ $FLAGS_withtest -eq $FLAGS_TRUE ]]; then +if [[ $FLAGS_withdev -eq $FLAGS_TRUE ]] ; then sudo touch "$ROOT_FS_DIR/root/.dev_mode" # Re-run ldconfig to fix /etc/ldconfig.so.cache. @@ -363,10 +376,13 @@ fi --target="$ARCH" \ --board="$BOARD" -# Check that the image has been correctly created. -"${SCRIPTS_DIR}/test_image" \ - --root="$ROOT_FS_DIR" \ - --target="$ARCH" +# Don't test the factory install shim. +if [[ $FLAGS_factory_install -eq ${FLAGS_FALSE} ]] ; then + # Check that the image has been correctly created. + "${SCRIPTS_DIR}/test_image" \ + --root="$ROOT_FS_DIR" \ + --target="$ARCH" +fi # Clean up symlinks so they work on a running target rooted at "/". # Here development packages are rooted at /usr/local. However, do not diff --git a/common.sh b/common.sh index 9121a24f72..1023d480c7 100644 --- a/common.sh +++ b/common.sh @@ -123,6 +123,12 @@ DEFAULT_INSTALL_MASK="/usr/include /usr/man /usr/share/man /usr/share/doc \ /usr/share/pkgconfig /usr/share/gettext /usr/share/readline /etc/runlevels \ /usr/share/openrc /lib/rc *.a *.la /etc/init.d" +FACTORY_INSTALL_MASK="/opt/google/chrome /opt/google/o3d /opt/netscape \ + /usr/lib/dri /usr/lib/python2.6/test /usr/share/chewing /usr/share/fonts \ + /usr/share/ibus-pinyin /usr/share/libhangul /usr/share/locale \ + /usr/share/m17n /usr/share/mime /usr/share/sounds /usr/share/tts \ + /usr/share/X11 /usr/share/zoneinfo" + # Check to ensure not running old scripts V_REVERSE='' V_VIDOFF=''