Question

I have .deb package whose contents I need to extract in a programmatic way. However, I am not able to find any resources on the topic, such as .deb package format specification, which would give me some more idea how to approach the problem without going and reverse engineering the whole thing.

Any ideas?

Was it helpful?

Solution

If you don't find a library for this (I didn't, either), and cannot resort to running system commands, you can always implement your own to read ar archives. The ar file format isn't terribly complicated.

OTHER TIPS

Quite simple, actually.

ar xv [name of deb file]

To call from within C, you could use system:

system("ar xv [name of deb file]");

One of the design goals for the .deb package format was to make it easy to extract using existing tools and/or libraries. The top-level structure is indeed an ar file, but inside that, you will find another level of structure, which is traditionally a pair of tar files. For more documentation, see e.g. http://en.wikipedia.org/wiki/Deb_(file_format)

You can probably use the GNU ar sources to build a library of your own if you cannot find an existing library. I would expect there to be general libraries for ar / tar / cpio / what have you.

I just saw libarchive supports the ar format, along with a ton of others.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top