From 4d8e50a4de2c1929b0383cd15fc87c8ae5b7d5e1 Mon Sep 17 00:00:00 2001 From: Ken Mixter Date: Tue, 22 Dec 2009 17:24:49 -0800 Subject: [PATCH 1/8] Create a method to push an image to a live running Chromium OS machine provided you have root ssh access with a local private key (which is the case for test builds). Updates the running instance and reboots it. Review URL: http://codereview.chromium.org/512003 --- image_to_live.sh | 204 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100755 image_to_live.sh diff --git a/image_to_live.sh b/image_to_live.sh new file mode 100755 index 0000000000..17c1514656 --- /dev/null +++ b/image_to_live.sh @@ -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&" + + 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" From 4112bcd7f90cf516c4b6a78d2bb1fff71b54ddd8 Mon Sep 17 00:00:00 2001 From: Daniel Erat Date: Tue, 22 Dec 2009 18:22:01 -0800 Subject: [PATCH 2/8] Clean up chromiumos-build build files and update .gitignore. Review URL: http://codereview.chromium.org/516004 --- make_chroot.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/make_chroot.sh b/make_chroot.sh index b7df6ca6b9..d1b0be15c0 100755 --- a/make_chroot.sh +++ b/make_chroot.sh @@ -193,7 +193,9 @@ bash_chroot "export DEBIAN_FRONTEND=noninteractive LANG=C && \ echo "Installing chromiumos-build tool..." 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 From 06c4dcf4c915c5d3ef057df008f14b9dab8b54f4 Mon Sep 17 00:00:00 2001 From: tedbo Date: Tue, 22 Dec 2009 21:20:24 -0800 Subject: [PATCH 3/8] Change install_packages.sh to run from outside of the target rootfs and install debs into the target rootfs. This will still run the maintainer scripts, but it is a step in the right direction to being able to create a cross-compiled image. This will allow us to experiment with disabling the maintainer scripts and attempt to get that working. It also makes it easier to modify the install_packages script since it now has access to shflags and the source tree properly. This CL also cleans up stuff doing in build_image.sh to bind mount the trunk into the target rootfs, set up packages for install there, etc. The next step is to experiment with disabling maintainer scripts. One possible way to do that would be to put a shim in place of dpkg so that when apt calls dpkg it install a package we call dpkg-deb with a simple unpack instead. This would allow us to continue to use the good nice features that apt provides. Review URL: http://codereview.chromium.org/517003 --- build_image.sh | 70 ++++------------------ install_packages.sh | 140 +++++++++++++++++++++++++++++--------------- 2 files changed, 107 insertions(+), 103 deletions(-) diff --git a/build_image.sh b/build_image.sh index 0e4ada5cdd..223567d746 100755 --- a/build_image.sh +++ b/build_image.sh @@ -38,11 +38,6 @@ DEFINE_string suite "$DEFAULT_IMG_SUITE" "Repository suite to base image on." DEFINE_string pkglist "$DEFAULT_PKGLIST" \ "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=$(basename "${KERNEL_DEB_PATH}" .deb | sed -e 's/linux-image-//' -e 's/_.*//') KERNEL_VERSION=${KERNEL_VERSION:-${KERNEL_DEB}} @@ -65,14 +60,7 @@ ROOT_FS_DIR="${OUTPUT_DIR}/rootfs" ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image" MBR_IMG="${OUTPUT_DIR}/mbr.image" OUTPUT_IMG="${OUTPUT_DIR}/usb.img" - -# 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}" +SETUP_DIR="${OUTPUT_DIR}/tmp" LOOP_DEV= @@ -111,7 +99,6 @@ cleanup_rootfs_mounts() { sudo umount "${ROOT_FS_DIR}/proc" sudo umount "${ROOT_FS_DIR}/sys" - sudo umount "${ROOT_FS_DIR}/trunk" } cleanup_rootfs_loop() { @@ -138,8 +125,8 @@ trap cleanup EXIT mkdir -p "$ROOT_FS_DIR" # 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 * 950)) +# 1 GB in hard-drive-manufacturer-speak is 10^9, not 2^30. 700MB < 10^9 bytes. +ROOT_SIZE_BYTES=$((1024 * 1024 * 700)) dd if=/dev/zero of="$ROOT_FS_IMG" bs=1 count=1 seek=$((ROOT_SIZE_BYTES - 1)) # Format, tune, and mount the rootfs. @@ -163,6 +150,7 @@ then fi # Bootstrap the base debian file system +# TODO: Switch to --variant=minbase sudo debootstrap --arch=i386 $FLAGS_suite "$ROOT_FS_DIR" "${FLAGS_mirror}" # -- 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 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 # built packages. mkdir -p "$SETUP_DIR" 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" -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. cd "$SETUP_DIR" dpkg-scanpackages local_packages/ /dev/null | \ gzip > local_packages/Packages.gz 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 < $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 -sudo chroot "$ROOT_FS_DIR" \ - "${ROOTFS_SETUP_DIR}/${ROOTFS_PACKAGE_INSTALL_SCRIPT}" +"${SCRIPTS_DIR}/install_packages.sh" \ + --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. -"${SCRIPTS_DIR}/${ROOTFS_CUSTOMIZE_SCRIPT}" --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" +"${SCRIPTS_DIR}/customize_rootfs.sh" --root="${ROOT_FS_DIR}" # Unmount mounts within the rootfs so it is ready to be imaged. cleanup_rootfs_mounts diff --git a/install_packages.sh b/install_packages.sh index 86bcfebea2..79917b634b 100755 --- a/install_packages.sh +++ b/install_packages.sh @@ -1,37 +1,103 @@ -#!/bin/sh +#!/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. -# 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 # 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 -# 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/ /;}'` +ROOT_FS_DIR="$FLAGS_root" +if [[ -z "$ROOT_FS_DIR" ]]; then + echo "Error: --root is required." + exit 1 +fi +if [[ ! -d "$ROOT_FS_DIR" ]]; then + echo "Error: Root FS does not exist? ($ROOT_FS_DIR)" + exit 1 +fi # Create the temporary apt source.list used to install packages. -cat < /etc/apt/sources.list -deb file:"$SETUP_DIR" local_packages/ -deb $SERVER $SUITE main restricted multiverse universe +APT_SOURCE="${ROOT_FS_DIR}/../sources.list" +cat < "$APT_SOURCE" +deb file:"$FLAGS_setup_dir" local_packages/ +deb $FLAGS_server $FLAGS_suite main restricted multiverse universe 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 < "$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 -apt-get update -apt-get --yes --force-yes install $COMPONENTS +COMPONENTS=`cat $FLAGS_package_list | grep -v ' *#' | grep -v '^ *$' | sed '/$/{N;s/\n/ /;}'` +sudo apt-get -c="$APT_CONFIG" update +sudo apt-get -c="$APT_CONFIG" --yes --force-yes install $COMPONENTS # Create kernel installation configuration to suppress warnings, # install the kernel in /boot, and manage symlinks. -cat < /etc/kernel-img.conf +cat <> /etc/apt/sources.list - apt-get update - apt-get --yes --force-yes --no-install-recommends \ - install $COMPONENTS2 -fi +# Clean up the apt cache. +# TODO: The cache was populated by debootstrap, not these installs. Remove +# this line when we can get debootstrap to stop doing this. +sudo rm -f "${ROOT_FS_DIR}"/var/cache/apt/archives/*.deb # 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" +# TODO: Replace with list_installed_packages.sh when it is fixed up. +dpkg --root="${ROOT_FS_DIR}" -l > \ + "${FLAGS_output_dir}/package_list_installed.txt" From 4f3c95b241fb33f5119768e40fc761e8f8167193 Mon Sep 17 00:00:00 2001 From: tedbo Date: Tue, 22 Dec 2009 21:23:05 -0800 Subject: [PATCH 4/8] Add a helper script to be able to run "apt-get install" without running the maintainer scripts on installed packages. I've experimented with using this in the install_packages.sh that runs from outside the targetfs. It is able to extract packages and make them appear to be installed (for the most part) without running the maintainer scripts. This will allow us to start figuring out what problems we will have when we no longer run the maintainer scripts. In the long run it would be nice to add an option to "dpkg" to skip maintainer scripts. Review URL: http://codereview.chromium.org/517004 --- dpkg_no_scripts.sh | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100755 dpkg_no_scripts.sh diff --git a/dpkg_no_scripts.sh b/dpkg_no_scripts.sh new file mode 100755 index 0000000000..fe5a817a81 --- /dev/null +++ b/dpkg_no_scripts.sh @@ -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 From 2cfa925e59b5302d4efd9421c37bbd261df062f7 Mon Sep 17 00:00:00 2001 From: tedbo Date: Tue, 22 Dec 2009 21:44:28 -0800 Subject: [PATCH 5/8] Add --no-install-recommends when we install most of our components. Given this we need to explicitly install xterm and lsof, but otherwise it is a net reduction of about 45 packages, which is nice. Review URL: http://codereview.chromium.org/515009 --- customize_rootfs.sh | 2 +- install_packages.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/customize_rootfs.sh b/customize_rootfs.sh index 554bbb659f..5f165b75f2 100755 --- a/customize_rootfs.sh +++ b/customize_rootfs.sh @@ -148,7 +148,7 @@ sudo rm -rf "$TMP_STATIC" # Fix issue where alsa-base (dependency of alsa-utils) is messing up our sound # drivers. The stock modprobe settings worked fine. # 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. sudo rm -rf "${ROOT_FS_DIR}/usr/share/fonts/X11" diff --git a/install_packages.sh b/install_packages.sh index 79917b634b..028bbc3dca 100755 --- a/install_packages.sh +++ b/install_packages.sh @@ -93,7 +93,8 @@ apt-config -c="$APT_CONFIG" dump > "${ROOT_FS_DIR}/../apt.conf.dump" # Install prod packages COMPONENTS=`cat $FLAGS_package_list | grep -v ' *#' | grep -v '^ *$' | sed '/$/{N;s/\n/ /;}'` sudo apt-get -c="$APT_CONFIG" update -sudo apt-get -c="$APT_CONFIG" --yes --force-yes install $COMPONENTS +sudo apt-get -c="$APT_CONFIG" --yes --force-yes --no-install-recommends \ + install $COMPONENTS # Create kernel installation configuration to suppress warnings, # install the kernel in /boot, and manage symlinks. From fbf8a99ab7f1b58b50c41d970c4347853004612d Mon Sep 17 00:00:00 2001 From: Yusuke Sato Date: Wed, 23 Dec 2009 23:42:12 +0900 Subject: [PATCH 6/8] Adding third_party/ibus-m17n/ to the Chromium OS build. ibus-m17n provides input method engines for many languages such as Thai. - third_party/ibus-m17n/make_pkg.sh Copied from third_party/ibus-anthy/make_pkg.sh, then slightly modified. - third_party/ibus-m17n/ibus-m17n_1.2.0.20090930-1.diff.gz Copied from the Ubuntu Karmic's ibus-m17n package just like as third_party/clutter/clutter-1.0_1.0.4-0ubuntu1.diff.gz. Review URL: http://codereview.chromium.org/502089 --- build_platform_packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_platform_packages.sh b/build_platform_packages.sh index 3ac5f7c854..854ee7b912 100755 --- a/build_platform_packages.sh +++ b/build_platform_packages.sh @@ -35,7 +35,7 @@ PLATFORM_DIRS="acpi assets fake_hal init installer login_manager \ THIRD_PARTY_DIR="$SRC_ROOT/third_party" THIRD_PARTY_PACKAGES="connman e2fsprogs/files \ gflags google-breakpad gpt gtest \ - ibus ibus-chewing ibus-anthy \ + ibus ibus-chewing ibus-anthy ibus-m17n \ ply-image slim/src synaptics \ wpa_supplicant xscreensaver/xscreensaver-5.08 \ xserver-xorg-core xserver-xorg-video-intel" From 24f6456a2c91682885bae47a264ba60eb5f533b9 Mon Sep 17 00:00:00 2001 From: Yusuke Sato Date: Thu, 24 Dec 2009 00:29:21 +0900 Subject: [PATCH 7/8] Adding third_party/ibus-hangul/ to the Chromium OS build. ibus-hangul provides an input method for Korean. - third_party/ibus-hangul/libhangul_0.0.10-1.diff.gz - third_party/ibus-hangul/libhangul_0.0.10.orig.tar.gz These files are source package of libhangul for Ubuntu Lucid (10.04 LTS) at http://packages.ubuntu.com/en/lucid/libhangul0-data. Since Karmic's libhangle (0.0.9) is too old to build ibus-hangul trunk, we'll build libhangul packages ourselves. - third_party/ibus-hangul/make_pkg.sh This script first builds and installs libhangul debian packages, then builds ibus-hangul. - third_party/ibus-hangul/ibus-hangul_1.2.0.20090617-2.diff.gz Copied from the Ubuntu Karmic's ibus-m17n package just like as third_party/clutter/clutter-1.0_1.0.4-0ubuntu1.diff.gz. - third_party/ibus-hangul/ibus-hangul_remove_python_deps.diff Patch for third_party/ibus-hangul/debian/rules which removes setup tools written in Python from the ibus-hangul debian package. Review URL: http://codereview.chromium.org/501150 --- build_platform_packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_platform_packages.sh b/build_platform_packages.sh index 854ee7b912..2e8a9e7708 100755 --- a/build_platform_packages.sh +++ b/build_platform_packages.sh @@ -35,7 +35,7 @@ PLATFORM_DIRS="acpi assets fake_hal init installer login_manager \ THIRD_PARTY_DIR="$SRC_ROOT/third_party" THIRD_PARTY_PACKAGES="connman e2fsprogs/files \ gflags google-breakpad gpt gtest \ - ibus ibus-chewing ibus-anthy ibus-m17n \ + ibus ibus-chewing ibus-anthy ibus-hangul ibus-m17n \ ply-image slim/src synaptics \ wpa_supplicant xscreensaver/xscreensaver-5.08 \ xserver-xorg-core xserver-xorg-video-intel" From 54fd4a350fe97e78482905b0c3d0282330ce1e79 Mon Sep 17 00:00:00 2001 From: Daniel Erat Date: Wed, 23 Dec 2009 12:15:23 -0800 Subject: [PATCH 8/8] Make more build scripts barf when run as root. Review URL: http://codereview.chromium.org/518004 --- build_image.sh | 2 +- build_platform_packages.sh | 2 +- build_tests.sh | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build_image.sh b/build_image.sh index 223567d746..8a926e4286 100755 --- a/build_image.sh +++ b/build_image.sh @@ -17,8 +17,8 @@ # 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 +assert_not_root_user DEFAULT_PKGLIST="${SRC_ROOT}/package_repo/package-list-prod.txt" diff --git a/build_platform_packages.sh b/build_platform_packages.sh index 2e8a9e7708..845c125fea 100755 --- a/build_platform_packages.sh +++ b/build_platform_packages.sh @@ -8,8 +8,8 @@ # 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 +assert_not_root_user # Flags DEFINE_boolean stable $FLAGS_FALSE "Build with stable version of browser." diff --git a/build_tests.sh b/build_tests.sh index f4da0a2831..a057b60e67 100755 --- a/build_tests.sh +++ b/build_tests.sh @@ -8,6 +8,9 @@ # The path to common.sh should be relative to your script's location. . "$(dirname "$0")/common.sh" +assert_inside_chroot +assert_not_root_user + # Flags # Parse command line