Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # Common constants for build scripts | 5 # Common constants for build scripts |
| 6 # This must evaluate properly for both /bin/bash and /bin/sh | 6 # This must evaluate properly for both /bin/bash and /bin/sh |
| 7 | 7 |
| 8 # All scripts should die on error unless commands are specifically excepted | 8 # All scripts should die on error unless commands are specifically excepted |
| 9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'. | 9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'. |
| 10 # TODO: Re-enable this once shflags is less prone to dying. | 10 # TODO: Re-enable this once shflags is less prone to dying. |
| 11 #set -e | 11 #set -e |
| 12 | 12 |
| 13 # The number of jobs to pass to tools that can run in parallel (such as make | 13 # The number of jobs to pass to tools that can run in parallel (such as make |
| 14 # and dpkg-buildpackage | 14 # and dpkg-buildpackage |
| 15 NUM_JOBS=`grep -c "^processor" /proc/cpuinfo` | 15 NUM_JOBS=`grep -c "^processor" /proc/cpuinfo` |
| 16 | 16 |
| 17 # True if we have the 'pv' utility - also set up COMMON_PV_CAT for convenience | |
| 18 COMMON_PV_OK=1 | |
| 19 COMMON_PV_CAT=pv | |
| 20 pv -V >/dev/null 2>&1 || COMMON_PV_OK=0 | |
| 21 if [ $COMMON_PV_OK -eq 0 ]; then | |
| 22 COMMON_PV_CAT=cat | |
| 23 fi | |
| 24 | |
| 17 # Store location of the calling script. | 25 # Store location of the calling script. |
| 18 TOP_SCRIPT_DIR="${TOP_SCRIPT_DIR:-$(dirname $0)}" | 26 TOP_SCRIPT_DIR="${TOP_SCRIPT_DIR:-$(dirname $0)}" |
| 19 | 27 |
| 20 # Find root of source tree | 28 # Find root of source tree |
| 21 if [ "x$GCLIENT_ROOT" != "x" ] | 29 if [ "x$GCLIENT_ROOT" != "x" ] |
| 22 then | 30 then |
| 23 # GCLIENT_ROOT already set, so we're done | 31 # GCLIENT_ROOT already set, so we're done |
| 24 true | 32 true |
| 25 elif [ "x$COMMON_SH" != "x" ] | 33 elif [ "x$COMMON_SH" != "x" ] |
| 26 then | 34 then |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 fi | 128 fi |
| 121 | 129 |
| 122 # Detect whether we're inside a chroot or not | 130 # Detect whether we're inside a chroot or not |
| 123 if [ -e /etc/debian_chroot ] | 131 if [ -e /etc/debian_chroot ] |
| 124 then | 132 then |
| 125 INSIDE_CHROOT=1 | 133 INSIDE_CHROOT=1 |
| 126 else | 134 else |
| 127 INSIDE_CHROOT=0 | 135 INSIDE_CHROOT=0 |
| 128 fi | 136 fi |
| 129 | 137 |
| 138 | |
| 139 # Standard filenames | |
| 140 CHROMEOS_IMAGE_NAME="chromiumos_image.bin" | |
| 141 CHROMEOS_TEST_IMAGE_NAME="chromiumos_test_image.bin" | |
| 142 | |
| 143 | |
| 130 # Directory locations inside the dev chroot | 144 # Directory locations inside the dev chroot |
| 131 CHROOT_TRUNK_DIR="/home/$USER/trunk" | 145 CHROOT_TRUNK_DIR="/home/$USER/trunk" |
| 132 | 146 |
| 133 # Install make for portage ebuilds. Used by build_image and gmergefs. | 147 # Install make for portage ebuilds. Used by build_image and gmergefs. |
| 134 # TODO: Is /usr/local/autotest-chrome still used by anyone? | 148 # TODO: Is /usr/local/autotest-chrome still used by anyone? |
| 135 DEFAULT_INSTALL_MASK="/usr/include /usr/man /usr/share/man /usr/share/doc \ | 149 DEFAULT_INSTALL_MASK="/usr/include /usr/man /usr/share/man /usr/share/doc \ |
| 136 /usr/share/gtk-doc /usr/share/gtk-2.0 /usr/lib/gtk-2.0/include \ | 150 /usr/share/gtk-doc /usr/share/gtk-2.0 /usr/lib/gtk-2.0/include \ |
| 137 /usr/share/info /usr/share/aclocal /usr/lib/gcc /usr/lib/pkgconfig \ | 151 /usr/share/info /usr/share/aclocal /usr/lib/gcc /usr/lib/pkgconfig \ |
| 138 /usr/share/pkgconfig /usr/share/gettext /usr/share/readline /etc/runlevels \ | 152 /usr/share/pkgconfig /usr/share/gettext /usr/share/readline /etc/runlevels \ |
| 139 /usr/share/openrc /lib/rc *.a *.la /etc/init.d /usr/lib/debug | 153 /usr/share/openrc /lib/rc *.a *.la /etc/init.d /usr/lib/debug |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 chroot_hacks_from_outside() { | 533 chroot_hacks_from_outside() { |
| 520 # Give args better names. | 534 # Give args better names. |
| 521 local chroot_dir="${1}" | 535 local chroot_dir="${1}" |
| 522 | 536 |
| 523 # Add root as a sudoer if not already done. | 537 # Add root as a sudoer if not already done. |
| 524 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then | 538 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then |
| 525 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers" | 539 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers" |
| 526 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\"" | 540 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\"" |
| 527 fi | 541 fi |
| 528 } | 542 } |
| 543 | |
| 544 # This function converts a chromiumos image into a test image, either | |
| 545 # in place or by copying to a new test image filename first. It honors | |
| 546 # the following flags (see mod_image_for_test.sh) | |
| 547 # | |
| 548 # --factory | |
| 549 # --factory_install | |
| 550 # --force_copy | |
| 551 # | |
| 552 # On entry, pass the image pathname to modify | |
| 553 # On exit, it echoes the pathname of the resulting test image | |
| 554 # | |
| 555 # Usage: | |
| 556 # SRC_IMAGE=$(prepare_test_image "/path/to/image") | |
|
sosa
2010/12/01 20:37:45
Dcoument both $1 and $2 ... i only see $1 specifie
| |
| 557 | |
|
sosa
2010/12/01 20:37:45
Remove extra line here
| |
| 558 prepare_test_image() { | |
| 559 # If we're asked to modify the image for test, then let's make a copy and | |
| 560 # modify that instead. | |
| 561 # Check for manufacturing image. | |
| 562 local args | |
| 563 | |
| 564 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then | |
| 565 args="--factory" | |
| 566 fi | |
| 567 | |
| 568 # Check for install shim. | |
| 569 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then | |
|
sosa
2010/12/01 20:37:45
Just checking but these two can't be set at the sa
sjg
2010/12/01 20:54:00
Yes I noticed this - I copied the code as before.
| |
| 570 args="--factory_install" | |
| 571 fi | |
| 572 | |
| 573 # Check for forcing copy of image | |
| 574 if [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ]; then | |
| 575 args="$args --force_copy" | |
|
sosa
2010/12/01 20:37:45
${args}
| |
| 576 fi | |
| 577 | |
| 578 # Modify the image for test, creating a new test image | |
| 579 "${SCRIPTS_DIR}/mod_image_for_test.sh" --board=${FLAGS_board} --image=\ | |
|
sosa
2010/12/01 20:37:45
I believe having the = at the break point will fai
sjg
2010/12/01 20:54:00
It seems to work, but I have changed it
| |
| 580 "$1/$2" --noinplace ${args} >/dev/stderr | |
| 581 | |
| 582 # From now on we use the just-created test image | |
| 583 echo "$1/${CHROMEOS_TEST_IMAGE_NAME}" | |
| 584 } | |
| OLD | NEW |