mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-12-14 11:02:04 +08:00
初步制作qemu实现的跨架构运行wine的功能结构
This commit is contained in:
25
Mount.sh
Normal file
25
Mount.sh
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
if [ ` whoami ` != "root" ]; then
|
||||||
|
echo "Only root can run me"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! -d "$1" ]; then
|
||||||
|
echo "路径不存在!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# 挂载用户目录
|
||||||
|
mkdir -p "$1/home/$USER"
|
||||||
|
mount -o bind ~ "$1/home/$USER"
|
||||||
|
# 挂载 Wine 运行器目录
|
||||||
|
#mount -o bind `dirname $0` "$1/opt/apps/deepin-wine-runner/wine"
|
||||||
|
mount -o bind `dirname $0` "$1/opt/apps/deepin-wine-runner/"
|
||||||
|
# 挂载必备目录
|
||||||
|
cd "$1"
|
||||||
|
mount --bind /dev ./dev
|
||||||
|
mount --bind /dev/pts ./dev/pts
|
||||||
|
mount -t proc /proc ./proc
|
||||||
|
mount --bind /etc/resolv.conf ./etc/resolv.conf
|
||||||
|
mount -t sysfs /sys ./sys
|
||||||
|
mount --bind /dev/shm ./dev/shm
|
||||||
|
# 如果参数 2 存在
|
||||||
|
chroot . "${@:2}"
|
||||||
47
QemuDownload.py
Normal file
47
QemuDownload.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import traceback
|
||||||
|
import req as requests
|
||||||
|
import PyQt5.QtGui as QtGui
|
||||||
|
import PyQt5.QtCore as QtCore
|
||||||
|
import PyQt5.QtWidgets as QtWidgets
|
||||||
|
from Model import *
|
||||||
|
|
||||||
|
sources = [
|
||||||
|
"https://code.gitlink.org.cn/gfdgd_xi/deepin-wine-runner-ubuntu-image/raw/branch/master/Sandbox"
|
||||||
|
]
|
||||||
|
sourceIndex = 0
|
||||||
|
|
||||||
|
def ReadTXT(path: str) -> str:
|
||||||
|
with open(path, "r") as file:
|
||||||
|
things = file.read()
|
||||||
|
return things
|
||||||
|
|
||||||
|
def WriteTXT(path: str, text: str) -> None:
|
||||||
|
with open(path, "w") as file:
|
||||||
|
file.write(text)
|
||||||
|
|
||||||
|
def CheckVersion(arch: str) -> bool:
|
||||||
|
information = requests.get(f"{sources[sourceIndex]}/{arch}/lists.json").json()[0]
|
||||||
|
try:
|
||||||
|
ReadTXT()
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
QtWidgets.QMessageBox.critical(None, "错误", traceback.format_exc())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
||||||
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
|
if os.system("which qemu-i386-static"):
|
||||||
|
if QtWidgets.QMessageBox.question(None, "提示", "检测到您未安装 qemu-user-static,是否安装?") == QtWidgets.QMessageBox.Yes:
|
||||||
|
OpenTerminal(f"pkexec bash '{programPath}/ShellList/InstallQemuUserStatic.sh'")
|
||||||
|
exit()
|
||||||
|
while True:
|
||||||
|
archList = requests.get(f"{sources[sourceIndex]}/lists.json").json()
|
||||||
|
choose = QtWidgets.QInputDialog.getItem(None, "选择", "选择要安装/更新的镜像对应的架构", archList, 0, False)
|
||||||
|
if not choose[1]:
|
||||||
|
QtWidgets.QMessageBox.information(None, "提示", "用户取消操作")
|
||||||
|
break
|
||||||
24
QemuRun.py
Normal file
24
QemuRun.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
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:
|
||||||
|
print("参数不足")
|
||||||
|
sys.exit(1)
|
||||||
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
|
# 判断是否已下载镜像
|
||||||
|
if not os.path.exists(f"{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}"):
|
||||||
|
if QtWidgets.QMessageBox.information(None, "提示", "此镜像未下载解压,无法继续"):
|
||||||
|
pass
|
||||||
|
commandList = ""
|
||||||
|
for i in sys.argv[2:]:
|
||||||
|
commandList += f"'{i}'"
|
||||||
|
# 判断是否挂载
|
||||||
|
if not os.path.ismount(f"{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}/proc"):
|
||||||
|
print("文件暂未挂载,开始挂载")
|
||||||
|
sys.exit(os.system(f"pkexec '{programPath}/Mount.sh' '{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}/proc' {commandList}"))
|
||||||
|
sys.exit(os.system(f"pkexec chroot '{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}/proc' {commandList}"))
|
||||||
3
ShellList/InstallQemuUserStatic.sh
Executable file
3
ShellList/InstallQemuUserStatic.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
echo 开始安装 qemu-user-static
|
||||||
|
pkexec apt update
|
||||||
|
pkexec apt install qemu-user-static -y
|
||||||
Reference in New Issue
Block a user