xref: /haiku/docs/develop/packages/Bootstrapping.rst (revision d79d9a8524bfb0778a898b026c7af203df5b8873)
103d384bbSLeorize===================
203d384bbSLeorizeBootstrapping Haiku
303d384bbSLeorize===================
403d384bbSLeorize
503d384bbSLeorizeEven a very basic Haiku requires a set of third-party packages (ICU, zlib,...),
603d384bbSLeorizea Haiku sufficiently complete to build software even more
703d384bbSLeorize(binutils, gcc, make,...). So whenever something fundamental in Haiku
803d384bbSLeorize(the architecture ABI, the ABI of libroot) changes in a binary incompatible way,
903d384bbSLeorizeor when Haiku is ported to a new architecture, it is necessary to bootstrap
1003d384bbSLeorizeHaiku and a basic set of required third-party packages. This document describes
1103d384bbSLeorizehow this process works.
1203d384bbSLeorize
1303d384bbSLeorizePrerequisites
1403d384bbSLeorize=============
1503d384bbSLeorize
1603d384bbSLeorize- So far the bootstrap build has only been tested on Linux. It will probably
1703d384bbSLeorize  also work on FreeBSD and other Unixes. Haiku is not yet supported as a build
1803d384bbSLeorize  platform.
1903d384bbSLeorize- A required prerequisite for the bootstrap build is a checkout of the
2003d384bbSLeorize  haikuporter, the haikuports, and the haikuports.cross repositories from the
2103d384bbSLeorize  `Github HaikuPorts site`_.
2203d384bbSLeorize
2303d384bbSLeorize  .. _Github HaikuPorts site: https://github.com/haikuports/
2403d384bbSLeorize
2503d384bbSLeorize- Additional build tools are required for the build platform:
2603d384bbSLeorize
2703d384bbSLeorize  - autoconf
2803d384bbSLeorize  - automake
2903d384bbSLeorize  - cmake (For compiling python_bootstrap)
3003d384bbSLeorize  - ncurses_development (For compiling texinfo_bootstrap)
3103d384bbSLeorize
3203d384bbSLeorize- All the usual prerequisites for building Haiku.
3303d384bbSLeorize
3403d384bbSLeorizeConfiguring and Building
3503d384bbSLeorize========================
3603d384bbSLeorize
3703d384bbSLeorize1. Configure the Haiku build with all usual parameters, but add the
3803d384bbSLeorize   ``--bootstrap`` option with its three parameters, the paths to the checked
3903d384bbSLeorize   out haikuporter *script* (eg. ``../haikuporter/haikuporter``),
4003d384bbSLeorize   haikuports.cross, and haikuports repositories folders::
4103d384bbSLeorize
4203d384bbSLeorize     .../configure ... --bootstrap path/to/haikuporter path/to/haikuports.cross path/to/haikuports
4303d384bbSLeorize
4403d384bbSLeorize   It is important that you build outside the tree, as otherwise the build will
4503d384bbSLeorize   fail!
4603d384bbSLeorize#. Build a bootstrap Haiku image::
4703d384bbSLeorize
4803d384bbSLeorize     jam -q @bootstrap-raw
4903d384bbSLeorize
5003d384bbSLeorize#. Boot the bootstrap Haiku (e.g. in a virtual machine), edit the file
5103d384bbSLeorize   "/boot/home/haikuports/haikuports.config" -- entering your email address in
5203d384bbSLeorize   the "PACKAGER" field -- and finally open a Terminal and build the third-party
5303d384bbSLeorize   packages::
5403d384bbSLeorize
5503d384bbSLeorize     cd haikuports
5603d384bbSLeorize     haikuporter --do-bootstrap
5703d384bbSLeorize
5803d384bbSLeorizeIn the "packages" subdirectory the built packages are collected. This is the
5903d384bbSLeorizeinitial set of packages for the HaikuPorts packages repository, plus the source
6003d384bbSLeorizepackages the Haiku build system put in your generated directory under
6103d384bbSLeorize"objects/haiku/<arch>/packaging/repositories/HaikuPorts-sources-build/packages"
6203d384bbSLeorize(ignore the "rigged" source packages). With these packages a HaikuPorts package
6303d384bbSLeorizerepository can be built and in turn a regular Haiku can be built using it.
6403d384bbSLeorizeFurther packages can then be built on the regular Haiku.
6503d384bbSLeorize
6603d384bbSLeorizeFurther hints:
6703d384bbSLeorize
6803d384bbSLeorize- Of course, as usual, "-j<number>" can be passed to the jam building the
6903d384bbSLeorize  bootstrap Haiku. Building the bootstrap third-party packages, which is part of
7003d384bbSLeorize  this process, will take quite some time anyway. Since those packages are built
7103d384bbSLeorize  sequentially, the jam variable "HAIKU_PORTER_CONCURRENT_JOBS" can be defined
7203d384bbSLeorize  to the number of jobs that shall be used to build a package.
7303d384bbSLeorize- Instead of "bootstrap-raw" the build profile "bootstrap-vmware" can be used as
7403d384bbSLeorize  well. You can also define your own build profile, e.g. for building to a
7503d384bbSLeorize  partition. As long as its name starts with "bootstrap-" that will result in a
7603d384bbSLeorize  bootstrap Haiku.
7703d384bbSLeorize- ``haikuporter`` also supports the "-j<number>" option to specify the number of
7803d384bbSLeorize  jobs to use. Even on real hardware this step will nevertheless take a long
7903d384bbSLeorize  time.
8003d384bbSLeorize- The jam variable HAIKU_PORTER_EXTRA_OPTIONS can be defined to any options that
8103d384bbSLeorize  should be passed to ``haikuporter`` (``--debug`` is handy for showing python
8203d384bbSLeorize  strack traces, for instance).
8303d384bbSLeorize
8403d384bbSLeorizeHow it works
8503d384bbSLeorize============
8603d384bbSLeorizeBuilding the bootstrap Haiku image is in principle quite similar to building a
8703d384bbSLeorizeregular Haiku image, save for the following differences:
8803d384bbSLeorize
8903d384bbSLeorize- Some parts of a regular Haiku that aren't needed for building packages are
9003d384bbSLeorize  omitted (e.g. the Demos, MediaPlayer, the OpenGL API,...).
9103d384bbSLeorize- Certain third-party packages that aren't needed for building packages are
9203d384bbSLeorize  omitted as well.
9303d384bbSLeorize- The third-party packages are not downloaded from some package repository.
9403d384bbSLeorize  Instead for each package a bootstrap version is built from the sources using
9503d384bbSLeorize  ``haikuporter`` and the respective build recipe from haikuports.cross.
9603d384bbSLeorize- ``haikuporter`` itself and ready-to-build ("rigged") source packages for all
9703d384bbSLeorize  needed final third-party packages are copied to the image.
9803d384bbSLeorize
9903d384bbSLeorizeObviously the last two points are the juicy parts. Building a bootstrap
10003d384bbSLeorizethird-party package -- unless it is a pure data package -- requires certain
10103d384bbSLeorizeparts of Haiku; usually the headers, libroot and other libraries, and the glue
10203d384bbSLeorizecode. For some Haiku libraries we do already need certain third-party packages.
10303d384bbSLeorizeSo there's a bit of ping pong going on:
10403d384bbSLeorize
10503d384bbSLeorize- Initially the build system builds a package
10603d384bbSLeorize  "haiku_cross_devel_sysroot_stage1_<arch>.hpkg". It contains the essentials for
10703d384bbSLeorize  cross-compiling bootstrap third-party packages, but nothing that itself
10803d384bbSLeorize  depends on a third-party package.
10903d384bbSLeorize- Once all third-party packages required for it have been built, a more complete
11003d384bbSLeorize  "haiku_cross_devel_sysroot_<arch>.hpkg" is built. It is used to cross-compile
11103d384bbSLeorize  the remaining third-party packages.
11203d384bbSLeorize
11303d384bbSLeorizeThe rigged source packages (and regular source packages) are built via
11403d384bbSLeorize``haikuporter`` from the regular haikuports repository checkout. haikuports
11503d384bbSLeorizecontains build recipes for a lot of software. Which source packages should be
11603d384bbSLeorizebuilt is determined by the build system by checking what packages are needed for
11703d384bbSLeorizethe target build profile used by the bootstrap process. This defaults to
11803d384bbSLeorize"minimum-raw", but it can be changed by setting the jam variable
11903d384bbSLeorize"HAIKU_BOOTSTRAP_SOURCES_PROFILE"
12003d384bbSLeorize(i.e. ``jam -sHAIKU_BOOTSTRAP_SOURCES_PROFILE=@release-raw -q @bootstrap-raw``
12103d384bbSLeorizewill include source packages for all packages needed by release image).
12203d384bbSLeorize
1236ec74693SAlexander von Gluck IVFormat of hpkg Source Repository
124*d79d9a85SAdrien Destugues================================
125*d79d9a85SAdrien Destugues
1266ec74693SAlexander von Gluck IVFor Haikuporter to use source or "rigged" packages instead of requesting
1276ec74693SAlexander von Gluck IVpackages from a remote url (essential during bootstrap when patch, git,
1286ec74693SAlexander von Gluck IVcurl, etc are unavailable), haikuporter works on an empty haikuports repository
1296ec74693SAlexander von Gluck IVwith the following layout:
1306ec74693SAlexander von Gluck IV
1316ec74693SAlexander von Gluck IV- haikuports/input-source-packages
1326ec74693SAlexander von Gluck IV  Contains all input source (or source_rigged) hpkgs
1336ec74693SAlexander von Gluck IV- haikuports/FormatVersions
1346ec74693SAlexander von Gluck IV  Contains ``RecipeFormatVersion=1`` so haikuporter can identify the haikuports
1356ec74693SAlexander von Gluck IV  repository
1366ec74693SAlexander von Gluck IV
1376ec74693SAlexander von Gluck IVAfter ``haikuporter`` is given this directory structure, it will parse the
1386ec74693SAlexander von Gluck IVsource or "rigged" packages, and allow you to build them internally replacing
1396ec74693SAlexander von Gluck IVthe SOURCE_URI with ``pkg:input-source-packages/``
1406ec74693SAlexander von Gluck IV
1416ec74693SAlexander von Gluck IVThis process is generally automated during the generation of the bootstrap
1426ec74693SAlexander von Gluck IVimage, but manual setup may be needed if the bootstrap image is non-functional
1436ec74693SAlexander von Gluck IVon your target platform.
1446ec74693SAlexander von Gluck IV
14503d384bbSLeorizeHaiku Architecture Ports
14603d384bbSLeorize========================
147*d79d9a85SAdrien Destugues
14803d384bbSLeorizeWhen preparing a new Haiku architecture port for the bootstrap build the
14903d384bbSLeorizefollowing things need to be considered:
15003d384bbSLeorize
15103d384bbSLeorize- There need to be repository definitions
15203d384bbSLeorize  "build/jam/repositories/HaikuPorts/<arch>" and
15303d384bbSLeorize  "build/jam/repositories/HaikuPortsCross/<arch>". The former lists the packages
15403d384bbSLeorize  available for a regular Haiku, i.e. it must include at least the packages
15503d384bbSLeorize  needed for a basic Haiku image that can build third-party packages. The latter
15603d384bbSLeorize  lists the available bootstrap third-party packages.
15703d384bbSLeorize- There needs to be "src/data/package_infos/<arch>/haiku", a package info for
15803d384bbSLeorize  the Haiku system package (currently also used for the bootstrap package).
15903d384bbSLeorize- In the haikuports.cross repository all build recipes need to support the
16003d384bbSLeorize  architecture (the architecture must be listed in the "ARCHITECTURES"
16103d384bbSLeorize  variable). Some software may need to be patched for cross-building to work for
16203d384bbSLeorize  the architecture.
16303d384bbSLeorize- In the haikuports repository all build recipes for required software need to
16403d384bbSLeorize  support the architecture.
16503d384bbSLeorize
16603d384bbSLeorizeIf the Haiku architecture port doesn't support a working userland yet, the
16703d384bbSLeorizeprocess obviously cannot go further than building the bootstrap Haiku image.
168