Split out installation of packages from customize_rootfs into a separate script.

The build_image script now calls install_packages.sh followed
by customize_rootfs.sh.

The current system installs packages and performs customization
fixups from within the rootfs it is building. In order to
cross-build properly we'll need to do these steps from outside
of the root. Splitting package installation and rootfs customization
will make it easier to do this. A follow-on change will modify
customize_rootfs to run from outside of the rootfs.

Review URL: http://codereview.chromium.org/414051

git-svn-id: svn://chrome-svn/chromeos/trunk@300 06c00378-0e64-4dae-be16-12b19f9950a1
This commit is contained in:
tedbo@google.com 2009-11-20 22:15:58 +00:00
parent 5db44aa611
commit c0c8c69143
3 changed files with 93 additions and 73 deletions

View File

@ -66,6 +66,7 @@ ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image"
MBR_IMG="${OUTPUT_DIR}/mbr.image" MBR_IMG="${OUTPUT_DIR}/mbr.image"
OUTPUT_IMG="${OUTPUT_DIR}/usb.img" OUTPUT_IMG="${OUTPUT_DIR}/usb.img"
ROOTFS_PACKAGE_INSTALL_SCRIPT="install_packages.sh"
ROOTFS_CUSTOMIZE_SCRIPT="customize_rootfs.sh" ROOTFS_CUSTOMIZE_SCRIPT="customize_rootfs.sh"
ROOTFS_SETUP_DIR="/tmp/chromeos_setup" ROOTFS_SETUP_DIR="/tmp/chromeos_setup"
SETUP_DIR="${ROOT_FS_DIR}/${ROOTFS_SETUP_DIR}" SETUP_DIR="${ROOT_FS_DIR}/${ROOTFS_SETUP_DIR}"
@ -179,6 +180,7 @@ sudo mount --bind "$GCLIENT_ROOT" "$ROOT_FS_DIR/trunk"
# built packages. # built packages.
mkdir -p "$SETUP_DIR" mkdir -p "$SETUP_DIR"
mkdir -p "${SETUP_DIR}/local_packages" mkdir -p "${SETUP_DIR}/local_packages"
cp "${SCRIPTS_DIR}/${ROOTFS_PACKAGE_INSTALL_SCRIPT}" "$SETUP_DIR"
cp "${SCRIPTS_DIR}/${ROOTFS_CUSTOMIZE_SCRIPT}" "$SETUP_DIR" cp "${SCRIPTS_DIR}/${ROOTFS_CUSTOMIZE_SCRIPT}" "$SETUP_DIR"
cp "$FLAGS_pkglist" "${SETUP_DIR}/package-list-prod.txt" cp "$FLAGS_pkglist" "${SETUP_DIR}/package-list-prod.txt"
cp "${FLAGS_build_root}/x86/local_packages"/* "${SETUP_DIR}/local_packages" cp "${FLAGS_build_root}/x86/local_packages"/* "${SETUP_DIR}/local_packages"
@ -212,9 +214,16 @@ EOF
# ...and all CHROMEOS_ vars # ...and all CHROMEOS_ vars
set | grep "^CHROMEOS_" >> $CUST_OPTS set | grep "^CHROMEOS_" >> $CUST_OPTS
# Run the setup script # Run the package install script
sudo chroot "$ROOT_FS_DIR" \
"${ROOTFS_SETUP_DIR}/${ROOTFS_PACKAGE_INSTALL_SCRIPT}"
# Run the script to customize the resulting root file system.
sudo chroot "$ROOT_FS_DIR" "${ROOTFS_SETUP_DIR}/${ROOTFS_CUSTOMIZE_SCRIPT}" sudo chroot "$ROOT_FS_DIR" "${ROOTFS_SETUP_DIR}/${ROOTFS_CUSTOMIZE_SCRIPT}"
# No longer need the setup directory in the rootfs.
rm -rf "$SETUP_DIR"
# Move package lists from the image into the output dir # Move package lists from the image into the output dir
sudo mv "$ROOT_FS_DIR"/etc/package_list_*.txt "$OUTPUT_DIR" sudo mv "$ROOT_FS_DIR"/etc/package_list_*.txt "$OUTPUT_DIR"

View File

@ -4,7 +4,7 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
# Sets up the chromeos distribution from inside a chroot of the root fs. # Customizes the root file system of a chromium-based os.
# NOTE: This script should be called by build_image.sh. Do not run this # NOTE: This script should be called by build_image.sh. Do not run this
# on your own unless you know what you are doing. # on your own unless you know what you are doing.
@ -15,9 +15,6 @@ echo "Reading options..."
cat "$(dirname $0)/customize_opts.sh" cat "$(dirname $0)/customize_opts.sh"
. "$(dirname $0)/customize_opts.sh" . "$(dirname $0)/customize_opts.sh"
PACKAGE_LIST_FILE="${SETUP_DIR}/package-list-prod.txt"
PACKAGE_LIST_FILE2="${SETUP_DIR}/package-list-2.txt"
COMPONENTS=`cat $PACKAGE_LIST_FILE | grep -v ' *#' | grep -v '^ *$' | sed '/$/{N;s/\n/ /;}'`
FULLNAME="ChromeOS User" FULLNAME="ChromeOS User"
USERNAME="chronos" USERNAME="chronos"
ADMIN_GROUP="admin" ADMIN_GROUP="admin"
@ -85,33 +82,6 @@ echo "%admin ALL=(ALL) ALL" >> /etc/sudoers
useradd -G "${ADMIN_GROUP},${DEFGROUPS}" -g ${ADMIN_GROUP} -s /bin/bash -m \ useradd -G "${ADMIN_GROUP},${DEFGROUPS}" -g ${ADMIN_GROUP} -s /bin/bash -m \
-c "${FULLNAME}" -p ${CRYPTED_PASSWD} ${USERNAME} -c "${FULLNAME}" -p ${CRYPTED_PASSWD} ${USERNAME}
# Create apt source.list
cat <<EOF > /etc/apt/sources.list
deb file:"$SETUP_DIR" local_packages/
deb $SERVER $SUITE main restricted multiverse universe
EOF
# Install prod packages
apt-get update
apt-get --yes --force-yes install $COMPONENTS
# Create kernel installation configuration to suppress warnings,
# install the kernel in /boot, and manage symlinks.
cat <<EOF > /etc/kernel-img.conf
link_in_boot = yes
do_symlinks = yes
minimal_swap = yes
clobber_modules = yes
warn_reboot = no
do_bootloader = no
do_initrd = yes
warn_initrd = no
EOF
# NB: KERNEL_VERSION comes from customize_opts.sh
apt-get --yes --force-yes --no-install-recommends \
install "linux-image-${KERNEL_VERSION}"
# Set timezone symlink # Set timezone symlink
rm -f /etc/localtime rm -f /etc/localtime
ln -s /mnt/stateful_partition/etc/localtime /etc/localtime ln -s /mnt/stateful_partition/etc/localtime /etc/localtime
@ -130,47 +100,6 @@ SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{type}=="1", KERNEL=="eth*",
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0" SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"
EOF EOF
# Setup bootchart. Due to dependencies, this adds about 180MB!
apt-get --yes --force-yes --no-install-recommends install bootchart
# TODO: Replace this with pybootchartgui, or remove it entirely.
apt-get --yes --force-yes --no-install-recommends install bootchart-java
# Install additional packages from a second mirror, if necessary. This must
# be done after all packages from the first repository are installed; after
# the apt-get update, apt-get and debootstrap will prefer the newest package
# versions (which are probably on this second mirror).
if [ -f "$PACKAGE_LIST_FILE2" ]
then
COMPONENTS2=`cat $PACKAGE_LIST_FILE2 | grep -v ' *#' | grep -v '^ *$' | sed '/$/{N;s/\n/ /;}'`
echo "deb $SERVER2 $SUITE2 main restricted multiverse universe" \
>> /etc/apt/sources.list
apt-get update
apt-get --yes --force-yes --no-install-recommends \
install $COMPONENTS2
fi
# List all packages installed so far, since these are what the local
# repository needs to contain.
# TODO: better place to put the list. Must still exist after the chroot
# is dismounted, so build_image.sh can get it. That rules out /tmp and
# $SETUP_DIR (which is under /tmp).
sudo sh -c "/trunk/src/scripts/list_installed_packages.sh \
> /etc/package_list_installed.txt"
# Remove unused packages.
# TODO: How are these getting on our image, anyway?
set +e
dpkg -l | grep pulseaudio | awk '{ print $2 }' | xargs dpkg --purge
dpkg -l | grep conkeror | awk '{ print $2 }' | xargs dpkg --purge
# TODO(rspangler): fix uninstall steps which fail at tip
#dpkg -l | grep xulrunner | awk '{ print $2 }' | xargs dpkg --purge
set -e
# Clean up other useless stuff created as part of the install process.
rm -f /var/cache/apt/archives/*.deb
rm -rf "$SETUP_DIR"
# Fix issue where alsa-base (dependency of alsa-utils) is messing up our sound # Fix issue where alsa-base (dependency of alsa-utils) is messing up our sound
# drivers. The stock modprobe settings worked fine. # drivers. The stock modprobe settings worked fine.
# TODO: Revisit when we have decided on how sound will work on chromeos. # TODO: Revisit when we have decided on how sound will work on chromeos.

82
install_packages.sh Executable file
View File

@ -0,0 +1,82 @@
#!/bin/sh
# 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.
# Sets up the chromium-based os from inside a chroot of the root fs.
# NOTE: This script should be called by build_image.sh. Do not run this
# on your own unless you know what you are doing.
set -e
# Read options from the config file created by build_image.sh.
echo "Reading options..."
cat "$(dirname $0)/customize_opts.sh"
. "$(dirname $0)/customize_opts.sh"
PACKAGE_LIST_FILE="${SETUP_DIR}/package-list-prod.txt"
PACKAGE_LIST_FILE2="${SETUP_DIR}/package-list-2.txt"
COMPONENTS=`cat $PACKAGE_LIST_FILE | grep -v ' *#' | grep -v '^ *$' | sed '/$/{N;s/\n/ /;}'`
# Create the temporary apt source.list used to install packages.
cat <<EOF > /etc/apt/sources.list
deb file:"$SETUP_DIR" local_packages/
deb $SERVER $SUITE main restricted multiverse universe
EOF
# Install prod packages
apt-get update
apt-get --yes --force-yes install $COMPONENTS
# Create kernel installation configuration to suppress warnings,
# install the kernel in /boot, and manage symlinks.
cat <<EOF > /etc/kernel-img.conf
link_in_boot = yes
do_symlinks = yes
minimal_swap = yes
clobber_modules = yes
warn_reboot = no
do_bootloader = no
do_initrd = yes
warn_initrd = no
EOF
# NB: KERNEL_VERSION comes from customize_opts.sh
apt-get --yes --force-yes --no-install-recommends \
install "linux-image-${KERNEL_VERSION}"
# Setup bootchart. Due to dependencies, this adds about 180MB!
apt-get --yes --force-yes --no-install-recommends install bootchart
# TODO: Replace this with pybootchartgui, or remove it entirely.
apt-get --yes --force-yes --no-install-recommends install bootchart-java
# Install additional packages from a second mirror, if necessary. This must
# be done after all packages from the first repository are installed; after
# the apt-get update, apt-get and debootstrap will prefer the newest package
# versions (which are probably on this second mirror).
if [ -f "$PACKAGE_LIST_FILE2" ]
then
COMPONENTS2=`cat $PACKAGE_LIST_FILE2 | grep -v ' *#' | grep -v '^ *$' | sed '/$/{N;s/\n/ /;}'`
echo "deb $SERVER2 $SUITE2 main restricted multiverse universe" \
>> /etc/apt/sources.list
apt-get update
apt-get --yes --force-yes --no-install-recommends \
install $COMPONENTS2
fi
# List all packages installed so far, since these are what the local
# repository needs to contain.
# TODO: better place to put the list. Must still exist after the chroot
# is dismounted, so build_image.sh can get it. That rules out /tmp and
# $SETUP_DIR (which is under /tmp).
sudo sh -c "/trunk/src/scripts/list_installed_packages.sh \
> /etc/package_list_installed.txt"
# Clean up other useless stuff created as part of the install process.
rm -f /var/cache/apt/archives/*.deb
# List all packages still installed post-pruning
sudo sh -c "/trunk/src/scripts/list_installed_packages.sh \
> /etc/package_list_pruned.txt"