mirror of
https://gitee.com/amber-ce/amber-pm
synced 2026-05-14 02:00:20 +08:00
Merge remote-tracking branch 'refs/remotes/origin/master'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
Package: apm
|
||||
Version: 1.1.2
|
||||
Version: 1.1.3
|
||||
Maintainer: shenmo <jifengshenmo@outlook.com>
|
||||
Priority: optional
|
||||
Section: utils
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enumAppInfoList() {
|
||||
appInfoList=()
|
||||
apps="/var/lib/apm"
|
||||
@@ -13,6 +9,7 @@ enumAppInfoList() {
|
||||
done
|
||||
echo "${appInfoList[@]}"
|
||||
}
|
||||
|
||||
linkDir() {
|
||||
ensureTargetDir() {
|
||||
targetFile=$1
|
||||
@@ -26,17 +23,14 @@ linkDir() {
|
||||
targetDir=$(dirname "$target")
|
||||
find "$source" -type f | while read sourceFile; do
|
||||
targetFile="$targetDir/${sourceFile#$sourceDir/}"
|
||||
|
||||
|
||||
ensureTargetDir "$targetFile"
|
||||
sourceFile=$(realpath --relative-to="$(dirname $targetFile)" "$sourceFile" )
|
||||
if [ ! -e "${targetFile}" ];then
|
||||
ln -sv "$sourceFile" "$targetFile"
|
||||
sourceFile=$(realpath --relative-to="$(dirname $targetFile)" "$sourceFile" )
|
||||
if [ ! -e "${targetFile}" ];then
|
||||
ln -sv "$sourceFile" "$targetFile"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
linkApp() {
|
||||
appID=$1
|
||||
appEntriesDir="/var/lib/apm/$appID/entries"
|
||||
@@ -53,6 +47,21 @@ linkApp() {
|
||||
if [ ! -d "$folder" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# 对于 applications 目录,先为所有 .desktop 文件添加必要的字段
|
||||
if [ "$folder" = "$appEntriesDir/applications" ]; then
|
||||
find "$folder" -name "*.desktop" -type f | while read desktop; do
|
||||
# 添加 X-APM-APPID
|
||||
if ! grep -q "^X-APM-APPID=" "$desktop"; then
|
||||
echo "X-APM-APPID=$appID" >> "$desktop"
|
||||
fi
|
||||
# 添加 X-Deepin-PreUninstall
|
||||
if ! grep -q "^X-Deepin-PreUninstall=" "$desktop"; then
|
||||
echo "X-Deepin-PreUninstall=amber-pm-app-uninstaller $appID" >> "$desktop"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$folder" = "$appEntriesDir/polkit" ]; then
|
||||
linkDir "$folder" "/usr/share/polkit-1"
|
||||
elif [ "$folder" = "$appEntriesDir/fonts/conf" ]; then
|
||||
@@ -64,32 +73,29 @@ linkApp() {
|
||||
}
|
||||
|
||||
function exec_uos_package_link(){
|
||||
|
||||
for app in $(enumAppInfoList); do
|
||||
linkApp "$app" &
|
||||
|
||||
done
|
||||
wait
|
||||
for app in $(enumAppInfoList); do
|
||||
linkApp "$app" &
|
||||
done
|
||||
wait
|
||||
}
|
||||
|
||||
function exec_v23_icon_link(){
|
||||
# Fix v23 broken icon
|
||||
if [ ! -d "/usr/share/icons/hicolor/scalable/apps" ];then
|
||||
mkdir -p /usr/share/icons/hicolor/scalable/apps
|
||||
fi
|
||||
# Fix v23 broken icon
|
||||
if [ ! -d "/usr/share/icons/hicolor/scalable/apps" ];then
|
||||
mkdir -p /usr/share/icons/hicolor/scalable/apps
|
||||
fi
|
||||
|
||||
for icon_root_icon_path in $(ls /usr/share/icons/*.png /usr/share/icons/*.svg 2>/dev/null)
|
||||
do
|
||||
target_icon_path=/usr/share/icons/hicolor/scalable/apps/$(basename ${icon_root_icon_path})
|
||||
if [ ! -e ${target_icon_path} ];then
|
||||
ln -sv $(realpath --relative-to=/usr/share/icons/hicolor/scalable/apps ${icon_root_icon_path}) /usr/share/icons/hicolor/scalable/apps
|
||||
fi
|
||||
done
|
||||
for icon_root_icon_path in $(ls /usr/share/icons/*.png /usr/share/icons/*.svg 2>/dev/null)
|
||||
do
|
||||
target_icon_path=/usr/share/icons/hicolor/scalable/apps/$(basename ${icon_root_icon_path})
|
||||
if [ ! -e ${target_icon_path} ];then
|
||||
ln -sv $(realpath --relative-to=/usr/share/icons/hicolor/scalable/apps ${icon_root_icon_path}) /usr/share/icons/hicolor/scalable/apps
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function exec_link_clean(){
|
||||
# remove broken links in /usr/share
|
||||
|
||||
# remove broken links in /usr/share
|
||||
find /usr/share/applications -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/icons -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/mime/packages -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
@@ -98,77 +104,74 @@ function exec_link_clean(){
|
||||
find /usr/share/fcitx -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/help -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/locale -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
# find /usr/lib/$(gcc -dumpmachine)/fcitx -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/lib/mozilla/plugins -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/polkit-1/actions -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/fonts -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /etc/fonts/conf.d -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
|
||||
|
||||
}
|
||||
|
||||
function exec_uos_package_update(){
|
||||
update-icon-caches /usr/share/icons/* > /dev/null 2>&1 &
|
||||
update-desktop-database -q > /dev/null 2>&1 &
|
||||
update-mime-database -V /usr/share/mime > /dev/null 2>&1 &
|
||||
glib-compile-schemas /usr/share/glib-2.0/schemas/ > /dev/null 2>&1 &
|
||||
|
||||
}
|
||||
|
||||
function exec_debian_compatibile_links(){
|
||||
# 源目录和目标目录定义
|
||||
local SOURCE_DIR="/var/lib/apm"
|
||||
local TARGET_DIR="/var/lib/apm/apm/files/ace-env/var/lib/apm"
|
||||
# 源目录和目标目录定义
|
||||
local SOURCE_DIR="/var/lib/apm"
|
||||
local TARGET_DIR="/var/lib/apm/apm/files/ace-env/var/lib/apm"
|
||||
|
||||
# 检查目标目录是否存在
|
||||
if [[ ! -d "$TARGET_DIR" ]]; then
|
||||
mkdir -p $TARGET_DIR
|
||||
fi
|
||||
|
||||
# 第一部分:为缺失的目录创建软链接
|
||||
echo "检查并创建缺失的软链接..."
|
||||
for dir in "$SOURCE_DIR"/*/; do
|
||||
# 获取目录名(去掉路径和尾部斜杠)
|
||||
dirname=$(basename "$dir")
|
||||
|
||||
# 跳过 apm 目录
|
||||
if [[ "$dirname" == "apm" ]]; then
|
||||
continue
|
||||
# 检查目标目录是否存在
|
||||
if [[ ! -d "$TARGET_DIR" ]]; then
|
||||
mkdir -p $TARGET_DIR
|
||||
fi
|
||||
|
||||
# 检查目标目录中是否已存在对应的软链接或目录
|
||||
target_link="$TARGET_DIR/$dirname"
|
||||
if [[ ! -e "$target_link" ]]; then
|
||||
echo "创建软链接: $target_link -> $dir"
|
||||
ln -sv "$dir" "$target_link"
|
||||
fi
|
||||
done
|
||||
|
||||
# 第二部分:清理无效的软链接
|
||||
echo "清理无效的软链接..."
|
||||
for link in "$TARGET_DIR"/*; do
|
||||
# 检查是否为软链接
|
||||
if [[ -L "$link" ]]; then
|
||||
# 检查软链接是否有效(指向的目标是否存在)
|
||||
if [[ ! -e "$link" ]]; then
|
||||
echo "删除无效软链接: $link"
|
||||
rm "$link"
|
||||
# 第一部分:为缺失的目录创建软链接
|
||||
echo "检查并创建缺失的软链接..."
|
||||
for dir in "$SOURCE_DIR"/*/; do
|
||||
# 获取目录名(去掉路径和尾部斜杠)
|
||||
dirname=$(basename "$dir")
|
||||
|
||||
# 跳过 apm 目录
|
||||
if [[ "$dirname" == "apm" ]]; then
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# 检查目标目录中是否已存在对应的软链接或目录
|
||||
target_link="$TARGET_DIR/$dirname"
|
||||
if [[ ! -e "$target_link" ]]; then
|
||||
echo "创建软链接: $target_link -> $dir"
|
||||
ln -sv "$dir" "$target_link"
|
||||
fi
|
||||
done
|
||||
|
||||
# 第二部分:清理无效的软链接
|
||||
echo "清理无效的软链接..."
|
||||
for link in "$TARGET_DIR"/*; do
|
||||
# 检查是否为软链接
|
||||
if [[ -L "$link" ]]; then
|
||||
# 检查软链接是否有效(指向的目标是否存在)
|
||||
if [[ ! -e "$link" ]]; then
|
||||
echo "删除无效软链接: $link"
|
||||
rm "$link"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#########################################################################################
|
||||
echo "----------------Running APM Dstore Patch----------------"
|
||||
|
||||
# execute linkApp function for each app and print output
|
||||
# 执行链接操作(同时完成 .desktop 字段添加)
|
||||
exec_uos_package_link
|
||||
|
||||
|
||||
#exec_v23_icon_link
|
||||
# exec_v23_icon_link
|
||||
exec_link_clean
|
||||
wait
|
||||
exec_uos_package_update
|
||||
if [[ "${IS_APM_ENV}" = "" ]];then
|
||||
exec_debian_compatibile_links
|
||||
exec_debian_compatibile_links
|
||||
fi
|
||||
|
||||
echo "----------------Finished----------------"
|
||||
echo "----------------Finished----------------"
|
||||
@@ -1 +1 @@
|
||||
@VERSION@=1.1.8
|
||||
@VERSION@=1.1.9
|
||||
|
||||
@@ -4,7 +4,7 @@ Version: @VERSION@
|
||||
Architecture: amd64
|
||||
Maintainer: shenmo <shenmo@spark-app.store>
|
||||
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
|
||||
|
||||
52
src/usr/bin/amber-pm-app-uninstaller
Executable file
52
src/usr/bin/amber-pm-app-uninstaller
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/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" zenity --notification --text="$@"
|
||||
}
|
||||
|
||||
# 如果当前不是 root,则用 pkexec 重新执行并传递必要的环境变量
|
||||
if [ "$UID" != "0" ]; then
|
||||
# 保存当前环境变量,通过 env 传递给 pkexec
|
||||
exec pkexec "$0" "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# 用户确认
|
||||
if zenity --question --text="即将卸载 $1\n请确认" --no-wrap; then
|
||||
# 启动卸载命令(这里假设 apm 是系统命令,请根据实际情况调整)
|
||||
# 注意:apm 可能不存在,可替换为 apt、dnf 等
|
||||
apm autoremove "$1" -y
|
||||
ret=$?
|
||||
|
||||
|
||||
fi
|
||||
|
||||
notify-send "卸载完成"
|
||||
@@ -646,14 +646,17 @@ fi
|
||||
sudo -E chrootEnvPath="$chrootEnvPath" /var/lib/apm/apm/files/ace-run-pkg aptss clean || true
|
||||
sudo -E chrootEnvPath="$chrootEnvPath" /var/lib/apm/apm/files/ace-run-pkg rm -vfr /var/lib/apt/lists || true
|
||||
sudo -E chrootEnvPath="$chrootEnvPath" /var/lib/apm/apm/files/ace-run-pkg rm -vfr /var/lib/aptss/lists || true
|
||||
sudo -E chrootEnvPath="$chrootEnvPath" /var/lib/apm/apm/files/ace-run-pkg rm -vfr /var/cache/apt/* || true
|
||||
sudo -E chrootEnvPath="$chrootEnvPath" /var/lib/apm/apm/files/ace-run-pkg rm -vfr /var/cache/apt/archives/* || true
|
||||
|
||||
#清理 .dpkg-new 文件
|
||||
log.info "搜索并清理 .dpkg-new 文件..."
|
||||
# 在 core 目录下查找并删除所有以 .dpkg-new 结尾的文件
|
||||
find "$CRAFT_DIR/core" -name "*.dpkg-new" 2>/dev/null | while read -r file; do
|
||||
log.info "删除: $file"
|
||||
sudo rm -f "$file"
|
||||
# 重命名 .dpkg-new 文件(去掉后缀)
|
||||
log.info "处理 .dpkg-new 文件,去掉后缀..."
|
||||
find "$CRAFT_DIR/core" -name "*.dpkg-new" 2>/dev/null | while read -r file; do
|
||||
newfile="${file%.dpkg-new}"
|
||||
log.info "重命名: $file -> $newfile"
|
||||
sudo mv -f "$file" "$newfile"
|
||||
done
|
||||
|
||||
# 统计清理结果
|
||||
|
||||
@@ -100,7 +100,7 @@ until ! echo $updatetext | grep -q "E:"; do
|
||||
updatetext=$(LANGUAGE=en_US apm update 2>&1)
|
||||
retry_count=$((retry_count + 1))
|
||||
done
|
||||
|
||||
apm clean
|
||||
update_app_number=$(env LANGUAGE=en_US apm list --upgradable 2>/dev/null | grep -c upgradable)
|
||||
echo "update_app_number is $update_app_number"
|
||||
|
||||
|
||||
@@ -357,6 +357,7 @@ case "$1" in
|
||||
amber-pm-debug amber-pm-dstore-patch
|
||||
apm-nvidia-toggle
|
||||
amber-pm-gxde-desktop-fix
|
||||
update-mime-database /var/lib/apm/apm/files/ace-env/amber-ce-tools/data-dir/mime > /dev/null 2>&1 &
|
||||
;;
|
||||
download|search|policy|list|update|clean|show|depends|rdepends|changelog|moo)
|
||||
command=$1
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
|
||||
<policyconfig>
|
||||
<vendor>Flamescion</vendor>
|
||||
<icon_name>x-package-repository</icon_name>
|
||||
<action id="store.spark-app.apm-uninstaller">
|
||||
<description>运行justinstallme需要权限</description>
|
||||
<message>要使用ssinstall需要权限</message>
|
||||
<defaults>
|
||||
<allow_any>yes</allow_any>
|
||||
<allow_inactive>yes</allow_inactive>
|
||||
<allow_active>yes</allow_active>
|
||||
</defaults>
|
||||
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/amber-pm-app-uninstaller</annotate>
|
||||
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
|
||||
</action>
|
||||
</policyconfig>
|
||||
@@ -114,7 +114,8 @@ ln -sv ../../usr/share/applications $chrootEnvPath/amber-ce-tools/data-dir/
|
||||
ln -sv ../../usr/share/icons $chrootEnvPath/amber-ce-tools/data-dir/
|
||||
mkdir -p $chrootEnvPath/usr/share/templates
|
||||
ln -sfv ../../usr/share/templates/ $chrootEnvPath/amber-ce-tools/data-dir/
|
||||
|
||||
mkdir -p $chrootEnvPath/usr/share/templates
|
||||
ln -sfv ../../usr/share/mime/ $chrootEnvPath/amber-ce-tools/data-dir/
|
||||
|
||||
chmod 777 -R $chrootEnvPath/usr/share/icons
|
||||
rm -vfr $chrootEnvPath/dev/*
|
||||
|
||||
Reference in New Issue
Block a user