diff options
author | Catalina Focsa <catalina.focsa@enea.com> | 2015-12-11 10:32:32 +0100 |
---|---|---|
committer | Adrian Calianu <adrian.calianu@enea.com> | 2015-12-14 14:14:59 +0100 |
commit | 4f56a3b823cb8dd43086ad8bdb78ff37520613b4 (patch) | |
tree | 1d93f5c03184e9222443f15b640a7247aa845bd7 | |
parent | 218c2f039ccf435e42716ba1208a1ecbdb8f653c (diff) | |
download | meta-el-common-4f56a3b823cb8dd43086ad8bdb78ff37520613b4.tar.gz |
Add enea-init-build-env to meta-enea-base
Add enea-init-build-env to the repo.
Sourcing it from poky dir shall be done with explicit path using:
"source meta-enea-base/enea-init-build-env [OPTIONS]".
The default layer added to bblayers.conf is now meta-enea-base
instead of meta-enea and shouldn't be added in the
"-l" option as usual.
Signed-off-by: Catalina Focsa <catalina.focsa@enea.com>
Signed-off-by: Adrian Calianu <adrian.calianu@enea.com>
-rwxr-xr-x | enea-init-build-env | 261 |
1 files changed, 261 insertions, 0 deletions
diff --git a/enea-init-build-env b/enea-init-build-env new file mode 100755 index 0000000..e231a5b --- /dev/null +++ b/enea-init-build-env | |||
@@ -0,0 +1,261 @@ | |||
1 | #!/bin/bash | ||
2 | if [ "$_" = "$0" ]; then | ||
3 | echo "Error: This script needs to be sourced." | ||
4 | echo "Please run as 'source $0'." | ||
5 | exit | ||
6 | fi | ||
7 | |||
8 | # always unset these in case something goes wrong in the previous run | ||
9 | unset BBLAYERS_CONF_EXISTS | ||
10 | unset BUILD_PATH | ||
11 | unset CUSTOM_SCRIPTS | ||
12 | unset DISTRO | ||
13 | unset DOWNLOAD_DLDIR | ||
14 | unset SOURCE_MIRROR_URL | ||
15 | unset ENEAROOT | ||
16 | unset EXITME | ||
17 | unset LOCAL_CONF_EXISTS | ||
18 | unset MACHINE | ||
19 | unset METALAYERS | ||
20 | unset NUM_CORES | ||
21 | unset SSTATE_DIR | ||
22 | unset SSTATE_MIRRORS | ||
23 | unset TESTING_ADDITIONS | ||
24 | unset -f usage | ||
25 | unset OPTERR | ||
26 | unset OPTIND | ||
27 | unset OPTION | ||
28 | |||
29 | NUM_CORES=$(grep -c processor /proc/cpuinfo || echo 2) | ||
30 | BUILD_PATH="build" | ||
31 | METALAYERS="meta-enea-base" | ||
32 | |||
33 | function usage() { | ||
34 | cat <<EOF | ||
35 | Usage: | ||
36 | source $(basename $BASH_SOURCE) [OPTIONS] | ||
37 | |||
38 | OPTIONS: | ||
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 | ||
76 | EOF | ||
77 | } | ||
78 | |||
79 | SSTATE_MIRRORS='http://linux.enea.com/${DISTRO_VERSION}/sstate-cache/PATH' | ||
80 | SOURCE_MIRROR_URL='http://linux.enea.com/${DISTRO_VERSION}/sources' | ||
81 | |||
82 | while 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 | ||
126 | done | ||
127 | |||
128 | METALAYERS="$METALAYERS,meta-openembedded/meta-filesystems,meta-openembedded/meta-networking,meta-openembedded/meta-oe,meta-openembedded/meta-python" | ||
129 | ENEAROOT="$(pwd)" | ||
130 | ENEAROOT=$(readlink -f "$ENEAROOT") | ||
131 | |||
132 | if [[ ! -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 | ||
138 | fi | ||
139 | if [[ ! -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 | ||
145 | fi | ||
146 | |||
147 | if [[ -n $EXITME ]]; then | ||
148 | echo | ||
149 | elif [[ -z $BASH_VERSINFO ]]; then | ||
150 | echo "This script requires bash." | ||
151 | elif [ "$MACHINE"x = "x" -a ! -r "$BUILD_PATH/conf/local.conf" ]; then | ||
152 | cat <<EOF | ||
153 | error: When creating a new build dir, you must at least specify -m MACHINE. | ||
154 | |||
155 | Use option -h for help. | ||
156 | EOF | ||
157 | else | ||
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 | if [[ -n $DISTRO ]]; then | ||
204 | sed -i -e "s|^DISTRO.*|DISTRO ?= \"$DISTRO\"|" conf/local.conf | ||
205 | sed -i -e 's|^PACKAGE_CLASSES ?= "package_rpm"|PACKAGE_CLASSES ?= "package_rpm package_ipk"|' conf/local.conf | ||
206 | echo "*** Info: Setting PACKAGE_CLASSES to ipk and rpm" | ||
207 | echo "*** Info: Setting DISTRO to $DISTRO " | ||
208 | fi | ||
209 | |||
210 | |||
211 | if [[ -n $DOWNLOAD_DLDIR ]]; then | ||
212 | sed -i -e "s|^#DL_DIR ?=.*|DL_DIR ?= \"$DOWNLOAD_DLDIR\"|" conf/local.conf | ||
213 | echo "*** Info: Setting DL_DIR to $DOWNLOAD_DLDIR" | ||
214 | fi | ||
215 | |||
216 | if [[ ""x != "${CUSTOM_SCRIPTS}"x ]]; then | ||
217 | echo "*** Info: Appying \"${CUSTOM_SCRIPTS}\"" | ||
218 | ${CUSTOM_SCRIPTS} | ||
219 | fi | ||
220 | |||
221 | else | ||
222 | echo "You already had conf/local.conf file, no modification is done." | ||
223 | fi | ||
224 | |||
225 | if [[ -n $BBLAYERS_CONF_EXISTS ]]; then | ||
226 | if [[ ""x != "${METALAYERS}"x ]]; then | ||
227 | for layer in $(echo $METALAYERS | tr ',' ' '); do | ||
228 | layer=$ENEAROOT/$layer | ||
229 | if [[ ! -d $layer ]]; then | ||
230 | echo "*** Error: There is no meta-layer called: $layer" | ||
231 | else | ||
232 | egrep "$layer " conf/bblayers.conf >/dev/null || | ||
233 | sed -i -e '/.*meta-yocto .*/i\'" $layer \\\\" conf/bblayers.conf | ||
234 | echo "*** Info: Adding $layer to bblayers.conf" | ||
235 | fi | ||
236 | done | ||
237 | fi | ||
238 | else | ||
239 | echo "You already had conf/bblayers.conf file, no modification is done." | ||
240 | fi | ||
241 | fi | ||
242 | |||
243 | unset BBLAYERS_CONF_EXISTS | ||
244 | unset BUILD_PATH | ||
245 | unset CUSTOM_SCRIPTS | ||
246 | unset DISTRO | ||
247 | unset DOWNLOAD_DLDIR | ||
248 | unset SOURCE_MIRROR_URL | ||
249 | unset ENEAROOT | ||
250 | unset EXITME | ||
251 | unset LOCAL_CONF_EXISTS | ||
252 | unset MACHINE | ||
253 | unset METALAYERS | ||
254 | unset NUM_CORES | ||
255 | unset SSTATE_DIR | ||
256 | unset SSTATE_MIRRORS | ||
257 | unset TESTING_ADDITIONS | ||
258 | unset -f usage | ||
259 | unset OPTERR | ||
260 | unset OPTIND | ||
261 | unset OPTION | ||