oe-setup-builddir 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #!/bin/sh
  2. # OE Build Environment Setup Script
  3. #
  4. # Copyright (C) 2006-2011 Linux Foundation
  5. #
  6. # SPDX-License-Identifier: GPL-2.0-or-later
  7. #
  8. die() {
  9. echo Error: "$@" >&2
  10. exit 1
  11. }
  12. [ -n "$BUILDDIR" ] || die "The build directory (BUILDDIR) must be set!"
  13. if [ "$1" = '--help' ] || [ "$1" = '-h' ]; then
  14. echo 'Usage: oe-setup-builddir'
  15. echo ''
  16. echo "OpenEmbedded setup-builddir - setup build directory $BUILDDIR"
  17. echo ''
  18. exit 2
  19. fi
  20. mkdir -p "$BUILDDIR/conf"
  21. [ -d "$BUILDDIR" ] || die "The build directory ($BUILDDIR) does not exist!"
  22. [ -w "$BUILDDIR" ] ||
  23. die "Cannot write to $BUILDDIR, perhaps try sourcing with a writable path? i.e. . oe-init-build-env ~/my-build"
  24. # Attempting removal of sticky,setuid bits from BUILDDIR, BUILDDIR/conf
  25. chmod -st "$BUILDDIR" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR"
  26. chmod -st "$BUILDDIR/conf" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR/conf"
  27. cd "$BUILDDIR" || die "Failed to change directory to $BUILDDIR!"
  28. . "$OEROOT/.templateconf"
  29. # Keep the original TEMPLATECONF before possibly prefixing it with $OEROOT below.
  30. ORG_TEMPLATECONF=$TEMPLATECONF
  31. #
  32. # $TEMPLATECONF can point to a directory for the template local.conf & bblayers.conf
  33. #
  34. if [ -n "$TEMPLATECONF" ]; then
  35. if [ ! -d "$TEMPLATECONF" ]; then
  36. # Allow TEMPLATECONF=meta-xyz/conf as a shortcut
  37. if [ -d "$OEROOT/$TEMPLATECONF" ]; then
  38. TEMPLATECONF="$OEROOT/$TEMPLATECONF"
  39. fi
  40. [ -d "$TEMPLATECONF" ] ||
  41. die "TEMPLATECONF value points to nonexistent directory '$TEMPLATECONF'"
  42. fi
  43. templatesdir=$(python3 -c "import sys; print(sys.argv[1].strip('/').split('/')[-2])" "$TEMPLATECONF")
  44. if [ "$templatesdir" != templates ] || [ ! -f "$TEMPLATECONF/../../layer.conf" ]; then
  45. die "TEMPLATECONF value (which is $TEMPLATECONF) must point to meta-some-layer/conf/templates/template-name"
  46. fi
  47. OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample"
  48. OECORELOCALCONF="$TEMPLATECONF/local.conf.sample"
  49. OECORENOTESCONF="$TEMPLATECONF/conf-notes.txt"
  50. fi
  51. unset SHOWYPDOC
  52. if [ -z "$OECORELOCALCONF" ]; then
  53. OECORELOCALCONF="$OEROOT/meta/conf/templates/default/local.conf.sample"
  54. fi
  55. if [ ! -r "$BUILDDIR/conf/local.conf" ]; then
  56. cat <<EOM
  57. You had no conf/local.conf file. This configuration file has therefore been
  58. created for you from $OECORELOCALCONF
  59. You may wish to edit it to, for example, select a different MACHINE (target
  60. hardware).
  61. EOM
  62. cp -f "$OECORELOCALCONF" "$BUILDDIR/conf/local.conf"
  63. SHOWYPDOC=yes
  64. fi
  65. if [ -z "$OECORELAYERCONF" ]; then
  66. OECORELAYERCONF="$OEROOT/meta/conf/templates/default/bblayers.conf.sample"
  67. fi
  68. if [ ! -r "$BUILDDIR/conf/bblayers.conf" ]; then
  69. cat <<EOM
  70. You had no conf/bblayers.conf file. This configuration file has therefore been
  71. created for you from $OECORELAYERCONF
  72. To add additional metadata layers into your configuration please add entries
  73. to conf/bblayers.conf.
  74. EOM
  75. # Put the absolute path to the layers in bblayers.conf so we can run
  76. # bitbake without the init script after the first run.
  77. # ##COREBASE## is deprecated as its meaning was inconsistent, but continue
  78. # to replace it for compatibility.
  79. sed -e "s|##OEROOT##|$OEROOT|g" \
  80. -e "s|##COREBASE##|$OEROOT|g" \
  81. "$OECORELAYERCONF" > "$BUILDDIR/conf/bblayers.conf"
  82. SHOWYPDOC=yes
  83. fi
  84. # Prevent disturbing a new GIT clone in same console
  85. unset OECORELOCALCONF
  86. unset OECORELAYERCONF
  87. # Ending the first-time run message. Show the YP Documentation banner.
  88. if [ -n "$SHOWYPDOC" ]; then
  89. cat <<EOM
  90. The Yocto Project has extensive documentation about OE including a reference
  91. manual which can be found at:
  92. https://docs.yoctoproject.org
  93. For more information about OpenEmbedded see the website:
  94. https://www.openembedded.org/
  95. EOM
  96. # unset SHOWYPDOC
  97. fi
  98. # if [ -z "$OECORENOTESCONF" ]; then
  99. # OECORENOTESCONF="$OEROOT/meta/conf/templates/default/conf-notes.txt"
  100. # fi
  101. # [ ! -r "$OECORENOTESCONF" ] || cat "$OECORENOTESCONF"
  102. unset OECORENOTESCONF
  103. if [ ! -f "$BUILDDIR/conf/templateconf.cfg" ]; then
  104. echo "$ORG_TEMPLATECONF" >"$BUILDDIR/conf/templateconf.cfg"
  105. fi
  106. cat <<EOF
  107. ### Shell environment set up for builds. ###
  108. You can now run 'bitbake <target>'
  109. Common targets are:
  110. EOF
  111. finddir=`ls -d $OEROOT/../meta-*/ | grep -v $OEROOT/../meta-openembedded | grep -v $OEROOT/../meta-riscv`
  112. targets=`find $finddir -wholename '*/images/*.bb'`
  113. for i in $targets;do
  114. printf " %s\n" `basename $i | sed 's,\.bb$,,g'`
  115. done
  116. cat <<EOF
  117. machines:
  118. EOF
  119. machines=`find $finddir -wholename '*/conf/machine/*.conf'`
  120. for i in $machines;do
  121. printf " %s\n" `basename $i | sed 's,\.conf$,,g'`
  122. done
  123. cat <<EOF
  124. You can also run generated qemu images with a command like 'runqemu qemux86'.
  125. Other commonly useful commands are:
  126. - 'devtool' and 'recipetool' handle common recipe tasks
  127. - 'bitbake-layers' handles common layer tasks
  128. - 'oe-pkgdata-util' handles common target package tasks
  129. EOF