[TCT][scripts_tpk][Non-ACR][Scripts to create build and execute TCT by tpk method]
authorAmritanshu Pandia <a.pandia1@samsung.com>
Thu, 9 Jun 2016 12:32:07 +0000 (18:02 +0530)
committerAmritanshu Pandia <a.pandia1@samsung.com>
Thu, 16 Jun 2016 05:32:31 +0000 (22:32 -0700)
Change-Id: I1d5695cdd1cf8b104dbb56eb374d4c5a36aa9162
Signed-off-by: Amritanshu Pandia <a.pandia1@samsung.com>
17 files changed:
scripts_tpk/LICENSE [new file with mode: 0755]
scripts_tpk/README [new file with mode: 0755]
scripts_tpk/external_wrapper.sh [new file with mode: 0755]
scripts_tpk/init.sh [new file with mode: 0755]
scripts_tpk/inst.sh [new file with mode: 0755]
scripts_tpk/install.log [new file with mode: 0755]
scripts_tpk/mobile.sed [new file with mode: 0755]
scripts_tpk/retriever.py [new file with mode: 0755]
scripts_tpk/spec.sh [new file with mode: 0755]
scripts_tpk/tcheadgen.py [new file with mode: 0755]
scripts_tpk/tcpackageslistsgen.py [new file with mode: 0755]
scripts_tpk/tctestsgen.py [new file with mode: 0755]
scripts_tpk/tpk-install.py [new file with mode: 0755]
scripts_tpk/tpk_create.sh [new file with mode: 0755]
scripts_tpk/tpkbuild.sh [new file with mode: 0755]
scripts_tpk/tpksdk-install.py [new file with mode: 0755]
scripts_tpk/wearable.sed [new file with mode: 0755]

diff --git a/scripts_tpk/LICENSE b/scripts_tpk/LICENSE
new file mode 100755 (executable)
index 0000000..d645695
--- /dev/null
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/scripts_tpk/README b/scripts_tpk/README
new file mode 100755 (executable)
index 0000000..4cd7911
--- /dev/null
@@ -0,0 +1,91 @@
+----------------------------------------------
+License
+----------------------------------------------
+Copyright (c) 2012 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+  of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+  may be used to endorse or promote products derived from this work without
+  specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+        Yue, Jianhui <jianhuix.a.yue@intel.com>
+
+
+----------------------------------------------
+Introduction
+----------------------------------------------
+   This test suite is for Web Application Security & Privacy module testing.
+
+
+----------------------------------------------
+Test Environment
+----------------------------------------------
+Run the cases as "root" user.
+
+
+----------------------------------------------
+Installation
+----------------------------------------------
+./autogen
+./configure prefix=/usr
+make && make install
+
+
+----------------------------------------------
+Build and Run
+----------------------------------------------
+(Suppose you only get the source code which has been set up on your test device.
+ If you have obtained tct-sp02-wrt-tests RPM packages, you can go directly  to step 3 on the test device)
+
+Steps:
+    1. Prepare for building:
+       cd tct-sp02-wrt-tests
+    2. Build RPM packages:
+       ./pack.sh -t all
+    3. Install RPM on the test device:
+       rpm -ivh tct-sp02-wrt-tests-<version>-<release>.<arch>.rpm
+    4. Prepare to install widget application on the device:
+       cd /opt/tct-sp02-wrt-tests/
+    5. Install WGT on the test device:
+       pkgcmd -i -t wgt -q -p **.wgt
+    6. Check the widget info when the widget has been installed:
+       wrt-launcher -l
+    7. Launch the widget:
+       wrt-launcher -s <Application id>
+    8. Uninstall WGT from the test device:
+       pkgcmd -u -q -t wgt -n <application id>
+
+
+----------------------------------------------
+Known Issues
+----------------------------------------------
+    1. Chromium browser does not support the widget framework.
+    2. The icons which are used in the test cases are contained in the associated widget package.
+
+Note: If there is any defects in this test suite, please do not hesitate to contact us by the email jianhuix.a.yue@intel.com
+
+
+----------------------------------------------
+Todo
+----------------------------------------------
+
+
diff --git a/scripts_tpk/external_wrapper.sh b/scripts_tpk/external_wrapper.sh
new file mode 100755 (executable)
index 0000000..079d4bc
--- /dev/null
@@ -0,0 +1,103 @@
+
+
+#!/bin/bash
+#
+# Copyright (c) 2014 Samsung Electronics Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+TIMEOUT_VALUE=60 #default timeout value
+FILE="/tmp/TC_Timeout.txt"
+
+if [[ "$1" == "" || "$2" == "" || "$3" == "" ]];
+then
+    echo "module name, TC name and build type type needed"
+    exit 1
+fi
+
+TIME_FACTOR=10
+RESULT_PATH=/tmp/tcresult
+ERRLOG_PATH=/tmp/tclog
+UTC_LOG_CORE=/tmp/utclog_core
+
+#Read timeout value from /tmp/TCT_Timeout.txt file
+if [ -f $FILE ];
+then
+       for next in `cat $FILE`
+       do
+           TIMEOUT_VALUE=$next
+       done
+fi
+
+function KillPackage {
+       pkgcmd --kill -n $1
+       sleep 2
+}
+
+
+function Execute {
+       rm -f $RESULT_PATH
+       rm -f $ERRLOG_PATH
+       rm -f $UTC_LOG_CORE
+
+       RET=`su -c "app_launcher -s $1 testcase_name $2" owner`
+       if [[ $RET != *"successfully launched"* ]];then
+               echo "Launch Failed"
+               KillPackage $1
+               exit 1
+       fi
+
+       COUNTER=0
+       COMPARE=$(($TIMEOUT_VALUE * $TIME_FACTOR))
+       while [ ! -e $RESULT_PATH ];
+       do
+               if [[ $COUNTER -gt $COMPARE ]];then
+                       echo "Timeout! [ Execution exceeded $TIMEOUT_VALUE seconds ]"
+                       if [ -e $ERRLOG_PATH ];
+                       then
+                               echo `cat $ERRLOG_PATH`
+                               rm -f $ERRLOG_PATH
+                       fi
+                       if [ -e $UTC_LOG_CORE ];
+                       then
+                               echo `cat $UTC_LOG_CORE`
+                               rm -f $UTC_LOG_CORE
+                       fi
+
+                       KillPackage $1
+                       exit 1
+               fi
+               sleep 0.1
+               COUNTER=$(($COUNTER + 1))
+       done
+
+       if [ -e $ERRLOG_PATH ];
+       then
+               echo `cat $ERRLOG_PATH`
+               rm -f $ERRLOG_PATH
+       fi
+       if [ -e $UTC_LOG_CORE ];
+       then
+               echo `cat $UTC_LOG_CORE`
+               rm -f $UTC_LOG_CORE
+       fi
+       exit `cat $RESULT_PATH`
+}
+
+
+Execute $1 $2
+
+
+
+
diff --git a/scripts_tpk/init.sh b/scripts_tpk/init.sh
new file mode 100755 (executable)
index 0000000..c79a247
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+#
+# Copyright (c) 2014 Samsung Electronics Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+PROJECT_DIR="$(cd "$(dirname $0)" && cd .. && pwd)"
+if [ ! -d $HOME/bin ]; then 
+       mkdir -p $HOME/bin
+fi     
+
+ln -sf $HOME/tizen-sdk/tools/ide/bin/tizen.sh $HOME/bin/tizen
+export PATH=$PATH:$HOME/bin
+tizen cli-config --global default.profiles.path=$HOME/workspace/.metadata/.plugins/org.tizen.common.sign/profiles.xml
+
+ln -sf ./scripts_tpk/tpkbuild.sh $PROJECT_DIR/tpkbuild
\ No newline at end of file
diff --git a/scripts_tpk/inst.sh b/scripts_tpk/inst.sh
new file mode 100755 (executable)
index 0000000..f5e1e27
--- /dev/null
@@ -0,0 +1,134 @@
+#!/bin/bash
+#
+# Copyright (c) 2014 Samsung Electronics Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+ NAME=$(basename $(cd $(dirname $0);pwd))
+ MOD_NAME=%{MOD_NAME}
+ PKG_DIR=%{PKG_DIR} # directory supplied by external script
+ PKG_NAME=%{PKG_NAME} # name supplied by external script
+ PKG_FULLNAME=%{PKG_FULLNAME} # name supplied by external script
+ #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 KillPackage {
+       alive=`pkgcmd -C -n $1 | grep "Not\|ARGUMENT_INVALID"`
+       if [ "$alive" == "" ]; then
+               pkgcmd --kill -n $1
+       fi
+}
+
+ function installpkg(){   
+     chmod -R 777 /$PKG_DIR/$PKG_FULLNAME
+     su -c "pkgcmd -i -q -t tpk -p /$PKG_DIR/$PKG_FULLNAME" owner
+     
+       if [ -e /home/owner/apps_rw/$PKG_NAME/shared/res/spec.sh ];then
+               WORKDIR=`pwd`
+               cd /home/owner/apps_rw/$PKG_NAME/shared/res
+               chmod -R 777 ./spec.sh
+               sh ./spec.sh $PKG_NAME
+               cd $WORKDIR
+       fi
+         
+       if [ -d /home/owner/apps_rw/$PKG_NAME/shared/res ];then
+               rm -rf /home/owner/content/res
+               mkdir -p /home/owner/content/res
+
+               cp -rf /home/owner/apps_rw/$PKG_NAME/shared/res/* /home/owner/content/res/
+               find /home/owner/content/res/ -exec chsmack -a "User::App::Shared" {} \;
+
+               if [ "$(uname -m)" == "armv7l" ]; then
+                        applist=`ls /home/owner/content/res | grep tpk | grep arm`
+               else
+                        applist=`ls /home/owner/content/res | grep tpk | grep i386`
+               fi
+
+               for app in $applist
+               do
+                        su -c "pkgcmd -i -q -t tpk -p /home/owner/content/res/$app" owner 
+                        sync
+               done
+
+               if [ "$(uname -m)" == "armv7l" ]; then
+                        applist_rpm=`ls /home/owner/content/res | grep rpm | grep arm`
+               else
+                        applist_rpm=`ls /home/owner/content/res | grep rpm | grep i586`
+               fi
+
+               for app in $applist_rpm
+               do
+                       su -c "pkgcmd -i -q -t rpm -p /home/owner/content/res/$app" owner
+                        sync
+               done
+       fi
+                
+       if [ $PKG_NAME == "org.tizen.email-native-itc" ]; then
+               echo "email-service org.tizen.email-native-itc rwxa" | smackload
+       fi
+               
+       if [ -f /opt/usr/apps/org.tizen.capi-message-port-native-itc/data/org.tizen.capi-message-port-native-itc.sh ]; then
+               source /opt/usr/apps/org.tizen.capi-message-port-native-itc/data/org.tizen.capi-message-port-native-itc.sh
+       fi
+
+       if [ -f /opt/usr/apps/org.tizen.capi-message-port-native-utc/bin/core-capi-message-port-tests.sh ]; then
+                source /opt/usr/apps/org.tizen.capi-message-port-native-utc/bin/core-capi-message-port-tests.sh
+
+       fi
+       ( echo 3 ; sleep 1 ; echo cert ; sleep 1 ; echo 0 ; ) | pkginfo --setcert org.tizen.messageportapp
+
+       rm -f /tmp/tcresult
+       rm -f /tmp/tclog
+       rm -f /tmp/utclog_core
+       rm -f /tmp/tcrerun
+               
+       if [[ $1 == "rerun" ]];then
+               touch /tmp/tcrerun
+       fi
+ }
+ function uninstallpkg(){
+ ### uninstall tpks and rpms and remove other resources ###
+         if [ -d /home/owner/content/tct/opt/$NAME ];then
+                 rm -rf /home/owner/content/tct/opt/$NAME
+                 su -c "pkgcmd -u -n $PKG_NAME" owner
+         else
+                 echo "Remove source file fail, please check if the source file exist: /home/owner/content/tct/opt/$NAME ..."
+         fi
+                
+                if [ -d /home/owner/content/res ];then
+                
+                       applist=`ls /home/owner/content/res | grep 'rpm\|tpk' | awk -F'-[0-9]' '{print $1}'`
+                       for app in $applist
+                               do
+                               su -c "pkgcmd -u -n $app" owner
+                               sync
+                       done
+                       rm -rf /home/owner/content/res
+               fi
+ }
+ case "$1" in
+     -h|--help) echo "$USAGE"
+                exit ;;
+     ""|-i) installpkg $2;;
+     -u) uninstallpkg;;
+     *) echo "Unknown option: $1"
+        echo "$USAGE"
+        exit ;;
+ esac
diff --git a/scripts_tpk/install.log b/scripts_tpk/install.log
new file mode 100755 (executable)
index 0000000..664870d
--- /dev/null
@@ -0,0 +1,2 @@
+**********************************************
+Following packages get installed successfully:
diff --git a/scripts_tpk/mobile.sed b/scripts_tpk/mobile.sed
new file mode 100755 (executable)
index 0000000..b0ae4df
--- /dev/null
@@ -0,0 +1,10 @@
+/define CONFIG_VALUE_LEN_MAX           1024/{i\
+#define CONFIG_VALUE_LEN_MAX           1024\
+#define CONFIGFILE_PATH "/tmp/TC_Config.txt"\
+#define TCT_CONFIG "/tmp/TCT_CONFIG"\
+#define ERR_LOG        "/tmp/tclog"\
+#define ERR_UTC_LOG    "/tmp/utclog"\
+#define DEBUG 0\
+#define MOBILE 1
+d
+}
diff --git a/scripts_tpk/retriever.py b/scripts_tpk/retriever.py
new file mode 100755 (executable)
index 0000000..480bc3e
--- /dev/null
@@ -0,0 +1,176 @@
+#!/usr/bin/python
+
+import os
+import argparse
+import re
+import sys
+from sys import argv
+
+def printUsage():
+       print('Usage note: retriever.py [option] [directory] [build_type]')
+       print('Options:')
+       print('  -n      retrieve TC names with corresponding startup and cleanup functions')
+       print('  -f      retrieveve TC name with corresponding "set" and "purpose" clauses')
+       print('  -anum   retrieve automatic TC number')
+       print('  -mnum   retrieve manual TC number')
+       print('')
+       print('In case of TC in form of "int tc_name()" script will abort.')
+       print('("int tc_name(void)" is a proper function signature)')
+
+       return
+
+def get_tc_files(dir):
+       FILES=[]
+       if ( TYPE == 'ctc' ):
+               prefix='CTs'
+       elif (TYPE == 'itc' ):
+               prefix='ITs'
+       elif (TYPE == 'utc' ):
+               prefix='utc'
+
+       for root, dirs, files in os.walk(dir):
+               for f in files:
+                       if ( re.search('^'+prefix+'.*\.(c|cpp)$', f) ):
+                               FILES.append(os.path.join(root, f))
+
+       return FILES
+
+def tc_names(TC_FILES):
+       TC_LIST=[]
+       for f in TC_FILES:
+               fil=open(f)
+               errFlag=False
+               lineCount=0
+               start_fn=''
+               clean_fn=''
+               for line in fil:
+                       lineCount+=1
+                       start_m=re.search('^void (?P<fn>.*startup)\(void\)', line)
+                       clean_m=re.search('^void (?P<fn>.*cleanup)\(void\)', line)
+                       tc_m=re.search('^int (?P<fn>.*)\(void\)', line)
+                       err_m=re.search('^int (?P<fn>.*)\(\)', line)
+                       if ( start_m != None ):
+                               start_fn=start_m.group('fn')
+                       elif ( clean_m != None ):
+                               clean_fn=clean_m.group('fn')
+                       elif ( tc_m != None ):
+                               TC_LIST.append(tc_m.group('fn')+','+start_fn+','+clean_fn)
+                       elif ( err_m != None ):
+                               print('Warning: function with empty argument list -- " '+err_m.group('fn')+' " in " '+f+' ":" '+lineCount)
+                               errFlag=True
+
+               fil.close()
+               if ( errFlag ):
+                       sys.exit()
+
+       for tc in TC_LIST:
+               print(tc)
+
+       return
+
+def tc_anum(TC_FILES):
+       TC_COUNT=0
+       for f in TC_FILES:
+               fil=open(f)
+               errFlag=False
+               lineCount=0
+               for line in fil:
+                       lineCount+=1
+                       err_m=re.search('^int (?P<fn>.*)\(\)', line)
+                       if (  err_m != None ):
+                               print('Warning: function with empty argument list -- " '+err_m.group('fn')+' " in " '+f+' ":" '+lineCount)
+                               errFlag=True
+                       elif ( re.search('^int (?P<fn>.*)\(void\)', line) != None ):
+                               TC_COUNT+=1
+
+               fil.close()
+               if ( errFlag ):
+                       sys.exit()
+
+       print(TC_COUNT)
+
+       return
+
+def tc_mnum(TC_FILES):
+       # TODO
+       print(0)
+       return
+
+def tc_fullinfo(TC_FILES):
+       TC_LIST=[]
+       for f in TC_FILES:
+               fil=open(f)
+               lineCount=0
+               errFlag=False
+               set='default'
+               purpose=''
+               for line in fil:
+                       lineCount+=1
+                       set_m=re.search('^//&\s+set:?\s+(?P<set>.*)\s*$', line)
+                       pur_m=re.search('^//&\s+purpose:?\s*(?P<purpose>.*)\s*$', line)
+                       tc_m=re.search('^int (?P<fn>.*)\(void\)', line)
+                       err_m=re.search('^int (?P<fn>.*)\(\)', line)
+                       if ( set_m != None ):
+                               set=set_m.group('set')
+                       elif ( pur_m != None ):
+                               purpose=pur_m.group('purpose')
+                       elif ( tc_m != None ):
+                               TC_LIST.append(tc_m.group('fn')+','+set+','+purpose)
+                               #set='default'
+                               #purpose=''
+                       elif (  err_m != None ):
+                               print('Warning: function with empty argument list -- " '+err_m.group('fn')+' " in " '+f+' ":" '+lineCount)
+                               errFlag=True
+               fil.close()
+               if ( errFlag ):
+                       sys.exit()
+
+       for tc in TC_LIST:
+               print(tc)
+
+       return
+
+# global variables
+
+DIR=None
+TYPE=None
+TC_FILES=[]
+
+### script starts here ###
+
+lenArgs=len(argv)
+
+if ( lenArgs == 1 ):
+       sys.exit()
+
+if ( (argv[1][0] == '-' and ( (re.search('^-(anum|mnum|f|n)$', argv[1]) == None) or (lenArgs > 4) )) or ( (argv[1][0] != '-') and (lenArgs > 1) ) ):
+       printUsage()
+       sys.exit()
+
+if ( lenArgs > 3 ):
+       TYPE=argv[3]
+
+if ( re.search('^-(anum|mnum|f)$', argv[1]) == None ):
+       DIR='.'
+       if ( argv[1] == '-n' ):
+               if ( lenArgs > 4 ):
+                       DIR=argv[4]
+       else:
+               DIR=argv[1]
+else:
+       if ( lenArgs > 2 ):
+               DIR=argv[2]
+
+TC_FILES=get_tc_files(DIR)
+
+command=argv[1]
+if ( command == '-anum' ):
+       tc_anum(TC_FILES)
+elif ( command == '-mnum' ):
+       tc_mnum(TC_FILES)
+elif ( command == '-f' ):
+       tc_fullinfo(TC_FILES)
+elif ( command == '-n' ):
+       tc_names(TC_FILES)
+else:
+       tc_names(TC_FILES)
diff --git a/scripts_tpk/spec.sh b/scripts_tpk/spec.sh
new file mode 100755 (executable)
index 0000000..4db77d8
--- /dev/null
@@ -0,0 +1,518 @@
+#!/bin/bash
+#
+# Copyright (c) 2016 Samsung Electronics Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+case "$1" in
+       "org.tizen.accounts-svc-native-itc") 
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp icontexto_256.png ../../data/icontexto_256.png
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data 
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.application-native-itc") 
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../res
+                       chsmack -a "User::App::Shared" ../../res
+                       chsmack -e "User::App::Shared" ../../res
+                       cp -r res/* ../../res/
+                       #chown -R 5000:5000 ../../res
+                       chown -R owner:users ../../res
+                       chmod -R 777 ../../res 
+                       #chsmack -a "User::App::Shared" ../../res/*
+                       #chsmack -e "User::App::Shared" ../../res/*
+                       find ../../res -exec chsmack -a org.tizen.application-native-itc {} \;
+                       find ../../res -exec chsmack -e org.tizen.application-native-itc {} \;
+                       ( echo 3 ; sleep 1 ; echo cert ; sleep 1 ; echo 0 ; ) | pkginfo --setcert org.tizen.application-native-itc
+                       ;;
+       "org.tizen.bluetooth-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp TestFile.vcf ../../data/TestFile.vcf
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.capi-message-port-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp org.tizen.capi-message-port-native-itc.sh ../../data/org.tizen.capi-message-port-native-itc.sh
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.contacts-service2-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp icon.png ../../data/icon.png
+                       cp TestRingtone.mp3 ../../data/TestRingtone.mp3
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.capi-media-tool-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp RapGod.mp3 ../../data/RapGod.mp3
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.email-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp Image_01.jpg ../../data/Image_01.jpg
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.key-manager-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp certificate.crt ../../data/certificate.crt
+                       cp signer.p12 ../../data/signer.p12
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.image-util-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp Image_01.jpg ../../data/Image_01.jpg
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.metadata-editor-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp metadata_editor_video.MP4 ../../data/metadata_editor_video.MP4
+                       cp metadata_editor_video2.MP4 ../../data/metadata_editor_video2.MP4
+                       cp metadata_editor_audio.MP3 ../../data/metadata_editor_audio.MP3
+                       cp metadata_editor_picture.JPG ../../data/metadata_editor_picture.JPG
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.metadata-extractor-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp metadata_audio.mp3 ../../data/metadata_audio.mp3
+                       cp metadata_video.mp4 ../../data/metadata_video.mp4
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.messages-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp Image.jpg ../../data/Image.jpg
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.media-content-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp TestImage.jpg ../../data/TestImage.jpg
+                       cp TestImage.jpg ../../data/Remove.jpg
+                       cp TestAudio.mp3 ../../data/TestAudio.mp3
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       mkdir -p ../../data/Images
+                       chsmack -a "User::App::Shared" ../../data/Images
+                       chsmack -e "User::App::Shared" ../../data/Images
+                       cp TestImage.jpg ../../data/Images/TestImage.jpg
+                       cp TestImage.jpg ../../data/Images/BookMarkImage.jpg
+                       cp TestImage.jpg ../../data/Images/ThumbNailImage.jpg
+                       cp TestImage.jpg ../../data/Images/BurstImage1.jpg
+                       cp TestImage.jpg ../../data/Images/BurstImage2.jpg
+                       cp TestImage.jpg ../../data/Images/BurstImage3.jpg
+                       cp TestImage.jpg ../../data/Images/BurstImage4.jpg
+                       chsmack -a "User::App::Shared" ../../data/Images/*
+                       chsmack -e "User::App::Shared" ../../data/Images/*
+                       
+                       mkdir -p ../../data/TestFolder
+                       chsmack -a "User::App::Shared" ../../data/TestFolder
+                       chsmack -e "User::App::Shared" ../../data/TestFolder
+                       cp TestImage.jpg ../../data/TestFolder/TestImage.jpg
+                       chsmack -a "User::App::Shared" ../../data/TestFolder/*
+                       chsmack -e "User::App::Shared" ../../data/TestFolder/*
+                       
+                       mkdir -p ../../data/Videos
+                       chsmack -a "User::App::Shared" ../../data/Videos
+                       chsmack -e "User::App::Shared" ../../data/Videos
+                       cp TestVideo.mp4 ../../data/Videos/TestVideo.mp4
+                       chsmack -a "User::App::Shared" ../../data/Videos/*
+                       chsmack -e "User::App::Shared" ../../data/Videos/*
+                       
+                       mkdir -p ../../data/Music
+                       chsmack -a "User::App::Shared" ../../data/Music
+                       chsmack -e "User::App::Shared" ../../data/Music
+                       cp TestAudio.mp3 ../../data/Music/TestAudio.mp3
+                       chsmack -a "User::App::Shared" ../../data/Music/*
+                       chsmack -e "User::App::Shared" ../../data/Music/*
+                       
+                       mkdir -p /home/owner/content/TestFolder
+                       chsmack -a "User::App::Shared" /home/owner/content/TestFolder
+                       chsmack -e "User::App::Shared" /home/owner/content/TestFolder
+                       cp TestImage.jpg /home/owner/content/TestFolder/TestImage.jpg
+                       cp TestImage.jpg /home/owner/content/TestImage.jpg
+                       cp TestImage.jpg /home/owner/content/Remove.jpg
+                       cp -R ../../data/Images/* /home/owner/content/Images/
+                       cp -R ../../data/Videos/* /home/owner/content/Videos/
+                       cp -R ../../data/Music/* /home/owner/content/Music/
+                       chmod -R 777 /home/owner/content/Music
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       ;;
+       "org.tizen.player-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp short.mp3 ../../data/short.mp3
+                       cp file.mp4 ../../data/file.mp4
+                       cp sub.srt ../../data/sub.srt
+                       cp v.mp4 ../../data/v.mp4
+                       cp Simpsons.h264 ../../data/Simpsons.h264
+                       cp AWB_header_change_AMR.amr ../../data/AWB_header_change_AMR.amr
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.shortcut-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       cp icon.png /home/owner/content/icon.png
+                       chown -R 5000:5000 /home/owner/content/icon.png
+                       chmod -R 777 /home/owner/content/icon.png
+                       chsmack -a "User::App::Shared" /home/owner/content/icon.png
+                       chsmack -e "User::App::Shared" /home/owner/content/icon.png
+                       ;;
+       "org.tizen.service-adaptor-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       cp icon.png /home/owner/share/Original.png
+                       chown -R 5000:5000 /home/owner/share/Original.png
+                       chmod -R 777 /home/owner/share/Original.png
+                       chsmack -a "User::App::Shared" /home/owner/share/Original.png
+                       chsmack -e "User::App::Shared" /home/owner/share/Original.png
+                       sqlite3 /opt/usr/dbspace/.media.db "UPDATE storage SET validity=1 WHERE storage_uuid='sample-plugin-for-tc';"
+                       ;;
+       "org.tizen.stt-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp start_sound.wav ../../data/start_sound.wav
+                       cp stop_sound.wav ../../data/stop_sound.wav
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.thumbnail-util-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp Sample_01.jpg ../../data/Sample_01.jpg
+                       cp Sample_02.jpg ../../data/Sample_02.jpg
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.video-util-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp video1.mp4 ../../data/video1.mp4
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.wav-player-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp WavPlayerTest.wav ../../data/WavPlayerTest.wav
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.webkit2-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       mkdir -p ../../data/webkit2_files/resources
+                       mkdir -p ../../data/webkit2_files/resources/common
+                       mkdir -p ../../data/webkit2_files/resources/ewk_context_menu
+                       mkdir -p ../../data/webkit2_files/resources/ewk_view
+                       cp resources/common/*.html ../../data/webkit2_files/resources/common/
+                       cp resources/ewk_context_menu/*.png ../../data/webkit2_files/resources/ewk_context_menu/
+                       cp resources/ewk_context_menu/*.html ../../data/webkit2_files/resources/ewk_context_menu/
+                       cp resources/ewk_view/*.html ../../data/webkit2_files/resources/ewk_view/
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.wifi-native-itc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp cert.crt ../../data/cert.crt
+                       cp testing.pem ../../data/testing.pem
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.image-util-native-ctc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp ImageUtil_sample.jpg ../../data/ImageUtil_sample.jpg
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.player-native-ctc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp MediaPlayer.mp3 ../../data/MediaPlayer.mp3
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.platform-permission-native-ctc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp native-platform-permission-ctc-0.1-0.armv7l.rpm ../../data/native-platform-permission-ctc-0.1-0.armv7l.rpm
+                       cp native-platform-permission-ctc-0.1-0.aarch64.rpm ../../data/native-platform-permission-ctc-0.1-0.aarch64.rpm
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       cp -R PlatformPermission_test.jpg /home/owner/content/Images/PlatformPermission_test.jpg
+                       chmod -R 777 /home/owner/content/Images
+                       ;;
+       "org.tizen.video-util-native-ctc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp video_color.mp4 ../../data/video_color.mp4
+                       chown -R 5000:5000 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.capi-media-vision-native-utc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p /home/owner/content/model
+                       chsmack -a "User::App::Shared" /home/owner/content/model
+                       chsmack -e "User::App::Shared" /home/owner/content/model
+                       cp rec/test_rec_model /home/owner/content/model/test_rec_model
+                       cp track/test_trk_model /home/owner/content/model/test_trk_model
+                       chmod -R 777 /home/owner/content/model
+                       chown -R 5000:5000 /home/owner/content/model
+                       chsmack -a "User::App::Shared" /home/owner/content/model/*
+                       chsmack -e "User::App::Shared" /home/owner/content/model/*
+                       
+                       mkdir -p /home/owner/content/res/img
+                       chsmack -a "User::App::Shared" /home/owner/content/res
+                       chsmack -e "User::App::Shared" /home/owner/content/res
+                       chsmack -a "User::App::Shared" /home/owner/content/res/img
+                       chsmack -e "User::App::Shared" /home/owner/content/res/img
+                       cp res/media-vision-barcodes.json /home/owner/content/res/media-vision-barcodes.json
+                       cp res/img/*.jpg /home/owner/content/res/img/
+                       cp res/img/*.raw /home/owner/content/res/img/
+                       chmod -R 777 /home/owner/content/res
+                       chown -R 5000:5000 /home/owner/content/res
+                       chsmack -a "User::App::Shared" /home/owner/content/res/*
+                       chsmack -e "User::App::Shared" /home/owner/content/res/*
+                       chsmack -a "User::App::Shared" /home/owner/content/res/img/*
+                       chsmack -e "User::App::Shared" /home/owner/content/res/img/*
+                       
+                       mkdir -p /home/owner/content/res/rec/P1
+                       mkdir -p /home/owner/content/res/rec/P2
+                       chsmack -a "User::App::Shared" /home/owner/content/res/rec
+                       chsmack -e "User::App::Shared" /home/owner/content/res/rec
+                       chsmack -a "User::App::Shared" /home/owner/content/res/rec/P1
+                       chsmack -e "User::App::Shared" /home/owner/content/res/rec/P1
+                       chsmack -a "User::App::Shared" /home/owner/content/res/rec/P2
+                       chsmack -e "User::App::Shared" /home/owner/content/res/rec/P2
+                       cp rec/P1/*.jpg /home/owner/content/res/rec/P1/
+                       cp rec/P2/*.jpg /home/owner/content/res/rec/P2/
+                       chsmack -a "User::App::Shared" /home/owner/content/res/rec/*
+                       chsmack -e "User::App::Shared" /home/owner/content/res/rec/*
+                       chsmack -a "User::App::Shared" /home/owner/content/res/rec/P1/*
+                       chsmack -e "User::App::Shared" /home/owner/content/res/rec/P1/*
+                       chsmack -a "User::App::Shared" /home/owner/content/res/rec/P2/*
+                       chsmack -e "User::App::Shared" /home/owner/content/res/rec/P2/*
+                       
+                       mkdir -p /home/owner/content/res/eye
+                       chsmack -a "User::App::Shared" /home/owner/content/res/eye
+                       chsmack -e "User::App::Shared" /home/owner/content/res/eye
+                       cp res/eye/*.jpg /home/owner/content/res/eye/
+                       chsmack -a "User::App::Shared" /home/owner/content/res/eye/*
+                       chsmack -e "User::App::Shared" /home/owner/content/res/eye/*
+                       
+                       mkdir -p /home/owner/content/res/expr
+                       chsmack -a "User::App::Shared" /home/owner/content/res/expr
+                       chsmack -e "User::App::Shared" /home/owner/content/res/expr
+                       cp res/expr/*.jpg  /home/owner/content/res/expr/
+                       chsmack -a "User::App::Shared" /home/owner/content/res/expr/*
+                       chsmack -e "User::App::Shared" /home/owner/content/res/expr/*
+                       
+                       mkdir -p /home/owner/content/res/track/sequence
+                       chsmack -a "User::App::Shared" /home/owner/content/res/track/sequence
+                       chsmack -e "User::App::Shared" /home/owner/content/res/track/sequence
+                       cp res/track/sequence/*.jpg /home/owner/content/res/track/sequence/
+                       chsmack -a "User::App::Shared" /home/owner/content/res/track/sequence/*
+                       chsmack -e "User::App::Shared" /home/owner/content/res/track/sequence/*
+                       
+                       mkdir -p /home/owner/content/res/facedetect
+                       chsmack -a "User::App::Shared" /home/owner/content/res/facedetect
+                       chsmack -e "User::App::Shared" /home/owner/content/res/facedetect
+                       cp res/facedetect/*.jpg %{buildroot}/home/owner/content/res/facedetect/
+                       chsmack -a "User::App::Shared" /home/owner/content/res/facedetect/*
+                       chsmack -e "User::App::Shared" /home/owner/content/res/facedetect/*
+                       
+                       mkdir -p /home/owner/content/res/image
+                       chsmack -a "User::App::Shared" /home/owner/content/res/image
+                       chsmack -e "User::App::Shared" /home/owner/content/res/image
+                       cp res/image/*.jpg %{buildroot}/home/owner/content/res/image/
+                       chsmack -a "User::App::Shared" /home/owner/content/res/image/*
+                       chsmack -e "User::App::Shared" /home/owner/content/res/image/*
+                       
+                       mkdir -p /home/owner/content/res/image/tracking
+                       chsmack -a "User::App::Shared" /home/owner/content/res/image/tracking
+                       chsmack -e "User::App::Shared" /home/owner/content/res/image/tracking
+                       cp res/image/tracking/*.jpg /home/owner/content/res/image/tracking/
+                       chsmack -a "User::App::Shared" /home/owner/content/res/image/tracking/*
+                       chsmack -e "User::App::Shared" /home/owner/content/res/image/tracking/*
+                       
+                       mkdir -p /home/owner/content/res/surv
+                       chsmack -a "User::App::Shared" /home/owner/content/res/surv
+                       chsmack -e "User::App::Shared" /home/owner/content/res/surv
+                       cp res/surv/* /home/owner/content/res/surv/
+                       chsmack -a "User::App::Shared" /home/owner/content/res/surv/*
+                       chsmack -e "User::App::Shared" /home/owner/content/res/surv/*
+                       ;;
+       "org.tizen.capi-message-port-native-utc")
+                       echo "Installing pre-requisites for the package $1"
+                       install -m 755 core-capi-message-port-tests.sh /home/owner/apps_rw/org.tizen.capi-message-port-native-utc/bin
+                       ;;
+       "org.tizen.metadata-editor-native-utc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp res/* ../../data/
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.stt-native-utc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       cp res/ringtone.wav ../../data/ringtone.wav
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+       "org.tizen.webkit2-native-utc")
+                       echo "Installing pre-requisites for the package $1"
+                       mkdir -p ../../data
+                       mkdir -p ../../data/res
+                       mkdir -p ../../data/res/common
+                       mkdir -p ../../data/res/ewk_context_menu
+                       mkdir -p ../../data/res/ewk_view
+                       chsmack -a "User::App::Shared" ../../data
+                       chsmack -e "User::App::Shared" ../../data
+                       chsmack -a "User::App::Shared" ../../data/res
+                       chsmack -e "User::App::Shared" ../../data/res
+                       chsmack -a "User::App::Shared" ../../data/res/common
+                       chsmack -e "User::App::Shared" ../../data/res/common
+                       chsmack -a "User::App::Shared" ../../data/res/ewk_context_menu
+                       chsmack -e "User::App::Shared" ../../data/res/ewk_context_menu
+                       chsmack -a "User::App::Shared" ../../data/res/ewk_view
+                       chsmack -e "User::App::Shared" ../../data/res/ewk_view
+                       cp res/common/*.html ../../data/res/common/
+                       cp res/ewk_context_menu/*.png ../../data/res/ewk_context_menu/
+                       cp res/ewk_context_menu/*.html ../../data/res/ewk_context_menu/
+                       cp res/ewk_view/*.html ../../data/res/ewk_view/
+                       chown -R 5000:5000 ../../data
+                       chmod -R 777 ../../data
+                       chsmack -a "User::App::Shared" ../../data/*
+                       chsmack -e "User::App::Shared" ../../data/*
+                       ;;
+esac
\ No newline at end of file
diff --git a/scripts_tpk/tcheadgen.py b/scripts_tpk/tcheadgen.py
new file mode 100755 (executable)
index 0000000..3f5e8aa
--- /dev/null
@@ -0,0 +1,133 @@
+#!/usr/bin/python
+
+import os
+import sys
+import platform
+import re
+import commands
+import shutil
+from shutil import copy
+from commands import getstatusoutput
+from os import path
+from sys import argv
+from sys import exit
+
+def gen():
+       startup_counter = 0;
+       startup_list=[];
+
+       cleanup_counter = 0;
+       cleanup_list=[];
+
+       testcase_counter = 0;
+       testcase_list=[];
+
+       tc_array_counter = 0;
+       tc_array_list=[];
+
+       tf=open(TFILE)
+       f=open(FILE, 'w')
+       
+       f.write('//\n// Copyright (c) 2014 Samsung Electronics Co., Ltd.\n//\n// Licensed under the Apache License, Version 2.0 (the License);\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an "AS IS" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\n')
+       f.write('#ifndef __'+HEADER_NAME+'__\n')
+       f.write('#define __'+HEADER_NAME+'__\n')
+       f.write('\n')
+       f.write('#include "testcase.h"\n')
+       f.write('#include "tct_common.h"\n')
+       f.write('\n')
+
+       for line in tf:
+               fields=line.strip('\n').split(',')
+               testcase_list.append(fields[0])
+               testcase_counter+=1
+               
+               if ( (startup_counter == 0) or (startup_list[startup_counter-1] != fields[1]) ):
+                       startup_list.append(fields[1])
+                       startup_counter+=1
+               
+               if ( (cleanup_counter == 0) or (cleanup_list[cleanup_counter-1] != fields[2]) ):
+                       cleanup_list.append(fields[2])
+                       cleanup_counter+=1
+
+               if ( fields[1] and fields[2] ):
+                       tc_array_list.append('"'+fields[0]+'", '+fields[0]+', '+fields[1]+', '+fields[2])
+               else:
+                       tc_array_list.append('"'+fields[0]+'", '+fields[0]+', '+'NULL'+', '+'NULL')
+
+               tc_array_counter+=1
+
+       if ( startup_counter > cleanup_counter ):
+               sc_count=startup_counter
+       else:
+               sc_count=cleanup_counter
+
+       for i in range(sc_count):
+               if ( (i < startup_counter) and (startup_list[i] != '') ):
+                       f.write('extern void '+startup_list[i]+'(void);\n')
+               if ( (i < cleanup_counter) and (cleanup_list[i] != '') ):
+                       f.write('extern void '+cleanup_list[i]+'(void);\n')
+
+       f.write('\n')
+
+       for i in range(testcase_counter):
+               f.write('extern int '+testcase_list[i]+'(void);\n')
+
+       f.write('\n')
+       f.write('testcase tc_array[] = {\n')
+
+       for i in range(tc_array_counter):
+               f.write('    {'+tc_array_list[i]+'},\n')
+
+       f.write('    {NULL, NULL}\n')
+       f.write('};\n')
+       f.write('\n')
+       f.write('#endif // __'+HEADER_NAME+'__\n')
+
+       tf.close()
+       f.close()
+
+       return
+
+### script starts here ###
+
+if ( len(argv) < 4 ):
+       print('Usage note: tcheadgen.py <header_filename.h> <src_dir> <build_type>')
+       exit()
+
+# global variables
+
+if ( platform.system() == 'Windows' ):
+       dirSeparator='\\'
+else:
+       dirSeparator='/'
+
+FILE=os.getcwd()+dirSeparator+argv[1]
+TFILE=dirSeparator+'tmp'+dirSeparator+'retr.csv'
+HEADER_NAME=argv[1].upper().replace('-', '_').replace('.', '_')
+SCRIPT_DIR=path.abspath(path.dirname(argv[0]))
+
+status=getstatusoutput(SCRIPT_DIR+dirSeparator+'retriever.py -n '+argv[2]+' '+argv[3]+' > '+TFILE+'_pre')
+if ( (status[0] % 256) != 0 ):
+       tfile_pre=open(TFILE+'_pre')
+       for line in tfile_pre:
+               print(line.strip('\n'))
+       tfile_pre.close()
+       exit('Error executing retriever.py!!! Aborting...')
+
+# TODO sort tcs based on set field (module name)
+status=os.system('cat '+TFILE+'_pre | sort -t\',\' -k2,2 -s > '+TFILE+'_remove')
+#copy(TFILE+'_pre', TFILE+'_remove')
+
+# remove duplicate lines
+tfr=open(TFILE+'_remove')
+tf=open(TFILE, 'w')
+x={}
+for l in tfr:
+       tc=l.split(',')[0]
+       if ( (tc in x.keys()) == False ):
+               x[tc]=1
+               tf.write(l)
+tfr.close()
+tf.close()
+
+gen()
diff --git a/scripts_tpk/tcpackageslistsgen.py b/scripts_tpk/tcpackageslistsgen.py
new file mode 100755 (executable)
index 0000000..f55d039
--- /dev/null
@@ -0,0 +1,121 @@
+#!/usr/bin/python
+
+import os
+import sys
+import platform
+import re
+import commands
+import shutil
+from shutil import copy
+from commands import getstatusoutput
+from os import path
+from sys import argv
+from sys import exit
+
+def regen():
+       found=0
+       replaced=0
+
+       f=open(FILE)
+       tf=open(TFILE, 'w')
+
+       for line in f:
+               match=re.search('\s<suite name="tct-'+MODULE_NAME+'-native-'+TYPE+'"\scategory="\s'+CATEGORY+'\s"', line)
+               if ( match != None ):
+                       found=1
+                       continue
+               match=re.search('</suite>', line)
+               if ( match != None ):
+                       if ( (found == 1) and (RMMOD == 0) ):
+                               tf.write('  <suite name="tct-'+MODULE_NAME+'-native-'+TYPE+'" category=" '+CATEGORY+' ">\n')
+                               tf.write('    <auto_tcn>'+AUTO_NUM+'</auto_tcn>\n')
+                               tf.write('    <manual_tcn>'+MAN_NUM+'</manual_tcn>\n')
+                               tf.write('    <total_tcn>'+TOT_NUM+'</total_tcn>\n')
+                               tf.write('    <pkg_name>'+PROFILE+'/tct-'+MODULE_NAME+'-native-'+TYPE+'-3.0.zip</pkg_name>\n')
+                               tf.write('  </suite>\n')
+
+                               found = 0;
+                               replaced = 1;
+                       elif ( (found == 1) and (RMMOD == 1) ):
+                               found=0
+                               replaced=1
+                       else:
+                               tf.write(line)
+
+                       continue
+               match=re.search('</ns3:testplan>', line)
+               if ( match != None ):
+                       if ( (replaced == 0) and (RMMOD == 0) ):
+                               tf.write('  <suite name="tct-'+MODULE_NAME+'-native-'+TYPE+'" category=" '+CATEGORY+' ">\n')
+                               tf.write('    <auto_tcn>'+AUTO_NUM+'</auto_tcn>\n')
+                               tf.write('    <manual_tcn>'+MAN_NUM+'</manual_tcn>\n')
+                               tf.write('    <total_tcn>'+TOT_NUM+'</total_tcn>\n')
+                               tf.write('    <pkg_name>'+PROFILE+'/tct-'+MODULE_NAME+'-native-'+TYPE+'-3.0.zip</pkg_name>\n')
+                               tf.write('  </suite>\n')
+                               tf.write(line+'\n')
+                       else:
+                               tf.write(line)
+
+                       continue
+               if ( found == 0 ):
+                       tf.write(line)
+
+       f.close()
+       tf.close()
+
+       copy(TFILE, FILE)
+
+       return
+
+### script starts here ###
+
+if ( len(argv) < 4 ):
+       print('Usage note: tcpackageslistsgen.py <type> <module_name> <profile> <output_file.xml>')
+       exit()
+
+# global variables
+
+if ( platform.system() == 'Windows' ):
+       dirSeparator='\\'
+else:
+       dirSeparator='/'
+
+TYPE=argv[1]
+MODULE_NAME=argv[2]
+PROFILE=argv[3]
+FILE=argv[4]
+RMMOD=int(argv[5])
+if ( path.exists(FILE) == False ):
+       exit('No such file: '+FILE)
+
+MODULE_NAME_MOD=MODULE_NAME+'-native-'+TYPE
+WORKSPACE_SRC_DIR=os.getenv('HOME')+dirSeparator+'workspace'+dirSeparator+MODULE_NAME_MOD+dirSeparator+'src'
+
+CATEGORY='IntegrationTestCases'
+if ( TYPE == 'utc' ):
+       CATEGORY='UnitTestCases'
+if ( TYPE == 'ctc' ):
+       CATEGORY='CompatibilityTestCases'
+
+SCRIPT_DIR=path.abspath(path.dirname(argv[0]))
+cwd=os.getcwd()
+os.chdir(SCRIPT_DIR)
+os.chdir('..')
+status=commands.getstatusoutput('scripts_tpk'+dirSeparator+'retriever.py -anum '+WORKSPACE_SRC_DIR+' '+TYPE)
+if ( (status[0] % 256) != 0 ):
+       exit(status[1])
+else:
+       AUTO_NUM=status[1]
+
+status=commands.getstatusoutput('scripts_tpk'+dirSeparator+'retriever.py -mnum '+WORKSPACE_SRC_DIR+' '+TYPE)
+if ( (status[0] % 256) != 0 ):
+       exit(status[1])
+else:
+       MAN_NUM=status[1]
+TOT_NUM=str(int(AUTO_NUM)+int(MAN_NUM))
+
+TFILE=dirSeparator+'tmp'+dirSeparator+'tempfile.xml'
+if ( path.exists(TFILE) ):
+       os.remove(TFILE)
+
+regen()
diff --git a/scripts_tpk/tctestsgen.py b/scripts_tpk/tctestsgen.py
new file mode 100755 (executable)
index 0000000..e05e275
--- /dev/null
@@ -0,0 +1,95 @@
+#!/usr/bin/python
+
+import os
+import platform
+import sys
+import commands
+import re
+from shutil import copy
+from os import path
+from os import getenv
+from sys import argv
+from sys import exit
+from string import capwords
+
+def gen(tcfile):
+       set=''
+       tfile=open(TFILE)
+       fil=open(FILE, 'w')
+
+       # begin
+       fil.write('<?xml version="1.0" encoding="UTF-8"?>\n')
+       fil.write('    <?xml-stylesheet type="text/xsl" href="./testcase.xsl"?>\n')
+       fil.write('<test_definition>\n')
+       fil.write('  <suite name="tct-'+MODULE_NAME+'-native-'+BUILD_TYPE+'" category="Native APIs">\n')
+
+       for line in tfile:
+               line=line.strip('\n')
+               fields=line.split(',')
+               if ( set != '' and set != fields[1] ):
+                       fil.write('    </set>\n')
+               if ( set != fields[1] ):
+                       set=fields[1]
+                       fil.write('    <set name="'+set+'">\n')
+               tcname=fields[0]
+               tcpurpose=''
+               
+               fil.write('      <testcase component="NativeAPI/'+MODULE_NAME_C+'/'+set+'" execution_type="auto" id="'+tcname+'" purpose="'+tcpurpose+'">\n')
+               fil.write('        <description>\n')
+               fil.write('          <test_script_entry test_script_expected_result="0">/home/owner/content/tct/opt/tct-'+MODULE_NAME+'-native-'+BUILD_TYPE+'/external_wrapper.sh '+MODULE_FULL_NAME+' '+tcname+' '+BUILD_TYPE+'</test_script_entry>\n')
+               fil.write('        </description>\n')
+               fil.write('      </testcase>\n')
+       
+       # end
+       if ( set != '' ):
+               fil.write('    </set>\n')
+       fil.write('  </suite>\n')
+       fil.write('</test_definition>\n')
+
+       tfile.close()
+       fil.close()
+       return
+
+### script starts here ###
+
+if ( len(argv) < 4 ):
+       print('Usage note: tctestsgen.py <build_type> <module_name> <path_to_xml>')
+       exit()
+
+# global variables
+
+if ( platform.system() == 'Windows' ):
+       dirSeparator='\\'
+else:
+       dirSeparator='/'
+
+MODULE_NAME=argv[2]
+BUILD_TYPE=argv[1]
+MODULE_NAME_MOD=MODULE_NAME+'-native-'+BUILD_TYPE
+MODULE_FULL_NAME='org.tizen.'+MODULE_NAME_MOD
+MODULE_NAME_C=capwords(MODULE_NAME, '-').translate(None, '-')
+SCRIPT_DIR=path.abspath(path.dirname(argv[0]))
+WORKSPACE_SRC_DIR=getenv('HOME')+dirSeparator+'workspace'+dirSeparator+MODULE_NAME_MOD+dirSeparator+'src'
+
+FILE=argv[3]+dirSeparator+'tests.xml'
+if ( path.exists(FILE) ):
+       os.remove(FILE)
+
+TFILE=dirSeparator+'tmp'+dirSeparator+'tcs.csv'
+if ( path.exists(TFILE) ):
+       os.remove(TFILE)
+
+os.chdir(SCRIPT_DIR+dirSeparator+'..')
+# test this a bit
+status=commands.getstatusoutput('scripts_tpk'+dirSeparator+'retriever.py -f '+WORKSPACE_SRC_DIR+' '+BUILD_TYPE+' > '+TFILE+'_pre')
+if ( (status[0] % 256) != 0 ):
+       tfil_pre=open(TFILE+'_pre')
+       for line in tfile_pre:
+               print(line.strip('\n'))
+       tfile_pre.close()
+       exit('Error executing retriever.py!!! Aborting...')
+# TODO sort tcs based on set field (module)
+status=os.system('cat '+TFILE+'_pre | sort -t\',\' -k2,2 -s > '+TFILE)
+#copy(TFILE+'_pre', TFILE)
+
+gen(TFILE)
diff --git a/scripts_tpk/tpk-install.py b/scripts_tpk/tpk-install.py
new file mode 100755 (executable)
index 0000000..77198ae
--- /dev/null
@@ -0,0 +1,247 @@
+#!/usr/bin/python
+
+import platform
+import os
+import stat
+import sys
+import time
+import commands
+import subprocess
+import re
+import argparse
+import shutil
+import zipfile
+
+def copytpk(btype, module):
+       if ( os.path.exists(TPK_DIR) == False ):
+               os.makedirs(TPK_DIR)
+
+       os.chdir(WORKSPACE_DIR)
+       PKG_NAME='org\.tizen\.'+module
+       PKG_NAME=PKG_NAME+'-native-'+btype
+       VER='1\.0\.0'
+       PKG_VNAME=PKG_NAME+'-'+VER
+       PKG_VNAME=PKG_VNAME+'-arm'
+       FIND_FILE=PKG_VNAME+'\.tpk'
+       for root, dirs, files in os.walk(os.getcwd()):
+               for f in files:
+                       if ( re.search(FIND_FILE, f) != None ):
+                               shutil.copy(os.path.join(root, f), TPK_DIR+dirSeparator)
+                               print('COPYING: '+PKG_NAME.replace('\\', '')+' tpk file is copied to '+TPK_DIR)
+       return
+
+def removeDir(path):
+       for root, dirs, files in os.walk(path, topdown=False):
+               if ( len(dirs) == 0 ):
+                       for f in files:
+                               try:
+                                       os.remove(os.path.join(root, f))
+                               except(OSError):
+                                       return False
+
+               elif ( len(files) == 0 ):
+                       for d in dirs:
+                               try:
+                                       os.removedirs(os.path.join(root, d))
+                               except(OSError):
+                                       return False
+       try:
+               os.rmdir(path)
+       except(OSError):
+               # if exception is raised here it means dir is not empty and this shouldnot happen
+               return False
+
+       return True
+
+def install(TYPE, MODNAME, PROFILE):
+       rpmCheck=False
+       global INSTALL_PKG_COUNT
+       if ( TYPE == None ):
+               install('ctc', None, PROFILE)
+               install('itc', None, PROFILE)
+               install('utc', None, PROFILE)
+       else:
+               if ( MODNAME == None ):
+                       #os.chdir(WORKSPACE_DIR)
+                       for root, dirs, files in os.walk(WORKSPACE_DIR):
+                               for f in files:
+                                       r=re.search('^org\.tizen\.(?P<module_name>.*)-native-'+TYPE+'-1\.0\.0-arm\.tpk', f)
+                                       if ( r ):
+                                               install(TYPE, r.group('module_name'), PROFILE)
+
+               else:
+                       print('')
+                       print('********************START Installing '+TYPE+':'+MODNAME+'**********************')
+                       copytpk(TYPE, MODNAME)
+                       os.chdir(PROJECT_DIR)
+                       # setting variables
+                       PKG_NAME='org.tizen.'+MODNAME+'-native-'+TYPE
+                       VER='1.0.0'
+                       PKG_VNAME=PKG_NAME+'-'+VER+'-arm'
+                       PKG_FNAME=PKG_VNAME+'.tpk'
+                       if ( os.path.exists(TPK_DIR+dirSeparator+PKG_FNAME) == False):
+                               sys.exit('Package Not Found '+PKG_VNAME)
+                       TIZEN____='tizen_native_3.0'
+                       TCT_DIR='opt'+dirSeparator+'tct-'+MODNAME+'-native-'+TYPE
+                       TO_PKG_DIR=dirSeparator+'opt'+dirSeparator+'tct'+dirSeparator+TIZEN____+dirSeparator+'packages'
+                       
+                       print('Deploying '+TYPE+'->'+MODNAME+' suite to tct-mgr...')
+                       # prepare tct directory and files
+                       print('-- Preparing suite .zip file...')
+                       print('---- Creating '+dirSeparator+'tmp'+dirSeparator+TCT_DIR+' directory')
+                       removeDir(dirSeparator+'tmp'+dirSeparator+'opt')
+                       os.makedirs(dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+
+                       # README
+                       print('---- Copying '+dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+                       shutil.copy('scripts_tpk'+dirSeparator+'README', dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+                       
+                       # tpk
+                       print('---- Copying '+dirSeparator+'tmp'+dirSeparator+TCT_DIR+' package')
+                       try:
+                               shutil.copy(TPK_DIR+dirSeparator+PKG_FNAME, dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+                       except(shutil.Error):
+                               sys.exit('Aborting...')
+
+                       # inst.sh
+                       print('---- Generating '+dirSeparator+'tmp'+dirSeparator+TCT_DIR+dirSeparator+'inst.sh file')
+                       # TODO port for windows
+                       #status=os.system('sed -e "s:%{PKG_NAME}:"'+PKG_NAME+'":g" \
+                       #       -e "s:%{PKG_FULLNAME}:"'+PKG_FNAME+'":g" \
+                       #       -e "s:%{PKG_DIR}:"/opt/usr/media/tct/'+TCT_DIR+'":g" \
+                       #       scripts_tpk/inst.sh > /tmp/'+TCT_DIR+'/inst.sh')
+                       src_f=open('scripts_tpk'+dirSeparator+'inst.sh')
+                       dest_f=open(dirSeparator+'tmp'+dirSeparator+TCT_DIR+dirSeparator+'inst.sh', 'w')
+                       for line in src_f:
+                               pkg_dir_m=re.search('^\sPKG_DIR=(?P<pkg_dir>%{PKG_DIR})', line)
+                               pkg_name_m=re.search('^\sPKG_NAME=(?P<pkg_name>%{PKG_NAME})', line)
+                               pkg_fname_m=re.search('^\sPKG_FULLNAME=(?P<pkg_fname>%{PKG_FULLNAME})', line)
+                               if ( pkg_dir_m != None ):
+                                       PKG_DIR=dirSeparator+'home'+dirSeparator+'owner'+dirSeparator+'content'+dirSeparator+'tct'+dirSeparator+TCT_DIR
+                                       line=line.replace('%{PKG_DIR}', '"'+PKG_DIR+'"')
+                               elif ( pkg_name_m != None ):
+                                       line=line.replace('%{PKG_NAME}', '"'+PKG_NAME+'"')
+                               elif ( pkg_fname_m != None ):
+                                       line=line.replace('%{PKG_FULLNAME}', '"'+PKG_FNAME+'"')
+
+                               dest_f.write(line)
+                       src_f.close()
+                       dest_f.close()
+
+                       #if ( (status % 256) != 0 ):
+                       #       sys.exit('Error executing inst.sh!!! Aborting...')
+                       os.chmod(dirSeparator+'tmp'+dirSeparator+TCT_DIR+dirSeparator+'inst.sh', stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH|stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|stat.S_IWUSR)
+                       
+                       # tests.xml
+                       print('---- Generating '+dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+                       status=commands.getstatusoutput('scripts_tpk'+dirSeparator+'tctestsgen.py '+TYPE+' '+MODNAME+' '+dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+                       if ( len(status[1]) > 0 ):
+                               print(status[1])
+                       if ( ( status[0] % 256 ) != 0 ):
+                               print('Failed to execute tctestsgen.py!!!')
+                               sys.exit('Aborting...')
+                       
+                       # external_wrapper.sh
+                       shutil.copy('scripts_tpk'+dirSeparator+'external_wrapper.sh', dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+
+                       # LICENSE, add_all_smack_rule.sh, all_smack.rule
+                       shutil.copy('scripts_tpk'+dirSeparator+'LICENSE', dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+
+                       # zip
+                       print('---- Preparing '+dirSeparator+'tmp'+dirSeparator+'tct'+dirSeparator+'packages'+dirSeparator+'tct-'+MODNAME+'-'+'native-'+TYPE+'-3.0.zip file')
+
+                       # clear old zips
+                       removeDir(dirSeparator+'tmp'+dirSeparator+'tct'+dirSeparator+'packages')
+                       os.makedirs(dirSeparator+'tmp'+dirSeparator+'tct'+dirSeparator+'packages')
+
+                       # create new zip
+                       #os.chdir(dirSeparator+'tmp')
+                       zipper(dirSeparator+'tmp'+dirSeparator+'opt', dirSeparator+'tmp'+dirSeparator+'tct'+dirSeparator+'packages'+dirSeparator+'tct-'+MODNAME+'-native-'+TYPE+'-3.0.zip', True, dirSeparator)
+
+                       # deployment
+                       print('-- Suite deployment...')
+                       print('---- Copying '+TO_PKG_DIR+dirSeparator+PROFILE+dirSeparator+'tct-'+MODNAME+'-native-'+TYPE+'-3.0.zip')
+                       if ( os.path.exists(TO_PKG_DIR+dirSeparator+PROFILE) == False):
+                               os.makedirs(TO_PKG_DIR+dirSeparator+PROFILE)
+                       shutil.copy(dirSeparator+'tmp'+dirSeparator+'tct'+dirSeparator+'packages'+dirSeparator+'tct-'+MODNAME+'-native-'+TYPE+'-3.0.zip', TO_PKG_DIR+dirSeparator+PROFILE)
+                       print('---- Updating '+TO_PKG_DIR+dirSeparator+'pkg_infos'+dirSeparator+PROFILE+'_pkg_info.xml')
+                       status=commands.getstatusoutput('scripts_tpk'+dirSeparator+'tcpackageslistsgen.py '+TYPE+' '+MODNAME+' '+PROFILE+' '+TO_PKG_DIR+dirSeparator+'pkg_infos'+dirSeparator+PROFILE+'_pkg_info.xml 0')
+                       if ( len(status[1]) > 0 ):
+                               print(status[1])
+                       if ( removeDir(TPK_DIR) == False ):
+                               sys.exit('Error removing '+TPK_DIR+'. Aborting...')
+                       print('**************Task finished successfully*********************')
+                       print('')
+                       os.chdir(PROJECT_DIR)
+                       logFile=open('install.log', 'a')
+                       logFile.write(TYPE+':->'+MODNAME+'\n')
+                       logFile.close()
+                       INSTALL_PKG_COUNT+=1
+
+       return
+
+def zipper(zip_dir, zip_file, include_root, sep):
+       zf = zipfile.ZipFile(zip_file, 'w', compression=zipfile.ZIP_DEFLATED)
+       root_len = len(os.path.abspath(zip_dir))
+       if ( include_root ):
+               zip_root=os.path.abspath(zip_dir).strip(sep).split(sep)[-1]
+               root_len-=len(zip_root)
+       for root, dirs, files in os.walk(zip_dir):
+               archive_root = os.path.abspath(root)[root_len:]
+               for f in files:
+                       fullpath = os.path.join(root, f)
+                       archive_name = os.path.join(archive_root, f)
+                       zf.write(fullpath, archive_name, zipfile.ZIP_DEFLATED)
+       zf.close()
+       return zip_file
+
+# global variables
+dirSeparator='/'
+
+module=None
+build_ctype=None
+profile=None
+
+INSTALL_PKG_COUNT=0
+
+### script starts here ###
+
+OS=platform.system()
+if ( OS == 'Windows' ):
+       dirSeparator='\\'
+
+PROJECT_DIR=(os.path.abspath(os.path.dirname(sys.argv[0])))
+TPK_DIR=os.getenv('HOME')+dirSeparator+'tpks'
+WORKSPACE_DIR=os.getenv('HOME')+dirSeparator+'workspace'
+
+# TODO use argparse
+if ( len(sys.argv) >= 2 ):
+       profile=sys.argv[1]
+if ( len(sys.argv) >= 3 ):
+       build_ctype=sys.argv[2]
+if ( len(sys.argv) >= 4 ):
+       module=sys.argv[3]
+
+if ( os.path.exists('install.log') ):
+       os.remove('install.log')
+
+instLog=open('install.log', 'w')
+instLog.write('**********************************************\n')
+instLog.write('Following packages get installed successfully:\n')
+instLog.close()
+
+install(build_ctype, module, profile)
+
+if ( module == None ):
+       instLog=open('install.log', 'a')
+       instLog.write('**********************************************\n')
+       instLog.write('Total Intall PASS Count = ' + str(INSTALL_PKG_COUNT) + '\n')
+       instLog.close()
+       instLog=open('install.log')
+       for line in instLog:
+               print(line.strip('\n'))
+       instLog.close()
+
+os.remove('install.log')
+       
+       
diff --git a/scripts_tpk/tpk_create.sh b/scripts_tpk/tpk_create.sh
new file mode 100755 (executable)
index 0000000..c0ff64c
--- /dev/null
@@ -0,0 +1,172 @@
+#!/bin/bash
+#
+# Copyright (c) 2014 Samsung Electronics Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Initializing log text properties
+red=`tput setaf 1`
+green=`tput setaf 2`
+reset=`tput sgr0`
+bold=`tput bold`
+
+RunCommand () {
+        echo $green''$2' Started'$reset
+        if eval $1; then
+                echo $green''$2' SUCCESSFUL'$reset
+        else
+                echo $red'[ERROR]'$2' FAILED'
+                echo ""
+                echo " ============================================"
+                echo "||                "$bold"BUILD FAILED$reset$red              ||"
+                echo " ============================================"
+                echo ""$reset
+                exit 1
+fi
+}
+
+deploySourceFile() {
+       rm -rf $1/src/*.c
+       rm -rf $1/inc/*.h
+       
+       echo $green"Copying Source files "
+       
+       #copying source and header files 
+       cp $2/*.c $1/src/.
+       cp $2/*/*.c $1/src/.
+       
+       cp $2/*.h $1/inc/.
+       cp $2/*/*.h $1/inc/.
+
+       #copying common source and header files 
+       cp $2/../../common/*.c $1/src/.
+       cp $2/../../common/*.h $1/inc/.
+       
+       # copying data and shared data 
+       find $2/. -type f ! -iname "*.c" ! -iname "*.h" ! -iname "*.tpk"  ! -iname "CMakeLists.txt" -exec cp  {} $1/shared/res \;
+       
+       if [ -d $2/res/$3 ];then
+               find $2/res/$3/. -type f -iname "*.tpk"  -exec cp  {} $1/shared/res \;
+       fi
+       
+       cp scripts_tpk/spec.sh $1/shared/res/.
+
+       sed -i -f scripts_tpk/$3.sed $1/inc/tct_common.h
+       
+       # include tct_common.h in utc source files
+       if [ "$5" == "utc" ]; then
+               for srcFile in `ls $1/src/ | grep -v core | grep -v common`
+               do
+                       sed -i '1i\#include <tct_common.h>' $1/src/$srcFile
+               done
+       fi
+       
+       cd $1 
+       find ./src -iname *.c -print0 | tr '\0' ' ' > test.files
+       sed -i 's/\.\///g' test.files
+       
+       replace="src/$4.c"      
+       output=`cat test.files`
+       sed -i "/USER_SRCS/d" project_def.prop
+       echo "USER_SRCS =$output" >> project_def.prop
+
+       rm -rf test.files
+
+       # updating privileges in xml file
+       sed -i '/<\/manifest>/d' tizen-manifest.xml
+       
+       if [ "$5" == "utc" ]; then
+               grep -ir "privilege" $2/../../../packaging/$5/core-$6-tests.xml >> tizen-manifest.xml
+       else
+               grep -ir "privilege" $2/../../../packaging/$5/native-$6-$5.xml >> tizen-manifest.xml
+       fi
+       
+       echo "</manifest>" >> tizen-manifest.xml
+       sed -i 's/example/tizen/g' tizen-manifest.xml
+
+       echo $green"Source files copied and xml modified successfully"
+       
+       cd $2/../../../scripts_tpk
+}
+
+TESTCASE_TYPE="$1"
+MODULE_NAME="$2"
+ARCH_TYPE="$3"
+APPLLICATION_PROFILE="basic-ui"
+PROFILE_TYPE="$4"
+WORKSPACE_PATH="$HOME/workspace"
+
+# build command properties 
+COMPILER_TYPE="llvm"
+BUILD_TYPE="Debug"
+UNSUPPORTED_FILE="tct_unsupported.txt"
+
+#######skipping build for unsupported modules#######
+if [ "$ARCH_TYPE" == "arm" ]; then
+       ARCH="armv7l"
+elif [ "$ARCH_TYPE" == "x86" ]; then
+       ARCH="i586"
+fi
+
+SUPPORTED=`cat ./$UNSUPPORTED_FILE | grep "$PROFILE_TYPE:$ARCH:$TESTCASE_TYPE:$MODULE_NAME;"`
+if [[ $SUPPORTED != "" ]]
+then
+       echo ""
+       echo "****************SKIPPED BUILDING $TESTCASE_TYPE:native-$MODULE_NAME***************************"
+       echo "'$TESTCASE_TYPE:$MODULE_NAME' is Unsupported for (profile type='$PROFILE_TYPE',architecture='$ARCH_TYPE')"
+       echo "'SKIPPING' THIS MODULE FROM BUILD PROCESS"
+       echo "***********************************************************************************"
+       echo ""
+       sleep 1
+       exit
+fi
+
+if [ "$1" == "itc" ]; then
+       PROJECT_NAME="$MODULE_NAME-native-itc"
+elif [ "$1" == "ctc" ]; then
+       PROJECT_NAME="$MODULE_NAME-native-ctc"
+elif [ "$1" == "utc" ]; then
+       PROJECT_NAME="$MODULE_NAME-native-utc"
+fi
+
+PWD=$(pwd)
+SRC_DIRCTORY=$PWD/src
+# packaging properties details
+
+echo "TESTCASE TYPE : $TESTCASE_TYPE"
+echo "PROFILE TYPE : $PROFILE_TYPE"
+echo "MODULE NAME : $MODULE_NAME"
+echo "WORKSPACE PATH : $WORKSPACE_PATH"
+
+if [ -d $WORKSPACE_PATH/$PROJECT_NAME ];then
+       rm -rf $WORKSPACE_PATH/$PROJECT_NAME
+fi
+
+if [ ! -d $SRC_DIRCTORY/$TESTCASE_TYPE/$MODULE_NAME ];then
+       echo $red"[ERROR] BUILD FAILED : Module doesn't exist "
+       echo ""$reset
+       exit
+fi
+
+RunCommand "tizen create native-project -p $PROFILE_TYPE-3.0 -t $APPLLICATION_PROFILE -n $PROJECT_NAME -- $WORKSPACE_PATH" "Project creation $PROJECT_NAME"
+deploySourceFile "$WORKSPACE_PATH/$PROJECT_NAME" "$SRC_DIRCTORY/$TESTCASE_TYPE/$MODULE_NAME" "$PROFILE_TYPE" "$PROJECT_NAME" "$TESTCASE_TYPE" "$MODULE_NAME"
+RunCommand "tizen build-native -a $ARCH_TYPE -c $COMPILER_TYPE -C $BUILD_TYPE -- $WORKSPACE_PATH/$PROJECT_NAME" "Building tpk $PROJECT_NAME"
+RunCommand "tizen package --type tpk --sign test -- $WORKSPACE_PATH/$PROJECT_NAME/$BUILD_TYPE" "packaging of $PROJECT_NAME"
+
+echo $green""
+echo " ============================================"
+echo "||              "$bold"CREATION  SUCCESSFUL$reset$green        ||"
+echo " ============================================"
+echo ""$reset
+
diff --git a/scripts_tpk/tpkbuild.sh b/scripts_tpk/tpkbuild.sh
new file mode 100755 (executable)
index 0000000..e1d6646
--- /dev/null
@@ -0,0 +1,161 @@
+#!/bin/bash
+#
+# Copyright (c) 2014 Samsung Electronics Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+PWD=`pwd`
+PROFILE_TYPE=""
+ARCH_TYPE=""
+TESTCASE_TYPE=""
+MODULE_NAME=""
+
+function helpusage {
+# usage note
+    echo "Usage: `basename $0` <build|install> <build_type> <module_name> <arch_type> <device_type>"
+    echo "<build_type> = itc|ctc|utc"
+    echo "<arch_type> = arm|x86"
+    echo "<device_type> = mobile|wearable"
+    echo "commands description:"
+    echo "       build                 performs SDK build"
+    echo "       install               install packages for execution"
+    echo "To build|install all the packages (itc,ctc and utc), usage: `basename $0` build|install <arch_type> <device_type>"
+    echo "To build|install all packages of a <build_type>, usage: `basename $0` build|install <build_type> <arch_type> <device_type>"
+    echo ""
+    exit 1
+}
+
+if   [ "$2" = "mobile" ] || [ "$3" = "mobile" ] || [ "$4" = "mobile" ] || [ "$5" = "mobile" ]; then
+       PROFILE_TYPE="mobile"
+elif [ "$2" = "wearable" ] || [ "$3" = "wearable"  ] || [ "$4" = "wearable"  ] || [ "$5" = "wearable"  ]; then
+       PROFILE_TYPE="wearable"
+else
+       echo "Add argument 'profile type (mobile or wearable)'"
+       helpusage
+fi
+
+if   [ "$2" = "arm" ] || [ "$3" = "arm" ] || [ "$4" = "arm" ] || [ "$5" = "arm" ]; then
+       ARCH_TYPE="arm"
+elif [ "$2" = "x86" ] || [ "$3" = "x86"  ] || [ "$4" = "x86"  ] || [ "$5" = "x86"  ]; then
+       ARCH_TYPE="x86"
+else
+       echo "Add argument 'architecture (arm or x86)'"
+       helpusage
+fi
+
+function check_tc_type {
+
+       if [ "$#" -eq  "3" ]; then
+               if   [ "$1" = "itc" ] || [ "$2" = "itc" ] || [ "$3" = "itc" ]; then
+                       TESTCASE_TYPE="itc"
+               elif   [ "$1" = "utc" ] || [ "$2" = "utc" ] || [ "$3" = "utc" ]; then
+                       TESTCASE_TYPE="utc"
+               elif   [ "$1" = "ctc" ] || [ "$2" = "ctc" ] || [ "$3" = "ctc" ]; then
+                       TESTCASE_TYPE="ctc"
+               else
+                       echo "Add argument 'test case type (itc or ctc or utc)'"
+                       helpusage
+               fi
+
+       elif [ "$#" -eq  "4" ]; then
+               if [ "$1" = "itc" ] || [ "$2" = "itc" ] || [ "$3" = "itc" ] || [ "$4" = "itc" ]; then
+                       TESTCASE_TYPE="itc"
+               elif [ "$1" = "utc" ] || [ "$2" = "utc" ] || [ "$3" = "utc" ] || [ "$4" = "utc" ]; then
+                       TESTCASE_TYPE="utc"
+               elif [ "$1" = "ctc" ] || [ "$2" = "ctc" ] || [ "$3" = "ctc" ] || [ "$4" = "ctc" ]; then
+                       TESTCASE_TYPE="ctc"
+               else
+                       echo "Add argument 'test case type (itc or ctc or utc)'"
+                       helpusage
+               fi
+       fi
+}
+
+function build {
+
+       if [ "$#" -eq  "2" ]; then
+               scripts_tpk/tpk_create.sh $1 $2 $ARCH_TYPE $PROFILE_TYPE
+
+       elif [ "$#" -eq  "1" ]; then
+               for module in `ls -1 src/$1/ | grep -v CMakeList`
+               do
+                       build $1 $module
+               done
+
+       else
+               for test_type in `ls -1 src/ | grep -v CMakeList | grep -v common`
+               do
+                       build $test_type
+               done
+       fi
+}
+
+function install {
+
+       TC_TYPE=$1
+       MOD_NAME=$2
+
+       if [ "$ARCH_TYPE" == "arm" ]; then
+               ln -sf ./scripts_tpk/tpk-install.py $PWD/tpk-install
+               python tpk-install $PROFILE_TYPE $TC_TYPE $MOD_NAME
+       elif [ "$ARCH_TYPE" == "x86" ]; then
+               ln -sf ./scripts_tpk/tpksdk-install.py $PWD/tpksdk-install
+               python tpksdk-install $PROFILE_TYPE $TC_TYPE $MOD_NAME
+       fi
+}
+
+if [ -z "$1" ]; then
+       helpusage
+
+elif [ "build" == "$1" ]; then
+       
+       if [ "$#" -eq  "3" ]; then
+               build
+       
+       elif  [ "$#" -eq  "4" ]; then
+               check_tc_type $2 $3 $4
+               build $TESTCASE_TYPE
+       
+       elif  [ "$#" -eq  "5" ]; then
+               check_tc_type $2 $3 $4 $5
+               MODULE_NAME=$3
+               build $TESTCASE_TYPE $MODULE_NAME
+       
+       else
+               echo "Entered wrong number of arguments"
+               helpusage
+       fi
+
+elif [ "install" == "$1" ]; then
+       
+       if [ "$#" -eq  "3" ]; then
+               install
+       
+       elif  [ "$#" -eq  "4" ]; then
+               check_tc_type $2 $3 $4
+               install $TESTCASE_TYPE
+       
+       elif  [ "$#" -eq  "5" ]; then
+               check_tc_type $2 $3 $4 $5
+               MODULE_NAME=$3
+               install $TESTCASE_TYPE $MODULE_NAME
+       
+       else
+               echo "Entered wrong number of arguments"
+               helpusage
+       fi
+else
+       echo "Entered invalid arguments"
+       helpusage
+fi
diff --git a/scripts_tpk/tpksdk-install.py b/scripts_tpk/tpksdk-install.py
new file mode 100755 (executable)
index 0000000..1779e0d
--- /dev/null
@@ -0,0 +1,243 @@
+#!/usr/bin/python
+
+import platform
+import os
+import stat
+import sys
+import time
+import commands
+import subprocess
+import re
+import argparse
+import shutil
+import zipfile
+
+def copytpk(btype, module):
+       if ( os.path.exists(TPK_DIR) == False ):
+               os.makedirs(TPK_DIR)
+
+       os.chdir(WORKSPACE_DIR)
+       # backslashes because strings will be used as regex patterns
+       PKG_NAME='org\.tizen\.'+module+'-native-'+btype
+       VER='1\.0\.0'
+       PKG_VNAME=PKG_NAME+'-'+VER+'-'+ARCH
+       FIND_FILE=PKG_VNAME+'\.tpk'
+       print('copytpk: '+FIND_FILE)
+       for root, dirs, files in os.walk(os.getcwd()):
+               for f in files:
+                       if ( re.search(FIND_FILE, f) != None ):
+                               shutil.copy(os.path.join(root, f), TPK_DIR+dirSeparator)
+                               print('COPYING: '+PKG_NAME.replace('\\', '')+' tpk file is copied to '+TPK_DIR)
+       return
+
+def removeDir(path):
+       for root, dirs, files in os.walk(path, topdown=False):
+               if ( len(dirs) == 0 ):
+                       for f in files:
+                               try:
+                                       os.remove(os.path.join(root, f))
+                               except(OSError):
+                                       return False
+
+               elif ( len(files) == 0 ):
+                       for d in dirs:
+                               try:
+                                       os.removedirs(os.path.join(root, d))
+                               except(OSError):
+                                       return False
+       try:
+               os.rmdir(path)
+       except(OSError):
+               # if exception is raised here it means dir is not empty and this shouldnot happen
+               return False
+
+       return True
+
+def install(TYPE, MODNAME, PROFILE):
+       global INSTALL_PKG_COUNT
+       if ( TYPE == None ):
+               install('ctc', None, PROFILE)
+               install('itc', None, PROFILE)
+               install('utc', None, PROFILE)
+       else:
+               if ( MODNAME == None ):
+                       #os.chdir(WORKSPACE_DIR)
+                       for root, dirs, files in os.walk(WORKSPACE_DIR):
+                               for f in files:
+                                       r=re.search('^org\.tizen\.(?P<module_name>.*)-native-'+TYPE+'-1\.0\.0-'+ARCH+'\.tpk', f)
+                                       if ( r ):
+                                               install(TYPE, r.group('module_name'), PROFILE)
+
+               else:
+                       print('')
+                       print('********************START Installing '+TYPE+':'+MODNAME+'**********************')
+                       copytpk(TYPE, MODNAME)
+                       os.chdir(PROJECT_DIR)
+                       # setting variables
+                       PKG_NAME='org.tizen.'+MODNAME+'-native-'+TYPE
+                       VER='1.0.0'
+                       PKG_VNAME=PKG_NAME+'-'+VER+'-'+ARCH
+                       PKG_FNAME=PKG_VNAME+'.tpk'
+                       if ( os.path.exists(TPK_DIR+dirSeparator+PKG_FNAME) == False):
+                               sys.exit('Package Not Found '+PKG_VNAME)
+                       TIZEN____='tizen_native_3.0'
+                       TCT_DIR='opt'+dirSeparator+'tct-'+MODNAME+'-native-'+TYPE
+                       TO_PKG_DIR=dirSeparator+'opt'+dirSeparator+'tct'+dirSeparator+TIZEN____+dirSeparator+'packages'
+                       
+                       print('Deploying '+TYPE+'->'+MODNAME+' suite to tct-mgr...')
+                       # prepare tct directory and files
+                       print('-- Preparing suite .zip file...')
+                       print('---- Creating '+dirSeparator+'tmp'+dirSeparator+TCT_DIR+' directory')
+                       removeDir(dirSeparator+'tmp'+dirSeparator+'opt')
+                       os.makedirs(dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+
+                       # README
+                       print('---- Copying '+dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+                       shutil.copy('scripts_tpk'+dirSeparator+'README', dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+                       
+                       # tpk
+                       print('---- Copying '+dirSeparator+'tmp'+dirSeparator+TCT_DIR+' package')
+                       try:
+                               shutil.copy(TPK_DIR+dirSeparator+PKG_FNAME, dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+                       except(shutil.Error):
+                               sys.exit('Aborting...')
+
+                       # inst.sh
+                       print('---- Generating '+dirSeparator+'tmp'+dirSeparator+TCT_DIR+dirSeparator+'inst.sh file')
+                       src_f=open('scripts_tpk'+dirSeparator+'inst.sh')
+                       dest_f=open(dirSeparator+'tmp'+dirSeparator+TCT_DIR+dirSeparator+'inst.sh', 'w')
+                       for line in src_f:
+                               pkg_dir_m=re.search('^\sPKG_DIR=(?P<pkg_dir>%{PKG_DIR})', line)
+                               pkg_name_m=re.search('^\sPKG_NAME=(?P<pkg_name>%{PKG_NAME})', line)
+                               pkg_fname_m=re.search('^\sPKG_FULLNAME=(?P<pkg_fname>%{PKG_FULLNAME})', line)
+                               if ( pkg_dir_m != None ):
+                                       PKG_DIR=dirSeparator+'home'+dirSeparator+'owner'+dirSeparator+'content'+dirSeparator+'tct'+dirSeparator+TCT_DIR
+                                       line=line.replace('%{PKG_DIR}', '"'+PKG_DIR+'"')
+                               elif ( pkg_name_m != None ):
+                                       line=line.replace('%{PKG_NAME}', '"'+PKG_NAME+'"')
+                               elif ( pkg_fname_m != None ):
+                                       line=line.replace('%{PKG_FULLNAME}', '"'+PKG_FNAME+'"')
+
+                               dest_f.write(line)
+                       src_f.close()
+                       dest_f.close()
+
+                       #if ( (status % 256) != 0 ):
+                       #       sys.exit('Error executing inst.sh!!! Aborting...')
+                       os.chmod(dirSeparator+'tmp'+dirSeparator+TCT_DIR+dirSeparator+'inst.sh', stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH|stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|stat.S_IWUSR)
+                       
+                       # tests.xml
+                       print('---- Generating '+dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+                       status=commands.getstatusoutput('scripts_tpk'+dirSeparator+'tctestsgen.py '+TYPE+' '+MODNAME+' '+dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+                       if ( len(status[1]) > 0 ):
+                               print(status[1])
+                       if ( ( status[0] % 256 ) != 0 ):
+                               print('Failed to execute tctestsgen.py!!!')
+                               sys.exit('Aborting...')
+                       
+                       # external_wrapper.sh
+                       shutil.copy('scripts_tpk'+dirSeparator+'external_wrapper.sh', dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+
+                       # LICENSE, add_all_smack_rule.sh, all_smack.rule
+                       shutil.copy('scripts_tpk'+dirSeparator+'LICENSE', dirSeparator+'tmp'+dirSeparator+TCT_DIR)
+
+                       # zip
+                       print('---- Preparing '+dirSeparator+'tmp'+dirSeparator+'tct'+dirSeparator+'packages'+dirSeparator+'tct-'+MODNAME+'-'+'native-'+TYPE+'-3.0.zip file')
+
+                       # clear old zips
+                       removeDir(dirSeparator+'tmp'+dirSeparator+'tct'+dirSeparator+'packages')
+                       os.makedirs(dirSeparator+'tmp'+dirSeparator+'tct'+dirSeparator+'packages')
+
+                       # create new zip
+                       #os.chdir(dirSeparator+'tmp')
+                       zipper(dirSeparator+'tmp'+dirSeparator+'opt', dirSeparator+'tmp'+dirSeparator+'tct'+dirSeparator+'packages'+dirSeparator+'tct-'+MODNAME+'-native-'+TYPE+'-3.0.zip', True, dirSeparator)
+
+                       # deployment
+                       print('-- Suite deployment...')
+                       print('---- Copying '+TO_PKG_DIR+dirSeparator+PROFILE+dirSeparator+'tct-'+MODNAME+'-native-'+TYPE+'-3.0.zip')
+                       if ( os.path.exists(TO_PKG_DIR+dirSeparator+PROFILE) == False):
+                               os.makedirs(TO_PKG_DIR+dirSeparator+PROFILE)
+                       shutil.copy(dirSeparator+'tmp'+dirSeparator+'tct'+dirSeparator+'packages'+dirSeparator+'tct-'+MODNAME+'-native-'+TYPE+'-3.0.zip', TO_PKG_DIR+dirSeparator+PROFILE)
+                       print('---- Updating '+TO_PKG_DIR+dirSeparator+'pkg_infos'+dirSeparator+PROFILE+'_pkg_info.xml')
+                       status=commands.getstatusoutput('scripts_tpk'+dirSeparator+'tcpackageslistsgen.py '+TYPE+' '+MODNAME+' '+PROFILE+' '+TO_PKG_DIR+dirSeparator+'pkg_infos'+dirSeparator+PROFILE+'_pkg_info.xml 0')
+                       if ( len(status[1]) > 0 ):
+                               print(status[1])
+                       if ( removeDir(TPK_DIR) == False ):
+                               sys.exit('Error removing '+TPK_DIR+'. Aborting...')
+                       print('**************Task finished successfully*********************')
+                       print('')
+                       os.chdir(PROJECT_DIR)
+                       logFile=open('install.log', 'a')
+                       logFile.write(TYPE+':->'+MODNAME+'\n')
+                       logFile.close()
+                       INSTALL_PKG_COUNT+=1
+
+       return
+
+def zipper(zip_dir, zip_file, include_root, sep):
+       zf = zipfile.ZipFile(zip_file, 'w', compression=zipfile.ZIP_DEFLATED)
+       root_len = len(os.path.abspath(zip_dir))
+       if ( include_root ):
+               zip_root=os.path.abspath(zip_dir).strip(sep).split(sep)[-1]
+               root_len-=len(zip_root)
+       for root, dirs, files in os.walk(zip_dir):
+               archive_root = os.path.abspath(root)[root_len:]
+               for f in files:
+                       fullpath = os.path.join(root, f)
+                       archive_name = os.path.join(archive_root, f)
+                       zf.write(fullpath, archive_name, zipfile.ZIP_DEFLATED)
+       zf.close()
+       return zip_file
+
+# global variables
+dirSeparator='/'
+
+module=None
+build_ctype=None
+profile=None
+
+INSTALL_PKG_COUNT=0
+
+### script starts here ###
+
+OS=platform.system()
+if ( OS == 'Windows' ):
+       dirSeparator='\\'
+
+PROJECT_DIR=(os.path.abspath(os.path.dirname(sys.argv[0])))
+TPK_DIR=os.getenv('HOME')+dirSeparator+'tpks'
+WORKSPACE_DIR=os.getenv('HOME')+dirSeparator+'workspace'
+# this value doesnot change throughout
+ARCH='i386'
+
+# TODO use argparse
+if ( len(sys.argv) >= 2 ):
+       profile=sys.argv[1]
+if ( len(sys.argv) >= 3 ):
+       build_ctype=sys.argv[2]
+if ( len(sys.argv) >= 4 ):
+       module=sys.argv[3]
+
+if ( os.path.exists('install.log') ):
+       os.remove('install.log')
+
+instLog=open('install.log', 'w')
+instLog.write('**********************************************\n')
+instLog.write('Following packages get installed successfully:\n')
+instLog.close()
+
+install(build_ctype, module, profile)
+
+if ( module == None ):
+       instLog=open('install.log', 'a')
+       instLog.write('**********************************************\n')
+       instLog.write('Total Intall PASS Count = ' + str(INSTALL_PKG_COUNT) + '\n')
+       instLog.close()
+       instLog=open('install.log')
+       for line in instLog:
+               print(line.strip('\n'))
+       instLog.close()
+
+os.remove('install.log')
+       
+       
diff --git a/scripts_tpk/wearable.sed b/scripts_tpk/wearable.sed
new file mode 100755 (executable)
index 0000000..4d2ee45
--- /dev/null
@@ -0,0 +1,10 @@
+/define CONFIG_VALUE_LEN_MAX           1024/{i\
+#define CONFIG_VALUE_LEN_MAX           1024\
+#define CONFIGFILE_PATH "/tmp/TC_Config.txt"\
+#define TCT_CONFIG "/tmp/TCT_CONFIG"\
+#define ERR_LOG        "/tmp/tclog"\
+#define ERR_UTC_LOG    "/tmp/utclog"\
+#define DEBUG 0\
+#define WEARABLE 1
+d
+}