2022-11-30 14:37:37 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
import sys
|
2022-12-02 19:16:08 +08:00
|
|
|
import getpass
|
2022-11-30 14:37:37 +08:00
|
|
|
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]}"):
|
2022-12-02 19:16:08 +08:00
|
|
|
QtWidgets.QMessageBox.information(None, "提示", "此镜像未下载解压,无法继续")
|
|
|
|
exit()
|
2022-11-30 14:37:37 +08:00
|
|
|
commandList = ""
|
2022-12-02 19:16:08 +08:00
|
|
|
userName = getpass.getuser()
|
2022-11-30 14:37:37 +08:00
|
|
|
for i in sys.argv[2:]:
|
2022-12-02 19:16:08 +08:00
|
|
|
commandList += f"'{i}' "
|
2022-11-30 14:37:37 +08:00
|
|
|
# 判断是否挂载
|
|
|
|
if not os.path.ismount(f"{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}/proc"):
|
|
|
|
print("文件暂未挂载,开始挂载")
|
2022-12-02 19:16:08 +08:00
|
|
|
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}"))
|