blob: 11ce9db893a1b166fd4681bdd26f77b246196b29 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
#!/bin/sh
# Copyright (C) 2016 Deepin, Inc.
#
# Author: Li LongYu <lilongyu@linuxdeepin.com>
# Peng Hao <penghao@linuxdeepin.com>
# Codist <countstarlight@gmail.com>
WINEPREFIX="$HOME/.deepinwine/Deepin-TIM"
APPDIR="/opt/deepinwine/apps/Deepin-TIM"
APPVER="3.2.0.21856"
APPTAR="files.7z"
PACKAGENAME="com.qq.tim"
WINE_CMD="wine"
HelpApp()
{
echo " Extra Commands:"
echo " -r/--reset Reset app to fix errors"
echo " -e/--remove Remove deployed app files"
echo " -d/--deepin Switch to 'deepin-wine'"
echo " -h/--help Show program help info"
}
CallApp()
{
if [ ! -f "$WINEPREFIX/reinstalled" ]
then
touch $WINEPREFIX/reinstalled
env WINEPREFIX="$WINEPREFIX" $WINE_CMD $APPDIR/TIM$APPVER.exe
else
#disable Tencent MiniBrowser
#_DeleteRegistry "HKCU\\Software\\Tencent\\MiniBrowser"
#Support use native file dialog
export ATTACH_FILE_DIALOG=1
env WINEPREFIX="$WINEPREFIX" WINEDEBUG=-msvcrt $WINE_CMD "c:\\Program Files\\Tencent\\TIM\\Bin\\TIM.exe" &
fi
}
ExtractApp()
{
mkdir -p "$1"
7z x "$APPDIR/$APPTAR" -o"$1"
mv "$1/drive_c/users/@current_user@" "$1/drive_c/users/$USER"
sed -i "s#@current_user@#$USER#" $1/*.reg
}
DeployApp()
{
ExtractApp "$WINEPREFIX"
echo "$APPVER" > "$WINEPREFIX/PACKAGE_VERSION"
}
RemoveApp()
{
rm -rf "$WINEPREFIX"
}
ResetApp()
{
echo "Reset $PACKAGENAME....."
read -p "* Are you sure?(Y/N)" ANSWER
if [ "$ANSWER" = "Y" -o "$ANSWER" = "y" -o -z "$ANSWER" ]; then
EvacuateApp
DeployApp
CallApp
fi
}
UpdateApp()
{
if [ -f "$WINEPREFIX/PACKAGE_VERSION" ] && [ "$(cat "$WINEPREFIX/PACKAGE_VERSION")" = "$APPVER" ]; then
return
fi
if [ -d "${WINEPREFIX}.tmpdir" ]; then
rm -rf "${WINEPREFIX}.tmpdir"
fi
ExtractApp "${WINEPREFIX}.tmpdir"
/opt/deepinwine/tools/updater -s "${WINEPREFIX}.tmpdir" -c "${WINEPREFIX}" -v
rm -rf "${WINEPREFIX}.tmpdir"
echo "$APPVER" > "$WINEPREFIX/PACKAGE_VERSION"
}
RunApp()
{
if [ -d "$WINEPREFIX" ]; then
UpdateApp
else
DeployApp
fi
CallApp
}
CreateBottle()
{
if [ -d "$WINEPREFIX" ]; then
UpdateApp
else
DeployApp
fi
}
msg()
{
ECHO_LEVEL=("\033[1;32m==> " "\033[1;31m==> ERROR: ")
echo -e "${ECHO_LEVEL[$1]}\033[1;37m$2\033[0m"
}
SwitchToDeepinWine()
{
PACKAGE_MANAGER="yay"
DEEPIN_WINE_DEPENDS="deepin-wine"
if ! [ -x "$(command -v yay)" ]; then
if ! [ -x "$(command -v yaourt)" ]; then
msg 1 "Need to install 'yay' or 'yaourt' first." >&2
exit 1
else
$PACKAGE_MANAGER="yaourt"
fi
fi
if [[ -z "$(ps -e | grep -o gsd-xsettings)" ]]; then
DEEPIN_WINE_DEPENDS="${DEEPIN_WINE_DEPENDS} xsettingsd"
fi
if [ "$XDG_CURRENT_DESKTOP" = "Deepin" ]; then
DEEPIN_WINE_DEPENDS="${DEEPIN_WINE_DEPENDS} lib32-freetype2-infinality-ultimate"
fi
msg 0 "Installing dependencies: ${DEEPIN_WINE_DEPENDS} ..."
$PACKAGE_MANAGER -S ${DEEPIN_WINE_DEPENDS} --needed
msg 0 "Redeploying app ..."
if [ -d "$WINEPREFIX" ]; then
RemoveApp
fi
DeployApp
msg 0 "Reversing the patch ..."
patch -p1 -R -d ${WINEPREFIX} < $APPDIR/reg.patch
msg 0 "Creating flag file '$WINEPREFIX/deepin' ..."
touch -f $WINEPREFIX/deepin
msg 0 "Done."
}
# Init
if [ -f "$WINEPREFIX/deepin" ]; then
WINE_CMD="deepin-wine"
if [[ -z "$(ps -e | grep -o gsd-xsettings)" ]] && [[ -z "$(ps -e | grep -o xsettingsd)" ]]; then
/usr/bin/xsettingsd &
fi
fi
if [ -z $1 ]; then
RunApp
exit 0
fi
case $1 in
"-r" | "--reset")
ResetApp
;;
"-c" | "--create")
CreateBottle
;;
"-e" | "--remove")
RemoveApp
;;
"-d" | "--deepin")
SwitchToDeepinWine
;;
"-u" | "--uri")
RunApp $2
;;
"-h" | "--help")
HelpApp
;;
*)
echo "Invalid option: $1"
echo "Use -h|--help to get help"
exit 1
;;
esac
exit 0
|