I am trying to block GRUB packages from being installed (after having purged them). The problem is virtually identical to Blacklisting packages from installing and even involves GRUB which is exactly what the selected answer illustrated doing.

However, it does not work in 12.04 LTS using the cloud-image edition.

In my scripts to do all this, I first delete the packages involved. It has an annoying UNinstall prompt, but I finally figured out how to feed it answers (see https://askubuntu.com/questions/195801/when-uninstalling-all-grub-packages-for-ec2-ami-build-script-how-do-i-bypass-pr for my older question) to make it move along. After that uninstall is done, I run commands to edit the /etc/apt/apt.conf.d/01autoremove file to add the grub blacklist line as shown in the answer for the question above.

EXECUTING: diff -U999999 /root/etc_apt_apt.conf.d_01autoremove /etc/apt/apt.conf.d/01autoremove
--- /root/etc_apt_apt.conf.d_01autoremove       2012-04-20 10:21:55.000000000 +0000
+++ /etc/apt/apt.conf.d/01autoremove    2012-10-03 16:28:17.000000000 +0000
@@ -1,26 +1,27 @@

+       "grub*";

FYI, the commands are prefixed with "EXECUTING" and shown that way as part of the mechanism of my script to show what it is doing.

The file /root/etc_apt_apt.conf.d_01autoremove in this case is a backup of the original, being compared with the changed file already in its place. It looks right to me. Then I do the command with the same package names being negated with the "-" suffix. And yet it still installs them as new packages:

EXECUTING: apt-get --yes dist-upgrade grub-common- grub-gfxpayload-lists- grub-legacy-ec2- grub-pc- grub-pc-bin- grub2-common-
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  grub-common grub-gfxpayload-lists grub-pc grub-pc-bin grub2-common linux-image-3.2.0-31-virtual
The following packages will be upgraded:
  apport apt apt-transport-https apt-utils dbus gnupg gpgv isc-dhcp-client isc-dhcp-common libapt-inst1.4
  libapt-pkg4.12 libdbus-1-3 libgc1c2 libxml2 linux-firmware linux-image-virtual linux-virtual multiarch-support
  ntfs-3g openssl python-apport python-problem-report resolvconf tzdata ubuntu-keyring
25 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 45.4 MB of archives.
After this operation, 35.1 MB of additional disk space will be used.

One reason I do not want to have them installed here is the unpredictability of prompts that my script has to feed input answers to. And this just makes no sense for them to be installed when they have been blacklisted, and not really needed.

FYI, for reference on why GRUB is not needed, I am using the recommended option 2 in AWS EC2 PV-GRUB kernel images (AKIs) as described in this document at AWS: http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/UserProvidedkernels.html

So the big question: how to prevent these packages from being installed whatsoever?


Never-MarkAuto-Sections doesn't do what you read it does. First, it's a list of sections (like admin), not package names (like grub-pc). Second, it requires exact names, not wildcard patterns. Third, it doesn't prevent a package from installing anyway: what it means is that if the package is pulled in by a dependency, it will not be marked as automatically installed.

Grub is recommended by the standard kernel image. An easy way to not getting it reinstaled is to tell APT not to follow recommend-level dependencies, with --no-install-recommends on the command line or APT::Install-Recommends "false"; in apt.conf. I don't know of a way to ignore a specific dependency.

You can block a package from installing by giving it a negative priority in /etc/apt/preferences, see How to forbid a specific package to be installed?. But that won't solve your problem since APT will still try to pull in the dependency.

You can make a fake grub-pc package with equivs, see How to fake a package version installed?. That's what I'd do here: you have Grub, but not provided through a deb package, so make a fake package to tell that to the package manager.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.