oe-buildenv-internal 4.7 KB

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