初步支持沙箱化运行应用

This commit is contained in:
2025-11-01 00:21:27 +08:00
parent 7b8ceb8328
commit 0f9a4ed76a
5 changed files with 212 additions and 14 deletions

View File

@@ -22,6 +22,7 @@ Commands:
install 安装软件包
remove 卸载软件包
run <package> 运行指定软件包的可执行文件
sandbox-run <package> 运行指定软件包的可执行文件(主目录沙箱化)
update 更新软件包信息
hold 锁定软件包版本
@@ -53,7 +54,11 @@ apm_exec(){
local lowerdirs=()
local current_dir="${PATH_PREFIX}/var/lib/apm/${coredir}" # 当前目录开始
local next_info_file=""
if [[ "$APM_USE_SANDBOX" = "1" ]];then
APM_RUN_EXEC=/var/lib/apm/apm/files/ace-run-sandbox
else
APM_RUN_EXEC=/var/lib/apm/apm/files/ace-run
fi
while : ; do
# 构建info文件的路径
next_info_file="${current_dir}/info"
@@ -105,7 +110,7 @@ apm_exec(){
fuse-overlayfs -o lowerdir="$lowerdir",upperdir="${PATH_PREFIX}/var/lib/apm/${coredir}/files/core/",workdir="${PATH_PREFIX}/var/lib/apm/${coredir}/files/work/" "/tmp/apm/${coredir}"
# 执行命令
chrootEnvPath="/tmp/apm/${coredir}" /var/lib/apm/apm/files/ace-run "$@"
chrootEnvPath="/tmp/apm/${coredir}" ${APM_RUN_EXEC} "$@"
# 卸载
umount "/tmp/apm/${coredir}"
@@ -314,6 +319,12 @@ case "$1" in
exit 1
fi
;;
sandbox-run)
# 运行包命令:第二个参数必须是包名
export APM_USE_SANDBOX=1
shift
$0 run "$@"
;;
debug)
shift
debug_info $@

View File

@@ -44,11 +44,14 @@ _apm()
"update"
"upgrade" "full-upgrade" "dist-upgrade"
"run"
"run-sandbox"
"help"
"source" "build-dep"
"clean" "autoclean"
"download" "changelog"
"amber"
"xmp360"
"bronya"
"debug"
"depends" "rdepends"
"policy")
@@ -236,7 +239,7 @@ fi
command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
return 0
;;
run)
run|run-sandbox)
COMPREPLY=( $( compgen -W "$(apm_run_compgen)" "$cur" ) )
return 0
;;