Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: build_image

Issue 2825021: build_image: pull out kernel partition creation (Closed) Base URL: ssh://git@gitrw.chromium.org//crosutils.git
Patch Set: add keep_work and note when we are using non-"to" output Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build_kernel_image.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 455
456 menuentry "local image B" { 456 menuentry "local image B" {
457 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 cros_e fi 457 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 cros_e fi
458 } 458 }
459 459
460 menuentry "Alternate USB Boot" { 460 menuentry "Alternate USB Boot" {
461 linux (hd0,3)/boot/vmlinuz quiet console=tty2 init=/sbin/init boot=local rootw ait root=/dev/sdb3 ro noresume noswap i915.modeset=1 loglevel=1 cros_efi 461 linux (hd0,3)/boot/vmlinuz quiet console=tty2 init=/sbin/init boot=local rootw ait root=/dev/sdb3 ro noresume noswap i915.modeset=1 loglevel=1 cros_efi
462 } 462 }
463 463
464 EOF 464 EOF
465 # TODO(wad) add baseline syslinux files to ESP and install the syslinux loader
465 466
466 # FIXME: At the moment, we're working on signed images for x86 only. ARM will 467 # Builds the kernel partition image. The temporary files are kept around
467 # support this before shipping, but at the moment they don't. 468 # so that we can perform a load_kernel_test later on the final image.
468 if [[ "${ARCH}" = "x86" ]]; then 469 # TODO(wad) add dm-verity boot args (--boot_args, --root)
469 470 ${SCRIPTS_DIR}/build_kernel_image.sh \
470 # Legacy BIOS will use the kernel in the rootfs (via syslinux), as will 471 --arch="${ARCH}" \
471 # standard EFI BIOS (via grub, from the EFI System Partition). Chrome OS 472 --to="${OUTPUT_DIR}/vmlinuz.image" \
472 # BIOS will use a separate signed kernel partition, which we'll create now. 473 --vmlinuz="${ROOT_FS_DIR}/boot/vmlinuz" \
473 # FIXME: remove serial output, debugging messages. 474 --working_dir="${OUTPUT_DIR}" \
474 cat <<'EOF' > "${OUTPUT_DIR}/config.txt" 475 --keep_work \
475 earlyprintk=serial,ttyS0,115200 476 --keys_dir="${SRC_ROOT}/platform/vboot_reference/tests/testkeys"
476 console=ttyS0,115200
477 init=/sbin/init
478 add_efi_memmap
479 gpt
480 boot=local
481 rootwait
482 root=/dev/sd%D%P
483 ro
484 noresume
485 noswap
486 i915.modeset=1
487 loglevel=7
488 cros_secure
489 EOF
490
491 # FIXME: We need to specify the real keys and certs here!
492 SIG_DIR="${SRC_ROOT}/platform/vboot_reference/tests/testkeys"
493
494 # Wrap the public keys with VbPublicKey headers.
495 vbutil_key --pack \
496 --in "${SIG_DIR}/key_rsa2048.keyb" \
497 --version 1 --algorithm 4 \
498 --out "${OUTPUT_DIR}/key_alg4.vbpubk"
499
500 vbutil_key --pack \
501 --in "${SIG_DIR}/key_rsa4096.keyb" \
502 --version 1 --algorithm 8 \
503 --out "${OUTPUT_DIR}/key_alg8.vbpubk"
504
505 vbutil_keyblock --pack "${OUTPUT_DIR}/data4_sign8.keyblock" \
506 --datapubkey "${OUTPUT_DIR}/key_alg4.vbpubk" \
507 --signprivate "${SIG_DIR}/key_rsa4096.pem" \
508 --algorithm 8 --flags 3
509
510 # Verify the keyblock.
511 vbutil_keyblock --unpack "${OUTPUT_DIR}/data4_sign8.keyblock" \
512 --signpubkey "${OUTPUT_DIR}/key_alg8.vbpubk"
513
514 # Sign the kernel:
515 vbutil_kernel --pack "${OUTPUT_DIR}/vmlinuz.image" \
516 --keyblock "${OUTPUT_DIR}/data4_sign8.keyblock" \
517 --signprivate "${SIG_DIR}/key_rsa2048.pem" \
518 --version 1 \
519 --config "${OUTPUT_DIR}/config.txt" \
520 --bootloader /lib64/bootstub/bootstub.efi \
521 --vmlinuz "${ROOT_FS_DIR}/boot/vmlinuz"
522
523 # And verify it.
524 vbutil_kernel --verify "${OUTPUT_DIR}/vmlinuz.image" \
525 --signpubkey "${OUTPUT_DIR}/key_alg8.vbpubk"
526
527 else
528 # FIXME: For now, ARM just uses the unsigned kernel by itself.
529 cp -f "${ROOT_FS_DIR}/boot/vmlinuz" "${OUTPUT_DIR}/vmlinuz.image"
530 fi
531
532 477
533 # Perform any customizations on the root file system that are needed. 478 # Perform any customizations on the root file system that are needed.
534 "${SCRIPTS_DIR}/customize_rootfs" \ 479 "${SCRIPTS_DIR}/customize_rootfs" \
535 --root="${ROOT_FS_DIR}" \ 480 --root="${ROOT_FS_DIR}" \
536 --target="${ARCH}" \ 481 --target="${ARCH}" \
537 --board="${BOARD}" 482 --board="${BOARD}"
538 483
539 # Don't test the factory install shim. 484 # Don't test the factory install shim.
540 if [[ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ]] ; then 485 if [[ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ]] ; then
541 # Check that the image has been correctly created. 486 # Check that the image has been correctly created.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 echo "Creating developer image from base image ${OUTPUT_IMG}" 535 echo "Creating developer image from base image ${OUTPUT_IMG}"
591 cp ${OUTPUT_DIR}/${PRISTINE_IMAGE_NAME} ${OUTPUT_DIR}/${DEVELOPER_IMAGE_NAME} 536 cp ${OUTPUT_DIR}/${PRISTINE_IMAGE_NAME} ${OUTPUT_DIR}/${DEVELOPER_IMAGE_NAME}
592 update_dev_packages ${OUTPUT_DIR}/${DEVELOPER_IMAGE_NAME} 537 update_dev_packages ${OUTPUT_DIR}/${DEVELOPER_IMAGE_NAME}
593 fi 538 fi
594 539
595 trap - EXIT 540 trap - EXIT
596 541
597 # FIXME: only signing things for x86 right now. 542 # FIXME: only signing things for x86 right now.
598 if [[ "${ARCH}" = "x86" ]]; then 543 if [[ "${ARCH}" = "x86" ]]; then
599 # Verify the final image. 544 # Verify the final image.
545 # key_alg8.vbpubk is generated by build_kernel_image.sh --keep_work
600 load_kernel_test "${OUTPUT_IMG}" "${OUTPUT_DIR}/key_alg8.vbpubk" 546 load_kernel_test "${OUTPUT_IMG}" "${OUTPUT_DIR}/key_alg8.vbpubk"
601 fi 547 fi
602 548
603 # Clean up temporary files. 549 # Clean up temporary files.
604 rm -f "${ROOT_FS_IMG}" "${STATEFUL_FS_IMG}" "${OUTPUT_DIR}/vmlinuz.image" \ 550 rm -f "${ROOT_FS_IMG}" "${STATEFUL_FS_IMG}" "${OUTPUT_DIR}/vmlinuz.image" \
605 "${ESP_FS_IMG}" "${OUTPUT_DIR}/data4_sign8.keyblock" \ 551 "${ESP_FS_IMG}" "${OUTPUT_DIR}/data4_sign8.keyblock" \
606 "${OUTPUT_DIR}/key_alg4.vbpubk" "${OUTPUT_DIR}/key_alg8.vbpubk" 552 "${OUTPUT_DIR}/key_alg4.vbpubk" "${OUTPUT_DIR}/key_alg8.vbpubk"
607 rmdir "${ROOT_FS_DIR}" "${STATEFUL_FS_DIR}" "${ESP_FS_DIR}" 553 rmdir "${ROOT_FS_DIR}" "${STATEFUL_FS_DIR}" "${ESP_FS_DIR}"
608 554
609 echo "Done. Image created in ${OUTPUT_DIR}" 555 echo "Done. Image created in ${OUTPUT_DIR}"
610 echo "Chromium OS image created as ${PRISTINE_IMAGE_NAME}" 556 echo "Chromium OS image created as ${PRISTINE_IMAGE_NAME}"
611 if [ "${FLAGS_recovery}" -eq "${FLAGS_TRUE}" ]; then 557 if [ "${FLAGS_recovery}" -eq "${FLAGS_TRUE}" ]; then
612 echo "Recovery image created as ${PRISTINE_IMAGE_NAME}" 558 echo "Recovery image created as ${PRISTINE_IMAGE_NAME}"
613 fi 559 fi
614 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then 560 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then
615 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" 561 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}"
616 fi 562 fi
617 563
618 print_time_elapsed 564 print_time_elapsed
619 565
620 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" 566 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:"
621 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" 567 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX"
622 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" 568 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:"
623 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" 569 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}"
624 echo "from the scripts directory where you entered the chroot." 570 echo "from the scripts directory where you entered the chroot."
OLDNEW
« no previous file with comments | « no previous file | build_kernel_image.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698