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

Side by Side Diff: src/scripts/build_image

Issue 1567013: Clean up temporary files and directories left by build_image, etc. (Closed)
Patch Set: Emit scripts to pack/unpack the image. Created 10 years, 8 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
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 # Determine build version. 63 # Determine build version.
64 . "${SCRIPTS_DIR}/chromeos_version.sh" 64 . "${SCRIPTS_DIR}/chromeos_version.sh"
65 65
66 # Use canonical path since some tools (e.g. mount) do not like symlinks. 66 # Use canonical path since some tools (e.g. mount) do not like symlinks.
67 # Append build attempt to output directory. 67 # Append build attempt to output directory.
68 IMAGE_SUBDIR="${CHROMEOS_VERSION_STRING}-a${FLAGS_build_attempt}" 68 IMAGE_SUBDIR="${CHROMEOS_VERSION_STRING}-a${FLAGS_build_attempt}"
69 OUTPUT_DIR="${FLAGS_output_root}/${FLAGS_board}/${IMAGE_SUBDIR}" 69 OUTPUT_DIR="${FLAGS_output_root}/${FLAGS_board}/${IMAGE_SUBDIR}"
70 ROOT_FS_DIR="${OUTPUT_DIR}/rootfs" 70 ROOT_FS_DIR="${OUTPUT_DIR}/rootfs"
71 ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image" 71 ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image"
72 MBR_IMG="${OUTPUT_DIR}/mbr.image"
73 OUTPUT_IMG="${OUTPUT_DIR}/chromiumos_image.bin" 72 OUTPUT_IMG="${OUTPUT_DIR}/chromiumos_image.bin"
74 73
75 BOARD="${FLAGS_board}" 74 BOARD="${FLAGS_board}"
76 BOARD_ROOT="${FLAGS_build_root}/${BOARD}" 75 BOARD_ROOT="${FLAGS_build_root}/${BOARD}"
77 76
78 LOOP_DEV= 77 LOOP_DEV=
79 78
80 # What cross-build are we targeting? 79 # What cross-build are we targeting?
81 . "${BOARD_ROOT}/etc/make.conf.board_setup" 80 . "${BOARD_ROOT}/etc/make.conf.board_setup"
82 LIBC_VERSION=${LIBC_VERSION:-"2.10.1-r1"} 81 LIBC_VERSION=${LIBC_VERSION:-"2.10.1-r1"}
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 315
317 # Perform any customizations on the root file system that are needed. 316 # Perform any customizations on the root file system that are needed.
318 WITH_DEV="" 317 WITH_DEV=""
319 if [[ $FLAGS_withdev -eq $FLAGS_TRUE ]]; then 318 if [[ $FLAGS_withdev -eq $FLAGS_TRUE ]]; then
320 WITH_DEV="--withdev" 319 WITH_DEV="--withdev"
321 fi 320 fi
322 321
323 # Extract the kernel from the root filesystem for use by the GPT image. Legacy 322 # Extract the kernel from the root filesystem for use by the GPT image. Legacy
324 # BIOS will use the kernel in the rootfs (via syslinux), ChromeOS BIOS will use 323 # BIOS will use the kernel in the rootfs (via syslinux), ChromeOS BIOS will use
325 # the kernel partition. 324 # the kernel partition.
326 sudo cp -f ${ROOT_FS_DIR}/boot/vmlinuz ${OUTPUT_DIR}/vmlinuz.image 325 sudo cp -f "${ROOT_FS_DIR}/boot/vmlinuz" "${OUTPUT_DIR}/vmlinuz.image"
327 326
328 #TODO(sosa@chromium.org) - Does it make sense to leave /usr/local bound here? 327 #TODO(sosa@chromium.org) - Does it make sense to leave /usr/local bound here?
329 "${SCRIPTS_DIR}/customize_rootfs" \ 328 "${SCRIPTS_DIR}/customize_rootfs" \
330 --root="$ROOT_FS_DIR" \ 329 --root="$ROOT_FS_DIR" \
331 --target="$ARCH" \ 330 --target="$ARCH" \
332 --board="$BOARD" \ 331 --board="$BOARD" \
333 $WITH_DEV 332 $WITH_DEV
334 333
335 # Check that the image has been correctly created. 334 # Check that the image has been correctly created.
336 "${SCRIPTS_DIR}/test_image" \ 335 "${SCRIPTS_DIR}/test_image" \
(...skipping 11 matching lines...) Expand all
348 sudo umount "$ROOT_FS_DIR/usr/local" 347 sudo umount "$ROOT_FS_DIR/usr/local"
349 fi 348 fi
350 349
351 # Cleanup loop devices. 350 # Cleanup loop devices.
352 cleanup_stateful_fs_loop 351 cleanup_stateful_fs_loop
353 cleanup_rootfs_loop 352 cleanup_rootfs_loop
354 353
355 # Create the GPT-formatted image 354 # Create the GPT-formatted image
356 ${SCRIPTS_DIR}/build_gpt.sh \ 355 ${SCRIPTS_DIR}/build_gpt.sh \
357 --arch=${ARCH} --board=${FLAGS_board} --board_root=${BOARD_ROOT} \ 356 --arch=${ARCH} --board=${FLAGS_board} --board_root=${BOARD_ROOT} \
358 ${OUTPUT_DIR} ${OUTPUT_IMG} 357 "${OUTPUT_DIR}" "${OUTPUT_IMG}"
359 358
359 # Clean up temporary files.
360 rm -f "${ROOT_FS_IMG}" "${STATEFUL_IMG}" "${OUTPUT_DIR}/vmlinuz.image"
361 rmdir "${ROOT_FS_DIR}" "${STATEFUL_DIR}"
360 362
361 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" 363 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}"
362 echo "Done. Image created in ${OUTPUT_DIR}" 364 echo "Done. Image created in ${OUTPUT_DIR}"
363 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" 365 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:"
364 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdb" 366 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdb"
365 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" 367 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:"
366 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" 368 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}"
367 echo "from the scripts directory where you entered the chroot." 369 echo "from the scripts directory where you entered the chroot."
368 370
369 trap - EXIT 371 trap - EXIT
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698