我怎样才能让 APT “忽略”某个包?

我怎样才能让 APT “忽略”某个包?

我正在使用 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__

答案1

暂时,通过运行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文件恢复为其原始内容。

答案2

忽略更新 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 忽略一些依赖关系?

相关内容