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