Compare commits

..

17 Commits

Author SHA1 Message Date
shenmo7192 f9fd0020c2 删除部分无用文件;不再修改主机名 2025-10-29 11:12:47 +08:00
shenmo7192 7a0b949bd1 update Packaging-demo/README.md.
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2025-10-28 13:21:43 +00:00
shenmo7192 021279310f update README.md.
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2025-10-28 11:38:15 +00:00
shenmo7192 338a3f5d93 支持 apm show 指令
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2025-10-28 11:14:15 +00:00
shenmo7192 48b0b0b5a1 update src/usr/bin/apm.
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2025-10-28 11:09:33 +00:00
Ving 877bf82f6c !5 更新软件主图标与 README.md
* update README.md.
* update README.md.
* update README.md.
* update README.md.
* 删除文件 src/var/lib/apm/files/.keep
* 更新软件主图标
* 新建 files
* 更新软件主图标
2025-10-28 11:08:40 +00:00
shenmo7192 ac6846a64a update src/usr/bin/apm.
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2025-10-28 08:32:24 +00:00
shenmo7192 b2ed2974b9 完成文档 2025-10-28 16:27:15 +08:00
shenmo7192 128944d7d4 修改文档 2025-10-28 16:23:34 +08:00
shenmo7192 910216a457 convert 只输入最表层的依赖
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2025-10-27 06:49:31 +00:00
shenmo7192 48b06ca964 1.0.10 2025-10-27 12:55:53 +08:00
shenmo7192 1cb22d8465 修复convert无法正确写入的问题 2025-10-27 12:54:49 +08:00
shenmo7192 0d368d73d9 写错了变量名称 2025-10-27 12:45:36 +08:00
shenmo7192 f73645a024 去除debug信息 2025-10-27 12:37:36 +08:00
shenmo7192 e46affc340 1.0.10 2025-10-27 12:36:48 +08:00
shenmo7192 c5fd74b513 更改spec以和实际一致 2025-10-27 11:42:05 +08:00
shenmo7192 1c492b165d 支持依赖解析 2025-10-27 11:29:37 +08:00
19 changed files with 336 additions and 421 deletions
+141
View File
@@ -0,0 +1,141 @@
# APM 软件包打包流程
本文档为开发者准备,若您只是想从 deb 软件包打包 APM 软件包,您可以通过 `amber-pm-convert`指令进行全自动一键转换
通过 `apm search amber-pm- ` 即可搜索到所有可用的 base 列表
---
## APM 软件包结构规范
在阅读前,请确保您对overlayfs有了基本的了解
overlayfs 原理解析:https://www.cnblogs.com/arnoldlu/p/13055501.html
---
一个典型的 APM 软件/中层依赖包应当包含以下内容
```
├── DEBIAN
│ ├── control
│ └── postinst
└── var
└── lib
└── apm
└── eom
├── entries
│ ├── applications
│ ├── doc
│ ├── glib-2.0
│ └── man
├── files
│ ├── core
│ └── work
├── info
└── info_debug
```
* DEBIAN目录包含了软件包的基本信息和依赖的环境信息
1. 以下是 control 文件的内容
```
Package: eom
Version: 1.26.0-2-apm
Architecture: amd64
Maintainer: APM Converter <apm-convert@spark-app.store>
Depends: amber-pm-bookworm
Installed-Size: 45228
Description: APM converted package from eom
This package was automatically converted from the original deb package.
Based on: amber-pm-bookworm
```
Package: 包名。应当唯一。若使用转换器进行转换,默认和原包名一致
Version: 版本号。若使用转换器进行转换,默认在原版本号后加`-apm`
Architecture: 软件包架构。同 dpkg 进行填写即可。若使用转换器进行转换,默认和原包架构一致
Depends: 依赖包。填写直接依赖的base即可
Installed-Size: 安装后的大小。若使用转换器进行转换,会自动填写
Description: 包描述。若使用转换器进行转换,会自动填写
2. 以下是 postinst 文件内容
```
#!/bin/bash
PACKAGE_NAME="$DPKG_MAINTSCRIPT_PACKAGE"
if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
echo "清理卸载残留"
rm -rf "/var/lib/apm/$PACKAGE_NAME"
else
echo "非卸载,跳过清理"
fi
```
若无特殊需求,内容保持一致即可,用于在卸载软件包后清理环境
* /var/lib/apm 包含了APM 软件容器的文件和信息
软件应当被放置在 /var/lib/apm/软件包名/ 处
此处有两个目录,两个文件
entries 可选,包含了软件包需要被放到 /usr/share/ 的文件,如 desktop icon 等
files 必须,包含了软件包的 upperdir 和 workdir
info 必须,包含了直接依赖的base信息。若应用使用了多层的依赖,会一层一层寻找info信息,直到找到底层依赖
info_debug 可选,包含了打包时解析的依赖信息
entries下的内容同软件需要放置到 /usr/share/ 下的内容
> 注意: .desktop 文件应当新加一行 X-APM-APPID=包名 来允许软件管理器管理
files的内容请见下一节
## APM upperdir 制作流程
以下为手动制作 upperdir 的流程
首先,安装 apm 并使用`sudo apm install` 安装你所需要的 base
随后,新建三个文件夹,corework 和 ace-env ,执行
`sudo mount -t overlay overlay -o lowerdir='/var/lib/apm/apm/files/ace-env/var/lib/apm/base包的包名(如amber-pm-trixie/files/ace-env',upperdir=core/,workdir=work/ ./ace-env`
随后chroot进入进行安装操作,直接进行 apt install 或者其他都可以,完成后解除挂载 ./ace-env
你便得到了:
* core: 保存新增文件
* work: 保存变更信息
需把这两个目录重新拥有并权限换成755后放入对应的目录进行 apm 打包
你也可以测试一下刚刚打包的软件
fuse-overlayfs -o lowerdir='/var/lib/apm/apm/files/ace-env/var/lib/apm/base包的包名(如amber-pm-trixie/files/ace-env',upperdir=core/,workdir=work/ ./ace-env
即可只读挂载。这一步 apm run 包名 会帮你做好。
> apm run 包名: 寻找 /var/lib/apm/包名/是否存在。若存在,根据info文件合成 fuser-overlayfs 参数进行挂载,随后用ACE工具chroot进入进行启动
./ace-run 即可进入,可以尝试启动一下刚刚安装的应用
## APM 打包
使用 `dpkg-deb --build 软件包目录 输出目录` 即可进行打包
## APM 底层 Base Runtime 的构建
详见 https://gitee.com/amber-ce/amber-pm-common
View File
+64 -36
View File
@@ -1,50 +1,78 @@
# APM <div align="center">
<img src="https://gitee.com/possibleving/amber-pm/raw/master/amber-pm-logo.png" alt="软件主图标" width="200" height="200"/>
</div>
# <p align="center">APM 琥珀软件包管理器</p>
## 简介
APM 是一款基于 fuse-overlayfsdpkgAmberCE 容器的软件包管理系统,支持在 DebianFedoraArch Linux 等发行版上运行。
APM 目前提供 Debian 12/13 与 deepin 25 基础环境,支持将适配以上环境的应用转换为 APM 应用。
> APM 会自动从主机获取 NVIDIA 驱动文件,因此您无需担心 N 卡加速问题;
>
> 您可在 [src](src/) 目录找到 APM 的源代码;
>
> OverlayFS 原理解析:[https://www.cnblogs.com/arnoldlu/p/13055501.html](https://www.cnblogs.com/arnoldlu/p/13055501.html)。
## 使用方法
```
APM - Amber Package Manager 1.0.10
Usage:
apm [COMMAND] [OPTIONS] [PACKAGES...]
Commands:
install 安装软件包
remove 卸载软件包
update 更新软件包信息
list 查看可用软件包信息
show 查看软件包信息
search 搜索软件包
download 下载包
clean 清除缓存软件包
autoremove 自动移除不需要的包
full-upgrade 完全升级软件包
run <package> 运行指定软件包的可执行文件
ssaudit <path> 使用 ssaudit 进行本地软件安装,详情见 spark-store
debug 显示调试系统信息并进入调试环境
amber 彩蛋功能
xmp360 彩蛋功能
bronya 彩蛋功能
-h, --help 显示此帮助信息
```
APM 是一款基于 fuse-overlayfs dpkg ACE 的容器软件包管理系统
源码在 src ## APM Deb 包全自动转换器使用方法
原理:https://www.cnblogs.com/arnoldlu/p/13055501.html ```
用法: amber-pm-convert --base <basename> [--base <basename> ...] <deb文件路径> [--pkgname <包名>] [--version <版本号>]
## 体验demo: 查看 https://gitee.com/amber-ce/amber-pm/releases 参数说明:
--basename 必填参数,指定基础环境名称,可多次使用指定多个基础环境
deb文件路径 必填参数,要转换的 Deb 文件路径
--pkgname 可选参数,指定新包的包名(默认使用原 Deb 包名)
--version 可选参数,指定新包的版本号(默认在原版本后追加'-apm'
示例:
amber-pm-convert --base amber-pm-trixie /path/to/package.deb
amber-pm-convert --base amber-pm-bookworm-spark-wine /path/to/package.deb --pkgname new-pkg --version 1.0.0
最下层的 base 在最后,从上到下写 base
制作apm包upperdir的流程 ```
先安装 apm (从release > 注意:APM 软件包为特殊的 Deb 软件包,因此若您在使用 Debian 或其他使用 dpkg 管理软件包的发行版,也可使用 apt 直接将 APM 软件包安装至系统中,同样可供使用。对于此种情况,请使用系统自带的 apt 进行软件包管理。
sudo apm install base包后,在 ## APM 的原理和软件包的介绍
sudo mount -t overlay overlay -o lowerdir='/var/lib/apm/apm/files/ace-env/var/lib/apm/amber-pm-trixie/files/ace-env',upperdir=core/,workdir=work/ ./ace-env 详见 [Packaging-demo](Packaging-demo)。
随后chroot进入进行安装操作,直接进行 apt install 或者其他都可以,完成后 ## APM 构建 Tips
core: 保存新增文件 APM 使用了特殊的精简版 AmberCE 兼容环境,相关的 Tips 见 [Tips](tips.md)。
work: 保存变更信息
需把这两个目录重新拥有并权限换成755
fuse-overlayfs -o lowerdir='/var/lib/apm/apm/files/ace-env/var/lib/apm/amber-pm-trixie/files/ace-env',upperdir=core/,workdir=work/ ./ace-env
即可只读挂载。这一步 apm run 包名 会帮你做好。
> apm run 包名: 寻找 /var/lib/apm/包名/是否存在。若存在,根据info文件合成 fuser-overlayfs 参数进行挂载,随后用ACE工具chroot进入进行启动
./ace-run 即可进入,可以尝试启动一下刚刚安装的应用
spec(对于APM内的包):
对于base
/var/lib/apm/包名/files/ace-env 是 lowerdir
对于core
/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位置,后续会加到自动展示中
core的依赖需要写base
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

+2 -2
View File
@@ -1,9 +1,9 @@
Package: apm Package: apm
Source: amber-ce Source: amber-ce
Version: 1.0.9 Version: 1.1.0
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
+43 -9
View File
@@ -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
# 生成输出文件名 # 生成输出文件名
+40 -11
View File
@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
VERSION=1.0.9 VERSION=1.1.0
# 获取脚本名称用于帮助信息 # 获取脚本名称用于帮助信息
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/
@@ -17,16 +17,20 @@ APM - Amber Package Manager ${VERSION}
Usage: Usage:
$SCRIPT_NAME [COMMAND] [OPTIONS] [PACKAGES...] $SCRIPT_NAME [COMMAND] [OPTIONS] [PACKAGES...]
Commands: Commands:
install 安装软件包 install 安装软件包
remove 卸载软件包 remove 卸载软件包
update 更新软件包信息 update 更新软件包信息
list 查看可用软件包信息
search 搜索软件包
download 下载包 download 下载包
show 展示包信息
clean 清除缓存软件包 clean 清除缓存软件包
autoremove 自动移除不需要的包 autoremove 自动移除不需要的包
full-upgrade 完全升级软件包 full-upgrade 完全升级软件包
run <package> 运行指定软件包的可执行文件 run <package> 运行指定软件包的可执行文件
ssaudit <path> 使用 ssaudit 进行软件安装,详情见 spark-store ssaudit <path> 使用 ssaudit 进行本地软件安装,详情见 spark-store
debug 显示调试系统信息并进入调试环境 debug 显示调试系统信息并进入调试环境
amber 彩蛋功能 amber 彩蛋功能
xmp360 彩蛋功能 xmp360 彩蛋功能
@@ -34,22 +38,27 @@ Commands:
-h, --help 显示此帮助信息 -h, --help 显示此帮助信息
EOF 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 +71,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 +91,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 +107,7 @@ apm_exec(){
# 调试信息函数 # 调试信息函数
debug_info() { debug_info() {
log.debug "======= APM Debug Information =======" log.debug "======= APM Debug Information ======="
@@ -211,7 +230,7 @@ case "$1" in
apm-nvidia-toggle apm-nvidia-toggle
amber-pm-gxde-desktop-fix amber-pm-gxde-desktop-fix
;; ;;
download|search|policy|list|update|clean) download|search|policy|list|update|clean|show)
command=$1 command=$1
shift shift
amber-pm-debug aptss "$command" "$@" amber-pm-debug aptss "$command" "$@"
@@ -282,6 +301,16 @@ case "$1" in
;; ;;
ssaudit) ssaudit)
amber-pm-debug ssaudit "$@" --native amber-pm-debug ssaudit "$@" --native
exit_code=$?
if [ $exit_code -eq 0 ]; then
log.info "Operation successful"
else
log.error "Error: Operation failed"
exit $exit_code
fi
amber-pm-debug amber-pm-dstore-patch
amber-pm-gxde-desktop-fix
;; ;;
-h|--help) -h|--help)
show_help show_help
Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

+4 -3
View File
@@ -1,6 +1,9 @@
#!/bin/bash #!/bin/bash
bash(){
/usr/bin/bash --rcfile <(cat ~/.bashrc; echo "PS1=\"\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@Amber-PM \[\e[36;40m\]\w\[\e[0m\]]\\\$ \"") $@
}
export -f bash
chrootEnvPath="${chrootEnvPath:-$(pwd)/ace-env}" chrootEnvPath="${chrootEnvPath:-$(pwd)/ace-env}"
@@ -102,8 +105,6 @@ BIND_DIRS=(
"--dev-bind-try /home /home" "--dev-bind-try /home /home"
) )
EXTRA_ARGS=( EXTRA_ARGS=(
"--hostname Amber-PM"
"--unshare-uts"
"--cap-add CAP_SYS_ADMIN" "--cap-add CAP_SYS_ADMIN"
) )
+4 -1
View File
@@ -1,6 +1,9 @@
#!/bin/bash #!/bin/bash
bash(){
/usr/bin/bash --rcfile <(cat ~/.bashrc; echo "PS1=\"\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@Amber-PM \[\e[36;40m\]\w\[\e[0m\]]\\\$ \"") $@
}
export -f bash
chrootEnvPath="${chrootEnvPath:-$(pwd)/ace-env}" chrootEnvPath="${chrootEnvPath:-$(pwd)/ace-env}"
-2
View File
@@ -104,8 +104,6 @@ sudo -u $(get_current_user) bwrap --dev-bind $chrootEnvPath/ / \
--bind-try /usr/share/themes /usr/local/share/themes \ --bind-try /usr/share/themes /usr/local/share/themes \
--bind-try /usr/share/icons /usr/local/share/icons \ --bind-try /usr/share/icons /usr/local/share/icons \
--bind-try /usr/share/fonts /usr/local/share/fonts \ --bind-try /usr/share/fonts /usr/local/share/fonts \
--hostname Amber-PM \
--unshare-uts \
--dev-bind-try /etc/resolv.conf /etc/resolv.conf \ --dev-bind-try /etc/resolv.conf /etc/resolv.conf \
--dev-bind-try /home /home \ --dev-bind-try /home /home \
locale-gen locale-gen
+5 -2
View File
@@ -1,5 +1,10 @@
#!/bin/bash #!/bin/bash
bash(){
/usr/bin/bash --rcfile <(cat ~/.bashrc; echo "PS1=\"\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@Amber-PM \[\e[36;40m\]\w\[\e[0m\]]\\\$ \"") $@
}
export -f bash
curdir=`realpath $0` curdir=`realpath $0`
parent_dir=`dirname $curdir` parent_dir=`dirname $curdir`
pparent_dir=`dirname $parent_dir` pparent_dir=`dirname $parent_dir`
@@ -115,8 +120,6 @@ BIND_DIRS=(
"--dev-bind-try /home /home" "--dev-bind-try /home /home"
) )
EXTRA_ARGS=( EXTRA_ARGS=(
"--hostname Amber-PM"
"--unshare-uts"
"--cap-add CAP_SYS_ADMIN" "--cap-add CAP_SYS_ADMIN"
) )
-155
View File
@@ -1,155 +0,0 @@
#!/bin/bash
curdir=`realpath $0`
parent_dir=`dirname $curdir`
pparent_dir=`dirname $parent_dir`
ppparent_dir=`dirname $pparent_dir`
PKGNAME=`basename $ppparent_dir`
export ACE_PACKAGE_NAME=$PKGNAME
chrootEnvPath=/var/lib/apm/$PKGNAME/files/ace-env
if [ ! -e $chrootEnvPath/finish.flag ];then
if [ "$(id -u)" = "0" ]; then
`dirname $chrootEnvPath`/bin/ace-init
else
pkexec `dirname $chrootEnvPath`/bin/ace-init
fi
fi
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"
"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"
"--ro-bind-try /usr/share/themes /usr/local/share/themes"
"--ro-bind-try /usr/share/icons /usr/local/share/icons"
"--ro-bind-try /usr/share/fonts /usr/local/share/fonts"
"--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 \"/usr/bin/bwrap ${container_command}\""
# 输出完整的 EXEC_COMMAND 以查看
# echo "${EXEC_COMMAND}"
# 注意: 实际执行时,请确保所有变量(如 $uid, $chrootEnvPath 等)都已正确定义
eval ${EXEC_COMMAND}
@@ -1,91 +0,0 @@
#!/bin/bash
if [ "$UID" != "0" ];then
echo "Need to be run as root."
exit 1
fi
# 清除先前的变量值
unset ABSOLUTE_PATH IN_CONTAINER_PATH PKGNAME_GUESS DPKG_LIST_FILE ACE_ENV_PATH
# 定义环境路径变量
ACE_ENV_PATH="/var/lib/apm/apm/files/ace-env"
# 检查参数个数
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <desktop-file>"
exit 1
fi
# 保存并验证绝对路径
ABSOLUTE_PATH=$1
if [[ $ABSOLUTE_PATH != "$ACE_ENV_PATH"* ]]; then
echo "Error: Invalid path. Must start with $ACE_ENV_PATH"
exit 1
fi
# 验证是否为desktop文件
if [[ ! $ABSOLUTE_PATH == *.desktop ]]; then
if [ ! -e $ABSOLUTE_PATH ];then
echo "$ABSOLUTE_PATH does not exist. May have already been uninstalled. Ignore it."
exit
else
echo "Error: The file is not a desktop file."
exit 1
fi
fi
# 截取路径
IN_CONTAINER_PATH=${ABSOLUTE_PATH#"$ACE_ENV_PATH"}
# 截取并保存包名
PKGNAME_GUESS=$(basename "$ABSOLUTE_PATH" .desktop)
# 检查dpkg列表文件
DPKG_INFO_PATH="$ACE_ENV_PATH/var/lib/dpkg/info"
if [ -f "$DPKG_INFO_PATH/$PKGNAME_GUESS.list" ]; then
DPKG_LIST_FILE="$DPKG_INFO_PATH/$PKGNAME_GUESS.list"
elif ls "$DPKG_INFO_PATH/${PKGNAME_GUESS}:*.list" 1> /dev/null 2>&1; then
DPKG_LIST_FILE=$(ls "$DPKG_INFO_PATH/${PKGNAME_GUESS}:*.list" | head -n 1)
else
echo "Warn:No dpkg list file found for $PKGNAME_GUESS.desktop,try to scan to search for the package"
fi
# 验证文件并执行操作
if [ -f "$DPKG_LIST_FILE" ]; then
if grep -q "$IN_CONTAINER_PATH" "$DPKG_LIST_FILE" || grep -q "/var/lib/apm/$PKGNAME_GUESS/entries/applications/$PKGNAME_GUESS.desktop" "$DPKG_LIST_FILE"; then
apm-debug apt autopurge $PKGNAME_GUESS -y
ret=$?
if [ "$ret" = "0" ];then
echo "Operation succeeded."
exit
else
echo "Operation failed."
exit $ret
fi
else
echo "Warn: Path not found in the dpkg list file,try to scan to search for the package"
fi
fi
# 遍历所有list文件 As fallback
for file in "$DPKG_INFO_PATH"/*.list; do
if grep -q "$IN_CONTAINER_PATH" "$file"; then
PKGNAME_GUESS=$(basename "$file" .list | cut -d':' -f1)
echo "Get pkgname $PKGNAME_GUESS, uninstalling..."
apm-debug apt autopurge $PKGNAME_GUESS -y
ret=$?
if [ "$ret" = "0" ];then
echo "Operation succeeded."
exit 0
else
echo "Operation failed."
exit $ret
fi
fi
done
echo "Error: No matching package found."
exit 1
@@ -1,77 +0,0 @@
#!/bin/bash
if [ "$UID" != "0" ];then
pkexec $0
exit
fi
# 定义应用列表文件路径
ACE_dir="/var/lib/apm/apm/files/ace-env"
HERE="$(dirname $(realpath $0))"
# 读取所有.desktop文件,并构造应用列表
app_list=()
for file in "$ACE_dir"/usr/share/applications/*.desktop; do
if [ ! -e "$file" ];then ##可能是软链接,对主机来说无用
file=$ACE_dir$(readlink $file)
fi
if [ "$(grep -m 1 '^NoDisplay=' "$file" | cut -d '=' -f 2)" = "true" ] || [ "$(grep -m 1 '^NoDisplay=' "$file" | cut -d '=' -f 2)" = "True" ];then
continue
fi
# 读取应用名称和简介
name_orig=$(grep -m 1 '^Name=' "$file" | cut -d '=' -f 2)
name_i18n=$(grep -m 1 "^Name\[${LANGUAGE}\]\=" "$file" | cut -d '=' -f 2)
if [ -z "$name_i18n" ] ;then
name=$name_orig
else
name=$name_i18n
fi
comment_orig=$(grep -m 1 '^Comment=' "$file" | cut -d '=' -f 2)
comment_i18n=$(grep -m 1 "^Comment\[${LANGUAGE}\]\=" "$file" | cut -d '=' -f 2)
if [ -z "$comment_i18n" ] ;then
comment=$comment_orig
else
comment=$comment_i18n
fi
# 如果没有简介,则显示"N/A"
[[ -z "$comment" ]] && comment="N/A"
# 添加到应用列表数组
app_list+=("false" "$name" "$comment" "$file")
done
# 使用 Zenity 显示应用列表,并获取用户选择
selected_apps=$(zenity --list --title "应用列表" --column "是否卸载" --column "应用名称" --column "应用介绍" --column "desktop文件位置" --checklist "${app_list[@]}" --print-column=4 --hide-column=4 --separator=" " --width=800 --height=400)
# 检查用户是否做出了选择
if [ -n "$selected_apps" ]; then
# 卸载选中的应用
(for app_desktop_path in $selected_apps; do
${HERE}/ace-uninstall-helper "$app_desktop_path"
ret=$?
if [ "$ret" != "0" ];then
zenity --error --width 768 --text "$app_desktop_path 卸载失败,中止操作\n请手动执行\nsudo $0 $app_desktop_path \n查看报错!"
exit 1
break
fi
done ) &
cmd_pid=$!
(while kill -0 $cmd_pid 2> /dev/null; do
echo "# 正在执行..."
sleep 1
done)| zenity --progress --text="正在执行卸载操作..." --pulsate --auto-close --no-cancel --width 400
wait $cmd_pid
cmd_status=$?
if [ "$cmd_status" = "1" ];then
zenity --error --width 200 --text "卸载过程出现错误"
exit 1
else
zenity --info --width 200 --text "选定应用已卸载"
fi
else
zenity --info --text "未选择任何应用"
fi
+4 -3
View File
@@ -4,7 +4,7 @@
2. apm 添加了一个钩子(debian only),在安装到 /var/lib/apm 下的应用存在ace-env时,进行configure nvidia操作;若存在entries,则进行链接到/usr/share/applications操作 2. apm 添加了一个钩子(debian only),在安装到 /var/lib/apm 下的应用存在ace-env时,进行configure nvidia操作;若存在entries,则进行链接到/usr/share/applications操作
3. apm 内置 ubuntu rootfs的修改如下 3. apm 内置 rootfs的修改如下
* 安装xz-utils * 安装xz-utils
@@ -26,8 +26,7 @@
* 重要:如何在APM内更新内容——如何覆盖?
* deb全自动转apm
* apm版融合商店 * apm版融合商店
* 类似 Wine 运行器的方式全图形化傻瓜式打包 * 类似 Wine 运行器的方式全图形化傻瓜式打包
* 自动融合 APM 应用到系统主机,并实现右键卸载 * 自动融合 APM 应用到系统主机,并实现右键卸载
@@ -43,3 +42,5 @@
* 完成amd64软件源配置 * 完成amd64软件源配置
* 修改aptss以兼容APM源加速 * 修改aptss以兼容APM源加速
* apm环境变量添加 IS_APM_ENV=1 GTK_USE_PORTAL=1 * apm环境变量添加 IS_APM_ENV=1 GTK_USE_PORTAL=1
* 重要:如何在APM内更新内容——如何覆盖?
* deb全自动转apm