oe-buildenv-internal 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/bin/sh
  2. # OE-Core Build Environment Setup Script
  3. #
  4. # Copyright (C) 2006-2011 Linux Foundation
  5. #
  6. # SPDX-License-Identifier: GPL-2.0-or-later
  7. #
  8. if ! $(return >/dev/null 2>&1) ; then
  9. echo 'oe-buildenv-internal: error: this script must be sourced'
  10. echo ''
  11. echo 'Usage: . $OEROOT/scripts/oe-buildenv-internal &&'
  12. echo ''
  13. echo 'OpenEmbedded oe-buildenv-internal - an internal script that is'
  14. echo 'used in oe-init-build-env to initialize oe build environment'
  15. echo ''
  16. exit 2
  17. fi
  18. # It is assumed OEROOT is already defined when this is called
  19. if [ -z "$OEROOT" ]; then
  20. echo >&2 "Error: OEROOT is not defined!"
  21. return 1
  22. fi
  23. if [ -z "$OE_SKIP_SDK_CHECK" ] && [ -n "$OECORE_SDK_VERSION" ]; then
  24. 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."
  25. return 1
  26. fi
  27. py_v27_check=$(python2 -c 'import sys; print sys.version_info >= (2,7,3)')
  28. if [ "$py_v27_check" != "True" ]; then
  29. echo >&2 "OpenEmbedded requires 'python' to be python v2 (>= 2.7.3), not python v3."
  30. echo >&2 "Please upgrade your python v2."
  31. fi
  32. unset py_v27_check
  33. # We potentially have code that doesn't parse correctly with older versions
  34. # of Python, and rather than fixing that and being eternally vigilant for
  35. # any other new feature use, just check the version here.
  36. py_v34_check=$(python3 -c 'import sys; print(sys.version_info >= (3,4,0))')
  37. if [ "$py_v34_check" != "True" ]; then
  38. echo >&2 "BitBake requires Python 3.4.0 or later as 'python3'"
  39. return 1
  40. fi
  41. unset py_v34_check
  42. if [ -z "$BDIR" ]; then
  43. if [ -z "$1" ]; then
  44. BDIR="build"
  45. else
  46. BDIR="$1"
  47. if [ "$BDIR" = "/" ]; then
  48. echo >&2 "Error: / is not supported as a build directory."
  49. return 1
  50. fi
  51. # Remove any possible trailing slashes. This is used to work around
  52. # buggy readlink in Ubuntu 10.04 that doesn't ignore trailing slashes
  53. # and hence "readlink -f new_dir_to_be_created/" returns empty.
  54. BDIR=$(echo $BDIR | sed -re 's|/+$||')
  55. BDIR=$(readlink -f "$BDIR")
  56. if [ -z "$BDIR" ]; then
  57. PARENTDIR=$(dirname "$1")
  58. echo >&2 "Error: the directory $PARENTDIR does not exist?"
  59. return 1
  60. fi
  61. fi
  62. if [ -n "$2" ]; then
  63. BITBAKEDIR="$2"
  64. fi
  65. fi
  66. if [ "${BDIR#/}" != "$BDIR" ]; then
  67. BUILDDIR="$BDIR"
  68. else
  69. BUILDDIR="$(pwd)/$BDIR"
  70. fi
  71. unset BDIR
  72. if [ -z "$BITBAKEDIR" ]; then
  73. BITBAKEDIR="$OEROOT/bitbake$BBEXTRA"
  74. test -d "$BITBAKEDIR" || BITBAKEDIR="$OEROOT/../bitbake$BBEXTRA"
  75. fi
  76. BITBAKEDIR=$(readlink -f "$BITBAKEDIR")
  77. BUILDDIR=$(readlink -f "$BUILDDIR")
  78. BBPATH=$BUILDDIR
  79. export BBPATH
  80. if [ ! -d "$BITBAKEDIR" ]; then
  81. 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"
  82. return 1
  83. fi
  84. # Make sure our paths are at the beginning of $PATH
  85. for newpath in "$BITBAKEDIR/bin" "$OEROOT/scripts"; do
  86. # Remove any existences of $newpath from $PATH
  87. PATH=$(echo $PATH | sed -re "s#(^|:)$newpath(:|$)#\2#g;s#^:##")
  88. # Add $newpath to $PATH
  89. PATH="$newpath:$PATH"
  90. done
  91. unset BITBAKEDIR newpath
  92. # Used by the runqemu script
  93. export BUILDDIR
  94. export PATH
  95. BB_ENV_EXTRAWHITE_OE="MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
  96. HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \
  97. all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \
  98. SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \
  99. SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR BBPATH_EXTRA BB_SETSCENE_ENFORCE"
  100. BB_ENV_EXTRAWHITE="$(echo $BB_ENV_EXTRAWHITE $BB_ENV_EXTRAWHITE_OE | tr ' ' '\n' | LC_ALL=C sort --unique | tr '\n' ' ')"
  101. export BB_ENV_EXTRAWHITE