-
Notifications
You must be signed in to change notification settings - Fork 6
/
yoctoTizenUpdateSource
executable file
·276 lines (250 loc) · 8.57 KB
/
yoctoTizenUpdateSource
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#!/bin/bash
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012-2013 Intel, Inc.
# License: GPLv2
# Authors: Ronan Le Martret <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2,
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
SCRIPT_DIR=$(dirname $0)
VERBOSE="no"
SHOW_HELP="no"
CLEAN_PRJ="no"
BUILD_PRJ_AFTER="no"
CONFIG_FILE="${SCRIPT_DIR}/yoctoTizen_config"
REV_FILE=
CLEANPRJ="no"
while test $# -gt 0; do
case $1 in
*-help)
SHOW_HELP="yes"
shift
;;
*-h)
SHOW_HELP="yes"
shift
;;
*-clean-force)
CLEAN_PRJ="yes"
shift
;;
*-build)
BUILD_PRJ_AFTER="yes"
shift
;;
*-verbose)
VERBOSE=$2
shift
shift
;;
*-config)
CONFIG_FILE=$2
shift
shift
;;
*-rev-file)
REV_FILE=$2
shift
shift
;;
*)
echo "Unknown parameter $1."
echo "This script is not accepting this parameter currently."
exit 1
;;
esac
done
if [ "${SHOW_HELP}" != "no" ]; then
echo "clone/checkout tizen on yocto source"
echo " --help,-h show this help"
echo " --verbose yes/no default yes"
echo " --clean-force remove previous build without any chance of recovery,"
echo " use this option at your own risk"
echo " --config file_path"
echo " use a external config file (default ${SCRIPT_DIR}/yoctoTizen_config)"
echo " --rev-file file_path"
echo " specify the revision file (not optional)"
echo " --build build project after fetch"
exit 0
fi
# If user have no yoctoTizenrc
if [ ! -e "${CONFIG_FILE}" ] ;then
cp "${SCRIPT_DIR}/yoctoTizen_config_skeleton" "${CONFIG_FILE}"
fi
source ${CONFIG_FILE}
if [ -z ${REV_FILE} ] ; then
echo "You have not specify the revision file,"
echo " You can chooce default file (--rev-file file_path):"
echo $(ls "${SCRIPT_DIR}/yoctoTizen_rev"*)
exit 1
fi
source ${REV_FILE}
test_parameter() {
if [ -z $2 ] ;then
echo The variable \"$1\" is empty please configure it.
echo Open file ${SCRIPT_DIR}/yoctoTizen_config
exit 1
fi
}
function add_meta_to_bblayers
{
echo
META_DIR=$1
BBLAYER_FILE=$2
echo add \"${META_DIR}\" to file ${BBLAYER_FILE}.
if grep -q "${META_DIR} " "${BBLAYER_FILE}"; then
echo ${META_DIR} is already present in ${BBLAYER_FILE}.
else
sed -i -e '/meta-yocto-bsp/a \ '${META_DIR}' \\' ${BBLAYER_FILE}
fi
}
function rm_meta_to_bblayers
{
echo
META_DIR=$1
BBLAYER_FILE=$2
echo remove \"${META_DIR}\" to file ${BBLAYER_FILE}.
if grep -q "${META_DIR} " "${BBLAYER_FILE}"; then
echo ${META_DIR} is present in ${BBLAYER_FILE} now remove it.
echo sed -i "/${META_DIR}/d" ${BBLAYER_FILE}
sed -i "/${META_DIR}/d" ${BBLAYER_FILE}
else
echo ${META_DIR} is not present in ${BBLAYER_FILE}.
fi
}
function change_conf_default_value
{
DEFAULT_VALUE=$1
OUR_VALUE=$2
CONF_FILE=$3
echo
echo into file ${CONF_FILE}
echo ' change value' \"${DEFAULT_VALUE}\" by \"${OUR_VALUE}\"
if grep -q "${OUR_VALUE}" ${CONF_FILE} ;then
echo \"${OUR_VALUE}\" is set in ${CONF_FILE}.
else
sed -i -e "s,${DEFAULT_VALUE}.*,${OUR_VALUE},g" ${CONF_FILE}
fi
}
test_parameter WORKINGDIR ${WORKINGDIR}
mkdir -p ${WORKINGDIR}
if [ $? -ne 0 ] ;then
exit 1
fi
test_parameter BUILD_PRJ ${BUILD_PRJ}
test_parameter CLONE_CMD ${CLONE_CMD}
#----------------------------------------------------------------------------
if [ "${VERBOSE}" = "yes" ] ; then
set -x
fi
#----------------------------------------------------------------------------
if [ -d "${WORKINGDIR}/poky" ] ; then
cd "${WORKINGDIR}/poky"
git fetch --all
else
cd "${WORKINGDIR}"
git ${CLONE_CMD} git://git.yoctoproject.org/poky poky
fi
cd ${WORKINGDIR}/poky
git reset --hard ${POKY_REV}
echo
#----------------------------------------------------------------------------
if [ -d "${WORKINGDIR}/meta-intel" ] ; then
cd "${WORKINGDIR}/meta-intel"
git fetch --all
else
cd "${WORKINGDIR}"
git ${CLONE_CMD} git://git.yoctoproject.org/meta-intel meta-intel
fi
cd "${WORKINGDIR}/meta-intel"
git reset --hard ${META_INTEL_REV}
echo
#----------------------------------------------------------------------------
if [ -d "${WORKINGDIR}/meta-openembedded" ] ; then
cd "${WORKINGDIR}/meta-openembedded"
git fetch --all
else
cd "${WORKINGDIR}"
git ${CLONE_CMD} git://git.openembedded.org/meta-openembedded meta-openembedded
fi
cd "${WORKINGDIR}/meta-openembedded"
git reset --hard ${META_OPENEMBEDDED_REV}
echo
#----------------------------------------------------------------------------
if [ -d "${WORKINGDIR}/meta-tizen" ] ; then
cd "${WORKINGDIR}/meta-tizen"
git fetch --all
else
cd "${WORKINGDIR}"
git ${CLONE_CMD} git://review.tizen.org/scm/bb/meta-tizen meta-tizen
fi
cd "${WORKINGDIR}/meta-tizen"
git reset --hard ${META_TIZEN_REV}
echo
#----------------------------------------------------------------------------
echo init build project
cd "${WORKINGDIR}/poky"
source oe-init-build-env ${BUILD_PRJ}
echo add and remove meta
echo --------------
add_meta_to_bblayers ${WORKINGDIR}/meta-tizen/meta-tizen-adaptation-meta-oe "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
add_meta_to_bblayers ${WORKINGDIR}/meta-tizen/meta-tizen-adaptation-oe-core "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
add_meta_to_bblayers ${WORKINGDIR}/meta-tizen/meta-tizen-common-base "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
add_meta_to_bblayers ${WORKINGDIR}/meta-tizen/meta-tizen-common-demo "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
add_meta_to_bblayers ${WORKINGDIR}/meta-tizen/meta-tizen-common-devtools "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
add_meta_to_bblayers ${WORKINGDIR}/meta-tizen/meta-tizen-common-share "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
add_meta_to_bblayers ${WORKINGDIR}/meta-tizen/meta-tizen-ivi "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
rm_meta_to_bblayers meta-efl "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
add_meta_to_bblayers ${WORKINGDIR}/meta-openembedded/meta-oe "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
echo --------------
case ${MACHINE} in
haswell-wc)
add_meta_to_bblayers ${WORKINGDIR}/meta-intel/meta-isg/meta-haswell-wc "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
add_meta_to_bblayers ${WORKINGDIR}/meta-intel "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
;;
romley-ivb)
add_meta_to_bblayers ${WORKINGDIR}/meta-intel/meta-romley "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
add_meta_to_bblayers ${WORKINGDIR}/meta-intel "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
;;
valleyisland-64)
add_meta_to_bblayers ${WORKINGDIR}/meta-intel/meta-isg/meta-valleyisland "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
add_meta_to_bblayers ${WORKINGDIR}/meta-intel "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
;;
valleyisland-32)
add_meta_to_bblayers ${WORKINGDIR}/meta-intel/meta-isg/meta-valleyisland "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
add_meta_to_bblayers ${WORKINGDIR}/meta-intel "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/bblayers.conf"
;;
esac
change_conf_default_value "DISTRO ?=" "DISTRO = \"tizen\"" "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/local.conf"
change_conf_default_value "MACHINE ??=" "MACHINE = \"${MACHINE}\"" "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/local.conf"
change_conf_default_value "DL_DIR ?= " "DL_DIR = ${WORKINGDIR}/poky/downloads" "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/local.conf"
change_conf_default_value "#OE_TERMINAL = " "OE_TERMINAL = \"screen\"" "${WORKINGDIR}/poky/${BUILD_PRJ}/conf/local.conf"
if [ "${CLEAN_PRJ}" = "yes" ] ; then
echo "Clean directory"
for path in bitbake.lock cache downloads sstate-cache tmp ; do
rm -fr "${WORKINGDIR}/poky/${BUILD_PRJ}/${path}"
done
fi
if [ "${VERBOSE}" = "yes" ] ; then
set +x
fi
if [ "${BUILD_PRJ_AFTER}" = "yes" ] ; then
echo "Build image:"
cd "${WORKINGDIR}/poky"
source oe-init-build-env ${BUILD_PRJ}
bitbake -k "${IMAGE_NAME}" -c fetchall
bitbake -k "${IMAGE_NAME}"
else
echo "To build image:"
echo " " cd ${WORKINGDIR}/poky
echo " " source oe-init-build-env ${BUILD_PRJ}
echo " " bitbake ${IMAGE_NAME}
fi
exit 0