mirror of
https://gitee.com/amber-ce/amber-pm
synced 2025-12-17 02:41:37 +08:00
支持依赖解析
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
Package: apm
|
||||
Source: amber-ce
|
||||
Version: 1.0.9
|
||||
Version: 1.0.10
|
||||
Architecture: amd64
|
||||
Maintainer: shenmo <shenmo@spark-app.store>
|
||||
Installed-Size: 48716
|
||||
Installed-Size: 48720
|
||||
Depends: bubblewrap, flatpak, policykit-1 | pkexec | polkit-1 | polkit, systemd, procps,coreutils,fuse-overlayfs,xz-utils
|
||||
Section: misc
|
||||
Conflicts: ace-host-integration
|
||||
|
||||
@@ -19,7 +19,7 @@ usage() {
|
||||
echo ""
|
||||
echo "示例:"
|
||||
echo " $SCRIPT_NAME --base amber-pm-trixie /path/to/package.deb"
|
||||
echo " $SCRIPT_NAME --base base上 --base base中 --base base下 /path/to/package.deb --pkgname new-pkg --version 1.0.0"
|
||||
echo " $SCRIPT_NAME --base amber-pm-bookworm-spark-wine /path/to/package.deb --pkgname new-pkg --version 1.0.0"
|
||||
echo "最下层的base在最后面,从上到下写base"
|
||||
}
|
||||
|
||||
@@ -112,7 +112,35 @@ cleanup() {
|
||||
# 设置退出时清理
|
||||
trap cleanup EXIT
|
||||
|
||||
# 2. 检查原DEB包信息
|
||||
# 递归获取info文件中的依赖
|
||||
get_recursive_basenames() {
|
||||
local basename="$1"
|
||||
local base_dir="/var/lib/apm/apm/files/ace-env/var/lib/apm/$basename"
|
||||
local info_file="$base_dir/files/ace-env/info"
|
||||
|
||||
if [ -f "$info_file" ]; then
|
||||
log.info "读取info文件: $info_file"
|
||||
while IFS= read -r base; do
|
||||
# 跳过空行
|
||||
[[ -z "$base" ]] && continue
|
||||
# 如果依赖的base没有被记录过,则递归添加
|
||||
if [[ ! " ${BASENAMES[*]} " =~ " $base " ]]; then
|
||||
BASENAMES+=("$base")
|
||||
# 递归获取依赖
|
||||
get_recursive_basenames "$base"
|
||||
fi
|
||||
done < "$info_file"
|
||||
else
|
||||
log.info "未找到info文件,跳过: $info_file"
|
||||
fi
|
||||
}
|
||||
|
||||
# 递归获取所有基础环境
|
||||
for BASE in "${BASENAMES[@]}"; do
|
||||
get_recursive_basenames "$BASE"
|
||||
done
|
||||
|
||||
# 检查DEB文件
|
||||
log.info "检查原DEB包信息..."
|
||||
ORIG_PKGNAME=$(dpkg -f "$DEB_PATH" Package)
|
||||
ORIG_VERSION=$(dpkg -f "$DEB_PATH" Version)
|
||||
@@ -130,7 +158,7 @@ log.info "新包名: $NEW_PKGNAME"
|
||||
log.info "新版本: $NEW_VERSION"
|
||||
log.info "新架构: $ORIG_ARCH"
|
||||
|
||||
# 3. 构建lowerdir路径(多个base按顺序叠放)
|
||||
# 2. 构建lowerdir路径(多个base按顺序叠放)
|
||||
log.info "构建overlay lowerdir路径..."
|
||||
LOWERDIRS=()
|
||||
|
||||
|
||||
@@ -40,29 +40,45 @@ EOF
|
||||
|
||||
|
||||
apm_exec(){
|
||||
# 读取info文件中的所有行,按从下到上的顺序构建lowerdir
|
||||
# 递归读取info文件并构建lowerdir
|
||||
local lowerdirs=()
|
||||
|
||||
# 检查info文件是否存在
|
||||
if [[ ! -f "${PATH_PREFIX}/var/lib/apm/${coredir}/info" ]]; then
|
||||
log.error "Info file not found for package: $coredir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 读取info文件的每一行
|
||||
while IFS= read -r basedir; do
|
||||
[[ -z "$basedir" ]] && continue # 跳过空行
|
||||
local current_dir="${PATH_PREFIX}/var/lib/apm/${coredir}/files" # 当前目录开始
|
||||
local next_info_file=""
|
||||
|
||||
while : ; do
|
||||
# 构建info文件的路径
|
||||
next_info_file="${current_dir}/info"
|
||||
|
||||
# 检查ace-env目录是否存在
|
||||
if [[ -d "${PATH_PREFIX}/var/lib/apm/${basedir}/files/ace-env" ]]; then
|
||||
lowerdirs+=("${PATH_PREFIX}/var/lib/apm/${basedir}/files/ace-env")
|
||||
# 如果ace-env不存在,检查core目录
|
||||
elif [[ -d "${PATH_PREFIX}/var/lib/apm/${basedir}/files/core" ]]; then
|
||||
lowerdirs+=("${PATH_PREFIX}/var/lib/apm/${basedir}/files/core")
|
||||
else
|
||||
log.warn "Neither ace-env nor core directory found for base: $basedir"
|
||||
# 检查info文件是否存在
|
||||
if [[ ! -f "$next_info_file" ]]; then
|
||||
log.debug "No more info files found, stopping recursion."
|
||||
break
|
||||
fi
|
||||
done < "${PATH_PREFIX}/var/lib/apm/${coredir}/info"
|
||||
|
||||
# 读取info文件的每一行并构建lowerdir
|
||||
while IFS= read -r basedir; do
|
||||
[[ -z "$basedir" ]] && continue # 跳过空行
|
||||
|
||||
# 检查ace-env目录是否存在
|
||||
if [[ -d "${current_dir}/${basedir}/files/ace-env" ]]; then
|
||||
lowerdirs+=("${current_dir}/${basedir}/files/ace-env")
|
||||
# 如果ace-env不存在,检查core目录
|
||||
elif [[ -d "${current_dir}/${basedir}/files/core" ]]; then
|
||||
lowerdirs+=("${current_dir}/${basedir}/files/core")
|
||||
else
|
||||
log.warn "Neither ace-env nor core directory found for base: $basedir"
|
||||
fi
|
||||
done < "$next_info_file"
|
||||
|
||||
# 尝试获取下一个依赖信息的路径
|
||||
local next_basedir=$(tail -n 1 "$next_info_file")
|
||||
if [[ -z "$next_basedir" || ! -d "${current_dir}/${next_basedir}/files" ]]; then
|
||||
log.debug "No further dependencies found, ending recursion."
|
||||
break
|
||||
fi
|
||||
# 更新当前目录,递归处理下一个依赖
|
||||
current_dir="${current_dir}/${next_basedir}/files"
|
||||
done
|
||||
|
||||
# 检查是否找到了有效的lowerdir
|
||||
if [[ ${#lowerdirs[@]} -eq 0 ]]; then
|
||||
@@ -89,6 +105,7 @@ apm_exec(){
|
||||
|
||||
|
||||
|
||||
|
||||
# 调试信息函数
|
||||
debug_info() {
|
||||
log.debug "======= APM Debug Information ======="
|
||||
|
||||
Reference in New Issue
Block a user