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 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 32 | # Make sure we're not using python v3.x as 'python', we don't support it. |
| 33 | py_v2_check=$(/usr/bin/env python --version 2>&1 | grep "Python 3") |
| 34 | if [ -n "$py_v2_check" ]; then |
| 35 | echo >&2 "OpenEmbedded requires 'python' to be python v2 (>= 2.7.3), not python v3." |
| 36 | echo >&2 "Please set up python v2 as your default 'python' interpreter." |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 37 | return 1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 39 | unset py_v2_check |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 41 | py_v27_check=$(python -c 'import sys; print sys.version_info >= (2,7,3)') |
| 42 | if [ "$py_v27_check" != "True" ]; then |
| 43 | echo >&2 "OpenEmbedded requires 'python' to be python v2 (>= 2.7.3), not python v3." |
| 44 | echo >&2 "Please upgrade your python v2." |
| 45 | fi |
| 46 | unset py_v27_check |
| 47 | |
| 48 | # We potentially have code that doesn't parse correctly with older versions |
| 49 | # of Python, and rather than fixing that and being eternally vigilant for |
| 50 | # any other new feature use, just check the version here. |
| 51 | py_v34_check=$(python3 -c 'import sys; print(sys.version_info >= (3,4,0))') |
| 52 | if [ "$py_v34_check" != "True" ]; then |
| 53 | echo >&2 "BitBake requires Python 3.4.0 or later as 'python3'" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 54 | return 1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 56 | unset py_v34_check |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 57 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 58 | if [ -z "$BDIR" ]; then |
| 59 | if [ -z "$1" ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 60 | BDIR="build" |
| 61 | else |
| 62 | BDIR="$1" |
| 63 | if [ "$BDIR" = "/" ]; then |
| 64 | echo >&2 "Error: / is not supported as a build directory." |
| 65 | return 1 |
| 66 | fi |
| 67 | |
| 68 | # Remove any possible trailing slashes. This is used to work around |
| 69 | # buggy readlink in Ubuntu 10.04 that doesn't ignore trailing slashes |
| 70 | # and hence "readlink -f new_dir_to_be_created/" returns empty. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 71 | BDIR=$(echo $BDIR | sed -re 's|/+$||') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 72 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 73 | BDIR=$(readlink -f "$BDIR") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 74 | if [ -z "$BDIR" ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 75 | PARENTDIR=$(dirname "$1") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 76 | echo >&2 "Error: the directory $PARENTDIR does not exist?" |
| 77 | return 1 |
| 78 | fi |
| 79 | fi |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 80 | if [ -n "$2" ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 | BITBAKEDIR="$2" |
| 82 | fi |
| 83 | fi |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 84 | if [ "${BDIR#/}" != "$BDIR" ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 85 | BUILDDIR="$BDIR" |
| 86 | else |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 87 | BUILDDIR="$(pwd)/$BDIR" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 88 | fi |
| 89 | unset BDIR |
| 90 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 91 | if [ -z "$BITBAKEDIR" ]; then |
| 92 | BITBAKEDIR="$OEROOT/bitbake$BBEXTRA" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 93 | fi |
| 94 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 95 | BITBAKEDIR=$(readlink -f "$BITBAKEDIR") |
| 96 | BUILDDIR=$(readlink -f "$BUILDDIR") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 97 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 98 | if [ ! -d "$BITBAKEDIR" ]; then |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 99 | echo >&2 "Error: The bitbake directory ($BITBAKEDIR) does not exist! Please ensure a copy of bitbake exists at this location or specify an alternative path on the command line" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 100 | return 1 |
| 101 | fi |
| 102 | |
| 103 | # Make sure our paths are at the beginning of $PATH |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 104 | for newpath in "$BITBAKEDIR/bin" "$OEROOT/scripts"; do |
| 105 | # Remove any existences of $newpath from $PATH |
| 106 | PATH=$(echo $PATH | sed -re "s#(^|:)$newpath(:|$)#\2#g;s#^:##") |
| 107 | |
| 108 | # Add $newpath to $PATH |
| 109 | PATH="$newpath:$PATH" |
| 110 | done |
| 111 | unset BITBAKEDIR newpath |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 112 | |
| 113 | # Used by the runqemu script |
| 114 | export BUILDDIR |
| 115 | export PATH |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 116 | |
| 117 | BB_ENV_EXTRAWHITE_OE="MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 118 | HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \ |
| 119 | all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \ |
| 120 | SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 121 | SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR BBPATH_EXTRA BB_SETSCENE_ENFORCE" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 122 | |
| 123 | BB_ENV_EXTRAWHITE="$(echo $BB_ENV_EXTRAWHITE $BB_ENV_EXTRAWHITE_OE | tr ' ' '\n' | LC_ALL=C sort --unique | tr '\n' ' ')" |
| 124 | |
| 125 | export BB_ENV_EXTRAWHITE |