bitbake 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. needgit="1"
  53. TARVERSION=`tar --version | head -n 1 | cut -d ' ' -f 4`
  54. GITVERSION=`git --version | cut -d ' ' -f 3`
  55. float_test() {
  56. echo | awk 'END { exit ( !( '"$1"')); }'
  57. }
  58. version_compare() {
  59. python -c "from distutils.version import LooseVersion; import sys; sys.exit(not (LooseVersion('$1') $2 LooseVersion('$3')))"
  60. }
  61. # Tar version 1.24 and onwards handle overwriting symlinks correctly
  62. # but earlier versions do not; this needs to work properly for sstate
  63. float_test "$TARVERSION > 1.23" && needtar="0"
  64. # Need git >= 1.7.5 for git-remote --mirror=xxx syntax
  65. version_compare $GITVERSION ">=" 1.7.5 && needgit="0"
  66. buildpseudo="1"
  67. if [ $needpseudo = "1" ]; then
  68. if [ -e "$BUILDDIR/pseudodone" ]; then
  69. PSEUDOBINDIR=`cat $BUILDDIR/pseudodone`
  70. else
  71. PSEUDOBINDIR=`bitbake -e | grep STAGING_BINDIR_NATIVE=\" | cut -d '=' -f2 | cut -d '"' -f2`
  72. fi
  73. if [ -e "$PSEUDOBINDIR/pseudo" ]; then
  74. buildpseudo="0"
  75. fi
  76. # Verify that the pseudo recipes are older then the pseudodone file
  77. PSEUDO_RECIPE="`dirname $0`/../meta/recipes-devtools/pseudo"
  78. if [ $buildpseudo -eq 0 ] && [ ! -d "$PSEUDO_RECIPE" ]; then
  79. echo "Unable to verify if pseudo-native is up to date..." >&2
  80. elif [ $buildpseudo -eq 0 ]; then
  81. PSEUDO_NEWER=`find $PSEUDO_RECIPE -type f -newer $BUILDDIR/pseudodone`
  82. if [ -n "$PSEUDO_NEWER" ]; then
  83. buildpseudo="2"
  84. fi
  85. fi
  86. if [ $buildpseudo = "0" -a ! -e "$BUILDDIR/pseudodone" ] ; then
  87. echo $PSEUDOBINDIR > $BUILDDIR/pseudodone
  88. fi
  89. fi
  90. # If tar is already built, we don't want to do it again...
  91. if [ -e "$PSEUDOBINDIR/tar" -a "$needtar" = "1" ]; then
  92. needtar="0"
  93. fi
  94. # If git is already built, we don't want to do it again...
  95. if [ -e "$PSEUDOBINDIR/git" -a "$needgit" = "1" ]; then
  96. needgit="0"
  97. fi
  98. if [ $needpseudo = "0" ]; then
  99. buildpseudo="0"
  100. fi
  101. # If pseudo-native is an argument, assume the user wants to build pseudo-native!
  102. if [ $needpseudo != "0" -a $buildpseudo -eq 0 ]; then
  103. for opt in $@; do
  104. if [ "$opt" = "pseudo-native" ]; then
  105. buildpseudo="3"
  106. break
  107. fi
  108. done
  109. fi
  110. OLDPATH=$PATH
  111. export PATH=`echo $PATH | sed s#[^:]*/scripts:##g`
  112. if [ $buildpseudo -gt 0 ]; then
  113. [ $buildpseudo -eq 1 ] && echo "Pseudo is not present but is required, building this first before the main build"
  114. [ $buildpseudo -eq 2 ] && echo "Pseudo may be out of date, rebuilding pseudo before the main build"
  115. [ $buildpseudo -eq 3 ] && echo "Building pseudo-native before main build"
  116. export PSEUDO_BUILD=1
  117. TARTARGET="tar-replacement-native"
  118. if [ $needtar = "0" ]; then
  119. TARTARGET=""
  120. fi
  121. GITTARGET="git-replacement-native"
  122. if [ $needgit = "0" ]; then
  123. GITTARGET=""
  124. fi
  125. # Pass through debug options
  126. additionalopts=""
  127. for opt in $@; do
  128. for key in $PASSTHROUGH_OPTS; do
  129. if [ $opt = $key ]
  130. then
  131. additionalopts="$additionalopts $opt"
  132. break
  133. fi
  134. done
  135. done
  136. if [ $needtar = "1" ]; then
  137. bitbake $TARTARGET -c populate_sysroot
  138. fi
  139. bitbake pseudo-native $GITTARGET $additionalopts -c populate_sysroot
  140. ret=$?
  141. if [ "$ret" != "0" ]; then
  142. exit 1
  143. fi
  144. PSEUDOBINDIR=`bitbake -e | grep STAGING_BINDIR_NATIVE=\" | cut -d '=' -f2 | cut -d '"' -f2`
  145. ret=$?
  146. if [ "$ret" != "0" ]; then
  147. exit 1
  148. fi
  149. echo $PSEUDOBINDIR > $BUILDDIR/pseudodone
  150. # This needs to exist in case pseudo has to log somewhere
  151. mkdir -p $PSEUDOBINDIR/../../var/pseudo
  152. fi
  153. BITBAKE=`which bitbake`
  154. export PATH=$OLDPATH
  155. if [ $needpseudo = "1" ]; then
  156. export PSEUDO_BUILD=2
  157. PSEUDO_BINDIR=$PSEUDOBINDIR PSEUDO_LIBDIR=$PSEUDOBINDIR/../lib/pseudo/lib PSEUDO_PREFIX=$PSEUDOBINDIR/../../ PSEUDO_DISABLED=1 $PSEUDOBINDIR/pseudo $BITBAKE $@
  158. else
  159. export PSEUDO_BUILD=0
  160. $BITBAKE $@
  161. fi
  162. ret=$?
  163. exit $ret