isar-setup-builddir 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #!/bin/sh
  2. # Isar Build Environment Setup Script
  3. #
  4. # Copyright (C) 2006-2011 Linux Foundation
  5. # Copyright (C) 2016 ilbers GmbH
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. if [ -z "$BUILDDIR" ]; then
  21. echo >&2 "Error: The build directory (BUILDDIR) must be set!"
  22. exit 1
  23. fi
  24. mkdir -p "$BUILDDIR/conf"
  25. if [ ! -d "$BUILDDIR" ]; then
  26. echo >&2 "Error: The builddir ($BUILDDIR) does not exist!"
  27. exit 1
  28. fi
  29. if [ ! -w "$BUILDDIR" ]; then
  30. echo >&2 "Error: Cannot write to $BUILDDIR, perhaps try sourcing with a writable path? i.e. . oe-init-build-env ~/my-build"
  31. exit 1
  32. fi
  33. # Attempting removal of sticky,setuid bits from BUILDDIR, BUILDDIR/conf
  34. chmod -st "$BUILDDIR" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR"
  35. chmod -st "$BUILDDIR/conf" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR/conf"
  36. cd "$BUILDDIR"
  37. if [ -f "$BUILDDIR/conf/templateconf.cfg" ]; then
  38. TEMPLATECONF=$(cat "$BUILDDIR/conf/templateconf.cfg")
  39. fi
  40. . $ISARROOT/.templateconf
  41. if [ ! -f "$BUILDDIR/conf/templateconf.cfg" ]; then
  42. echo "$TEMPLATECONF" >"$BUILDDIR/conf/templateconf.cfg"
  43. fi
  44. #
  45. # $TEMPLATECONF can point to a directory for the template local.conf & bblayers.conf
  46. #
  47. if [ -n "$TEMPLATECONF" ]; then
  48. if [ ! -d "$TEMPLATECONF" ]; then
  49. # Allow TEMPLATECONF=meta-xyz/conf as a shortcut
  50. if [ -d "$ISARROOT/$TEMPLATECONF" ]; then
  51. TEMPLATECONF="$ISARROOT/$TEMPLATECONF"
  52. fi
  53. if [ ! -d "$TEMPLATECONF" ]; then
  54. echo >&2 "Error: '$TEMPLATECONF' must be a directory containing local.conf & bblayers.conf"
  55. exit 1
  56. fi
  57. fi
  58. ISARCORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample"
  59. ISARCORELOCALCONF="$TEMPLATECONF/local.conf.sample"
  60. ISARCORENOTESCONF="$TEMPLATECONF/conf-notes.txt"
  61. fi
  62. unset SHOWYPDOC
  63. if [ -z "$ISARCORELOCALCONF" ]; then
  64. ISARCORELOCALCONF="$ISARROOT/meta/conf/local.conf.sample"
  65. fi
  66. if [ ! -r "$BUILDDIR/conf/local.conf" ]; then
  67. cat <<EOM
  68. You had no conf/local.conf file. This configuration file has therefore been
  69. created for you with some default values. You may wish to edit it to, for
  70. example, select a different MACHINE (target hardware). See conf/local.conf
  71. for more information as common configuration options are commented.
  72. EOM
  73. cp -f $ISARCORELOCALCONF "$BUILDDIR/conf/local.conf"
  74. SHOWYPDOC=yes
  75. fi
  76. if [ -z "$ISARCORELAYERCONF" ]; then
  77. ISARCORELAYERCONF="$ISARROOT/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. This configuration file has therefore been
  82. created for you with some default values. To add additional metadata layers
  83. into your configuration please add entries to conf/bblayers.conf.
  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. sed -e "s|##ISARROOT##|$ISARROOT|g" \
  88. $ISARCORELAYERCONF > "$BUILDDIR/conf/bblayers.conf"
  89. SHOWYPDOC=yes
  90. fi
  91. if [ ! -f "$BUILDDIR/conf/bitbake.conf" ]; then
  92. cp "$ISARROOT/meta-isar/conf/bitbake.conf.sample" \
  93. "$BUILDDIR/conf/bitbake.conf"
  94. fi
  95. # Ending the first-time run message. Show the no documentation banner.
  96. if [ ! -z "$SHOWYPDOC" ]; then
  97. cat <<EOM
  98. For more information about isar, contact the developers at:
  99. https://lists.debian.org/debian-embedded/
  100. EOM
  101. unset SHOWYPDOC
  102. fi
  103. cat <<EOM
  104. ### Shell environment set up for builds. ###
  105. You can now run 'bitbake <target>'
  106. EOM
  107. if [ -z "$ISARCORENOTESCONF" ]; then
  108. ISARCORENOTESCONF="$ISARROOT/meta/conf/conf-notes.txt"
  109. fi
  110. [ ! -r "$ISARCORENOTESCONF" ] || cat $ISARCORENOTESCONF
  111. unset ISARCORENOTESCONF