bitbake 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #!/bin/sh
  2. # This is the bitbake wrapper script that ensures everything is set up
  3. # correctly in the environment, builds pseudo separately if it hasn't
  4. # already been built, and then runs bitbake within pseudo.
  5. export BBFETCH2=True
  6. export BB_ENV_EXTRAWHITE="PSEUDO_BUILD PSEUDO_DISABLED $BB_ENV_EXTRAWHITE"
  7. # For certain operations (i.e. that won't be actually running any tasks)
  8. # we don't need pseudo
  9. NO_BUILD_OPTS="--version -h --help -p --parse-only -s --show-versions -e --environment -g --graphviz"
  10. # Some options are useful to pass through to the initial pseudo build if
  11. # that needs to be run (for debugging)
  12. PASSTHROUGH_OPTS="-D -DD -DDD -DDDD -v"
  13. needpseudo="1"
  14. for opt in $@; do
  15. for key in $NO_BUILD_OPTS; do
  16. if [ $opt = $key ]
  17. then
  18. needpseudo="0"
  19. break
  20. fi
  21. done
  22. [ $needpseudo = "0" ] && break
  23. done
  24. # Make sure we're not using python v3.x. This check can't go into
  25. # sanity.bbclass because bitbake's source code doesn't even pass
  26. # parsing stage when used with python v3, so we catch it here so we
  27. # can offer a meaningful error message.
  28. py_v3_check=`/usr/bin/env python --version 2>&1 | grep "Python 3"`
  29. if [ "$py_v3_check" != "" ]; then
  30. echo "Bitbake is not compatible with python v3"
  31. echo "Please set up python v2 as your default python interpreter"
  32. exit 1
  33. fi
  34. # Similarly, we now have code that doesn't parse correctly with older
  35. # versions of Python, and rather than fixing that and being eternally
  36. # vigilant for any other new feature use, just check the version here.
  37. py_v26_check=`python -c 'import sys; print sys.version_info >= (2,6,0)'`
  38. if [ "$py_v26_check" != "True" ]; then
  39. echo "BitBake requires Python 2.6 or later"
  40. exit 1
  41. fi
  42. if [ ! -e conf/bblayers.conf ] ; then
  43. BDPRINT=""
  44. [ -n "$BUILDDIR" ] && BDPRINT=": $BUILDDIR"
  45. echo "Unable to find conf/bblayers.conf"
  46. echo "BitBake must be run from within your build directory$BDPRINT"
  47. exit 1
  48. elif [ -z "$BUILDDIR" ] ; then
  49. BUILDDIR="`pwd`"
  50. fi
  51. needtar="1"
  52. TARVERSION=`tar --version | head -n 1 | cut -d ' ' -f 4`
  53. float_test() {
  54. echo | awk 'END { exit ( !( '"$1"')); }'
  55. }
  56. # Tar version 1.24 and onwards handle overwriting symlinks correctly
  57. # but earlier versions do not; this needs to work properly for sstate
  58. float_test "$TARVERSION > 1.23" && needtar="0"
  59. buildpseudo="1"
  60. if [ $needpseudo = "1" ]; then
  61. if [ -e "$BUILDDIR/pseudodone" ]; then
  62. PSEUDOBINDIR=`cat $BUILDDIR/pseudodone`
  63. else
  64. PSEUDOBINDIR=`bitbake -e | grep STAGING_BINDIR_NATIVE=\" | cut -d '=' -f2 | cut -d '"' -f2`
  65. fi
  66. if [ -e "$PSEUDOBINDIR/pseudo" ]; then
  67. buildpseudo="0"
  68. fi
  69. # Verify that the pseudo recipes are older then the pseudodone file
  70. PSEUDO_RECIPE="`dirname $0`/../meta/recipes-devtools/pseudo"
  71. if [ $buildpseudo -eq 0 ] && [ ! -d "$PSEUDO_RECIPE" ]; then
  72. echo "Unable to verify if pseudo-native is up to date..." >&2
  73. elif [ $buildpseudo -eq 0 ]; then
  74. PSEUDO_NEWER=`find $PSEUDO_RECIPE -type f -newer $BUILDDIR/pseudodone`
  75. if [ -n "$PSEUDO_NEWER" ]; then
  76. buildpseudo="2"
  77. fi
  78. fi
  79. if [ $buildpseudo = "0" -a ! -e "$BUILDDIR/pseudodone" ] ; then
  80. echo $PSEUDOBINDIR > $BUILDDIR/pseudodone
  81. fi
  82. fi
  83. # If tar is already built, we don't want to do it again...
  84. if [ -e "$PSEUDOBINDIR/tar" -a "$needtar" = "1" ]; then
  85. needtar="0"
  86. fi
  87. if [ $needpseudo = "0" ]; then
  88. buildpseudo="0"
  89. fi
  90. # If pseudo-native is an argument, assume the user wants to build pseudo-native!
  91. if [ $needpseudo != "0" -a $buildpseudo -eq 0 ]; then
  92. for opt in $@; do
  93. if [ "$opt" = "pseudo-native" ]; then
  94. buildpseudo="3"
  95. break
  96. fi
  97. done
  98. fi
  99. OLDPATH=$PATH
  100. export PATH=`echo $PATH | sed s#[^:]*/scripts:##`
  101. if [ $buildpseudo -gt 0 ]; then
  102. [ $buildpseudo -eq 1 ] && echo "Pseudo is not present but is required, building this first before the main build"
  103. [ $buildpseudo -eq 2 ] && echo "Pseudo may be out of date, rebuilding pseudo before the main build"
  104. [ $buildpseudo -eq 3 ] && echo "Building pseudo-native before main build"
  105. export PSEUDO_BUILD=1
  106. TARTARGET="tar-replacement-native"
  107. if [ $needtar = "0" ]; then
  108. TARTARGET=""
  109. fi
  110. # Pass through debug options
  111. additionalopts=""
  112. for opt in $@; do
  113. for key in $PASSTHROUGH_OPTS; do
  114. if [ $opt = $key ]
  115. then
  116. additionalopts="$additionalopts $opt"
  117. break
  118. fi
  119. done
  120. done
  121. if [ $needtar = "1" ]; then
  122. bitbake $TARTARGET -c populate_sysroot
  123. fi
  124. bitbake pseudo-native $additionalopts -c populate_sysroot
  125. ret=$?
  126. if [ "$ret" != "0" ]; then
  127. exit 1
  128. fi
  129. PSEUDOBINDIR=`bitbake -e | grep STAGING_BINDIR_NATIVE=\" | cut -d '=' -f2 | cut -d '"' -f2`
  130. ret=$?
  131. if [ "$ret" != "0" ]; then
  132. exit 1
  133. fi
  134. echo $PSEUDOBINDIR > $BUILDDIR/pseudodone
  135. # This needs to exist in case pseudo has to log somewhere
  136. mkdir -p $PSEUDOBINDIR/../../var/pseudo
  137. fi
  138. BITBAKE=`which bitbake`
  139. export PATH=$OLDPATH
  140. if [ $needpseudo = "1" ]; then
  141. export PSEUDO_BUILD=2
  142. PSEUDO_BINDIR=$PSEUDOBINDIR PSEUDO_LIBDIR=$PSEUDOBINDIR/../lib/pseudo/lib PSEUDO_PREFIX=$PSEUDOBINDIR/../../ PSEUDO_DISABLED=1 $PSEUDOBINDIR/pseudo $BITBAKE $@
  143. else
  144. export PSEUDO_BUILD=0
  145. $BITBAKE $@
  146. fi
  147. ret=$?
  148. exit $ret