summaryrefslogtreecommitdiff
path: root/config-sdk/package_rootstrap.sh
blob: ba1c264c40fcbd8521c651d4b5acf74ba43b9218 (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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
#!/bin/bash
###############################################################################
# Init
###############################################################################
SCRIPT_NAME="$(basename ${BASH_SOURCE[0]})"
SCRIPT_FULLPATH="$(readlink -f ${BASH_SOURCE[0]})"
SCRIPT_BASE="$(dirname ${SCRIPT_FULLPATH})"
SCRIPT_VER="0.0.3"

DIR_TMP_PKG=".temp_pkg"
DIR_TMP_SDK_PKG=$(pwd)/".temp_sdk_pkg"
DIR_OUTPUT=".pkg"

#OS_LIST="ubuntu-32 ubuntu-64 windows-32 windows-64 macos-64"
OS_LIST="ubuntu-64"

DIR_INFO=".info"
DIR_RPM=".rpm"
DIR_PLUGIN=".plugin"
DIR_TMP=".tmp"
DIR_EMULATOR=".emulator"
DIR_TARGET=".target"

PATH_PACKAGE_RES=""

OPT_CONF=""

PRIVATE=""
TMP_PKG_VERSION="0.0.1"

INTERNAL=false
SDKPKG=false
SNAPSHOT=""

DEVICE="device"
EMULATOR="emulator"
###############################################################################
echo ""
echo " $SCRIPT_NAME ($SCRIPT_VER) is packaging tool of rootstrap"
echo ""

###############################################################################
# function log
###############################################################################
function log()
{
    #printf "[${SCRIPT_NAME}:${BASH_LINENO[0]}] ${@}\n"
    printf "${@}\n\n"
}

function log_info()
{
    printf "[INFO] ${@}\n\n"
}

function log_warn()
{
    printf "[WARN] ${@}\n\n"
}

function log_error()
{
    printf "[${SCRIPT_NAME}:${BASH_LINENO[0]}][ERROR] ${@}\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 pkg_build_internal
# $1 : Type (emulator/device/emulator64/device64)
# $2 : resource Path (.emulator/.target)
###############################################################################
function pkg_build_internal()
{

    TYPE=${1}

    if [[ ${TYPE} == *"device"* ]]; then
        PLUGIN_FILE="${DIR_PLUGIN}/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-device.core.xml"
        INFO_FILE="${DIR_INFO}/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-device.core.dev.xml"
    else
        PLUGIN_FILE="${DIR_PLUGIN}/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-emulator.core.xml"
        INFO_FILE="${DIR_INFO}/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-emulator.core.dev.xml"
    fi

    log_info "Clean up Resource Directory ${PATH_PACKAGE_RES}"
    if [[ -n ${PATH_PACKAGE_RES} ]] && [[ -e "${PATH_PACKAGE_RES}/data" ]] ; then
        rm -rf "${PATH_PACKAGE_RES}/data"
    fi

    log_info "mkdir -p ${DIR_PLUGIN_DEST}"
    mkdir -p ${DIR_PLUGIN_DEST}

    log_info "mkdir -p ${DIR_INFO_DEST}"
    mkdir -p ${DIR_INFO_DEST}

    log_info "mkdir -p ${DIR_ROOTSTRAP_DEST}"
    mkdir -p ${DIR_ROOTSTRAP_DEST}


    # Get Current Info
    log_info "Get Current RS_ID, RS_PATH, DEV_PACKAGE_CONFIG_PATH"

    RS_ID=$(xmlstarlet sel -t -m "//rootstrap/@id" -v "." $PLUGIN_FILE)
    RS_PATH=$(xmlstarlet sel -t -m "//rootstrap/@path" -v "." $PLUGIN_FILE)
    DEV_PACKAGE_CONFIG_PATH=$(xmlstarlet sel -t -m "//property[@key='DEV_PACKAGE_CONFIG_PATH']/@value" -v "." $PLUGIN_FILE)

    log_info "TYPE=$TYPE"
    log_info "RS_ID=$RS_ID"
    log_info "RS_PATH=$RS_PATH"
    log_info "DEV_PACKAGE_CONFIG_PATH=$DEV_PACKAGE_CONFIG_PATH"


    # Replace Info
    log_info "Convert RS_ID, RS_PATH, DEV_PACKAGE_CONFIG_PATH"

    if [ "$INTERNAL" = true ]; then
    RS_ID=${PLATFORM_PROFILE}-${PLATFORM_VERSION}-${TYPE}.core${PRIVATE}${SNAPSHOT}
    else
    RS_ID=${PLATFORM_PROFILE}-${PLATFORM_VERSION}-${TYPE}.core${SNAPSHOT}
    fi

    RS_PATH=$(dirname $RS_PATH)"/${RS_ID}"
    DEV_PACKAGE_CONFIG_PATH=$(dirname $DEV_PACKAGE_CONFIG_PATH)"/${RS_ID}.dev.xml"

    log_info "NEW RS_ID=$RS_ID"
    log_info "NEW RS_PATH=$RS_PATH"
    log_info "NEW DEV_PACKAGE_CONFIG_PATH=$DEV_PACKAGE_CONFIG_PATH"


    # Copy
    log_info "cp ${PLUGIN_FILE} ${DIR_PLUGIN_DEST}/${RS_ID}.xml"
    cp ${PLUGIN_FILE} ${DIR_PLUGIN_DEST}/${RS_ID}.xml >/dev/null

    log_info "cp ${INFO_FILE} ${DIR_INFO_DEST}/${RS_ID}.dev.xml"
    cp ${INFO_FILE} ${DIR_INFO_DEST}/${RS_ID}.dev.xml >/dev/null



    # Change Plugin XML
    xmlstarlet ed -L -u "//rootstrap/@id" -v "${RS_ID}" ${DIR_PLUGIN_DEST}/${RS_ID}.xml
    xmlstarlet ed -L -u "//rootstrap/@path" -v "${RS_PATH}" ${DIR_PLUGIN_DEST}/${RS_ID}.xml

    if [ "$INTERNAL" = true ]; then
        if [ -n "${SNAPSHOT}" ]; then
            log_info "SNAPSHOT = [$SNAPSHOT]"
            xmlstarlet ed -L -u "//rootstrap/@name" -v "Tizen ${TYPE[*]^} $PLATFORM_VERSION ${PRIVATE:1} (${SNAPSHOT:1})" ${DIR_PLUGIN_DEST}/${RS_ID}.xml
        else
            xmlstarlet ed -L -u "//rootstrap/@name" -v "Tizen ${TYPE[*]^} $PLATFORM_VERSION ${PRIVATE:1}" ${DIR_PLUGIN_DEST}/${RS_ID}.xml
        fi
    else
        xmlstarlet ed -L -u "//rootstrap/@name" -v "Tizen ${TYPE[*]^} $PLATFORM_VERSION" ${DIR_PLUGIN_DEST}/${RS_ID}.xml
    fi

    xmlstarlet ed -L -u "//property[@key='DEV_PACKAGE_CONFIG_PATH']/@value" -v "${DEV_PACKAGE_CONFIG_PATH}" ${DIR_PLUGIN_DEST}/${RS_ID}.xml

    if [[ ${TYPE} == *"device64"* ]]; then
        xmlstarlet ed -L -u "//rootstrap/@architecture" -v "aarch64" ${DIR_PLUGIN_DEST}/${RS_ID}.xml
    elif [[ ${TYPE} == *"emulator64"* ]]; then
        xmlstarlet ed -L -u "//rootstrap/@architecture" -v "x86_64" ${DIR_PLUGIN_DEST}/${RS_ID}.xml
    fi

    # Rename Plugin XML
    #log_info "mv ${DIR_PLUGIN}/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-${TYPE}*.xml ${DIR_PLUGIN}/${RS_ID}.xml"
    #mv ${DIR_PLUGIN}/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-${TYPE}*.xml ${DIR_PLUGIN}/${RS_ID}.xml >/dev/null

    #log_info "mv ${DIR_INFO}/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-${TYPE}*.dev.xml ${DIR_INFO}/${RS_ID}.dev.xml"
    #mv ${DIR_INFO}/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-${TYPE}*.dev.xml ${DIR_INFO}/${RS_ID}.dev.xml >/dev/null

    # Copy Resource
    #DIR_PLUGIN_DEST="${PATH_PACKAGE_RES}/data/tools/smart-build-interface/plugins/"
    #DIR_INFO_DEST="${PATH_PACKAGE_RES}/data/platforms/tizen-${PLATFORM_VERSION}/${PLATFORM_PROFILE}/rootstraps/info/"
    #DIR_ROOTSTRAP_DEST="${PATH_PACKAGE_RES}/data/platforms/tizen-${PLATFORM_VERSION}/${PLATFORM_PROFILE}/rootstraps/"

    #mkdir -p ${DIR_PLUGIN_DEST}
    #mkdir -p ${DIR_INFO_DEST}
    #mkdir -p ${DIR_ROOTSTRAP_DEST}

    if [[ ${TYPE} == *"device64"* ]]; then
    (
        log_info "Copy RS Resource [${DIR_TARGET}] to [${DIR_ROOTSTRAP_DEST}/${RS_ID}] ... "
        cd ${DIR_TARGET}
	rm ./usr/lib/*
        zip -r --symlinks ${RS_ID}.zip lib64 lib usr >/dev/null
        unzip ${RS_ID}.zip -d ${DIR_ROOTSTRAP_DEST}/${RS_ID} >/dev/null
        rm *.zip
    )
    elif [[ ${TYPE} == *"emulator64"* ]]; then
    (
        log_info "Copy RS Resource [${DIR_EMULATOR}] to [${DIR_ROOTSTRAP_DEST}/${RS_ID}] ... "
        cd ${DIR_EMULATOR}
	rm ./usr/lib/*
        zip -r --symlinks ${RS_ID}.zip lib64 lib usr >/dev/null
        unzip ${RS_ID}.zip -d ${DIR_ROOTSTRAP_DEST}/${RS_ID} >/dev/null
        rm *.zip
    )
    elif [[ ${TYPE} == *"device"* ]]; then
    (
        log_info "Copy RS Resource [${DIR_TARGET}] to [${DIR_ROOTSTRAP_DEST}/${RS_ID}] ... "
        cd ${DIR_TARGET}
        zip -r --symlinks ${RS_ID}.zip lib usr >/dev/null
        unzip ${RS_ID}.zip -d ${DIR_ROOTSTRAP_DEST}/${RS_ID} >/dev/null
        rm *.zip
    )
    elif [[ ${TYPE} == *"emulator"* ]]; then
    (
        log_info "Copy RS Resource [${DIR_EMULATOR}] to [${DIR_ROOTSTRAP_DEST}/${RS_ID}] ... "
        cd ${DIR_EMULATOR}
        zip -r --symlinks ${RS_ID}.zip lib usr >/dev/null
        unzip ${RS_ID}.zip -d ${DIR_ROOTSTRAP_DEST}/${RS_ID} >/dev/null
        rm *.zip
    )
    fi
}

function pkg_build()
{

    pkg_build_internal ${DEVICE}

    (
    cd ${PATH_PACKAGE_RES}
    zip -r ${NAME_DEVICE_PKG_ZIP} data >/dev/null
    mv ${PATH_PACKAGE_RES}/*.zip ${pkg_dir}
    log_info "Genarated Basic RS resource [${pkg_dir}] ... "
    )

#    pkg_build_internal ${EMULATOR}
#    (
#    cd ${PATH_PACKAGE_RES}
#    zip -r ${NAME_EMULATOR_PKG_ZIP} data >/dev/null
#    mv ${PATH_PACKAGE_RES}/*.zip ${pkg_dir}
#    log_info "Genarated Basic RS resource [${pkg_dir}] ... "
#    )

}

###############################################################################
# function create_pkginfo
# VAL_PKG="$1"
# VAL_VERSION="$2"
# VAL_OS="$3"
###############################################################################
function create_pkginfo()
{

    #pkginfo.manifest
    #Package : mobile-3.0-rs-device.core
    #Version : 3.0.8
    #OS : ubuntu-32
    #Maintainer : Seunghwan Lee <sh.cat.lee@samsung.com>
    #Attribute : binary
    #Description : ARM rootstrap for native app development

    FILE_PKGINFO="pkginfo.manifest"
    ATTR_PKG="Package"
    ATTR_VERSION="Version"
    ATTR_OS="OS"
    ATTR_MAIN="Maintainer : Seunghwan Lee <sh.cat.lee@samsung.com>"
    ATTR_ATTR="Attribute : binary"
    ATTR_DESC="Description : rootstrap for native app development"


    if [[ -e $FILE_PKGINFO ]]; then
        rm $FILE_PKGINFO
    fi

    VAL_PKG="$1"
    VAL_VERSION="$2"
    VAL_OS="$3"

    echo "$ATTR_PKG : $VAL_PKG" | tee -a $FILE_PKGINFO
    echo "$ATTR_VERSION : $VAL_VERSION" | tee -a $FILE_PKGINFO

    if [[ ${VAL_OS} == "all" ]]; then
    echo "$ATTR_OS : ubuntu-64, windows-64, macos-64" | tee -a $FILE_PKGINFO
    else
    echo "$ATTR_OS : $VAL_OS" | tee -a $FILE_PKGINFO
    fi

    echo "$ATTR_MAIN" | tee -a $FILE_PKGINFO
    echo "$ATTR_ATTR" | tee -a $FILE_PKGINFO
    echo "$ATTR_DESC" | tee -a $FILE_PKGINFO


}

###############################################################################
# function usage
###############################################################################
function usage () {
    echo "$SCRIPT_NAME ($SCRIPT_VER) is script to package rootstrap for SDK"
    echo "Usage: $SCRIPT_NAME -C [<config_file>] [<OPTION>]"
    echo "    -C, --conf      : Configuration File"
    echo "    -o, --os        : Package OS (ubuntu-64 windows-64 macos-64)"
    echo "    -h, --help"
    echo "    -v, --version   : Display script version information"
    echo "    --internal      : "
    echo "    --snapshot      : "
    echo "    --sdkpkg        : "
    echo "    --pkgver        : "
    echo ""
    echo "Example:"
    echo " >$SCRIPT_NAME -C rs-config"
    echo " > mobile-3.0-device.core, mobile-3.0-emulator.core"
    echo " >$SCRIPT_NAME -C rs-config -os ubuntu-64"
    echo ""
    echo "Example:"
    echo " >$SCRIPT_NAME -C rs-config"
    echo " > mobile-3.0-device.core, mobile-3.0-emulator.core"

    echo ""
    echo "Output Diretory:"
    echo ".temp_pkg"
    echo ".pkg"

    return
}

###############################################################################
## Get Parameter
###############################################################################
OPTS=`getopt -o -d:o:C: --long dir:,os:,conf:,internal,public,snapshot:,sdkpkg,pkgver:,64bit -- "$@"`
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;;
        -o | --os ) OS_LIST="${2}"; shift;shift;;
        -h | --help ) usage; exit 0;;
        -v | --version ) echo "${SCRIPT_NAME}" "version : $SCRIPT_VER"; exit 0 ;;
        --internal ) INTERNAL=true; shift;;
        --public ) PUBLIC=true; shift;;
        --snapshot ) SNAPSHOT=$2; shift;shift;;
        --sdkpkg ) SDKPKG=true; shift;;
        --pkgver ) TMP_PKG_VERSION=$2; shift;shift;;
        --64bit )
            echo "64bit!!";
            DEVICE="device64"
            EMULATOR="emulator64"
            shift;;
        -- ) shift; break ;;
        *)
        echo "param error";
        exit 1; shift;;
esac
done

###############################################################################
## Check Environment
###############################################################################
if [[ -e ${OPT_CONF} ]]; then
    log_info "source ${OPT_CONF}"
    source "${OPT_CONF}"
else
    log_error "[Error] Configuration File Does not Exist"
    usage
    exit 1
fi

log_info "OS_LIST = $OS_LIST"

#CHECK CMD available
printf "check command ... "
if [ -z $(which xmlstarlet) ]
then
    log_error "[Error] Check xmlstarlet command" 1>&2
    exit -1
fi
printf "Done\n\n"


#CHECK Resource from make_rootstrap.sh
printf "check Resource Directory ... "
if [ ! -e ${DIR_INFO} ] || [ ! -e ${DIR_PLUGIN} ] || [ ! -e ${DIR_TARGET} ]
then
    echo "Check resource dirs are exist !" 1>&2
    echo "${DIR_INFO}" 1>&2
    echo "${DIR_TARGET}" 1>&2
    echo "${DIR_PLUGIN}" 1>&2
    exit -1
fi
printf "Done\n\n"

#CHECK configuration
if [[ -z $PLATFORM_VERSION ]]; then
    echo "[Error] Configure PLATFORM_VERSION is NULL" 1>&2
    exit -1
fi

if [[ -z $PLATFORM_PROFILE ]]; then
    echo "[Error] Configure PLATFORM_PROFILE is NULL" 1>&2
    exit -1
fi

if [[ -n $SNAPSHOT ]]; then
SNAPSHOT=".$SNAPSHOT"
fi

if [ "$INTERNAL" = true ]; then
PRIVATE=".private"
fi

if [ "$PUBLIC" = true ]; then
PRIVATE=".public"
INTERNAL=true;
fi

if [ -z $SNAPSHOT ] && [ "$INTERNAL" = false ]; then
log_info "SET SDKPKG = true (Snapshot = NULL,  INTERNAL = false)"
SDKPKG=true
fi


###############################################################################
## Clean Up
###############################################################################

PATH_PACKAGE_RES=$PWD/$DIR_TMP_PKG
printf "Clean up Directory ${PATH_PACKAGE_RES} ... "

if [[  -e "$PATH_PACKAGE_RES" ]]; then
    rm -rf $PATH_PACKAGE_RES
fi
mkdir $PATH_PACKAGE_RES

printf "Done\n\n"

pkg_dir=$PWD"/$DIR_OUTPUT"

printf "Clean up Directory ${pkg_dir} ... "

if [[ -e ${pkg_dir} ]]; then
    rm -rf ${pkg_dir};
fi
mkdir ${pkg_dir};
printf "Done\n\n"


###############################################################################
## Build rootstarp SDK package
###############################################################################

printf "make rootstrap Package\n\n"

NAME_DEVICE_PKG_ZIP=${PLATFORM_PROFILE}-${PLATFORM_VERSION}-rs-${DEVICE}.core${PRIVATE}${SNAPSHOT}.zip
NAME_EMULATOR_PKG_ZIP=${PLATFORM_PROFILE}-${PLATFORM_VERSION}-rs-${EMULATOR}.core${PRIVATE}${SNAPSHOT}.zip

DIR_PLUGIN_DEST="${PATH_PACKAGE_RES}/data/tools/smart-build-interface/plugins/"
DIR_INFO_DEST="${PATH_PACKAGE_RES}/data/platforms/tizen-${PLATFORM_VERSION}/${PLATFORM_PROFILE}/rootstraps/info/"
DIR_ROOTSTRAP_DEST="${PATH_PACKAGE_RES}/data/platforms/tizen-${PLATFORM_VERSION}/${PLATFORM_PROFILE}/rootstraps/"

###############################################################################
#Create Rootstrap Basic Resource to .pkg
###############################################################################
pkg_build_internal ${DEVICE}
(
cd ${PATH_PACKAGE_RES}
zip -r ${NAME_DEVICE_PKG_ZIP} data >/dev/null
mv ${PATH_PACKAGE_RES}/*.zip ${pkg_dir}
log_info "Genarated Basic RS resource [${pkg_dir}] ... \n\n"
)

#pkg_build_internal ${EMULATOR}
#(
#cd ${PATH_PACKAGE_RES}
#zip -r ${NAME_EMULATOR_PKG_ZIP} data >/dev/null
#mv ${PATH_PACKAGE_RES}/*.zip ${pkg_dir}
#log_info "Genarated Basic RS resource [${pkg_dir}] ... \n\n"
#)

log "Done... [$SECONDS]Sec\n\n"

###############################################################################
#Create Rootstrap Package for SDK to .pkg
###############################################################################
if [[ "$SDKPKG" == true ]] && [[ -z "$SNAPSHOT" ]] ; then
    echo "Start SDK package .. from temp"

    if [[ -e ${DIR_TMP_SDK_PKG} ]]; then
        rm -rf ${DIR_TMP_SDK_PKG};
    fi
    mkdir ${DIR_TMP_SDK_PKG};

    for OS in $OS_LIST
    do
        mkdir -p ${DIR_TMP_SDK_PKG}/${OS};

        cp $DIR_OUTPUT/*.zip $DIR_TMP_SDK_PKG/$OS

        mv ${DIR_TMP_SDK_PKG}/${OS}/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-rs-${DEVICE}.core*.zip ${DIR_TMP_SDK_PKG}/${OS}/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-rs-${DEVICE}.core${PRIVATE}_${TMP_PKG_VERSION}_${OS}.zip

        #device
        create_pkginfo "${PLATFORM_PROFILE}-${PLATFORM_VERSION}-rs-${DEVICE}.core${PRIVATE}" "$TMP_PKG_VERSION" "all"
        zip "${DIR_TMP_SDK_PKG}/${OS}/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-rs-${DEVICE}.core${PRIVATE}_${TMP_PKG_VERSION}_${OS}.zip" pkginfo.manifest

        #emulator
#        mv ${DIR_TMP_SDK_PKG}/${OS}/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-rs-${EMULATOR}.core*.zip ${DIR_TMP_SDK_PKG}/${OS}/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-rs-${EMULATOR}.core${PRIVATE}_${TMP_PKG_VERSION}_${OS}.zip
#        create_pkginfo "${PLATFORM_PROFILE}-${PLATFORM_VERSION}-rs-${EMULATOR}.core${PRIVATE}" "$TMP_PKG_VERSION" "all"
#        zip "${DIR_TMP_SDK_PKG}/${OS}/${PLATFORM_PROFILE}-${PLATFORM_VERSION}-rs-${EMULATOR}.core${PRIVATE}_${TMP_PKG_VERSION}_${OS}.zip" pkginfo.manifest
    done

    rm $DIR_OUTPUT/*.zip
    find ${DIR_TMP_SDK_PKG} -name "*.zip" -exec mv {} $DIR_OUTPUT \;

fi

if [[ -n "$SNAPSHOT" ]] ; then
    log_info "Add PkgInfo for ABS [$SNAPSHOT] \n\n"
    #device
    create_pkginfo "${PLATFORM_PROFILE}-${PLATFORM_VERSION}-rs-${DEVICE}.core${PRIVATE}" "0.0.1" "all"
    find $DIR_OUTPUT -name "*device*.zip" -exec zip {} pkginfo.manifest \;


    #emulator
#    create_pkginfo "${PLATFORM_PROFILE}-${PLATFORM_VERSION}-rs-${EMULATOR}.core${PRIVATE}" "0.0.1" "all"
#    find $DIR_OUTPUT -name "*emulator*.zip" -exec zip {} pkginfo.manifest \;
fi

###############################################################################
# Show PKG
###############################################################################
echo "$(ls ${pkg_dir}/*.zip | wc -l) files Genereated ... "
for i in $(ls ${pkg_dir}/*.zip)
do
    echo "$(du -h $i | awk '{print $2,"["$1"]"}')"
done

echo "Done... [$SECONDS]Sec"
exit 0