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