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