| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | #!/bin/sh | 
 | 2 |  | 
 | 3 | # OE-Core Build Environment Setup Script | 
 | 4 | # | 
 | 5 | # Copyright (C) 2006-2011 Linux Foundation | 
 | 6 | # | 
 | 7 | # This program is free software; you can redistribute it and/or modify | 
 | 8 | # it under the terms of the GNU General Public License as published by | 
 | 9 | # the Free Software Foundation; either version 2 of the License, or | 
 | 10 | # (at your option) any later version. | 
 | 11 | # | 
 | 12 | # This program is distributed in the hope that it will be useful, | 
 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
 | 15 | # GNU General Public License for more details. | 
 | 16 | # | 
 | 17 | # You should have received a copy of the GNU General Public License | 
 | 18 | # along with this program; if not, write to the Free Software | 
 | 19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
 | 20 |  | 
 | 21 | # It is assumed OEROOT is already defined when this is called | 
 | 22 | if [ -z "$OEROOT" ]; then | 
 | 23 |     echo >&2 "Error: OEROOT is not defined!" | 
 | 24 |     return 1 | 
 | 25 | fi | 
 | 26 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 27 | if [ -z "$OE_SKIP_SDK_CHECK" ] && [ -n "$OECORE_SDK_VERSION" ]; then | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 |     echo >&2 "Error: The OE SDK/ADT was detected as already being present in this shell environment. Please use a clean shell when sourcing this environment script." | 
 | 29 |     return 1 | 
 | 30 | fi | 
 | 31 |  | 
 | 32 | # Make sure we're not using python v3.x. This check can't go into | 
 | 33 | # sanity.bbclass because bitbake's source code doesn't even pass | 
 | 34 | # parsing stage when used with python v3, so we catch it here so we | 
 | 35 | # can offer a meaningful error message. | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 36 | py_v3_check=$(/usr/bin/env python --version 2>&1 | grep "Python 3") | 
 | 37 | if [ -n "$py_v3_check" ]; then | 
 | 38 |     echo >&2 "Bitbake is not compatible with python v3" | 
 | 39 |     echo >&2 "Please set up python v2 as your default python interpreter" | 
 | 40 |     return 1 | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 41 | fi | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 42 | unset py_v3_check | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 43 |  | 
 | 44 | # Similarly, we now have code that doesn't parse correctly with older | 
 | 45 | # versions of Python, and rather than fixing that and being eternally | 
 | 46 | # vigilant for any other new feature use, just check the version here. | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 47 | py_v26_check=$(python -c 'import sys; print sys.version_info >= (2,7,3)') | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 48 | if [ "$py_v26_check" != "True" ]; then | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 49 |     echo >&2 "BitBake requires Python 2.7.3 or later" | 
 | 50 |     return 1 | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 51 | fi | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 52 | unset py_v26_check | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 53 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 54 | if [ -z "$BDIR" ]; then | 
 | 55 |     if [ -z "$1" ]; then | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 56 |         BDIR="build" | 
 | 57 |     else | 
 | 58 |         BDIR="$1" | 
 | 59 |         if [ "$BDIR" = "/" ]; then | 
 | 60 |             echo >&2 "Error: / is not supported as a build directory." | 
 | 61 |             return 1 | 
 | 62 |         fi | 
 | 63 |  | 
 | 64 |         # Remove any possible trailing slashes. This is used to work around | 
 | 65 |         # buggy readlink in Ubuntu 10.04 that doesn't ignore trailing slashes | 
 | 66 |         # and hence "readlink -f new_dir_to_be_created/" returns empty. | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 67 |         BDIR=$(echo $BDIR | sed -re 's|/+$||') | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 68 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 69 |         BDIR=$(readlink -f "$BDIR") | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 70 |         if [ -z "$BDIR" ]; then | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 71 |             PARENTDIR=$(dirname "$1") | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 72 |             echo >&2 "Error: the directory $PARENTDIR does not exist?" | 
 | 73 |             return 1 | 
 | 74 |         fi | 
 | 75 |     fi | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 76 |     if [ -n "$2" ]; then | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 77 |         BITBAKEDIR="$2" | 
 | 78 |     fi | 
 | 79 | fi | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 80 | if [ "${BDIR#/}" != "$BDIR" ]; then | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 |     BUILDDIR="$BDIR" | 
 | 82 | else | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 83 |     BUILDDIR="$(pwd)/$BDIR" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 84 | fi | 
 | 85 | unset BDIR | 
 | 86 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 87 | if [ -z "$BITBAKEDIR" ]; then | 
 | 88 |     BITBAKEDIR="$OEROOT/bitbake$BBEXTRA" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 89 | fi | 
 | 90 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 91 | BITBAKEDIR=$(readlink -f "$BITBAKEDIR") | 
 | 92 | BUILDDIR=$(readlink -f "$BUILDDIR") | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 93 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 94 | if [ ! -d "$BITBAKEDIR" ]; then | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 |     echo >&2 "Error: The bitbake directory ($BITBAKEDIR) does not exist!  Please ensure a copy of bitbake exists at this location" | 
 | 96 |     return 1 | 
 | 97 | fi | 
 | 98 |  | 
 | 99 | # Make sure our paths are at the beginning of $PATH | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 100 | for newpath in "$BITBAKEDIR/bin" "$OEROOT/scripts"; do | 
 | 101 |     # Remove any existences of $newpath from $PATH | 
 | 102 |     PATH=$(echo $PATH | sed -re "s#(^|:)$newpath(:|$)#\2#g;s#^:##") | 
 | 103 |  | 
 | 104 |     # Add $newpath to $PATH | 
 | 105 |     PATH="$newpath:$PATH" | 
 | 106 | done | 
 | 107 | unset BITBAKEDIR newpath | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 108 |  | 
 | 109 | # Used by the runqemu script | 
 | 110 | export BUILDDIR | 
 | 111 | export PATH | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 112 |  | 
 | 113 | BB_ENV_EXTRAWHITE_OE="MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \ | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 114 | HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \ | 
 | 115 | all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \ | 
 | 116 | SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \ | 
 | 117 | SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR" | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 118 |  | 
 | 119 | BB_ENV_EXTRAWHITE="$(echo $BB_ENV_EXTRAWHITE $BB_ENV_EXTRAWHITE_OE | tr ' ' '\n' | LC_ALL=C sort --unique | tr '\n' ' ')" | 
 | 120 |  | 
 | 121 | export BB_ENV_EXTRAWHITE |