Libarchive Goes Vala

About Libarchive

Libarchive is a great and flexible library. It allows extracting as well as writing data from many archive formats and many compressions without having to deal with them specifically.

Libarchive is used by many projects like gnomes archive manager (file-roller) or KDEs ark – and there will be at least one more application using it in the future: Boxes.

What is Done

Since Boxes needs more archive handling for the express installation I started writing a Libarchive wrapper for Vala with a gnomish (simple) API. Although this wrapper currently lacks some features (I don’t have the time to do a full-grown thing right now) it is capable of the most basic operations (synchronous for now):

  • List files from an archive.
  • Extract files from an archive.
  • Write files into an existing/new archive.

In order to achieve this I also updated the vapi file to Libarchive 3. This will hopefully go into the Vala repositories soon [0].

You can find the code for the wrapper here [1] and the discussion about it here [2]. I do appreciate any comments. I hope this wrapper will be helpul to others.

What’s Next

For the Wrapper

So far the wrapper can do everything needed by Boxes so far. Since the wrapper is merely a byproduct at this moment I will not be able to continue the development at the moment. However, since this wrapper seems to be of interest to the community [3] I do have a TODO-list for some later time:

  • Implement the iterators for the readable archive (this works well together with the stream-based Libarchive API).
  • Allow deletion of existing files in archives.
  • Make extraction/insertion operations asynchronous and  cancellable.

For Boxes

You can read more about my GSOC project on a previous post of mine.

Libarchive is needed for handling ISOs and the initrd archives. It will be used to insert preseed.cfg files for the express installation of Debian based systems. I have taken a look at the important parts of the code in Boxes; this is what needs to be done:

  • Integration of a stripped version of the wrapper into Boxes.
  • Refactoring of the UnattendedFile class to support several injection methods.
  • Writing of desktop-profile installation scripts for several distributions (mainly Debian and Ubuntu, JEOS scripts do exist).

I also hope I can reduce the runtime dependencies for Boxes a bit. However, we cannot use Libarchive for all archive operations at this moment since there is a bug concerning the Fedora 20 DVD iso (affecting ark, file-roller and my own wrapper, a bug is already filed [4]).

More Information






3 responses on “Libarchive Goes Vala

  1. Hi, just curios, do you handle Unicode? It happens to me to open ZIP folder with Czech nationals names under file-roller and was not able to extract the content (my session runs in English mode). Is this a bug?

    1. Hello,

      I don’t handle unicode characters at all. The wrapper is at this moment rather a helper class to get the initrd injection for debian working. (

      As you can see here:
      libarchive should handle Unicode filenames well.

      I also found this:

      If nothing helps, I am sure the file-roller guys appreciate if you file a bug!

  2. Pingback: Lasse's blog | Boxes – Express Installation for Debian

Leave a Reply