Compare commits

..

28 Commits

Author SHA1 Message Date
shenmo7192 8838d900f0 清理干净
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2025-11-01 04:34:20 +00:00
shenmo7192 0f6780e4f4 completion没改过来 2025-11-01 08:57:27 +08:00
shenmo7192 3edefa0243 提交 README 2025-11-01 00:26:58 +08:00
shenmo7192 0f9a4ed76a 初步支持沙箱化运行应用 2025-11-01 00:21:27 +08:00
shenmo7192 7b8ceb8328 忘记改下面了 2025-10-31 23:38:00 +08:00
shenmo7192 c54a9d39c2 update converter 2025-10-31 23:34:15 +08:00
shenmo7192 a2b7bc9826 ensure_dirs 2025-10-31 23:13:14 +08:00
shenmo7192 40809464f2 尝试整个主目录进行沙箱 2025-10-31 23:08:48 +08:00
shenmo7192 31c4ee9c25 update logs 2025-10-31 21:15:58 +08:00
shenmo7192 908f3ab9de 尝试性加入主目录沙箱--Wine 2025-10-31 21:09:16 +08:00
shenmo7192 7b06cf293b 修复 无法转换包的问题,提示需要安装dpkg;修复 apm debug 失效的问题 2025-10-31 13:04:38 +08:00
shenmo7192 137460768f update: APM upgrade notifier 2025-10-31 12:52:22 +08:00
shenmo7192 c3486af9a5 feat: 支持在fedora和arch上直接打包
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2025-10-30 07:24:47 +00:00
shenmo7192 9bbcb06c59 Revert "尝试让ace-run也挂载到系统的icon"
This reverts commit 5f55cf19360a891681bd787fafafe946adb5c1df.
2025-10-30 05:58:39 +00:00
shenmo7192 1c7ce04f42 update linyaps.md.
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2025-10-30 05:01:43 +00:00
shenmo7192 d13b0b596b update linyaps.md.
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2025-10-30 05:00:11 +00:00
shenmo7192 0d41828ece add linyaps.md.
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2025-10-30 04:59:56 +00:00
shenmo7192 f8ce04cae3 尝试让ace-run也挂载到系统的icon
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2025-10-30 04:23:47 +00:00
shenmo7192 6b4d95b363 apm logo small
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2025-10-29 06:32:47 +00:00
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
28 changed files with 637 additions and 276 deletions
+149
View File
@@ -0,0 +1,149 @@
# 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"
for username in $(ls /home)
do
echo /home/$username
if [ -d "/home/$username/.apm/$PACKAGE_NAME" ]
then
rm -fr "/home/$username/.apm/$PACKAGE_NAME"
fi
done
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
+71 -36
View File
@@ -1,50 +1,85 @@
# 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 卸载软件包
run <package> 运行指定软件包的可执行文件
sandbox-run <package> 运行指定软件包的可执行文件(主目录沙箱化)
update 更新软件包信息
hold 锁定软件包版本
unhold 解锁软件包版本
full-upgrade 升级全部软件包
list 查看可用软件包信息
search 搜索软件包
download 下载包
show 展示包信息
clean 清除缓存软件包
autoremove 自动移除不需要的包
ssaudit <path> 使用 ssaudit 进行本地软件安装,详情见 spark-store
debug 显示调试系统信息并进入调试环境
amber 彩蛋功能
xmp360 彩蛋功能
bronya 彩蛋功能
-h, --help 显示此帮助信息
-v, --version 展示APM版本号
```
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: 保存新增文件
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
APM 使用了特殊的精简版 AmberCE 兼容环境,相关的 Tips 见 [Tips](tips.md)。
Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

+34
View File
@@ -0,0 +1,34 @@
玲珑官方搞了个这玩意,APM用户这边有人想要那我就写了,其实意义不大
好用就完了,APM又快又简单
| 特性 | 如意玲珑 | 琥珀 APM | Snap | AppImage |
| ------------------------- | ------------------------------- | ------------- | ---------------- | -------------------------------------- |
| 打包桌面应用 | ✔ | ✔ | ✔ | ✔ |
| 打包终端应用 | ✔ | ✔ | ✔ | ✔ |
| 处理服务器应用 | ✔ | ✔ | ✔ | ✘ |
| 打包系统服务(root 权限) | ✘ | ✘ | ✔ | ✘ |
| 主题功能正常 | ✔ | ✔ | ✔ | ✔ |
| 提供库托管服务 | ✔ | ✔ | ✘ | ✘ |
| 库/依赖来源 | 包自身携带 | 包自身携带或使用 APM 中层 Base,用法详见[链接](https://bbs.deepin.org.cn/post/292648) | | |
| SDK | 包自身携带 | 无需专用SDK,复用Debian即可 | | |
| 商业支持 | ✔ | ✘ | ✔ | ✘ |
| 应用商店数量 | 预计 4700+ | 200+常用软件,持续扩充中 | 6600+ | 1300+ |
| 开发工具支持 | linglong-builder | 任意支持部署到debian的工具均支持 | electron-builder | |
| 容器支持 | ✔ | ✔ | ✔ | ◐ (官方不提供,技术上可行) |
| rootless 容器 | ✔ | ✔ | ✘ | ✘ |
| 不安装运行 | ✔ (提供 Bundle 模式) | ◐ (官方不提供,技术上可行) | ✘ | ✔ |
| 不解压运行 | ✔ (提供 Bundle 模式) | ◐ (官方不提供,技术上可行) | ✔ | ✔ |
| 自分发/绿色格式分发 | ✔ | ◐ (官方不提供,技术上可行) | ✘ | ✔ |
| 支持 Wine 应用运行 | ✔ | ✔ | ◐ (理论可行) | ◐ (使用 LD 修改 open 调用,兼容性差) |
| 离线环境支持 | ✔ | ✔ | ✔ | ✔ |
| 权限管理 | ✔ | ✘ | ✔ | ✘ |
| 中心仓库 | mirror-repo-linglong.deepin.com | 星火应用商店 | Snap Store | AppImageHub |
| 多版本共存 | ✔ | ✔ | ✔ | ✔ |
| 点对点分发 | ✔ | ✔ | ✔ | ✔ |
| 多镜像源加速分发 | ✘ | ✔ | ✘ | ◐ (官方不提供,技术上可行) |
| 作为普通安装包直接安装到宿主机 | ✘ | ✔ | ✘ | ✘ |
| 自定义生成 runtime base | ✘ | ✔ | ✘ | ✘ |
| 多级layer自动管理 | ◐ (理论可行) | ✔ | ✘ | ✘ |
| 一键直接转换 Debian 标准软件包 | ✘ | ✔ | ✘ | ✘ |
| 应用升级 | 仓库升级 | 仓库升级 | 仓库升级 | 官方工具升级 |
+4 -4
View File
@@ -1,10 +1,10 @@
Package: apm
Source: amber-ce
Version: 1.0.10
Architecture: amd64
Version: 1.1.2
Architecture: arm64
Maintainer: shenmo <shenmo@spark-app.store>
Installed-Size: 48724
Depends: bubblewrap, flatpak, policykit-1 | pkexec | polkit-1 | polkit, systemd, procps,coreutils,fuse-overlayfs,xz-utils
Installed-Size: 46496
Depends: bubblewrap, flatpak, policykit-1 | pkexec | polkit-1 | polkit, systemd, procps,coreutils,fuse-overlayfs,xz-utils,libnotify-bin,curl,xdg-user-dirs
Section: misc
Conflicts: ace-host-integration
Priority: optional
+10
View File
@@ -10,6 +10,16 @@ if [ "$1" = "remove" ] || [ "$1" = "purge" ];then
echo "清理卸载残留"
rm -rf /var/lib/apm/
for username in $(ls /home)
do
echo /home/$username
if [ -d "/home/$username/.apm/" ]
then
rm -fr "/home/$username/.apm/"
fi
done
else
echo "非卸载,跳过清理"
fi
+17 -5
View File
@@ -7,6 +7,10 @@ log.info() { echo -e "[\e[96mINFO\e[0m]: \e[1m$*\e[0m"; }
log.debug() { echo -e "[\e[32mDEBUG\e[0m]: \e[1m$*\e[0m"; }
SCRIPT_NAME=$(basename "$0")
if ! command -v dpkg > /dev/null ;then
log.error "若想使用APM软件包转换器,您需先安装dpkg"
exit 1
fi
# 显示用法信息
usage() {
echo "用法: $SCRIPT_NAME --base <basename> [--base <basename> ...] <deb文件路径> [--pkgname <包名>] [--version <版本号>]"
@@ -274,7 +278,7 @@ mkdir -p "$MODIFIED_DEB_DIR/data"
cp -r "$EXTRACT_DIR"/* "$MODIFIED_DEB_DIR/" 2>/dev/null || true
# 使用fakeroot重新打包
cd "$MODIFIED_DEB_DIR" && fakeroot dpkg-deb --build -Z none . "$MODIFIED_DEB_PATH"
cd "$MODIFIED_DEB_DIR" && fakeroot dpkg-deb --build -Z none . "$MODIFIED_DEB_PATH"
cd - > /dev/null
if [ ! -f "$MODIFIED_DEB_PATH" ]; then
@@ -315,20 +319,28 @@ for BASENAME in "${BASENAMES[@]}"; do
log.info " 写入: $BASENAME"
done
# 创建postinst脚本
cat > "$PKG_BUILD_DIR/DEBIAN/postinst" << 'EOF'
# 创建postrm脚本
cat > "$PKG_BUILD_DIR/DEBIAN/postrm" << 'EOF'
#!/bin/bash
PACKAGE_NAME="$DPKG_MAINTSCRIPT_PACKAGE"
if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
echo "清理卸载残留"
rm -rf "/var/lib/apm/$PACKAGE_NAME"
for username in $(ls /home)
do
echo /home/$username
if [ -d "/home/$username/.apm/$PACKAGE_NAME" ]
then
rm -fr "/home/$username/.apm/$PACKAGE_NAME"
fi
done
else
echo "非卸载,跳过清理"
fi
EOF
chmod +x "$PKG_BUILD_DIR/DEBIAN/postinst"
chmod +x "$PKG_BUILD_DIR/DEBIAN/postrm"
# 8. 复制文件到新的APM包
log.info "复制文件到新的APM包..."
@@ -387,7 +399,7 @@ EOF
OUTPUT_DEB="${NEW_PKGNAME}_${NEW_VERSION}_${ORIG_ARCH}.deb"
# 打包
fakeroot dpkg-deb --build "$PKG_BUILD_DIR" "$OUTPUT_DEB"
fakeroot dpkg-deb --build "$PKG_BUILD_DIR" "$OUTPUT_DEB"
log.info "转换完成!"
log.info "生成的APM包: $OUTPUT_DEB"
+25 -1
View File
@@ -3,7 +3,29 @@
if [[ ! -e "/usr/share/gxde-api" ]] && ! grep -q "Kylin" /etc/os-release; then
exit 0 # No needed
fi
function ensure_dir() {
local dir="$1"
# 检查目录是否为空
if [ -z "$dir" ]; then
echo "错误: 目录路径不能为空"
return 1
fi
# 检查目录是否存在
if [ ! -d "$dir" ]; then
echo "目录 '$dir' 不存在,正在创建..."
if mkdir -p "$dir"; then
echo "成功创建目录 '$dir'"
return 0
else
echo "错误: 无法创建目录 '$dir'"
return 1
fi
else
return 0
fi
}
# 函数:检查目录并创建符号链接
process_directory() {
local source_dir="$1"
@@ -18,6 +40,8 @@ process_directory() {
fi
}
ensure_dir "/usr/local/share/applications/"
ensure_dir "/usr/local/share/icons/"
# 处理 applications 目录
process_directory "/var/lib/apm/apm/files/ace-env/amber-ce-tools/data-dir/applications/" \
"/usr/local/share/applications/" "Applications"
+148
View File
@@ -0,0 +1,148 @@
#!/bin/bash
# 发送通知
function get_upgradable_list(){
output=$(env LANGUAGE=en_US amber-pm-debug aptss list --upgradable | awk NR\>1)
IFS_OLD="$IFS"
IFS=$'\n'
for line in $output ; do
PKG_NAME=$(echo $line | awk -F '/' '{print $1}')
PKG_NEW_VER=$(echo $line | awk -F ' ' '{print $2}')
PKG_CUR_VER=$(echo $line | awk -F ' ' '{print $6}' | awk -F ']' '{print $1}')
echo "${PKG_NAME} ${PKG_NEW_VER} ${PKG_CUR_VER}"
done
IFS="$IFS_OLD"
}
function get_current_user() {
# 优先通过 who 命令获取用户
local user
user=$(who | awk '{print $1}' | head -n 1 2>/dev/null)
# 如果 who 无输出,则通过 loginctl 获取
if [[ -z "$user" ]]; then
user=$(loginctl list-sessions --no-legend 2>/dev/null | awk '{print $3}' | head -n 1)
fi
# 返回最终结果(可能为空)
echo "${user}"
}
function notify-send() {
# Detect user using the display
local user=$(get_current_user)
# Detect uid of the user
local uid=$(id -u $user)
sudo -u $user DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus notify-send "$@"
}
# 检测网络链接畅通
function network-check() {
# 超时时间
local timeout=15
# 目标网站
local target=www.baidu.com
# 获取响应状态码
local ret_code=$(curl -I -s --connect-timeout ${timeout} ${target} -w %{http_code} | tail -n1)
if [ "$ret_code" = "200" ]; then
# 网络畅通
return 0
else
# 网络不畅通
return 1
fi
}
# 初始化等待时间和最大等待时间
initial_wait_time=15 # 初始等待时间 15 秒
max_wait_time=$((12 * 3600)) # 最大等待时间 12 小时
# 检测网络,若不通则进行重试,采用指数退避算法
wait_time=$initial_wait_time
while ! network-check; do
echo "$TRANSHELL_CONTENT_NETWORK_FAIL"
echo "Waiting for network to recover... Retrying in ${wait_time} seconds."
sleep $wait_time
wait_time=$((wait_time * 2)) # 等待时间翻倍
if [ $wait_time -gt $max_wait_time ]; then
wait_time=$max_wait_time # 最大等待时间限制为12小时
fi
done
# 每日更新星火源文件
updatetext=$(LANGUAGE=en_US apm update 2>&1)
# 在网络恢复后,继续更新操作
retry_count=0
max_retries=12 # 最大重试次数,防止死循环
until ! echo $updatetext | grep -q "E:"; do
if [ $retry_count -ge $max_retries ]; then
echo "Reached maximum retry limit for apm update."
exit 1
fi
echo "Update failed...Will retry in 15sec"
sleep 15
updatetext=$(LANGUAGE=en_US apm update 2>&1)
retry_count=$((retry_count + 1))
done
update_app_number=$(env LANGUAGE=en_US apm list --upgradable 2>/dev/null | grep -c upgradable)
echo "update_app_number is $update_app_number"
if [ "$update_app_number" -le 0 ]; then
exit 0
fi
# 获取用户选择的要更新的应用
PKG_LIST="$(get_upgradable_list)"
# 指定分隔符为 \n
IFS_OLD="$IFS"
IFS=$'\n'
for line in $PKG_LIST; do
# PKG_NAME=$(echo $line | awk -F ' ' '{print $1}')
# PKG_NEW_VER=$(echo $line | awk -F ' ' '{print $2}')
# PKG_CUR_VER=$(echo $line | awk -F ' ' '{print $3}')
# amber-pm-debug dpkg --compare-versions $PKG_NEW_VER le $PKG_CUR_VER
#
# if [ $? -eq 0 ]; then
# let update_app_number=$update_app_number-1
# continue
# fi
# 检测是否是 hold 状态
PKG_STA=$(amber-pm-debug dpkg-query -W -f='\''\${db:Status-Want}'\' $PKG_NAME)
#PKG_STA=$(dpkg-query -W -f='${db:Status-Want}' $PKG_NAME)
if [ "$PKG_STA" = "hold" ]; then
let update_app_number=$update_app_number-1
fi
done
# 还原分隔符
IFS="$IFS_OLD"
if [ $update_app_number -le 0 ]; then
exit 0
fi
# 如果都是hold或者版本一致的那就直接退出,否则把剩余的给提醒了
# TODO: 除了apt-mark hold之外额外有一个禁止检查列表
notify-send -a apm "APM 琥珀应用包" "有 $update_app_number 个应用可以更新啦,apm list --upgradable 以查看" || true # Some machine don't have bus, or who command just print nothing.
+67 -21
View File
@@ -1,5 +1,5 @@
#!/bin/bash
VERSION=1.0.10
VERSION=1.1.2
# 获取脚本名称用于帮助信息
SCRIPT_NAME=$(basename "$0")
PATH_PREFIX=/var/lib/apm/apm/files/ace-env/
@@ -17,23 +17,33 @@ APM - Amber Package Manager ${VERSION}
Usage:
$SCRIPT_NAME [COMMAND] [OPTIONS] [PACKAGES...]
Commands:
install 安装软件包
remove 卸载软件包
update 更新软件包信息
download 下载包
clean 清除缓存软件包
autoremove 自动移除不需要的包
full-upgrade 完全升级软件包
run <package> 运行指定软件包的可执行文件
ssaudit <path> 使用 ssaudit 进行软件安装,详情见 spark-store
debug 显示调试系统信息并进入调试环境
amber 彩蛋功能
xmp360 彩蛋功能
bronya 彩蛋功能
install 安装软件包
remove 卸载软件包
run <package> 运行指定软件包的可执行文件
sandbox-run <package> 运行指定软件包的可执行文件(主目录沙箱化)
-h, --help 显示此帮助信息
update 更新软件包信息
hold 锁定软件包版本
unhold 解锁软件包版本
full-upgrade 升级全部软件包
list 查看可用软件包信息
search 搜索软件包
download 下载包
show 展示包信息
clean 清除缓存软件包
autoremove 自动移除不需要的包
ssaudit <path> 使用 ssaudit 进行本地软件安装,详情见 spark-store
debug 显示调试系统信息并进入调试环境
amber 彩蛋功能
xmp360 彩蛋功能
bronya 彩蛋功能
-h, --help 显示此帮助信息
-v, --version 展示APM版本号
EOF
}
@@ -44,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"
@@ -96,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}"
@@ -227,7 +241,7 @@ case "$1" in
apm-nvidia-toggle
amber-pm-gxde-desktop-fix
;;
download|search|policy|list|update|clean)
download|search|policy|list|update|clean|show)
command=$1
shift
amber-pm-debug aptss "$command" "$@"
@@ -239,6 +253,18 @@ case "$1" in
exit $exit_code
fi
;;
hold|unhold)
command=$1
shift
amber-pm-debug apt-mark "$command" "$@"
exit_code=$?
if [ $exit_code -eq 0 ]; then
log.info "Operation successful"
else
log.error "Error: Operation failed"
exit $exit_code
fi
;;
remove|autoremove|purge|autopurge)
# 特殊APT命令:移除第一个参数后传递其余参数
@@ -280,7 +306,7 @@ case "$1" in
fi
coredir=$pkg
export APM_PKG_NAME=$pkg
# 检测是否有额外命令参数
if [ $# -gt 0 ]; then
@@ -293,15 +319,35 @@ case "$1" in
exit 1
fi
;;
sandbox-run)
# 运行包命令:第二个参数必须是包名
export APM_USE_SANDBOX=1
shift
$0 run "$@"
;;
debug)
debug_info
shift
debug_info $@
;;
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)
show_help
;;
-v|--version)
echo "$VERSION"
;;
amber)
amber_egg
;;
@@ -6,7 +6,7 @@ After=apt-daily.service network.target network-online.target systemd-networkd.se
[Service]
Type=simple
RemainAfterExit=yes
ExecStart=bash -c "apm clean && apm update"
ExecStart=amber-pm-upgrade-notifier
Restart=on-failure
RestartSec=10
+11
View File
@@ -0,0 +1,11 @@
[Unit]
Description=Timer for APM Daily Update
[Timer]
# 开机后第一次执行
OnBootSec=1min
# 每天执行一次
OnUnitActiveSec=1d
[Install]
WantedBy=timers.target
@@ -44,11 +44,14 @@ _apm()
"update"
"upgrade" "full-upgrade" "dist-upgrade"
"run"
"sandbox-run"
"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|sandbox-run)
COMPREPLY=( $( compgen -W "$(apm_run_compgen)" "$cur" ) )
return 0
;;
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

+32 -5
View File
@@ -1,13 +1,41 @@
#!/bin/bash
function 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
function ensure_dir() {
local dir="$1"
# 检查目录是否为空
if [ -z "$dir" ]; then
echo "错误: 目录路径不能为空"
return 1
fi
# 检查目录是否存在
if [ ! -d "$dir" ]; then
echo "目录 '$dir' 不存在,正在创建..."
if mkdir -p "$dir"; then
echo "成功创建目录 '$dir'"
return 0
else
echo "错误: 无法创建目录 '$dir'"
return 1
fi
else
return 0
fi
}
chrootEnvPath="${chrootEnvPath:-$(pwd)/ace-env}"
APM_PKG_NAME="${APM_PKG_NAME:-apm-general}"
non_root_user=$(who | awk '{print $1}' | head -n 1)
uid=$(id -u $non_root_user)
ensure_dir $HOME/.apm/${APM_PKG_NAME}/.deepinwine
#### This part is for args pharm
@@ -100,10 +128,9 @@ BIND_DIRS=(
"--ro-bind-try /usr/share/fonts /usr/local/share/fonts"
"--dev-bind-try /etc/resolv.conf /etc/resolv.conf"
"--dev-bind-try /home /home"
"--dev-bind-try $HOME/.apm/${APM_PKG_NAME}/.deepinwine $HOME/.deepinwine"
)
EXTRA_ARGS=(
"--hostname Amber-PM"
"--unshare-uts"
"--cap-add CAP_SYS_ADMIN"
)
+4 -1
View File
@@ -1,6 +1,9 @@
#!/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}"
@@ -1,26 +1,47 @@
#!/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
function 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
function ensure_dir() {
local dir="$1"
# 检查目录是否为空
if [ -z "$dir" ]; then
echo "错误: 目录路径不能为空"
return 1
fi
# 检查目录是否存在
if [ ! -d "$dir" ]; then
echo "目录 '$dir' 不存在,正在创建..."
if mkdir -p "$dir"; then
echo "成功创建目录 '$dir'"
return 0
else
echo "错误: 无法创建目录 '$dir'"
return 1
fi
else
return 0
fi
}
chrootEnvPath="${chrootEnvPath:-$(pwd)/ace-env}"
chrootEnvPath=/var/lib/apm/$PKGNAME/files/ace-env
APM_PKG_NAME="${APM_PKG_NAME:-apm-general}"
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)
ensure_dir $HOME/.apm/${APM_PKG_NAME}/
ensure_dir $HOME/.apm/${APM_PKG_NAME}/$(basename $(xdg-user-dir DESKTOP))
ensure_dir $HOME/.apm/${APM_PKG_NAME}/$(basename $(xdg-user-dir DOCUMENTS))
ensure_dir $HOME/.apm/${APM_PKG_NAME}/$(basename $(xdg-user-dir PICTURES))
ensure_dir $HOME/.apm/${APM_PKG_NAME}/$(basename $(xdg-user-dir DOWNLOAD))
ensure_dir $HOME/.apm/${APM_PKG_NAME}/$(basename $(xdg-user-dir VIDEOS))
ensure_dir $HOME/.apm/${APM_PKG_NAME}/$(basename $(xdg-user-dir MUSIC))
#### This part is for args pharm
@@ -92,6 +113,7 @@ ENV_VARS=(
"PULSE_SERVER /run/user/\$uid/pulse/native"
"PATH /amber-ce-tools/bin-override:\$PATH"
"IS_ACE_ENV 1"
"GTK_USE_PORTAL 1"
"XDG_DATA_DIRS /amber-ce-tools/additional-data-dir-in-container:\$XDG_DATA_DIRS"
)
@@ -108,19 +130,24 @@ BIND_DIRS=(
"--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/icons /usr/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"
"--dev-bind-try $HOME/.apm/${APM_PKG_NAME}/ $HOME/"
"--dev-bind-try $(xdg-user-dir DESKTOP) $(xdg-user-dir DESKTOP)"
"--dev-bind-try $(xdg-user-dir DOCUMENTS) $(xdg-user-dir DOCUMENTS)"
"--dev-bind-try $(xdg-user-dir PICTURES) $(xdg-user-dir PICTURES)"
"--dev-bind-try $(xdg-user-dir DOWNLOAD) $(xdg-user-dir DOWNLOAD)"
"--dev-bind-try $(xdg-user-dir VIDEOS) $(xdg-user-dir VIDEOS)"
"--dev-bind-try $(xdg-user-dir MUSIC) $(xdg-user-dir MUSIC)"
)
EXTRA_ARGS=(
"--hostname Amber-PM"
"--unshare-uts"
# "--cap-add CAP_SYS_ADMIN"
"--cap-add CAP_SYS_ADMIN"
)
EXTRA_SCRIPTS=(
cursor_theme_dir_integration
# cursor_theme_dir_integration
)
##########合成bwrap 4. 合成并执行指令
@@ -141,10 +168,8 @@ for var in "${EXTRA_SCRIPTS[@]}"; do
$var
done
# 添加最终的 bash 命令
add_command "bash -c \"/usr/bin/bwrap ${container_command}\""
add_command "bash -c \"${container_command}\""
# 输出完整的 EXEC_COMMAND 以查看
# echo "${EXEC_COMMAND}"
-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/icons /usr/local/share/icons \
--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 /home /home \
locale-gen
+5 -2
View File
@@ -1,5 +1,10 @@
#!/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`
parent_dir=`dirname $curdir`
pparent_dir=`dirname $parent_dir`
@@ -115,8 +120,6 @@ BIND_DIRS=(
"--dev-bind-try /home /home"
)
EXTRA_ARGS=(
"--hostname Amber-PM"
"--unshare-uts"
"--cap-add CAP_SYS_ADMIN"
)
@@ -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
+5 -4
View File
@@ -4,7 +4,7 @@
2. apm 添加了一个钩子(debian only),在安装到 /var/lib/apm 下的应用存在ace-env时,进行configure nvidia操作;若存在entries,则进行链接到/usr/share/applications操作
3. apm 内置 ubuntu rootfs的修改如下
3. apm 内置 rootfs的修改如下
* 安装xz-utils
@@ -26,8 +26,7 @@
* 重要:如何在APM内更新内容——如何覆盖?
* deb全自动转apm
* apm版融合商店
* 类似 Wine 运行器的方式全图形化傻瓜式打包
* 自动融合 APM 应用到系统主机,并实现右键卸载
@@ -42,4 +41,6 @@
* 添加 gxde fixer 确保在GXDE下可以正常展示应用(即进行一次host integration类操作)
* 完成amd64软件源配置
* 修改aptss以兼容APM源加速
* apm环境变量添加 IS_APM_ENV=1 GTK_USE_PORTAL=1
* apm环境变量添加 IS_APM_ENV=1 GTK_USE_PORTAL=1
* 重要:如何在APM内更新内容——如何覆盖?
* deb全自动转apm