| 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 23 matching lines...) Expand all Loading... |
| 34 DEFINE_boolean installmask $FLAGS_TRUE \ | 34 DEFINE_boolean installmask $FLAGS_TRUE \ |
| 35 "Use INSTALL_MASK to shrink the resulting image." | 35 "Use INSTALL_MASK to shrink the resulting image." |
| 36 DEFINE_integer jobs -1 \ | 36 DEFINE_integer jobs -1 \ |
| 37 "How many packages to build in parallel at maximum." | 37 "How many packages to build in parallel at maximum." |
| 38 DEFINE_boolean statefuldev $FLAGS_FALSE \ | 38 DEFINE_boolean statefuldev $FLAGS_FALSE \ |
| 39 "Install development packages on stateful partition -- still experimental" | 39 "Install development packages on stateful partition -- still experimental" |
| 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 withtest $FLAGS_FALSE \ | 42 DEFINE_boolean withtest $FLAGS_FALSE \ |
| 43 "Include packages required for testing and prepare image for testing" | 43 "Include packages required for testing and prepare image for testing" |
| 44 DEFINE_string factory_server $FLAGS_FALSE \ |
| 45 "Build a factory install image pointing to given server." |
| 44 | 46 |
| 45 # Parse command line. | 47 # Parse command line. |
| 46 FLAGS "$@" || exit 1 | 48 FLAGS "$@" || exit 1 |
| 47 eval set -- "${FLAGS_ARGV}" | 49 eval set -- "${FLAGS_ARGV}" |
| 48 | 50 |
| 49 # Only now can we die on error. shflags functions leak non-zero error codes, | 51 # Only now can we die on error. shflags functions leak non-zero error codes, |
| 50 # so will die prematurely if 'set -e' is specified before now. | 52 # so will die prematurely if 'set -e' is specified before now. |
| 51 set -e | 53 set -e |
| 52 | 54 |
| 53 if [ -z "$FLAGS_board" ] ; then | 55 if [ -z "$FLAGS_board" ] ; then |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 # Install development packages. | 292 # Install development packages. |
| 291 if [[ $FLAGS_withdev -eq $FLAGS_TRUE ]] ; then | 293 if [[ $FLAGS_withdev -eq $FLAGS_TRUE ]] ; then |
| 292 sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \ | 294 sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \ |
| 293 --root="$ROOT_DEV_DIR" --root-deps=rdeps \ | 295 --root="$ROOT_DEV_DIR" --root-deps=rdeps \ |
| 294 --usepkgonly chromeos-dev $EMERGE_JOBS | 296 --usepkgonly chromeos-dev $EMERGE_JOBS |
| 295 | 297 |
| 296 # The ldd tool is a useful shell script but lives in glibc; just copy it. | 298 # The ldd tool is a useful shell script but lives in glibc; just copy it. |
| 297 sudo cp -a "$(which ldd)" "${ROOT_DEV_DIR}/usr/bin" | 299 sudo cp -a "$(which ldd)" "${ROOT_DEV_DIR}/usr/bin" |
| 298 fi | 300 fi |
| 299 | 301 |
| 302 if [ -n "$FLAGS_factory_server" ]; then |
| 303 sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \ |
| 304 --root="$ROOT_DEV_DIR" --root-deps=rdeps \ |
| 305 --usepkgonly chromeos-factoryinstall $EMERGE_JOBS |
| 306 fi |
| 307 |
| 300 # Install packages required for testing. | 308 # Install packages required for testing. |
| 301 if [[ $FLAGS_withtest -eq $FLAGS_TRUE ]] ; then | 309 if [[ $FLAGS_withtest -eq $FLAGS_TRUE ]] ; then |
| 302 sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \ | 310 sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \ |
| 303 --root="$ROOT_DEV_DIR" --root-deps=rdeps \ | 311 --root="$ROOT_DEV_DIR" --root-deps=rdeps \ |
| 304 --usepkgonly chromeos-test $EMERGE_JOBS | 312 --usepkgonly chromeos-test $EMERGE_JOBS |
| 305 fi | 313 fi |
| 306 | 314 |
| 307 # Clean up links setup for stateful install of extra packages. | 315 # Clean up links setup for stateful install of extra packages. |
| 308 if [ $FLAGS_statefuldev -eq $FLAGS_TRUE ] ; then | 316 if [ $FLAGS_statefuldev -eq $FLAGS_TRUE ] ; then |
| 309 # Fix symlinks so they work on live system. | 317 # Fix symlinks so they work on live system. |
| 310 for path in bin include lib libexec sbin share; do | 318 for path in bin include lib libexec sbin share; do |
| 311 sudo unlink $DEV_IMAGE_ROOT/usr/$path | 319 sudo unlink $DEV_IMAGE_ROOT/usr/$path |
| 312 sudo ln -s /usr/local/$path $DEV_IMAGE_ROOT/usr/$path | 320 sudo ln -s /usr/local/$path $DEV_IMAGE_ROOT/usr/$path |
| 313 done | 321 done |
| 314 | 322 |
| 315 # Fix exceptions. | 323 # Fix exceptions. |
| 316 sudo unlink "$DEV_IMAGE_ROOT/usr/lib64" | 324 sudo unlink "$DEV_IMAGE_ROOT/usr/lib64" |
| 317 sudo unlink "$DEV_IMAGE_ROOT/usr/local" | 325 sudo unlink "$DEV_IMAGE_ROOT/usr/local" |
| 318 | 326 |
| 319 sudo ln -s "/usr/local/lib" "$DEV_IMAGE_ROOT/usr/lib64" | 327 sudo ln -s "/usr/local/lib" "$DEV_IMAGE_ROOT/usr/lib64" |
| 320 sudo ln -s "/usr/local" "$DEV_IMAGE_ROOT/usr/local" | 328 sudo ln -s "/usr/local" "$DEV_IMAGE_ROOT/usr/local" |
| 321 | 329 |
| 322 #TODO(sosa@chromium.org) - /usr/bin/xterm symlink not created in stateful. | 330 #TODO(sosa@chromium.org) - /usr/bin/xterm symlink not created in stateful. |
| 323 sudo ln -sf "/usr/local/bin/aterm" "/usr/bin/xterm" | 331 sudo ln -sf "/usr/local/bin/aterm" "/usr/bin/xterm" |
| 324 fi | 332 fi |
| 325 | 333 |
| 326 # Perform any customizations on the root file system that are needed. | 334 # Perform any customizations on the root file system that are needed. |
| 327 WITH_DEV="" | 335 EXTRA_CUSTOMIZE_ROOTFS_FLAGS="" |
| 328 if [[ $FLAGS_withdev -eq $FLAGS_TRUE ]]; then | 336 if [ $FLAGS_withdev -eq $FLAGS_TRUE ]; then |
| 329 WITH_DEV="--withdev" | 337 EXTRA_CUSTOMIZE_ROOTFS_FLAGS="--withdev" |
| 338 fi |
| 339 if [ -n "$FLAGS_factory_server" ]; then |
| 340 # Indentation off b/c of long line |
| 341 EXTRA_CUSTOMIZE_ROOTFS_FLAGS="$EXTRA_CUSTOMIZE_ROOTFS_FLAGS"\ |
| 342 " --factory_server=$FLAGS_factory_server" |
| 330 fi | 343 fi |
| 331 | 344 |
| 332 # Extract the kernel from the root filesystem for use by the GPT image. Legacy | 345 # Extract the kernel from the root filesystem for use by the GPT image. Legacy |
| 333 # BIOS will use the kernel in the rootfs (via syslinux), Chrome OS BIOS will | 346 # BIOS will use the kernel in the rootfs (via syslinux), Chrome OS BIOS will |
| 334 # use the kernel partition. | 347 # use the kernel partition. |
| 335 sudo cp -f "${ROOT_FS_DIR}/boot/vmlinuz" "${OUTPUT_DIR}/vmlinuz.image" | 348 sudo cp -f "${ROOT_FS_DIR}/boot/vmlinuz" "${OUTPUT_DIR}/vmlinuz.image" |
| 336 | 349 |
| 337 # Create EFI System Partition to boot stock EFI BIOS (but not ChromeOS EFI | 350 # Create EFI System Partition to boot stock EFI BIOS (but not ChromeOS EFI |
| 338 # BIOS). We only need this for x86, but it's simpler and safer to keep the disk | 351 # BIOS). We only need this for x86, but it's simpler and safer to keep the disk |
| 339 # images the same for both x86 and ARM. | 352 # images the same for both x86 and ARM. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 356 menuentry "32-bit serial" { | 369 menuentry "32-bit serial" { |
| 357 linux /efi/boot/vmlinuz earlyprintk=serial,ttyS0,115200 i915.modeset=0 console
=ttyS0,115200 acpi=off init=/sbin/init boot=local rootwait root=/dev/sda3 ro nor
esume noswap loglevel=7 | 370 linux /efi/boot/vmlinuz earlyprintk=serial,ttyS0,115200 i915.modeset=0 console
=ttyS0,115200 acpi=off init=/sbin/init boot=local rootwait root=/dev/sda3 ro nor
esume noswap loglevel=7 |
| 358 } | 371 } |
| 359 EOF | 372 EOF |
| 360 | 373 |
| 361 #TODO(sosa@chromium.org) - Does it make sense to leave /usr/local bound here? | 374 #TODO(sosa@chromium.org) - Does it make sense to leave /usr/local bound here? |
| 362 "${SCRIPTS_DIR}/customize_rootfs" \ | 375 "${SCRIPTS_DIR}/customize_rootfs" \ |
| 363 --root="$ROOT_FS_DIR" \ | 376 --root="$ROOT_FS_DIR" \ |
| 364 --target="$ARCH" \ | 377 --target="$ARCH" \ |
| 365 --board="$BOARD" \ | 378 --board="$BOARD" \ |
| 366 $WITH_DEV | 379 $EXTRA_CUSTOMIZE_ROOTFS_FLAGS |
| 367 | 380 |
| 368 # Check that the image has been correctly created. | 381 # Check that the image has been correctly created. |
| 369 "${SCRIPTS_DIR}/test_image" \ | 382 "${SCRIPTS_DIR}/test_image" \ |
| 370 --root="$ROOT_FS_DIR" \ | 383 --root="$ROOT_FS_DIR" \ |
| 371 --target="$ARCH" | 384 --target="$ARCH" |
| 372 | 385 |
| 373 # Set dev_mode flag and update library cache. | 386 # Set dev_mode flag and update library cache. |
| 374 if [ $FLAGS_statefuldev -eq $FLAGS_TRUE ] ; then | 387 if [ $FLAGS_statefuldev -eq $FLAGS_TRUE ] ; then |
| 375 sudo touch "$ROOT_FS_DIR/root/.dev_mode" | 388 sudo touch "$ROOT_FS_DIR/root/.dev_mode" |
| 376 sudo /sbin/ldconfig -r "$ROOT_FS_DIR" | 389 sudo /sbin/ldconfig -r "$ROOT_FS_DIR" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 398 | 411 |
| 399 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" | 412 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" |
| 400 echo "Done. Image created in ${OUTPUT_DIR}" | 413 echo "Done. Image created in ${OUTPUT_DIR}" |
| 401 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" | 414 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" |
| 402 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdb" | 415 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdb" |
| 403 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" | 416 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" |
| 404 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" | 417 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" |
| 405 echo "from the scripts directory where you entered the chroot." | 418 echo "from the scripts directory where you entered the chroot." |
| 406 | 419 |
| 407 trap - EXIT | 420 trap - EXIT |
| OLD | NEW |