diff --git a/src/DEBIAN/control b/src/DEBIAN/control index 5a77580..b651f96 100755 --- a/src/DEBIAN/control +++ b/src/DEBIAN/control @@ -3,7 +3,7 @@ Source: amber-ce Version: 1.0.5 Architecture: amd64 Maintainer: shenmo -Installed-Size: 48672 +Installed-Size: 48676 Depends: bubblewrap, flatpak, zenity, policykit-1 | pkexec | polkit-1 | polkit, systemd, procps,coreutils,fuse-overlayfs Section: misc Conflicts: ace-host-integration diff --git a/src/usr/bin/apm b/src/usr/bin/apm index 13b6380..017cc82 100755 --- a/src/usr/bin/apm +++ b/src/usr/bin/apm @@ -25,9 +25,10 @@ Commands: full-upgrade 完全升级软件包 run 运行指定软件包的可执行文件 ssaudit 使用 ssaudit 进行软件安装,详情见 spark-store - debug 显示调试系统信息 + debug 显示调试系统信息并进入调试环境 + amber 彩蛋功能 -h, --help 显示此帮助信息 - --amber 彩蛋功能 + EOF } @@ -159,12 +160,12 @@ case "$1" in debug_info ;; ssaudit) - ssaudit "$@" --native + amber-pm-debug ssaudit "$@" --native ;; -h|--help) show_help ;; - --amber) + amber) amber_egg ;; *) diff --git a/src/usr/share/bash-completion/completions/apm b/src/usr/share/bash-completion/completions/apm index 34388da..3fe1688 100755 --- a/src/usr/share/bash-completion/completions/apm +++ b/src/usr/share/bash-completion/completions/apm @@ -36,7 +36,7 @@ _apm() # see if the user selected a command already local COMMANDS=( - "ssupdate" + "ssaudit" "list" "search" "show" "showsrc" @@ -48,7 +48,8 @@ _apm() "source" "build-dep" "clean" "autoclean" "download" "changelog" - "moo" + "amber" + "debug" "depends" "rdepends" "policy") diff --git a/src/var/lib/apm/apm/files/ace-run-pkg b/src/var/lib/apm/apm/files/ace-run-pkg new file mode 100755 index 0000000..2662a3e --- /dev/null +++ b/src/var/lib/apm/apm/files/ace-run-pkg @@ -0,0 +1,138 @@ +#!/bin/bash + + + +chrootEnvPath="${chrootEnvPath:-$(pwd)/ace-env}" + + + +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 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 3. 环境变量和目录绑定配置段 +# 添加环境变量和其他初始设置 +ENV_VARS=( + "FAKEROOTDONTTRYCHOWN 1" + "PULSE_SERVER /run/user/\$uid/pulse/native" + "PATH /amber-ce-tools/bin-override:\$PATH" + "IS_ACE_ENV 1" + "GTK_USE_PORTAL 1" + "XDG_DATA_DIRS /amber-ce-tools/additional-data-dir-in-container:\$XDG_DATA_DIRS" +) + +BIND_DIRS=( + "--dev-bind $chrootEnvPath/ /" + "--dev-bind-try /media /media" + "--dev-bind-try /mnt /mnt" + "--dev-bind-try /tmp /tmp" + "--dev-bind-try /data /data" + "--dev-bind-try /dev /dev" + "--proc /proc" + "--dev-bind /sys /sys" + "--dev-bind /run /run" + "--dev-bind-try /run/user/\$uid/pulse /run/user/\$uid/pulse" + "--dev-bind / /host" + "--dev-bind-try /etc/resolv.conf /etc/resolv.conf" + "--dev-bind-try /home /home" +) +EXTRA_ARGS=( + "--hostname Amber-PM" + "--unshare-uts" + "--cap-add CAP_SYS_ADMIN" +) + +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_ARGS[@]}"; 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} + +