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