pardus-chroot
This commit is contained in:
parent
366ed1d58d
commit
44923aa454
30
gui/runner.py
Normal file
30
gui/runner.py
Normal file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import PyQt5.QtWidgets as QtWidgets
|
||||
|
||||
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("确定")
|
||||
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_())
|
@ -4,12 +4,18 @@ 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 "$@"
|
||||
pkexec gx-env-load-desktop
|
||||
exit
|
||||
fi
|
||||
echo aa > /tmp/env-$USER.txt
|
||||
if [[ ! -f $chrootEnvPath/tmp/env-$USER.txt ]]; then
|
||||
echo 未挂载目录,立即挂载
|
||||
pkexec gx-env-mount-root
|
||||
pkexec gx-env-init
|
||||
fi
|
||||
command="$@"
|
||||
#echo $command
|
||||
pkexec env DISPLAY=$DISPLAY chroot $chrootEnvPath sudo -u $USER bash -c "$command"
|
||||
#echo $@
|
||||
pkexec gx-env-load-desktop
|
38
pardus-chroot
Executable file
38
pardus-chroot
Executable file
@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
set +e
|
||||
DESTDIR="$1"
|
||||
if [[ $UID -ne 0 ]] ; then
|
||||
echo "You must be root!"
|
||||
exit 1
|
||||
fi
|
||||
if [[ -b "$1" ]] ; then
|
||||
DESTDIR=$(mktemp -d)
|
||||
mount "$1" "$DESTDIR"
|
||||
fi
|
||||
shift
|
||||
if [[ "$DESTDIR" == "" || ! -f "$DESTDIR/etc/os-release" ]] ; then
|
||||
echo "Target filesystem is invalid: $DESTDIR"
|
||||
exit 1
|
||||
fi
|
||||
mount --bind /dev "$DESTDIR/dev"
|
||||
mount --bind /run "$DESTDIR/run"
|
||||
mount --bind /media "$DESTDIR/media"
|
||||
mount -t devpts devpts "$DESTDIR/dev/pts"
|
||||
mount -t sysfs sysfs "$DESTDIR/sys"
|
||||
mount -t proc proc "$DESTDIR/proc"
|
||||
mount -t tmpfs tmpfs "$DESTDIR/dev/shm"
|
||||
mount --bind /tmp "$DESTDIR/tmp"
|
||||
if [[ -d /sys/firmware/efi/ ]] ; then
|
||||
mount -t efivarfs efivarfs "$DESTDIR/sys/firmware/efi/efivars"
|
||||
fi
|
||||
#cat /etc/resolv.conf > $DESTDIR/etc/resolv.conf
|
||||
#SHELL=/bin/bash unshare --fork --pid chroot "$DESTDIR" "$@"
|
||||
#exit
|
||||
# 下面的因为有问题,不使用
|
||||
#if [[ -d /sys/firmware/efi/ ]] ; then
|
||||
# while umount "$DESTDIR/sys/firmware/efi/efivars" 2>/dev/null ; do : ;done
|
||||
#fi
|
||||
#for dir in dev/pts dev/shm dev sys proc run media ; do
|
||||
# while umount "$DESTDIR/$dir" 2>/dev/null; do : ;done
|
||||
#done
|
||||
#umount -lf "$DESTDIR" 2>/dev/null
|
Loading…
x
Reference in New Issue
Block a user