David McMahon | 4930294 | 2010-02-18 16:55:35 -0800 | [diff] [blame] | 1 | # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | # Common constants for build scripts |
| 6 | # This must evaluate properly for both /bin/bash and /bin/sh |
| 7 | |
| 8 | # All scripts should die on error unless commands are specifically excepted |
| 9 | # by prefixing with '!' or surrounded by 'set +e' / 'set -e'. |
| 10 | # TODO: Re-enable this once shflags is less prone to dying. |
| 11 | #set -e |
| 12 | |
| 13 | # The number of jobs to pass to tools that can run in parallel (such as make |
| 14 | # and dpkg-buildpackage |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 15 | NUM_JOBS=$(grep -c "^processor" /proc/cpuinfo) |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 16 | |
Simon Glass | 142ca06 | 2011-02-09 13:39:43 -0800 | [diff] [blame] | 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 | |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 25 | # Make sure we have the location and name of the calling script, using |
| 26 | # the current value if it is already set. |
| 27 | SCRIPT_LOCATION=${SCRIPT_LOCATION:-$(dirname "$(readlink -f "$0")")} |
| 28 | SCRIPT_NAME=${SCRIPT_NAME:-$(basename "$0")} |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 29 | |
Anton Staaf | 30acb0b | 2011-01-26 16:00:20 -0800 | [diff] [blame] | 30 | # Detect whether we're inside a chroot or not |
| 31 | if [ -e /etc/debian_chroot ] |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 32 | then |
Anton Staaf | 30acb0b | 2011-01-26 16:00:20 -0800 | [diff] [blame] | 33 | INSIDE_CHROOT=1 |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 34 | else |
Anton Staaf | 30acb0b | 2011-01-26 16:00:20 -0800 | [diff] [blame] | 35 | INSIDE_CHROOT=0 |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 36 | fi |
| 37 | |
Anton Staaf | 30acb0b | 2011-01-26 16:00:20 -0800 | [diff] [blame] | 38 | # Construct a list of possible locations for the source tree. This list is |
| 39 | # based on various environment variables and globals that may have been set |
| 40 | # by the calling script. |
| 41 | function get_gclient_root_list() { |
| 42 | if [ $INSIDE_CHROOT -eq 1 ]; then |
| 43 | echo "/home/${USER}/trunk" |
| 44 | |
| 45 | if [ -n "${SUDO_USER}" ]; then echo "/home/${SUDO_USER}/trunk"; fi |
| 46 | fi |
| 47 | |
| 48 | if [ -n "${COMMON_SH}" ]; then echo "$(dirname "$COMMON_SH")/../.."; fi |
| 49 | if [ -n "${BASH_SOURCE}" ]; then echo "$(dirname "$BASH_SOURCE")/../.."; fi |
| 50 | } |
| 51 | |
| 52 | # Based on the list of possible source locations we set GCLIENT_ROOT if it is |
| 53 | # not already defined by looking for a src directory in each seach path |
| 54 | # location. If we do not find a valid looking root we error out. |
| 55 | function get_gclient_root() { |
| 56 | if [ -n "${GCLIENT_ROOT}" ]; then |
| 57 | return |
| 58 | fi |
| 59 | |
| 60 | for path in $(get_gclient_root_list); do |
| 61 | if [ -d "${path}/src" ]; then |
| 62 | GCLIENT_ROOT=${path} |
| 63 | break |
| 64 | fi |
| 65 | done |
| 66 | |
| 67 | if [ -z "${GCLIENT_ROOT}" ]; then |
| 68 | # Using dash or sh, we don't know where we are. $0 refers to the calling |
| 69 | # script, not ourselves, so that doesn't help us. |
| 70 | echo "Unable to determine location for common.sh. If you are sourcing" |
| 71 | echo "common.sh from a script run via dash or sh, you must do it in the" |
| 72 | echo "following way:" |
| 73 | echo ' COMMON_SH="$(dirname "$0")/../../scripts/common.sh"' |
| 74 | echo ' . "$COMMON_SH"' |
| 75 | echo "where the first line is the relative path from your script to" |
| 76 | echo "common.sh." |
| 77 | exit 1 |
| 78 | fi |
| 79 | } |
| 80 | |
| 81 | # Find root of source tree |
| 82 | get_gclient_root |
| 83 | |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 84 | # Canonicalize the directories for the root dir and the calling script. |
| 85 | # readlink is part of coreutils and should be present even in a bare chroot. |
tedbo | 4f44d9e | 2010-01-08 17:26:11 -0800 | [diff] [blame] | 86 | # This is better than just using |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 87 | # FOO = "$(cd $FOO ; pwd)" |
tedbo | 4f44d9e | 2010-01-08 17:26:11 -0800 | [diff] [blame] | 88 | # since that leaves symbolic links intact. |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 89 | # Note that 'realpath' is equivalent to 'readlink -f'. |
Mike Frysinger | a1a06ab | 2011-08-10 11:40:30 -0400 | [diff] [blame^] | 90 | SCRIPT_LOCATION=$(readlink -f "$SCRIPT_LOCATION") |
| 91 | GCLIENT_ROOT=$(readlink -f "$GCLIENT_ROOT") |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 92 | |
| 93 | # Other directories should always be pathed down from GCLIENT_ROOT. |
| 94 | SRC_ROOT="$GCLIENT_ROOT/src" |
| 95 | SRC_INTERNAL="$GCLIENT_ROOT/src-internal" |
| 96 | SCRIPTS_DIR="$SRC_ROOT/scripts" |
| 97 | |
| 98 | # Load developer's custom settings. Default location is in scripts dir, |
| 99 | # since that's available both inside and outside the chroot. By convention, |
| 100 | # settings from this file are variables starting with 'CHROMEOS_' |
| 101 | CHROMEOS_DEV_SETTINGS="${CHROMEOS_DEV_SETTINGS:-$SCRIPTS_DIR/.chromeos_dev}" |
Mike Frysinger | a1a06ab | 2011-08-10 11:40:30 -0400 | [diff] [blame^] | 102 | if [ -f "$CHROMEOS_DEV_SETTINGS" ]; then |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 103 | # Turn on exit-on-error during custom settings processing |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 104 | SAVE_OPTS=$(set +o) |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 105 | set -e |
| 106 | |
| 107 | # Read settings |
Mike Frysinger | a1a06ab | 2011-08-10 11:40:30 -0400 | [diff] [blame^] | 108 | . "$CHROMEOS_DEV_SETTINGS" |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 109 | |
| 110 | # Restore previous state of exit-on-error |
| 111 | eval "$SAVE_OPTS" |
| 112 | fi |
| 113 | |
| 114 | # Load shflags |
Anush Elangovan | 56de1dd | 2010-08-02 23:56:07 -0700 | [diff] [blame] | 115 | if [[ -f /usr/lib/shflags ]]; then |
| 116 | . /usr/lib/shflags |
Raja Aluri | c6e23cd | 2010-11-02 15:55:57 -0700 | [diff] [blame] | 117 | elif [ -f ./lib/shflags/shflags ]; then |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 118 | . ./lib/shflags/shflags |
Anush Elangovan | 56de1dd | 2010-08-02 23:56:07 -0700 | [diff] [blame] | 119 | else |
| 120 | . "${SRC_ROOT}/scripts/lib/shflags/shflags" |
| 121 | fi |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 122 | |
Bill Richardson | 10d27c2 | 2010-01-20 13:38:50 -0800 | [diff] [blame] | 123 | # Our local mirror |
| 124 | DEFAULT_CHROMEOS_SERVER=${CHROMEOS_SERVER:-"http://build.chromium.org/mirror"} |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 125 | |
Bill Richardson | 10d27c2 | 2010-01-20 13:38:50 -0800 | [diff] [blame] | 126 | # Upstream mirrors and build suites come in 2 flavors |
| 127 | # DEV - development chroot, used to build the chromeos image |
| 128 | # IMG - bootable image, to run on actual hardware |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 129 | |
Bill Richardson | 10d27c2 | 2010-01-20 13:38:50 -0800 | [diff] [blame] | 130 | DEFAULT_DEV_MIRROR=${CHROMEOS_DEV_MIRROR:-"${DEFAULT_CHROMEOS_SERVER}/ubuntu"} |
| 131 | DEFAULT_DEV_SUITE=${CHROMEOS_DEV_SUITE:-"karmic"} |
| 132 | |
| 133 | DEFAULT_IMG_MIRROR=${CHROMEOS_IMG_MIRROR:-"${DEFAULT_CHROMEOS_SERVER}/ubuntu"} |
| 134 | DEFAULT_IMG_SUITE=${CHROMEOS_IMG_SUITE:-"karmic"} |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 135 | |
| 136 | # Default location for chroot |
| 137 | DEFAULT_CHROOT_DIR=${CHROMEOS_CHROOT_DIR:-"$GCLIENT_ROOT/chroot"} |
| 138 | |
| 139 | # All output files from build should go under $DEFAULT_BUILD_ROOT, so that |
| 140 | # they don't pollute the source directory. |
| 141 | DEFAULT_BUILD_ROOT=${CHROMEOS_BUILD_ROOT:-"$SRC_ROOT/build"} |
| 142 | |
David McMahon | 4930294 | 2010-02-18 16:55:35 -0800 | [diff] [blame] | 143 | # Set up a global ALL_BOARDS value |
Mike Frysinger | a1a06ab | 2011-08-10 11:40:30 -0400 | [diff] [blame^] | 144 | if [ -d "$SRC_ROOT/overlays" ]; then |
| 145 | ALL_BOARDS=$(cd "$SRC_ROOT/overlays"; \ |
| 146 | ls -1d overlay-* 2>&- | sed 's,overlay-,,g') |
David Rochberg | 3b91070 | 2010-12-02 10:45:21 -0500 | [diff] [blame] | 147 | fi |
David McMahon | 4930294 | 2010-02-18 16:55:35 -0800 | [diff] [blame] | 148 | # Strip CR |
| 149 | ALL_BOARDS=$(echo $ALL_BOARDS) |
| 150 | # Set a default BOARD |
| 151 | #DEFAULT_BOARD=x86-generic # or... |
| 152 | DEFAULT_BOARD=$(echo $ALL_BOARDS | awk '{print $NF}') |
| 153 | |
David James | ff07201 | 2010-11-30 13:22:05 -0800 | [diff] [blame] | 154 | # Enable --fast by default. |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 155 | DEFAULT_FAST=${FLAGS_TRUE} |
David James | 0366864 | 2010-07-28 17:08:29 -0700 | [diff] [blame] | 156 | |
Simon Glass | 142ca06 | 2011-02-09 13:39:43 -0800 | [diff] [blame] | 157 | |
| 158 | # Standard filenames |
| 159 | CHROMEOS_IMAGE_NAME="chromiumos_image.bin" |
| 160 | CHROMEOS_TEST_IMAGE_NAME="chromiumos_test_image.bin" |
Chris Sosa | b885b80 | 2011-02-16 15:33:11 -0800 | [diff] [blame] | 161 | CHROMEOS_FACTORY_TEST_IMAGE_NAME="chromiumos_factory_image.bin" |
Simon Glass | 142ca06 | 2011-02-09 13:39:43 -0800 | [diff] [blame] | 162 | |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 163 | # Directory locations inside the dev chroot |
| 164 | CHROOT_TRUNK_DIR="/home/$USER/trunk" |
| 165 | |
Chris Sosa | aa1a7fd | 2010-04-02 14:06:29 -0700 | [diff] [blame] | 166 | # Install make for portage ebuilds. Used by build_image and gmergefs. |
Chris Masone | d11ce17 | 2010-11-09 14:22:08 -0800 | [diff] [blame] | 167 | # TODO: Is /usr/local/autotest-chrome still used by anyone? |
Daniel Erat | e82f07c | 2010-12-21 13:39:22 -0800 | [diff] [blame] | 168 | DEFAULT_INSTALL_MASK=" |
| 169 | *.a |
| 170 | *.la |
| 171 | /etc/init.d |
| 172 | /etc/runlevels |
| 173 | /lib/rc |
| 174 | /usr/bin/Xnest |
| 175 | /usr/bin/Xvfb |
| 176 | /usr/include |
| 177 | /usr/lib/debug |
| 178 | /usr/lib/gcc |
| 179 | /usr/lib/gtk-2.0/include |
| 180 | /usr/lib/pkgconfig |
| 181 | /usr/local/autotest |
| 182 | /usr/local/autotest-chrome |
| 183 | /usr/man |
| 184 | /usr/share/aclocal |
| 185 | /usr/share/doc |
| 186 | /usr/share/gettext |
| 187 | /usr/share/gtk-2.0 |
| 188 | /usr/share/gtk-doc |
| 189 | /usr/share/info |
| 190 | /usr/share/man |
| 191 | /usr/share/openrc |
| 192 | /usr/share/pkgconfig |
| 193 | /usr/share/readline |
Chris Wolfe | d13775f | 2011-07-26 16:34:38 -0400 | [diff] [blame] | 194 | /usr/src |
Daniel Erat | e82f07c | 2010-12-21 13:39:22 -0800 | [diff] [blame] | 195 | " |
Chris Sosa | aa1a7fd | 2010-04-02 14:06:29 -0700 | [diff] [blame] | 196 | |
Daniel Erat | e82f07c | 2010-12-21 13:39:22 -0800 | [diff] [blame] | 197 | FACTORY_INSTALL_MASK=" |
| 198 | /opt/Qualcomm |
| 199 | /opt/Synaptics |
| 200 | /opt/google/chrome |
| 201 | /opt/google/o3d |
| 202 | /opt/google/talkplugin |
| 203 | /opt/netscape |
| 204 | /usr/lib/debug |
| 205 | /usr/lib/dri |
| 206 | /usr/lib/python2.6/test |
| 207 | /usr/local/autotest |
| 208 | /usr/local/autotest-chrome |
| 209 | /usr/local/autotest-pkgs |
| 210 | /usr/share/X11 |
| 211 | /usr/share/chewing |
| 212 | /usr/share/fonts |
| 213 | /usr/share/ibus-pinyin |
| 214 | /usr/share/libhangul |
| 215 | /usr/share/locale |
| 216 | /usr/share/m17n |
| 217 | /usr/share/mime |
| 218 | /usr/share/sounds |
| 219 | /usr/share/tts |
| 220 | /usr/share/zoneinfo |
| 221 | " |
Tom Wai-Hong Tam | f87a367 | 2010-05-17 16:06:33 +0800 | [diff] [blame] | 222 | |
Gaurav Shah | 786ceeb | 2011-07-26 15:03:37 -0700 | [diff] [blame] | 223 | # Determine and set up variables needed for fancy color output (if supported). |
Gaurav Shah | 786ceeb | 2011-07-26 15:03:37 -0700 | [diff] [blame] | 224 | V_BOLD_RED= |
| 225 | V_BOLD_GREEN= |
| 226 | V_BOLD_YELLOW= |
Mike Frysinger | c2474ae | 2011-08-11 18:27:44 -0400 | [diff] [blame] | 227 | V_REVERSE= |
| 228 | V_VIDOFF= |
Gaurav Shah | 786ceeb | 2011-07-26 15:03:37 -0700 | [diff] [blame] | 229 | |
| 230 | if tput colors >/dev/null 2>&1; then |
Mike Frysinger | c2474ae | 2011-08-11 18:27:44 -0400 | [diff] [blame] | 231 | # order matters: we want VIDOFF last so that when we trace with `set -x`, |
| 232 | # our terminal doesn't bleed colors as bash dumps the values of vars. |
Gaurav Shah | 786ceeb | 2011-07-26 15:03:37 -0700 | [diff] [blame] | 233 | V_BOLD_RED="$(tput bold; tput setaf 1)" |
| 234 | V_BOLD_GREEN="$(tput bold; tput setaf 2)" |
| 235 | V_BOLD_YELLOW="$(tput bold; tput setaf 3)" |
Mike Frysinger | c2474ae | 2011-08-11 18:27:44 -0400 | [diff] [blame] | 236 | V_REVERSE="$(tput rev)" |
| 237 | V_VIDOFF="$(tput sgr0)" |
Gaurav Shah | 786ceeb | 2011-07-26 15:03:37 -0700 | [diff] [blame] | 238 | fi |
David McMahon | b7eb3a2 | 2010-02-09 14:07:40 -0800 | [diff] [blame] | 239 | |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 240 | # ----------------------------------------------------------------------------- |
| 241 | # Functions |
| 242 | |
Chris Sosa | acada73 | 2010-02-23 15:20:03 -0800 | [diff] [blame] | 243 | function setup_board_warning { |
tedbo | 373c390 | 2010-04-12 10:52:40 -0700 | [diff] [blame] | 244 | echo |
| 245 | echo "$V_REVERSE================= WARNING ======================$V_VIDOFF" |
Chris Sosa | acada73 | 2010-02-23 15:20:03 -0800 | [diff] [blame] | 246 | echo |
| 247 | echo "*** No default board detected in " \ |
| 248 | "$GCLIENT_ROOT/src/scripts/.default_board" |
| 249 | echo "*** Either run setup_board with default flag set" |
| 250 | echo "*** or echo |board_name| > $GCLIENT_ROOT/src/scripts/.default_board" |
| 251 | echo |
| 252 | } |
| 253 | |
| 254 | |
| 255 | # Sets the default board variable for calling script |
| 256 | function get_default_board { |
tedbo | 373c390 | 2010-04-12 10:52:40 -0700 | [diff] [blame] | 257 | DEFAULT_BOARD= |
| 258 | |
Chris Sosa | acada73 | 2010-02-23 15:20:03 -0800 | [diff] [blame] | 259 | if [ -f "$GCLIENT_ROOT/src/scripts/.default_board" ] ; then |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 260 | DEFAULT_BOARD=$(cat "$GCLIENT_ROOT/src/scripts/.default_board") |
Chris Sosa | acada73 | 2010-02-23 15:20:03 -0800 | [diff] [blame] | 261 | fi |
| 262 | } |
| 263 | |
| 264 | |
Don Garrett | 640a058 | 2010-05-04 16:54:28 -0700 | [diff] [blame] | 265 | # Enter a chroot and restart the current script if needed |
| 266 | function restart_in_chroot_if_needed { |
David Rochberg | 3b91070 | 2010-12-02 10:45:21 -0500 | [diff] [blame] | 267 | # NB: Pass in ARGV: restart_in_chroot_if_needed "$@" |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 268 | if [ $INSIDE_CHROOT -ne 1 ]; then |
Chris Sosa | fd2cdec | 2011-03-24 16:06:59 -0700 | [diff] [blame] | 269 | # Get inside_chroot path for script. |
| 270 | local chroot_path="$(reinterpret_path_for_chroot "$0")" |
Don Garrett | 640a058 | 2010-05-04 16:54:28 -0700 | [diff] [blame] | 271 | exec $SCRIPTS_DIR/enter_chroot.sh -- \ |
Chris Sosa | fd2cdec | 2011-03-24 16:06:59 -0700 | [diff] [blame] | 272 | "$chroot_path" "$@" |
Don Garrett | 640a058 | 2010-05-04 16:54:28 -0700 | [diff] [blame] | 273 | fi |
| 274 | } |
| 275 | |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 276 | # Fail unless we're inside the chroot. This guards against messing up your |
| 277 | # workstation. |
| 278 | function assert_inside_chroot { |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 279 | if [ $INSIDE_CHROOT -ne 1 ]; then |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 280 | echo "This script must be run inside the chroot. Run this first:" |
| 281 | echo " $SCRIPTS_DIR/enter_chroot.sh" |
| 282 | exit 1 |
| 283 | fi |
| 284 | } |
| 285 | |
| 286 | # Fail if we're inside the chroot. This guards against creating or entering |
| 287 | # nested chroots, among other potential problems. |
| 288 | function assert_outside_chroot { |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 289 | if [ $INSIDE_CHROOT -ne 0 ]; then |
rspangler@google.com | d74220d | 2009-10-09 20:56:14 +0000 | [diff] [blame] | 290 | echo "This script must be run outside the chroot." |
| 291 | exit 1 |
| 292 | fi |
| 293 | } |
| 294 | |
derat@google.com | 86dcc8e | 2009-11-21 19:49:49 +0000 | [diff] [blame] | 295 | function assert_not_root_user { |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 296 | if [ $(id -u) = 0 ]; then |
derat@google.com | 86dcc8e | 2009-11-21 19:49:49 +0000 | [diff] [blame] | 297 | echo "This script must be run as a non-root user." |
| 298 | exit 1 |
| 299 | fi |
| 300 | } |
| 301 | |
Luigi Semenzato | 1f82e12 | 2010-03-23 12:43:08 -0700 | [diff] [blame] | 302 | # Check that all arguments are flags; that is, there are no remaining arguments |
| 303 | # after parsing from shflags. Allow (with a warning) a single empty-string |
| 304 | # argument. |
| 305 | # |
| 306 | # TODO: fix buildbot so that it doesn't pass the empty-string parameter, |
| 307 | # then change this function. |
| 308 | # |
| 309 | # Usage: check_flags_only_and_allow_null_arg "$@" && set -- |
| 310 | function check_flags_only_and_allow_null_arg { |
| 311 | do_shift=1 |
| 312 | if [[ $# == 1 && -z "$@" ]]; then |
| 313 | echo "$0: warning: ignoring null argument" >&2 |
| 314 | shift |
| 315 | do_shift=0 |
| 316 | fi |
| 317 | if [[ $# -gt 0 ]]; then |
| 318 | echo "error: invalid arguments: \"$@\"" >&2 |
| 319 | flags_help |
| 320 | exit 1 |
| 321 | fi |
| 322 | return $do_shift |
| 323 | } |
| 324 | |
Chris Sosa | d979852 | 2010-06-16 14:29:50 -0700 | [diff] [blame] | 325 | function info { |
Anton Staaf | 6adf1a3 | 2011-03-02 10:13:14 -0800 | [diff] [blame] | 326 | echo -e >&2 "${V_BOLD_GREEN}INFO ${CROS_LOG_PREFIX:-""}: $1${V_VIDOFF}" |
Will Drewry | 55b42c9 | 2010-10-20 15:44:11 -0500 | [diff] [blame] | 327 | } |
Chris Sosa | d979852 | 2010-06-16 14:29:50 -0700 | [diff] [blame] | 328 | |
robotboy | 2ea03ac | 2010-02-11 15:30:55 -0800 | [diff] [blame] | 329 | function warn { |
Anton Staaf | 6adf1a3 | 2011-03-02 10:13:14 -0800 | [diff] [blame] | 330 | echo -e >&2 "${V_BOLD_YELLOW}WARNING ${CROS_LOG_PREFIX:-""}: $1${V_VIDOFF}" |
robotboy | 2ea03ac | 2010-02-11 15:30:55 -0800 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | function error { |
Anton Staaf | 6adf1a3 | 2011-03-02 10:13:14 -0800 | [diff] [blame] | 334 | echo -e >&2 "${V_BOLD_RED}ERROR ${CROS_LOG_PREFIX:-""}: $1${V_VIDOFF}" |
robotboy | 2ea03ac | 2010-02-11 15:30:55 -0800 | [diff] [blame] | 335 | } |
David James | 546747b | 2010-03-23 15:19:43 -0700 | [diff] [blame] | 336 | |
| 337 | function die { |
| 338 | error "$1" |
| 339 | exit 1 |
| 340 | } |
Chris Sosa | aa1a7fd | 2010-04-02 14:06:29 -0700 | [diff] [blame] | 341 | |
| 342 | # Retry an emerge command according to $FLAGS_retries |
David James | fd7403a | 2010-07-09 12:00:17 -0700 | [diff] [blame] | 343 | # The $EMERGE_JOBS flags will only be added the first time the command is run |
Chris Sosa | aa1a7fd | 2010-04-02 14:06:29 -0700 | [diff] [blame] | 344 | function eretry () { |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 345 | local i |
Chris Sosa | aa1a7fd | 2010-04-02 14:06:29 -0700 | [diff] [blame] | 346 | for i in $(seq $FLAGS_retries); do |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 347 | echo "Retrying $@" |
| 348 | "$@" $EMERGE_JOBS && return 0 |
Chris Sosa | aa1a7fd | 2010-04-02 14:06:29 -0700 | [diff] [blame] | 349 | done |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 350 | "$@" && return 0 |
Chris Sosa | aa1a7fd | 2010-04-02 14:06:29 -0700 | [diff] [blame] | 351 | return 1 |
| 352 | } |
| 353 | |
| 354 | # Removes single quotes around parameter |
| 355 | # Arguments: |
| 356 | # $1 - string which optionally has surrounding quotes |
| 357 | # Returns: |
| 358 | # None, but prints the string without quotes. |
| 359 | function remove_quotes() { |
| 360 | echo "$1" | sed -e "s/^'//; s/'$//" |
| 361 | } |
tedbo | 373c390 | 2010-04-12 10:52:40 -0700 | [diff] [blame] | 362 | |
| 363 | # Writes stdin to the given file name as root using sudo in overwrite mode. |
| 364 | # |
| 365 | # $1 - The output file name. |
| 366 | function sudo_clobber() { |
| 367 | sudo tee "$1" > /dev/null |
| 368 | } |
| 369 | |
| 370 | # Writes stdin to the given file name as root using sudo in append mode. |
| 371 | # |
| 372 | # $1 - The output file name. |
| 373 | function sudo_append() { |
| 374 | sudo tee -a "$1" > /dev/null |
| 375 | } |
robotboy | 9891221 | 2010-04-12 14:08:14 -0700 | [diff] [blame] | 376 | |
| 377 | # Unmounts a directory, if the unmount fails, warn, and then lazily unmount. |
| 378 | # |
| 379 | # $1 - The path to unmount. |
| 380 | function safe_umount { |
| 381 | path=${1:?} |
| 382 | shift |
| 383 | |
| 384 | if ! sudo umount -d "${path}"; then |
| 385 | warn "Failed to unmount ${path}" |
| 386 | warn "Doing a lazy unmount" |
| 387 | |
| 388 | sudo umount -d -l "${path}" || die "Failed to lazily unmount ${path}" |
| 389 | fi |
| 390 | } |
Chris Sosa | 702618f | 2010-05-14 12:52:32 -0700 | [diff] [blame] | 391 | |
Chris Sosa | d445502 | 2010-05-20 10:14:06 -0700 | [diff] [blame] | 392 | # Fixes symlinks that are incorrectly prefixed with the build root ${1} |
| 393 | # rather than the real running root '/'. |
| 394 | # TODO(sosa) - Merge setup - cleanup below with this method. |
| 395 | fix_broken_symlinks() { |
| 396 | local build_root="${1}" |
| 397 | local symlinks=$(find "${build_root}/usr/local" -lname "${build_root}/*") |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 398 | local symlink |
Chris Sosa | d445502 | 2010-05-20 10:14:06 -0700 | [diff] [blame] | 399 | for symlink in ${symlinks}; do |
| 400 | echo "Fixing ${symlink}" |
| 401 | local target=$(ls -l "${symlink}" | cut -f 2 -d '>') |
| 402 | # Trim spaces from target (bashism). |
| 403 | target=${target/ /} |
| 404 | # Make new target (removes rootfs prefix). |
| 405 | new_target=$(echo ${target} | sed "s#${build_root}##") |
| 406 | |
| 407 | echo "Fixing symlink ${symlink}" |
| 408 | sudo unlink "${symlink}" |
| 409 | sudo ln -sf "${new_target}" "${symlink}" |
| 410 | done |
| 411 | } |
| 412 | |
Chris Sosa | 702618f | 2010-05-14 12:52:32 -0700 | [diff] [blame] | 413 | # Sets up symlinks for the developer root. It is necessary to symlink |
| 414 | # usr and local since the developer root is mounted at /usr/local and |
| 415 | # applications expect to be installed under /usr/local/bin, etc. |
| 416 | # This avoids packages installing into /usr/local/usr/local/bin. |
| 417 | # ${1} specifies the symlink target for the developer root. |
| 418 | # ${2} specifies the symlink target for the var directory. |
| 419 | # ${3} specifies the location of the stateful partition. |
| 420 | setup_symlinks_on_root() { |
| 421 | # Give args better names. |
| 422 | local dev_image_target=${1} |
| 423 | local var_target=${2} |
| 424 | local dev_image_root="${3}/dev_image" |
| 425 | |
| 426 | # If our var target is actually the standard var, we are cleaning up the |
| 427 | # symlinks (could also check for /usr/local for the dev_image_target). |
| 428 | if [ ${var_target} = "/var" ]; then |
| 429 | echo "Cleaning up /usr/local symlinks for ${dev_image_root}" |
| 430 | else |
| 431 | echo "Setting up symlinks for /usr/local for ${dev_image_root}" |
| 432 | fi |
| 433 | |
| 434 | # Set up symlinks that should point to ${dev_image_target}. |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 435 | local path |
Chris Sosa | 702618f | 2010-05-14 12:52:32 -0700 | [diff] [blame] | 436 | for path in usr local; do |
| 437 | if [ -h "${dev_image_root}/${path}" ]; then |
| 438 | sudo unlink "${dev_image_root}/${path}" |
| 439 | elif [ -e "${dev_image_root}/${path}" ]; then |
| 440 | die "${dev_image_root}/${path} should be a symlink if exists" |
| 441 | fi |
Mike Frysinger | a1a06ab | 2011-08-10 11:40:30 -0400 | [diff] [blame^] | 442 | sudo ln -s "${dev_image_target}" "${dev_image_root}/${path}" |
Chris Sosa | 702618f | 2010-05-14 12:52:32 -0700 | [diff] [blame] | 443 | done |
| 444 | |
| 445 | # Setup var symlink. |
| 446 | if [ -h "${dev_image_root}/var" ]; then |
| 447 | sudo unlink "${dev_image_root}/var" |
| 448 | elif [ -e "${dev_image_root}/var" ]; then |
| 449 | die "${dev_image_root}/var should be a symlink if it exists" |
| 450 | fi |
| 451 | |
| 452 | sudo ln -s "${var_target}" "${dev_image_root}/var" |
| 453 | } |
Nick Sanders | d250927 | 2010-06-16 03:50:04 -0700 | [diff] [blame] | 454 | |
Will Drewry | 55b42c9 | 2010-10-20 15:44:11 -0500 | [diff] [blame] | 455 | # These two helpers clobber the ro compat value in our root filesystem. |
| 456 | # |
| 457 | # When the system is built with --enable_rootfs_verification, bit-precise |
| 458 | # integrity checking is performed. That precision poses a usability issue on |
| 459 | # systems that automount partitions with recognizable filesystems, such as |
| 460 | # ext2/3/4. When the filesystem is mounted 'rw', ext2 metadata will be |
| 461 | # automatically updated even if no other writes are performed to the |
| 462 | # filesystem. In addition, ext2+ does not support a "read-only" flag for a |
| 463 | # given filesystem. That said, forward and backward compatibility of |
| 464 | # filesystem features are supported by tracking if a new feature breaks r/w or |
| 465 | # just write compatibility. We abuse the read-only compatibility flag[1] in |
| 466 | # the filesystem header by setting the high order byte (le) to FF. This tells |
| 467 | # the kernel that features R24-R31 are all enabled. Since those features are |
| 468 | # undefined on all ext-based filesystem, all standard kernels will refuse to |
| 469 | # mount the filesystem as read-write -- only read-only[2]. |
| 470 | # |
| 471 | # [1] 32-bit flag we are modifying: |
| 472 | # http://git.chromium.org/cgi-bin/gitweb.cgi?p=kernel.git;a=blob;f=include/linux/ext2_fs.h#l417 |
| 473 | # [2] Mount behavior is enforced here: |
| 474 | # http://git.chromium.org/cgi-bin/gitweb.cgi?p=kernel.git;a=blob;f=fs/ext2/super.c#l857 |
| 475 | # |
| 476 | # N.B., if the high order feature bits are used in the future, we will need to |
| 477 | # revisit this technique. |
| 478 | disable_rw_mount() { |
| 479 | local rootfs="$1" |
| 480 | local offset="${2-0}" # in bytes |
Will Drewry | 9b7cb51 | 2010-10-20 18:11:24 -0500 | [diff] [blame] | 481 | local ro_compat_offset=$((0x464 + 3)) # Set 'highest' byte |
| 482 | printf '\377' | |
Will Drewry | 55b42c9 | 2010-10-20 15:44:11 -0500 | [diff] [blame] | 483 | sudo dd of="$rootfs" seek=$((offset + ro_compat_offset)) \ |
| 484 | conv=notrunc count=1 bs=1 |
| 485 | } |
| 486 | |
| 487 | enable_rw_mount() { |
| 488 | local rootfs="$1" |
| 489 | local offset="${2-0}" |
Will Drewry | 9b7cb51 | 2010-10-20 18:11:24 -0500 | [diff] [blame] | 490 | local ro_compat_offset=$((0x464 + 3)) # Set 'highest' byte |
| 491 | printf '\000' | |
Will Drewry | 55b42c9 | 2010-10-20 15:44:11 -0500 | [diff] [blame] | 492 | sudo dd of="$rootfs" seek=$((offset + ro_compat_offset)) \ |
| 493 | conv=notrunc count=1 bs=1 |
| 494 | } |
| 495 | |
Nick Sanders | d250927 | 2010-06-16 03:50:04 -0700 | [diff] [blame] | 496 | # Get current timestamp. Assumes common.sh runs at startup. |
| 497 | start_time=$(date +%s) |
| 498 | |
| 499 | # Print time elsapsed since start_time. |
| 500 | print_time_elapsed() { |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 501 | local end_time=$(date +%s) |
| 502 | local elapsed_seconds=$(($end_time - $start_time)) |
| 503 | local minutes=$(($elapsed_seconds / 60)) |
| 504 | local seconds=$(($elapsed_seconds % 60)) |
Olof Johansson | 6d49138 | 2010-08-09 16:05:50 -0500 | [diff] [blame] | 505 | echo "Elapsed time: ${minutes}m${seconds}s" |
Nick Sanders | d250927 | 2010-06-16 03:50:04 -0700 | [diff] [blame] | 506 | } |
Doug Anderson | 0c9e88d | 2010-10-19 14:49:39 -0700 | [diff] [blame] | 507 | |
Anton Staaf | 9bcd841 | 2011-01-24 15:27:14 -0800 | [diff] [blame] | 508 | # The board and variant command line options can be used in a number of ways |
| 509 | # to specify the board and variant. The board can encode both pieces of |
| 510 | # information separated by underscores. Or the variant can be passed using |
| 511 | # the separate variant option. This function extracts the canonical board and |
| 512 | # variant information and provides it in the BOARD, VARIANT and BOARD_VARIANT |
| 513 | # variables. |
| 514 | get_board_and_variant() { |
| 515 | local flags_board="${1}" |
| 516 | local flags_variant="${2}" |
| 517 | |
| 518 | BOARD=$(echo "$flags_board" | cut -d '_' -f 1) |
| 519 | VARIANT=${flags_variant:-$(echo "$flags_board" | cut -s -d '_' -f 2)} |
| 520 | |
| 521 | if [ -n "$VARIANT" ]; then |
| 522 | BOARD_VARIANT="${BOARD}_${VARIANT}" |
| 523 | else |
| 524 | BOARD_VARIANT="${BOARD}" |
| 525 | fi |
| 526 | } |
Simon Glass | 142ca06 | 2011-02-09 13:39:43 -0800 | [diff] [blame] | 527 | |
| 528 | # This function converts a chromiumos image into a test image, either |
| 529 | # in place or by copying to a new test image filename first. It honors |
| 530 | # the following flags (see mod_image_for_test.sh) |
| 531 | # |
| 532 | # --factory |
| 533 | # --factory_install |
| 534 | # --force_copy |
| 535 | # |
| 536 | # On entry, pass the directory containing the image, and the image filename |
| 537 | # On exit, it puts the pathname of the resulting test image into |
| 538 | # CHROMEOS_RETURN_VAL |
| 539 | # (yes this is ugly, but perhaps less ugly than the alternatives) |
| 540 | # |
| 541 | # Usage: |
| 542 | # SRC_IMAGE=$(prepare_test_image "directory" "imagefile") |
| 543 | prepare_test_image() { |
| 544 | # If we're asked to modify the image for test, then let's make a copy and |
| 545 | # modify that instead. |
| 546 | # Check for manufacturing image. |
| 547 | local args |
| 548 | |
| 549 | if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then |
| 550 | args="--factory" |
| 551 | fi |
| 552 | |
| 553 | # Check for install shim. |
| 554 | if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then |
| 555 | args="--factory_install" |
| 556 | fi |
| 557 | |
| 558 | # Check for forcing copy of image |
| 559 | if [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ]; then |
| 560 | args="${args} --force_copy" |
| 561 | fi |
| 562 | |
| 563 | # Modify the image for test, creating a new test image |
| 564 | "${SCRIPTS_DIR}/mod_image_for_test.sh" --board=${FLAGS_board} \ |
| 565 | --image="$1/$2" --noinplace ${args} |
| 566 | |
| 567 | # From now on we use the just-created test image |
Simon Glass | 6e448ae | 2011-03-03 11:20:54 -0800 | [diff] [blame] | 568 | if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then |
| 569 | CHROMEOS_RETURN_VAL="$1/${CHROMEOS_FACTORY_TEST_IMAGE_NAME}" |
| 570 | else |
| 571 | CHROMEOS_RETURN_VAL="$1/${CHROMEOS_TEST_IMAGE_NAME}" |
| 572 | fi |
Simon Glass | 142ca06 | 2011-02-09 13:39:43 -0800 | [diff] [blame] | 573 | } |
Anton Staaf | 6f5262d | 2011-03-02 09:35:54 -0800 | [diff] [blame] | 574 | |
| 575 | # Check that the specified file exists. If the file path is empty or the file |
| 576 | # doesn't exist on the filesystem generate useful error messages. Otherwise |
| 577 | # show the user the name and path of the file that will be used. The padding |
| 578 | # parameter can be used to tabulate multiple name:path pairs. For example: |
| 579 | # |
| 580 | # check_for_file "really long name" "...:" "file.foo" |
| 581 | # check_for_file "short name" ".........:" "another.bar" |
| 582 | # |
| 583 | # Results in the following output: |
| 584 | # |
| 585 | # Using really long name...: file.foo |
| 586 | # Using short name.........: another.bar |
| 587 | # |
| 588 | # If tabulation is not required then passing "" for padding generates the |
| 589 | # output "Using <name> <path>" |
| 590 | check_for_file() { |
| 591 | local name=$1 |
| 592 | local padding=$2 |
| 593 | local path=$3 |
| 594 | |
| 595 | if [ -z "${path}" ]; then |
| 596 | die "No ${name} file specified." |
| 597 | fi |
| 598 | |
| 599 | if [ ! -e "${path}" ]; then |
| 600 | die "No ${name} file found at: ${path}" |
| 601 | else |
| 602 | info "Using ${name}${padding} ${path}" |
| 603 | fi |
| 604 | } |
| 605 | |
| 606 | # Check that the specified tool exists. If it does not exist in the PATH |
| 607 | # generate a useful error message indicating how to install the ebuild |
| 608 | # that contains the required tool. |
| 609 | check_for_tool() { |
| 610 | local tool=$1 |
| 611 | local ebuild=$2 |
| 612 | |
| 613 | if ! which "${tool}" >/dev/null ; then |
| 614 | error "The ${tool} utility was not found in your path. Run the following" |
| 615 | error "command in your chroot to install it: sudo -E emerge ${ebuild}" |
| 616 | exit 1 |
| 617 | fi |
| 618 | } |
Chris Sosa | fd2cdec | 2011-03-24 16:06:59 -0700 | [diff] [blame] | 619 | |
| 620 | # Reinterprets path from outside the chroot for use inside. |
| 621 | # Returns "" if "" given. |
| 622 | # $1 - The path to reinterpret. |
| 623 | function reinterpret_path_for_chroot() { |
| 624 | if [ $INSIDE_CHROOT -ne 1 ]; then |
| 625 | if [ -z "${1}" ]; then |
| 626 | echo "" |
| 627 | else |
| 628 | local path_abs_path=$(readlink -f "${1}") |
| 629 | local gclient_root_abs_path=$(readlink -f "${GCLIENT_ROOT}") |
| 630 | |
| 631 | # Strip the repository root from the path. |
| 632 | local relative_path=$(echo ${path_abs_path} \ |
Mike Frysinger | a1a06ab | 2011-08-10 11:40:30 -0400 | [diff] [blame^] | 633 | | sed "s:${gclient_root_abs_path}/::") |
Chris Sosa | fd2cdec | 2011-03-24 16:06:59 -0700 | [diff] [blame] | 634 | |
| 635 | if [ "${relative_path}" = "${path_abs_path}" ]; then |
| 636 | die "Error reinterpreting path. Path ${1} is not within source tree." |
| 637 | fi |
| 638 | |
| 639 | # Prepend the chroot repository path. |
| 640 | echo "/home/${USER}/trunk/${relative_path}" |
| 641 | fi |
| 642 | else |
| 643 | # Path is already inside the chroot :). |
| 644 | echo "${1}" |
| 645 | fi |
| 646 | } |
Gabe Black | 83d8b82 | 2011-08-01 17:50:09 -0700 | [diff] [blame] | 647 | |
| 648 | # Find a firmware component using one of a set of prefixes, or an override if |
| 649 | # one is given. |
| 650 | # The first argument is a list of path prefixes which are prepended to the |
| 651 | # component name, relative to the current board's build directory. |
| 652 | # The second argument is the name of the component to look for. |
| 653 | # The third argument is an optional override. If it's a non-empty string, that |
| 654 | # value is returned instead of searching. This makes it a little easier to |
| 655 | # accept overrides in calling scripts. |
| 656 | # The return value is the override if one is set, the first path at which a |
| 657 | # component is found, or the last path searched if none is found. Later checks |
| 658 | # in the calling scripts can identify that the file doesn't exist and handle |
| 659 | # the error appropriately. |
| 660 | function find_fw_component() { |
| 661 | local prefixes=$1 |
| 662 | local component=$2 |
| 663 | local override=$3 |
| 664 | if [ ! -z "${override}" ]; then |
| 665 | echo "${override}" |
| 666 | exit 0 |
| 667 | fi |
| 668 | local path="" |
| 669 | for prefix in ${prefixes}; do |
| 670 | path="/build/${BOARD_VARIANT}/${prefix}/${component}" |
| 671 | if [ -e "${path}" ]; then |
| 672 | break |
| 673 | fi |
| 674 | done |
| 675 | echo "${path}" |
| 676 | } |
| 677 | |
| 678 | # A wrapper for find_fw_component which provides a set of prefixes which make |
| 679 | # sense for u-boot. |
| 680 | function find_u_boot_component () { |
| 681 | local component=$1 |
| 682 | local override=$2 |
| 683 | find_fw_component "firmware u-boot" "${component}" "${override}" |
| 684 | } |
| 685 | |
| 686 | # A wrapper for find_fw_component which provides a set of prefixes which make |
| 687 | # sense for coreboot. |
| 688 | function find_coreboot_component () { |
| 689 | local component=$1 |
| 690 | local override=$2 |
| 691 | find_fw_component "firmware coreboot" "${component}" "${override}" |
| 692 | } |
David James | 0ea96e4 | 2011-08-03 11:53:50 -0700 | [diff] [blame] | 693 | |
| 694 | function emerge_custom_kernel() { |
| 695 | local install_root="$1" |
| 696 | local root=${FLAGS_build_root}/${FLAGS_board} |
| 697 | local tmp_pkgdir=${root}/custom-packages |
| 698 | |
| 699 | # Clean up any leftover state in custom directories. |
Mike Frysinger | a1a06ab | 2011-08-10 11:40:30 -0400 | [diff] [blame^] | 700 | sudo rm -rf "${tmp_pkgdir}" |
David James | 0ea96e4 | 2011-08-03 11:53:50 -0700 | [diff] [blame] | 701 | |
| 702 | # Update chromeos-initramfs to contain the latest binaries from the build |
| 703 | # tree. This is basically just packaging up already-built binaries from |
| 704 | # $root. We are careful not to muck with the existing prebuilts so that |
| 705 | # prebuilts can be uploaded in parallel. |
| 706 | # TODO(davidjames): Implement ABI deps so that chromeos-initramfs will be |
| 707 | # rebuilt automatically when its dependencies change. |
Mike Frysinger | a1a06ab | 2011-08-10 11:40:30 -0400 | [diff] [blame^] | 708 | sudo -E PKGDIR="${tmp_pkgdir}" $EMERGE_BOARD_CMD -1 \ |
David James | 0ea96e4 | 2011-08-03 11:53:50 -0700 | [diff] [blame] | 709 | chromeos-base/chromeos-initramfs || die "Cannot emerge chromeos-initramfs" |
| 710 | |
| 711 | # Verify all dependencies of the kernel are installed. This should be a |
| 712 | # no-op, but it's good to check in case a developer didn't run |
| 713 | # build_packages. |
| 714 | local kernel=$(portageq-${FLAGS_board} expand_virtual ${root} virtual/kernel) |
Mike Frysinger | a1a06ab | 2011-08-10 11:40:30 -0400 | [diff] [blame^] | 715 | sudo -E PKGDIR="${tmp_pkgdir}" $EMERGE_BOARD_CMD --onlydeps \ |
David James | 0ea96e4 | 2011-08-03 11:53:50 -0700 | [diff] [blame] | 716 | ${kernel} || die "Cannot emerge kernel dependencies" |
| 717 | |
| 718 | # Build the kernel. This uses the standard root so that we can pick up the |
| 719 | # initramfs from there. But we don't actually install the kernel to the |
| 720 | # standard root, because that'll muck up the kernel debug symbols there, |
| 721 | # which we want to upload in parallel. |
Mike Frysinger | a1a06ab | 2011-08-10 11:40:30 -0400 | [diff] [blame^] | 722 | sudo -E PKGDIR="${tmp_pkgdir}" $EMERGE_BOARD_CMD --buildpkgonly \ |
David James | 0ea96e4 | 2011-08-03 11:53:50 -0700 | [diff] [blame] | 723 | ${kernel} || die "Cannot emerge kernel" |
| 724 | |
| 725 | # Install the custom kernel to the provided install root. |
Mike Frysinger | a1a06ab | 2011-08-10 11:40:30 -0400 | [diff] [blame^] | 726 | sudo -E PKGDIR="${tmp_pkgdir}" $EMERGE_BOARD_CMD --usepkgonly \ |
David James | 0ea96e4 | 2011-08-03 11:53:50 -0700 | [diff] [blame] | 727 | --root=${install_root} ${kernel} || die "Cannot emerge kernel to root" |
| 728 | } |