Debian

我怎樣才能讓 APT “忽略”一個包?

  • November 29, 2021

我正在使用帶有此核心版本的 Debian 不穩定執行 VPS:

2.6.32-274.7.1.el5.028stab095.1

我剛剛升級了我的軟體包,出於某種奇怪的原因,APT 要我安裝linux-image-3.2.0-3-amd64,這很奇怪,因為我無法修改核心,因為它是一個 VPS。無論如何我都嘗試安裝它,但我懷疑它不起作用:

root@youmu:~# apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? Y
Setting up linux-image-3.2.0-3-amd64 (3.2.23-1) ...
Running depmod.
vmlinuz(/boot/vmlinuz-3.2.0-3-amd64
) points to /boot/vmlinuz-3.2.0-3-amd64
(/boot/vmlinuz-3.2.0-3-amd64) -- doing nothing at /var/lib/dpkg/info/linux-image-3.2.0-3-amd64.postinst line 268.
initrd.img(/boot/initrd.img-3.2.0-3-amd64
) points to /boot/initrd.img-3.2.0-3-amd64
(/boot/initrd.img-3.2.0-3-amd64) -- doing nothing at /var/lib/dpkg/info/linux-image-3.2.0-3-amd64.postinst line 268.
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-3-amd64 /boot/vmlinuz-3.2.0-3-amd64
update-initramfs: Generating /boot/initrd.img-3.2.0-3-amd64
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.2.0-3-amd64 /boot/vmlinuz-3.2.0-3-amd64
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... Generating /boot/grub/default file and setting the default boot entry to 0
entry not specified.
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.2.0-3-amd64.postinst line 696.
dpkg: error processing linux-image-3.2.0-3-amd64 (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
linux-image-3.2.0-3-amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@youmu:~# 

所以我試圖刪除它,但它仍然失敗。

我想知道是否有辦法讓 APT 忽略一個包,就好像它不存在一樣,所以每次我安裝一個包時它都不會打擾我。我嘗試將包擱置,但它仍想重新配置它。

有什麼建議麼?

postinst 文件結束:

## Run user hook script here, if any
if ($postinst_hook) {
 &run_hook("postinst", $postinst_hook);
}

if (-d "/etc/kernel/postinst.d") {
 print STDERR "Examining /etc/kernel/postinst.d.\n";
 system ("run-parts --verbose --exit-on-error --arg=$version " .
         "--arg=$realimageloc$kimage-$version " .
         "/etc/kernel/postinst.d") &&
           die "Failed to process /etc/kernel/postinst.d";
}

if (-d "/etc/kernel/postinst.d/$version") {
 print STDERR "Examining /etc/kernel/postinst.d/$version.\n";
 system ("run-parts --verbose --exit-on-error --arg=$version " .
         "--arg=$realimageloc$kimage-$version " .
         "/etc/kernel/postinst.d/$version") &&
           die "Failed to process /etc/kernel/postinst.d/$version";
}

exit 0;

__END__

exec update-grub作為臨時,/etc/kernel/postinst.d/zz-update-grub通過執行註釋掉:

$ sudo sed -i.bak '/exec update-grub/s/^/#/' /etc/kernel/postinst.d/zz-update-grub

然後執行配置腳本:

$ sudo dpkg --configure -a

如果有效,您可以將zz-update-grub文件恢復為其原始內容。

忽略更新 apt 的啟動腳本的公認答案不再像update-grub現在包裝在一個if塊中那樣工作,當中間沒有任何內容時,它會失敗。這裡有一個更有效的方法:

$ sudo mv /usr/sbin/update-grub /usr/sbin/update-grub.disabled
$ sudo mv /usr/sbin/update-initramfs /usr/sbin/update-initramfs.disabled
$ sudo mv /usr/sbin/cryptsetup /usr/sbin/cryptsetup.disabled

如果您使用的是 NFS,這是一種有效的解決方法。最好檢查官方 Debian 文件,或改進 apt 腳本,以免 NFS 客戶端失敗。

相關答案:如何讓 apt-get 忽略某些依賴項?

引用自:https://serverfault.com/questions/425193