deep-wine-runner/WineLib/run.sh

87 lines
2.7 KiB
Bash
Raw Normal View History

2023-07-10 22:35:54 +08:00
#!/bin/bash
CURRENT_DIR=$(cd $(dirname $0); pwd)
2023-07-11 15:08:28 +08:00
if [[ ! -d "$CURRENT_DIR/usr" ]]; then
zenity --info --text=未安装运行库,无法运行 --no-wrap
exit
fi
2023-07-11 20:58:17 +08:00
systemNeedCommand=""
for libr in `ls /usr/lib`
do
if [[ -f /usr/lib/$libr/libc.so.6 ]]; then
if [[ ! -f "$CURRENT_DIR/usr/lib/$libr/libc.so.6" ]]; then
echo $libr
systemNeedCommand="$systemNeedCommand --ro-bind /usr/lib/$libr/ /usr/lib/$libr/ "
mkdir -p "$CURRENT_DIR/usr/lib/$libr"
fi
fi
done
for libr in `ls /usr/lib/ld*.so*`
do
if [[ -f $libr ]]; then
if [[ ! -f "$CURRENT_DIR/$libr" ]]; then
systemNeedCommand="$systemNeedCommand --ro-bind $libr $libr "
touch "$CURRENT_DIR/$libr"
else
if [[ ! -s "$CURRENT_DIR/$libr" ]]; then
systemNeedCommand="$systemNeedCommand --ro-bind $libr $libr "
fi
fi
fi
done
2023-07-11 22:32:28 +08:00
if [[ -d /usr/lib64 ]] && [[ ! -d "$CURRENT_DIR/usr/lib64" ]]; then
2023-07-11 20:58:17 +08:00
mkdir -p "$CURRENT_DIR/usr/lib64"
fi
2023-07-11 22:32:28 +08:00
if [[ -d /usr/lib64/ ]]; then
for libr in `ls /usr/lib64/ld*.so*`
do
if [[ -f $libr ]]; then
if [[ ! -f "$CURRENT_DIR/$libr" ]]; then
2023-07-11 20:58:17 +08:00
systemNeedCommand="$systemNeedCommand --ro-bind $libr $libr "
2023-07-11 22:32:28 +08:00
touch "$CURRENT_DIR/$libr"
else
if [[ ! -s "$CURRENT_DIR/$libr" ]]; then
systemNeedCommand="$systemNeedCommand --ro-bind $libr $libr "
fi
2023-07-11 20:58:17 +08:00
fi
fi
2023-07-11 22:32:28 +08:00
done
fi
2023-07-11 20:58:17 +08:00
if [[ ! -d "$CURRENT_DIR/usr/lib/locale" ]]; then
systemNeedCommand="$systemNeedCommand --ro-bind /usr/lib/locale /usr/lib/locale "
fi
2023-07-11 22:32:28 +08:00
2023-07-11 18:10:51 +08:00
if [[ ! -d "$CURRENT_DIR/usr/lib64" ]]; then
bwrap --dev-bind / / \
2023-07-11 20:58:17 +08:00
--bind "$CURRENT_DIR/usr/lib" /lib \
--bind "$CURRENT_DIR/usr" /usr \
2023-07-11 18:10:51 +08:00
--ro-bind /usr/share /usr/share \
--ro-bind /usr/bin /usr/bin \
--ro-bind /usr/sbin /usr/sbin \
2023-07-11 20:58:17 +08:00
$systemNeedCommand \
2023-07-11 18:10:51 +08:00
-- "$@"
exit
fi
2023-07-11 17:19:39 +08:00
if [[ ! -f /lib64 ]] && [[ ! -d /lib64 ]] && [[ ! -L /lib64 ]]; then
2023-07-11 20:58:17 +08:00
pkexec ln -s /usr/lib64 /lib64
fi
if [[ -L /lib64 ]] || [[ -d /lib64 ]] || [[ -f /lib64 ]];then
bwrap --dev-bind / / \
--bind "$CURRENT_DIR/usr/lib" /lib \
--bind "$CURRENT_DIR/usr/lib64" /lib \
--bind "$CURRENT_DIR/usr" /usr \
--ro-bind /usr/share /usr/share \
--ro-bind /usr/bin /usr/bin \
--ro-bind /usr/sbin /usr/sbin \
$systemNeedCommand \
-- "$@"
exit
2023-07-10 22:35:54 +08:00
fi
bwrap --dev-bind / / \
2023-07-11 20:58:17 +08:00
--bind "$CURRENT_DIR/usr/lib" /lib \
--bind "$CURRENT_DIR/usr" /usr \
2023-07-10 22:35:54 +08:00
--ro-bind /usr/share /usr/share \
--ro-bind /usr/bin /usr/bin \
--ro-bind /usr/sbin /usr/sbin \
2023-07-11 20:58:17 +08:00
$systemNeedCommand \
2023-07-10 22:35:54 +08:00
-- "$@"