From 908f3ab9dea4a2a50068cfe06cacdf857c1be10d Mon Sep 17 00:00:00 2001 From: shenmo Date: Fri, 31 Oct 2025 21:09:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E6=80=A7=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E4=B8=BB=E7=9B=AE=E5=BD=95=E6=B2=99=E7=AE=B1--Wine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DEBIAN/control | 2 +- src/DEBIAN/postrm | 14 +++++++++++++- src/usr/bin/amber-pm-convert | 8 ++++++++ src/usr/bin/apm | 4 ++-- src/var/lib/apm/apm/files/ace-run | 32 +++++++++++++++++++++++++++---- 5 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/DEBIAN/control b/src/DEBIAN/control index 092841e..5014c1f 100755 --- a/src/DEBIAN/control +++ b/src/DEBIAN/control @@ -1,6 +1,6 @@ Package: apm Source: amber-ce -Version: 1.1.1 +Version: 1.1.2 Architecture: amd64 Maintainer: shenmo Installed-Size: 48724 diff --git a/src/DEBIAN/postrm b/src/DEBIAN/postrm index 9ca9e81..6d8ca5e 100755 --- a/src/DEBIAN/postrm +++ b/src/DEBIAN/postrm @@ -5,11 +5,23 @@ systemctl disable apm-daily-update -if [ "$1" = "remove" ] || [ "$1" = "purge" ];then +if [ "$1" = "remove" ] ;then +echo "执行卸载操作,您的容器仍然被保留在 /var/lib/apm/ 下。请执行 sudo apt purge apm 以清理" +elif [ "$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 diff --git a/src/usr/bin/amber-pm-convert b/src/usr/bin/amber-pm-convert index 3a98525..aeb311c 100755 --- a/src/usr/bin/amber-pm-convert +++ b/src/usr/bin/amber-pm-convert @@ -327,6 +327,14 @@ 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 diff --git a/src/usr/bin/apm b/src/usr/bin/apm index 8bee2d9..2fafe06 100755 --- a/src/usr/bin/apm +++ b/src/usr/bin/apm @@ -1,5 +1,5 @@ #!/bin/bash -VERSION=1.1.1 +VERSION=1.1.2 # 获取脚本名称用于帮助信息 SCRIPT_NAME=$(basename "$0") PATH_PREFIX=/var/lib/apm/apm/files/ace-env/ @@ -301,7 +301,7 @@ case "$1" in fi coredir=$pkg - + export APM_PKG_NAME=$pkg # 检测是否有额外命令参数 if [ $# -gt 0 ]; then diff --git a/src/var/lib/apm/apm/files/ace-run b/src/var/lib/apm/apm/files/ace-run index 9e91668..3c8f403 100755 --- a/src/var/lib/apm/apm/files/ace-run +++ b/src/var/lib/apm/apm/files/ace-run @@ -1,17 +1,40 @@ #!/bin/bash -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 + echo "目录 '$dir' 已存在" + 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 if [ "$1" = "" ];then @@ -103,6 +126,7 @@ 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=( "--cap-add CAP_SYS_ADMIN"