blob: 55d73ca1e46fb18864ec08c5a910da4b714d00d4 [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#
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
21if [ -z "$BUILDDIR" ]; then
22 echo >&2 "Error: The build directory (BUILDDIR) must be set!"
23 exit 1
24fi
25
Brad Bishop6e60e8b2018-02-01 10:27:11 -050026if [ "$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
32fi
33
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034mkdir -p "$BUILDDIR/conf"
35
36if [ ! -d "$BUILDDIR" ]; then
37 echo >&2 "Error: The builddir ($BUILDDIR) does not exist!"
38 exit 1
39fi
40
41if [ ! -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
44fi
45
46# Attempting removal of sticky,setuid bits from BUILDDIR, BUILDDIR/conf
47chmod -st "$BUILDDIR" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR"
48chmod -st "$BUILDDIR/conf" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR/conf"
49
50cd "$BUILDDIR"
51
52if [ -f "$BUILDDIR/conf/templateconf.cfg" ]; then
53 TEMPLATECONF=$(cat "$BUILDDIR/conf/templateconf.cfg")
54fi
55
56. $OEROOT/.templateconf
57
58if [ ! -f "$BUILDDIR/conf/templateconf.cfg" ]; then
59 echo "$TEMPLATECONF" >"$BUILDDIR/conf/templateconf.cfg"
60fi
61
62#
63# $TEMPLATECONF can point to a directory for the template local.conf & bblayers.conf
64#
65if [ -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 Bishop37a0e4d2017-12-04 01:01:44 -050072 echo >&2 "Error: TEMPLATECONF value points to nonexistent directory '$TEMPLATECONF'"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073 exit 1
74 fi
75 fi
76 OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample"
77 OECORELOCALCONF="$TEMPLATECONF/local.conf.sample"
78 OECORENOTESCONF="$TEMPLATECONF/conf-notes.txt"
79fi
80
81unset SHOWYPDOC
82if [ -z "$OECORELOCALCONF" ]; then
83 OECORELOCALCONF="$OEROOT/meta/conf/local.conf.sample"
84fi
85if [ ! -r "$BUILDDIR/conf/local.conf" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050086 cat <<EOM
Patrick Williamsc124f4f2015-09-15 14:41:29 -050087You had no conf/local.conf file. This configuration file has therefore been
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050088created for you with some default values. You may wish to edit it to, for
89example, select a different MACHINE (target hardware). See conf/local.conf
90for more information as common configuration options are commented.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091
92EOM
93 cp -f $OECORELOCALCONF "$BUILDDIR/conf/local.conf"
94 SHOWYPDOC=yes
95fi
96
97if [ -z "$OECORELAYERCONF" ]; then
98 OECORELAYERCONF="$OEROOT/meta/conf/bblayers.conf.sample"
99fi
100if [ ! -r "$BUILDDIR/conf/bblayers.conf" ]; then
101 cat <<EOM
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500102You had no conf/bblayers.conf file. This configuration file has therefore been
103created for you with some default values. To add additional metadata layers
104into your configuration please add entries to conf/bblayers.conf.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500105
106EOM
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
116fi
117
118# Prevent disturbing a new GIT clone in same console
119unset OECORELOCALCONF
120unset OECORELAYERCONF
121
122# Ending the first-time run message. Show the YP Documentation banner.
123if [ ! -z "$SHOWYPDOC" ]; then
124 cat <<EOM
125The Yocto Project has extensive documentation about OE including a reference
126manual which can be found at:
127 http://yoctoproject.org/documentation
128
129For more information about OpenEmbedded see their website:
130 http://www.openembedded.org/
131
132EOM
133# unset SHOWYPDOC
134fi
135
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136if [ -z "$OECORENOTESCONF" ]; then
137 OECORENOTESCONF="$OEROOT/meta/conf/conf-notes.txt"
138fi
139[ ! -r "$OECORENOTESCONF" ] || cat $OECORENOTESCONF
140unset OECORENOTESCONF