不再频繁提示NVIDIA信息,添加autopurge相关的内容

This commit is contained in:
2025-11-21 10:56:42 +08:00
parent 22b7728b24
commit 8b06b2a71f
2 changed files with 21 additions and 11 deletions

View File

@@ -70,7 +70,7 @@ _apm()
# supported options per command # supported options per command
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
case $command in case $command in
install|remove|purge|upgrade|dist-upgrade|full-upgrade|autoremove) install|remove|purge|upgrade|dist-upgrade|full-upgrade|autoremove|autopurge)
COMPREPLY=( $( compgen -W '--show-progress COMPREPLY=( $( compgen -W '--show-progress
--fix-broken --purge --verbose-versions --auto-remove --fix-broken --purge --verbose-versions --auto-remove
-s --simulate --dry-run -s --simulate --dry-run

View File

@@ -14,29 +14,39 @@ log.error "需要把ace-env所在的路径设置为第一个参数"
exit 1 exit 1
fi fi
# 1\. 获取宿主机 NVIDIA 驱动版本 # 1. 获取宿主机 NVIDIA 驱动版本
nvidia_version=$(cat /sys/module/nvidia/version 2>/dev/null) nvidia_version=$(cat /sys/module/nvidia/version 2>/dev/null)
if [ -z "$nvidia_version" ]; then if [ -z "$nvidia_version" ]; then
log.warn "无法获取 NVIDIA 驱动版本 Can not determine NVIDIA Driver version" # log.warn "无法获取 NVIDIA 驱动版本 Can not determine NVIDIA Driver version"
exit 1 exit 1
fi fi
# 2\. 目标目录准备 # 2. 目标目录准备
ACE_DIR="$1" ACE_DIR="$1"
if [[ ! -e "${ACE_DIR}" ]];then if [[ ! -e "${ACE_DIR}" ]];then
log.error "未检测到 apm安装请安装后再试 apm is not detected. Please try again after installation" log.error "未检测到 apm安装请安装后再试 apm is not detected. Please try again after installation"
log.info "请按回车关闭... Press Enter to close..."
read
exit 1 exit 1
fi fi
mkdir -p "$ACE_DIR/usr/lib" "$ACE_DIR/usr/lib32" mkdir -p "$ACE_DIR/usr/lib" "$ACE_DIR/usr/lib32"
# 检查版本是否已存在且匹配
if [ -f "$ACE_DIR/current_version" ]; then
existing_version=$(cat "$ACE_DIR/current_version")
if [ "$existing_version" = "$nvidia_version" ]; then
# log.info "NVIDIA 驱动版本未变化,跳过链接操作 NVIDIA Driver version unchanged, skipping linking."
exit 0
else
log.info "检测到 NVIDIA 驱动版本变化: $existing_version -> $nvidia_version"
log.info "NVIDIA Driver version changed: $existing_version -> $nvidia_version"
fi
fi
log.info "正在链接 NVIDIA 驱动库 Linking NVIDIA Driver Libs" log.info "正在链接 NVIDIA 驱动库 Linking NVIDIA Driver Libs"
# 3\. 收集库文件路径 # 3. 收集库文件路径
lib_list=$(ldconfig -p | grep -Ei "nvidia|libcuda" | cut -d'>' -f2) lib_list=$(ldconfig -p | grep -Ei "nvidia|libcuda" | cut -d'>' -f2)
# 4\. 复制库文件 # 4. 复制库文件
copied=0 copied=0
for lib in $lib_list; do for lib in $lib_list; do
resolved=$(readlink -f "$lib") # 解析符号链接 resolved=$(readlink -f "$lib") # 解析符号链接
@@ -48,7 +58,7 @@ for lib in $lib_list; do
fi fi
done done
# 5\. 复制辅助文件 # 5. 复制辅助文件
additional_files=( additional_files=(
/usr/share/vulkan/icd.d/nvidia_icd.json /usr/share/vulkan/icd.d/nvidia_icd.json
/usr/share/egl/egl_external_platform.d/20_nvidia_xcb.json /usr/share/egl/egl_external_platform.d/20_nvidia_xcb.json
@@ -62,7 +72,7 @@ for file in "${additional_files[@]}"; do
fi fi
done done
# 6\. 标记版本 # 6. 标记版本
if [ $copied -eq 1 ]; then if [ $copied -eq 1 ]; then
echo "$nvidia_version" > "$ACE_DIR/current_version" echo "$nvidia_version" > "$ACE_DIR/current_version"
log.info "NVIDIA 驱动库已成功链接 Nvidia Driver Libs are successfully linked. " log.info "NVIDIA 驱动库已成功链接 Nvidia Driver Libs are successfully linked. "