Building packages with haikuporter

Blog post by humdinger on Wed, 2017-02-22 08:38

HaikuPorter is a python tool that takes a so-called recipe that describes the dependencies of a software and how to download, build and package it.

The HaikuPorts Wiki has all the info to get started writing recipes. But it gets into too much detail if all you want is use HaikuPorter to build stuff with existing working recipes.

Here’s a quick step-by-step guide how to do that.

1. Getting HaikuPorter and the Recipes

Get the HaikuPorter tool and the haikuports tree with all the recipes:

git clone https://github.com/haikuports/haikuporter.git
git clone https://github.com/haikuports/haikuports.git

That'll create two directories: "haikuporter" with the python tool and "haikuports" with all the recipes categorized in sub-folders.

2. Setting up HaikuPorter

Put HaikuPorter into the system's “Path”, so it can be invoked like any other command:

cd haikuporter
ln -s haikuporter ~/config/non-packaged/bin/

Copy and edit the haikuports configuration file:

cp haikuports-sample.conf ~/config/settings/haikuports.conf
lpe ~/config/settings/haikuports.conf

In the haikuports.conf file you have to edit/un-comment the lines:

  • TREE_PATH - where you cloned the haikuports tree, e.g. "/boot/home/haikuports"
  • PACKAGER - your name and email address, e.g. "Humdinger <humdinger@mymail.com>"
  • TARGET_ARCHITECTURE="x86_gcc2"
  • SECONDARY_TARGET_ARCHITECTURE="x86"

This is for running the official 32bit Haiku (gcc2hybrid), where the older gcc2 compiler is the default to maintain BeOS compatibility and "x86" is a modern compiler (currently gcc5.4) for applications that won't build with the ancient gcc2.

3. Using HaikuPorter

Now you can start using HaikuPorter. You get all its options with "haikuporter --help".

In the haikuports tree, you search the recipe of the software you’d like to build. You can also use, e.g. "haikuporter -o artpaint" to have haikuporter look for a specific recipe, here for “ArtPaint”.

To build ArtPaint, you type:

haikuporter -S -j4 --get-dependencies --no-source-packages artpaint

-S : enforce "strict policy" to create standard compliant HPKGs.
-j4 : use 4 cores when building to save time.
--get-dependencies : automatically download all packages needed for building that aren’t already installed.
--no-source-packages : don’t create a package with the source code.
artpaint : build the latest recipe for "ArtPaint".

You find successfully built packages in the folder "haikuports/packages".

4. Keeping uptodate

The haikuports tree receives almost daily changes with new, updated and fixed recipes. To stay abreast with those changes, you should regularly update. This is very easy with "haikuporter --get".

Likewise, haikuporter itself gets updated from time to time. At the latest if recipes start to fail building, you should update. This, too, is quite easy; you enter the directory "haikuporter" that you have cloned in the 1st step and use git to pull in all changes:

cd haikuporter
git pull

5. Tips & Tricks

  • To save yourself much typing, you can add this line to the file ~/config/settings/profile (a text file that you have to create if it doesn’t exist already):

    alias hp='haikuporter -S -j4 --get-dependencies --no-source-packages'
    

    Now you can build with a simple "hp artpaint" and have those standard parameters added automatically.

  • Some software can’t be built with gcc2 and needs the modern compiler. You can see that in the recipes that declare:

    ARCHITECTURES="!x86_gcc2 x86 x86_64"
    SECONDARY_ARCHITECTURES="x86"
    

    The "!" says the package can't be built for that architecture. A "?" shows that it hasn't been tested for it.

    In such a case, haikuporter will complain that "it is broken on the target architecture". You instruct haikuporter to build with the secondary architecture by appending a "_x86" to the recipe name, e.g. " bepdf_x86".

  • Sometimes you find recipes for different versions of a software. HaikuPorter builds the latest by default. If you'd like a specific version, you can append the version number found in the recipe's filename, e.g. "bepdf_x86-2.0.0" to build v2.0.0 of BePDF for the secondary architecture (gcc5.4 currently).

  • If something goes wrong and you want a fresh start, open the folder of the recipe you try to build and delete all folders starting with "work-". Also delete the "download" folder if you suspect a corrupted source archive.
    Do a "haikuporter artpaint -c" for ArtPaint as example. In some weird cases you may have to also delete the folders "haikuports/packages" and "haikuports/repositories", which will be time-consumingly recreated with the next build.