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 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 41 | if [ -f "$BUILDDIR/conf/templateconf.cfg" -a -z "$TEMPLATECONF" ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 42 | TEMPLATECONF=$(cat "$BUILDDIR/conf/templateconf.cfg") |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 43 | # The following two are no longer valid; unsetting them will automatically get them replaced |
| 44 | # with correct ones. |
| 45 | if [ $TEMPLATECONF = "meta/conf" -o $TEMPLATECONF = "meta-poky/conf" ]; then |
| 46 | unset TEMPLATECONF |
| 47 | rm $BUILDDIR/conf/templateconf.cfg |
| 48 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 49 | fi |
| 50 | |
Patrick Williams | de0582f | 2022-04-08 10:23:27 -0500 | [diff] [blame] | 51 | . "$OEROOT"/.templateconf |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 53 | # |
| 54 | # $TEMPLATECONF can point to a directory for the template local.conf & bblayers.conf |
| 55 | # |
| 56 | if [ -n "$TEMPLATECONF" ]; then |
| 57 | if [ ! -d "$TEMPLATECONF" ]; then |
| 58 | # Allow TEMPLATECONF=meta-xyz/conf as a shortcut |
| 59 | if [ -d "$OEROOT/$TEMPLATECONF" ]; then |
| 60 | TEMPLATECONF="$OEROOT/$TEMPLATECONF" |
| 61 | fi |
| 62 | if [ ! -d "$TEMPLATECONF" ]; then |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 63 | echo >&2 "Error: TEMPLATECONF value points to nonexistent directory '$TEMPLATECONF'" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 64 | exit 1 |
| 65 | fi |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 66 | templatesdir=$(python3 -c "import sys; print(sys.argv[1].strip('/').split('/')[-2])" $TEMPLATECONF) |
| 67 | if [ ! -f "$TEMPLATECONF/../../layer.conf" -o $templatesdir != "templates" ]; then |
| 68 | echo >&2 "Error: TEMPLATECONF value (which is $TEMPLATECONF) must point to meta-some-layer/conf/templates/template-name" |
| 69 | exit 1 |
| 70 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 71 | fi |
| 72 | OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample" |
| 73 | OECORELOCALCONF="$TEMPLATECONF/local.conf.sample" |
| 74 | OECORENOTESCONF="$TEMPLATECONF/conf-notes.txt" |
| 75 | fi |
| 76 | |
| 77 | unset SHOWYPDOC |
| 78 | if [ -z "$OECORELOCALCONF" ]; then |
| 79 | OECORELOCALCONF="$OEROOT/meta/conf/local.conf.sample" |
| 80 | fi |
| 81 | if [ ! -r "$BUILDDIR/conf/local.conf" ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 82 | cat <<EOM |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 83 | You had no conf/local.conf file. This configuration file has therefore been |
Patrick Williams | db4c27e | 2022-08-05 08:10:29 -0500 | [diff] [blame] | 84 | created for you from $OECORELOCALCONF |
| 85 | You may wish to edit it to, for example, select a different MACHINE (target |
| 86 | hardware). See conf/local.conf for more information as common configuration |
| 87 | options are commented. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 88 | |
| 89 | EOM |
Patrick Williams | de0582f | 2022-04-08 10:23:27 -0500 | [diff] [blame] | 90 | cp -f "$OECORELOCALCONF" "$BUILDDIR/conf/local.conf" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 91 | SHOWYPDOC=yes |
| 92 | fi |
| 93 | |
| 94 | if [ -z "$OECORELAYERCONF" ]; then |
| 95 | OECORELAYERCONF="$OEROOT/meta/conf/bblayers.conf.sample" |
| 96 | fi |
| 97 | if [ ! -r "$BUILDDIR/conf/bblayers.conf" ]; then |
| 98 | cat <<EOM |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 99 | You had no conf/bblayers.conf file. This configuration file has therefore been |
Patrick Williams | db4c27e | 2022-08-05 08:10:29 -0500 | [diff] [blame] | 100 | created for you from $OECORELAYERCONF |
| 101 | To add additional metadata layers into your configuration please add entries |
| 102 | to conf/bblayers.conf. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 103 | |
| 104 | EOM |
| 105 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 106 | # Put the absolute path to the layers in bblayers.conf so we can run |
| 107 | # bitbake without the init script after the first run. |
| 108 | # ##COREBASE## is deprecated as its meaning was inconsistent, but continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 109 | # to replace it for compatibility. |
| 110 | sed -e "s|##OEROOT##|$OEROOT|g" \ |
| 111 | -e "s|##COREBASE##|$OEROOT|g" \ |
Patrick Williams | de0582f | 2022-04-08 10:23:27 -0500 | [diff] [blame] | 112 | "$OECORELAYERCONF" > "$BUILDDIR/conf/bblayers.conf" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 113 | SHOWYPDOC=yes |
| 114 | fi |
| 115 | |
| 116 | # Prevent disturbing a new GIT clone in same console |
| 117 | unset OECORELOCALCONF |
| 118 | unset OECORELAYERCONF |
| 119 | |
| 120 | # Ending the first-time run message. Show the YP Documentation banner. |
| 121 | if [ ! -z "$SHOWYPDOC" ]; then |
| 122 | cat <<EOM |
| 123 | The Yocto Project has extensive documentation about OE including a reference |
| 124 | manual which can be found at: |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 125 | https://docs.yoctoproject.org |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 126 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 127 | For more information about OpenEmbedded see the website: |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 128 | https://www.openembedded.org/ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 129 | |
| 130 | EOM |
| 131 | # unset SHOWYPDOC |
| 132 | fi |
| 133 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 134 | if [ -z "$OECORENOTESCONF" ]; then |
| 135 | OECORENOTESCONF="$OEROOT/meta/conf/conf-notes.txt" |
| 136 | fi |
Patrick Williams | de0582f | 2022-04-08 10:23:27 -0500 | [diff] [blame] | 137 | [ ! -r "$OECORENOTESCONF" ] || cat "$OECORENOTESCONF" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 138 | unset OECORENOTESCONF |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 139 | |
| 140 | if [ ! -f "$BUILDDIR/conf/templateconf.cfg" ]; then |
| 141 | echo "$TEMPLATECONF" >"$BUILDDIR/conf/templateconf.cfg" |
| 142 | fi |