Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 When uninstalling all GRUB packages for EC2 AMI build script, how do I bypass prompting? 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 @@
 APT
 {
   NeverAutoRemove
   {
        "^firmware-linux.*";
        "^linux-firmware$";
        "^linux-image.*";
        "^kfreebsd-image.*";
        "^linux-restricted-modules.*";
        "^linux-ubuntu-modules-.*";
        "^gnumach$";
        "^gnumach-image.*";
   };

   Never-MarkAuto-Sections
   {
        "metapackages";
        "restricted/metapackages";
        "universe/metapackages";
        "multiverse/metapackages";
        "oldlibs";
        "restricted/oldlibs";
        "universe/oldlibs";
        "multiverse/oldlibs";
+       "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?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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