HOWTO: Make A Metapackage and A Repository for Your Metapackage
I’ve done my fair share of dabbling in metapackages and making apt repositories, so I figured I might as well share the knowledge.
I hate the kind of howto that shows you steps you can blindly follow. I’d rather help you to learn. But I’ll compromise. The following howto you can blindly follow, but I’m including resources so you can help yourself to more information if you want it.
1. The metapackage.
Since .debs are, essentially, snapshots of the installed program as seen from the root directory in an archive with a little metadata, you can start by making an empty package jail with
mkdir -p package/DEBIAN
package/ is the root of the jail; DEBIAN/ is a directory that contains any information the Debian packaging tools will need to produce the package. For a metapackage, you’ll need only one file: control. (Here is an example control file) If you want more information on writing a control file, the format has manpage documentation:
man 5 deb-control
If you just want to create a metapackage to install the package setup from another installation, you can use this tip I adapted from Daniel. Run the following command on the installation whose packageset you want to copy:
dpkg-query -W -f='${Package}, ' | sed 's/\, $//'
This will query your dpkg database and return the list of all packages in a comma-delimited list amenable to copying-and-pasting into the “Depends” portion of your control file.
Once you’ve written your control file, use the command
dpkg-deb -b package name.deb
To build the metapackage (Remember, though, that this isn’t the way to build real packages!). dpkg-deb comes with Ubuntu and Debian, so don’t worry about fetching that package. You can find more information about building packages with man dpkg-deb.
If you just want a metapackage, you can obviously stop there.
2. The apt repository.
I use the Falcon Repository Generator by Dennis Kaarsemaker for fewer headaches.
Falcon is available from the Universe repository in Hardy Heron, so it can be installed with a simple apt-get install falcon. Fuller documentation can be found on Kaarsemaker’s website or at /usr/share/doc/falcon/html/index.html (once it’s installed, of course!)
Once it’s installed, make your repository root. For the purposes of this HOWTO, we’ll assume that your repository root is at ~/.falcon/rootdir.
An apt repository has two parts to it: a ‘Pocket’ and a ‘Component’. In a sources.list entry, here’s where the pocket and component go:
deb http://archive.ubuntu.com/ubuntu POCKET COMPONENT(S)
So, in the sources.list line deb http://archive.ubuntu.com/ubuntu feisty main restricted, feisty is the pocket and main and restricted are the components. You want to create your pockets as directories under pool directory in the repository root:
mkdir -vp ~/.falcon/rootdir/pool/hardy/extras
will pave the way for making a pocket called “hardy” with an “extras” component.
Make your pockets and components, and then run
falcon-start -r ~/.falcon/rootdir configure
This will bring up an ncurses-based interface for configuring falcon. You want to go to Pockets and Components, and configure your pockets and components. This shouldn’t take much thinking; the pocket version should be the OS version you want that pocket to be used for. For instance, the ‘hardy’ pocket should be given version 8.04. You can give a description to your pockets and components if you like, but it’s not necessary.
You can also define metacomponents here. A metacomponent is a feature unique to falcon; it is, as the name implies, a component of components. For instance, if I have three components, say main, extra, and nonfree, I can create a metacomponent containing them all called “everything” and any package in main, extra, or nonfree will show up in “everything”. The interface for defining metacomponents should be self-explanatory.
You can also go into the General Configuration menu and configure a few things there. You might like to sign your repository; this may be done in the General Configuration menu.
After you have configured everything you like, you can exit the configuration menu. Copy your metapackage into ~/.falcon/rootdir/pool/POCKET/COMPONENT and then run falcon-start -r ~/.falcon/rootdir scan and, finally, falcon-start -r ~/.falcon/rootdir export. This will generate your repository at ~/.falcon/rootdir. And there you have it: a metapackage and a repository to hold it!
Thanks for that.
Having just rebuilt my machine and been annoyed that i couldn’t remember all the programs i installed before, I’m making a meta package of all the programs i install.
I’m too lazy to bother with a repository just now (might do later when i start using it on my other computers) so i just run:
dpkg -i mymeta.deb; apt-get install -f
Not the most elegant of solutions i know but it seems to work.
I guess that’ll work. It doesn’t really sound like an ideal solution, I must say ;). There’s gotta be some kind of local package dependency resolver around.
There is, gdebi. Just double click the package from Nautilus. I suspect there’s a similar setup in Kubuntu.
Yeah, but that’d be too easy.
[...] popular post of mine and it was in serious need of some updating, I’ve gone back and revised HOWTO: Make A Metapackage And Repository to make it more up-to-date. There were a number of stylistic inconsistencies and it was generally [...]
[...] This article has the essentials…. make an empty directory structure…. [...]
[...] read from Iandefor’s blog that metapackages have a control file. And that’s where the details of the package dependencies are. It says what must be [...]
Here I give you a link with a useful tip
http://tips-debian.blogspot.com/2008/04/make-repository.html
[...] Updated Post I updated the metapackage-n’-repository howto to reflect the current status of Falcon, since that part hadn’t been updated for a little over a year and a few things had changed. Enjoy the new version here. [...]
Hey Ian,
I’m trying to write a script that automates the creation of a metapackage and a repository for it’s dependancies.
er….I could do with a few pointers if you have time. :)
Please email me if you can and I’ll send you the script.
Great article BTW!
H.
From
http://iandefor.wordpress.com/2006/12/16/howto-make-a-metapackage-and-repository-for-your-metapackage-and-surprise-im-quit-of-bumps/
I hate the kind of howto that shows you steps you can blindly follow. I’d rather help you to learn.
I couldn’t agree more. I’d like to see “WHYTOs” become the norm.
73,
Ged.