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

Side by Side Diff: src/scripts/build_image

Issue 2440005: RootFS size customization params added (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: added check for rootfs size and its partition 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 | « src/scripts/build_gpt.sh ('k') | no next file » | 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 28 matching lines...) Expand all
39 "Install development packages on stateful partition rather than the rootfs" 39 "Install development packages on stateful partition rather than the rootfs"
40 DEFINE_string to "" \ 40 DEFINE_string to "" \
41 "The target image file or device" 41 "The target image file or device"
42 DEFINE_boolean factory_install $FLAGS_FALSE \ 42 DEFINE_boolean factory_install $FLAGS_FALSE \
43 "Build a smaller image to overlay the factory install shim on; this argument \ 43 "Build a smaller image to overlay the factory install shim on; this argument \
44 is also required in image_to_usb." 44 is also required in image_to_usb."
45 DEFINE_string arm_extra_bootargs "" \ 45 DEFINE_string arm_extra_bootargs "" \
46 "Additional command line options to pass to the ARM kernel." 46 "Additional command line options to pass to the ARM kernel."
47 DEFINE_boolean recovery $FLAGS_FALSE \ 47 DEFINE_boolean recovery $FLAGS_FALSE \
48 "Build a recovery image. Default: False." 48 "Build a recovery image. Default: False."
49 DEFINE_integer rootfs_partition_size 1024 \
50 "rootfs parition size in MBs."
51 DEFINE_integer rootfs_size 720 \
52 "rootfs filesystem size in MBs."
49 53
50 # Parse command line. 54 # Parse command line.
51 FLAGS "$@" || exit 1 55 FLAGS "$@" || exit 1
52 eval set -- "${FLAGS_ARGV}" 56 eval set -- "${FLAGS_ARGV}"
53 57
54 # Only now can we die on error. shflags functions leak non-zero error codes, 58 # Only now can we die on error. shflags functions leak non-zero error codes,
55 # so will die prematurely if 'set -e' is specified before now. 59 # so will die prematurely if 'set -e' is specified before now.
56 set -e 60 set -e
57 61
58 if [ -z "$FLAGS_board" ] ; then 62 if [ -z "$FLAGS_board" ] ; then
59 error "--board is required." 63 error "--board is required."
60 exit 1 64 exit 1
61 fi 65 fi
62 66
67 if [ "$FLAGS_rootfs_size" -gt "$FLAGS_rootfs_partition_size" ] ; then
68 error "rootfs (${FLAGS_rootfs_size} MB) is bigger than partition (${FLAGS_root fs_partition_size} MB)."
69 exit 1
70 fi
71
63 # Determine build version. 72 # Determine build version.
64 . "${SCRIPTS_DIR}/chromeos_version.sh" 73 . "${SCRIPTS_DIR}/chromeos_version.sh"
65 74
66 # Use canonical path since some tools (e.g. mount) do not like symlinks. 75 # Use canonical path since some tools (e.g. mount) do not like symlinks.
67 # Append build attempt to output directory. 76 # Append build attempt to output directory.
68 IMAGE_SUBDIR="${CHROMEOS_VERSION_STRING}-a${FLAGS_build_attempt}" 77 IMAGE_SUBDIR="${CHROMEOS_VERSION_STRING}-a${FLAGS_build_attempt}"
69 OUTPUT_DIR="${FLAGS_output_root}/${FLAGS_board}/${IMAGE_SUBDIR}" 78 OUTPUT_DIR="${FLAGS_output_root}/${FLAGS_board}/${IMAGE_SUBDIR}"
70 ROOT_FS_DIR="${OUTPUT_DIR}/rootfs" 79 ROOT_FS_DIR="${OUTPUT_DIR}/rootfs"
71 ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image" 80 ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image"
72 81
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 if [ -z "$LOOP_DEV" ] ; then 276 if [ -z "$LOOP_DEV" ] ; then
268 echo "No free loop device. Free up a loop device or reboot. exiting. " 277 echo "No free loop device. Free up a loop device or reboot. exiting. "
269 exit 1 278 exit 1
270 fi 279 fi
271 280
272 # Create root file system disk image to fit on a 1GB memory stick. 281 # Create root file system disk image to fit on a 1GB memory stick.
273 # 1 GB in hard-drive-manufacturer-speak is 10^9, not 2^30. 950MB < 10^9 bytes. 282 # 1 GB in hard-drive-manufacturer-speak is 10^9, not 2^30. 950MB < 10^9 bytes.
274 if [[ $FLAGS_factory_install -eq ${FLAGS_TRUE} ]] ; then 283 if [[ $FLAGS_factory_install -eq ${FLAGS_TRUE} ]] ; then
275 ROOT_SIZE_BYTES=$((1024 * 1024 * 300)) 284 ROOT_SIZE_BYTES=$((1024 * 1024 * 300))
276 else 285 else
277 ROOT_SIZE_BYTES=$((1024 * 1024 * 720)) 286 ROOT_SIZE_BYTES=$((1024 * 1024 * ${FLAGS_rootfs_size}))
278 fi 287 fi
279 288
280 dd if=/dev/zero of="$ROOT_FS_IMG" bs=1 count=1 seek=$((ROOT_SIZE_BYTES - 1)) 289 dd if=/dev/zero of="$ROOT_FS_IMG" bs=1 count=1 seek=$((ROOT_SIZE_BYTES - 1))
281 sudo losetup "$LOOP_DEV" "$ROOT_FS_IMG" 290 sudo losetup "$LOOP_DEV" "$ROOT_FS_IMG"
282 sudo mkfs.ext3 "$LOOP_DEV" 291 sudo mkfs.ext3 "$LOOP_DEV"
283 292
284 # Tune and mount rootfs. 293 # Tune and mount rootfs.
285 UUID=$(uuidgen) 294 UUID=$(uuidgen)
286 DISK_LABEL="C-KEYFOB" 295 DISK_LABEL="C-KEYFOB"
287 sudo tune2fs -L "$DISK_LABEL" -U "$UUID" -c 0 -i 0 "$LOOP_DEV" 296 sudo tune2fs -L "$DISK_LABEL" -U "$UUID" -c 0 -i 0 "$LOOP_DEV"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 RECOVERY="--norecovery" 499 RECOVERY="--norecovery"
491 if [[ ${FLAGS_recovery} -eq $FLAGS_TRUE ]]; then 500 if [[ ${FLAGS_recovery} -eq $FLAGS_TRUE ]]; then
492 RECOVERY="--recovery" 501 RECOVERY="--recovery"
493 fi 502 fi
494 503
495 # Create the GPT-formatted image 504 # Create the GPT-formatted image
496 ${SCRIPTS_DIR}/build_gpt.sh \ 505 ${SCRIPTS_DIR}/build_gpt.sh \
497 --arch=${ARCH} \ 506 --arch=${ARCH} \
498 --board=${FLAGS_board} \ 507 --board=${FLAGS_board} \
499 --arm_extra_bootargs="${FLAGS_arm_extra_bootargs}" \ 508 --arm_extra_bootargs="${FLAGS_arm_extra_bootargs}" \
509 --rootfs_partition_size=${FLAGS_rootfs_partition_size} \
500 ${RECOVERY} \ 510 ${RECOVERY} \
501 "${OUTPUT_DIR}" \ 511 "${OUTPUT_DIR}" \
502 "${OUTPUT_IMG}" 512 "${OUTPUT_IMG}"
503 513
504 # Clean up temporary files. 514 # Clean up temporary files.
505 rm -f "${ROOT_FS_IMG}" "${STATEFUL_IMG}" "${OUTPUT_DIR}/vmlinuz.image" \ 515 rm -f "${ROOT_FS_IMG}" "${STATEFUL_IMG}" "${OUTPUT_DIR}/vmlinuz.image" \
506 "${ESP_IMG}" 516 "${ESP_IMG}"
507 rmdir "${ROOT_FS_DIR}" "${STATEFUL_DIR}" "${ESP_DIR}" 517 rmdir "${ROOT_FS_DIR}" "${STATEFUL_DIR}" "${ESP_DIR}"
508 518
509 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" 519 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}"
510 520
511 # Create a developer image based on the chromium os base image 521 # Create a developer image based on the chromium os base image
512 [ "$FLAGS_withdev" -eq "$FLAGS_TRUE" ] && create_developer_image 522 [ "$FLAGS_withdev" -eq "$FLAGS_TRUE" ] && create_developer_image
513 trap - EXIT 523 trap - EXIT
514 524
515 # be quiet again 525 # be quiet again
516 set +x 526 set +x
517 527
518 echo "Done. Image created in ${OUTPUT_DIR}" 528 echo "Done. Image created in ${OUTPUT_DIR}"
519 echo "Chromium OS image created as $PRISTINE_IMAGE_NAME" 529 echo "Chromium OS image created as $PRISTINE_IMAGE_NAME"
520 if [ "$FLAGS_withdev" -eq "$FLAGS_TRUE" ]; then 530 if [ "$FLAGS_withdev" -eq "$FLAGS_TRUE" ]; then
521 echo "Developer image created as $DEVELOPER_IMAGE_NAME" 531 echo "Developer image created as $DEVELOPER_IMAGE_NAME"
522 fi 532 fi
523 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" 533 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:"
524 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" 534 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX"
525 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" 535 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:"
526 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" 536 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}"
527 echo "from the scripts directory where you entered the chroot." 537 echo "from the scripts directory where you entered the chroot."
OLDNEW
« no previous file with comments | « src/scripts/build_gpt.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698