summaryrefslogtreecommitdiffstats
path: root/enea-init-build-env
diff options
context:
space:
mode:
Diffstat (limited to 'enea-init-build-env')
-rwxr-xr-xenea-init-build-env264
1 files changed, 264 insertions, 0 deletions
diff --git a/enea-init-build-env b/enea-init-build-env
new file mode 100755
index 0000000000..9bc5bab43f
--- /dev/null
+++ b/enea-init-build-env
@@ -0,0 +1,264 @@
1#!/bin/bash
2if [ "$_" = "$0" ]; then
3 echo "Error: This script needs to be sourced."
4 echo "Please run as 'source $0'."
5 exit
6fi
7
8# always unset these in case something goes wrong in the previous run
9unset BBLAYERS_CONF_EXISTS
10unset BUILD_PATH
11unset CUSTOM_SCRIPTS
12unset DISTRO
13unset DOWNLOAD_DLDIR
14unset SOURCE_MIRROR_URL
15unset ENEAROOT
16unset EXITME
17unset LOCAL_CONF_EXISTS
18unset MACHINE
19unset METALAYERS
20unset NUM_CORES
21unset SSTATE_DIR
22unset SSTATE_MIRRORS
23unset TESTING_ADDITIONS
24unset -f usage
25unset OPTERR
26unset OPTIND
27unset OPTION
28
29NUM_CORES=$(grep -c processor /proc/cpuinfo || echo 2)
30BUILD_PATH="build"
31METALAYERS="meta-enea"
32
33function usage() {
34cat <<EOF
35Usage:
36 source $(basename $BASH_SOURCE) [OPTIONS]
37
38OPTIONS:
39 -b <build dir>
40 Build dir
41 default: build
42
43 -c <script name>
44 Script to be used for further customization
45 Multiple executable customization scripts could be used
46 The customized script must have the executable bit set in order to be used
47 e.g. -c meta-some-layer/scripts/conf_setup.sh
48
49 -g <url>
50 download mirror e.g., file:///media/downloads
51 default: http://linux.enea.com/${DISTRO_VERSION}/sources
52
53 -j <cores>
54 Number of cores to use in build.
55 default: all
56
57 -k <sstate dir>
58 Shared local sstate cache, type -k <build dir>/sstate
59 if you want to use private sstate cache.
60
61 -l <list of meta-layers>
62 List of meta-layers, e.g., -l meta-fsl-ppc,meta-enea-lwrt
63 default: none
64
65 -m <machine name>
66 Machine name (required)
67
68 -t
69 To be used by testing framework.
70 Currently add the distrodata inheritance.
71 -s
72 Non-default DISTRO to use
73
74 -h
75 Help - this text
76EOF
77}
78
79SSTATE_MIRRORS='http://linux.enea.com/${DISTRO_VERSION}/sstate-cache/PATH'
80SOURCE_MIRROR_URL='http://linux.enea.com/${DISTRO_VERSION}/sources'
81
82while getopts ":hb:c:d:f:g:j:k:l:m:ts:" OPTION; do
83 case $OPTION in
84 b)
85 BUILD_PATH=$OPTARG
86 ;;
87 c)
88 CUSTOM_SCRIPTS=$CUSTOM_SCRIPTS" eval $PWD/$OPTARG;"
89 ;;
90 d)
91 # set DL_DIR. be careful when using this, as it's easy to
92 # introduce isseues if this dir is shared
93 DOWNLOAD_DLDIR=$(readlink -m $OPTARG)
94 ;;
95 g)
96 SOURCE_MIRROR_URL=$OPTARG
97 ;;
98 j)
99 NUM_CORES=$OPTARG
100 ;;
101 k)
102 SSTATE_DIR=$(readlink -m $OPTARG)
103 ;;
104 l)
105 METALAYERS="$METALAYERS,$OPTARG"
106 ;;
107 m)
108 MACHINE=$OPTARG
109 ;;
110 t)
111 TESTING_ADDITIONS=1
112 ;;
113 s)
114 DISTRO=$OPTARG
115 ;;
116 h)
117 usage
118 EXITME=1
119 ;;
120 \?)
121 echo "Unknown option '-$OPTARG'"
122 usage
123 EXITME=1
124 ;;
125 esac
126done
127
128METALAYERS="$METALAYERS,meta-openembedded/meta-filesystems,meta-openembedded/meta-networking,meta-openembedded/meta-oe,meta-openembedded/meta-python"
129ENEAROOT="$(pwd)"
130ENEAROOT=$(readlink -f "$ENEAROOT")
131
132if [[ ! -d $SSTATE_DIR && ! -z $SSTATE_DIR ]]; then
133 mkdir -p $SSTATE_DIR
134 if [[ $? -ne 0 ]]; then
135 echo "Error: Unable to create directory $SSTATE_DIR. Do you have permissions?"
136 EXITME=1
137 fi
138fi
139if [[ ! -d $DOWNLOAD_DLDIR && ! -z $DOWNLOAD_DLDIR ]]; then
140 mkdir -p $DOWNLOAD_DLDIR
141 if [[ $? -ne 0 ]]; then
142 echo "Error: Unable to create directory $DOWNLOAD_DLDIR. Do you have permissions?"
143 EXITME=1
144 fi
145fi
146
147if [[ -n $EXITME ]]; then
148 echo
149elif [[ -z $BASH_VERSINFO ]]; then
150 echo "This script requires bash."
151elif [ "$MACHINE"x = "x" -a ! -r "$BUILD_PATH/conf/local.conf" ]; then
152cat <<EOF
153error: When creating a new build dir, you must at least specify -m MACHINE.
154
155Use option -h for help.
156EOF
157else
158
159 if ! (test -r "$BUILD_PATH/conf/local.conf"); then
160 LOCAL_CONF_EXISTS=1
161 fi
162
163 if ! (test -r "$BUILD_PATH/conf/bblayers.conf"); then
164 BBLAYERS_CONF_EXISTS=1
165 fi
166
167 source ./oe-init-build-env $BUILD_PATH
168
169 if [[ -n $LOCAL_CONF_EXISTS ]]; then
170 sed -i \
171 -e "s|^#BB_NUMBER_THREADS.*|BB_NUMBER_THREADS \?= \"$NUM_CORES\"|" \
172 -e "s|^#PARALLEL_MAKE.*|PARALLEL_MAKE \?= \"-j $NUM_CORES\"|" \
173 -e 's|^DISTRO ?= "poky"|DISTRO ?= "enea"|' \
174 conf/local.conf
175 echo "*** Info: Setting BB_NUMBER_THREADS to $NUM_CORES"
176 echo "*** Info: Setting PARALLEL_MAKE to -j$NUM_CORES"
177 echo "*** Info: Setting DISTRO to enea"
178
179 if [[ -n $MACHINE ]]; then
180 sed -i -e "s|^MACHINE.*|MACHINE = \"$MACHINE\"|" conf/local.conf
181 echo "*** Info: Setting MACHINE to $MACHINE"
182 fi
183
184 echo "SSTATE_MIRRORS ?= \"file://.* $SSTATE_MIRRORS\"" >> conf/local.conf
185 echo "*** Info: Setting SSTATE_MIRRORS to $SSTATE_MIRRORS"
186
187 if [[ -n $SSTATE_DIR ]]; then
188 sed -i -e "s|^#SSTATE_DIR ?=.*|SSTATE_DIR ?= \"$SSTATE_DIR\"|" conf/local.conf
189 echo "*** Info: Setting SSTATE_DIR to $SSTATE_DIR"
190 fi
191
192 echo "SOURCE_MIRROR_URL ?= \"$SOURCE_MIRROR_URL\"" >> conf/local.conf
193 echo "*** Info: Setting SOURCE_MIRROR_URL to $SOURCE_MIRROR_URL"
194 echo "INHERIT += \"own-mirrors\"" >> conf/local.conf
195 echo "*** Info: Inheriting own-mirror"
196
197
198 if [[ -n $TESTING_ADDITIONS ]]; then
199 echo "INHERIT += \"distrodata\"" >> conf/local.conf
200 echo "*** Info: Inheriting distrodata."
201 fi
202
203 echo -e '\nLICENSE_FLAGS_WHITELIST += "non-commercial"\n' >> conf/local.conf
204 echo "*** Info: Need to set LICENSE_FLAGS_WHITELIST for netperf"
205
206 if [[ -n $DISTRO ]]; then
207 sed -i -e "s|^DISTRO.*|DISTRO ?= \"$DISTRO\"|" conf/local.conf
208 sed -i -e 's|^PACKAGE_CLASSES ?= "package_rpm"|PACKAGE_CLASSES ?= "package_rpm package_ipk"|' conf/local.conf
209 echo "*** Info: Setting PACKAGE_CLASSES to ipk and rpm"
210 echo "*** Info: Setting DISTRO to $DISTRO "
211 fi
212
213
214 if [[ -n $DOWNLOAD_DLDIR ]]; then
215 sed -i -e "s|^#DL_DIR ?=.*|DL_DIR ?= \"$DOWNLOAD_DLDIR\"|" conf/local.conf
216 echo "*** Info: Setting DL_DIR to $DOWNLOAD_DLDIR"
217 fi
218
219 if [[ ""x != "${CUSTOM_SCRIPTS}"x ]]; then
220 echo "*** Info: Appying \"${CUSTOM_SCRIPTS}\""
221 ${CUSTOM_SCRIPTS}
222 fi
223
224 else
225 echo "You already had conf/local.conf file, no modification is done."
226 fi
227
228 if [[ -n $BBLAYERS_CONF_EXISTS ]]; then
229 if [[ ""x != "${METALAYERS}"x ]]; then
230 for layer in $(echo $METALAYERS | tr ',' ' '); do
231 layer=$ENEAROOT/$layer
232 if [[ ! -d $layer ]]; then
233 echo "*** Error: There is no meta-layer called: $layer"
234 else
235 egrep "$layer " conf/bblayers.conf >/dev/null ||
236 sed -i -e '/.*meta-yocto .*/i\'" $layer \\\\" conf/bblayers.conf
237 echo "*** Info: Adding $layer to bblayers.conf"
238 fi
239 done
240 fi
241 else
242 echo "You already had conf/bblayers.conf file, no modification is done."
243 fi
244fi
245
246unset BBLAYERS_CONF_EXISTS
247unset BUILD_PATH
248unset CUSTOM_SCRIPTS
249unset DISTRO
250unset DOWNLOAD_DLDIR
251unset SOURCE_MIRROR_URL
252unset ENEAROOT
253unset EXITME
254unset LOCAL_CONF_EXISTS
255unset MACHINE
256unset METALAYERS
257unset NUM_CORES
258unset SSTATE_DIR
259unset SSTATE_MIRRORS
260unset TESTING_ADDITIONS
261unset -f usage
262unset OPTERR
263unset OPTIND
264unset OPTION