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