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 | |
| 27 | if [ -z "$OE_SKIP_SDK_CHECK" -a ! -z "$OECORE_SDK_VERSION" ]; then |
| 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. |
| 36 | py_v3_check=`/usr/bin/env python --version 2>&1 | grep "Python 3"` |
| 37 | if [ "$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 |
| 41 | fi |
| 42 | |
| 43 | # Similarly, we now have code that doesn't parse correctly with older |
| 44 | # versions of Python, and rather than fixing that and being eternally |
| 45 | # vigilant for any other new feature use, just check the version here. |
| 46 | py_v26_check=`python -c 'import sys; print sys.version_info >= (2,7,3)'` |
| 47 | if [ "$py_v26_check" != "True" ]; then |
| 48 | echo >&2 "BitBake requires Python 2.7.3 or later" |
| 49 | return 1 |
| 50 | fi |
| 51 | |
| 52 | if [ "x$BDIR" = "x" ]; then |
| 53 | if [ "x$1" = "x" ]; then |
| 54 | BDIR="build" |
| 55 | else |
| 56 | BDIR="$1" |
| 57 | if [ "$BDIR" = "/" ]; then |
| 58 | echo >&2 "Error: / is not supported as a build directory." |
| 59 | return 1 |
| 60 | fi |
| 61 | |
| 62 | # Remove any possible trailing slashes. This is used to work around |
| 63 | # buggy readlink in Ubuntu 10.04 that doesn't ignore trailing slashes |
| 64 | # and hence "readlink -f new_dir_to_be_created/" returns empty. |
| 65 | BDIR=`echo $BDIR | sed -re 's|/+$||'` |
| 66 | |
| 67 | BDIR=`readlink -f "$BDIR"` |
| 68 | if [ -z "$BDIR" ]; then |
| 69 | PARENTDIR=`dirname "$1"` |
| 70 | echo >&2 "Error: the directory $PARENTDIR does not exist?" |
| 71 | return 1 |
| 72 | fi |
| 73 | fi |
| 74 | if [ "x$2" != "x" ]; then |
| 75 | BITBAKEDIR="$2" |
| 76 | fi |
| 77 | fi |
| 78 | if expr "$BDIR" : '/.*' > /dev/null ; then |
| 79 | BUILDDIR="$BDIR" |
| 80 | else |
| 81 | BUILDDIR="`pwd`/$BDIR" |
| 82 | fi |
| 83 | unset BDIR |
| 84 | |
| 85 | if [ "x$BITBAKEDIR" = "x" ]; then |
| 86 | BITBAKEDIR="$OEROOT/bitbake$BBEXTRA/" |
| 87 | fi |
| 88 | |
| 89 | BITBAKEDIR=`readlink -f "$BITBAKEDIR"` |
| 90 | BUILDDIR=`readlink -f "$BUILDDIR"` |
| 91 | |
| 92 | if ! (test -d "$BITBAKEDIR"); then |
| 93 | echo >&2 "Error: The bitbake directory ($BITBAKEDIR) does not exist! Please ensure a copy of bitbake exists at this location" |
| 94 | return 1 |
| 95 | fi |
| 96 | |
| 97 | # Make sure our paths are at the beginning of $PATH |
| 98 | NEWPATHS="${OEROOT}/scripts:$BITBAKEDIR/bin:" |
| 99 | PATH=$NEWPATHS$(echo $PATH | sed -e "s|:$NEWPATHS|:|g" -e "s|^$NEWPATHS||") |
| 100 | unset BITBAKEDIR NEWPATHS |
| 101 | |
| 102 | # Used by the runqemu script |
| 103 | export BUILDDIR |
| 104 | export PATH |
| 105 | export BB_ENV_EXTRAWHITE="MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \ |
| 106 | HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \ |
| 107 | all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \ |
| 108 | SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \ |
| 109 | SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR" |