blob: 93722e08adb8d0f2c47f939188f9cf6bc159c8a1 [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
26mkdir -p "$BUILDDIR/conf"
27
28if [ ! -d "$BUILDDIR" ]; then
29 echo >&2 "Error: The builddir ($BUILDDIR) does not exist!"
30 exit 1
31fi
32
33if [ ! -w "$BUILDDIR" ]; then
34 echo >&2 "Error: Cannot write to $BUILDDIR, perhaps try sourcing with a writable path? i.e. . oe-init-build-env ~/my-build"
35 exit 1
36fi
37
38# Attempting removal of sticky,setuid bits from BUILDDIR, BUILDDIR/conf
39chmod -st "$BUILDDIR" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR"
40chmod -st "$BUILDDIR/conf" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR/conf"
41
42cd "$BUILDDIR"
43
44if [ -f "$BUILDDIR/conf/templateconf.cfg" ]; then
45 TEMPLATECONF=$(cat "$BUILDDIR/conf/templateconf.cfg")
46fi
47
48. $OEROOT/.templateconf
49
50if [ ! -f "$BUILDDIR/conf/templateconf.cfg" ]; then
51 echo "$TEMPLATECONF" >"$BUILDDIR/conf/templateconf.cfg"
52fi
53
54#
55# $TEMPLATECONF can point to a directory for the template local.conf & bblayers.conf
56#
57if [ -n "$TEMPLATECONF" ]; then
58 if [ ! -d "$TEMPLATECONF" ]; then
59 # Allow TEMPLATECONF=meta-xyz/conf as a shortcut
60 if [ -d "$OEROOT/$TEMPLATECONF" ]; then
61 TEMPLATECONF="$OEROOT/$TEMPLATECONF"
62 fi
63 if [ ! -d "$TEMPLATECONF" ]; then
64 echo >&2 "Error: '$TEMPLATECONF' must be a directory containing local.conf & bblayers.conf"
65 exit 1
66 fi
67 fi
68 OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample"
69 OECORELOCALCONF="$TEMPLATECONF/local.conf.sample"
70 OECORENOTESCONF="$TEMPLATECONF/conf-notes.txt"
71fi
72
73unset SHOWYPDOC
74if [ -z "$OECORELOCALCONF" ]; then
75 OECORELOCALCONF="$OEROOT/meta/conf/local.conf.sample"
76fi
77if [ ! -r "$BUILDDIR/conf/local.conf" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050078 cat <<EOM
Patrick Williamsc124f4f2015-09-15 14:41:29 -050079You had no conf/local.conf file. This configuration file has therefore been
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050080created for you with some default values. You may wish to edit it to, for
81example, select a different MACHINE (target hardware). See conf/local.conf
82for more information as common configuration options are commented.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083
84EOM
85 cp -f $OECORELOCALCONF "$BUILDDIR/conf/local.conf"
86 SHOWYPDOC=yes
87fi
88
89if [ -z "$OECORELAYERCONF" ]; then
90 OECORELAYERCONF="$OEROOT/meta/conf/bblayers.conf.sample"
91fi
92if [ ! -r "$BUILDDIR/conf/bblayers.conf" ]; then
93 cat <<EOM
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050094You had no conf/bblayers.conf file. This configuration file has therefore been
95created for you with some default values. To add additional metadata layers
96into your configuration please add entries to conf/bblayers.conf.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097
98EOM
99
100 # Put the abosolute path to the layers in bblayers.conf so we can run
101 # bitbake without the init script after the first run
102 # ##COREBASE## is deprecated as it's meaning was inconsistent, but continue
103 # to replace it for compatibility.
104 sed -e "s|##OEROOT##|$OEROOT|g" \
105 -e "s|##COREBASE##|$OEROOT|g" \
106 $OECORELAYERCONF > "$BUILDDIR/conf/bblayers.conf"
107 SHOWYPDOC=yes
108fi
109
110# Prevent disturbing a new GIT clone in same console
111unset OECORELOCALCONF
112unset OECORELAYERCONF
113
114# Ending the first-time run message. Show the YP Documentation banner.
115if [ ! -z "$SHOWYPDOC" ]; then
116 cat <<EOM
117The Yocto Project has extensive documentation about OE including a reference
118manual which can be found at:
119 http://yoctoproject.org/documentation
120
121For more information about OpenEmbedded see their website:
122 http://www.openembedded.org/
123
124EOM
125# unset SHOWYPDOC
126fi
127
128cat <<EOM
129
130### Shell environment set up for builds. ###
131
132You can now run 'bitbake <target>'
133
134EOM
135if [ -z "$OECORENOTESCONF" ]; then
136 OECORENOTESCONF="$OEROOT/meta/conf/conf-notes.txt"
137fi
138[ ! -r "$OECORENOTESCONF" ] || cat $OECORENOTESCONF
139unset OECORENOTESCONF