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 @@
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?