Compare commits

...

5 Commits

Author SHA1 Message Date
shenmo7192 523c9f6d9e build: 更新版本号至1.2.4 2026-04-05 12:01:38 +08:00
shenmo7192 dc7916598e refactor(desktop-fix): 重构桌面修复工具并支持多发行版
- 将工具重命名为更通用的 amber-pm-desktop-fix
- 添加对不同发行版的支持,包括银河麒麟系统
- 实现旧链接自动迁移功能
- 改进目录创建和符号链接处理逻辑
2026-04-05 12:01:16 +08:00
shenmo7192 bf996af2c0 fix(desktop): 修复非麒麟系统下桌面链接迁移问题
添加对旧版桌面链接的迁移处理,确保非麒麟系统中应用程序链接正确指向新位置
更新桌面数据库以反映变更
2026-04-05 11:58:58 +08:00
shenmo7192 2ddfa59dee chore: drop掉fish的支持 2026-04-01 14:36:27 +08:00
shenmo7192 9d23672441 优先使用/usr/share/fonts
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2026-03-30 02:49:33 +00:00
7 changed files with 111 additions and 322 deletions
+7 -2
View File
@@ -70,13 +70,18 @@ amber-pm-convert --base amber-pm-bookworm-spark-wine /path/to/package.deb --pkgn
- 安装或更新软件包后自动执行
- 确保应用商店配置正确
### 2.3 amber-pm-gxde-desktop-fix
### 2.3 amber-pm-desktop-fix
**功能**:修复 GXDE 桌面环境相关问题。
**功能**:修复桌面环境相关问题,维护应用程序和图标链接
**使用场景**
- 安装或移除软件包后自动执行
- 确保桌面环境正常运行
- 自动迁移旧版链接到新目录结构
**说明**
- 银河麒麟系统:链接到 `/usr/share/applications/`
- 其他发行版:链接到 `/usr/local/share/applications/apm/`
## 3. 沙箱与安全工具
+1 -1
View File
@@ -1 +1 @@
@VERSION@=1.2.3
@VERSION@=1.2.4
+98
View File
@@ -0,0 +1,98 @@
#!/bin/bash
# 确定目标目录
if grep -q "Kylin" /etc/os-release; then
TARGET_BASE="/usr/share"
APP_TARGET_DIR="$TARGET_BASE/applications"
echo "检测到麒麟系统,使用目标目录: $TARGET_BASE"
else
TARGET_BASE="/usr/local/share"
APP_TARGET_DIR="$TARGET_BASE/applications/apm"
echo "检测到非麒麟系统,使用目标目录: $APP_TARGET_DIR"
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"
local target_dir="$2"
local name="$3"
if [ -d "$source_dir" ] && [ -n "$(ls -A "$source_dir")" ]; then
ln -sv $source_dir/* "$target_dir" 2>/dev/null
find "$target_dir" -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
else
echo "$name directory is empty or does not exist, skipping..."
fi
}
# 使用动态确定的目标目录
ensure_dir "$APP_TARGET_DIR/"
ensure_dir "$TARGET_BASE/icons/"
# 处理 applications 目录
process_directory "/var/lib/apm/apm/files/ace-env/amber-ce-tools/data-dir/applications/" \
"$APP_TARGET_DIR/" "Applications"
# 处理 icons 目录
process_directory "/var/lib/apm/apm/files/ace-env/amber-ce-tools/data-dir/icons/" \
"$TARGET_BASE/icons/" "Icons"
# 等待所有后台任务完成
wait
# 迁移老链接(仅非麒麟系统需要)
if ! grep -q "Kylin" /etc/os-release; then
OLD_LINK_DIR="/usr/local/share/applications"
# 检查旧目录是否存在且不是apm子目录
if [ -d "$OLD_LINK_DIR" ] && [ "$OLD_LINK_DIR" != "$APP_TARGET_DIR" ]; then
echo "检查并迁移老链接..."
# 查找旧目录中指向APM数据目录的符号链接
find "$OLD_LINK_DIR" -maxdepth 1 -type l | while read -r link; do
target=$(readlink "$link")
# 如果链接指向APM的数据目录
if [[ "$target" == /var/lib/apm/apm/files/ace-env/amber-ce-tools/data-dir/applications/* ]]; then
filename=$(basename "$link")
# 如果新位置没有同名文件,则移动
if [ ! -e "$APP_TARGET_DIR/$filename" ]; then
echo "迁移老链接: $filename"
mv -v "$link" "$APP_TARGET_DIR/"
else
echo "新位置已存在 $filename,删除老链接"
rm -v "$link"
fi
fi
done
fi
fi
# 更新桌面数据库
if command -v update-desktop-database >/dev/null 2>&1; then
echo "正在更新桌面数据库..."
update-desktop-database "$TARGET_BASE/applications/"
else
echo "警告: update-desktop-database 命令未找到"
fi
-67
View File
@@ -1,67 +0,0 @@
#!/bin/bash
if [[ ! -e "/usr/share/gxde-api" ]] && ! grep -q "Kylin" /etc/os-release; then
exit 0 # No needed
fi
# 确定目标目录
if grep -q "Kylin" /etc/os-release; then
TARGET_BASE="/usr/share"
echo "检测到麒麟系统,使用目标目录: $TARGET_BASE"
else
TARGET_BASE="/usr/local/share"
echo "检测到GXDE环境,使用目标目录: $TARGET_BASE"
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"
local target_dir="$2"
local name="$3"
if [ -d "$source_dir" ] && [ -n "$(ls -A "$source_dir")" ]; then
ln -sv $source_dir/* "$target_dir" 2>/dev/null
find "$target_dir" -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
else
echo "$name directory is empty or does not exist, skipping..."
fi
}
# 使用动态确定的目标目录
ensure_dir "$TARGET_BASE/applications/"
ensure_dir "$TARGET_BASE/icons/"
# 处理 applications 目录
process_directory "/var/lib/apm/apm/files/ace-env/amber-ce-tools/data-dir/applications/" \
"$TARGET_BASE/applications/" "Applications"
# 处理 icons 目录
process_directory "/var/lib/apm/apm/files/ace-env/amber-ce-tools/data-dir/icons/" \
"$TARGET_BASE/icons/" "Icons"
# 等待所有后台任务完成
wait
+4 -4
View File
@@ -391,7 +391,7 @@ case "$1" in
fi
amber-pm-debug amber-pm-dstore-patch
apm-nvidia-toggle
amber-pm-gxde-desktop-fix
amber-pm-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)
@@ -432,7 +432,7 @@ case "$1" in
exit $exit_code
fi
amber-pm-debug amber-pm-dstore-patch
amber-pm-gxde-desktop-fix
amber-pm-desktop-fix
;;
launch)
shift
@@ -512,7 +512,7 @@ case "$1" in
exit $exit_code
fi
amber-pm-debug amber-pm-dstore-patch
amber-pm-gxde-desktop-fix
amber-pm-desktop-fix
;;
ssinstall)
@@ -526,7 +526,7 @@ case "$1" in
exit $exit_code
fi
amber-pm-debug amber-pm-dstore-patch
amber-pm-gxde-desktop-fix
amber-pm-desktop-fix
;;
-h|--help)
-248
View File
@@ -1,248 +0,0 @@
# APM 琥珀软件包管理器的 fish 自动补全
# 定义命令列表
set -l commands \
ssaudit \
ssinstall \
launch \
list \
search \
show \
showsrc \
install \
remove \
purge \
autoremove \
autopurge \
update \
upgrade \
full-upgrade \
dist-upgrade \
run \
sandbox-run \
bwrap-run \
help \
source \
build-dep \
clean \
autoclean \
download \
changelog \
amber \
xmp360 \
bronya \
debug \
depends \
rdepends \
policy
# 定义通用选项
set -l options \
-h \
--help \
--help-all \
-v \
--version
# 定义命令特定选项
set -l install_options \
-d \
--download-only \
-y \
--assume-yes \
--assume-no \
-u \
--show-upgraded \
-m \
--ignore-missing \
-t \
--target-release \
--download \
--fix-missing \
--ignore-hold \
--upgrade \
--only-upgrade \
--allow-change-held-packages \
--allow-remove-essential \
--allow-downgrades \
--print-uris \
--trivial-only \
--remove \
--arch-only \
--allow-unauthenticated \
--allow-insecure-repositories \
--install-recommends \
--install-suggests \
--no-install-recommends \
--no-install-suggests \
--fix-policy \
--show-progress \
--fix-broken \
--purge \
--verbose-versions \
--auto-remove \
-s \
--simulate \
--dry-run \
--force-yes \
--reinstall \
--solver
set -l remove_options $install_options
set -l update_options \
--list-cleanup \
--print-uris \
--allow-insecure-repositories
set -l list_options \
--installed \
--upgradable \
--manual-installed \
-v \
--verbose \
-a \
--all-versions \
-t \
--target-release
set -l show_options \
-a \
--all-versions
set -l depends_options \
-i \
--important \
--installed \
--pre-depends \
--depends \
--recommends \
--suggests \
--replaces \
--breaks \
--conflicts \
--enhances \
--recurse \
--implicit
set -l search_options \
-n \
--names-only \
-f \
--full
set -l showsrc_options \
--only-source
set -l source_options $install_options \
-b \
--compile \
--build \
-P \
--build-profiles \
--diff-only \
--debian-only \
--tar-only \
--dsc-only
set -l build_dep_options $install_options \
-a \
--host-architecture \
-P \
--build-profiles \
--purge \
--solver
set -l clean_options \
-s \
--simulate \
--dry-run
set -l autoclean_options $clean_options
# 定义目录路径
set -l primary_dir "/var/lib/apm/apm/files/ace-env/var/lib/apm/"
set -l fallback_dir "/var/lib/apm/"
# 查找不包含特定子目录的目录
function find_directories_without_ace_env
set -l base_dir $argv[1]
set -l result
# 检查基础目录是否存在
if not test -d "$base_dir"
return 1
end
# 查找所有直接子目录,排除包含ace-env子目录的目录
for dir in "$base_dir"/*
if test -d "$dir" && not test -d "$dir/files/ace-env"
set result $result (basename "$dir")
end
end
# 输出结果
if test (count $result) -gt 0
echo $result
return 0
end
return 1
end
function apm_run_compgen
set -l result (find_directories_without_ace_env "$primary_dir")
if test -n "$result"
echo $result
else
set result (find_directories_without_ace_env "$fallback_dir")
if test -n "$result"
echo $result
else
echo ""
end
end
end
# 主完成函数
complete -c apm -n "not __fish_seen_subcommand_from $commands" -a "$options" -d "选项"
complete -c apm -n "not __fish_seen_subcommand_from $commands" -a "$commands" -d "命令"
# 命令特定的完成
complete -c apm -n "__fish_seen_subcommand_from install" -a "$install_options" -d "选项"
complete -c apm -n "__fish_seen_subcommand_from install" -k -A "*.deb" -d "Deb 包"
complete -c apm -n "__fish_seen_subcommand_from remove purge autoremove autopurge" -a "$remove_options" -d "选项"
complete -c apm -n "__fish_seen_subcommand_from remove purge autoremove autopurge" -k -F "ls -1 $primary_dir 2>/dev/null || ls -1 $fallback_dir 2>/dev/null" -d "包"
complete -c apm -n "__fish_seen_subcommand_from update" -a "$update_options" -d "选项"
complete -c apm -n "__fish_seen_subcommand_from list" -a "$list_options" -d "选项"
complete -c apm -n "__fish_seen_subcommand_from show" -a "$show_options" -d "选项"
complete -c apm -n "__fish_seen_subcommand_from show" -k -F "amber-pm-debug apt-cache --no-generate pkgnames '' -o Dir::Cache=/var/lib/aptss/ 2>/dev/null" -d "包"
complete -c apm -n "__fish_seen_subcommand_from depends rdepends" -a "$depends_options" -d "选项"
complete -c apm -n "__fish_seen_subcommand_from depends rdepends" -k -F "amber-pm-debug apt-cache --no-generate pkgnames '' -o Dir::Cache=/var/lib/aptss/ 2>/dev/null" -d "包"
complete -c apm -n "__fish_seen_subcommand_from search" -a "$search_options" -d "选项"
complete -c apm -n "__fish_seen_subcommand_from showsrc" -a "$showsrc_options" -d "选项"
complete -c apm -n "__fish_seen_subcommand_from showsrc" -k -F "amber-pm-debug apt-cache --no-generate pkgnames '' -o Dir::Cache=/var/lib/aptss/ 2>/dev/null" -d "包"
complete -c apm -n "__fish_seen_subcommand_from source" -a "$source_options" -d "选项"
complete -c apm -n "__fish_seen_subcommand_from source" -k -F "amber-pm-debug apt-cache --no-generate pkgnames '' -o Dir::Cache=/var/lib/aptss/ 2>/dev/null" -d "包"
complete -c apm -n "__fish_seen_subcommand_from build-dep" -a "$build_dep_options" -d "选项"
complete -c apm -n "__fish_seen_subcommand_from build-dep" -k -F "amber-pm-debug apt-cache --no-generate pkgnames '' -o Dir::Cache=/var/lib/aptss/ 2>/dev/null" -d "包"
complete -c apm -n "__fish_seen_subcommand_from clean" -a "$clean_options" -d "选项"
complete -c apm -n "__fish_seen_subcommand_from autoclean" -a "$autoclean_options" -d "选项"
complete -c apm -n "__fish_seen_subcommand_from download changelog policy" -k -F "amber-pm-debug apt-cache --no-generate pkgnames '' -o Dir::Cache=/var/lib/aptss/ 2>/dev/null" -d "包"
complete -c apm -n "__fish_seen_subcommand_from run sandbox-run bwrap-run launch" -k -F "apm_run_compgen" -d "包"
complete -c apm -n "__fish_seen_subcommand_from run sandbox-run bwrap-run launch" -k -A "*" -d "文件"
complete -c apm -n "__fish_seen_subcommand_from ssaudit ssinstall" -k -A "*" -d "文件"
+1
View File
@@ -128,6 +128,7 @@ BASE_BIND_DIRS=(
"--dev-bind / /host"
"--dev-bind-try /etc/resolv.conf /etc/resolv.conf"
"--dev-bind-try /usr/share/icons /usr/local/share/icons"
"--dev-bind-try /usr/share/fonts /usr/local/share/fonts"
"--dev-bind-try /usr/share/themes /usr/share/themes"
"--dev-bind-try /home /home"
"--dev-bind-try $HOME/.apm/${APM_PKG_NAME}/.deepinwine $HOME/.deepinwine"