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