oe-setup-builddir 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. if [ -z "$BUILDDIR" ]; then
  9. echo >&2 "Error: The build directory (BUILDDIR) must be set!"
  10. exit 1
  11. fi
  12. if [ "$1" = '--help' -o "$1" = '-h' ]; then
  13. echo 'Usage: oe-setup-builddir'
  14. echo ''
  15. echo "OpenEmbedded setup-builddir - setup build directory $BUILDDIR"
  16. echo ''
  17. exit 2
  18. fi
  19. mkdir -p "$BUILDDIR/conf"
  20. if [ ! -d "$BUILDDIR" ]; then
  21. echo >&2 "Error: The builddir ($BUILDDIR) does not exist!"
  22. exit 1
  23. fi
  24. if [ ! -w "$BUILDDIR" ]; then
  25. echo >&2 "Error: Cannot write to $BUILDDIR, perhaps try sourcing with a writable path? i.e. . oe-init-build-env ~/my-build"
  26. exit 1
  27. fi
  28. # Attempting removal of sticky,setuid bits from BUILDDIR, BUILDDIR/conf
  29. chmod -st "$BUILDDIR" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR"
  30. chmod -st "$BUILDDIR/conf" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR/conf"
  31. cd "$BUILDDIR"
  32. if [ -f "$BUILDDIR/conf/templateconf.cfg" ]; then
  33. TEMPLATECONF=$(cat "$BUILDDIR/conf/templateconf.cfg")
  34. fi
  35. . $OEROOT/.templateconf
  36. if [ ! -f "$BUILDDIR/conf/templateconf.cfg" ]; then
  37. echo "$TEMPLATECONF" >"$BUILDDIR/conf/templateconf.cfg"
  38. fi
  39. #
  40. # $TEMPLATECONF can point to a directory for the template local.conf & bblayers.conf
  41. #
  42. if [ -n "$TEMPLATECONF" ]; then
  43. if [ ! -d "$TEMPLATECONF" ]; then
  44. # Allow TEMPLATECONF=meta-xyz/conf as a shortcut
  45. if [ -d "$OEROOT/$TEMPLATECONF" ]; then
  46. TEMPLATECONF="$OEROOT/$TEMPLATECONF"
  47. fi
  48. if [ ! -d "$TEMPLATECONF" ]; then
  49. echo >&2 "Error: TEMPLATECONF value points to nonexistent directory '$TEMPLATECONF'"
  50. exit 1
  51. fi
  52. fi
  53. OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample"
  54. OECORELOCALCONF="$TEMPLATECONF/local.conf.sample"
  55. OECORENOTESCONF="$TEMPLATECONF/conf-notes.txt"
  56. fi
  57. unset SHOWYPDOC
  58. if [ -z "$OECORELOCALCONF" ]; then
  59. OECORELOCALCONF="$OEROOT/meta/conf/local.conf.sample"
  60. fi
  61. if [ ! -r "$BUILDDIR/conf/local.conf" ]; then
  62. cat <<EOM
  63. You had no conf/local.conf file. This configuration file has therefore been
  64. created for you with some default values. You may wish to edit it to, for
  65. example, select a different MACHINE (target hardware). See conf/local.conf
  66. for more information as common configuration options are commented.
  67. EOM
  68. cp -f $OECORELOCALCONF "$BUILDDIR/conf/local.conf"
  69. SHOWYPDOC=yes
  70. fi
  71. if [ -z "$OECORELAYERCONF" ]; then
  72. OECORELAYERCONF="$OEROOT/meta/conf/bblayers.conf.sample"
  73. fi
  74. if [ ! -r "$BUILDDIR/conf/bblayers.conf" ]; then
  75. cat <<EOM
  76. You had no conf/bblayers.conf file. This configuration file has therefore been
  77. created for you with some default values. To add additional metadata layers
  78. into your configuration please add entries to conf/bblayers.conf.
  79. EOM
  80. # Put the abosolute path to the layers in bblayers.conf so we can run
  81. # bitbake without the init script after the first run
  82. # ##COREBASE## is deprecated as it's meaning was inconsistent, but continue
  83. # to replace it for compatibility.
  84. sed -e "s|##OEROOT##|$OEROOT|g" \
  85. -e "s|##COREBASE##|$OEROOT|g" \
  86. $OECORELAYERCONF > "$BUILDDIR/conf/bblayers.conf"
  87. SHOWYPDOC=yes
  88. fi
  89. # Prevent disturbing a new GIT clone in same console
  90. unset OECORELOCALCONF
  91. unset OECORELAYERCONF
  92. # Ending the first-time run message. Show the YP Documentation banner.
  93. if [ ! -z "$SHOWYPDOC" ]; then
  94. cat <<EOM
  95. The Yocto Project has extensive documentation about OE including a reference
  96. manual which can be found at:
  97. http://yoctoproject.org/documentation
  98. For more information about OpenEmbedded see their website:
  99. http://www.openembedded.org/
  100. EOM
  101. # unset SHOWYPDOC
  102. fi
  103. if [ -z "$OECORENOTESCONF" ]; then
  104. OECORENOTESCONF="$OEROOT/meta/conf/conf-notes.txt"
  105. fi
  106. [ ! -r "$OECORENOTESCONF" ] || cat $OECORENOTESCONF
  107. unset OECORENOTESCONF