| OLD | NEW |
| 1 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2009 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. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 true | 24 true |
| 25 elif [ "x$COMMON_SH" != "x" ] | 25 elif [ "x$COMMON_SH" != "x" ] |
| 26 then | 26 then |
| 27 # COMMON_SH set, so assume that's us | 27 # COMMON_SH set, so assume that's us |
| 28 GCLIENT_ROOT="$(dirname "$COMMON_SH")/../.." | 28 GCLIENT_ROOT="$(dirname "$COMMON_SH")/../.." |
| 29 elif [ "x$BASH_SOURCE" != "x" ] | 29 elif [ "x$BASH_SOURCE" != "x" ] |
| 30 then | 30 then |
| 31 # Using bash, so we can find ourselves | 31 # Using bash, so we can find ourselves |
| 32 GCLIENT_ROOT="$(dirname "$BASH_SOURCE")/../.." | 32 GCLIENT_ROOT="$(dirname "$BASH_SOURCE")/../.." |
| 33 else | 33 else |
| 34 # Using dash or sh, we don't know where we are. $0 refers to the calling | 34 # Using dash or sh, we don't know where we are. $0 refers to the calling |
| 35 # script, not ourselves, so that doesn't help us. | 35 # script, not ourselves, so that doesn't help us. |
| 36 echo "Unable to determine location for common.sh. If you are sourcing" | 36 echo "Unable to determine location for common.sh. If you are sourcing" |
| 37 echo "common.sh from a script run via dash or sh, you must do it in the" | 37 echo "common.sh from a script run via dash or sh, you must do it in the" |
| 38 echo "following way:" | 38 echo "following way:" |
| 39 echo ' COMMON_SH="$(dirname "$0")/../../scripts/common.sh"' | 39 echo ' COMMON_SH="$(dirname "$0")/../../scripts/common.sh"' |
| 40 echo ' . "$COMMON_SH"' | 40 echo ' . "$COMMON_SH"' |
| 41 echo "where the first line is the relative path from your script to" | 41 echo "where the first line is the relative path from your script to" |
| 42 echo "common.sh." | 42 echo "common.sh." |
| 43 exit 1 | 43 exit 1 |
| 44 fi | 44 fi |
| 45 | 45 |
| 46 # Canonicalize the directories for the root dir and the calling script. | 46 # Canonicalize the directories for the root dir and the calling script. |
| 47 # readlink is part of coreutils and should be present even in a bare chroot. | 47 # readlink is part of coreutils and should be present even in a bare chroot. |
| 48 # This is better than just using | 48 # This is better than just using |
| 49 # FOO = "$(cd $FOO ; pwd)" | 49 # FOO = "$(cd $FOO ; pwd)" |
| 50 # since that leaves symbolic links intact. | 50 # since that leaves symbolic links intact. |
| 51 # Note that 'realpath' is equivalent to 'readlink -f'. | 51 # Note that 'realpath' is equivalent to 'readlink -f'. |
| 52 TOP_SCRIPT_DIR=`readlink -f $TOP_SCRIPT_DIR` | 52 TOP_SCRIPT_DIR=`readlink -f $TOP_SCRIPT_DIR` |
| 53 GCLIENT_ROOT=`readlink -f $GCLIENT_ROOT` | 53 GCLIENT_ROOT=`readlink -f $GCLIENT_ROOT` |
| 54 | 54 |
| 55 # Other directories should always be pathed down from GCLIENT_ROOT. | 55 # Other directories should always be pathed down from GCLIENT_ROOT. |
| 56 SRC_ROOT="$GCLIENT_ROOT/src" | 56 SRC_ROOT="$GCLIENT_ROOT/src" |
| 57 SRC_INTERNAL="$GCLIENT_ROOT/src-internal" | 57 SRC_INTERNAL="$GCLIENT_ROOT/src-internal" |
| 58 SCRIPTS_DIR="$SRC_ROOT/scripts" | 58 SCRIPTS_DIR="$SRC_ROOT/scripts" |
| 59 | 59 |
| 60 # Load developer's custom settings. Default location is in scripts dir, | 60 # Load developer's custom settings. Default location is in scripts dir, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 83 # IMG - bootable image, from local package repository | 83 # IMG - bootable image, from local package repository |
| 84 | 84 |
| 85 # Build suites | 85 # Build suites |
| 86 DEFAULT_EXT_SUITE=${CHROMEOS_EXT_SUITE:-"chromeos_dev"} | 86 DEFAULT_EXT_SUITE=${CHROMEOS_EXT_SUITE:-"chromeos_dev"} |
| 87 DEFAULT_DEV_SUITE=${CHROMEOS_DEV_SUITE:-"chromeos_dev"} | 87 DEFAULT_DEV_SUITE=${CHROMEOS_DEV_SUITE:-"chromeos_dev"} |
| 88 DEFAULT_IMG_SUITE=${CHROMEOS_IMG_SUITE:-"chromeos"} | 88 DEFAULT_IMG_SUITE=${CHROMEOS_IMG_SUITE:-"chromeos"} |
| 89 | 89 |
| 90 # Package repositories (mirrors) | 90 # Package repositories (mirrors) |
| 91 DEFAULT_EXT_MIRROR=${CHROMEOS_EXT_MIRROR:-"http://build.chromium.org/buildbot/pa
ckages"} | 91 DEFAULT_EXT_MIRROR=${CHROMEOS_EXT_MIRROR:-"http://build.chromium.org/buildbot/pa
ckages"} |
| 92 DEFAULT_DEV_MIRROR=${CHROMEOS_DEV_MIRROR:-"file://$GCLIENT_ROOT/repo/apt"} | 92 DEFAULT_DEV_MIRROR=${CHROMEOS_DEV_MIRROR:-"file://$GCLIENT_ROOT/repo/apt"} |
| 93 DEFAULT_IMG_MIRROR=${CHROMEOS_IMG_MIRROR:-"file:///home/$USER/trunk/repo/apt"} | 93 DEFAULT_IMG_MIRROR=${CHROMEOS_IMG_MIRROR:-"copy:///home/$USER/trunk/repo/apt"} |
| 94 | 94 |
| 95 # Default location for chroot | 95 # Default location for chroot |
| 96 DEFAULT_CHROOT_DIR=${CHROMEOS_CHROOT_DIR:-"$GCLIENT_ROOT/chroot"} | 96 DEFAULT_CHROOT_DIR=${CHROMEOS_CHROOT_DIR:-"$GCLIENT_ROOT/chroot"} |
| 97 | 97 |
| 98 # All output files from build should go under $DEFAULT_BUILD_ROOT, so that | 98 # All output files from build should go under $DEFAULT_BUILD_ROOT, so that |
| 99 # they don't pollute the source directory. | 99 # they don't pollute the source directory. |
| 100 DEFAULT_BUILD_ROOT=${CHROMEOS_BUILD_ROOT:-"$SRC_ROOT/build"} | 100 DEFAULT_BUILD_ROOT=${CHROMEOS_BUILD_ROOT:-"$SRC_ROOT/build"} |
| 101 | 101 |
| 102 # Detect whether we're inside a chroot or not | 102 # Detect whether we're inside a chroot or not |
| 103 if [ -e /etc/debian_chroot ] | 103 if [ -e /etc/debian_chroot ] |
| 104 then | 104 then |
| 105 INSIDE_CHROOT=1 | 105 INSIDE_CHROOT=1 |
| 106 else | 106 else |
| 107 INSIDE_CHROOT=0 | 107 INSIDE_CHROOT=0 |
| 108 fi | 108 fi |
| 109 | 109 |
| 110 # Directory locations inside the dev chroot | 110 # Directory locations inside the dev chroot |
| 111 CHROOT_TRUNK_DIR="/home/$USER/trunk" | 111 CHROOT_TRUNK_DIR="/home/$USER/trunk" |
| 112 | 112 |
| 113 # ----------------------------------------------------------------------------- | 113 # ----------------------------------------------------------------------------- |
| 114 # Functions | 114 # Functions |
| 115 | 115 |
| 116 # Make a package | 116 # Make a package |
| 117 function make_pkg_common { | 117 function make_pkg_common { |
| 118 # Positional parameters from calling script. :? means "fail if unset". | 118 # Positional parameters from calling script. :? means "fail if unset". |
| 119 set -e | 119 set -e |
| 120 PKG_BASE=${1:?} | 120 PKG_BASE=${1:?} |
| 121 shift | 121 shift |
| 122 set +e | 122 set +e |
| 123 | 123 |
| 124 # All packages are built in the chroot | 124 # All packages are built in the chroot |
| 125 assert_inside_chroot | 125 assert_inside_chroot |
| 126 | 126 |
| 127 # Command line options | 127 # Command line options |
| 128 DEFINE_string build_root "$DEFAULT_BUILD_ROOT" "Root of build output" | 128 DEFINE_string build_root "$DEFAULT_BUILD_ROOT" "Root of build output" |
| 129 | 129 |
| 130 # Parse command line and update positional args | 130 # Parse command line and update positional args |
| 131 FLAGS "$@" || exit 1 | 131 FLAGS "$@" || exit 1 |
| 132 eval set -- "${FLAGS_ARGV}" | 132 eval set -- "${FLAGS_ARGV}" |
| 133 | 133 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 # Positional parameters from calling script. :? means "fail if unset". | 183 # Positional parameters from calling script. :? means "fail if unset". |
| 184 PKG_NAME=${1:?} | 184 PKG_NAME=${1:?} |
| 185 shift | 185 shift |
| 186 | 186 |
| 187 if [ -z `which $PKG_NAME` ] | 187 if [ -z `which $PKG_NAME` ] |
| 188 then | 188 then |
| 189 echo "Can't find $PKG_NAME; attempting to install it." | 189 echo "Can't find $PKG_NAME; attempting to install it." |
| 190 sudo apt-get --yes --force-yes install $PKG_NAME | 190 sudo apt-get --yes --force-yes install $PKG_NAME |
| 191 fi | 191 fi |
| 192 } | 192 } |
| OLD | NEW |