mirror of
https://gitee.com/amber-ce/amber-pm
synced 2026-06-22 14:13:54 +08:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 910216a457 | |||
| 48b06ca964 | |||
| 1cb22d8465 | |||
| 0d368d73d9 | |||
| f73645a024 | |||
| e46affc340 | |||
| c5fd74b513 | |||
| 1c492b165d |
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
Package: apm
|
Package: apm
|
||||||
Source: amber-ce
|
Source: amber-ce
|
||||||
Version: 1.0.9
|
Version: 1.0.10
|
||||||
Architecture: amd64
|
Architecture: amd64
|
||||||
Maintainer: shenmo <shenmo@spark-app.store>
|
Maintainer: shenmo <shenmo@spark-app.store>
|
||||||
Installed-Size: 48716
|
Installed-Size: 48724
|
||||||
Depends: bubblewrap, flatpak, policykit-1 | pkexec | polkit-1 | polkit, systemd, procps,coreutils,fuse-overlayfs,xz-utils
|
Depends: bubblewrap, flatpak, policykit-1 | pkexec | polkit-1 | polkit, systemd, procps,coreutils,fuse-overlayfs,xz-utils
|
||||||
Section: misc
|
Section: misc
|
||||||
Conflicts: ace-host-integration
|
Conflicts: ace-host-integration
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ usage() {
|
|||||||
echo ""
|
echo ""
|
||||||
echo "示例:"
|
echo "示例:"
|
||||||
echo " $SCRIPT_NAME --base amber-pm-trixie /path/to/package.deb"
|
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"
|
echo "最下层的base在最后面,从上到下写base"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +41,7 @@ while [ $# -gt 0 ]; do
|
|||||||
case $1 in
|
case $1 in
|
||||||
--base)
|
--base)
|
||||||
BASENAMES+=("$2")
|
BASENAMES+=("$2")
|
||||||
|
BASENAMES_ORIG+=("$2")
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--pkgname)
|
--pkgname)
|
||||||
@@ -112,7 +113,35 @@ cleanup() {
|
|||||||
# 设置退出时清理
|
# 设置退出时清理
|
||||||
trap cleanup EXIT
|
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/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包信息..."
|
log.info "检查原DEB包信息..."
|
||||||
ORIG_PKGNAME=$(dpkg -f "$DEB_PATH" Package)
|
ORIG_PKGNAME=$(dpkg -f "$DEB_PATH" Package)
|
||||||
ORIG_VERSION=$(dpkg -f "$DEB_PATH" Version)
|
ORIG_VERSION=$(dpkg -f "$DEB_PATH" Version)
|
||||||
@@ -130,7 +159,7 @@ log.info "新包名: $NEW_PKGNAME"
|
|||||||
log.info "新版本: $NEW_VERSION"
|
log.info "新版本: $NEW_VERSION"
|
||||||
log.info "新架构: $ORIG_ARCH"
|
log.info "新架构: $ORIG_ARCH"
|
||||||
|
|
||||||
# 3. 构建lowerdir路径(多个base按顺序叠放)
|
# 2. 构建lowerdir路径(多个base按顺序叠放)
|
||||||
log.info "构建overlay lowerdir路径..."
|
log.info "构建overlay lowerdir路径..."
|
||||||
LOWERDIRS=()
|
LOWERDIRS=()
|
||||||
|
|
||||||
@@ -275,11 +304,16 @@ mkdir -p "$PKG_BUILD_DIR/DEBIAN"
|
|||||||
mkdir -p "$PKG_BUILD_DIR/var/lib/apm/$NEW_PKGNAME"/{entries,files}
|
mkdir -p "$PKG_BUILD_DIR/var/lib/apm/$NEW_PKGNAME"/{entries,files}
|
||||||
|
|
||||||
# 创建info文件 - 写入所有base,每行一个
|
# 创建info文件 - 写入所有base,每行一个
|
||||||
log.info "创建info文件,包含所有基础环境:"
|
log.info "创建info文件,包含输入的基础环境:"
|
||||||
for BASENAME in "${BASENAMES[@]}"; do
|
for BASENAME in "${BASENAMES_ORIG[@]}"; do
|
||||||
echo "$BASENAME" >> "$PKG_BUILD_DIR/var/lib/apm/$NEW_PKGNAME/info"
|
echo "$BASENAME" >> "$PKG_BUILD_DIR/var/lib/apm/$NEW_PKGNAME/info"
|
||||||
log.info " 写入: $BASENAME"
|
log.info " 写入: $BASENAME"
|
||||||
done
|
done
|
||||||
|
log.info "创建info_debug文件,包含所有基础环境:"
|
||||||
|
for BASENAME in "${BASENAMES[@]}"; do
|
||||||
|
echo "$BASENAME" >> "$PKG_BUILD_DIR/var/lib/apm/$NEW_PKGNAME/info_debug"
|
||||||
|
log.info " 写入: $BASENAME"
|
||||||
|
done
|
||||||
|
|
||||||
# 创建postinst脚本
|
# 创建postinst脚本
|
||||||
cat > "$PKG_BUILD_DIR/DEBIAN/postinst" << 'EOF'
|
cat > "$PKG_BUILD_DIR/DEBIAN/postinst" << 'EOF'
|
||||||
@@ -334,19 +368,19 @@ calculate_directory_size() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 构建依赖字符串 - 包含所有base
|
# 构建依赖字符串 - 包含所有base
|
||||||
DEPENDS_STR=$(IFS=,; echo "${BASENAMES[*]}")
|
DEPENDS_STR=$(IFS=,; echo "${BASENAMES_ORIG[*]}")
|
||||||
|
|
||||||
# 创建control文件
|
# 创建control文件
|
||||||
cat > "${PKG_BUILD_DIR}/DEBIAN/control" << EOF
|
cat > "${PKG_BUILD_DIR}/DEBIAN/control" << EOF
|
||||||
Package: $NEW_PKGNAME
|
Package: $NEW_PKGNAME
|
||||||
Version: $NEW_VERSION
|
Version: $NEW_VERSION
|
||||||
Architecture: $ORIG_ARCH
|
Architecture: $ORIG_ARCH
|
||||||
Maintainer: APM Converter <apm@localhost>
|
Maintainer: APM Converter <apm-convert@spark-app.store>
|
||||||
Depends: $DEPENDS_STR
|
Depends: $DEPENDS_STR
|
||||||
Installed-Size: $(calculate_directory_size $PKG_BUILD_DIR)
|
Installed-Size: $(calculate_directory_size $PKG_BUILD_DIR)
|
||||||
Description: APM converted package from $DEB_PATH
|
Description: APM converted package from $ORIG_PKGNAME
|
||||||
This package was automatically converted from the original deb package.
|
This package was automatically converted from the original deb package.
|
||||||
Based on: ${BASENAMES[*]}
|
Based on: ${BASENAMES_ORIG[*]}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# 生成输出文件名
|
# 生成输出文件名
|
||||||
|
|||||||
+24
-8
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
VERSION=1.0.9
|
VERSION=1.0.10
|
||||||
# 获取脚本名称用于帮助信息
|
# 获取脚本名称用于帮助信息
|
||||||
SCRIPT_NAME=$(basename "$0")
|
SCRIPT_NAME=$(basename "$0")
|
||||||
PATH_PREFIX=/var/lib/apm/apm/files/ace-env/
|
PATH_PREFIX=/var/lib/apm/apm/files/ace-env/
|
||||||
@@ -40,16 +40,22 @@ EOF
|
|||||||
|
|
||||||
|
|
||||||
apm_exec(){
|
apm_exec(){
|
||||||
# 读取info文件中的所有行,按从下到上的顺序构建lowerdir
|
# 递归读取info文件并构建lowerdir
|
||||||
local lowerdirs=()
|
local lowerdirs=()
|
||||||
|
local current_dir="${PATH_PREFIX}/var/lib/apm/${coredir}" # 当前目录开始
|
||||||
|
local next_info_file=""
|
||||||
|
|
||||||
|
while : ; do
|
||||||
|
# 构建info文件的路径
|
||||||
|
next_info_file="${current_dir}/info"
|
||||||
|
# echo "${current_dir}/info"
|
||||||
# 检查info文件是否存在
|
# 检查info文件是否存在
|
||||||
if [[ ! -f "${PATH_PREFIX}/var/lib/apm/${coredir}/info" ]]; then
|
if [[ ! -f "$next_info_file" ]]; then
|
||||||
log.error "Info file not found for package: $coredir"
|
# log.debug "No more info files found, stopping recursion."
|
||||||
return 1
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 读取info文件的每一行
|
# 读取info文件的每一行并构建lowerdir
|
||||||
while IFS= read -r basedir; do
|
while IFS= read -r basedir; do
|
||||||
[[ -z "$basedir" ]] && continue # 跳过空行
|
[[ -z "$basedir" ]] && continue # 跳过空行
|
||||||
|
|
||||||
@@ -62,7 +68,17 @@ apm_exec(){
|
|||||||
else
|
else
|
||||||
log.warn "Neither ace-env nor core directory found for base: $basedir"
|
log.warn "Neither ace-env nor core directory found for base: $basedir"
|
||||||
fi
|
fi
|
||||||
done < "${PATH_PREFIX}/var/lib/apm/${coredir}/info"
|
done < "$next_info_file"
|
||||||
|
|
||||||
|
# 尝试获取下一个依赖信息的路径
|
||||||
|
local next_basedir=$(tail -n 1 "$next_info_file")
|
||||||
|
if [[ -z "$next_basedir" || ! -d "${PATH_PREFIX}/var/lib/apm/${next_basedir}" ]]; then
|
||||||
|
log.debug "No further dependencies found, ending recursion."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
# 更新当前目录,递归处理下一个依赖
|
||||||
|
current_dir="${PATH_PREFIX}/var/lib/apm/${next_basedir}"
|
||||||
|
done
|
||||||
|
|
||||||
# 检查是否找到了有效的lowerdir
|
# 检查是否找到了有效的lowerdir
|
||||||
if [[ ${#lowerdirs[@]} -eq 0 ]]; then
|
if [[ ${#lowerdirs[@]} -eq 0 ]]; then
|
||||||
@@ -72,7 +88,6 @@ apm_exec(){
|
|||||||
|
|
||||||
# 将lowerdirs数组用冒号连接起来
|
# 将lowerdirs数组用冒号连接起来
|
||||||
local lowerdir=$(IFS=:; echo "${lowerdirs[*]}")
|
local lowerdir=$(IFS=:; echo "${lowerdirs[*]}")
|
||||||
|
|
||||||
# 创建挂载点目录
|
# 创建挂载点目录
|
||||||
mkdir -p "/tmp/apm/${coredir}"
|
mkdir -p "/tmp/apm/${coredir}"
|
||||||
|
|
||||||
@@ -89,6 +104,7 @@ apm_exec(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 调试信息函数
|
# 调试信息函数
|
||||||
debug_info() {
|
debug_info() {
|
||||||
log.debug "======= APM Debug Information ======="
|
log.debug "======= APM Debug Information ======="
|
||||||
|
|||||||
Reference in New Issue
Block a user