mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-06-06 15:19:50 +08:00
Qemu Run And Chroot Unmount
This commit is contained in:
parent
a5352c6942
commit
fb0ff07ad6
BIN
Model/__pycache__/__init__.cpython-36.pyc
Normal file
BIN
Model/__pycache__/__init__.cpython-36.pyc
Normal file
Binary file not shown.
32
Mount.sh
32
Mount.sh
@ -7,12 +7,10 @@ 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/"
|
||||
echo $0
|
||||
echo $1
|
||||
echo $2
|
||||
echo $3
|
||||
# 挂载必备目录
|
||||
cd "$1"
|
||||
mount --bind /dev ./dev
|
||||
@ -21,5 +19,23 @@ 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}"
|
||||
chmod 777 -R root
|
||||
xhost +
|
||||
# 挂载 Wine 运行器目录
|
||||
mount -o bind `dirname $0` ./opt/apps/deepin-wine-runner/
|
||||
# 挂载字体
|
||||
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"
|
||||
fi
|
||||
# 挂载用户目录到 /root(默认 $HOME 路径)
|
||||
if [[ $2 == "root" ]]; then
|
||||
mount --bind root "$1/root/"
|
||||
else
|
||||
mount --bind "/home/$2" "$1/root/"
|
||||
fi
|
||||
|
||||
# 如果参数 3 存在
|
||||
chroot . "${@:3}"
|
13
QemuRun.py
13
QemuRun.py
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import getpass
|
||||
import PyQt5.QtWidgets as QtWidgets
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -12,13 +13,15 @@ if __name__ == "__main__":
|
||||
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
|
||||
QtWidgets.QMessageBox.information(None, "提示", "此镜像未下载解压,无法继续")
|
||||
exit()
|
||||
commandList = ""
|
||||
userName = getpass.getuser()
|
||||
for i in sys.argv[2:]:
|
||||
commandList += f"'{i}'"
|
||||
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}"))
|
||||
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}"))
|
||||
#print(f"pkexec chroot '{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}/' {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 DISPLAY=:0.0 {commandList}"))
|
27
UnMount.sh
Normal file
27
UnMount.sh
Normal file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
if [ ` whoami ` != "root" ]; then
|
||||
echo "Only root can run me"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "$1" ]; then
|
||||
echo "路径不存在!"
|
||||
exit 1
|
||||
fi
|
||||
echo $0
|
||||
echo $1
|
||||
echo $2
|
||||
#echo $3
|
||||
# 挂载必备目录
|
||||
cd "$1"
|
||||
umount ./dev
|
||||
umount ./dev/pts
|
||||
umount ./proc
|
||||
umount ./etc/resolv.conf
|
||||
umount ./sys
|
||||
umount ./dev/shm
|
||||
# 挂载 Wine 运行器目录
|
||||
umount ./opt/apps/deepin-wine-runner/
|
||||
# 挂载字体
|
||||
umount ./usr/share/fonts
|
||||
# 挂载用户目录到 /root(默认 $HOME 路径)
|
||||
umount ./root
|
7
demo/APICheck/main.cpp
Normal file
7
demo/APICheck/main.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include <iostream>
|
||||
#include <Windows.h>
|
||||
using namespace std;
|
||||
int main(){
|
||||
MessageBox(NULL, TEXT("a"), TEXT("A"), 32);
|
||||
return 0;
|
||||
}
|
BIN
demo/APICheck/main.exe
Executable file
BIN
demo/APICheck/main.exe
Executable file
Binary file not shown.
BIN
req/__pycache__/__init__.cpython-36.pyc
Normal file
BIN
req/__pycache__/__init__.cpython-36.pyc
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user