基本完成第一版
This commit is contained in:
parent
b853640a03
commit
779e303147
14
deb/DEBIAN/control
Executable file
14
deb/DEBIAN/control
Executable file
@ -0,0 +1,14 @@
|
||||
Package: gx-env-runner
|
||||
Version: 1.0
|
||||
Maintainer: gfdgd xi <3025613752@qq.com>
|
||||
Homepage: https://gitee.com/gfdgd-xi/deep-wine-runner
|
||||
Architecture: all
|
||||
Severity: serious
|
||||
Certainty: possible
|
||||
Check: binaries
|
||||
Type: binary, udeb
|
||||
Priority: optional
|
||||
Depends: python3, python3-pyqt5, bubblewrap, gx-env-runtime
|
||||
Section: utils
|
||||
Installed-Size: 2569264
|
||||
Description: gx-env-runtime
|
3
deb/DEBIAN/postinst
Executable file
3
deb/DEBIAN/postinst
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
cp /usr/bin/gx-env-load-desktop-in-chroot /opt/new-system-env/gx-env/
|
||||
#gx-env-load-desktop
|
8
deb/DEBIAN/postrm
Executable file
8
deb/DEBIAN/postrm
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
# 删除软件缓存(留着也没什么用了)
|
||||
# 缓存目录:~/.cache/deepin-wine-runner
|
||||
if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
|
||||
rm -rf /usr/share/applications/gx-env-*.desktop
|
||||
else
|
||||
echo "非卸载,跳过清理"
|
||||
fi
|
13
deb/usr/bin/gx-env-adduser-root
Executable file
13
deb/usr/bin/gx-env-adduser-root
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
chrootEnvPath=/opt/new-system-env
|
||||
zenity --info --text=请输入需要设置的密码 --no-wrap
|
||||
firstPWD=`zenity --password`
|
||||
zenity --info --text=请再输入一次相同的密码 --no-wrap
|
||||
secondPWD=`zenity --password`
|
||||
if [[ $firstPWD != $secondPWD ]]; then
|
||||
zenity --error --text=密码不相同,无法继续 --no-wrap
|
||||
exit 1
|
||||
fi
|
||||
echo -e "$firstPWD\n$firstPWD\n\n\n\n\n\nY\n" | gx-env-run-root adduser $USER
|
||||
#gx-env-run-root bash -c "echo $USER >> /etc/sudo"
|
2
deb/usr/bin/gx-env-filemanager
Executable file
2
deb/usr/bin/gx-env-filemanager
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
gx-env-run dolphin
|
21
deb/usr/bin/gx-env-init
Executable file
21
deb/usr/bin/gx-env-init
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
chrootEnvPath=/opt/new-system-env
|
||||
if [[ ! -d $chrootEnvPath ]]; then
|
||||
echo Chroot 环境不存在,请部署环境后再试
|
||||
exit 1
|
||||
fi
|
||||
echo aa > /tmp/env-$USER.txt
|
||||
if [[ ! -f $chrootEnvPath/tmp/env-$USER.txt ]]; then
|
||||
echo 未挂载目录,立即挂载
|
||||
pkexec env `printenv` gx-env-mount-root
|
||||
fi
|
||||
#user=`whoami`
|
||||
if [[ ! -f $chrootEnvPath/user/$USER ]]; then
|
||||
gx-env-adduser-root
|
||||
if [[ $? != 0 ]]; then
|
||||
echo Create User Error!
|
||||
exit 1
|
||||
fi
|
||||
pkexec env `printenv` mkdir $chrootEnvPath/user/ -p #$USER
|
||||
pkexec env `printenv` touch $chrootEnvPath/user/$USER
|
||||
fi
|
3
deb/usr/bin/gx-env-install-deb
Executable file
3
deb/usr/bin/gx-env-install-deb
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
gx-env-run-root apt update
|
||||
gx-env-run-root apt install "$1"
|
11
deb/usr/bin/gx-env-load-desktop
Executable file
11
deb/usr/bin/gx-env-load-desktop
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
chrootEnvPath=/opt/new-system-env
|
||||
if [[ -f $HOME/.config/gx-env/nosandbox ]]; then
|
||||
gx-env-run-root python3 /gx-env/gx-env-load-desktop-in-chroot
|
||||
else
|
||||
gx-env-run-root python3 /gx-env/gx-env-load-desktop-in-chroot 1
|
||||
fi
|
||||
if [[ ! -d /usr/share/applications/gx-env ]]; then
|
||||
pkexec mkdir /usr/share/applications/gx-env -p
|
||||
fi
|
||||
pkexec cp $chrootEnvPath/gx-env/desktop/* /usr/share/applications/gx-env -v
|
79
deb/usr/bin/gx-env-load-desktop-in-chroot
Executable file
79
deb/usr/bin/gx-env-load-desktop-in-chroot
Executable file
@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
#chrootEnvPath="/opt/new-system-env"
|
||||
chrootEnvPath="/"
|
||||
if not os.path.exists("/gx-env/desktop"):
|
||||
os.makedirs("/gx-env/desktop")
|
||||
if not os.path.exists("/gx-env/shell"):
|
||||
os.makedirs("/gx-env/shell")
|
||||
if not os.path.exists("/gx-env/icons"):
|
||||
os.makedirs("/gx-env/icons")
|
||||
for i in os.listdir("{}/usr/share/applications".format(chrootEnvPath)):
|
||||
if i == "gdebi.desktop" or i == "spark-store.desktop":
|
||||
continue
|
||||
#if os.path.exists("/usr/share/applications/gx-env-{}".format(i)):
|
||||
# continue
|
||||
info = ""
|
||||
try:
|
||||
with open("{}/usr/share/applications/{}".format(chrootEnvPath, i), "r") as file:
|
||||
info = file.read()
|
||||
except:
|
||||
try:
|
||||
with open("{}/opt/apps/{}/entries/applications/{}".format(chrootEnvPath, os.path.splitext(os.path.basename(i))[0], i), "r") as file:
|
||||
info = file.read()
|
||||
except:
|
||||
continue
|
||||
newInfo = ""
|
||||
for r in info.splitlines():
|
||||
if "exec=" in r.lower():
|
||||
#newInfo += "Exec=gx-env-run " + r[5:].strip() + "\n"
|
||||
with open("/gx-env/shell/gx-env-{}.sh".format(os.path.splitext(os.path.basename(i))[0]), "w") as file:
|
||||
command = ""
|
||||
program = r[5:].strip()
|
||||
#try:
|
||||
# if sys.argv[1] == "1":
|
||||
# command += " --no-sandbox "
|
||||
#except:
|
||||
# pass
|
||||
|
||||
if "%F" in program:
|
||||
program = program.replace("%F", "$1")
|
||||
command += " %F "
|
||||
if "%f" in program:
|
||||
program = program.replace("%f", "$2")
|
||||
command += " %f "
|
||||
if "%u" in program:
|
||||
program = program.replace("%u", "$3")
|
||||
command += " %u "
|
||||
if "%U" in program:
|
||||
program = program.replace("%U", "$4")
|
||||
command += " %U "
|
||||
try:
|
||||
if sys.argv[1] == "1":
|
||||
file.write("#!/bin/bash\n" + program + " --no-sandbox")
|
||||
else:
|
||||
file.write("#!/bin/bash\n" + program)
|
||||
except:
|
||||
file.write("#!/bin/bash\n" + program)
|
||||
newInfo += "Exec=gx-env-run bash \"/gx-env/shell/gx-env-{}.sh\" {} \n".format(os.path.splitext(os.path.basename(i))[0], command)
|
||||
elif "name=" in r.lower() or "name[" in r.lower():
|
||||
newInfo += r + "(兼容模式)\n"
|
||||
elif "icon=" in r.lower():
|
||||
if os.path.exists(r[5:]):
|
||||
newInfo += "Icon=/opt/new-system-env/" + r[5:] + "\n"
|
||||
else:
|
||||
path = subprocess.getoutput("find /usr/share/icons -name '{}.???' | head -n1".format(r[5:]))
|
||||
if os.path.islink(path):
|
||||
os.system("cp '{}' '/gx-env/icons/{}'".format(path, os.path.basename(path)))
|
||||
newInfo += "Icon=/opt/new-system-env/gx-env/icons/" + os.path.basename(path) + "\n"
|
||||
else:
|
||||
newInfo += "Icon=/opt/new-system-env/" + path + "\n"
|
||||
else:
|
||||
newInfo += r + "\n"
|
||||
print(newInfo)
|
||||
print(i)
|
||||
with open("/gx-env/desktop/gx-env-{}".format(i), "w") as file:
|
||||
file.write(newInfo)
|
12
deb/usr/bin/gx-env-mount-root
Executable file
12
deb/usr/bin/gx-env-mount-root
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
if [[ `whoami` != "root" ]]; then
|
||||
echo 请使用 root 权限运行
|
||||
exit 1
|
||||
fi
|
||||
xhost +
|
||||
chrootEnvPath=/opt/new-system-env
|
||||
rm $chrootEnvPath/etc/resolv.conf
|
||||
cp /etc/resolv.conf $chrootEnvPath/etc/resolv.conf
|
||||
|
||||
#mount --bind /home $chrootEnvPath/home
|
||||
#mount --bind /root $chrootEnvPath/root
|
26
deb/usr/bin/gx-env-run
Executable file
26
deb/usr/bin/gx-env-run
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
chrootEnvPath=/opt/new-system-env
|
||||
#if [[ `whoami` != "root" ]]; then
|
||||
# echo 请使用 root 权限运行
|
||||
# exit 1
|
||||
#fi
|
||||
if [[ ! -f ~/.config/gx-env/chroot ]]; then
|
||||
if [[ `whoami` != root ]]; then
|
||||
if [[ ! -f $chrootEnvPath/user/$USER ]]; then
|
||||
gx-env-init
|
||||
fi
|
||||
fi
|
||||
bwrap --dev-bind / / --dev-bind $chrootEnvPath/etc /etc --dev-bind $chrootEnvPath/opt /opt --dev-bind $chrootEnvPath/usr /usr --dev-bind $chrootEnvPath/var /var --dev-bind $chrootEnvPath/bin /bin --dev-bind $chrootEnvPath/boot /boot --dev-bind $chrootEnvPath/lib /lib --dev-bind $chrootEnvPath/lib32 /lib32 --dev-bind $chrootEnvPath/lib64 /lib64 --dev-bind $chrootEnvPath/libx32 /libx32 --dev-bind $chrootEnvPath/gx-env /gx-env --dev-bind /etc/resolv.conf /etc/resolv.conf "$@"
|
||||
#pkexec env `` gx-env-load-desktop
|
||||
exit
|
||||
fi
|
||||
echo aa > /tmp/env-$USER.txt
|
||||
if [[ ! -f $chrootEnvPath/tmp/env-$USER.txt ]]; then
|
||||
echo 未挂载目录,立即挂载
|
||||
gx-env-init
|
||||
fi
|
||||
command="$@"
|
||||
#echo $command
|
||||
pkexec env `printenv` chroot $chrootEnvPath sudo -u $USER bash -c "$command"
|
||||
#echo $@
|
||||
#pkexec gx-env-load-desktop
|
51
deb/usr/bin/gx-env-run-gui
Executable file
51
deb/usr/bin/gx-env-run-gui
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import PyQt5.QtWidgets as QtWidgets
|
||||
|
||||
def RunProgram():
|
||||
window.hide()
|
||||
if os.system("which gx-env-run"):
|
||||
QtWidgets.QMessageBox.critical(window, "错误", "gx-env-run 不存在!")
|
||||
return
|
||||
if runProgramWithRoot.isChecked():
|
||||
if os.getenv("HOME") + "/.config/gx-env/bwrap":
|
||||
envDist = os.environ
|
||||
envSet = "DISPLAY=$DISPLAY "
|
||||
for i in envDist:
|
||||
envSet += "{}=${} ".format(i, i)
|
||||
os.system("pkexec env " + envSet + " gx-env-run " + programPath.text())
|
||||
return
|
||||
else:
|
||||
os.system("gx-env-run-root " + programPath.text())
|
||||
return
|
||||
os.system("gx-env-run " + programPath.text())
|
||||
sys.exit(0)
|
||||
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
window = QtWidgets.QMainWindow()
|
||||
widget = QtWidgets.QWidget()
|
||||
layout = QtWidgets.QGridLayout()
|
||||
|
||||
programPath = QtWidgets.QLineEdit()
|
||||
browser = QtWidgets.QPushButton("浏览……")
|
||||
runProgramWithRoot = QtWidgets.QCheckBox("以 root 权限运行应用")
|
||||
layout.addWidget(QtWidgets.QLabel("""你可以在兼容模式下运行程序"""), 0, 0, 1, 4)
|
||||
layout.addWidget(QtWidgets.QLabel("程序路径:"), 1, 0)
|
||||
layout.addWidget(programPath, 1, 1, 1, 3)
|
||||
#layout.addWidget(browser, 1, 3)
|
||||
|
||||
controlLayout = QtWidgets.QHBoxLayout()
|
||||
cancelButton = QtWidgets.QPushButton("取消")
|
||||
okButton = QtWidgets.QPushButton("确定")
|
||||
okButton.clicked.connect(RunProgram)
|
||||
controlLayout.addWidget(runProgramWithRoot)
|
||||
controlLayout.addWidget(browser)
|
||||
controlLayout.addWidget(cancelButton)
|
||||
controlLayout.addWidget(okButton)
|
||||
layout.addLayout(controlLayout, 2, 2, 1, 2)
|
||||
|
||||
widget.setLayout(layout)
|
||||
window.setCentralWidget(widget)
|
||||
window.show()
|
||||
sys.exit(app.exec_())
|
26
deb/usr/bin/gx-env-run-root
Executable file
26
deb/usr/bin/gx-env-run-root
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
chrootEnvPath=/opt/new-system-env
|
||||
#if [[ `whoami` != "root" ]]; then
|
||||
# echo 请使用 root 权限运行
|
||||
# exit 1
|
||||
#fi
|
||||
if [[ ! -f ~/.config/gx-env/chroot ]]; then
|
||||
#if [[ `whoami` != root ]]; then
|
||||
# if [[ ! -d $chrootEnvPath/home/$USER ]]; then
|
||||
# pkexec env `printenv` gx-env-init
|
||||
# fi
|
||||
#fi
|
||||
pkexec env `printenv` bwrap --dev-bind / / --dev-bind $chrootEnvPath/etc /etc --dev-bind $chrootEnvPath/opt /opt --dev-bind $chrootEnvPath/usr /usr --dev-bind $chrootEnvPath/var /var --dev-bind $chrootEnvPath/bin /bin --dev-bind $chrootEnvPath/boot /boot --dev-bind $chrootEnvPath/lib /lib --dev-bind $chrootEnvPath/lib32 /lib32 --dev-bind $chrootEnvPath/lib64 /lib64 --dev-bind $chrootEnvPath/libx32 /libx32 --dev-bind $chrootEnvPath/gx-env /gx-env --dev-bind /etc/resolv.conf /etc/resolv.conf "$@"
|
||||
#pkexec gx-env-load-desktop
|
||||
exit
|
||||
fi
|
||||
echo aa > /tmp/env-$USER.txt
|
||||
if [[ ! -f $chrootEnvPath/tmp/env-$USER.txt ]]; then
|
||||
echo 未挂载目录,立即挂载
|
||||
pkexec env `printenv` gx-env-mount-root
|
||||
fi
|
||||
command="$@"
|
||||
#echo $command
|
||||
pkexec env `printenv` chroot $chrootEnvPath "$@"
|
||||
#pkexec gx-env-load-desktop
|
||||
#echo $@
|
0
deb/usr/bin/gx-env-runner_1.0.0_all.deb
Normal file
0
deb/usr/bin/gx-env-runner_1.0.0_all.deb
Normal file
57
deb/usr/bin/gx-env-setting-gui
Executable file
57
deb/usr/bin/gx-env-setting-gui
Executable file
@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
import threading
|
||||
import PyQt5.QtWidgets as QtWidgets
|
||||
|
||||
homePath = os.getenv("HOME")
|
||||
if not os.path.exists("{}/.config/gx-env/".format(homePath)):
|
||||
os.makedirs("{}/.config/gx-env/".format(homePath))
|
||||
|
||||
def Save():
|
||||
try:
|
||||
if allCommandAddNoSandbox.isChecked() and not os.path.exists("{}/.config/gx-env/nosandbox".format(homePath)):
|
||||
os.mknod("{}/.config/gx-env/nosandbox".format(homePath))
|
||||
if allCommandAddNoSandbox.isChecked() and not os.path.exists("{}/.config/gx-env/nosandbox".format(homePath)):
|
||||
os.remove("{}/.config/gx-env/nosandbox".format(homePath))
|
||||
os.system("pkexec env `printenv` gx-env-run")
|
||||
QtWidgets.QMessageBox.information(window, "提示", "设置完成!")
|
||||
|
||||
except:
|
||||
traceback.print_exc()
|
||||
QtWidgets.QMessageBox.critical(window, "错误", traceback.print_exc())
|
||||
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
window = QtWidgets.QMainWindow()
|
||||
widget = QtWidgets.QWidget()
|
||||
layout = QtWidgets.QGridLayout()
|
||||
sparkStoreRun = QtWidgets.QPushButton("打开星火应用商店")
|
||||
gdebiRun = QtWidgets.QPushButton("安装 deb 包")
|
||||
xfce4TerminalRun = QtWidgets.QPushButton("终端")
|
||||
xfce4TerminalRootRun = QtWidgets.QPushButton("终端(root)")
|
||||
sparkStoreRun.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-run-root spark-store --no-sandbox ; gx-env-load-desktop"]).start())
|
||||
gdebiRun.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-run-root gdebi ; gx-env-load-desktop"]).start())
|
||||
xfce4TerminalRun.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-run xfce4-terminal"]).start())
|
||||
xfce4TerminalRootRun.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-run-root xfce4 ; gx-env-load-desktop"]).start())
|
||||
allCommandAddNoSandbox = QtWidgets.QCheckBox("程序默认添加 --no-sandbox 参数")
|
||||
allCommandAddNoSandbox.setChecked(os.path.exists("{}/.config/gx-env/nosandbox".format(homePath)))
|
||||
runMoreProgram = QtWidgets.QPushButton("运行更多")
|
||||
runMoreProgram.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-run-gui"]).start())
|
||||
refreshDesktop = QtWidgets.QPushButton("刷新启动器图标")
|
||||
refreshDesktop.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-load-desktop"]).start())
|
||||
saveButton = QtWidgets.QPushButton("保存")
|
||||
saveButton.clicked.connect(Save)
|
||||
layout.addWidget(sparkStoreRun, 0, 0)
|
||||
layout.addWidget(gdebiRun, 0, 1)
|
||||
layout.addWidget(xfce4TerminalRun, 0, 2)
|
||||
layout.addWidget(xfce4TerminalRootRun, 0, 3)
|
||||
layout.addWidget(xfce4TerminalRootRun, 0, 3)
|
||||
layout.addWidget(runMoreProgram, 0, 4)
|
||||
layout.addWidget(refreshDesktop, 0, 5)
|
||||
layout.addWidget(allCommandAddNoSandbox, 1, 0, 1, 5)
|
||||
layout.addWidget(saveButton, 1, 5)
|
||||
widget.setLayout(layout)
|
||||
window.setCentralWidget(widget)
|
||||
window.show()
|
||||
sys.exit(app.exec_())
|
8
deb/usr/share/applications/gx-env-setting.desktop
Normal file
8
deb/usr/share/applications/gx-env-setting.desktop
Normal file
@ -0,0 +1,8 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
X-Categories=System;
|
||||
Exec=gx-env-setting-gui
|
||||
Icon=settings
|
||||
Name=兼容环境设置
|
||||
Terminal=false
|
||||
StartupNotify=true
|
21
deb/usr/share/polkit-1/actions/gx.env.pkexec.cp.policy
Normal file
21
deb/usr/share/polkit-1/actions/gx.env.pkexec.cp.policy
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE policyconfig PUBLIC
|
||||
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
|
||||
<policyconfig>
|
||||
<vendor>gfdgd xi</vendor>
|
||||
<vendor_url>https://gitee.com/gfdgd-xi/uengine-runner/</vendor_url>
|
||||
<action id="gx.env.pkexec.cp">
|
||||
<message>Authentication is required to Run App</message>
|
||||
<message xml:lang="zh_CN">使用对应的程序需要输入密码</message>
|
||||
<icon_name>preferences-system</icon_name>
|
||||
<defaults>
|
||||
<allow_any>yes</allow_any>
|
||||
<allow_inactive>yes</allow_inactive>
|
||||
<allow_active>yes</allow_active>
|
||||
</defaults>
|
||||
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/cp</annotate>
|
||||
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
|
||||
</action>
|
||||
|
||||
</policyconfig>
|
21
deb/usr/share/polkit-1/actions/gx.env.pkexec.env.policy
Normal file
21
deb/usr/share/polkit-1/actions/gx.env.pkexec.env.policy
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE policyconfig PUBLIC
|
||||
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
|
||||
<policyconfig>
|
||||
<vendor>gfdgd xi</vendor>
|
||||
<vendor_url>https://gitee.com/gfdgd-xi/uengine-runner/</vendor_url>
|
||||
<action id="gx.env.pkexec.env">
|
||||
<message>Authentication is required to Run App</message>
|
||||
<message xml:lang="zh_CN">使用对应的程序需要输入密码</message>
|
||||
<icon_name>preferences-system</icon_name>
|
||||
<defaults>
|
||||
<allow_any>yes</allow_any>
|
||||
<allow_inactive>yes</allow_inactive>
|
||||
<allow_active>yes</allow_active>
|
||||
</defaults>
|
||||
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/env</annotate>
|
||||
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
|
||||
</action>
|
||||
|
||||
</policyconfig>
|
@ -9,5 +9,5 @@ if [[ $firstPWD != $secondPWD ]]; then
|
||||
zenity --error --text=密码不相同,无法继续 --no-wrap
|
||||
exit 1
|
||||
fi
|
||||
echo -e "$firstPWD\n$firstPWD\n\n\n\n\n\nY\n" | ./run-root.sh adduser `whoami`
|
||||
gx-env-run-root bash -c "echo $USER >> /etc/sudo"
|
||||
echo -e "$firstPWD\n$firstPWD\n\n\n\n\n\nY\n" | gx-env-run-root adduser $USER
|
||||
#gx-env-run-root bash -c "echo $USER >> /etc/sudo"
|
||||
|
10
gx-env-init
10
gx-env-init
@ -1,9 +1,5 @@
|
||||
#!/bin/bash
|
||||
chrootEnvPath=/opt/new-system-env
|
||||
if [[ ! -f /usr/bin/pardus-chroot ]]; then
|
||||
echo 请安装 pardus-chroot 后再试
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -d $chrootEnvPath ]]; then
|
||||
echo Chroot 环境不存在,请部署环境后再试
|
||||
exit 1
|
||||
@ -11,7 +7,7 @@ fi
|
||||
echo aa > /tmp/env-$USER.txt
|
||||
if [[ ! -f $chrootEnvPath/tmp/env-$USER.txt ]]; then
|
||||
echo 未挂载目录,立即挂载
|
||||
sudo gx-env-mount-root
|
||||
pkexec env `printenv` gx-env-mount-root
|
||||
fi
|
||||
#user=`whoami`
|
||||
if [[ ! -f $chrootEnvPath/user/$USER ]]; then
|
||||
@ -20,6 +16,6 @@ if [[ ! -f $chrootEnvPath/user/$USER ]]; then
|
||||
echo Create User Error!
|
||||
exit 1
|
||||
fi
|
||||
sudo mkdir $chrootEnvPath/user/ -p #$USER
|
||||
sudo touch $chrootEnvPath/user/$USER
|
||||
pkexec env `printenv` mkdir $chrootEnvPath/user/ -p #$USER
|
||||
pkexec env `printenv` touch $chrootEnvPath/user/$USER
|
||||
fi
|
@ -1,7 +1,11 @@
|
||||
#!/bin/bash
|
||||
chrootEnvPath=/opt/new-system-env
|
||||
gx-env-run-root python3 /gx-env/gx-env-load-desktop-in-chroot
|
||||
if [[ -f $HOME/.config/gx-env/nosandbox ]]; then
|
||||
gx-env-run-root python3 /gx-env/gx-env-load-desktop-in-chroot
|
||||
else
|
||||
gx-env-run-root python3 /gx-env/gx-env-load-desktop-in-chroot 1
|
||||
fi
|
||||
if [[ ! -d /usr/share/applications/gx-env ]]; then
|
||||
sudo mkdir /usr/share/applications/gx-env -p
|
||||
pkexec mkdir /usr/share/applications/gx-env -p
|
||||
fi
|
||||
pkexec cp $chrootEnvPath/gx-env/desktop/* /usr/share/applications/gx-env -v
|
23
gx-env-load-desktop-in-chroot
Normal file → Executable file
23
gx-env-load-desktop-in-chroot
Normal file → Executable file
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
#chrootEnvPath="/opt/new-system-env"
|
||||
@ -11,8 +12,10 @@ if not os.path.exists("/gx-env/shell"):
|
||||
if not os.path.exists("/gx-env/icons"):
|
||||
os.makedirs("/gx-env/icons")
|
||||
for i in os.listdir("{}/usr/share/applications".format(chrootEnvPath)):
|
||||
if os.path.exists("/usr/share/applications/gx-env-{}".format(i)):
|
||||
if i == "gdebi.desktop" or i == "spark-store.desktop":
|
||||
continue
|
||||
#if os.path.exists("/usr/share/applications/gx-env-{}".format(i)):
|
||||
# continue
|
||||
info = ""
|
||||
try:
|
||||
with open("{}/usr/share/applications/{}".format(chrootEnvPath, i), "r") as file:
|
||||
@ -28,8 +31,14 @@ for i in os.listdir("{}/usr/share/applications".format(chrootEnvPath)):
|
||||
if "exec=" in r.lower():
|
||||
#newInfo += "Exec=gx-env-run " + r[5:].strip() + "\n"
|
||||
with open("/gx-env/shell/gx-env-{}.sh".format(os.path.splitext(os.path.basename(i))[0]), "w") as file:
|
||||
program = r[5:].strip()
|
||||
command = ""
|
||||
program = r[5:].strip()
|
||||
#try:
|
||||
# if sys.argv[1] == "1":
|
||||
# command += " --no-sandbox "
|
||||
#except:
|
||||
# pass
|
||||
|
||||
if "%F" in program:
|
||||
program = program.replace("%F", "$1")
|
||||
command += " %F "
|
||||
@ -42,7 +51,13 @@ for i in os.listdir("{}/usr/share/applications".format(chrootEnvPath)):
|
||||
if "%U" in program:
|
||||
program = program.replace("%U", "$4")
|
||||
command += " %U "
|
||||
file.write("#!/bin/bash\n" + program)
|
||||
try:
|
||||
if sys.argv[1] == "1":
|
||||
file.write("#!/bin/bash\n" + program + " --no-sandbox")
|
||||
else:
|
||||
file.write("#!/bin/bash\n" + program)
|
||||
except:
|
||||
file.write("#!/bin/bash\n" + program)
|
||||
newInfo += "Exec=gx-env-run bash \"/gx-env/shell/gx-env-{}.sh\" {} \n".format(os.path.splitext(os.path.basename(i))[0], command)
|
||||
elif "name=" in r.lower() or "name[" in r.lower():
|
||||
newInfo += r + "(兼容模式)\n"
|
||||
@ -61,4 +76,4 @@ for i in os.listdir("{}/usr/share/applications".format(chrootEnvPath)):
|
||||
print(newInfo)
|
||||
print(i)
|
||||
with open("/gx-env/desktop/gx-env-{}".format(i), "w") as file:
|
||||
file.write(newInfo)
|
||||
file.write(newInfo)
|
||||
|
@ -5,8 +5,8 @@ if [[ `whoami` != "root" ]]; then
|
||||
fi
|
||||
xhost +
|
||||
chrootEnvPath=/opt/new-system-env
|
||||
pardus-chroot $chrootEnvPath
|
||||
rm $chrootEnvPath/etc/resolv.conf
|
||||
cp /etc/resolv.conf $chrootEnvPath/etc/resolv.conf
|
||||
mount --bind /home $chrootEnvPath/home
|
||||
mount --bind /root $chrootEnvPath/root
|
||||
|
||||
#mount --bind /home $chrootEnvPath/home
|
||||
#mount --bind /root $chrootEnvPath/root
|
11
gx-env-run
11
gx-env-run
@ -4,15 +4,20 @@ chrootEnvPath=/opt/new-system-env
|
||||
# echo 请使用 root 权限运行
|
||||
# exit 1
|
||||
#fi
|
||||
if [[ -f ~/.config/gx-env/bwrap ]]; then
|
||||
bwrap --dev-bind / / --dev-bind $chrootEnvPath/etc /etc --dev-bind $chrootEnvPath/opt /opt --dev-bind $chrootEnvPath/usr /usr --dev-bind $chrootEnvPath/var /var --dev-bind $chrootEnvPath/bin /bin --dev-bind $chrootEnvPath/boot /boot --dev-bind $chrootEnvPath/lib /lib --dev-bind $chrootEnvPath/lib32 /lib32 --dev-bind $chrootEnvPath/lib64 /lib64 --dev-bind $chrootEnvPath/libx32 /libx32 --dev-bind $chrootEnvPath/gx-env /gx-env "$@"
|
||||
if [[ ! -f ~/.config/gx-env/chroot ]]; then
|
||||
if [[ `whoami` != root ]]; then
|
||||
if [[ ! -f $chrootEnvPath/user/$USER ]]; then
|
||||
gx-env-init
|
||||
fi
|
||||
fi
|
||||
bwrap --dev-bind / / --dev-bind $chrootEnvPath/etc /etc --dev-bind $chrootEnvPath/opt /opt --dev-bind $chrootEnvPath/usr /usr --dev-bind $chrootEnvPath/var /var --dev-bind $chrootEnvPath/bin /bin --dev-bind $chrootEnvPath/boot /boot --dev-bind $chrootEnvPath/lib /lib --dev-bind $chrootEnvPath/lib32 /lib32 --dev-bind $chrootEnvPath/lib64 /lib64 --dev-bind $chrootEnvPath/libx32 /libx32 --dev-bind $chrootEnvPath/gx-env /gx-env --dev-bind /etc/resolv.conf /etc/resolv.conf "$@"
|
||||
#pkexec env `` gx-env-load-desktop
|
||||
exit
|
||||
fi
|
||||
echo aa > /tmp/env-$USER.txt
|
||||
if [[ ! -f $chrootEnvPath/tmp/env-$USER.txt ]]; then
|
||||
echo 未挂载目录,立即挂载
|
||||
pkexec env `printenv` gx-env-init
|
||||
gx-env-init
|
||||
fi
|
||||
command="$@"
|
||||
#echo $command
|
||||
|
0
gx-env-run-gui
Normal file → Executable file
0
gx-env-run-gui
Normal file → Executable file
@ -4,8 +4,13 @@ chrootEnvPath=/opt/new-system-env
|
||||
# echo 请使用 root 权限运行
|
||||
# exit 1
|
||||
#fi
|
||||
if [[ -f ~/.config/gx-env/bwrap ]]; then
|
||||
pkexec env `printenv` bwrap --dev-bind / / --dev-bind $chrootEnvPath/etc /etc --dev-bind $chrootEnvPath/opt /opt --dev-bind $chrootEnvPath/usr /usr --dev-bind $chrootEnvPath/var /var --dev-bind $chrootEnvPath/bin /bin --dev-bind $chrootEnvPath/boot /boot --dev-bind $chrootEnvPath/lib /lib --dev-bind $chrootEnvPath/lib32 /lib32 --dev-bind $chrootEnvPath/lib64 /lib64 --dev-bind $chrootEnvPath/libx32 /libx32 --dev-bind $chrootEnvPath/gx-env /gx-env "$@"
|
||||
if [[ ! -f ~/.config/gx-env/chroot ]]; then
|
||||
#if [[ `whoami` != root ]]; then
|
||||
# if [[ ! -d $chrootEnvPath/home/$USER ]]; then
|
||||
# pkexec env `printenv` gx-env-init
|
||||
# fi
|
||||
#fi
|
||||
pkexec env `printenv` bwrap --dev-bind / / --dev-bind $chrootEnvPath/etc /etc --dev-bind $chrootEnvPath/opt /opt --dev-bind $chrootEnvPath/usr /usr --dev-bind $chrootEnvPath/var /var --dev-bind $chrootEnvPath/bin /bin --dev-bind $chrootEnvPath/boot /boot --dev-bind $chrootEnvPath/lib /lib --dev-bind $chrootEnvPath/lib32 /lib32 --dev-bind $chrootEnvPath/lib64 /lib64 --dev-bind $chrootEnvPath/libx32 /libx32 --dev-bind $chrootEnvPath/gx-env /gx-env --dev-bind /etc/resolv.conf /etc/resolv.conf "$@"
|
||||
#pkexec gx-env-load-desktop
|
||||
exit
|
||||
fi
|
||||
|
2
gx-env-run-terminal
Executable file
2
gx-env-run-terminal
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
gx-env-run xfce4-terminal
|
38
gx-env-setting-gui
Normal file → Executable file
38
gx-env-setting-gui
Normal file → Executable file
@ -1,9 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
import threading
|
||||
import PyQt5.QtWidgets as QtWidgets
|
||||
|
||||
homePath = os.getenv("HOME")
|
||||
if not os.path.exists("{}/.config/gx-env/".format(homePath)):
|
||||
os.makedirs("{}/.config/gx-env/".format(homePath))
|
||||
|
||||
def Save():
|
||||
try:
|
||||
if allCommandAddNoSandbox.isChecked() and not os.path.exists("{}/.config/gx-env/nosandbox".format(homePath)):
|
||||
os.mknod("{}/.config/gx-env/nosandbox".format(homePath))
|
||||
if allCommandAddNoSandbox.isChecked() and not os.path.exists("{}/.config/gx-env/nosandbox".format(homePath)):
|
||||
os.remove("{}/.config/gx-env/nosandbox".format(homePath))
|
||||
os.system("pkexec env `printenv` gx-env-run")
|
||||
QtWidgets.QMessageBox.information(window, "提示", "设置完成!")
|
||||
|
||||
except:
|
||||
traceback.print_exc()
|
||||
QtWidgets.QMessageBox.critical(window, "错误", traceback.print_exc())
|
||||
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
window = QtWidgets.QMainWindow()
|
||||
@ -13,15 +30,28 @@ sparkStoreRun = QtWidgets.QPushButton("打开星火应用商店")
|
||||
gdebiRun = QtWidgets.QPushButton("安装 deb 包")
|
||||
xfce4TerminalRun = QtWidgets.QPushButton("终端")
|
||||
xfce4TerminalRootRun = QtWidgets.QPushButton("终端(root)")
|
||||
sparkStoreRun.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-run-root spark-store --no-sandbox ; pkexec env `printenv` gx-env-run"]).start())
|
||||
gdebiRun.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-run-root gdebi ; pkexec env `printenv` gx-env-run"]).start())
|
||||
sparkStoreRun.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-run-root spark-store --no-sandbox ; gx-env-load-desktop"]).start())
|
||||
gdebiRun.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-run-root gdebi ; gx-env-load-desktop"]).start())
|
||||
xfce4TerminalRun.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-run xfce4-terminal"]).start())
|
||||
xfce4TerminalRootRun.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-run-root xfce4 ; pkexec env `printenv` gx-env-run"]).start())
|
||||
xfce4TerminalRootRun.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-run-root xfce4 ; gx-env-load-desktop"]).start())
|
||||
allCommandAddNoSandbox = QtWidgets.QCheckBox("程序默认添加 --no-sandbox 参数")
|
||||
allCommandAddNoSandbox.setChecked(os.path.exists("{}/.config/gx-env/nosandbox".format(homePath)))
|
||||
runMoreProgram = QtWidgets.QPushButton("运行更多")
|
||||
runMoreProgram.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-run-gui"]).start())
|
||||
refreshDesktop = QtWidgets.QPushButton("刷新启动器图标")
|
||||
refreshDesktop.clicked.connect(lambda: threading.Thread(target=os.system, args=["gx-env-load-desktop"]).start())
|
||||
saveButton = QtWidgets.QPushButton("保存")
|
||||
saveButton.clicked.connect(Save)
|
||||
layout.addWidget(sparkStoreRun, 0, 0)
|
||||
layout.addWidget(gdebiRun, 0, 1)
|
||||
layout.addWidget(xfce4TerminalRun, 0, 2)
|
||||
layout.addWidget(xfce4TerminalRootRun, 0, 3)
|
||||
layout.addWidget(xfce4TerminalRootRun, 0, 3)
|
||||
layout.addWidget(runMoreProgram, 0, 4)
|
||||
layout.addWidget(refreshDesktop, 0, 5)
|
||||
layout.addWidget(allCommandAddNoSandbox, 1, 0, 1, 5)
|
||||
layout.addWidget(saveButton, 1, 5)
|
||||
widget.setLayout(layout)
|
||||
window.setCentralWidget(widget)
|
||||
window.show()
|
||||
sys.exit(app.exec_())
|
||||
sys.exit(app.exec_())
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
#exit
|
||||
set +e
|
||||
DESTDIR="$1"
|
||||
if [[ $UID -ne 0 ]] ; then
|
||||
|
21
pkexec/gx.env.pkexec.cp.policy
Normal file
21
pkexec/gx.env.pkexec.cp.policy
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE policyconfig PUBLIC
|
||||
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
|
||||
<policyconfig>
|
||||
<vendor>gfdgd xi</vendor>
|
||||
<vendor_url>https://gitee.com/gfdgd-xi/uengine-runner/</vendor_url>
|
||||
<action id="gx.env.pkexec.cp">
|
||||
<message>Authentication is required to Run App</message>
|
||||
<message xml:lang="zh_CN">使用对应的程序需要输入密码</message>
|
||||
<icon_name>preferences-system</icon_name>
|
||||
<defaults>
|
||||
<allow_any>yes</allow_any>
|
||||
<allow_inactive>yes</allow_inactive>
|
||||
<allow_active>yes</allow_active>
|
||||
</defaults>
|
||||
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/cp</annotate>
|
||||
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
|
||||
</action>
|
||||
|
||||
</policyconfig>
|
21
pkexec/gx.env.pkexec.env.policy
Normal file
21
pkexec/gx.env.pkexec.env.policy
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE policyconfig PUBLIC
|
||||
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
|
||||
<policyconfig>
|
||||
<vendor>gfdgd xi</vendor>
|
||||
<vendor_url>https://gitee.com/gfdgd-xi/uengine-runner/</vendor_url>
|
||||
<action id="gx.env.pkexec.env">
|
||||
<message>Authentication is required to Run App</message>
|
||||
<message xml:lang="zh_CN">使用对应的程序需要输入密码</message>
|
||||
<icon_name>preferences-system</icon_name>
|
||||
<defaults>
|
||||
<allow_any>yes</allow_any>
|
||||
<allow_inactive>yes</allow_inactive>
|
||||
<allow_active>yes</allow_active>
|
||||
</defaults>
|
||||
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/env</annotate>
|
||||
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
|
||||
</action>
|
||||
|
||||
</policyconfig>
|
Loading…
Reference in New Issue
Block a user