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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 if [[ $FLAGS_replace -eq $FLAGS_TRUE ]]; then | 116 if [[ $FLAGS_replace -eq $FLAGS_TRUE ]]; then |
117 sudo rm -rf "$OUTPUT_DIR" | 117 sudo rm -rf "$OUTPUT_DIR" |
118 else | 118 else |
119 echo "Directory $OUTPUT_DIR already exists." | 119 echo "Directory $OUTPUT_DIR already exists." |
120 echo "Use --build_attempt option to specify an unused attempt." | 120 echo "Use --build_attempt option to specify an unused attempt." |
121 echo "Or use --replace if you want to overwrite this directory." | 121 echo "Or use --replace if you want to overwrite this directory." |
122 exit 1 | 122 exit 1 |
123 fi | 123 fi |
124 fi | 124 fi |
125 | 125 |
| 126 # Be verbose to help debug failures. |
| 127 set -x |
| 128 |
126 # Create the output directory. | 129 # Create the output directory. |
127 mkdir -p "$OUTPUT_DIR" | 130 mkdir -p "$OUTPUT_DIR" |
128 | 131 |
129 cleanup_rootfs_loop() { | 132 cleanup_rootfs_loop() { |
130 sudo umount -d "$ROOT_FS_DIR" | 133 sudo umount -d "$ROOT_FS_DIR" |
131 } | 134 } |
132 | 135 |
133 cleanup_stateful_fs_loop() { | 136 cleanup_stateful_fs_loop() { |
134 sudo umount "${ROOT_FS_DIR}/usr/local" | 137 sudo umount "${ROOT_FS_DIR}/usr/local" |
135 sudo umount "${ROOT_FS_DIR}/var" | 138 sudo umount "${ROOT_FS_DIR}/var" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 sudo mount --bind "${STATEFUL_DIR}/var" "${ROOT_FS_DIR}/var" | 383 sudo mount --bind "${STATEFUL_DIR}/var" "${ROOT_FS_DIR}/var" |
381 | 384 |
382 # We "emerge --root=$ROOT_FS_DIR --root-deps=rdeps --usepkgonly" all of the | 385 # We "emerge --root=$ROOT_FS_DIR --root-deps=rdeps --usepkgonly" all of the |
383 # runtime packages for chrome os. This builds up a chrome os image from binary | 386 # runtime packages for chrome os. This builds up a chrome os image from binary |
384 # packages with runtime dependencies only. We use INSTALL_MASK to trim the | 387 # packages with runtime dependencies only. We use INSTALL_MASK to trim the |
385 # image size as much as possible. | 388 # image size as much as possible. |
386 sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \ | 389 sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \ |
387 --root="$ROOT_FS_DIR" --root-deps=rdeps \ | 390 --root="$ROOT_FS_DIR" --root-deps=rdeps \ |
388 --usepkgonly chromeos $EMERGE_JOBS | 391 --usepkgonly chromeos $EMERGE_JOBS |
389 | 392 |
390 # Extract the kernel from the root filesystem for use by the GPT image. Legacy | |
391 # BIOS will use the kernel in the rootfs (via syslinux), Chrome OS BIOS will | |
392 # use the kernel partition. | |
393 sudo cp -f "${ROOT_FS_DIR}/boot/vmlinuz" "${OUTPUT_DIR}/vmlinuz.image" | |
394 | |
395 # Create EFI System Partition to boot stock EFI BIOS (but not ChromeOS EFI | 393 # Create EFI System Partition to boot stock EFI BIOS (but not ChromeOS EFI |
396 # BIOS). We only need this for x86, but it's simpler and safer to keep the disk | 394 # BIOS). We only need this for x86, but it's simpler and safer to keep the disk |
397 # images the same for both x86 and ARM. | 395 # images the same for both x86 and ARM. |
398 ESP_IMG=${OUTPUT_DIR}/esp.image | 396 ESP_IMG=${OUTPUT_DIR}/esp.image |
399 # NOTE: The size argument for mkfs.vfat is in 1024-byte blocks. We'll hard-code | 397 # NOTE: The size argument for mkfs.vfat is in 1024-byte blocks. We'll hard-code |
400 # it to 16M for now. | 398 # it to 16M for now. |
401 ESP_BLOCKS=16384 | 399 ESP_BLOCKS=16384 |
402 /usr/sbin/mkfs.vfat -C ${OUTPUT_DIR}/esp.image ${ESP_BLOCKS} | 400 /usr/sbin/mkfs.vfat -C ${OUTPUT_DIR}/esp.image ${ESP_BLOCKS} |
403 ESP_DIR=${OUTPUT_DIR}/esp | 401 ESP_DIR=${OUTPUT_DIR}/esp |
404 ESP_LOOP_DEV=$(sudo losetup -f) | 402 ESP_LOOP_DEV=$(sudo losetup -f) |
(...skipping 16 matching lines...) Expand all Loading... |
421 menuentry "local image A" { | 419 menuentry "local image A" { |
422 linux $grubpartA/boot/vmlinuz quiet console=tty2 init=/sbin/init boot=local ro
otwait root=/dev/$linuxpartA ro noresume noswap i915.modeset=1 loglevel=1 | 420 linux $grubpartA/boot/vmlinuz quiet console=tty2 init=/sbin/init boot=local ro
otwait root=/dev/$linuxpartA ro noresume noswap i915.modeset=1 loglevel=1 |
423 } | 421 } |
424 | 422 |
425 menuentry "local image B" { | 423 menuentry "local image B" { |
426 linux $grubpartB/boot/vmlinuz quiet console=tty2 init=/sbin/init boot=local ro
otwait root=/dev/$linuxpartB ro noresume noswap i915.modeset=1 loglevel=1 | 424 linux $grubpartB/boot/vmlinuz quiet console=tty2 init=/sbin/init boot=local ro
otwait root=/dev/$linuxpartB ro noresume noswap i915.modeset=1 loglevel=1 |
427 } | 425 } |
428 | 426 |
429 EOF | 427 EOF |
430 | 428 |
| 429 # Legacy BIOS will use the kernel in the rootfs (via syslinux), as will |
| 430 # standard EFI BIOS (via grub, from the EFI System Partition). Chrome OS BIOS |
| 431 # will use a separate signed kernel partition, which we'll create now. |
| 432 # FIXME: remove serial output, debugging messages |
| 433 cat <<'EOF' > "${OUTPUT_DIR}/config.txt" |
| 434 earlyprintk=serial,ttyS0,115200 |
| 435 console=ttyS0,115200 |
| 436 init=/sbin/init |
| 437 add_efi_memmap |
| 438 boot=local |
| 439 rootwait |
| 440 root=/dev/sd%D%P |
| 441 ro |
| 442 noresume |
| 443 noswap |
| 444 i915.modeset=1 |
| 445 loglevel=7 |
| 446 Hi_Mom |
| 447 EOF |
| 448 |
| 449 # FIXME: We need to specify the real keys and certs here! |
| 450 SIG_DIR="${SRC_ROOT}/platform/vboot_reference/tests/testkeys" |
| 451 |
| 452 # Create the kernel partition image. |
| 453 kernel_utility --generate \ |
| 454 --firmware_key "${SIG_DIR}/key_rsa4096.pem" \ |
| 455 --kernel_key "${SIG_DIR}/key_rsa1024.pem" \ |
| 456 --kernel_key_pub "${SIG_DIR}/key_rsa1024.keyb" \ |
| 457 --firmware_sign_algorithm 8 \ |
| 458 --kernel_sign_algorithm 2 \ |
| 459 --kernel_key_version 1 \ |
| 460 --kernel_version 1 \ |
| 461 --config "${OUTPUT_DIR}/config.txt" \ |
| 462 --bootloader /lib64/bootstub/bootstub.efi \ |
| 463 --vmlinuz "${ROOT_FS_DIR}/boot/vmlinuz" \ |
| 464 --out "${OUTPUT_DIR}/vmlinuz.image" |
| 465 |
431 # Perform any customizations on the root file system that are needed. | 466 # Perform any customizations on the root file system that are needed. |
432 "${SCRIPTS_DIR}/customize_rootfs" \ | 467 "${SCRIPTS_DIR}/customize_rootfs" \ |
433 --root="$ROOT_FS_DIR" \ | 468 --root="$ROOT_FS_DIR" \ |
434 --target="$ARCH" \ | 469 --target="$ARCH" \ |
435 --board="$BOARD" | 470 --board="$BOARD" |
436 | 471 |
437 # Don't test the factory install shim. | 472 # Don't test the factory install shim. |
438 if [[ $FLAGS_factory_install -eq ${FLAGS_FALSE} ]] ; then | 473 if [[ $FLAGS_factory_install -eq ${FLAGS_FALSE} ]] ; then |
439 # Check that the image has been correctly created. | 474 # Check that the image has been correctly created. |
440 "${SCRIPTS_DIR}/test_image" \ | 475 "${SCRIPTS_DIR}/test_image" \ |
(...skipping 29 matching lines...) Expand all Loading... |
470 rm -f "${ROOT_FS_IMG}" "${STATEFUL_IMG}" "${OUTPUT_DIR}/vmlinuz.image" \ | 505 rm -f "${ROOT_FS_IMG}" "${STATEFUL_IMG}" "${OUTPUT_DIR}/vmlinuz.image" \ |
471 "${ESP_IMG}" | 506 "${ESP_IMG}" |
472 rmdir "${ROOT_FS_DIR}" "${STATEFUL_DIR}" "${ESP_DIR}" | 507 rmdir "${ROOT_FS_DIR}" "${STATEFUL_DIR}" "${ESP_DIR}" |
473 | 508 |
474 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" | 509 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" |
475 | 510 |
476 # Create a developer image based on the chromium os base image | 511 # Create a developer image based on the chromium os base image |
477 [ "$FLAGS_withdev" -eq "$FLAGS_TRUE" ] && create_developer_image | 512 [ "$FLAGS_withdev" -eq "$FLAGS_TRUE" ] && create_developer_image |
478 trap - EXIT | 513 trap - EXIT |
479 | 514 |
| 515 # be quiet again |
| 516 set +x |
| 517 |
480 echo "Done. Image created in ${OUTPUT_DIR}" | 518 echo "Done. Image created in ${OUTPUT_DIR}" |
481 echo "Chromium OS image created as $PRISTINE_IMAGE_NAME" | 519 echo "Chromium OS image created as $PRISTINE_IMAGE_NAME" |
482 if [ "$FLAGS_withdev" -eq "$FLAGS_TRUE" ]; then | 520 if [ "$FLAGS_withdev" -eq "$FLAGS_TRUE" ]; then |
483 echo "Developer image created as $DEVELOPER_IMAGE_NAME" | 521 echo "Developer image created as $DEVELOPER_IMAGE_NAME" |
484 fi | 522 fi |
485 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" | 523 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" |
486 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" | 524 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" |
487 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" | 525 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" |
488 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" | 526 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" |
489 echo "from the scripts directory where you entered the chroot." | 527 echo "from the scripts directory where you entered the chroot." |
OLD | NEW |