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 # Make sure we have the location and name of the calling script, using | 25 # Make sure we have the location and name of the calling script, using |
18 # the current value if it is already set. | 26 # the current value if it is already set. |
19 SCRIPT_LOCATION=${SCRIPT_LOCATION:-$(dirname "$(readlink -f "$0")")} | 27 SCRIPT_LOCATION=${SCRIPT_LOCATION:-$(dirname "$(readlink -f "$0")")} |
20 SCRIPT_NAME=${SCRIPT_NAME:-$(basename "$0")} | 28 SCRIPT_NAME=${SCRIPT_NAME:-$(basename "$0")} |
21 | 29 |
22 # Detect whether we're inside a chroot or not | 30 # Detect whether we're inside a chroot or not |
23 if [ -e /etc/debian_chroot ] | 31 if [ -e /etc/debian_chroot ] |
24 then | 32 then |
25 INSIDE_CHROOT=1 | 33 INSIDE_CHROOT=1 |
26 else | 34 else |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 fi | 146 fi |
139 # Strip CR | 147 # Strip CR |
140 ALL_BOARDS=$(echo $ALL_BOARDS) | 148 ALL_BOARDS=$(echo $ALL_BOARDS) |
141 # Set a default BOARD | 149 # Set a default BOARD |
142 #DEFAULT_BOARD=x86-generic # or... | 150 #DEFAULT_BOARD=x86-generic # or... |
143 DEFAULT_BOARD=$(echo $ALL_BOARDS | awk '{print $NF}') | 151 DEFAULT_BOARD=$(echo $ALL_BOARDS | awk '{print $NF}') |
144 | 152 |
145 # Enable --fast by default. | 153 # Enable --fast by default. |
146 DEFAULT_FAST=${FLAGS_TRUE} | 154 DEFAULT_FAST=${FLAGS_TRUE} |
147 | 155 |
| 156 |
| 157 # Standard filenames |
| 158 CHROMEOS_IMAGE_NAME="chromiumos_image.bin" |
| 159 CHROMEOS_TEST_IMAGE_NAME="chromiumos_test_image.bin" |
| 160 |
| 161 |
148 # Directory locations inside the dev chroot | 162 # Directory locations inside the dev chroot |
149 CHROOT_TRUNK_DIR="/home/$USER/trunk" | 163 CHROOT_TRUNK_DIR="/home/$USER/trunk" |
150 | 164 |
151 # Install make for portage ebuilds. Used by build_image and gmergefs. | 165 # Install make for portage ebuilds. Used by build_image and gmergefs. |
152 # TODO: Is /usr/local/autotest-chrome still used by anyone? | 166 # TODO: Is /usr/local/autotest-chrome still used by anyone? |
153 DEFAULT_INSTALL_MASK=" | 167 DEFAULT_INSTALL_MASK=" |
154 *.a | 168 *.a |
155 *.la | 169 *.la |
156 /etc/init.d | 170 /etc/init.d |
157 /etc/runlevels | 171 /etc/runlevels |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 | 597 |
584 BOARD=$(echo "$flags_board" | cut -d '_' -f 1) | 598 BOARD=$(echo "$flags_board" | cut -d '_' -f 1) |
585 VARIANT=${flags_variant:-$(echo "$flags_board" | cut -s -d '_' -f 2)} | 599 VARIANT=${flags_variant:-$(echo "$flags_board" | cut -s -d '_' -f 2)} |
586 | 600 |
587 if [ -n "$VARIANT" ]; then | 601 if [ -n "$VARIANT" ]; then |
588 BOARD_VARIANT="${BOARD}_${VARIANT}" | 602 BOARD_VARIANT="${BOARD}_${VARIANT}" |
589 else | 603 else |
590 BOARD_VARIANT="${BOARD}" | 604 BOARD_VARIANT="${BOARD}" |
591 fi | 605 fi |
592 } | 606 } |
| 607 |
| 608 # This function converts a chromiumos image into a test image, either |
| 609 # in place or by copying to a new test image filename first. It honors |
| 610 # the following flags (see mod_image_for_test.sh) |
| 611 # |
| 612 # --factory |
| 613 # --factory_install |
| 614 # --force_copy |
| 615 # |
| 616 # On entry, pass the directory containing the image, and the image filename |
| 617 # On exit, it puts the pathname of the resulting test image into |
| 618 # CHROMEOS_RETURN_VAL |
| 619 # (yes this is ugly, but perhaps less ugly than the alternatives) |
| 620 # |
| 621 # Usage: |
| 622 # SRC_IMAGE=$(prepare_test_image "directory" "imagefile") |
| 623 prepare_test_image() { |
| 624 # If we're asked to modify the image for test, then let's make a copy and |
| 625 # modify that instead. |
| 626 # Check for manufacturing image. |
| 627 local args |
| 628 |
| 629 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then |
| 630 args="--factory" |
| 631 fi |
| 632 |
| 633 # Check for install shim. |
| 634 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then |
| 635 args="--factory_install" |
| 636 fi |
| 637 |
| 638 # Check for forcing copy of image |
| 639 if [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ]; then |
| 640 args="${args} --force_copy" |
| 641 fi |
| 642 |
| 643 # Modify the image for test, creating a new test image |
| 644 "${SCRIPTS_DIR}/mod_image_for_test.sh" --board=${FLAGS_board} \ |
| 645 --image="$1/$2" --noinplace ${args} |
| 646 |
| 647 # From now on we use the just-created test image |
| 648 CHROMEOS_RETURN_VAL="$1/${CHROMEOS_TEST_IMAGE_NAME}" |
| 649 } |
OLD | NEW |