From bcebe543cc23b621036708870ac9c0fa1044037d Mon Sep 17 00:00:00 2001
From: gfdgd_xi <3025613752@qq.com>
Date: Fri, 2 Dec 2022 22:26:10 +0800
Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=8F=96=E6=B6=88=E6=8C=82?=
 =?UTF-8?q?=E8=BD=BD=E5=AE=B9=E5=99=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Mount.sh        | 8 ++++----
 QemuDownload.py | 2 ++
 QemuRun.py      | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Mount.sh b/Mount.sh
index cc6b4eb..45c0d7a 100644
--- a/Mount.sh
+++ b/Mount.sh
@@ -14,11 +14,11 @@ echo $3
 # 挂载必备目录
 cd "$1"
 mount --bind /dev ./dev
-mount --bind  /dev/pts ./dev/pts
+#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
+#mount --bind /dev/shm  ./dev/shm
 chmod 777 -R root
 xhost +
 # 挂载 Wine 运行器目录
@@ -34,8 +34,8 @@ fi
 if [[ $2 == "root" ]]; then
     mount --bind root "$1/root/"
 else
-    mount --bind "/home/$2" "$1/root/"
+    mount --bind "/home/$2" "$1/home/$2"
 fi
 
 # 如果参数 3 存在
-chroot "--userspec=$2:$2" . "${@:3}"
\ No newline at end of file
+chroot "--userspec=$2:$2" . env "HOME=/home/$2" "${@:3}"
diff --git a/QemuDownload.py b/QemuDownload.py
index 312a9bb..7dede56 100644
--- a/QemuDownload.py
+++ b/QemuDownload.py
@@ -350,6 +350,8 @@ def on_delButton_clicked():
         if not changed:
             name = f"{path}/i386/{localJsonList[ui.localWineList.currentIndex().row()]}".replace(".tar.gz", "")
         print(name)
+        # 必须取消挂载目录才行
+        os.system(f"bash '{programPath}/UnMount.sh' '{name}'")
         #name = f"{homePath}/.deepin-wine-runner-ubuntu-images/{localJsonList[ui.localWineList.currentIndex().row()]}"
         dir = QtCore.QDir(name)
         dir.removeRecursively()
diff --git a/QemuRun.py b/QemuRun.py
index 8e8b669..eda1857 100644
--- a/QemuRun.py
+++ b/QemuRun.py
@@ -23,4 +23,4 @@ if __name__ == "__main__":
     if not os.path.ismount(f"{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}/proc"):
         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 DISPLAY=:0.0 {commandList}"))
\ No newline at end of file
+    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}"))