添加若干功能

This commit is contained in:
2022-11-06 12:49:34 +08:00
parent d8a92fab02
commit 57f18f1a74
7 changed files with 326 additions and 22 deletions

View File

@@ -13,6 +13,7 @@ build:
zip -v -q -r package-script.zip package-script
cp -rv VM deb/opt/apps/deepin-wine-runner
cp -rv AllInstall.py deb/opt/apps/deepin-wine-runner
cp -rv kill.sh deb/opt/apps/deepin-wine-runner
cp -rv req deb/opt/apps/deepin-wine-runner
cp -rv RegShot deb/opt/apps/deepin-wine-runner
cp -rv BeCyIconGrabber.exe deb/opt/apps/deepin-wine-runner

View File

@@ -2,8 +2,8 @@
# 使用系统默认的 bash 运行
###########################################################################################
# 作者gfdgd xi、为什么您不喜欢熊出没和阿布呢
# 版本:1.7.0
# 更新时间2022年07月15
# 版本:2.4.1
# 更新时间2022年11月06
# 感谢:感谢 wine 以及 deepin-wine 团队,提供了 wine 和 deepin-wine 给大家使用,让我能做这个程序
# 基于 Python3 的 tkinter 构建
###########################################################################################

View File

@@ -7,7 +7,10 @@
# 感谢:感谢 wine、deepin-wine 以及星火团队,提供了 wine、deepin-wine、spark-wine-devel 给大家使用,让我能做这个程序
# 基于 sh
#################################################################################################################
python3 -m pip install --upgrade pynput --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple
# 非强制性的必应组件,所以成功不成功都行
echo 安装组件
python3 -m pip install --upgrade pynput --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple > /dev/null | true
echo 执行完成
# 如果为非 X86 PC可以删除掉一些无用组件主要是用不了
if [ `arch` != "x86_64" ]; then
echo 非X86架构删除对非X86架构无用的组件

278
kill.sh Executable file
View File

@@ -0,0 +1,278 @@
#!/bin/bash
APP_NAME="QQ"
LOG_FILE=$0
SHELL_DIR=$(dirname $0)
SHELL_DIR=$(realpath "$SHELL_DIR")
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 | grep window_id: | 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

@@ -1845,20 +1845,15 @@ exe路径\' 参数 \'
<b>千万不要中断后不删除源的情况下 apt upgrade </b>中断后只需重新打开脚本输入 repair 或者随意安装一个 Wine会自动执行恢复操作即可
以及此脚本安装的 Wine 无法保证 100% 能使用,以及副作用是会提示
<code>N: 鉴于仓库 'https://community-packages.deepin.com/beige beige InRelease' 不支持 'i386' 体系结构,跳过配置文件 'main/binary-i386/Packages' 的获取。</code>'''
updateThingsString = '''※1、新增 VB Runtime 组件安装工具
※2、优化自动配置容器搜索功能,搜索不区分大小写
※3、新增 Wine 容器快捷键映射功能
4、修复在 arm 架构运行 Wine 时提示无法解压资源的问题
5、修复右键无法找到 Wine 运行器打开方式的问题
※6、修复了容器自动配置脚本 GUI 解析器无法指定 Wine、容器以及位数的功能
※7、容器自动配置脚本支持评分功能以及脚本内容介绍功能
※8、支持添加自定义安装的 Wine
※9、打包器打包的 arm 包支持同时支持 UOS 的 box86 和 exagear
※10、提供了 Python 的自动配置脚本 API
updateThingsString = '''※1、不基于生态适配活动脚本的打包器支持只生成制作容器的 7z 包
※2、两个打包器的容器自动删除脚本添加 kill.sh
※3、Wine 运行器支持杀死对应容器进程
4、非生态适配脚本打包器追加运行参数改为 --uri XXX 而非直接 XXX
5、两个打包器新增星火应用商店投稿入口
'''
for i in information["Thank"]:
thankText += f"{i}\n"
updateTime = "2022年10月25"
updateTime = "2022年11月06"
about = f'''<h1>关于</h1>
<p>一个能让Linux用户更加方便运行Windows应用的程序内置了对wine图形化的支持和各种Wine工具和自制Wine程序打包器、运行库安装工具等等</p>
<p>同时也内置了基于VirtualBox制作的小白Windows虚拟机安装工具可以做到只需要用户下载系统镜像并点击安装即可无需顾及虚拟机安装、创建、虚拟机的分区等等</p>
@@ -2073,6 +2068,9 @@ programRunLayout.addWidget(button3)
killProgram = QtWidgets.QPushButton(QtCore.QCoreApplication.translate("U", "终止程序"))
killProgram.clicked.connect(KillProgram)
programRunLayout.addWidget(killProgram)
killBottonProgram = QtWidgets.QPushButton(QtCore.QCoreApplication.translate("U", "终止指定容器的程序"))
killBottonProgram.clicked.connect(lambda: threading.Thread(target=os.system, args=[f"'{programPath}/kill.sh' '{os.path.basename(e1.currentText())}'"]).start())
programRunLayout.addWidget(killBottonProgram)
mainLayout.addWidget(programRun, 2, 1, 1, 1)
# 菜单栏

View File

@@ -1,16 +1,27 @@
#!/bin/bash
if [ "$1" = "remove" ] || [ "$1" = "purge" ];then
echo "清理卸载残留"
for username in `ls /home`
CONTAINER_NAME="@deb_package_name@"
if [ -z $CONTAINER_NAME ];then
echo "W: 没有指定容器,跳过清理容器。请手动前往 ~/.deepinwine/ 下删除"
exit
fi
if [ -e /opt/deepinwine/tools/kill.sh ];then
/opt/deepinwine/tools/kill.sh $CONTAINER_NAME
###这里注意如果没写CONTAINER_NAME,会把QQ杀了
fi
for username in $(ls /home)
do
echo /home/$username
if [ -d "/home/$username/.deepinwine/@deb_package_name@" ]
if [ -d /home/$username/.deepinwine/$CONTAINER_NAME ]
then
rm -rf "/home/$username/.deepinwine/@deb_package_name@"
rm -rf /home/$username/.deepinwine/$CONTAINER_NAME
fi
done
else
echo "非卸载,跳过清理"
echo "非卸载,跳过清理"
fi

View File

@@ -13,6 +13,8 @@
import os
import sys
import json
import threading
import webbrowser
import subprocess
import PyQt5.QtGui as QtGui
import PyQt5.QtCore as QtCore
@@ -222,6 +224,17 @@ menu = window.menuBar()
programMenu = menu.addMenu("程序")
exit = QtWidgets.QAction("退出")
exit.triggered.connect(window.close)
uploadSparkStore = menu.addMenu(QtCore.QCoreApplication.translate("U", "投稿到星火应用商店"))
uploadSparkStoreWebsize = QtWidgets.QAction(QtCore.QCoreApplication.translate("U", "从网页端投稿"))
if os.path.exists("/opt/spark-store-submitter/bin/spark-store-submitter"):
uploadSparkStoreProgram = QtWidgets.QAction(QtCore.QCoreApplication.translate("U", "使用投稿器投稿(推荐)"))
else:
uploadSparkStoreProgram = QtWidgets.QAction(QtCore.QCoreApplication.translate("U", "使用投稿器投稿(推荐,请先安装投稿器)"))
uploadSparkStoreProgram.setDisabled(True)
uploadSparkStore.addAction(uploadSparkStoreProgram)
uploadSparkStore.addAction(uploadSparkStoreWebsize)
uploadSparkStoreWebsize.triggered.connect(lambda: webbrowser.open_new_tab("https://upload.deepinos.org"))
uploadSparkStoreProgram.triggered.connect(lambda: threading.Thread(target=os.system, args=["/opt/spark-store-submitter/bin/spark-store-submitter"]).start())
helpMenu = menu.addMenu("帮助")
help = QtWidgets.QAction("帮助")
help.triggered.connect(ShowHelp)