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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 cros_root=/dev/mmcblk1p3 | 284 cros_root=/dev/mmcblk1p3 |
285 fi | 285 fi |
286 if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then | 286 if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then |
287 cros_root=/dev/dm-0 | 287 cros_root=/dev/dm-0 |
288 fi | 288 fi |
289 | 289 |
290 # TODO(wad) mount the root fs to LOOP_DEV from the image | 290 # TODO(wad) mount the root fs to LOOP_DEV from the image |
291 trap "mount_gpt_cleanup" EXIT | 291 trap "mount_gpt_cleanup" EXIT |
292 ${SCRIPTS_DIR}/mount_gpt_image.sh --from "${OUTPUT_DIR}" \ | 292 ${SCRIPTS_DIR}/mount_gpt_image.sh --from "${OUTPUT_DIR}" \ |
293 --image "${image_name}" -r "${ROOT_FS_DIR}" \ | 293 --image "${image_name}" -r "${ROOT_FS_DIR}" \ |
294 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" | 294 -s "${STATEFUL_FS_DIR}" |
295 | 295 |
296 sudo mount -o remount,ro "${ROOT_FS_DIR}" | 296 sudo mount -o remount,ro "${ROOT_FS_DIR}" |
297 root_dev=$(mount | grep -- "${ROOT_FS_DIR}" | cut -f1 -d' ' | tail -1) | 297 root_dev=$(mount | grep -- "${ROOT_FS_DIR}" | cut -f1 -d' ' | tail -1) |
298 | 298 |
299 DEVKEYSDIR="/usr/share/vboot/devkeys" | 299 DEVKEYSDIR="/usr/share/vboot/devkeys" |
300 | 300 |
301 # Builds the kernel partition image. The temporary files are kept around | 301 # Builds the kernel partition image. The temporary files are kept around |
302 # so that we can perform a load_kernel_test later on the final image. | 302 # so that we can perform a load_kernel_test later on the final image. |
303 ${SCRIPTS_DIR}/build_kernel_image.sh \ | 303 ${SCRIPTS_DIR}/build_kernel_image.sh \ |
304 --arch="${ARCH}" \ | 304 --arch="${ARCH}" \ |
(...skipping 20 matching lines...) Expand all Loading... |
325 sudo cp "${OUTPUT_DIR}/vmlinuz_hd.vblock" "${STATEFUL_FS_DIR}" | 325 sudo cp "${OUTPUT_DIR}/vmlinuz_hd.vblock" "${STATEFUL_FS_DIR}" |
326 fi | 326 fi |
327 | 327 |
328 # START_KERN_A is set by the first call to install the gpt. | 328 # START_KERN_A is set by the first call to install the gpt. |
329 local koffset="$(partoffset ${OUTPUT_DIR}/${image_name} 2)" | 329 local koffset="$(partoffset ${OUTPUT_DIR}/${image_name} 2)" |
330 sudo dd if="${OUTPUT_DIR}/vmlinuz.image" of="${OUTPUT_DIR}/${image_name}" \ | 330 sudo dd if="${OUTPUT_DIR}/vmlinuz.image" of="${OUTPUT_DIR}/${image_name}" \ |
331 conv=notrunc bs=512 seek=${koffset} | 331 conv=notrunc bs=512 seek=${koffset} |
332 | 332 |
333 # Update the bootloaders. For legacy/efi x86, the EFI system partition | 333 # Update the bootloaders. For legacy/efi x86, the EFI system partition |
334 # will be updated and for arm, the mbr will be updated (for u-boot). | 334 # will be updated and for arm, the mbr will be updated (for u-boot). |
335 local kernel_part="--kernel_partition='${OUTPUT_DIR}/vmlinuz.image'" | 335 local kernel_part= |
336 kernel_part="${kernel_part} --install_syslinux" | 336 local bootloader_to= |
337 local bootloader_to="${ESP_FS_IMG}" | 337 local bootloader_to_flags= |
338 local usb_disk="${FLAGS_usb_disk}" | 338 local usb_disk="${FLAGS_usb_disk}" |
339 local bootloader_to="$(mount | grep ${ESP_FS_DIR} | cut -f1 -d' ')" | 339 |
340 if [[ "${ARCH}" == "arm" ]]; then | 340 if [[ "${ARCH}" = "x86" ]]; then |
| 341 # x86 should update the esp in place in the image. |
| 342 bootloader_to="${OUTPUT_DIR}/${image_name}" |
| 343 local esp_offset="$(partoffset ${OUTPUT_DIR}/${image_name} 12)" |
| 344 esp_offset=$((esp_offset * 512)) # sectors to bytes |
| 345 local esp_size="$(partsize ${OUTPUT_DIR}/${image_name} 12)" |
| 346 esp_size=$((esp_size * 512)) # sectors to bytes |
| 347 bootloader_to_flags="--to_offset=${esp_offset} --to_size=${esp_size}" |
| 348 # Use the kernel partition to acquire configuration flags. |
| 349 kernel_part="--kernel_partition='${OUTPUT_DIR}/vmlinuz.image'" |
| 350 # Install syslinux on the EFI System Partition. |
| 351 kernel_part="${kernel_part} --install_syslinux" |
| 352 elif [[ "${ARCH}" = "arm" ]]; then |
341 # TODO(wad) mmcblk1p3 is hardcoded for arm for now! | 353 # TODO(wad) mmcblk1p3 is hardcoded for arm for now! |
342 usb_disk="/dev/mmcblk1p3" | 354 usb_disk="/dev/mmcblk1p3" |
| 355 # ARM doesn't support using the kernel image for kernel cmdline flags yet. |
343 kernel_part="--kernel_cmdline=\"${FLAGS_arm_extra_bootargs}\" " | 356 kernel_part="--kernel_cmdline=\"${FLAGS_arm_extra_bootargs}\" " |
344 # TODO(wad) Integrate dmtable extraction into the arm build | 357 # TODO(wad) Integrate dmtable extraction into the arm build |
345 # E.g. $(cat ${OUTPUT_DIR}/boot.config | tr -s '\n' ' ')" | 358 # E.g. $(cat ${OUTPUT_DIR}/boot.config | tr -s '\n' ' ')" |
346 local kpart_offset="--kernel_partition_offset=${koffset}" | 359 local kpart_offset="--kernel_partition_offset=${koffset}" |
347 local kpart_size="--kernel_partition_sectors=" | 360 local kpart_size="--kernel_partition_sectors=" |
348 kpart_size="${kpart_size}$(partsize ${OUTPUT_DIR}/${image_name} 2)" | 361 kpart_size="${kpart_size}$(partsize ${OUTPUT_DIR}/${image_name} 2)" |
349 kernel_part="${kernel_part} ${kpart_size} ${kpart_offset}" | 362 kernel_part="${kernel_part} ${kpart_size} ${kpart_offset}" |
350 info "Using addition bootloader arguments: ${kernel_part}" | 363 info "Using addition bootloader arguments: ${kernel_part}" |
351 bootloader_to="${OUTPUT_DIR}/arm.mbr" | 364 bootloader_to="${OUTPUT_DIR}/arm.mbr" |
352 fi | 365 fi |
353 | 366 |
354 # Temporary hack to fix syslinux building: | |
355 sudo umount ${ESP_FS_DIR} | |
356 | |
357 # Update partition 12 / legacy bootloaders and arm. | 367 # Update partition 12 / legacy bootloaders and arm. |
358 ${SCRIPTS_DIR}/update_bootloaders.sh \ | 368 ${SCRIPTS_DIR}/update_bootloaders.sh \ |
359 --arch=${ARCH} \ | 369 --arch=${ARCH} \ |
360 --to="${bootloader_to}" \ | 370 --to="${bootloader_to}" \ |
361 --from="${OUTPUT_DIR}"/boot \ | 371 --from="${OUTPUT_DIR}"/boot \ |
362 --vmlinuz="${OUTPUT_DIR}"/boot/vmlinuz \ | 372 --vmlinuz="${OUTPUT_DIR}"/boot/vmlinuz \ |
363 --usb_disk="${usb_disk}" \ | 373 --usb_disk="${usb_disk}" \ |
| 374 ${bootloader_to_flags} \ |
364 $kernel_part | 375 $kernel_part |
365 | 376 |
366 if [[ "${ARCH}" == "arm" ]]; then | 377 if [[ "${ARCH}" == "arm" ]]; then |
367 sudo dd bs=1 conv=notrunc if="${bootloader_to}" \ | 378 sudo dd bs=1 conv=notrunc if="${bootloader_to}" \ |
368 of="${OUTPUT_DIR}/${image_name}" | 379 of="${OUTPUT_DIR}/${image_name}" |
369 sudo rm "${bootloader_to}" | 380 sudo rm "${bootloader_to}" |
370 fi | 381 fi |
371 | 382 |
372 trap - EXIT | 383 trap - EXIT |
373 # Temporary hack to fix syslinux building, comment out -e ${ESP_FS_DIR} | |
374 # ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ | |
375 # -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" | |
376 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ | 384 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ |
377 -s "${STATEFUL_FS_DIR}" | 385 -s "${STATEFUL_FS_DIR}" |
378 } | 386 } |
379 | 387 |
380 # Modifies an existing image to add development packages | 388 # Modifies an existing image to add development packages |
381 update_dev_packages() { | 389 update_dev_packages() { |
382 local image_name=$1 | 390 local image_name=$1 |
383 | 391 |
384 echo "Adding developer packages to ${image_name}" | 392 echo "Adding developer packages to ${image_name}" |
385 | 393 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" | 731 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" |
724 fi | 732 fi |
725 | 733 |
726 print_time_elapsed | 734 print_time_elapsed |
727 | 735 |
728 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" | 736 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" |
729 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" | 737 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" |
730 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" | 738 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" |
731 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR}" | 739 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR}" |
732 echo "from the scripts directory where you entered the chroot." | 740 echo "from the scripts directory where you entered the chroot." |
OLD | NEW |