From b664df17e8b4aaf6f19bfcaa6db83ddaef69a34f Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 2 Apr 2025 19:22:49 +0800 Subject: [PATCH] =?UTF-8?q?ubuntu:=20=E4=BF=AE=E5=A4=8D=E5=88=A0=E9=99=A4?= =?UTF-8?q?=20grub-pc=20=E6=97=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #304 --- trans.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/trans.sh b/trans.sh index 7e401f5..22078b9 100644 --- a/trans.sh +++ b/trans.sh @@ -3870,16 +3870,21 @@ chroot_dnf() { fi } -chroot_apt_install() { +chroot_apt_update() { os_dir=$1 - shift current_hash=$(cat $os_dir/etc/apt/sources.list $os_dir/etc/apt/sources.list.d/*.sources 2>/dev/null | md5sum) if ! [ "$saved_hash" = "$current_hash" ]; then chroot $os_dir apt-get update saved_hash="$current_hash" fi +} +chroot_apt_install() { + os_dir=$1 + shift + + chroot_apt_update $os_dir DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get install -y "$@" } @@ -3887,6 +3892,10 @@ chroot_apt_remove() { os_dir=$1 shift + # minimal 镜像 删除 grub-pc 时会安装 grub-efi-amd64 + # 因此需要先更新索引 + chroot_apt_update $os_dir + # 不能用 apt remove --purge -y xxx yyy # 因为如果索引里没有其中一个,会报错,另一个也不会删除 local pkgs=