Compare commits

...

3 Commits
2.0.1 ... 2.0.2

Author SHA1 Message Date
2f41cc88b2 自带kill.sh 2023-04-12 21:49:55 +08:00
b262273a1d wine8 2023-04-12 17:38:28 +08:00
cb80f7be6b update spark-dwine-helper/build.sh.
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2023-04-12 09:16:18 +00:00
4 changed files with 289 additions and 12 deletions

View File

@@ -25,10 +25,10 @@ Version: $version
Architecture: all
Maintainer: shenmo <shenmo@spark-app.store>
Installed-Size: $SIZE
Depends: zenity, p7zip-full, fonts-noto-cjk,deepin-wine-helper(>=5.1) | com.wine-helper.deepin,transhell
Depends: zenity, p7zip-full, fonts-noto-cjk,transhell
Section: utils
Priority: extra
Recommends: spark-dwine-helper-settings
Recommends: spark-dwine-helper-settings,deepin-wine-helper(>=5.1) | com.wine-helper.deepin
Multi-Arch: foreign
Provides: store.spark-app.spark-dwine-helper(=$version)
Replaces: store.spark-app.spark-dwine-helper(<=$version)
@@ -85,10 +85,10 @@ Version: $version
Architecture: all
Maintainer: shenmo <shenmo@spark-app.store>
Installed-Size: $SIZE
Depends: zenity, p7zip-full, fonts-noto-cjk,deepin-wine-helper(>=5.1) | com.wine-helper.deepin,transhell
Depends: zenity, p7zip-full, fonts-noto-cjk,transhell
Section: utils
Priority: extra
Recommends: spark-dwine-helper-settings
Recommends: spark-dwine-helper-settings,deepin-wine-helper(>=5.1) | com.wine-helper.deepin
Provides: spark-dwine-helper(=$version)
Conflicts: spark-dwine-helper
Replaces: spark-dwine-helper(<=$version)

View File

@@ -0,0 +1,277 @@
#!/bin/bash
#####因为arm版本的deepin-wine-helper不带这个又不想破坏x86兼容性故改名
APP_NAME="QQ"
LOG_FILE=$0
SHELL_DIR=${0%/*}
if [ $SPECIFY_SHELL_DIR ]; then
SHELL_DIR=$SPECIFY_SHELL_DIR
fi
PUBLIC_DIR="/var/public"
UsePublicDir()
{
if [ -z "$USE_PUBLIC_DIR" ]; then
echo "Don't use public dir"
return 1
fi
if [ ! -d "$PUBLIC_DIR" ];then
echo "Not found $PUBLIC_DIR"
return 1
fi
if [ ! -r "$PUBLIC_DIR" ];then
echo "Can't read for $PUBLIC_DIR"
return 1
fi
if [ ! -w "$PUBLIC_DIR" ];then
echo "Can't write for $PUBLIC_DIR"
return 1
fi
if [ ! -x "$PUBLIC_DIR" ];then
echo "Can't excute for $PUBLIC_DIR"
return 1
fi
return 0
}
WINE_BOTTLE="$HOME/.deepinwine"
if UsePublicDir;then
WINE_BOTTLE="$PUBLIC_DIR"
fi
get_wine_by_pid()
{
wine_path=$(cat /proc/$1/maps | grep -E "\/wine$|\/wine64$|\/wine |\/wine64 " | head -1 | awk '{print $6}')
if [ -z "$wine_path" ];then
cat /proc/$1/cmdline| xargs -0 -L1 -I{} echo {} | grep -E "\/wine$|\/wine64$|\/wine |\/wine64 " | head -1
else
echo $wine_path
fi
}
is_wine_process()
{
wine_module=$(get_wine_by_pid $1)
if [ -z "$wine_module" ];then
wine_module=$(cat /proc/$1/maps | grep -E "\/wineserver$" | head -1)
fi
echo $wine_module
}
get_prefix_by_pid()
{
WINE_PREFIX=$(xargs -0 printf '%s\n' < /proc/$1/environ | grep WINEPREFIX)
WINE_PREFIX=${WINE_PREFIX##*=}
if [ -z "$WINE_PREFIX" ] && [ -n "$(is_wine_process $1)" ]; then
#不指定容器的情况用默认容器目录
WINE_PREFIX="$HOME/.wine"
fi
if [ -n "$WINE_PREFIX" ];then
WINE_PREFIX=$(realpath $WINE_PREFIX)
echo $WINE_PREFIX
fi
}
get_wineserver()
{
if [ -z "$1" ];then
return
fi
targ_prefix=$(realpath $1)
ps -ef | grep wineserver | while read server_info ;do
debug_log_to_file "get server info: $server_info"
server_pid=$(echo $server_info | awk '{print $2}')
server_prefix=$(get_prefix_by_pid $server_pid)
debug_log_to_file "get server pid $server_pid, prefix: $server_prefix"
if [ "$targ_prefix" = "$server_prefix" ];then
server=$(echo $server_info | awk '{print $NF}')
if [ "-p0" = "$server" ];then
server=$(echo $server_info | awk '{print $(NF-1)}')
fi
debug_log_to_file "get server $server"
echo $server
return
fi
done
}
init_log_file()
{
if [ -d "$DEBUG_LOG" ];then
LOG_DIR=$(realpath $DEBUG_LOG)
if [ -d "$LOG_DIR" ];then
LOG_FILE="${LOG_DIR}/${LOG_FILE##*/}.log"
echo "" > "$LOG_FILE"
debug_log "LOG_FILE=$LOG_FILE"
fi
fi
}
debug_log_to_file()
{
if [ -d "$DEBUG_LOG" ];then
strDate=$(date)
echo -e "${strDate}:${1}" >> "$LOG_FILE"
fi
}
debug_log()
{
strDate=$(date)
echo "${strDate}:${1}"
}
init_log_file
get_bottle_path_by_process_id()
{
PID_LIST="$1"
PREFIX_LIST=""
for pid_var in $PID_LIST ; do
WINE_PREFIX=$(get_prefix_by_pid $pid_var)
#去掉重复项
for path in $(echo -e $PREFIX_LIST) ; do
if [[ $path == "$WINE_PREFIX" ]]; then
WINE_PREFIX=""
fi
done
if [ -d "$WINE_PREFIX" ]; then
debug_log_to_file "found $pid_var : $WINE_PREFIX"
PREFIX_LIST+="\n$WINE_PREFIX"
fi
done
echo -e $PREFIX_LIST
}
get_pid_by_process_name()
{
PID_LIST=""
for pid_var in $(ps -ef | grep -E -i "$1" | grep -v grep | awk '{print $2}');do
#通过判断是否加载wine来判断是不是wine进程
if [ -n "$(is_wine_process $pid_var)" ];then
PID_LIST+=" $pid_var"
fi
done
echo "$PID_LIST"
}
get_bottle_path_by_process_name()
{
PID_LIST=$(get_pid_by_process_name $1)
debug_log_to_file "get pid list: $PID_LIST"
get_bottle_path_by_process_id "$PID_LIST"
}
get_bottle_path()
{
if [ -z "$1" ];then
return 0
fi
if [ -f "$1/user.reg" ]; then
realpath "$1"
return 0
fi
if [ -f "$WINE_BOTTLE/$1/user.reg" ]; then
realpath "$WINE_BOTTLE/$1"
return 0
fi
get_bottle_path_by_process_name "$1"
}
kill_app()
{
debug_log "try to kill $1"
for path in $(get_bottle_path $1); do
if [ -n "$path" ];then
WINESERVER=$(get_wineserver "$path")
if [ -f "$WINESERVER" ];then
debug_log "kill $path by $WINESERVER"
env WINEPREFIX="$path" "$WINESERVER" -k
fi
PID_LIST=$(get_pid_by_process_name "exe|wine")
for tag_pid in $PID_LIST; do
bottle=$(get_bottle_path_by_process_id "$tag_pid")
bottle=${bottle:1}
if [ "$path" = "$bottle" ];then
echo "kill $tag_pid for $bottle"
kill -9 $tag_pid
fi
done
fi
done
#Kill defunct process
ps -ef | grep -E "$USER.*exe.*<defunct>"
ps -ef | grep -E "$USER.*exe.*<defunct>" | grep -v grep | awk '{print $2}' | xargs -i kill -9 {}
}
get_tray_window()
{
$SHELL_DIR/get_tray_window | awk -F: '{print $2}'
}
get_stacking_window()
{
xprop -root _NET_CLIENT_LIST_STACKING | awk -F# '{print $2}' | sed -e 's/, / /g'
}
get_window_pid()
{
for winid in $(echo "$1" | sed -e 's/ /\n/g') ;
do
xprop -id $winid _NET_WM_PID | awk -F= '{print $2}'
done
}
get_window_bottle()
{
debug_log_to_file "get_window_bottle $1"
PID_LIST=$(get_window_pid "$1")
debug_log_to_file "get_window_bottle pid list: $PID_LIST"
get_bottle_path_by_process_id "$PID_LIST"
}
get_active_bottles()
{
TRAYWINDOWS=$(get_tray_window)
STACKINGWINDOWS=$(get_stacking_window)
debug_log_to_file "tray window id: $TRAYWINDOWS"
debug_log_to_file "stacking window id: $STACKINGWINDOWS"
PID_LIST="$TRAYWINDOWS $STACKINGWINDOWS"
get_window_bottle "$PID_LIST"
}
kill_exit_block_app()
{
TAGBOTTLE=$(get_bottle_path $1)
debug_log "tag bottle: $TAGBOTTLE"
ACTIVEBOTTLES=$(get_active_bottles)
debug_log "active bottles: $ACTIVEBOTTLES"
if [[ "$ACTIVEBOTTLES" != *"$TAGBOTTLE"* ]]; then
kill_app "$TAGBOTTLE"
fi
}
#get_active_bottles
#exit
debug_log "kill $1 $2"
if [ -n "$1" ]; then
APP_NAME="$1"
fi
if [ "$2" = "block" ]; then
kill_exit_block_app $APP_NAME $3
else
kill_app $APP_NAME
fi

View File

@@ -134,7 +134,7 @@ CallProcess()
is_autostart $DEB_PACKAGE_NAME
autostart=$?
if [ $autostart -ne 0 ];then
$SHELL_DIR/kill.sh "$BOTTLENAME" block
$SHELL_DIR/kill_spark.sh "$BOTTLENAME" block
fi
#change current dir to excute path
@@ -254,7 +254,7 @@ CallZhuMu()
CallQQGame()
{
debug_log "run $1"
$SHELL_DIR/kill.sh qqgame block
$SHELL_DIR/kill_spark.sh qqgame block
env WINEPREFIX="$WINEPREFIX" $WINE_CMD "$1" &
}
@@ -341,7 +341,7 @@ CallWXWork()
CallDingTalk()
{
debug_log "run $1"
$SHELL_DIR/kill.sh DingTalk block
$SHELL_DIR/kill_spark.sh DingTalk block
CallProcess "$@"
}
@@ -404,7 +404,7 @@ CallFoxmail()
CallTHS()
{
$SHELL_DIR/kill.sh ths block
$SHELL_DIR/kill_spark.sh ths block
debug_log "Start run $1"
#get file full path
@@ -414,7 +414,7 @@ CallTHS()
#kill bloack process
name="${path##*/}"
$SHELL_DIR/kill.sh "$name" block
$SHELL_DIR/kill_spark.sh "$name" block
#change current dir to excute path
path=$(dirname "$path")
@@ -432,7 +432,7 @@ CallTHS()
CallQQGameV2()
{
debug_log "run $1"
$SHELL_DIR/kill.sh QQMicroGameBox block
$SHELL_DIR/kill_spark.sh QQMicroGameBox block
CallProcess "$1" -action:force_download -appid:${2} -pid:8 -bin_version:1.1.2.4 -loginuin:
}
@@ -447,7 +447,7 @@ CallPsCs6()
#kill bloack process
name="${path##*/}"
$SHELL_DIR/kill.sh "$name" block
$SHELL_DIR/kill_spark.sh "$name" block
#change current dir to excute path
path=$(dirname "$path")

View File

@@ -79,7 +79,7 @@ fi
##############<<<<<<<<<屏蔽mono和gecko安装器开始
##默认屏蔽mono和gecko安装器
if [ "$APPRUN_CMD" = "spark-wine7-devel" ] && [ -z "$ENABLE_DOT_NET" ];then
if [ "$APPRUN_CMD" = "spark-wine7-devel" ] || [ "$APPRUN_CMD" = "spark-wine8" ] && [ -z "$ENABLE_DOT_NET" ];then
export WINEDLLOVERRIDES="mscoree,mshtml="
#### "为了降低打包体积默认关闭gecko和momo如有需要注释此行仅对spark-wine7-devel有效"