blob: 2598ba852d198d28f72f79fbb9f33f30fae66a6f [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
78cat <<EOM
79You had no conf/local.conf file. This configuration file has therefore been
80created for you with some default values. You may wish to edit it to use a
81different MACHINE (target hardware) or enable parallel build options to take
82advantage of multiple cores for example. See the file for more information as
83common configuration options are commented.
84
85EOM
86 cp -f $OECORELOCALCONF "$BUILDDIR/conf/local.conf"
87 SHOWYPDOC=yes
88fi
89
90if [ -z "$OECORELAYERCONF" ]; then
91 OECORELAYERCONF="$OEROOT/meta/conf/bblayers.conf.sample"
92fi
93if [ ! -r "$BUILDDIR/conf/bblayers.conf" ]; then
94 cat <<EOM
95You had no conf/bblayers.conf file. The configuration file has been created for
96you with some default values. To add additional metadata layers into your
97configuration please add entries to this file.
98
99EOM
100
101 # Put the abosolute path to the layers in bblayers.conf so we can run
102 # bitbake without the init script after the first run
103 # ##COREBASE## is deprecated as it's meaning was inconsistent, but continue
104 # to replace it for compatibility.
105 sed -e "s|##OEROOT##|$OEROOT|g" \
106 -e "s|##COREBASE##|$OEROOT|g" \
107 $OECORELAYERCONF > "$BUILDDIR/conf/bblayers.conf"
108 SHOWYPDOC=yes
109fi
110
111# Prevent disturbing a new GIT clone in same console
112unset OECORELOCALCONF
113unset OECORELAYERCONF
114
115# Ending the first-time run message. Show the YP Documentation banner.
116if [ ! -z "$SHOWYPDOC" ]; then
117 cat <<EOM
118The Yocto Project has extensive documentation about OE including a reference
119manual which can be found at:
120 http://yoctoproject.org/documentation
121
122For more information about OpenEmbedded see their website:
123 http://www.openembedded.org/
124
125EOM
126# unset SHOWYPDOC
127fi
128
129cat <<EOM
130
131### Shell environment set up for builds. ###
132
133You can now run 'bitbake <target>'
134
135EOM
136if [ -z "$OECORENOTESCONF" ]; then
137 OECORENOTESCONF="$OEROOT/meta/conf/conf-notes.txt"
138fi
139[ ! -r "$OECORENOTESCONF" ] || cat $OECORENOTESCONF
140unset OECORENOTESCONF