July 19, 2010

How-to: Blacklist Packages in Ubuntu

 

In my case I use Slackware Linux as my Primary OS in which I setup grub(legacy) as my primary bootloader, every time I went to update or upgrade ubuntu it tried to force grub2 to overwrite my MBR, this had to stop. I searched the net for answers with none found, I asking in irc channels with no success, so finally I decided to look around /etc/ at the configuration files for an option and I discovered it.

 

The answer is very simple:

 

  1. Remove the packages you don't want using apt-get, synaptic package manager or the software center.
  2. open apt's 01autoremove file by issuing the command sudo gedit /etc/apt/apt.conf.d/01autoremove
  3. Navigate to the bottom of the section titled Never-MarkAuto-Sections
  4. Add and entry to the section in my case to block grub I entered "grub*";.  The contents of the modified file is at the bottom of this page.
  5. You will enter the package name or portion of package names, including using * as a wildcard, in my case grub* blocks all packages that start with the word grub.

 

It is complete, when you next open the update utility it will not show the option to upgrade or update the software  that you chose to block.

The resolution is simple, but no documentation was found prior to this post. 

I hope you find this useful.

 

My /etc/apt/apt.conf.d/01autoremove file:

-------------------------------------------------------------------------------------------------------------------

APT
{
 NeverAutoRemove
 {
  "^linux-firmware$";
  "^linux-image.*";
  "^linux-restricted-modules.*";
  "^linux-ubuntu-modules-.*";
 };
 Never-MarkAuto-Sections
 {
  "metapackages";
  "restricted/metapackages";
  "universe/metapackages";
  "multiverse/metapackages";
  "oldlibs";
  "restricted/oldlibs";
  "universe/oldlibs";
  "multiverse/oldlibs";
  "grub*";
 };
};