This commit is contained in:
2025-10-19 02:05:16 +08:00
parent a2f339fbba
commit d5a34aac20
6 changed files with 34 additions and 132 deletions

View File

@@ -0,0 +1,33 @@
# APM 原理和软件包制作流程
制作apm包upperdir的流程
先安装base包从release
sudo mount -t overlay overlay -o lowerdir='/var/lib/apm/amber-pm-trixie-host/files/ace-env',upperdir=core/,workdir=work/ ./ace-env
随后chroot进入进行安装操作直接进行 apt install 或者其他都可以,完成后
core: 保存新增文件
work: 保存变更信息
需把这两个目录重新拥有并权限换成755
fuse-overlayfs -o lowerdir='/var/lib/apm/amber-pm-trixie-host/files/ace-env',upperdir=core/,workdir=work/ ./ace-env
即可只读挂载并进行ace操作
spec
对于lowerdir
/var/lib/apm/包名/files/ace-env 是 lowerdir
对于upperdir
/var/lib/apm/包名/files/core是upperdir
/var/lib/apm/包名/files/work是upperdir的work
/var/lib/apm/包名/files/ace-env是chroot进的目录需要在打包好的包内加上允许读写这个目录——或者后续换成tmp的挂载点
/var/lib/apm/包名/info是配置信息目前只写了依赖的base后续可以定义默认启动指令等
/var/lib/apm/包名/entries是desktop位置后续会加到自动展示中
apm run 包名: 寻找 /var/lib/apm/包名/是否存在。若存在根据info文件合成 fuser-overlayfs 参数进行挂载随后用ACE工具chroot进入进行启动

View File

@@ -2,7 +2,7 @@
chrootEnvPath=$(pwd)/ace-env
chrootEnvPath="${chrootEnvPath:-$(pwd)/ace-env}"

109
apm.sh
View File

@@ -1,109 +0,0 @@
#!/bin/bash
VERSION=0.1
# 获取脚本名称用于帮助信息
SCRIPT_NAME=$(basename "$0")
# 帮助信息函数
show_help() {
cat <<EOF
APM - Amber Package Manager ${VERSION}
Usage:
$SCRIPT_NAME [COMMAND] [OPTIONS] [PACKAGES...]
Commands:
install 安装软件包
remove 卸载软件包
autoremove 自动移除不需要的包
full-upgrade 完全升级软件包
run <package> 运行指定软件包的可执行文件
debug 显示调试系统信息
-h, --help 显示此帮助信息
--amber 彩蛋功能
EOF
}
# 调试信息函数
debug_info() {
echo "======= APM Debug Information ======="
echo "User: $(whoami)"
echo "Hostname: $(hostname)"
echo "OS: $(lsb_release -ds 2>/dev/null || uname -om)"
echo "Kernel: $(uname -sr)"
echo "Bash Version: ${BASH_VERSION}"
echo "APT Version: $(apt --version | head -n1)"
echo "====================================="
## 这里加上chroot进入apm
}
# 彩蛋函数
amber_egg() {
cat <<EOF
_ _ _ _ _____ ______
| | | | \ | | __ \| ___ \
| | | | \| | | \/| |_/ /
| |/\| | . \` | | __ | ___ \
\ /\ / |\ | |_\ \| |_/ /
\/ \/\_| \_/\____/\____/
Amber Package Manager - Sparkling with magic!
💎 Nothing is impossible for APM!
EOF
}
# 主命令处理
case "$1" in
install|remove|autoremove|full-upgrade)
# 特殊APT命令移除第一个参数后传递其余参数
command=$1
shift
sudo apt "$command" "$@"
;;
run)
# 运行包命令:第二个参数必须是包名
if [ -z "$2" ]; then
echo "Error: Package name required for 'run' command"
show_help
exit 1
fi
# 检查包是否已安装
pkg="$2"
shift 2 # 移除 'run' 和包名
if ! dpkg -l | grep "^ii $1 " > /dev/null; then
echo "Package not installed: $pkg"
exit 1
fi
# 检测是否有额外命令参数
if [ $# -gt 0 ]; then
# 有额外参数:执行用户提供的命令
echo "Running user command: $*"
exec "$@"
else
# 没有额外参数:执行包的主程序
bin_path=$(dpkg -L "$pkg" | grep -m1 -E '/bin/|/sbin/|/games/')
if [ -z "$bin_path" ]; then
echo "Error: No executable found in package '$pkg'"
exit 1
fi
echo "Running package executable: $bin_path"
exec "$bin_path"
fi
;;
debug)
debug_info
;;
-h|--help)
show_help
;;
--amber)
amber_egg
;;
*)
show_help
;;
esac

0
ace-env/etc/resolv.conf → core/.keep Normal file → Executable file
View File

0
work/.keep Executable file
View File

View File

@@ -1,22 +0,0 @@
sudo mount -t overlay overlay -o lowerdir='/var/lib/apm/amber-pm-trixie/files/ace-env',upperdir=core/,workdir=work/ ./ace-env
随后chroot进入进行安装操作完成后
core: 保存新增文件
work: 保存变更信息
需把这两个目录重新拥有并权限换成755
fuse-overlayfs -o lowerdir='/var/lib/apm/amber-pm-trixie/files/ace-env',upperdir=core/,workdir=work/ ./ace-env
即可只读挂载并进行ace操作
计划:
/var/lib/apm/包名/files/core是upperdir
/var/lib/apm/包名/files/work是upperdir
/var/lib/apm/包名/files/ace-env是chroot进的目录
/var/lib/apm/包名/info是配置信息
apm run 包名: 寻找 /var/lib/apm/包名/是否存在。若存在根据info文件合成 fuser-overlayfs(ll-killer) 参数进行挂载随后用ACE工具chroot进入进行启动