--- /dev/null
+#!/bin/bash
+wgt_installer="pkgcmd"
+NAME=$(basename $(cd $(dirname $0);pwd))
+
+#parse params
+USAGE="Usage: ./inst.sh [-i] [-u]
+ -i install wgt and config environment
+ -u uninstall wgt and remove source file
+[-i] option was set as default."
+
+function installpkg(){
+### install wgt ###
+type $wgt_installer > /dev/null 2>&1
+if [ $? -eq 0 ]; then
+ [ -e /opt/usr/media/tct/opt/$NAME/$NAME.wgt ] && $wgt_installer -i -t wgt -q -p /opt/usr/media/tct/opt/$NAME/$NAME.wgt
+ if [ $? -eq 0 ]; then
+ echo "Install /opt/usr/media/tct/opt/$NAME/$NAME.wgt to /opt/usr/apps/`wrt-launcher -l 2> /dev/null | grep $NAME | tail -n 1 | awk '{ print $(NF-1) }'` done"
+ echo "$(wrt-launcher -l | grep $NAME | awk '{ print $(NF-1) }') sdbd rw" | smackload
+ else
+ echo "Install /opt/$NAME/$NAME.wgt fail ..."
+ fi
+ sync
+fi
+}
+
+function uninstallpkg(){
+### uninstall wgt ###
+type $wgt_installer > /dev/null 2>&1
+if [ $? -eq 0 ]; then
+ package_id=`wrt-launcher -l 2> /dev/null | grep $NAME | tail -n 1 | awk '{ print $(NF-1) }'`
+ if [ -n "$(ps -ef | grep $package_id | grep -v grep | awk '{print $2}')" ]; then
+ for i in $(ps -ef | grep $package_id | grep -v grep | awk '{print $2}')
+ do
+ kill -9 $i
+ if [ "$?" -ne 0 ]; then
+ echo "Kill the processes of $NAME fail ..."
+ else
+ echo "Kill the processes of $NAME done"
+ fi
+ done
+ fi
+
+ if [ -n "$package_id" ]; then
+ $wgt_installer -u -q -t wgt -n $package_id
+ if [ "$?" -ne 0 ]; then
+ echo "Uninstall $NAME fail ..."
+ else
+ echo "Uninstall $NAME done"
+ fi
+ sync
+ fi
+fi
+
+### remove source file ###
+if [ -d /opt/usr/media/tct/opt/$NAME ];then
+ rm -rf /opt/usr/media/tct/opt/$NAME
+else
+ echo "Remove source file fail,please check if the source file exist: /opt/usr/media/tct/opt/$NAME ..."
+fi
+}
+
+case "$1" in
+ -h|--help) echo "$USAGE"
+ exit ;;
+ ""|-i) installpkg;;
+ -u) uninstallpkg;;
+ *) echo "Unknown option: $1"
+ echo "$USAGE"
+ exit ;;
+esac
#!/bin/bash
-#
-# Authors:
-# Jing Wang <jing.j.wang@intel.com>
-# Huajun Li <huajun.li@intel.com>
-# Yugang Fan <yugang.fan@intel.com>
-#
-# script create rpm package
+source $(dirname $0)/tct-behavior-tests.spec
#parse params
-USAGE="Usage: ./pack.sh"
+usage="Usage: ./pack.sh [-t <package type: wgt | apk | crx | xpk>]
+[-t wgt] option was set as default."
if [[ $1 == "-h" || $1 == "--help" ]]; then
- if [[ $platforms != "" ]]; then
- echo $USAGE "[-p "$platforms"]"
- else
- echo $USAGE
- fi
- echo "Create package with wgt and raw source by default"
+ echo $usage
+ exit 1
+fi
+
+type="wgt"
+while getopts t: o
+do
+ case "$o" in
+ t) type=$OPTARG;;
+ *) echo $usage
+ exit 1;;
+ esac
+done
+
+if [[ $type == "wgt" || $type == "apk" || $type == "crx" || $type == "xpk" ]];then
+ echo "Create package with $type and raw source"
+else
+ echo "Sorry,$type is not support... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+ echo "$usage"
exit 1
fi
-# parse spec required name
-NAME=`grep "Name:" *.spec | awk '{print $2}'`
-if [ -z "$NAME" ];then
- echo "Name not specified in spec file"
- exit 1
+if [[ -z $name || -z $version || -z $appname ]];then
+ echo "Package name or version not specified in setting file"
+ exit 1
fi
+SRC_ROOT=$PWD
+BUILD_ROOT=/tmp/${name}_pack
+BUILD_DEST=/tmp/${name}
+
+# clean
+function clean_workspace(){
+echo "cleaning workspace... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+rm -rf $BUILD_ROOT $BUILD_DEST
+}
-# parse spec required version
-VERSION=`grep "Version:" ${NAME}.spec | awk '{print $2}'`
-if [ -z "$VERSION" ];then
- echo "Version not specified in spec file"
- exit 1
+clean_workspace
+mkdir -p $BUILD_ROOT $BUILD_DEST
+
+# copy source code
+rm -rf *.rpm *.tar.bz2 *.tar.gz *.zip
+cp -arf $SRC_ROOT/* $BUILD_ROOT/
+
+## function for create wgt apk xpk ##
+
+function create_wgt(){
+# create wgt
+cd $BUILD_DEST
+cp -af $BUILD_ROOT/index.html $BUILD_DEST/
+cp -af $BUILD_ROOT/config.xml $BUILD_DEST/
+cp -af $BUILD_ROOT/icon.png $BUILD_DEST/
+cp -af $BUILD_ROOT/tests.xml $BUILD_DEST/
+cp -af $BUILD_ROOT/subtestresult.xml $BUILD_DEST/
+cp -af $BUILD_ROOT/js $BUILD_DEST/
+cp -af $BUILD_ROOT/css $BUILD_DEST/
+cp -af $BUILD_ROOT/tests $BUILD_DEST/
+cp -af $BUILD_ROOT/res $BUILD_DEST/
+mkdir -p $BUILD_DEST/opt/$name/res/media
+zip -rq $BUILD_DEST/opt/$name/$name.wgt *
+if [ $? -ne 0 ];then
+ echo "Create $name.wgt fail.... >>>>>>>>>>>>>>>>>>>>>>>>>"
+ clean_workspace
+ exit 1
fi
-SRC_ROOT=${PWD}
-RPM_ROOT=/tmp/${NAME}_pack
-ARCHIVE_TYPE=tar.gz #tar.gz2
-ARCHIVE_OPTION=czvf #cjvf
-
-# check precondition
-check_precondition()
-{
- which $1 > /dev/null 2>&1
- if [ $? -ne 0 ]; then
- echo "Error: no tool: $1"
+# sign wgt
+if [ $sign -eq 1 ];then
+ # copy signing tool
+ echo "copy signing tool... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+ cp -arf $SRC_ROOT/tools/signing $BUILD_ROOT/signing
+ if [ $? -ne 0 ];then
+ echo "No signing tool found in $SRC_ROOT/tools.... >>>>>>>>>>>>>>>>>>>>>>>>>"
+ clean_workspace
exit 1
fi
+ wgt=$(find $BUILD_DEST/opt/$name/ -name *.wgt)
+ for wgt in $(find $BUILD_DEST/opt/$name/ -name *.wgt);do
+ $BUILD_ROOT/signing/sign-widget.sh --dist platform $wgt
+ if [ $? -ne 0 ];then
+ echo "Please check your signature files... >>>>>>>>>>>>>>>>>>>>>>>>>"
+ clean_workspace
+ exit 1
+ fi
+ done
+fi
+}
+
+function create_apk(){
+echo "Sorry,apk is not support yet... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+clean_workspace
+exit 1
}
-check_precondition rpmbuild
-check_precondition gcc
-check_precondition make
+function create_xpk(){
+echo "Sorry,xpk is not support yet... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+clean_workspace
+exit 1
+}
-# clean
-echo "cleaning rpm workspace... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
-rm -rf $RPM_ROOT
-
-# create workspace
-echo "create rpm workspace... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
-mkdir -p $RPM_ROOT/RPMS $RPM_ROOT/SRPMS $RPM_ROOT/SPECS $RPM_ROOT/SOURCES $RPM_ROOT/BUILD $RPM_ROOT/src_tmp/$NAME-$VERSION
-
-# prepare
-echo "prepare workspace... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
-rm -rf *.rpm *.tar.bz2 *.tar.gz
-cp -a $SRC_ROOT/* $RPM_ROOT/src_tmp/$NAME-$VERSION
-# create Makefile in top src folder
-#cp $SRC_ROOT/top_Makefile $RPM_ROOT/src_tmp/$NAME-$VERSION/Makefile
-cp $PWD/${NAME}.spec $RPM_ROOT/SPECS
-cd $RPM_ROOT/src_tmp
-tar $ARCHIVE_OPTION $RPM_ROOT/SOURCES/$NAME-$VERSION.$ARCHIVE_TYPE $NAME-$VERSION
-cd -
-
-# build
-echo "build from workspace... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
-cd $RPM_ROOT/SPECS
-rpmbuild -ba ${NAME}.spec --clean --define "_topdir $RPM_ROOT" --target=noarch
-cd -
-
-# copy packages
-echo "copy from workspace... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
-echo "get packages......"
-find $RPM_ROOT -name "$NAME*.zip" | grep -v debuginfo | xargs -n1 -I {} mv -f {} $PWD
-find $RPM_ROOT -name "$NAME*.rpm" | grep -v debuginfo | xargs -n1 -I {} mv -f {} $PWD
-
-if [[ $platform != "" && $platform != "default" ]]; then
- cd $PWD
- for file in `ls *.rpm`; do
- new_name=`echo $file | sed "s/\.rpm/\.$platform\.rpm/g"`
- mv $file $new_name
- done
- cd -
+function create_crx(){
+echo "crx is not support yet... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+clean_workspace
+exit 1
+}
+
+## zip function ##
+function zip_for_wgt(){
+cd $BUILD_DEST
+# cp inst.sh script and tests.xml #
+cp -af $BUILD_ROOT/inst.sh.wgt $BUILD_DEST/opt/$name/inst.sh
+cp -af $BUILD_ROOT/tests.xml $BUILD_DEST/opt/$name/tests.xml
+
+# cp res folder #
+cp -a $BUILD_ROOT/res/font $BUILD_DEST/opt/$name/res/font
+cp -a $BUILD_ROOT/res/images $BUILD_DEST/opt/$name/res/images
+cp -a $BUILD_ROOT/res/js $BUILD_DEST/opt/$name/res/js
+cp -a $BUILD_ROOT/res/css $BUILD_DEST/opt/$name/res/css
+cp -a $BUILD_ROOT/res/media/red-green.theora.ogv $BUILD_DEST/opt/$name/res/media/
+
+if [ $src_file -eq 0 ];then
+ for file in $(ls opt/$name |grep -v wgt);do
+ if [[ "${whitelist[@]}" =~ $file ]];then
+ echo "$file in whitelist,keep it..."
+ else
+ echo "Remove unnessary file:$file..."
+ rm -rf opt/$name/$file
+ fi
+ done
+fi
+zip -Drq $BUILD_DEST/$name-$version.zip opt/
+if [ $? -ne 0 ];then
+ echo "Create zip package fail... >>>>>>>>>>>>>>>>>>>>>>>>>"
+ clean_workspace
+ exit 1
fi
+}
-echo "get $NAME-$VERSION.$ARCHIVE_TYPE......"
-mv -f $RPM_ROOT/SOURCES/$NAME-$VERSION.$ARCHIVE_TYPE $PWD
+function zip_for_apk(){
+echo "Sorry,apk is not support yet... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+clean_workspace
+exit 1
+}
-# clean
-echo "cleaning workspace... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
-rm -rf $RPM_ROOT
+function zip_for_xpk(){
+echo "Sorry,xpk is not support yet... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+clean_workspace
+exit 1
+}
+
+function zip_for_crx(){
+echo "zip_for_crx not ready yet... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+clean_workspace
+exit 1
+}
+
+## create wgt crx apk xpk and zip package ##
+case $type in
+ wgt) create_wgt
+ zip_for_wgt;;
+ apk) create_apk
+ zip_for_apk;;
+ xpk) create_xpk
+ zip_for_xpk;;
+ crx) create_crx
+ zip_for_crx;;
+esac
+
+
+# copy zip file
+echo "copy package from workspace... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+cp -f $BUILD_DEST/$name-$version.zip $SRC_ROOT/$name-$version.zip
+
+# clean workspace
+clean_workspace
# validate
echo "checking result... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
-if [ -z "`ls | grep "\.rpm"`" ] || [ -z "`ls | grep "\.$ARCHIVE_TYPE"`" ];then
- echo "------------------------------ FAILED to build $NAME packages --------------------------"
- exit 1
+if [ -z "`ls $SRC_ROOT | grep "\.zip"`" ];then
+ echo "------------------------------ FAILED to build $name packages --------------------------"
+ exit 1
fi
-echo "------------------------------ Done to build $NAME packages --------------------------"
-ls *.rpm *.$ARCHIVE_TYPE 2>/dev/null
+echo "------------------------------ Done to build $name packages --------------------------"
+cd $SRC_ROOT
+ls *.zip 2>/dev/null
-%define _unpackaged_files_terminate_build 0
+name="tct-behavior-tests"
+version="0.4.2"
+appname=$(echo $name|sed 's/-/_/g')
-Summary: TCT Behavior Tests
-Name: tct-behavior-tests
-Version: 0.4.2
-Release: 1
-License: BSD
-Group: System/Libraries
-Source: %name-%version.tar.gz
+# set value "1" if this suite need to sign,otherwise set "0" #
+sign="1"
-%description
-This is TCT Behavior test suite package
-
-
-%prep
-%setup -q
-
-%build
-./autogen
-./configure --prefix=/usr
-make
-
-%install
-rm -rf $RPM_BUILD_ROOT
-make install DESTDIR=$RPM_BUILD_ROOT
-
-pre_dir=`pwd`
-cp -a $RPM_BUILD_ROOT $RPM_BUILD_DIR/%name
-cp -a $pre_dir/index.html $RPM_BUILD_DIR/%name
-cp -a $pre_dir/config.xml $RPM_BUILD_DIR/%name
-cp -a $pre_dir/icon.png $RPM_BUILD_DIR/%name
-cp -a $pre_dir/tests.xml $RPM_BUILD_DIR/%name
-cp -a $pre_dir/subtestresult.xml $RPM_BUILD_DIR/%name
-cp -a $pre_dir/js $RPM_BUILD_DIR/%name
-cp -a $pre_dir/css $RPM_BUILD_DIR/%name
-cp -a $pre_dir/tests $RPM_BUILD_DIR/%name
-cp -a $pre_dir/res $RPM_BUILD_DIR/%name
-cd $RPM_BUILD_DIR/%name
-mkdir -p $RPM_BUILD_ROOT/opt/%name/res/media
-cp -a $pre_dir/res/font $RPM_BUILD_ROOT/opt/%name/res/font
-cp -a $pre_dir/res/images $RPM_BUILD_ROOT/opt/%name/res/images
-cp -a $pre_dir/res/js $RPM_BUILD_ROOT/opt/%name/res/js
-cp -a $pre_dir/res/css $RPM_BUILD_ROOT/opt/%name/res/css
-cp -a $pre_dir/res/media/red-green.theora.ogv $RPM_BUILD_ROOT/opt/%name/res/media/
-zip -rq $RPM_BUILD_ROOT/opt/%name/%name.wgt *
-cd $pre_dir/signing/
-./sign-widget.sh --config default.conf $RPM_BUILD_ROOT/opt/%name/%name.wgt
-cd $pre_dir
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files
-/opt/%name
-
-%changelog
-
-%post
-wgt_installer="wrt-installer"
-which $wgt_installer > /dev/null 2>&1
-if [ $? -eq 0 ]; then
- [ -e /opt/%name/%name.wgt ] && $wgt_installer -i /opt/%name/%name.wgt
- if [ $? -eq 0 ]; then
- echo "Install /opt/%name/%name.wgt to /opt/usr/apps/`wrt-launcher -l 2> /dev/null | grep %name | tail -n 1 | awk '{ print $NF }'` done"
- else
- echo "Install /opt/%name/%name.wgt fail ..."
- fi
- sync
-fi
-
-%postun
-wgt_installer="wrt-installer"
-which $wgt_installer > /dev/null 2>&1
-if [ $? -eq 0 ]; then
- package_id=`wrt-launcher -l 2> /dev/null | grep %name | tail -n 1 | awk '{ print $NF }'`
- if [ -n "$(ps -ef | grep $package_id | grep -v grep | awk '{print $2}')" ]; then
- for i in $(ps -ef | grep $package_id | grep -v grep | awk '{print $2}')
- do
- kill -9 $i
- if [ "$?" -ne 0 ]; then
- echo "Kill the processes of %name fail ..."
- else
- echo "Kill the processes of %name done"
- fi
- done
- fi
-
- if [ -n "$package_id" ]; then
- $wgt_installer -un $package_id
- if [ "$?" -ne 0 ]; then
- echo "Uninstall %name fail ..."
- else
- echo "Uninstall %name done"
- fi
- sync
- fi
-fi
+# set value "1" if this suite need to keep src_file,otherwise set "0" #
+src_file="1"
+# specified files to be kept in whitelist #
+whitelist="
+inst.sh
+tests.xml
+mediasrc"