mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-01-12 17:48:27 +08:00
Qemu优化
This commit is contained in:
parent
9c0e2d11b3
commit
f6698e2f39
2
ChangePassword.sh
Normal file
2
ChangePassword.sh
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
echo -e "123456\n123456\n\n\n\n\n\n\n\n\n" | adduser "$1"
|
2
Mount.sh
2
Mount.sh
@ -28,7 +28,7 @@ mount -o bind /usr/share/fonts ./usr/share/fonts
|
||||
# 配置用户
|
||||
if [ ! -d "home/$2" ]; then
|
||||
# 新建用户,且密码为 123456,以便读写
|
||||
chroot . echo -e "123456\n123456\n\n\n\n\n\n\n\n\n" | adduser "$2"
|
||||
chroot . bash /opt/apps/deepin-wine-runner/ChangePassword.sh "$2"
|
||||
fi
|
||||
# 挂载用户目录到 /root(默认 $HOME 路径)
|
||||
if [[ $2 == "root" ]]; then
|
||||
|
19
QemuRun.py
19
QemuRun.py
@ -7,7 +7,7 @@ import PyQt5.QtWidgets as QtWidgets
|
||||
if __name__ == "__main__":
|
||||
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
||||
homePath = os.getenv("HOME")
|
||||
if len(sys.argv) <= 2:
|
||||
if len(sys.argv) <= 1:
|
||||
print("参数不足")
|
||||
sys.exit(1)
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
@ -19,8 +19,23 @@ if __name__ == "__main__":
|
||||
userName = getpass.getuser()
|
||||
for i in sys.argv[2:]:
|
||||
commandList += f"'{i}' "
|
||||
if commandList.replace(" ", "") == "":
|
||||
commandList = "bash"
|
||||
# 需要先取消挂载其它目录以防止冲突
|
||||
path = f"{homePath}/.deepin-wine-runner-ubuntu-images"
|
||||
for i in os.listdir(path):
|
||||
archPath = f"{path}/{i}"
|
||||
if os.path.isdir(archPath):
|
||||
for k in os.listdir(archPath):
|
||||
bottlePath = f"{archPath}/{k}"
|
||||
if os.path.isdir(bottlePath):
|
||||
if f"{i}/{k}" == sys.argv[1]:
|
||||
continue
|
||||
if os.path.ismount(f"{bottlePath}/dev"):
|
||||
os.system(f"pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY bash '{programPath}/UnMount.sh' '{bottlePath}' ")
|
||||
|
||||
# 判断是否挂载
|
||||
if not os.path.ismount(f"{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}/proc"):
|
||||
if not os.path.ismount(f"{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}/dev"):
|
||||
print("文件暂未挂载,开始挂载")
|
||||
sys.exit(os.system(f"pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY bash '{programPath}/Mount.sh' '{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}' '{userName}' {commandList}"))
|
||||
sys.exit(os.system(f"pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY chroot '--userspec={userName}:{userName}' '{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}/' env 'HOME=/home/{userName}' {commandList}"))
|
||||
|
@ -25,3 +25,12 @@ umount ./opt/apps/deepin-wine-runner/
|
||||
umount ./usr/share/fonts
|
||||
# 挂载用户目录到 /root(默认 $HOME 路径)
|
||||
umount ./root
|
||||
for username in $(ls ./home)
|
||||
do
|
||||
echo ./home/$username
|
||||
umount ./home/$username
|
||||
# if [ -d ./home/$username/.deepinwine/$CONTAINER_NAME ]
|
||||
# then
|
||||
# rm -rf ./home/$username/.deepinwine/$CONTAINER_NAME
|
||||
# fi
|
||||
done
|
||||
|
@ -455,6 +455,16 @@ StartupNotify=true''') # 写入文本文档
|
||||
traceback.print_exc()
|
||||
QtWidgets.QMessageBox.critical(widget, "错误", f"快捷方式创建失败,错误如下:\n{traceback.format_exc()}")
|
||||
|
||||
def ConfigQemu():
|
||||
lists = []
|
||||
for i in qemuBottleList:
|
||||
lists.append(f"{i[0]}/{i[1]}")
|
||||
choose = QtWidgets.QInputDialog.getItem(window, "提示", "选择需要 Chroot 到里面的容器", lists, 0, False)
|
||||
if not choose[1]:
|
||||
return
|
||||
threading.Thread(target=OpenTerminal, args=[f"python3 '{programPath}/QemuRun.py' '{choose[0]}' "]).start()
|
||||
print(choose)
|
||||
|
||||
# 生成 desktop 文件在桌面
|
||||
# (第四个按钮的事件)
|
||||
def make_desktop_on_desktop():
|
||||
@ -2196,7 +2206,7 @@ updateThingsString = '''※1、容器自动配置脚本 GUI 查看介绍使用 Q
|
||||
'''
|
||||
for i in information["Thank"]:
|
||||
thankText += f"{i}\n"
|
||||
updateTime = "2022年12月02日"
|
||||
updateTime = "2022年12月03日"
|
||||
about = f'''<style>
|
||||
a:link, a:active {{
|
||||
text-decoration: none;
|
||||
@ -2670,6 +2680,13 @@ log.addAction(checkLogText)
|
||||
log.addAction(saveLogText)
|
||||
log.addAction(uploadLogText)
|
||||
|
||||
if len(qemuBottleList) >= 1:
|
||||
qemuMenu = menu.addMenu(QtCore.QCoreApplication.translate("U", "配置Chroot容器(&C)"))
|
||||
configMenu = QtWidgets.QAction(QtCore.QCoreApplication.translate("U", "配置指定容器"))
|
||||
qemuMenu.addAction(configMenu)
|
||||
configMenu.triggered.connect(ConfigQemu)
|
||||
print(qemuBottleList)
|
||||
|
||||
help = menu.addMenu(QtCore.QCoreApplication.translate("U", "帮助(&H)"))
|
||||
runStatusWebSize = QtWidgets.QAction(QtCore.QCoreApplication.translate("U", "查询程序在 Wine 的运行情况"))
|
||||
h1 = help.addMenu(QtCore.QCoreApplication.translate("U", "程序官网"))
|
||||
|
Loading…
Reference in New Issue
Block a user