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..06c085597b
--- /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 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 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
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'
80
81while getopts ":hb:c:d:f:g:j:k:l:m:ts:" OPTION; do
82 case $OPTION in
83 b)
84 BUILD_PATH=$OPTARG
85 ;;
86 c)
87 CUSTOM_SCRIPTS=$CUSTOM_SCRIPTS" eval $PWD/$OPTARG;"
88 ;;
89 d)
90 # set DL_DIR. be careful when using this, as it's easy to
91 # introduce isseues if this dir is shared
92 DOWNLOAD_DLDIR=$(readlink -m $OPTARG)
93 ;;
94 g)
95 DOWNLOAD_MIRRORS=$OPTARG
96 ;;
97 j)
98 NUM_CORES=$OPTARG
99 ;;
100 k)
101 SSTATE_DIR=$(readlink -m $OPTARG)
102 ;;
103 l)
104 METALAYERS="$METALAYERS,$OPTARG"
105 ;;
106 m)
107 MACHINE=$OPTARG
108 ;;
109 t)
110 TESTING_ADDITIONS=1
111 ;;
112 s)
113 DISTRO=$OPTARG
114 ;;
115 h)
116 usage
117 EXITME=1
118 ;;
119 \?)
120 echo "Unknown option '-$OPTARG'"
121 usage
122 EXITME=1
123 ;;
124 esac
125done
126
127METALAYERS="$METALAYERS,meta-openembedded/meta-filesystems,meta-openembedded/meta-networking,meta-openembedded/meta-oe"
128ENEAROOT="$(pwd)"
129ENEAROOT=$(readlink -f "$ENEAROOT")
130
131if [[ ! -d $SSTATE_DIR && ! -z $SSTATE_DIR ]]; then
132 mkdir -p $SSTATE_DIR
133 if [[ $? -ne 0 ]]; then
134 echo "Error: Unable to create directory $SSTATE_DIR. Do you have permissions?"
135 EXITME=1
136 fi
137fi
138if [[ ! -d $DOWNLOAD_DLDIR && ! -z $DOWNLOAD_DLDIR ]]; then
139 mkdir -p $DOWNLOAD_DLDIR
140 if [[ $? -ne 0 ]]; then
141 echo "Error: Unable to create directory $DOWNLOAD_DLDIR. Do you have permissions?"
142 EXITME=1
143 fi
144fi
145
146if [[ -n $EXITME ]]; then
147 echo
148elif [[ -z $BASH_VERSINFO ]]; then
149 echo "This script requires bash."
150elif [ "$MACHINE"x = "x" -a ! -r "$BUILD_PATH/conf/local.conf" ]; then
151cat <<EOF
152error: When creating a new build dir, you must at least specify -m MACHINE.
153
154Use option -h for help.
155EOF
156else
157
158 if ! (test -r "$BUILD_PATH/conf/local.conf"); then
159 LOCAL_CONF_EXISTS=1
160 fi
161
162 if ! (test -r "$BUILD_PATH/conf/bblayers.conf"); then
163 BBLAYERS_CONF_EXISTS=1
164 fi
165
166 source ./oe-init-build-env $BUILD_PATH
167
168 if [[ -n $LOCAL_CONF_EXISTS ]]; then
169 sed -i \
170 -e "s|^#BB_NUMBER_THREADS.*|BB_NUMBER_THREADS \?= \"$NUM_CORES\"|" \
171 -e "s|^#PARALLEL_MAKE.*|PARALLEL_MAKE \?= \"-j $NUM_CORES\"|" \
172 -e 's|^DISTRO ?= "poky"|DISTRO ?= "enea"|' \
173 conf/local.conf
174 echo "*** Info: Setting BB_NUMBER_THREADS to $NUM_CORES"
175 echo "*** Info: Setting PARALLEL_MAKE to -j$NUM_CORES"
176 echo "*** Info: Setting DISTRO to enea"
177
178 if [[ -n $MACHINE ]]; then
179 sed -i -e "s|^MACHINE.*|MACHINE = \"$MACHINE\"|" conf/local.conf
180 echo "*** Info: Setting MACHINE to $MACHINE"
181 fi
182
183 echo "SSTATE_MIRRORS ?= \"file://.* $SSTATE_MIRRORS\"" >> conf/local.conf
184 echo "*** Info: Setting SSTATE_MIRRORS to http://linux.enea.com"
185
186 if [[ -n $SSTATE_DIR ]]; then
187 sed -i -e "s|^#SSTATE_DIR ?=.*|SSTATE_DIR ?= \"$SSTATE_DIR\"|" conf/local.conf
188 echo "*** Info: Setting SSTATE_DIR to $SSTATE_DIR"
189 fi
190
191 sed -i -e 's|^PACKAGE_CLASSES ?= "package_rpm"|PACKAGE_CLASSES ?= "package_ipk"|' conf/local.conf
192 echo "*** Info: Setting PACKAGE_CLASSES to ipk"
193
194 echo "SOURCE_MIRROR_URL ?= \"$DOWNLOAD_MIRRORS\"" >> conf/local.conf
195 echo "INHERIT += \"own-mirrors\"" >> conf/local.conf
196 echo "*** Info: Setting SOURCE_MIRROR_URL to http://linux.enea.com"
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_ipk"|PACKAGE_CLASSES ?= "package_rpm package_ipk"|' conf/local.conf
209 echo "*** Info: Setting PACKAGE_CLASSES to 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 DOWNLOAD_MIRRORS
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