| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # Script to build a bootable keyfob-based chromeos system image. | 7 # Script to build a bootable keyfob-based chromeos system image. |
| 8 # It uses debootstrap (see https://wiki.ubuntu.com/DebootstrapChroot) to | 8 # It uses debootstrap (see https://wiki.ubuntu.com/DebootstrapChroot) to |
| 9 # create a base file system. It then cusotmizes the file system and adds | 9 # create a base file system. It then cusotmizes the file system and adds |
| 10 # Ubuntu and chromeos specific packages. Finally, it creates a bootable USB | 10 # Ubuntu and chromeos specific packages. Finally, it creates a bootable USB |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 # Use canonical path since some tools (e.g. mount) do not like symlinks | 60 # Use canonical path since some tools (e.g. mount) do not like symlinks |
| 61 # Append build attempt to output directory | 61 # Append build attempt to output directory |
| 62 IMAGE_SUBDIR="${CHROMEOS_VERSION_STRING}-a${FLAGS_build_attempt}" | 62 IMAGE_SUBDIR="${CHROMEOS_VERSION_STRING}-a${FLAGS_build_attempt}" |
| 63 OUTPUT_DIR="${FLAGS_output_root}/${IMAGE_SUBDIR}" | 63 OUTPUT_DIR="${FLAGS_output_root}/${IMAGE_SUBDIR}" |
| 64 ROOT_FS_DIR="${OUTPUT_DIR}/rootfs" | 64 ROOT_FS_DIR="${OUTPUT_DIR}/rootfs" |
| 65 ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image" | 65 ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image" |
| 66 MBR_IMG="${OUTPUT_DIR}/mbr.image" | 66 MBR_IMG="${OUTPUT_DIR}/mbr.image" |
| 67 OUTPUT_IMG="${OUTPUT_DIR}/usb.img" | 67 OUTPUT_IMG="${OUTPUT_DIR}/usb.img" |
| 68 | 68 |
| 69 ROOTFS_PACKAGE_INSTALL_SCRIPT="install_packages.sh" |
| 69 ROOTFS_CUSTOMIZE_SCRIPT="customize_rootfs.sh" | 70 ROOTFS_CUSTOMIZE_SCRIPT="customize_rootfs.sh" |
| 70 ROOTFS_SETUP_DIR="/tmp/chromeos_setup" | 71 ROOTFS_SETUP_DIR="/tmp/chromeos_setup" |
| 71 SETUP_DIR="${ROOT_FS_DIR}/${ROOTFS_SETUP_DIR}" | 72 SETUP_DIR="${ROOT_FS_DIR}/${ROOTFS_SETUP_DIR}" |
| 72 | 73 |
| 73 LOOP_DEV= | 74 LOOP_DEV= |
| 74 | 75 |
| 75 # Handle existing directory | 76 # Handle existing directory |
| 76 if [ -e "$OUTPUT_DIR" ] | 77 if [ -e "$OUTPUT_DIR" ] |
| 77 then | 78 then |
| 78 if [ $FLAGS_replace -eq $FLAGS_TRUE ] | 79 if [ $FLAGS_replace -eq $FLAGS_TRUE ] |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 173 |
| 173 # Set up bind mount for trunk, so we can get to package repository | 174 # Set up bind mount for trunk, so we can get to package repository |
| 174 # TODO: also use this instead of SETUP_DIR for other things below? | 175 # TODO: also use this instead of SETUP_DIR for other things below? |
| 175 sudo mkdir -p "$ROOT_FS_DIR/trunk" | 176 sudo mkdir -p "$ROOT_FS_DIR/trunk" |
| 176 sudo mount --bind "$GCLIENT_ROOT" "$ROOT_FS_DIR/trunk" | 177 sudo mount --bind "$GCLIENT_ROOT" "$ROOT_FS_DIR/trunk" |
| 177 | 178 |
| 178 # Create setup directory and copy over scripts, config files, and locally | 179 # Create setup directory and copy over scripts, config files, and locally |
| 179 # built packages. | 180 # built packages. |
| 180 mkdir -p "$SETUP_DIR" | 181 mkdir -p "$SETUP_DIR" |
| 181 mkdir -p "${SETUP_DIR}/local_packages" | 182 mkdir -p "${SETUP_DIR}/local_packages" |
| 183 cp "${SCRIPTS_DIR}/${ROOTFS_PACKAGE_INSTALL_SCRIPT}" "$SETUP_DIR" |
| 182 cp "${SCRIPTS_DIR}/${ROOTFS_CUSTOMIZE_SCRIPT}" "$SETUP_DIR" | 184 cp "${SCRIPTS_DIR}/${ROOTFS_CUSTOMIZE_SCRIPT}" "$SETUP_DIR" |
| 183 cp "$FLAGS_pkglist" "${SETUP_DIR}/package-list-prod.txt" | 185 cp "$FLAGS_pkglist" "${SETUP_DIR}/package-list-prod.txt" |
| 184 cp "${FLAGS_build_root}/x86/local_packages"/* "${SETUP_DIR}/local_packages" | 186 cp "${FLAGS_build_root}/x86/local_packages"/* "${SETUP_DIR}/local_packages" |
| 185 | 187 |
| 186 if [ -n "$FLAGS_pkglist2" ] | 188 if [ -n "$FLAGS_pkglist2" ] |
| 187 then | 189 then |
| 188 cp "$FLAGS_pkglist2" "${SETUP_DIR}/package-list-2.txt" | 190 cp "$FLAGS_pkglist2" "${SETUP_DIR}/package-list-2.txt" |
| 189 fi | 191 fi |
| 190 | 192 |
| 191 # Set up repository for local packages to install in the rootfs via apt-get. | 193 # Set up repository for local packages to install in the rootfs via apt-get. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 205 SETUP_DIR="$ROOTFS_SETUP_DIR" | 207 SETUP_DIR="$ROOTFS_SETUP_DIR" |
| 206 KERNEL_VERSION="$KERNEL_VERSION" | 208 KERNEL_VERSION="$KERNEL_VERSION" |
| 207 SERVER="$MIRROR_INSIDE" | 209 SERVER="$MIRROR_INSIDE" |
| 208 SUITE="$FLAGS_suite" | 210 SUITE="$FLAGS_suite" |
| 209 SERVER2="$MIRROR2_INSIDE" | 211 SERVER2="$MIRROR2_INSIDE" |
| 210 SUITE2="$FLAGS_suite2" | 212 SUITE2="$FLAGS_suite2" |
| 211 EOF | 213 EOF |
| 212 # ...and all CHROMEOS_ vars | 214 # ...and all CHROMEOS_ vars |
| 213 set | grep "^CHROMEOS_" >> $CUST_OPTS | 215 set | grep "^CHROMEOS_" >> $CUST_OPTS |
| 214 | 216 |
| 215 # Run the setup script | 217 # Run the package install script |
| 218 sudo chroot "$ROOT_FS_DIR" \ |
| 219 "${ROOTFS_SETUP_DIR}/${ROOTFS_PACKAGE_INSTALL_SCRIPT}" |
| 220 |
| 221 # Run the script to customize the resulting root file system. |
| 216 sudo chroot "$ROOT_FS_DIR" "${ROOTFS_SETUP_DIR}/${ROOTFS_CUSTOMIZE_SCRIPT}" | 222 sudo chroot "$ROOT_FS_DIR" "${ROOTFS_SETUP_DIR}/${ROOTFS_CUSTOMIZE_SCRIPT}" |
| 217 | 223 |
| 224 # No longer need the setup directory in the rootfs. |
| 225 rm -rf "$SETUP_DIR" |
| 226 |
| 218 # Move package lists from the image into the output dir | 227 # Move package lists from the image into the output dir |
| 219 sudo mv "$ROOT_FS_DIR"/etc/package_list_*.txt "$OUTPUT_DIR" | 228 sudo mv "$ROOT_FS_DIR"/etc/package_list_*.txt "$OUTPUT_DIR" |
| 220 | 229 |
| 221 # Unmount mounts within the rootfs so it is ready to be imaged. | 230 # Unmount mounts within the rootfs so it is ready to be imaged. |
| 222 cleanup_rootfs_mounts | 231 cleanup_rootfs_mounts |
| 223 | 232 |
| 224 # -- Turn root file system into bootable image -- | 233 # -- Turn root file system into bootable image -- |
| 225 | 234 |
| 226 # Setup extlinux configuration. | 235 # Setup extlinux configuration. |
| 227 # TODO: For some reason the /dev/disk/by-uuid is not being generated by udev | 236 # TODO: For some reason the /dev/disk/by-uuid is not being generated by udev |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 EOF | 271 EOF |
| 263 | 272 |
| 264 OUTSIDE_OUTPUT_DIR="~/chromeos/src/build/images/${IMAGE_SUBDIR}" | 273 OUTSIDE_OUTPUT_DIR="~/chromeos/src/build/images/${IMAGE_SUBDIR}" |
| 265 echo "Done. Image created in ${OUTPUT_DIR}" | 274 echo "Done. Image created in ${OUTPUT_DIR}" |
| 266 echo "To copy to USB keyfob, outside the chroot, do something like:" | 275 echo "To copy to USB keyfob, outside the chroot, do something like:" |
| 267 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdb" | 276 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdb" |
| 268 echo "To convert to VMWare image, outside the chroot, do something like:" | 277 echo "To convert to VMWare image, outside the chroot, do something like:" |
| 269 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" | 278 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" |
| 270 | 279 |
| 271 trap - EXIT | 280 trap - EXIT |
| OLD | NEW |