blob: dcb384c33a6b29beffbd6e66734501681a3da75f [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/bin/sh
2
3# OE Build Environment Setup Script
4#
5# Copyright (C) 2006-2011 Linux Foundation
6#
Brad Bishopc342db32019-05-15 21:57:59 -04007# SPDX-License-Identifier: GPL-2.0-or-later
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008#
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009
Andrew Geissler87f5cff2022-09-30 13:13:31 -050010die() {
11 echo Error: "$@" >&2
Patrick Williamsc124f4f2015-09-15 14:41:29 -050012 exit 1
Andrew Geissler87f5cff2022-09-30 13:13:31 -050013}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014
Andrew Geissler87f5cff2022-09-30 13:13:31 -050015[ -n "$BUILDDIR" ] || die "The build directory (BUILDDIR) must be set!"
16
17if [ "$1" = '--help' ] || [ "$1" = '-h' ]; then
Brad Bishop6e60e8b2018-02-01 10:27:11 -050018 echo 'Usage: oe-setup-builddir'
19 echo ''
20 echo "OpenEmbedded setup-builddir - setup build directory $BUILDDIR"
21 echo ''
22 exit 2
23fi
24
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025mkdir -p "$BUILDDIR/conf"
26
Andrew Geissler87f5cff2022-09-30 13:13:31 -050027[ -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 Williamsc124f4f2015-09-15 14:41:29 -050030
31# Attempting removal of sticky,setuid bits from BUILDDIR, BUILDDIR/conf
32chmod -st "$BUILDDIR" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR"
33chmod -st "$BUILDDIR/conf" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR/conf"
34
Andrew Geissler87f5cff2022-09-30 13:13:31 -050035cd "$BUILDDIR" || die "Failed to change directory to $BUILDDIR!"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036
Andrew Geissler87f5cff2022-09-30 13:13:31 -050037. "$OEROOT/.templateconf"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038
Andrew Geissler87f5cff2022-09-30 13:13:31 -050039# Keep the original TEMPLATECONF before possibly prefixing it with $OEROOT below.
40ORG_TEMPLATECONF=$TEMPLATECONF
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041
Andrew Geissler87f5cff2022-09-30 13:13:31 -050042#
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043# $TEMPLATECONF can point to a directory for the template local.conf & bblayers.conf
44#
45if [ -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 Geissler87f5cff2022-09-30 13:13:31 -050051 [ -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 Williamsc124f4f2015-09-15 14:41:29 -050057 fi
58 OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample"
59 OECORELOCALCONF="$TEMPLATECONF/local.conf.sample"
Patrick Williams73bd93f2024-02-20 08:07:48 -060060 OECORESUMMARYCONF="$TEMPLATECONF/conf-summary.txt"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061 OECORENOTESCONF="$TEMPLATECONF/conf-notes.txt"
62fi
63
64unset SHOWYPDOC
65if [ -z "$OECORELOCALCONF" ]; then
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060066 OECORELOCALCONF="$OEROOT/meta/conf/templates/default/local.conf.sample"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067fi
68if [ ! -r "$BUILDDIR/conf/local.conf" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050069 cat <<EOM
Patrick Williamsc124f4f2015-09-15 14:41:29 -050070You had no conf/local.conf file. This configuration file has therefore been
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050071created for you from $OECORELOCALCONF
72You may wish to edit it to, for example, select a different MACHINE (target
Andrew Geissler87f5cff2022-09-30 13:13:31 -050073hardware).
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074
75EOM
Patrick Williamsde0582f2022-04-08 10:23:27 -050076 cp -f "$OECORELOCALCONF" "$BUILDDIR/conf/local.conf"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050077 SHOWYPDOC=yes
78fi
79
80if [ -z "$OECORELAYERCONF" ]; then
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060081 OECORELAYERCONF="$OEROOT/meta/conf/templates/default/bblayers.conf.sample"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050082fi
83if [ ! -r "$BUILDDIR/conf/bblayers.conf" ]; then
84 cat <<EOM
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050085You had no conf/bblayers.conf file. This configuration file has therefore been
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050086created for you from $OECORELAYERCONF
87To add additional metadata layers into your configuration please add entries
88to conf/bblayers.conf.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050089
90EOM
91
Andrew Geissler9aee5002022-03-30 16:27:02 +000092 # Put the absolute path to the layers in bblayers.conf so we can run
93 # bitbake without the init script after the first run.
94 # ##COREBASE## is deprecated as its meaning was inconsistent, but continue
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095 # to replace it for compatibility.
96 sed -e "s|##OEROOT##|$OEROOT|g" \
97 -e "s|##COREBASE##|$OEROOT|g" \
Patrick Williamsde0582f2022-04-08 10:23:27 -050098 "$OECORELAYERCONF" > "$BUILDDIR/conf/bblayers.conf"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050099 SHOWYPDOC=yes
100fi
101
Patrick Williams73bd93f2024-02-20 08:07:48 -0600102if [ -z "$OECORESUMMARYCONF" ]; then
103 OECORESUMMARYCONF="$OEROOT/meta/conf/templates/default/conf-summary.txt"
104fi
105if [ ! -r "$BUILDDIR/conf/conf-summary.txt" ]; then
106 [ ! -r "$OECORESUMMARYCONF" ] || cp "$OECORESUMMARYCONF" "$BUILDDIR/conf/conf-summary.txt"
107fi
108
Andrew Geissler8f840682023-07-21 09:09:43 -0500109if [ -z "$OECORENOTESCONF" ]; then
110 OECORENOTESCONF="$OEROOT/meta/conf/templates/default/conf-notes.txt"
111fi
112if [ ! -r "$BUILDDIR/conf/conf-notes.txt" ]; then
113 [ ! -r "$OECORENOTESCONF" ] || cp "$OECORENOTESCONF" "$BUILDDIR/conf/conf-notes.txt"
114fi
115
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500116# Prevent disturbing a new GIT clone in same console
117unset OECORELOCALCONF
118unset OECORELAYERCONF
Patrick Williams73bd93f2024-02-20 08:07:48 -0600119unset OECORESUMMARYCONF
Andrew Geissler8f840682023-07-21 09:09:43 -0500120unset OECORENOTESCONF
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500121
122# Ending the first-time run message. Show the YP Documentation banner.
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500123if [ -n "$SHOWYPDOC" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500124 cat <<EOM
125The Yocto Project has extensive documentation about OE including a reference
126manual which can be found at:
Patrick Williams213cb262021-08-07 19:21:33 -0500127 https://docs.yoctoproject.org
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500128
Andrew Geissler9aee5002022-03-30 16:27:02 +0000129For more information about OpenEmbedded see the website:
Patrick Williams213cb262021-08-07 19:21:33 -0500130 https://www.openembedded.org/
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500131
132EOM
133# unset SHOWYPDOC
134fi
135
Patrick Williams73bd93f2024-02-20 08:07:48 -0600136[ ! -r "$BUILDDIR/conf/conf-summary.txt" ] || cat "$BUILDDIR/conf/conf-summary.txt"
Andrew Geissler8f840682023-07-21 09:09:43 -0500137[ ! -r "$BUILDDIR/conf/conf-notes.txt" ] || cat "$BUILDDIR/conf/conf-notes.txt"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500138
139if [ ! -f "$BUILDDIR/conf/templateconf.cfg" ]; then
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500140 echo "$ORG_TEMPLATECONF" >"$BUILDDIR/conf/templateconf.cfg"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500141fi