From e5933373d7a6081058588fbe336d10f1efb41d69 Mon Sep 17 00:00:00 2001 From: shenmo Date: Wed, 25 Mar 2026 19:42:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9C=A8deepin=E4=B8=8B?= =?UTF-8?q?=E5=8F=B3=E9=94=AE=E5=8D=B8=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DEBIAN/control | 2 +- src/usr/bin/amber-pm-app-uninstaller | 50 +++++++++++++++++++ .../store.spark-app.apm-uninstaller.policy | 18 +++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100755 src/usr/bin/amber-pm-app-uninstaller create mode 100644 src/usr/share/polkit-1/actions/store.spark-app.apm-uninstaller.policy diff --git a/src/DEBIAN/control b/src/DEBIAN/control index e7998b2..002f729 100755 --- a/src/DEBIAN/control +++ b/src/DEBIAN/control @@ -4,7 +4,7 @@ Version: @VERSION@ Architecture: amd64 Maintainer: shenmo Installed-Size: 49000 -Depends: bubblewrap, flatpak, policykit-1 | pkexec | polkit-1 | polkit, systemd, procps,coreutils,fuse-overlayfs,xz-utils | xz,libnotify-bin,curl,xdg-user-dirs,bash +Depends: zenity | garma,bubblewrap, flatpak, policykit-1 | pkexec | polkit-1 | polkit, systemd, procps,coreutils,fuse-overlayfs,xz-utils | xz,libnotify-bin,curl,xdg-user-dirs,bash Recommends: dpkg, fakeroot, busybox Section: misc Conflicts: ace-host-integration diff --git a/src/usr/bin/amber-pm-app-uninstaller b/src/usr/bin/amber-pm-app-uninstaller new file mode 100755 index 0000000..68a76fe --- /dev/null +++ b/src/usr/bin/amber-pm-app-uninstaller @@ -0,0 +1,50 @@ +#!/bin/bash + +# ===== Log ===== +log.warn() { echo -e "[\e[33mWARN\e[0m]: \e[1m$*\e[0m"; } +log.error() { echo -e "[\e[31mERROR\e[0m]: \e[1m$*\e[0m"; } +log.info() { echo -e "[\e[96mINFO\e[0m]: \e[1m$*\e[0m"; } +log.debug() { echo -e "[\e[32mDEBUG\e[0m]: \e[1m$*\e[0m"; } + +# 获取原始用户(调用 pkexec 或 sudo 的用户) +ORIGINAL_USER="${SUDO_USER:-$USER}" +ORIGINAL_UID=$(id -u "$ORIGINAL_USER") +ORIGINAL_DISPLAY="${DISPLAY:-:0}" +ORIGINAL_XAUTHORITY="${XAUTHORITY:-$HOME/.Xauthority}" + +# 以原始用户身份运行图形界面命令 +function run_as_user() { + sudo -u "$ORIGINAL_USER" DISPLAY="$ORIGINAL_DISPLAY" XAUTHORITY="$ORIGINAL_XAUTHORITY" "$@" +} + +function zenity() { + if [[ -e /usr/bin/garma ]]; then + run_as_user garma "$@" + else + run_as_user "$(command -v zenity)" "$@" + fi +} + +function notify-send() { + local uid="$ORIGINAL_UID" + sudo -u "$ORIGINAL_USER" DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${uid}/bus" notify-send "$@" +} + +# 如果当前不是 root,则用 pkexec 重新执行并传递必要的环境变量 +if [ "$UID" != "0" ]; then + # 保存当前环境变量,通过 env 传递给 pkexec + exec pkexec "$0" "$@" + exit $? +fi + + + +# 用户确认 +if zenity --question --text="Going to uninstall $1.\nPlease Confirm" --no-wrap; then + # 启动卸载命令(这里假设 apm 是系统命令,请根据实际情况调整) + # 注意:apm 可能不存在,可替换为 apt、dnf 等 + apm autoremove "$1" -y + ret=$? + + +fi \ No newline at end of file diff --git a/src/usr/share/polkit-1/actions/store.spark-app.apm-uninstaller.policy b/src/usr/share/polkit-1/actions/store.spark-app.apm-uninstaller.policy new file mode 100644 index 0000000..e841a24 --- /dev/null +++ b/src/usr/share/polkit-1/actions/store.spark-app.apm-uninstaller.policy @@ -0,0 +1,18 @@ + + + + Flamescion + x-package-repository + + 运行justinstallme需要权限 + 要使用ssinstall需要权限 + + yes + yes + yes + + /usr/bin/amber-pm-app-uninstaller + true + +