diff options
| author | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 13:50:35 +0100 | 
|---|---|---|
| committer | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 13:50:35 +0100 | 
| commit | 040dbf85c707a6e8c7da2396dd5377c28ad7a499 (patch) | |
| tree | 82003507144ea5e79e2f6e226c1619e81b377f77 | |
| parent | e2e6f6fe07049f33cb6348780fa975162752e421 (diff) | |
| download | poky-enea_linux_3.tar.gz | |
add enea init script to poky folderenea_linux_3
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
| -rwxr-xr-x | enea-init-build-env | 187 | 
1 files changed, 187 insertions, 0 deletions
| diff --git a/enea-init-build-env b/enea-init-build-env new file mode 100755 index 0000000000..2e53f8e69f --- /dev/null +++ b/enea-init-build-env | |||
| @@ -0,0 +1,187 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | if [ "$_" = "$0" ]; then | ||
| 3 | echo "Error: This script needs to be sourced." | ||
| 4 | echo "Please run as 'source $0'." | ||
| 5 | exit | ||
| 6 | fi | ||
| 7 | |||
| 8 | # always unset these in case something goes wrong in the previous run | ||
| 9 | unset OPTERR OPTIND OPTION MACHINE EXITME SSTATE_DIR DOWNLOAD_DLDIR METALAYERS | ||
| 10 | unset DOWNLOAD_MIRRORS LOCAL_CONF_EXISTS BBLAYERS_CONF_EXISTS | ||
| 11 | |||
| 12 | NUM_CORES=$(grep -c processor /proc/cpuinfo || echo 2) | ||
| 13 | BUILD_PATH="build" | ||
| 14 | METALAYERS="meta-enea" | ||
| 15 | |||
| 16 | function usage() { | ||
| 17 | cat <<EOF | ||
| 18 | Usage: | ||
| 19 | source $(basename $BASH_SOURCE) [OPTIONS] | ||
| 20 | |||
| 21 | OPTIONS: | ||
| 22 | -b <build dir> | ||
| 23 | Build dir | ||
| 24 | default: build | ||
| 25 | |||
| 26 | -g <url> | ||
| 27 | download mirror e.g., file:///media/downloads | ||
| 28 | default: http://linux.enea.com | ||
| 29 | |||
| 30 | -j <cores> | ||
| 31 | Number of cores to use in build. | ||
| 32 | default: all | ||
| 33 | |||
| 34 | -k <sstate dir> | ||
| 35 | Shared local sstate cache, type -k <build dir>/sstate | ||
| 36 | if you want to use private sstate cache. | ||
| 37 | |||
| 38 | -l <list of meta-layers> | ||
| 39 | List of meta-layers, e.g., -l meta-fsl-ppc,meta-enea-lwrt | ||
| 40 | default: none | ||
| 41 | |||
| 42 | -m <machine name> | ||
| 43 | Machine name (required) | ||
| 44 | |||
| 45 | -h | ||
| 46 | Help - this text | ||
| 47 | EOF | ||
| 48 | } | ||
| 49 | |||
| 50 | DOWNLOAD_MIRRORS='http://linux.enea.com/${DISTRO_VERSION}/sources/' | ||
| 51 | SSTATE_MIRRORS='http://linux.enea.com/${DISTRO_VERSION}/sstate-cache/PATH' | ||
| 52 | |||
| 53 | while getopts ":hb:d:f:g:j:k:l:m:t:" OPTION; do | ||
| 54 | case $OPTION in | ||
| 55 | b) | ||
| 56 | BUILD_PATH=$OPTARG | ||
| 57 | ;; | ||
| 58 | d) | ||
| 59 | # set DL_DIR. be careful when using this, as it's easy to | ||
| 60 | # introduce isseues if this dir is shared | ||
| 61 | DOWNLOAD_DLDIR=$(readlink -m $OPTARG) | ||
| 62 | ;; | ||
| 63 | g) | ||
| 64 | DOWNLOAD_MIRRORS=$OPTARG | ||
| 65 | ;; | ||
| 66 | j) | ||
| 67 | NUM_CORES=$OPTARG | ||
| 68 | ;; | ||
| 69 | k) | ||
| 70 | SSTATE_DIR=$(readlink -m $OPTARG) | ||
| 71 | ;; | ||
| 72 | l) | ||
| 73 | METALAYERS="$METALAYERS,$OPTARG" | ||
| 74 | ;; | ||
| 75 | m) | ||
| 76 | MACHINE=$OPTARG | ||
| 77 | ;; | ||
| 78 | h) | ||
| 79 | usage | ||
| 80 | EXITME=1 | ||
| 81 | ;; | ||
| 82 | \?) | ||
| 83 | echo "Unknown option '-$OPTARG'" | ||
| 84 | usage | ||
| 85 | EXITME=1 | ||
| 86 | ;; | ||
| 87 | esac | ||
| 88 | done | ||
| 89 | |||
| 90 | ENEAROOT="$(pwd)" | ||
| 91 | ENEAROOT=$(readlink -f "$ENEAROOT") | ||
| 92 | |||
| 93 | if [[ ! -d $SSTATE_DIR && ! -z $SSTATE_DIR ]]; then | ||
| 94 | mkdir -p $SSTATE_DIR | ||
| 95 | if [[ $? -ne 0 ]]; then | ||
| 96 | echo "Error: Unable to create directory $SSTATE_DIR. Do you have permissions?" | ||
| 97 | EXITME=1 | ||
| 98 | fi | ||
| 99 | fi | ||
| 100 | if [[ ! -d $DOWNLOAD_DLDIR && ! -z $DOWNLOAD_DLDIR ]]; then | ||
| 101 | mkdir -p $DOWNLOAD_DLDIR | ||
| 102 | if [[ $? -ne 0 ]]; then | ||
| 103 | echo "Error: Unable to create directory $DOWNLOAD_DLDIR. Do you have permissions?" | ||
| 104 | EXITME=1 | ||
| 105 | fi | ||
| 106 | fi | ||
| 107 | |||
| 108 | if [[ -n $EXITME ]]; then | ||
| 109 | echo | ||
| 110 | elif [[ -z $BASH_VERSINFO ]]; then | ||
| 111 | echo "This script requires bash." | ||
| 112 | elif [ "$MACHINE"x = "x" -a ! -r "$BUILD_PATH/conf/local.conf" ]; then | ||
| 113 | cat <<EOF | ||
| 114 | error: When creating a new build dir, you must at least specify -m MACHINE. | ||
| 115 | |||
| 116 | Use option -h for help. | ||
| 117 | EOF | ||
| 118 | else | ||
| 119 | |||
| 120 | if ! (test -r "$BUILD_PATH/conf/local.conf"); then | ||
| 121 | LOCAL_CONF_EXISTS=1 | ||
| 122 | fi | ||
| 123 | |||
| 124 | if ! (test -r "$BUILD_PATH/conf/bblayers.conf"); then | ||
| 125 | BBLAYERS_CONF_EXISTS=1 | ||
| 126 | fi | ||
| 127 | |||
| 128 | source ./oe-init-build-env $BUILD_PATH | ||
| 129 | |||
| 130 | if [[ -n $LOCAL_CONF_EXISTS ]]; then | ||
| 131 | sed -i \ | ||
| 132 | -e "s|^#BB_NUMBER_THREADS.*|BB_NUMBER_THREADS \?= \"$NUM_CORES\"|" \ | ||
| 133 | -e "s|^#PARALLEL_MAKE.*|PARALLEL_MAKE \?= \"-j $NUM_CORES\"|" \ | ||
| 134 | -e 's|^DISTRO ?= "poky"|DISTRO ?= "enea"|' \ | ||
| 135 | conf/local.conf | ||
| 136 | echo "*** Info: Setting BB_NUMBER_THREADS to $NUM_CORES" | ||
| 137 | echo "*** Info: Setting PARALLEL_MAKE to -j$NUM_CORES" | ||
| 138 | echo "*** Info: Setting DISTRO to enea" | ||
| 139 | |||
| 140 | if [[ -n $MACHINE ]]; then | ||
| 141 | sed -i -e "s|^MACHINE.*|MACHINE = \"$MACHINE\"|" conf/local.conf | ||
| 142 | echo "*** Info: Setting MACHINE to $MACHINE" | ||
| 143 | fi | ||
| 144 | |||
| 145 | echo "SSTATE_MIRRORS ?= \"file://.* $SSTATE_MIRRORS\"" >> conf/local.conf | ||
| 146 | echo "*** Info: Setting SSTATE_MIRRORS to http://linux.enea.com" | ||
| 147 | |||
| 148 | if [[ -n $SSTATE_DIR ]]; then | ||
| 149 | sed -i -e "s|^#SSTATE_DIR ?=.*|SSTATE_DIR ?= \"$SSTATE_DIR\"|" conf/local.conf | ||
| 150 | echo "*** Info: Setting SSTATE_DIR to $SSTATE_DIR" | ||
| 151 | fi | ||
| 152 | |||
| 153 | sed -i -e 's|^PACKAGE_CLASSES ?= "package_rpm"|PACKAGE_CLASSES ?= "package_ipk"|' conf/local.conf | ||
| 154 | echo "*** Info: Setting PACKAGE_CLASSES to ipk" | ||
| 155 | |||
| 156 | echo "SOURCE_MIRROR_URL ?= \"$DOWNLOAD_MIRRORS\"" >> conf/local.conf | ||
| 157 | echo "INHERIT += \"own-mirrors\"" >> conf/local.conf | ||
| 158 | echo "*** Info: Setting SOURCE_MIRROR_URL to http://linux.enea.com" | ||
| 159 | |||
| 160 | if [[ -n $DOWNLOAD_DLDIR ]]; then | ||
| 161 | sed -i -e "s|^#DL_DIR ?=.*|DL_DIR ?= \"$DOWNLOAD_DLDIR\"|" conf/local.conf | ||
| 162 | echo "*** Info: Setting DL_DIR to $DOWNLOAD_DLDIR" | ||
| 163 | fi | ||
| 164 | else | ||
| 165 | echo "You already had conf/local.conf file, no modification is done." | ||
| 166 | fi | ||
| 167 | |||
| 168 | if [[ -n $BBLAYERS_CONF_EXISTS ]]; then | ||
| 169 | if [[ ""x != "${METALAYERS}"x ]]; then | ||
| 170 | for layer in $(echo $METALAYERS | tr ',' ' '); do | ||
| 171 | layer=$ENEAROOT/$layer | ||
| 172 | if [[ ! -d $layer ]]; then | ||
| 173 | echo "*** Error: There is no meta-layer called: $layer" | ||
| 174 | else | ||
| 175 | egrep "$layer " conf/bblayers.conf >/dev/null || | ||
| 176 | sed -i -e '/.*meta-yocto .*/i\'" $layer \\\\" conf/bblayers.conf | ||
| 177 | echo "*** Info: Adding $layer to bblayers.conf" | ||
| 178 | fi | ||
| 179 | done | ||
| 180 | fi | ||
| 181 | else | ||
| 182 | echo "You already had conf/bblayers.conf file, no modification is done." | ||
| 183 | fi | ||
| 184 | fi | ||
| 185 | |||
| 186 | unset OPTERR OPTIND OPTION MACHINE EXITME SSTATE_DIR DOWNLOAD_DLDIR METALAYERS | ||
| 187 | unset DOWNLOAD_MIRRORS LOCAL_CONF_EXISTS BBLAYERS_CONF_EXISTS SSTATE_MIRRORS | ||
