diff --git a/src/DEBIAN/control b/src/DEBIAN/control index eb0180b..a7df52d 100755 --- a/src/DEBIAN/control +++ b/src/DEBIAN/control @@ -1,5 +1,5 @@ Package: cn.flamescion.bookworm-compatibility-mode -Version: 12.4.9 +Version: 12.4.10 Section: misc Priority: optional Depends: bubblewrap,flatpak,zenity,policykit-1,gcc,systemd diff --git a/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/ace-uninstall-helper b/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/ace-uninstall-helper index 0bc7d84..814dde5 100755 --- a/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/ace-uninstall-helper +++ b/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/ace-uninstall-helper @@ -25,8 +25,13 @@ fi # 验证是否为desktop文件 if [[ ! $ABSOLUTE_PATH == *.desktop ]]; then - echo "Error: The file is not a desktop file." - exit 1 + if [ ! -e $ABSOLUTE_PATH ];then + echo "$ABSOLUTE_PATH does not exist. May have already been uninstalled. Ignore it." + exit + else + echo "Error: The file is not a desktop file." + exit 1 + fi fi # 截取路径 diff --git a/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/bookworm-init b/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/bookworm-init index d02265f..65c586f 100755 --- a/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/bookworm-init +++ b/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/bookworm-init @@ -354,4 +354,4 @@ sudo -u $(who | awk '{print $1}' | head -n 1) bwrap --dev-bind $chrootEnvPath/ / locale-gen chown -R root $chrootEnvPath - +chmod 777 -R $chrootEnvPath /usr/share/icons diff --git a/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/bookworm-run b/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/bookworm-run index 0ab67fd..28a690f 100755 --- a/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/bookworm-run +++ b/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/bookworm-run @@ -8,12 +8,6 @@ PKGNAME=`basename $ppparent_dir` export PACKAGE_NAME=$PKGNAME chrootEnvPath=/opt/apps/$PKGNAME/files/bookworm-env - -if [ "$(id -u)" = "0" ]; then -`dirname $chrootEnvPath`/bin/bookworm-run-root "$@" -exit -fi - if [ ! -e $chrootEnvPath/finish.flag ];then if [ "$(id -u)" = "0" ]; then @@ -40,39 +34,117 @@ for arg in "$@"; do container_command="${container_command} '${arg}'" done fi +######################################################################################### +##########合成bwrap 1. 基础函数配置段 +# 初始化 EXEC_COMMAND 为 bwrap 基础指令 +EXEC_COMMAND="bwrap --dev-bind / / bwrap" + +# add_command 函数定义 +function add_command() { + # 参数拼接,考虑到转义和空格的处理 + for arg in "$@"; do + EXEC_COMMAND="${EXEC_COMMAND} ${arg}" + done +} + +function add_env_var() { + local var_name="${1}" + local var_value="${2}" + if [ "$var_value" != "" ]; then + add_command "--setenv $var_name $var_value" + + fi +} +##########合成bwrap 2. 特殊需求函数配置段 +function cursor_theme_dir_integration() { + +local directory="" +if [ "$(id -u)" = "0" ]; then #####We don't want bother root to install themes,but will try to fix the unwriteable issue + mkdir -p $chrootEnvPath/usr/share/icons + chmod 777 -R $chrootEnvPath/usr/share/icons + return +fi + +for directory in "/usr/share/icons"/*; do + # 检查是否为目录 + if [ -d "$directory" ]; then + # 检查目录中是否存在 cursors 文件 + if [ -d "$directory/cursors" ]; then + if [ -w $chrootEnvPath/usr/share/icons ];then + add_command "--ro-bind-try $directory $directory" + fi + fi + fi +done -bwrap --dev-bind / / \ - bwrap \ - --setenv LANG "$LANG" \ - --setenv LC_COLLATE "$LC_COLLATE" \ - --setenv LC_CTYPE "$LC_CTYPE" \ - --setenv LC_MONETARY "$LC_MONETARY" \ - --setenv LC_MESSAGES "$LC_MESSAGES" \ - --setenv LC_NUMERIC "$LC_NUMERIC" \ - --setenv LC_TIME "$LC_TIME" \ - --setenv LC_ALL "$LC_ALL" \ - --setenv PULSE_SERVER /run/user/$uid/pulse/native \ - --setenv PATH /flamescion-container-tools/bin-override:$PATH \ - --setenv IS_ACE_ENV "1" \ - --dev-bind $chrootEnvPath/ / \ - --dev-bind-try /media /media \ - --dev-bind-try /tmp /tmp \ - --dev /dev \ - --dev-bind-try /dev/dri /dev/dri \ - --proc /proc \ - --dev-bind /sys /sys \ - --dev-bind /run /run \ - --dev-bind-try /run/user/$uid/pulse /run/user/$uid/pulse \ - --dev-bind / /host \ - --ro-bind-try /usr/share/themes /usr/local/share/themes \ - --ro-bind-try /usr/share/icons /usr/local/share/icons \ - --ro-bind-try /usr/share/fonts /usr/local/share/fonts \ - --hostname Amber-CE-Bookworm \ - --unshare-uts \ - --dev-bind-try /etc/resolv.conf /etc/resolv.conf \ - --cap-add CAP_SYS_ADMIN \ - --dev-bind-try /home /home \ - bash -c "${container_command}" + + + + + +} +##########合成bwrap 3. 环境变量和目录绑定配置段 +# 添加环境变量和其他初始设置 +ENV_VARS=( + "LANG $LANG" + "LC_COLLATE $LC_COLLATE" + "LC_CTYPE $LC_CTYPE" + "LC_MONETARY $LC_MONETARY" + "LC_MESSAGES $LC_MESSAGES" + "LC_NUMERIC $LC_NUMERIC" + "LC_TIME $LC_TIME" + "LC_ALL $LC_ALL" + "PULSE_SERVER /run/user/\$uid/pulse/native" + "PATH /flamescion-container-tools/bin-override:\$PATH" + "IS_ACE_ENV 1" +) + +BIND_DIRS=( + "--dev-bind $chrootEnvPath/ /" + "--dev-bind-try /media /media" + "--dev-bind-try /tmp /tmp" + "--dev /dev" + "--dev-bind-try /dev/dri /dev/dri" + "--proc /proc" + "--dev-bind /sys /sys" + "--dev-bind /run /run" + "--dev-bind-try /run/user/\$uid/pulse /run/user/\$uid/pulse" + "--dev-bind / /host" + "--ro-bind-try /usr/share/themes /usr/local/share/themes" + "--ro-bind-try /usr/share/icons /usr/local/share/icons" + "--ro-bind-try /usr/share/fonts /usr/local/share/fonts" + "--hostname Amber-CE-Bookworm" + "--unshare-uts" + "--dev-bind-try /etc/resolv.conf /etc/resolv.conf" + "--cap-add CAP_SYS_ADMIN" + "--dev-bind-try /home /home" +) +EXTRA_SCRIPTS=( + cursor_theme_dir_integration +) + +##########合成bwrap 4. 合成并执行指令 +# 逐一添加到 EXEC_COMMAND +for var in "${ENV_VARS[@]}"; do + add_env_var $var +done + +for var in "${BIND_DIRS[@]}"; do + add_command "$var" +done + +for var in "${EXTRA_SCRIPTS[@]}"; do + $var +done + +# 添加最终的 bash 命令 +add_command "bash -c \"${container_command}\"" + +# 输出完整的 EXEC_COMMAND 以查看 +# echo "${EXEC_COMMAND}" + +# 注意: 实际执行时,请确保所有变量(如 $uid, $chrootEnvPath 等)都已正确定义 +eval ${EXEC_COMMAND} diff --git a/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/bookworm-run-root b/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/bookworm-run-root deleted file mode 100755 index 7a81a20..0000000 --- a/src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/bookworm-run-root +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash -if [ "$(id -u)" != "0" ]; then - echo "当前用户不是 root 用户,退出" - exit -fi - -curdir=`realpath $0` -parent_dir=`dirname $curdir` -pparent_dir=`dirname $parent_dir` -ppparent_dir=`dirname $pparent_dir` -PKGNAME=`basename $ppparent_dir` -export PACKAGE_NAME=$PKGNAME -chrootEnvPath=/opt/apps/$PKGNAME/files/bookworm-env - - -if [ ! -e $chrootEnvPath/finish.flag ];then - -if [ "$(id -u)" = "0" ]; then - `dirname $chrootEnvPath`/bin/bookworm-init -else -pkexec `dirname $chrootEnvPath`/bin/bookworm-init -fi - - -fi -non_root_user=$(who | awk '{print $1}' | head -n 1) -uid=$(id -u $non_root_user) - - -#### This part is for args pharm -if [ "$1" = "" ];then -container_command="bash" -else -container_command="$1" -shift -for arg in "$@"; do - arg="$(echo "${arg}x" | sed 's|'\''|'\'\\\\\'\''|g')" - arg="${arg%x}" - container_command="${container_command} '${arg}'" -done -fi - - -bwrap --dev-bind / / \ - bwrap \ - --setenv LANG "$LANG" \ - --setenv LC_COLLATE "$LC_COLLATE" \ - --setenv LC_CTYPE "$LC_CTYPE" \ - --setenv LC_MONETARY "$LC_MONETARY" \ - --setenv LC_MESSAGES "$LC_MESSAGES" \ - --setenv LC_NUMERIC "$LC_NUMERIC" \ - --setenv LC_TIME "$LC_TIME" \ - --setenv LC_ALL "$LC_ALL" \ - --setenv PULSE_SERVER /run/user/$uid/pulse/native \ - --setenv PATH /flamescion-container-tools/bin-override:$PATH \ - --setenv IS_ACE_ENV "1" \ - --dev-bind $chrootEnvPath/ / \ - --dev-bind-try /media /media \ - --dev-bind-try /tmp /tmp \ - --dev /dev \ - --dev-bind-try /dev/dri /dev/dri \ - --proc /proc \ - --dev-bind /sys /sys \ - --dev-bind /run /run \ - --dev-bind-try /run/user/$uid/pulse /run/user/$uid/pulse \ - --dev-bind / /host \ - --bind-try /usr/share/themes /usr/local/share/themes \ - --bind-try /usr/share/icons /usr/local/share/icons \ - --bind-try /usr/share/fonts /usr/local/share/fonts \ - --hostname Amber-CE-Bookworm \ - --unshare-uts \ - --dev-bind-try /etc/resolv.conf /etc/resolv.conf \ - --cap-add CAP_SYS_ADMIN \ - --dev-bind-try /home /home \ - bash -c "${container_command}" - - -