A Brief Look Inside HPKG | Haiku Project

The Haiku operating system has a packaging system that leverages a clever file format called HPKG. This article provides a simplistic overview of how the file format is structured.


This is a companion discussion topic for the original entry at https://www.haiku-os.org/blog/apl/2021-02-28_look_at_hpkg/
3 Likes

The images don’t load when I click the “Show Full Post…” button, but they do load when I open the link in a separate browser tab. Just FYI.

@apl Nice article, but I am a bit confused about the chunks. You say they are uncompressed, yet later say there is compressed data within them. I don’t quite get this.

@OneRyan I am not sure how the integration between these forums and our website works but I guess the articles are meant to be viewed on the website and the image locations must be relative to the website.

@leavengood I found it slightly confusing too. My read is that there are n chunks, and each chunk (except the last) represents 64kb of real, uncompressed data. They are stored compressed, and the index at the end contains those compressed lengths so you know what to decompress.

So you want to start reading from the start of data? Decompress the first chunk and use it. Let’s say it contains an index into byte 100,000. You know that’ll be in the second chunk because it covers bytes 65,536~131,071, so look at the index at the end of the file to know which bytes cover the compressed chunk two, then read and decompress that.

I miss the information, that a hpkg file, then installing it, there files are in write protected areas. I think this information need to be told too.

Hi; thanks for the feedback. I have amended the article here; can you see if this is more clear? I am not too sure about the image paths. If I put absolute paths then I presume it won’t render in Hugo properly when I’m writing it.

That definitely helps. I sort of got the idea before but this definitely makes it more clear. I know you were not trying to make this too technical but the example you added helps too.

Now I just need to try coding up my own HPKG reader, or really dig into the existing code.