oe-setup-builddir 4.4 KB

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