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 PV_CAT for convenience | |
18 PV_OK=1 | |
sosa
2010/11/30 22:01:43
These vars are pretty short, watch out for name co
sjg
2010/12/01 00:57:05
Done
| |
19 PV_CAT=pv | |
20 pv -V >/dev/null || PV_OK=0 | |
21 if [ $PV_OK -eq 0 ]; then | |
22 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 | |
sosa
2010/11/30 22:01:43
Check for name collisions in other files
| |
140 CHROMEOS_IMAGE_NAME="chromiumos_image.bin" | |
141 CHROMEOS_TEST_IMAGE_NAME="chromiumos_test_image.bin" | |
142 | |
sjg
2010/12/01 00:57:05
There are none.
cd .../src/scripts
grep CHROMEOS_
| |
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, SRC_IMAGE should contain the image pathname to modify | |
553 # On exit, SRC_IMAGE contains the pathname of the resulting test image | |
sosa
2010/11/30 22:01:43
Treat this more like a function ... i.e. don't mo
sjg
2010/12/01 00:57:05
Actually this is hard, because mod_image_for_test
sjg
2010/12/01 20:02:31
OK have piped the script to stderr as you suggest.
| |
554 | |
555 prepare_test_image() { | |
sosa
2010/11/30 22:01:43
Indent
| |
556 # If we're asked to modify the image for test, then let's make a copy and | |
557 # modify that instead. | |
558 # Check for manufacturing image. | |
559 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then | |
560 EXTRA_ARGS="--factory" | |
sosa
2010/11/30 22:01:43
use locals
| |
561 fi | |
562 | |
563 # Check for install shim. | |
564 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then | |
sosa
2010/11/30 22:01:43
style is no space between ] and ;. This has chang
| |
565 EXTRA_ARGS="--factory_install" | |
566 fi | |
567 | |
568 # Check for forcing copy of image | |
569 if [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then | |
570 EXTRA_ARGS+="--force_copy" | |
sosa
2010/11/30 22:01:43
Does this work? +=? Is that a bashism? Why not
| |
571 fi | |
572 | |
573 # modified the image for test, creating a new test image | |
sosa
2010/11/30 22:01:43
s/m/M
| |
574 "${SCRIPTS_DIR}/mod_image_for_test.sh" --board=${FLAGS_board} --image \ | |
sosa
2010/11/30 22:01:43
Use = consistently in options
| |
575 "${SRC_IMAGE}" --noinplace ${EXTRA_ARGS} | |
576 | |
577 # from now on we use the just-created test image | |
sosa
2010/11/30 22:01:43
s/f/F
| |
578 SRC_IMAGE="${FLAGS_from}/${CHROMEOS_TEST_IMAGE_NAME}" | |
579 echo "Source test image is: ${SRC_IMAGE}" | |
580 } | |
OLD | NEW |