blob: b49b2d7b688f3479ad166f06261bef9d0ec460dc (
plain)
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
|
#!/bin/bash
DEBUG_MODE=1
SCRIPT_NAME="$(basename ${BASH_SOURCE[0]})"
SCRIPT_FULLPATH="$(readlink -f ${BASH_SOURCE[0]})"
SCRIPT_BASE="$(dirname ${SCRIPT_FULLPATH})"
SCRIPT_VER="0.0.2"
CMD_RS_GEN="${SCRIPT_BASE}/script/rootstrap_gen_1.0.sh"
CMD_RS_INFO="${SCRIPT_BASE}/script/rootstrap_info_gen_1.0.sh"
CMD_RS_PLUGIN="${SCRIPT_BASE}/script/rootstrap_plugin_gen_1.0.sh"
CMD_API_FILTER="${SCRIPT_BASE}/script/api_filter.py"
CMD_API_GDBUS_FILTER="${SCRIPT_BASE}/script/api_filter_gdbus.py"
DIR_INFO=".info"
DIR_RPM=".rpm"
DIR_PLUGIN=".plugin"
DIR_TMP=".tmp"
DIR_EMULATOR=".emulator"
DIR_TARGET=".target"
DIR_ZIP=".zip"
PRIVATE_STRING=""
LOGFILE="rs.log"
if [ -e ${LOGFILE} ]; then
rm ${LOGFILE};
fi
touch ${LOGFILE}
###############################################################################
# function log
###############################################################################
function log()
{
printf "[${SCRIPT_NAME}:${BASH_LINENO[0]}] ${@}\n"
}
###############################################################################
# function check_error
# $1 : Error code(integer)
# $2 : Error Message
# $3 : Error Xml File)
# Example : check_error $? "Fail to function"
###############################################################################
function check_error()
{
if [ "$1" -ne "0" ]; then
printf "[${SCRIPT_NAME}:${BASH_LINENO[0]}] ERROR : $2 - exit code ($1) \n" 1>&2
exit $1
fi
}
###############################################################################
# function remove_dir
# $@ : Files
# Example : remove_dir test_dir test_file
###############################################################################
function remove_dir () {
echo "remove dir : $@"
rm -rf $@ >/dev/null 2>&1
}
###############################################################################
## function callRootstrapGen
# $1 : emulator/target
# $2 : ${RPM_PKG_SVR_EMULATOR}
# $3 : ${BASE_PKG_SVR_EMULATOR}
# Example : callRootstrapGen emulator ${RPM_PKG_SVR_EMULATOR} ${BASE_PKG_SVR_EMULATOR}
###############################################################################
function callRootstrapGen () {
log "make rootstrap for ${1}..." 1>&2
ROOTSTRAP_TYPE=${1};
if [[ -z ${3} ]]
then
FULL_RS_CMD="${CMD_RS_GEN} -t ${1} -u ${2} -q ${BUILD_REQUIRED_INSTALLED_PATH} -r ${GBS_BUILDROOT} ${xmlList}"
else
FULL_RS_CMD="${CMD_RS_GEN} -t ${1} -u ${2} -b ${3} -q ${BUILD_REQUIRED_INSTALLED_PATH} -r ${GBS_BUILDROOT} ${xmlList}"
fi
FULL_RS_INFO_CMD="${CMD_RS_INFO} -t $1 -l ${xmlList} -p $PLATFORM_PROFILE -v $PLATFORM_VERSION"
if [[ "${ROOTSTRAP_TYPE}" == "emulator" ]]; then
FULL_CMD_RS_PLUGIN_GEN="${CMD_RS_PLUGIN} -t ${ROOTSTRAP_TYPE} -i .info/$PLATFORM_PROFILE-$PLATFORM_VERSION-emulator.core.dev.xml -p ${PLATFORM_PROFILE} -v ${PLATFORM_VERSION}"
elif [[ "${ROOTSTRAP_TYPE}" == "target" ]]; then
FULL_CMD_RS_PLUGIN_GEN="${CMD_RS_PLUGIN} -t ${ROOTSTRAP_TYPE} -i .info/$PLATFORM_PROFILE-$PLATFORM_VERSION-device.core.dev.xml -p ${PLATFORM_PROFILE} -v ${PLATFORM_VERSION}"
else
exit 1;
fi
if [[ ${DEBUG_MODE} == "1" ]]
then
log "$FULL_RS_CMD"
$FULL_RS_CMD
check_error $? "Fail to ${CMD_RS_GEN}"
log "$FULL_RS_INFO_CMD"
$FULL_RS_INFO_CMD
check_error $? "Fail to ${CMD_RS_INFO}"
log "$FULL_CMD_RS_PLUGIN_GEN"
$FULL_CMD_RS_PLUGIN_GEN
check_error $? "Fail to ${FULL_CMD_RS_PLUGIN_GEN}"
else
if [[ -e ${LOGFILE} ]]; then
log "$FULL_RS_CMD" | tee -a ${LOGFILE}
fi
$FULL_RS_CMD >/dev/null
check_error $? "Fail to ${CMD_RS_GEN}"
log "$FULL_RS_INFO_CMD"
$FULL_RS_INFO_CMD >/dev/null
check_error $? "Fail to ${CMD_RS_INFO}"
log "$FULL_CMD_RS_PLUGIN_GEN"
$FULL_CMD_RS_PLUGIN_GEN >/dev/null
check_error $? "Fail to ${FULL_CMD_RS_PLUGIN_GEN}"
fi
##Append Snapshot
if [ -n "${SNAPSHOT_BASE}" ]; then
log "ADD Snapshot : ${SNAPSHOT_BASE}"
if [[ "${ROOTSTRAP_TYPE}" == "emulator" ]]; then
echo '<!-- '${SNAPSHOT_BASE}' -->' | tee -a .info/$PLATFORM_PROFILE-$PLATFORM_VERSION-emulator.core.dev.xml
elif [[ "${ROOTSTRAP_TYPE}" == "target" ]]; then
echo '<!-- '${SNAPSHOT_BASE}' -->' | tee -a .info/$PLATFORM_PROFILE-$PLATFORM_VERSION-device.core.dev.xml
fi
fi
log "Done... [$SECONDS]Sec" 1>&2
}
GLOBAL_ERROR="0"
OPT_TARGET=false
OPT_EMULATOR=false
OPT_DOWNLOAD_RPM=false
OPT_CLEAN=true
OPT_CONF=""
INTERNAL=false
###############################################################################
# function usage
###############################################################################
function usage () {
echo "$SCRIPT_NAME ($SCRIPT_VER) is script to make rootstrap using xml from OBS"
echo "Usage: $SCRIPT_NAME -C [<config_file>] [<OPTION>]... [<FILE>]..."
echo " -e, --emulator : Make Rootstrap for Emulator"
echo " -t, --target : Make Rootstrap for Target"
echo " -c, --clean : Delete .rpm cache folder"
echo " -h, --help"
echo " -v, --version : Display script version information"
echo ""
echo "Example:"
echo " >$SCRIPT_NAME -C rs-config ./rs_resource/NativeAPI/capi-appfw-app-manager-rs.xml"
echo " >$SCRIPT_NAME -C rs-config -e ./rs_resource"
echo " >$SCRIPT_NAME -C rs-config -t ./rs_resource"
echo ""
echo "Output Diretory:"
echo ".info"
echo ".emulator"
echo ".target"
echo ".rpm"
echo ".plugin"
echo ".tmp"
return
}
###############################################################################
## Get Parameter
###############################################################################
OPTS=`getopt -o -C:tedchv --long target,emulator,downloadrpm,clean,help,version,internal -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo ""
echo "#EXEC_CMD : $SCRIPT_NAME $OPTS"
eval set -- "$OPTS"
while true; do
case "$1" in
-C | --conf )OPT_CONF=$2;shift;shift;;
-t | --target )OPT_TARGET=true;shift;;
-e | --emulator )OPT_EMULATOR=true;shift;;
-d | --downloadrpm )OPT_DOWNLOAD_RPM=true;shift;;
-c | --clean )OPT_CLEAN=true;shift;;
-h | --help )usage;exit 0;;
-v | --version )echo "${SCRIPT_NAME}" "version : $SCRIPT_VER"; exit 0 ;;
--internal ) INTERNAL=true; shift;;
-- ) shift; break ;;
*) #file or directory
if [ -d "${1}" ] || [ -f "${1}" ]; then
xmlList+="${1} "
else
usage >&2
exit 1
fi
shift;;
esac
done
if [ "$OPT_TARGET" = false ] && [ "$OPT_EMULATOR" = false ]
then
OPT_TARGET=true
OPT_EMULATOR=true
fi
###############################################################################
## Print Parameter Option
###############################################################################
printf "\n#OPTION\n"
echo "OPT_CONF=${OPT_CONF}"
echo "OPT_CLEAN = $OPT_CLEAN"
echo "OPT_TARGET = $OPT_TARGET"
echo "OPT_EMULATOR = $OPT_EMULATOR"
echo "OPT_DOWNLOAD_RPM = $OPT_DOWNLOAD_RPM"
echo "OPT_CLEAN=$OPT_CLEAN"
if [ "$RS_INTERNAL" = true ] || [ "$INTERNAL" = true ]; then
echo "OPT_INTERNAL=TRUE"
fi
echo "xmlList=$xmlList"
printf "\n"
###############################################################################
## Check Environment
###############################################################################
if [[ "$xmlList" == "" ]]; then
usage >&2
exit 1
fi
if [[ -e ${OPT_CONF} ]]; then
log "source ${OPT_CONF}"
source "${OPT_CONF}"
else
log "[Error] Configuration File Does not Exist"
usage
exit 1
fi
if [[ ! -f ${CMD_RS_GEN} ]]; then
log "[Error] File not found ![${CMD_RS_GEN}]"
exit 1
fi
if [[ ! -f ${CMD_RS_INFO} ]]; then
log "[Error] File not found ![${CMD_RS_INFO}]"
exit 1
fi
if [[ ! -f ${CMD_RS_PLUGIN} ]]; then
log "[Error] File not found ![${CMD_RS_PLUGIN}]"
exit 1
fi
if [ "$OPT_CLEAN" = true ]; then
log "Clean dir ..."
remove_dir $DIR_INFO $DIR_RPM $DIR_PLUGIN $DIR_TMP $DIR_EMULATOR $DIR_TARGET
fi
if [[ -z ${RPM_PKG_SVR_EMULATOR} ]]; then
log "[Error] RPM_PKG_SVR_EMULATOR is NULL"
exit 1
fi
if [[ -z ${RPM_PKG_SVR_TARGET} ]]; then
log "[Error] RPM_PKG_SVR_TARGET is NULL"
exit 1
fi
log ""
log "BASE_PKG_SVR_EMULATOR = ${BASE_PKG_SVR_EMULATOR}"
log "BASE_PKG_SVR_TARGET = ${BASE_PKG_SVR_TARGET}"
log "RPM_PKG_SVR_EMULATOR = ${RPM_PKG_SVR_EMULATOR}"
log "RPM_PKG_SVR_TARGET = ${RPM_PKG_SVR_TARGET}"
log ""
SNAPSHOT_BASE=$(basename $SNAPSHOT_URL_PREFIX)
log "SNAPSHOT_BASE=$SNAPSHOT_BASE"
log ""
if [ "$RS_INTERNAL" = true ] || [ "$INTERNAL" = true ]; then
CMD_RS_GEN="$CMD_RS_GEN --internal"
CMD_RS_INFO="$CMD_RS_INFO"
CMD_RS_PLUGIN="$CMD_RS_PLUGIN --internal"
PRIVATE_STRING=".private"
fi
if [ -n "${ID}" ] && [ -n "${PW}" ]
then
CMD_RS_GEN="$CMD_RS_GEN -i ${ID} -p ${PW}"
echo "Append ID/PW Option : ${CMD_RS_GEN}"
fi
if [[ -e ${LOGFILE} ]]; then
CMD_RS_GEN="$CMD_RS_GEN --log ${LOGFILE}"
fi
###############################################################################
## Rootstrap Generation
###############################################################################
if [[ "$GLOBAL_ERROR" != "0" ]]; then
log "[Error] Failed download rpm";
exit 1;
fi
if [ "$OPT_TARGET" = true ]; then
remove_dir ${DIR_TMP} ${DIR_TARGET}
callRootstrapGen target ${RPM_PKG_SVR_TARGET} ${BASE_PKG_SVR_TARGET}
log "[INFO] Postscript ${GBS_BUILDROOT}";
mv ${GBS_BUILDROOT}/usr/include/asm-arm ${GBS_BUILDROOT}/usr/include/asm
mv ${GBS_BUILDROOT}/usr/include/base/deprecated/* ${GBS_BUILDROOT}/usr/include/base/
if [ "$INTERNAL" = false ]; then
echo "remove Non-Public EFL API"
$CMD_API_FILTER ${GBS_BUILDROOT} > /dev/null #EFL filter
echo "remove Non-Public GDBUS API"
$CMD_API_GDBUS_FILTER ${GBS_BUILDROOT} > /dev/null #GDBUS filter
fi
#echo "remove Public GDBUS API"
#$CMD_API_GDBUS_FILTER .target>/dev/null #GDBUS filter
if [ "$INTERNAL" = true ]; then
log "[INFO] Skip .. removing dlog-internal.h"
find ${GBS_BUILDROOT} -name "dlog.h" -exec perl -pi -e 's/#include\ \"dlog-internal\.h\"//g' {} \;
else
find ${GBS_BUILDROOT} -name "dlog.h" -exec perl -pi -e 's/#include\ \"dlog-internal\.h\"//g' {} \;
fi
if [ ! -d "${GBS_BUILDROOT}/usr/lib" ]; then
mkdir -p ${GBS_BUILDROOT}/usr/lib
fi
for FILE in $(find ${GBS_BUILDROOT} -name "*.so.*mobile");
do
mv ${FILE} ${FILE%.mobile};
done;
fi
if [ "$OPT_EMULATOR" = true ]; then
remove_dir ${DIR_TMP} ${DIR_EMULATOR}
callRootstrapGen emulator ${RPM_PKG_SVR_EMULATOR} ${BASE_PKG_SVR_EMULATOR}
log "[INFO] Postscript ${GBS_BUILDROOT}";
mv ${GBS_BUILDROOT}/usr/include/asm-x86 ${GBS_BUILDROOT}/usr/include/asm
mv ${GBS_BUILDROOT}/usr/include/base/deprecated/* ${GBS_BUILDROOT}/usr/include/base/
if [ "$INTERNAL" = false ]; then
echo "remove Non-Public EFL API"
$CMD_API_FILTER .emulator>/dev/null #EFL filter
echo "remove Non-Public GDBUS API"
$CMD_API_GDBUS_FILTER .emulator>/dev/null #GDBUS filter
fi
if [ "$INTERNAL" = true ]; then
log "[INFO] Skip .. removing dlog-internal.h"
find ${GBS_BUILDROOT} -name "dlog.h" -exec perl -pi -e 's/#include\ \"dlog-internal\.h\"//g' {} \;
else
find ${GBS_BUILDROOT} -name "dlog.h" -exec perl -pi -e 's/#include\ \"dlog-internal\.h\"//g' {} \;
fi
if [ ! -d "${GBS_BUILDROOT}/usr/lib" ]; then
mkdir -p ${GBS_BUILDROOT}/usr/lib
fi
for FILE in $(find ${GBS_BUILDROOT} -name "*.so.*mobile");
do
mv ${FILE} ${FILE%.mobile};
done;
fi
if [[ -e ${LOGFILE} ]]; then
log "END" | tee -a ${LOGFILE}
fi
###############################################################################
## END
###############################################################################
exit 0
|