Merge branch 'master' of ssh://chromiumos-git/chromeos

This commit is contained in:
David McMahon 2009-12-23 12:34:45 -08:00
commit f8b5b4bdf2
8 changed files with 405 additions and 108 deletions

View File

@ -17,8 +17,8 @@
# The path to common.sh should be relative to your script's location. # The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh" . "$(dirname "$0")/common.sh"
# Script must be run inside the chroot
assert_inside_chroot assert_inside_chroot
assert_not_root_user
DEFAULT_PKGLIST="${SRC_ROOT}/package_repo/package-list-prod.txt" DEFAULT_PKGLIST="${SRC_ROOT}/package_repo/package-list-prod.txt"
@ -38,11 +38,6 @@ DEFINE_string suite "$DEFAULT_IMG_SUITE" "Repository suite to base image on."
DEFINE_string pkglist "$DEFAULT_PKGLIST" \ DEFINE_string pkglist "$DEFAULT_PKGLIST" \
"Name of file listing packages to install from repository." "Name of file listing packages to install from repository."
DEFINE_string mirror2 "$DEFAULT_EXT_MIRROR" "Additional mirror to use."
DEFINE_string suite2 "$DEFAULT_EXT_SUITE" "Suite to use in additional mirror."
DEFINE_string pkglist2 "" \
"Name of file listing packages to install from additional mirror."
KERNEL_DEB_PATH=$(find "${FLAGS_build_root}/x86/local_packages" -name "linux-image-*.deb") KERNEL_DEB_PATH=$(find "${FLAGS_build_root}/x86/local_packages" -name "linux-image-*.deb")
KERNEL_DEB=$(basename "${KERNEL_DEB_PATH}" .deb | sed -e 's/linux-image-//' -e 's/_.*//') KERNEL_DEB=$(basename "${KERNEL_DEB_PATH}" .deb | sed -e 's/linux-image-//' -e 's/_.*//')
KERNEL_VERSION=${KERNEL_VERSION:-${KERNEL_DEB}} KERNEL_VERSION=${KERNEL_VERSION:-${KERNEL_DEB}}
@ -65,14 +60,7 @@ ROOT_FS_DIR="${OUTPUT_DIR}/rootfs"
ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image" 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"
SETUP_DIR="${OUTPUT_DIR}/tmp"
# These paths are relative to SCRIPTS_DIR.
ROOTFS_PACKAGE_INSTALL_SCRIPT="install_packages.sh"
ROOTFS_CUSTOMIZE_SCRIPT="customize_rootfs.sh"
ROOTFS_STATIC_DATA="${SRC_ROOT}/rootfs_static_data"
ROOTFS_SETUP_DIR="/tmp/chromeos_setup"
SETUP_DIR="${ROOT_FS_DIR}/${ROOTFS_SETUP_DIR}"
LOOP_DEV= LOOP_DEV=
@ -111,7 +99,6 @@ cleanup_rootfs_mounts() {
sudo umount "${ROOT_FS_DIR}/proc" sudo umount "${ROOT_FS_DIR}/proc"
sudo umount "${ROOT_FS_DIR}/sys" sudo umount "${ROOT_FS_DIR}/sys"
sudo umount "${ROOT_FS_DIR}/trunk"
} }
cleanup_rootfs_loop() { cleanup_rootfs_loop() {
@ -138,8 +125,8 @@ trap cleanup EXIT
mkdir -p "$ROOT_FS_DIR" mkdir -p "$ROOT_FS_DIR"
# Create root file system disk image to fit on a 1GB memory stick. # 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. # 1 GB in hard-drive-manufacturer-speak is 10^9, not 2^30. 700MB < 10^9 bytes.
ROOT_SIZE_BYTES=$((1024 * 1024 * 950)) ROOT_SIZE_BYTES=$((1024 * 1024 * 700))
dd if=/dev/zero of="$ROOT_FS_IMG" bs=1 count=1 seek=$((ROOT_SIZE_BYTES - 1)) dd if=/dev/zero of="$ROOT_FS_IMG" bs=1 count=1 seek=$((ROOT_SIZE_BYTES - 1))
# Format, tune, and mount the rootfs. # Format, tune, and mount the rootfs.
@ -163,6 +150,7 @@ then
fi fi
# Bootstrap the base debian file system # Bootstrap the base debian file system
# TODO: Switch to --variant=minbase
sudo debootstrap --arch=i386 $FLAGS_suite "$ROOT_FS_DIR" "${FLAGS_mirror}" sudo debootstrap --arch=i386 $FLAGS_suite "$ROOT_FS_DIR" "${FLAGS_mirror}"
# -- Customize the root file system -- # -- Customize the root file system --
@ -174,62 +162,30 @@ sudo mount -t proc proc "${ROOT_FS_DIR}/proc"
sudo mount -t sysfs sysfs "${ROOT_FS_DIR}/sys" # TODO: Do we need sysfs? sudo mount -t sysfs sysfs "${ROOT_FS_DIR}/sys" # TODO: Do we need sysfs?
sudo cp /etc/hosts "${ROOT_FS_DIR}/etc" sudo cp /etc/hosts "${ROOT_FS_DIR}/etc"
# Set up bind mount for trunk, so we can get to package repository
# TODO: also use this instead of SETUP_DIR for other things below?
sudo mkdir -p "$ROOT_FS_DIR/trunk"
sudo mount --bind "$GCLIENT_ROOT" "$ROOT_FS_DIR/trunk"
# Create setup directory and copy over scripts, config files, and locally # Create setup directory and copy over scripts, config files, and locally
# 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 -r "$ROOTFS_STATIC_DATA" "$SETUP_DIR"
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"
if [ -n "$FLAGS_pkglist2" ]
then
cp "$FLAGS_pkglist2" "${SETUP_DIR}/package-list-2.txt"
fi
# Set up repository for local packages to install in the rootfs via apt-get. # Set up repository for local packages to install in the rootfs via apt-get.
cd "$SETUP_DIR" cd "$SETUP_DIR"
dpkg-scanpackages local_packages/ /dev/null | \ dpkg-scanpackages local_packages/ /dev/null | \
gzip > local_packages/Packages.gz gzip > local_packages/Packages.gz
cd - cd -
# File-type mirrors have a different path when bind-mounted inside the chroot
# ${FOO/bar/baz} replaces bar with baz when evaluating $FOO.
MIRROR_INSIDE="${FLAGS_mirror/$GCLIENT_ROOT//trunk}"
MIRROR2_INSIDE="${FLAGS_mirror2/$GCLIENT_ROOT//trunk}"
# Write options for customize script into the chroot
CUST_OPTS="${SETUP_DIR}/customize_opts.sh"
cat <<EOF > $CUST_OPTS
REAL_USER=$USER
SETUP_DIR="$ROOTFS_SETUP_DIR"
KERNEL_VERSION="$KERNEL_VERSION"
SERVER="$MIRROR_INSIDE"
SUITE="$FLAGS_suite"
SERVER2="$MIRROR2_INSIDE"
SUITE2="$FLAGS_suite2"
EOF
# ...and all CHROMEOS_ vars
set | egrep "^CHROMEOS_|^BUILDBOT_" >> $CUST_OPTS
# Run the package install script # Run the package install script
sudo chroot "$ROOT_FS_DIR" \ "${SCRIPTS_DIR}/install_packages.sh" \
"${ROOTFS_SETUP_DIR}/${ROOTFS_PACKAGE_INSTALL_SCRIPT}" --root="$ROOT_FS_DIR" \
--output_dir="${OUTPUT_DIR}" \
--setup_dir="${SETUP_DIR}" \
--package_list="$FLAGS_pkglist" \
--server="$FLAGS_mirror" \
--suite="$FLAGS_suite" \
--kernel_version="$KERNEL_VERSION"
# Run the script to customize the resulting root file system. # Run the script to customize the resulting root file system.
"${SCRIPTS_DIR}/${ROOTFS_CUSTOMIZE_SCRIPT}" --root="${ROOT_FS_DIR}" "${SCRIPTS_DIR}/customize_rootfs.sh" --root="${ROOT_FS_DIR}"
# No longer need the setup directory in the rootfs.
rm -rf "$SETUP_DIR"
# Move package lists from the image into the output dir
sudo mv "$ROOT_FS_DIR"/etc/package_list_*.txt "$OUTPUT_DIR"
# Unmount mounts within the rootfs so it is ready to be imaged. # Unmount mounts within the rootfs so it is ready to be imaged.
cleanup_rootfs_mounts cleanup_rootfs_mounts

View File

@ -8,8 +8,8 @@
# The path to common.sh should be relative to your script's location. # The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh" . "$(dirname "$0")/common.sh"
# Script must be run inside the chroot
assert_inside_chroot assert_inside_chroot
assert_not_root_user
# Flags # Flags
DEFINE_boolean stable $FLAGS_FALSE "Build with stable version of browser." DEFINE_boolean stable $FLAGS_FALSE "Build with stable version of browser."
@ -35,7 +35,7 @@ PLATFORM_DIRS="acpi assets fake_hal init installer login_manager \
THIRD_PARTY_DIR="$SRC_ROOT/third_party" THIRD_PARTY_DIR="$SRC_ROOT/third_party"
THIRD_PARTY_PACKAGES="connman e2fsprogs/files \ THIRD_PARTY_PACKAGES="connman e2fsprogs/files \
gflags google-breakpad gpt gtest \ gflags google-breakpad gpt gtest \
ibus ibus-chewing ibus-anthy \ ibus ibus-chewing ibus-anthy ibus-hangul ibus-m17n \
ply-image slim/src synaptics \ ply-image slim/src synaptics \
wpa_supplicant xscreensaver/xscreensaver-5.08 \ wpa_supplicant xscreensaver/xscreensaver-5.08 \
xserver-xorg-core xserver-xorg-video-intel" xserver-xorg-core xserver-xorg-video-intel"

View File

@ -8,6 +8,9 @@
# The path to common.sh should be relative to your script's location. # The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/common.sh" . "$(dirname "$0")/common.sh"
assert_inside_chroot
assert_not_root_user
# Flags # Flags
# Parse command line # Parse command line

View File

@ -148,7 +148,7 @@ sudo rm -rf "$TMP_STATIC"
# 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.
sudo rm "${ROOT_FS_DIR}/etc/modprobe.d/alsa-base.conf" ! sudo rm "${ROOT_FS_DIR}/etc/modprobe.d/alsa-base.conf"
# Remove unneeded fonts. # Remove unneeded fonts.
sudo rm -rf "${ROOT_FS_DIR}/usr/share/fonts/X11" sudo rm -rf "${ROOT_FS_DIR}/usr/share/fonts/X11"

83
dpkg_no_scripts.sh Executable file
View File

@ -0,0 +1,83 @@
#!/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.
# This script can be used to replace the "dpkg" binary as far as the
# "apt-get install" command is concerned. When "apt-get install foo"
# runs it will make two calls to dpkg like:
# dpkg --status-fd ## --unpack --auto-deconfigure /path/to/foo.deb
# dpkg --status-fd ## --configure foo
# This script will extract the .deb file and make it appear to be installed
# successfully. It will skip the maintainer scripts and configure steps.
#
# As a one-off test, you can run like:
# apt-get -o="Dir::Bin::dpkg=/path/to/this" install foo
# 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"
# Flags
DEFINE_string root "" \
"The target rootfs directory in which to install packages."
DEFINE_string status_fd "" \
"The file descriptor to report status on; ignored."
DEFINE_boolean unpack $FLAGS_FALSE "Is the action 'unpack'?"
DEFINE_boolean configure $FLAGS_FALSE "Is the action 'configure'?"
DEFINE_boolean auto_deconfigure $FLAGS_FALSE "Ignored"
# Fix up the command line and parse with shflags.
FIXED_FLAGS="$@"
FIXED_FLAGS=${FIXED_FLAGS/status-fd/status_fd}
FIXED_FLAGS=${FIXED_FLAGS/auto-deconfigure/auto_deconfigure}
FLAGS $FIXED_FLAGS || exit 1
eval set -- "${FLAGS_ARGV}"
# Die on any errors.
set -e
if [ $FLAGS_configure -eq $FLAGS_TRUE ]; then
# We ignore configure requests.
exit 0
fi
if [ $FLAGS_unpack -ne $FLAGS_TRUE ]; then
# Ignore unknown command line.
echo "Unexpected command line: $@"
exit 0
fi
if [ -z "$FLAGS_root" ]; then
echo "Missing root directory."
exit 0
fi
DPKG_STATUS=""
if [ -d "$FLAGS_root/var/lib/dpkg" ]; then
DPKG_STATUS="$FLAGS_root/var/lib/dpkg/status"
DPKG_INFO="$FLAGS_root/var/lib/dpkg/info/"
fi
for p in "$@"; do
echo "Extracting $p"
dpkg-deb --extract "$p" "$FLAGS_root"
if [ -n "$DPKG_STATUS" ]; then
TMPDIR=$(mktemp -d)
dpkg-deb --control "$p" "$TMPDIR"
# Copy the info files
PACKAGE=$(dpkg-deb --field "$p" Package)
FILES=$(ls "$TMPDIR" | grep -v control)
for f in $FILES; do
cp "${TMPDIR}/$f" "${DPKG_INFO}/$PACKAGE.$f"
done
# Mark the package as installed successfully.
echo "Status: install ok installed" >> "$DPKG_STATUS"
cat "${TMPDIR}/control" >> "$DPKG_STATUS"
echo "" >> "$DPKG_STATUS"
rm -rf "$TMPDIR"
fi
done

204
image_to_live.sh Executable file
View File

@ -0,0 +1,204 @@
#!/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 convert the output of build_image.sh to a usb image.
# 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"
assert_outside_chroot
cd $(dirname "$0")
DEFAULT_PRIVATE_KEY="$SRC_ROOT/platform/testing/testing_rsa"
DEFINE_string ip "" "IP address of running Chromium OS instance"
DEFINE_boolean ignore_version $FLAGS_TRUE \
"Ignore existing version on running instance and always update"
DEFINE_boolean ignore_hostname $FLAGS_TRUE \
"Ignore existing AU hostname on running instance use this hostname"
DEFINE_string private_key "$DEFAULT_PRIVATE_KEY" \
"Private key of root account on instance"
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
set -e
if [ -z "$FLAGS_ip" ]; then
echo "Please specify the IP of the Chromium OS instance"
exit 1
fi
TMP=$(mktemp -d /tmp/image_to_live.XXXX)
TMP_PRIVATE_KEY=$TMP/private_key
TMP_KNOWN_HOSTS=$TMP/known_hosts
function kill_all_devservers {
! pkill -f 'python devserver.py'
}
function cleanup {
kill_all_devservers
rm -rf $TMP
}
trap cleanup EXIT
function remote_sh {
# Disable strict host checking so that we don't prompt the user when
# the host key file is removed and just go ahead and add it.
REMOTE_OUT=$(ssh -o StrictHostKeyChecking=no -o \
UserKnownHostsFile=$TMP_KNOWN_HOSTS root@$FLAGS_ip "$@")
return ${PIPESTATUS[0]}
}
function remote_reboot_sh {
rm -f $TMP_KNOWN_HOSTS
remote_sh "$@"
}
function set_up_remote_access {
if [ -z "$SSH_AGENT_PID" ]; then
eval `ssh-agent`
fi
cp $FLAGS_private_key $TMP_PRIVATE_KEY
chmod 0400 $TMP_PRIVATE_KEY
ssh-add $TMP_PRIVATE_KEY
# Verify the client is reachable before continuing
remote_sh "true"
}
function start_dev_server {
kill_all_devservers
sudo -v
./enter_chroot.sh "cd ../platform/dev; ./start-devserver.sh>/dev/null 2>&1" &
echo -n "Waiting on devserver to start"
until netstat -anp 2>&1 | grep 8080 > /dev/null; do
sleep .5
echo -n "."
done
echo ""
}
function prepare_update_metadata {
remote_sh "mount -norw,remount /"
if [ $FLAGS_ignore_version -eq $FLAGS_TRUE ]; then
echo "Forcing update independent of the current version"
remote_sh "cat /etc/lsb-release |\
grep -v CHROMEOS_RELEASE_VERSION > /etc/lsb-release~;\
mv /etc/lsb-release~ /etc/lsb-release; \
echo 'CHROMEOS_RELEASE_VERSION=0.0.0.0' >> /etc/lsb-release"
fi
if [ $FLAGS_ignore_hostname -eq $FLAGS_TRUE ]; then
echo "Forcing update from $HOSTNAME"
remote_sh "cat /etc/lsb-release |\
grep -v '^CHROMEOS_AUSERVER=' |\
grep -v '^CHROMEOS_DEVSERVER=' > /etc/lsb-release~;\
mv /etc/lsb-release~ /etc/lsb-release; \
echo 'CHROMEOS_AUSERVER=http://$HOSTNAME:8080/update' >> \
/etc/lsb-release; \
echo 'CHROMEOS_DEVSERVER=http://$HOSTNAME:8080' >> /etc/lsb-release"
fi
remote_sh "mount -noro,remount /"
}
function run_auto_update {
echo "Starting update and clear away prior"
UPDATE_FILE=/var/log/softwareupdate.log
# Clear it out so we don't see a prior run and make sure it
# exists so the first tail below can't fail if it races the
# memento updater first write and wins.
remote_sh "rm -f $UPDATE_FILE; touch $UPDATE_FILE; \
/opt/google/memento_updater/memento_updater.sh</dev/null>&/dev/null&"
local update_error
local output_file
local progress
update_error=1
output_file=$TMP/output
while true; do
# The softwareupdate.log gets pretty bit with download progress
# lines so only look in the last 100 lines for status.
remote_sh "tail -100 $UPDATE_FILE"
echo "$REMOTE_OUT" > $output_file
progress=$(tail -4 $output_file | grep 0K | head -1)
if [ -n "$progress" ]; then
echo "Image fetching progress: $progress"
fi
if grep -q 'updatecheck status="noupdate"' $output_file; then
echo "devserver is claiming there is no update available."
echo "Consider setting --ignore_version."
break
fi
if grep -q 'Autoupdate applied. You should now reboot' $output_file; then
echo "Autoupdate was successful."
update_error=0
fi
if grep -q 'Memento AutoUpdate terminating' $output_file; then
break
fi
# Sleep for a while so that ssh handling doesn't slow down the install
sleep 2
done
return $update_error
}
function remote_reboot {
echo "Rebooting."
remote_sh "touch /tmp/awaiting_reboot; reboot"
local output_file
output_file=$TMP/output
while true; do
REMOTE_OUT=""
# This may fail while the machine is done so generate output and a
# boolean result to distinguish between down/timeout and real failure
! remote_reboot_sh "echo 0; [ -e /tmp/awaiting_reboot ] && echo '1'; true"
echo "$REMOTE_OUT" > $output_file
if grep -q "0" $output_file; then
if grep -q "1" $output_file; then
echo "Not yet rebooted"
else
echo "Rebooted and responding"
break
fi
fi
sleep .5
done
}
set_up_remote_access
if remote_sh [ -e /tmp/memento_autoupdate_completed ]; then
echo "Machine has been updated but not yet rebooted. Rebooting it now."
echo "Rerun this script if you still wish to update it."
remote_reboot
exit 1
fi
start_dev_server
prepare_update_metadata
if ! run_auto_update; then
echo "Update was not successful."
exit
fi
remote_reboot
remote_sh "grep ^CHROMEOS_RELEASE_DESCRIPTION= /etc/lsb-release"
RELEASE_DESCRIPTION=$(echo $REMOTE_OUT | cut -d '=' -f 2)
echo "Update was successful and rebooted to $RELEASE_DESCRIPTION"

View File

@ -1,37 +1,104 @@
#!/bin/sh #!/bin/bash
# Copyright (c) 2009 The Chromium OS Authors. All rights reserved. # 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 # 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 chromium-based os from inside a chroot of the root fs. # Script to install packages into the target root file system.
#
# 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.
# 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"
# Script must be run inside the chroot
assert_inside_chroot
# Flags
DEFINE_string target "x86" \
"The target architecture to build for. One of { x86, arm }."
DEFINE_string root "" \
"The root file system to install packages in."
DEFINE_string output_dir "" \
"The location of the output directory to use."
DEFINE_string package_list "" \
"The package list file to use."
DEFINE_string setup_dir "/tmp" \
"The staging directory to use."
DEFINE_string server "" \
"The package server to use."
DEFINE_string suite "" \
"The package suite to use."
DEFINE_string kernel_version "" \
"The kernel version to use."
# Parse command line
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
# Die on any errors.
set -e set -e
# Read options from the config file created by build_image.sh. ROOT_FS_DIR="$FLAGS_root"
echo "Reading options..." if [[ -z "$ROOT_FS_DIR" ]]; then
cat "$(dirname $0)/customize_opts.sh" echo "Error: --root is required."
. "$(dirname $0)/customize_opts.sh" exit 1
fi
PACKAGE_LIST_FILE="${SETUP_DIR}/package-list-prod.txt" if [[ ! -d "$ROOT_FS_DIR" ]]; then
PACKAGE_LIST_FILE2="${SETUP_DIR}/package-list-2.txt" echo "Error: Root FS does not exist? ($ROOT_FS_DIR)"
COMPONENTS=`cat $PACKAGE_LIST_FILE | grep -v ' *#' | grep -v '^ *$' | sed '/$/{N;s/\n/ /;}'` exit 1
fi
# Create the temporary apt source.list used to install packages. # Create the temporary apt source.list used to install packages.
cat <<EOF > /etc/apt/sources.list APT_SOURCE="${ROOT_FS_DIR}/../sources.list"
deb file:"$SETUP_DIR" local_packages/ cat <<EOF > "$APT_SOURCE"
deb $SERVER $SUITE main restricted multiverse universe deb file:"$FLAGS_setup_dir" local_packages/
deb $FLAGS_server $FLAGS_suite main restricted multiverse universe
EOF EOF
# Cache directory for APT to use.
APT_CACHE_DIR="${FLAGS_output_dir}/tmp/cache/"
mkdir -p "${APT_CACHE_DIR}/archives/partial"
# Create the apt configuration file. See "man apt.conf"
APT_CONFIG="${ROOT_FS_DIR}/../apt.conf"
cat <<EOF > "$APT_CONFIG"
Dir
{
Cache "$APT_CACHE_DIR"; # TODO: Empty string to disable?
Cache {
archives "${APT_CACHE_DIR}/archives"; # TODO: Why do we need this?
};
Etc
{
sourcelist "$APT_SOURCE"
};
State "${ROOT_FS_DIR}/var/lib/apt/";
State
{
status "${ROOT_FS_DIR}/var/lib/dpkg/status";
};
};
DPkg
{
options {"--root=${ROOT_FS_DIR}";};
};
EOF
# TODO: Full audit of the apt conf dump to make sure things are ok.
apt-config -c="$APT_CONFIG" dump > "${ROOT_FS_DIR}/../apt.conf.dump"
# Install prod packages # Install prod packages
apt-get update COMPONENTS=`cat $FLAGS_package_list | grep -v ' *#' | grep -v '^ *$' | sed '/$/{N;s/\n/ /;}'`
apt-get --yes --force-yes install $COMPONENTS sudo apt-get -c="$APT_CONFIG" update
sudo apt-get -c="$APT_CONFIG" --yes --force-yes --no-install-recommends \
install $COMPONENTS
# Create kernel installation configuration to suppress warnings, # Create kernel installation configuration to suppress warnings,
# install the kernel in /boot, and manage symlinks. # install the kernel in /boot, and manage symlinks.
cat <<EOF > /etc/kernel-img.conf cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/kernel-img.conf"
link_in_boot = yes link_in_boot = yes
do_symlinks = yes do_symlinks = yes
minimal_swap = yes minimal_swap = yes
@ -42,41 +109,23 @@ do_initrd = yes
warn_initrd = no warn_initrd = no
EOF EOF
# NB: KERNEL_VERSION comes from customize_opts.sh # Install the kernel.
apt-get --yes --force-yes --no-install-recommends \ sudo apt-get -c="$APT_CONFIG" --yes --force-yes --no-install-recommends \
install "linux-image-${KERNEL_VERSION}" install "linux-image-${FLAGS_kernel_version}"
# Setup bootchart. # Setup bootchart.
# TODO: Move this and other developer oriented "components" into an optional # TODO: Move this and other developer oriented "components" into an optional
# package-list-prod-dev.txt (ideally with a better name). # package-list-prod-dev.txt (ideally with a better name).
apt-get --yes --force-yes --no-install-recommends install bootchart sudo apt-get -c="$APT_CONFIG" --yes --force-yes --no-install-recommends \
install bootchart
# Install additional packages from a second mirror, if necessary. This must # Clean up the apt cache.
# be done after all packages from the first repository are installed; after # TODO: The cache was populated by debootstrap, not these installs. Remove
# the apt-get update, apt-get and debootstrap will prefer the newest package # this line when we can get debootstrap to stop doing this.
# versions (which are probably on this second mirror). sudo rm -f "${ROOT_FS_DIR}"/var/cache/apt/archives/*.deb
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 # List all packages installed so far, since these are what the local
# repository needs to contain. # repository needs to contain.
# TODO: better place to put the list. Must still exist after the chroot # TODO: Replace with list_installed_packages.sh when it is fixed up.
# is dismounted, so build_image.sh can get it. That rules out /tmp and dpkg --root="${ROOT_FS_DIR}" -l > \
# $SETUP_DIR (which is under /tmp). "${FLAGS_output_dir}/package_list_installed.txt"
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"

View File

@ -193,7 +193,9 @@ bash_chroot "export DEBIAN_FRONTEND=noninteractive LANG=C && \
echo "Installing chromiumos-build tool..." echo "Installing chromiumos-build tool..."
bash_chroot "cd $CHROOT_TRUNK_DIR/tools/chromiumos-build && \ bash_chroot "cd $CHROOT_TRUNK_DIR/tools/chromiumos-build && \
debuild -us -uc && sudo dpkg -i ../*.deb" debuild -us -uc && \
sudo dpkg -i ../chromiumos-build_*.deb && \
rm ../chromiumos-build_*.{dsc,tar.gz,deb,build,changes}"
# Clean up the chroot mounts # Clean up the chroot mounts