xref: /haiku/docs/develop/packages/PackagingPolicy.rst (revision a5061ecec55353a5f394759473f1fd6df04890da)
103d384bbSLeorize================
203d384bbSLeorizePackaging Policy
303d384bbSLeorize================
403d384bbSLeorizeThis document defines the policy for creating packages.
503d384bbSLeorize
603d384bbSLeorizeMultiple Packages per Software
703d384bbSLeorize==============================
803d384bbSLeorizeInstallation files of a software shall be put into separated packages according
903d384bbSLeorizeto their purpose. For a software "foo":
1003d384bbSLeorize
1103d384bbSLeorize- Package "foo": Contains all runtime files, i.e. everything needed to "run" the
1203d384bbSLeorize  software. This may include executables (e.g. executable "bin/foo"), shared
1303d384bbSLeorize  libraries (e.g. "lib/libfoo.so"), data files
1403d384bbSLeorize  (e.g. "data/foo/foo-runtime-data").
1503d384bbSLeorize- Package "foo_devel": Contains only the files needed for development. This
1603d384bbSLeorize  includes header files and static libraries. Shared libraries are not to be
1703d384bbSLeorize  included. Instead the package must declare package "foo" with the matching
1803d384bbSLeorize  version as a requirement.
1903d384bbSLeorize- Package "foo_doc": Contains the documentation for using "foo".
2003d384bbSLeorize- Package "foo_devel_doc": Contains the documentation for "foo" development,
2103d384bbSLeorize  like API documentation etc.
2203d384bbSLeorize- Package "foo_debuginfo": Contains the debug information for the package "foo".
2303d384bbSLeorize
2403d384bbSLeorizeIf multiple packages are defined, they must not contain any common files.
2503d384bbSLeorize
2603d384bbSLeorizeIf a software contains client and server software that can be used independently
2703d384bbSLeorizefrom each other, two separate sets of packages shall be created.
2803d384bbSLeorize
2903d384bbSLeorizeProvides Declaration
3003d384bbSLeorize====================
3103d384bbSLeorizeA package "foo" must declare the following provided resolvables:
3203d384bbSLeorize
3303d384bbSLeorize- "foo=<version>" with <version> naming the exact version of the package.
3403d384bbSLeorize- "cmd:<name>=<version>" for each executable <name> with version <version>
3503d384bbSLeorize  installed in "bin/". This includes a declaration for "cmd:foo", if there is an
3603d384bbSLeorize  executable named like the package.
3703d384bbSLeorize- "lib:<name>=<version>" for each shared library <name> (not including a suffix,
3803d384bbSLeorize  e.g. "libfoo") with version <version> installed in "lib/".
3903d384bbSLeorize- "devel:<name>=<version>" for each library <name> (not including a suffix,
4003d384bbSLeorize  e.g. "libfoo") with version <version> for which development files (library
4103d384bbSLeorize  symlinks in "develop/lib" and header files in "develop/headers") are included.
4203d384bbSLeorize
4303d384bbSLeorizeAny instance of '-' in <name> shall be replaced by '_'. If the backward
4403d384bbSLeorizecompatibility of a resolvable is known, a "compat >= <compatibleVersion>" shall
4503d384bbSLeorizebe added accordingly.
4603d384bbSLeorize
4703d384bbSLeorizeDocumentation
4803d384bbSLeorize=============
4903d384bbSLeorizeIf a package "foo" provides documentation (which it should, of course), in many
5003d384bbSLeorizecases that can be provided in different formats:
5103d384bbSLeorize
5203d384bbSLeorize- Any kind of user documentation belongs in a subdirectory of "documentation"
5303d384bbSLeorize
5403d384bbSLeorize  - Man pages is the preferred format for terminal and should be installed into
5503d384bbSLeorize    the corresponding folders in the subdirectory "man".
5603d384bbSLeorize  - Info files are provided by many packages. If at all desirable, they should
5703d384bbSLeorize    be installed into the subdirectory "info". One problem with info files is
5803d384bbSLeorize    that all packages currently contain a file named "documentation/info/dir",
5903d384bbSLeorize    which supposedly is the list of all available info files, but since each
6003d384bbSLeorize    package provides an instance of this file containing only its own info
6103d384bbSLeorize    files, an arbitrary dir file is made visible via packagefs. The file should
6203d384bbSLeorize    therefore not be include in a package.
6303d384bbSLeorize  - Other documentation for a package foo -- HTML, a simple ReadMe, sample
6403d384bbSLeorize    documents, PDFs, etc. -- goes into subdirectory "packages/foo". If it is
6503d384bbSLeorize    likely that multiple versions of a package may be installed, then a version
6603d384bbSLeorize    string (as appropriate just major, major and minor, or even full (but no
6703d384bbSLeorize    revision)) should be appended, e.g. "package/foo-2" or "package/foo-2.13".
6803d384bbSLeorize
6903d384bbSLeorize- For a package foo_devel developer documentation, except man and info pages,
7003d384bbSLeorize  should go into "develop/documentation/foo". A version string may be appended
7103d384bbSLeorize  to the directory name as well. When it is unclear what is developer
7203d384bbSLeorize  documentation or it isn't really possible to separate it from user
7303d384bbSLeorize  documentation "documentation/foo" should be used.
7403d384bbSLeorize
7503d384bbSLeorizeData Files
7603d384bbSLeorize==========
7703d384bbSLeorizeData files for a package foo shall generally be placed in a directory
7803d384bbSLeorize"data/foo". If it is likely that multiple versions of a package may be
7903d384bbSLeorizeinstalled, then a version string shall be appended. Data (but not
8003d384bbSLeorizesettings/configuration) files generated at run-time shall be placed in
8103d384bbSLeorize"cache/foo" or "var/foo", depending on the kind of data the files contain. For
8203d384bbSLeorizedata files, both read-only or generated, that are shared between different
8303d384bbSLeorizepackages/software a differently named subdirectory may be used as appropriate
8403d384bbSLeorize(e.g. font files are placed in "data/fonts").
8503d384bbSLeorize
8603d384bbSLeorizeWritable and Settings Files and Directories
8703d384bbSLeorize===========================================
8803d384bbSLeorizeAll global writable files and directories as well as user settings files and
8903d384bbSLeorizedirectories that the package includes or the packaged software creates or
9003d384bbSLeorizerequires the user to create shall be declared by the package (via
9103d384bbSLeorizeGLOBAL_WRITABLE_FILES respectively USER_SETTINGS_FILES in the build recipe) in
9203d384bbSLeorizethe following way:
9303d384bbSLeorize
9403d384bbSLeorize- A user specific settings file shall never be installed on package activation.
9503d384bbSLeorize  Usually user specific settings files are completely optional. In the rare case
9603d384bbSLeorize  that a software requires a user specific settings, the user will have to
9703d384bbSLeorize  create it manually. In either case, if the package includes a template user
9803d384bbSLeorize  settings file, that should be declared::
9903d384bbSLeorize
10003d384bbSLeorize    USER_SETTINGS_FILES="settings/foo template data/foo/user-settings-template"
10103d384bbSLeorize
10203d384bbSLeorize  If no template file is included, the settings file shall still be declared::
10303d384bbSLeorize
10403d384bbSLeorize    USER_SETTINGS_FILES="settings/foo"
10503d384bbSLeorize
10603d384bbSLeorize- Since many ported software requires a global settings file or other writable
10703d384bbSLeorize  files, a default version of such a file can be provided and is automatically
10803d384bbSLeorize  installed on package activation. In that case the package must also declare
10903d384bbSLeorize  what shall be done with a user-modified file when the package is updated.
11003d384bbSLeorize  E.g.::
11103d384bbSLeorize
11203d384bbSLeorize    GLOBAL_WRITABLE_FILES="settings/foo keep-old"
11303d384bbSLeorize
11403d384bbSLeorize  "keep-old" indicates that the software can read old files and the
11503d384bbSLeorize  user-modified file should be kept. "manual" indicates that the software may
11603d384bbSLeorize  not be able to read an older file and the user may have to manually adjust it.
11703d384bbSLeorize  "auto-merge" indicates that the file format is simple text and a three-way
11803d384bbSLeorize  merge shall be attempted. If a default settings file is not included in the
11903d384bbSLeorize  package, the settings file shall still be declared, just without the
12003d384bbSLeorize  additional keyword.
12103d384bbSLeorize
12203d384bbSLeorizeIn both cases, user settings files and global writable files, the "directory"
12303d384bbSLeorizekeyword can be used to indicate that the given path actually refers to a
12403d384bbSLeorizedirectory.
12503d384bbSLeorize
12603d384bbSLeorizePost-Installation Scripts
12703d384bbSLeorize=========================
12803d384bbSLeorizeA package may include one or more post-installation scripts. The scripts are
12903d384bbSLeorizeexecuted whenever the package is activated (for the first time, but also after
130a22fa0c9SAlexander G. M. Smithpackage updates and first boot of a newly installed OS). They shall be placed
131a22fa0c9SAlexander G. M. Smithin "boot/post-install" and declared explicitly by the package (via
132a22fa0c9SAlexander G. M. SmithPOST_INSTALL_SCRIPTS in the build recipe). A post-install script should be
133a22fa0c9SAlexander G. M. Smithconsidered the last resort. It should only be used, if there's no reasonable
134a22fa0c9SAlexander G. M. Smithalternative.  A typical use would be to create a desktop icon that the user
135a22fa0c9SAlexander G. M. Smithcan move around or delete.
136a22fa0c9SAlexander G. M. Smith
137a22fa0c9SAlexander G. M. SmithPre-Uninstallation Scripts
138*a5061eceSAdrien Destugues==========================
139a22fa0c9SAlexander G. M. SmithThese undo the effects of a post-installation script and usually are put
140a22fa0c9SAlexander G. M. Smithinto "boot/pre-uninstall".  A typical use is to remove desktop icons.
141