支持取消挂载容器

This commit is contained in:
gfdgd xi 2022-12-02 22:26:10 +08:00
parent 9fdc3a998c
commit bcebe543cc
3 changed files with 7 additions and 5 deletions

@ -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}"
chroot "--userspec=$2:$2" . env "HOME=/home/$2" "${@:3}"

@ -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()

@ -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}"))
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}"))