不再频繁提示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
if [[ "$cur" == -* ]]; then
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
--fix-broken --purge --verbose-versions --auto-remove
-s --simulate --dry-run

View File

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