Upstream version 8.37.187.0
[platform/framework/web/crosswalk.git] / src / xwalk / tools / packaging / bootstrapped / linux / create_linux_installer.sh
1 #!/bin/sh
2 absolute_path () {
3     echo `cd $1 && pwd`
4 }
5 THIS_SCRIPT=$0
6 SCRIPT_DIR=`dirname $THIS_SCRIPT`
7 SCRIPT_DIR=`absolute_path $SCRIPT_DIR`
8 TEMP_DIR=/tmp/xwalk_build
9 while [ "$1" != "" ]; do
10     DASHED_PARAM=$1
11     PARAM=`echo ${DASHED_PARAM}|sed 's/--//'`
12     if [ "$PARAM" = "$DASHED_PARAM" ]; then
13       APP_PATH=$PARAM
14     else
15         if ! echo  $PARAM |grep  = ;  then
16             PARAM=`echo $PARAM |sed 's/^\(.*\)/\U\1/'`
17             eval $PARAM=true
18         else
19             PARAM=`echo $PARAM |sed 's/^\(.*=\)/\U\1/'`
20             eval $PARAM
21         fi
22     fi
23     shift
24 done
25
26 if [ "x$HELP" != "x" ]; then
27     echo
28     echo usage: $THIS_SCRIPT [options] [app_path]
29     echo
30     echo This script is used to create a standalone installer for Crosswalk applications. It
31     echo depends on checkinstall and Crosswalk to function properly.
32     echo The following options are supported:
33     echo "
34      app_path                  Path to the Crosswalk application. If not specified, the
35                                current directory is used.
36      --xwalk_path=<path>       Path to Crosswalk binaries. If not specified, the script
37                                will try to find them through PATH, the app path, or
38                                the current directory.
39      --app_name=<name>         Name of the application. If not specified, the name
40                                of the application directory is used.
41      --version=<version>       The version of the application, defaults to 1.0.0
42      --app_index=<path>        Path of app index file, relative to app_path. If not
43                                specified, index.html is used.
44      --app_arguments=<path>    Arugments to be passed into Crosswalk executable
45                                Example: --app_arguments=--allow-file-access-from-files
46      --out=<path>              Path of the output package file, defaults to
47                                $TEMP_DIR/<app_name>
48      --publisher=<name>        The manufacturer of this application, defaults to "Me"
49      --shadow_install=<yes|no> Enable/disable installing app to a temporary directory
50                                for testing purposed. Defaults to yes
51      --help                    Print this message "
52     exit 1
53 fi
54
55 if [ "x`which checkinstall`" = "x" ]; then
56     echo
57     echo "checkinstall is required to create an application package. You can install it by:
58     sudo apt-get install checkinstall"
59     exit 1
60 fi
61 if [ "x$APP_PATH" = "x" ]; then
62     APP_PATH=`pwd`
63 fi
64 if [ "x$APP_INDEX" = "x" ]; then
65     APP_INDEX=index.html
66 fi
67 if [ "x$VERSION" = "x" ]; then
68     VERSION=1.0.0
69 fi
70 if [ "x$XWALK_PATH" = "x" ]; then
71     XWALK_PATH=`which xwalk`
72     if [ "x$XWALK_PATH" != "x" ]; then
73         XWALK_PATH=`dirname $XWALK_PATH`
74     fi
75     if [ "x$XWALK_PATH" = "x" ]; then
76         XWALK_PATH=$APP_PATH
77         if ! test -f "$XWALK_PATH/xwalk"; then
78             XWALK_PATH=`pwd`
79             if ! test -f "$XWALK_PATH/xwalk"; then
80                 echo Please make sure you have installed xwalk and setup the PATH enviroment variable
81                 echo on your system properly. Or you can specify the Crosswalk path through --xwalk_path
82                 echo command line parameter.
83                 exit 1
84             fi
85         fi
86     fi
87 fi
88 if [ "x$APP_NAME" = "x" ]; then
89     APP_NAME=`basename $APP_PATH`
90 fi
91 if [ "x$PUBLISHER" = "x" ]; then
92     PUBLISHER=Me
93 fi
94
95 if [ "x$OUT" != "x" ]; then
96     OUT_OPT="--pakdir=$OUT"
97 fi
98
99 if [ "x$SHADOW_INSTALL" = "x" ]; then
100     SHADOW_INSTALL=yes
101 fi
102
103 XWALK_PATH=`absolute_path $XWALK_PATH`
104 APP_PATH=`absolute_path $APP_PATH`
105 BUILD_DIR=$TEMP_DIR/`basename $APP_PATH`
106 #export some variables so that Makefile can use them
107 export INSTALL_DIR=/opt/${PUBLISHER}/${APP_NAME}
108
109 #Prepare for the build dir
110 mkdir -p $TEMP_DIR
111 cp -r $APP_PATH $TEMP_DIR
112 if ! test -f $APP_PATH/Makefile; then
113     cp $SCRIPT_DIR/Makefile.templ $BUILD_DIR/Makefile
114 fi
115 if ! ls *.desktop > /dev/null 2>&1; then
116     while read line; do eval echo $line; done < $SCRIPT_DIR/app.desktop.templ > $BUILD_DIR/$APP_NAME.desktop
117 fi
118 cd $XWALK_PATH && cp xwalk xwalk.pak libffmpegsumo.so $BUILD_DIR
119
120 #build the package
121 cd $BUILD_DIR && checkinstall --pkgname=$APP_NAME --pkgversion=$VERSION \
122   --backup=no --install=no --exclude=Makefile --fstrans=$SHADOW_INSTALL $OUT_OPT
123 if [ $? != 0 -a -f  $APP_PATH/Makefile ]; then
124     echo "Warning: Packaging failed. Maybe there are some unsupported operations in your app's Makefile? Please try re-run the script with --shadow_install=no using sudo"
125     echo
126 fi