Friday, August 26, 2011

HOWTO: Create a Debian Meta Package

The following is a short tutorial on how to create a Debian meta package. Just as a brief background for those that do not know what a meta package is - a meta package is a Debian package that simply tells the package manager to download a whole bunch of other packages. Meta packages are useful for allowing for the quick installation of an entire group of packages. I use meta packages in the Bodhi repository for our theme pack and software bundles.

Fair warning for this tutorial I am assuming you have at least some basic command line experience.

Lets start by creating a directory that will have the same name as the meta package we are creating. For the purposes of this tutorial our package will be called "bodhi-theme-pack". So run:

mkdir ~/bodhi-theme-pack && cd ~/bodhi-theme-pack

Next, we need to create a "DEBIAN" directory within our package structure. Note it is required for meta packages that DEBIAN be in all capitals.

mkdir DEBIAN && cd DEBIAN

Then we are going to create a control file inside of our DEBIAN directory.

nano control

In the file that opens paste in this for the contents. The fields in this file are fairly self explanatory. Just note that you need a comma in-between each of the different package names you want your meta package to install. Finally, if you would like your meta package to do extra fancy things, you can also create post/pre install/remove scripts and all that jazz in your DEBIAN directory and they will be executed as with any debian package.

Finally, lets create our .deb package:

cd ~/ && dpkg --build bodhi-theme-pack

You will get a message confirming that the creation of your .deb package was successful and you should now have a "bodhi-theme-pack.deb" sitting in your home directory. If you have any questions or issues feel free to drop a comment below and I'll do my best to help you out.

Cheers,
~Jeff Hoogland

4 comments:

  1. Problem i have with metapackage is when i need to purge a single package that is in a metapackage group it will drag down whole packages that in same metapackage.

    E.g IIRC when i want to remove epiphany or totem in gnome.

    ReplyDelete
  2. Really usefull how to, thanks!

    @ Iza: Correct me if I'm wrong, but even if the metapackage gets unninstalled when you unninstall any of its dependencies, doesn't the rest of packages (individuals) remain installed? I think you mean the metapackage appears as unninstalled (since not all its components are installed) but that doesn't automatically unninstall the rest of the real individual packages.

    eg: I install the metapackage ubuntu-restricted-extras, but then I remove flash-nonfree. ubuntu-restricted-extras is then removed but other packages depending on it like pluggins-bad, pluggins-ugly... etc are still installed.

    ReplyDelete
  3. The rest of the other packages will stay installed, but an "apt-get autoremove" will remove them.

    ReplyDelete
  4. You can use the "equivs" package to do this cleaner.

    ReplyDelete