aboutsummarylogtreecommitdiffstats
path: root/run.sh
blob: 6f675d662cc92ac6cdaa09c1c1214e26f9e5be1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh

#   Copyright (C) 2016 Deepin, Inc.
#
#   Author:     Li LongYu <lilongyu@linuxdeepin.com>
#               Peng Hao <penghao@linuxdeepin.com>

#               Vufa <countstarlight@gmail.com>

version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; }

BOTTLENAME="Deepin-TIM"
APPVER="9.3.2deepin20"
WINEPREFIX="$HOME/.deepinwine/$BOTTLENAME"
TIM_FONTS="$WINEPREFIX/drive_c/windows/Fonts"
TIM_VER="3.4.8.22138"
EXEC_PATH="c:/Program Files/Tencent/TIM/Bin/TIM.exe"
EXEC_FILE="$WINEPREFIX/drive_c/Program Files/Tencent/TIM/Bin/TIM.exe"
START_SHELL_PATH="/opt/deepinwine/tools/run_v4.sh"
TIM_INSTALLER_PATH="c:/Program Files/Tencent/TIM$TIM_VER.exe"
export MIME_TYPE=""
export DEB_PACKAGE_NAME="com.qq.office.deepin"
export APPRUN_CMD="deepin-wine5"
DISABLE_ATTACH_FILE_DIALOG=""

export SPECIFY_SHELL_DIR=`dirname $START_SHELL_PATH`

ARCHIVE_FILE_DIR="/opt/apps/$DEB_PACKAGE_NAME/files"

export WINEDLLPATH=/opt/$APPRUN_CMD/lib:/opt/$APPRUN_CMD/lib64

OpenWinecfg()
{
    env WINEPREFIX=$WINEPREFIX $APPRUN_CMD winecfg
}

DeployApp()
{
    # backup fonts
    if [ -d "$TIM_FONTS" ];then
        mkdir -p $HOME/.deepinwine/.tim_tmp
        cp $TIM_FONTS/* $HOME/.deepinwine/.tim_tmp/
    fi

    # re-deploy bottle
    rm -rf "$WINEPREFIX"
    # run installer
    env LC_ALL=zh_CN.UTF-8 WINEDLLOVERRIDES="winemenubuilder.exe=d" $START_SHELL_PATH $BOTTLENAME $APPVER "$TIM_INSTALLER_PATH" "$@"

    # restore fonts
    if [ -d "$HOME/.deepinwine/.tim_tmp" ];then
        cp -n $HOME/.deepinwine/.tim_tmp/* $TIM_FONTS/
        rm -rf "$HOME/.deepinwine/.tim_tmp"
    fi
    touch $WINEPREFIX/reinstalled
    cat /opt/apps/$DEB_PACKAGE_NAME/files/files.md5sum > $WINEPREFIX/PACKAGE_VERSION
}

Run()
{
    if [ -z "$DISABLE_ATTACH_FILE_DIALOG" ];then
        export ATTACH_FILE_DIALOG=1
    fi

    if [ -n "$EXEC_PATH" ];then
        if [ ! -f "$WINEPREFIX/reinstalled" ];then
            DeployApp
        else
            # missing exec file
            if [ ! -f "$EXEC_FILE" ];then
                DeployApp
            fi

            env LC_ALL=zh_CN.UTF-8 $START_SHELL_PATH $BOTTLENAME $APPVER "$EXEC_PATH" "$@"
        fi
    else
        env LC_ALL=zh_CN.UTF-8 $START_SHELL_PATH $BOTTLENAME $APPVER "uninstaller.exe" "$@"
    fi
}

HelpApp()
{
	echo " Extra Commands:"
	echo " winecfg        Open winecfg"
	echo " -h/--help      Show program help info"
}

if [ -z $1 ]; then
	Run "$@"
	exit 0
fi
case $1 in
	"winecfg")
		OpenWinecfg
		;;
	"-h" | "--help")
		HelpApp
		;;
	*)
		Run "$@"
		;;
esac
exit 0