oe-buildenv-internal 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. # It is assumed OEROOT is already defined when this is called
  20. if [ -z "$OEROOT" ]; then
  21. echo >&2 "Error: OEROOT is not defined!"
  22. return 1
  23. fi
  24. if [ -z "$OE_SKIP_SDK_CHECK" ] && [ -n "$OECORE_SDK_VERSION" ]; then
  25. 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."
  26. return 1
  27. fi
  28. # Make sure we're not using python v3.x. This check can't go into
  29. # sanity.bbclass because bitbake's source code doesn't even pass
  30. # parsing stage when used with python v3, so we catch it here so we
  31. # can offer a meaningful error message.
  32. py_v3_check=$(/usr/bin/env python --version 2>&1 | grep "Python 3")
  33. if [ -n "$py_v3_check" ]; then
  34. echo >&2 "Bitbake is not compatible with python v3"
  35. echo >&2 "Please set up python v2 as your default python interpreter"
  36. return 1
  37. fi
  38. unset py_v3_check
  39. # Similarly, we now have code that doesn't parse correctly with older
  40. # versions of Python, and rather than fixing that and being eternally
  41. # vigilant for any other new feature use, just check the version here.
  42. py_v26_check=$(python -c 'import sys; print sys.version_info >= (2,7,3)')
  43. if [ "$py_v26_check" != "True" ]; then
  44. echo >&2 "BitBake requires Python 2.7.3 or later"
  45. return 1
  46. fi
  47. unset py_v26_check
  48. if [ -z "$BDIR" ]; then
  49. if [ -z "$1" ]; then
  50. BDIR="build"
  51. else
  52. BDIR="$1"
  53. if [ "$BDIR" = "/" ]; then
  54. echo >&2 "Error: / is not supported as a build directory."
  55. return 1
  56. fi
  57. # Remove any possible trailing slashes. This is used to work around
  58. # buggy readlink in Ubuntu 10.04 that doesn't ignore trailing slashes
  59. # and hence "readlink -f new_dir_to_be_created/" returns empty.
  60. BDIR=$(echo $BDIR | sed -re 's|/+$||')
  61. BDIR=$(readlink -f "$BDIR")
  62. if [ -z "$BDIR" ]; then
  63. PARENTDIR=$(dirname "$1")
  64. echo >&2 "Error: the directory $PARENTDIR does not exist?"
  65. return 1
  66. fi
  67. fi
  68. if [ -n "$2" ]; then
  69. BITBAKEDIR="$2"
  70. fi
  71. fi
  72. if [ "${BDIR#/}" != "$BDIR" ]; then
  73. BUILDDIR="$BDIR"
  74. else
  75. BUILDDIR="$(pwd)/$BDIR"
  76. fi
  77. unset BDIR
  78. if [ -z "$BITBAKEDIR" ]; then
  79. BITBAKEDIR="$OEROOT/bitbake$BBEXTRA"
  80. fi
  81. BITBAKEDIR=$(readlink -f "$BITBAKEDIR")
  82. BUILDDIR=$(readlink -f "$BUILDDIR")
  83. if [ ! -d "$BITBAKEDIR" ]; then
  84. echo >&2 "Error: The bitbake directory ($BITBAKEDIR) does not exist! Please ensure a copy of bitbake exists at this location"
  85. return 1
  86. fi
  87. # Make sure our paths are at the beginning of $PATH
  88. for newpath in "$BITBAKEDIR/bin" "$OEROOT/scripts"; do
  89. # Remove any existences of $newpath from $PATH
  90. PATH=$(echo $PATH | sed -re "s#(^|:)$newpath(:|$)#\2#g;s#^:##")
  91. # Add $newpath to $PATH
  92. PATH="$newpath:$PATH"
  93. done
  94. unset BITBAKEDIR newpath
  95. # Used by the runqemu script
  96. export BUILDDIR
  97. export PATH
  98. BB_ENV_EXTRAWHITE_OE="MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
  99. HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \
  100. all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \
  101. SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \
  102. SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR"
  103. BB_ENV_EXTRAWHITE="$(echo $BB_ENV_EXTRAWHITE $BB_ENV_EXTRAWHITE_OE | tr ' ' '\n' | LC_ALL=C sort --unique | tr '\n' ' ')"
  104. export BB_ENV_EXTRAWHITE