summaryrefslogtreecommitdiffstats
path: root/enea-init-build-env
diff options
context:
space:
mode:
authorAdrian Dudau <adrian.dudau@enea.com>2014-06-26 14:36:22 +0200
committerAdrian Dudau <adrian.dudau@enea.com>2014-06-26 15:32:53 +0200
commitf4cf9fe05bb3f32fabea4e54dd92d368967a80da (patch)
tree487180fa9866985ea7b28e625651765d86f515c3 /enea-init-build-env
downloadpoky-f4cf9fe05bb3f32fabea4e54dd92d368967a80da.tar.gz
initial commit for Enea Linux 4.0
Migrated from the internal git server on the daisy-enea branch Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'enea-init-build-env')
-rwxr-xr-xenea-init-build-env265
1 files changed, 265 insertions, 0 deletions
diff --git a/enea-init-build-env b/enea-init-build-env
new file mode 100755
index 0000000000..09d59cd3aa
--- /dev/null
+++ b/enea-init-build-env
@@ -0,0 +1,265 @@
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 DOWNLOAD_MIRRORS
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 customisation
45 Multiple custom executable stripts could be used
46 The custom 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
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
79DOWNLOAD_MIRRORS='http://linux.enea.com/${DISTRO_VERSION}/sources/'
80SSTATE_MIRRORS='http://linux.enea.com/${DISTRO_VERSION}/sstate-cache/PATH'
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 DOWNLOAD_MIRRORS=$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"
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 http://linux.enea.com"
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 sed -i -e 's|^PACKAGE_CLASSES ?= "package_rpm"|PACKAGE_CLASSES ?= "package_ipk"|' conf/local.conf
193 echo "*** Info: Setting PACKAGE_CLASSES to ipk"
194
195 echo "SOURCE_MIRROR_URL ?= \"$DOWNLOAD_MIRRORS\"" >> conf/local.conf
196 echo "INHERIT += \"own-mirrors\"" >> conf/local.conf
197 echo "*** Info: Setting SOURCE_MIRROR_URL to http://linux.enea.com"
198
199 if [[ -n $TESTING_ADDITIONS ]]; then
200 echo "INHERIT += \"distrodata\"" >> conf/local.conf
201 echo "*** Info: Inheriting distrodata."
202 fi
203
204 echo -e '\nLICENSE_FLAGS_WHITELIST += "non-commercial"\n' >> conf/local.conf
205 echo "*** Info: Need to set LICENSE_FLAGS_WHITELIST for netperf"
206
207 if [[ -n $DISTRO ]]; then
208 sed -i -e "s|^DISTRO.*|DISTRO ?= \"$DISTRO\"|" conf/local.conf
209 sed -i -e 's|^PACKAGE_CLASSES ?= "package_ipk"|PACKAGE_CLASSES ?= "package_rpm package_ipk"|' conf/local.conf
210 echo "*** Info: Setting PACKAGE_CLASSES to rpm"
211 echo "*** Info: Setting DISTRO to $DISTRO "
212 fi
213
214
215 if [[ -n $DOWNLOAD_DLDIR ]]; then
216 sed -i -e "s|^#DL_DIR ?=.*|DL_DIR ?= \"$DOWNLOAD_DLDIR\"|" conf/local.conf
217 echo "*** Info: Setting DL_DIR to $DOWNLOAD_DLDIR"
218 fi
219
220 if [[ ""x != "${CUSTOM_SCRIPTS}"x ]]; then
221 echo "*** Info: Appying \"${CUSTOM_SCRIPTS}\""
222 ${CUSTOM_SCRIPTS}
223 fi
224
225 else
226 echo "You already had conf/local.conf file, no modification is done."
227 fi
228
229 if [[ -n $BBLAYERS_CONF_EXISTS ]]; then
230 if [[ ""x != "${METALAYERS}"x ]]; then
231 for layer in $(echo $METALAYERS | tr ',' ' '); do
232 layer=$ENEAROOT/$layer
233 if [[ ! -d $layer ]]; then
234 echo "*** Error: There is no meta-layer called: $layer"
235 else
236 egrep "$layer " conf/bblayers.conf >/dev/null ||
237 sed -i -e '/.*meta-yocto .*/i\'" $layer \\\\" conf/bblayers.conf
238 echo "*** Info: Adding $layer to bblayers.conf"
239 fi
240 done
241 fi
242 else
243 echo "You already had conf/bblayers.conf file, no modification is done."
244 fi
245fi
246
247unset BBLAYERS_CONF_EXISTS
248unset BUILD_PATH
249unset CUSTOM_SCRIPTS
250unset DISTRO
251unset DOWNLOAD_DLDIR
252unset DOWNLOAD_MIRRORS
253unset ENEAROOT
254unset EXITME
255unset LOCAL_CONF_EXISTS
256unset MACHINE
257unset METALAYERS
258unset NUM_CORES
259unset SSTATE_DIR
260unset SSTATE_MIRRORS
261unset TESTING_ADDITIONS
262unset -f usage
263unset OPTERR
264unset OPTIND
265unset OPTION