| 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 from within | 7 # Script to build a bootable keyfob-based chromeos system image from within |
| 8 # a chromiumos setup. This assumes that all needed packages have been built into | 8 # a chromiumos setup. This assumes that all needed packages have been built into |
| 9 # the given target's root with binary packages turned on. This script will | 9 # the given target's root with binary packages turned on. This script will |
| 10 # build the Chrome OS image using only pre-built binary packages. | 10 # build the Chrome OS image using only pre-built binary packages. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 # Additional changes to developer image. | 217 # Additional changes to developer image. |
| 218 | 218 |
| 219 # The ldd tool is a useful shell script but lives in glibc; just copy it. | 219 # The ldd tool is a useful shell script but lives in glibc; just copy it. |
| 220 sudo cp -a "$(which ldd)" "${root_dev_dir}/usr/bin" | 220 sudo cp -a "$(which ldd)" "${root_dev_dir}/usr/bin" |
| 221 | 221 |
| 222 # If vim is installed, then a vi symlink would probably help. | 222 # If vim is installed, then a vi symlink would probably help. |
| 223 if [[ -x "${ROOT_FS_DIR}/usr/local/bin/vim" ]]; then | 223 if [[ -x "${ROOT_FS_DIR}/usr/local/bin/vim" ]]; then |
| 224 sudo ln -sf vim "${ROOT_FS_DIR}/usr/local/bin/vi" | 224 sudo ln -sf vim "${ROOT_FS_DIR}/usr/local/bin/vi" |
| 225 fi | 225 fi |
| 226 | 226 |
| 227 # Check that the image has been correctly created. | 227 # Check that the image has been correctly created. Only do it if not |
| 228 "${SCRIPTS_DIR}/test_image" \ | 228 # building a factory install image, as the INSTALL_MASK for it will |
| 229 --root="$root_fs_dir" \ | 229 # make test_image fail. |
| 230 --target="$ARCH" | 230 if [[ $FLAGS_factory_install -eq ${FLAGS_FALSE} ]] ; then |
| 231 "${SCRIPTS_DIR}/test_image" \ |
| 232 --root="$root_fs_dir" \ |
| 233 --target="$ARCH" |
| 234 fi |
| 231 | 235 |
| 232 trap - EXIT | 236 trap - EXIT |
| 233 $SCRIPTS_DIR/mount_gpt_image.sh -u -r "$root_fs_dir" -s "$stateful_dir" | 237 $SCRIPTS_DIR/mount_gpt_image.sh -u -r "$root_fs_dir" -s "$stateful_dir" |
| 234 echo "Developer image built and stored at $output_img" | 238 echo "Developer image built and stored at $output_img" |
| 235 } | 239 } |
| 236 | 240 |
| 237 # ${DEV_IMAGE_ROOT} specifies the location of where developer packages will | 241 # ${DEV_IMAGE_ROOT} specifies the location of where developer packages will |
| 238 # be installed on the stateful dir. On a Chromium OS system, this will | 242 # be installed on the stateful dir. On a Chromium OS system, this will |
| 239 # translate to /usr/local | 243 # translate to /usr/local |
| 240 DEV_IMAGE_ROOT= | 244 DEV_IMAGE_ROOT= |
| 241 | 245 |
| 242 trap "cleanup && delete_prompt" EXIT | 246 trap "cleanup && delete_prompt" EXIT |
| 243 | 247 |
| 244 mkdir -p "$ROOT_FS_DIR" | 248 mkdir -p "$ROOT_FS_DIR" |
| 245 | 249 |
| 246 # Create and format the root file system. | 250 # Create and format the root file system. |
| 247 | 251 |
| 248 # Check for loop device before creating image. | 252 # Check for loop device before creating image. |
| 249 LOOP_DEV=$(sudo losetup -f) | 253 LOOP_DEV=$(sudo losetup -f) |
| 250 if [ -z "$LOOP_DEV" ] ; then | 254 if [ -z "$LOOP_DEV" ] ; then |
| 251 echo "No free loop device. Free up a loop device or reboot. exiting. " | 255 echo "No free loop device. Free up a loop device or reboot. exiting. " |
| 252 exit 1 | 256 exit 1 |
| 253 fi | 257 fi |
| 254 | 258 |
| 255 # Create root file system disk image to fit on a 1GB memory stick. | 259 # Create root file system disk image to fit on a 1GB memory stick. |
| 256 # 1 GB in hard-drive-manufacturer-speak is 10^9, not 2^30. 950MB < 10^9 bytes. | 260 # 1 GB in hard-drive-manufacturer-speak is 10^9, not 2^30. 950MB < 10^9 bytes. |
| 257 if [[ $FLAGS_factory_install -eq ${FLAGS_TRUE} ]] ; then | 261 if [[ $FLAGS_factory_install -eq ${FLAGS_TRUE} ]] ; then |
| 258 ROOT_SIZE_BYTES=$((1024 * 1024 * 180)) | 262 ROOT_SIZE_BYTES=$((1024 * 1024 * 300)) |
| 259 else | 263 else |
| 260 ROOT_SIZE_BYTES=$((1024 * 1024 * 720)) | 264 ROOT_SIZE_BYTES=$((1024 * 1024 * 720)) |
| 261 fi | 265 fi |
| 262 | 266 |
| 263 dd if=/dev/zero of="$ROOT_FS_IMG" bs=1 count=1 seek=$((ROOT_SIZE_BYTES - 1)) | 267 dd if=/dev/zero of="$ROOT_FS_IMG" bs=1 count=1 seek=$((ROOT_SIZE_BYTES - 1)) |
| 264 sudo losetup "$LOOP_DEV" "$ROOT_FS_IMG" | 268 sudo losetup "$LOOP_DEV" "$ROOT_FS_IMG" |
| 265 sudo mkfs.ext3 "$LOOP_DEV" | 269 sudo mkfs.ext3 "$LOOP_DEV" |
| 266 | 270 |
| 267 # Tune and mount rootfs. | 271 # Tune and mount rootfs. |
| 268 UUID=$(uuidgen) | 272 UUID=$(uuidgen) |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 echo "Done. Image created in ${OUTPUT_DIR}" | 464 echo "Done. Image created in ${OUTPUT_DIR}" |
| 461 echo "Chromium OS image created as $PRISTINE_IMAGE_NAME" | 465 echo "Chromium OS image created as $PRISTINE_IMAGE_NAME" |
| 462 if [ "$FLAGS_withdev" -eq "$FLAGS_TRUE" ]; then | 466 if [ "$FLAGS_withdev" -eq "$FLAGS_TRUE" ]; then |
| 463 echo "Developer image created as $DEVELOPER_IMAGE_NAME" | 467 echo "Developer image created as $DEVELOPER_IMAGE_NAME" |
| 464 fi | 468 fi |
| 465 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" | 469 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" |
| 466 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" | 470 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" |
| 467 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" | 471 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" |
| 468 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" | 472 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" |
| 469 echo "from the scripts directory where you entered the chroot." | 473 echo "from the scripts directory where you entered the chroot." |
| OLD | NEW |