1================= 2Building Packages 3================= 4 5This page provides information regarding the package building process. The first 6section documents building a package with the low level command ``package``. The 7second section refers to building packages with the ``haikuporter`` tool. 8 9Building a Package with the "package" Command 10============================================= 11The package file format is specified in detail in a `separate document`_. This 12section presents information from the perspective of how to build a package file 13with the ``package`` command. 14 15.. _separate document: FileFormat.rst 16 17An hpkg file is an archive file (just like tar or zip files) that additionally 18contains package meta information in a separate section of the file. When 19building an hpkg file via the ``package`` command the meta information must be 20provided via a ``.PackageInfo`` file. For convenience, the file itself is added 21to the archive as well and can be extracted later, but it will be ignored by 22packagefs. 23 24The ``.PackageInfo`` file must be located in the top directory that is archived. 25A ``package`` invocation usually looks like that:: 26 27 package create -C foo-4.5.26-1 foo-4.5.26-1-x86.hpkg 28 29or (packaging a gcc2 build from within the folder):: 30 31 cd foo-4.5.26-1 32 package create ../foo-4.5.26-1-x86_gcc2.hpkg 33 34The argument of the ``-C`` option specifies the directory whose contents to 35archive (by default the current directory), the remaining argument is the path 36of the package file to be built. 37 38The .PackageInfo 39---------------- 40The contents of the ``.PackageInfo`` adheres to a restricted driver settings 41syntax. It consists of name-value pairs, following this simple grammar:: 42 43 package_info ::= attribute* 44 attribute ::= name value_list 45 value_list ::= value | ( "{" value* "}" ) 46 value ::= value_item+ ( '\n' | ';' ) 47 48``name`` can be one of the attribute names defined below. ``value_item`` is 49either an unquoted string not containing any whitespace characters or a string 50enclosed in quotation marks (``"`` or ``'``) which can contain whitespace and 51also escaped characters (using ``\``). 52 53The supported attributes are: 54 55- ``name``: The name of the package, not including the package version. Must 56 only contain ``entity_name_char`` characters. 57 58 :: 59 60 entity_name_char ::= any character but '-', '/', '=', '!', '<', '>', or whitespace 61 62- ``version``: The version of the package. The string must have the ``version`` 63 format (see the `Version Strings`_ section). 64- ``architecture``: The system architecture the package has been built for. Can 65 be either of: 66 67 - ``any``: Any architecture (e.g. a documentation package). 68 - ``x86``: Haiku x86, built with gcc 4. 69 - ``x86_gcc2``: Haiku x86, built with gcc 2. 70 71- ``summary``: A short (one-line) description of the package. 72- ``description``: A longer description of the package. 73- ``vendor``: The name of the person/organization publishing this package. 74- ``packager``: The name and e-mail address of person that created this package 75 (e.g. "Peter Packman <peter.packman@example.com>"). 76- ``copyrights``: A list of copyrights applying to the software contained in 77 this package. 78- ``licenses``: A list of names of the licenses applying to the software 79 contained in this package. 80- ``urls``: A list of URLs referring to the packaged software's project home 81 page. The list elements can be regular URLs or email-like named URLs (e.g. 82 "Project Foo <http://foo.example.com>"). 83- ``source-urls``: A list of URLs referring to the packaged software's source 84 code or build instructions. Elements have the same format as those of 85 ``urls``. 86- ``flags``: A list of boolean flags applying to the package. Can contain any 87 of the following: 88 89 - ``approve_license``: This package's license requires approval (i.e. must be 90 shown to and acknowledged by user before installation). 91 - ``system_package``: This is a system package (i.e. lives under 92 "/boot/system"). 93 94- ``provides``: A list of entities provided by this package. The list elements 95 must have the following format:: 96 97 entity ::= entity_name [ "=" version_ref ] [ ( "compat" | "compatible" ) ">=" version_ref ] 98 entity_name ::= [ entity_type ":" ] entity_name_char+ 99 entity_type ::= "lib" | "cmd" | "app" | "add_on" 100 101 See the `Version Strings`_ section for the ``version_ref`` definition. 102 The first ``version_ref`` specifies the version of the provided entity. It 103 can be omitted e.g. for abstract resolvables like "web_browser". The 104 ``version_ref`` after the "compat"/"compatible" string specifies the oldest 105 version the resolvable is backwards compatible with. 106 The ``entity_type`` specifies the type of entity provided: a library ("lib"), 107 a command line program ("cmd"), an application ("app"), or an add-on 108 ("add-on"). 109- ``requires``: A list of entities required by this package. The list elements 110 must have the following format:: 111 112 required_entity ::= entity_name [ version_operator version_ref [ "base" ] ] 113 version_operator ::= "<" | "<=" | "==" | "!=" | ">=" | ">" 114 115 See the `Version Strings`_ section for the ``version_ref`` definition. If 116 "base" is specified, the specified entity is the base package for this 117 package. The package manager shall ensure that this package is installed in 118 the same installation location as its base package. 119- ``supplements``: A list of entities that are supplemented by this package 120 (i.e. this package will automatically be selected for installation if the 121 supplemented entities are already installed). The list elements must have the 122 ``required_entity`` format. 123- ``conflicts``: A list of entities that this package conflicts with (i.e. only 124 one of both can be installed at any time). The list elements must have the 125 ``required_entity`` format. 126- ``freshens``: A list of entities that are being freshened by this package 127 (i.e. this package will patch one or more files of the package(s) that provide 128 this entity). The list elements must have the ``required_entity`` format. 129- ``replaces``: A list of entities that are being replaced by this package (used 130 if the name of a package changes, or if a package has been split). The list 131 elements must have the ``entity_name`` format. 132- ``global-writable-files``: A list of global writable file infos. The list 133 elements must have the following format:: 134 135 global_writable_file_info ::= path [ "directory" ] [ "keep-old" | "manual" | "auto-merge" ] 136 137 ``path`` is the relative path of the writable file or directory, starting with 138 "settings/" or any other writable directory. If the "directory" keyword is 139 given, the path refers to a directory. If no other keyword is given after the 140 path respectively after the "directory" keyword, the file or directory is not 141 included in the package. It will be created by the software or by the user. 142 If a keyword is given, the file or directory (a default version) is included 143 in the package and it will be extracted on package activation. The keyword 144 specifies what shall happen when the package is updated and a previous default 145 version of the file or directory has been modified by the user: 146 147 - "keep-old": Indicates that the software can read old files and the 148 user-modified file or directory should be kept. 149 - "manual": Indicates that the software may not be able to read an older file 150 and the user may have to manually adjust it. 151 - "auto-merge": Indicates that the file format is simple text and a three-way 152 merge shall be attempted (not applicable for directories). 153 154- ``user-settings-files``: A list of user settings file infos. The list elements 155 must have the following format:: 156 157 user_settings_file_info ::= path [ "directory" | "template" template_path ] 158 159 ``path`` is the relative path of the settings file or directory, starting with 160 "settings/". It is not included in the package. However, if ``template_path`` 161 is specified, it is a path to a file included in the package that can serve as 162 a template for the settings file. It doesn't imply any automatic action on 163 package activation, though. If the "directory" keyword is given, the path 164 refers to a settings directory (typical when a program creates multiple 165 settings files). 166- ``users``: A list of specifications for Unix users the packaged software 167 requires. The list elements must have the following format:: 168 169 user: ::= name [ "real-name" real_name ] "home" home_path [ "shell" shell_path ] [ "groups" group+ ] 170 171 ``name`` is the name of the Unix user, ``real_name``, if specified, the real 172 name of the user, ``home_path`` the path to the user's home directory, 173 ``shell_path`` the path to the user's shell, and ``group+`` is a list of the 174 names of Unix groups the user is a member of (first one is their primary 175 group). If the respective components are not specified, ``name`` is also 176 used as the user's real name, "/bin/bash" is the path of the user's shell, 177 and the user will belong to the default user group. 178- ``groups``: A list of names of Unix groups the packaged software requires. 179- ``post-install-scripts``: A list of paths of files included in the package, 180 which shall be executed on package activation. Each path must start with 181 "boot/post-install/". 182 183Version Strings 184--------------- 185Versions strings are used in three contexts: For the package version, for 186resolvable versions (``provides``), and in dependency version expressions 187(``requires``, ``supplements``, ``conflicts``, ``freshens``). They are 188structurally identical, with the exception that the former requires a revision 189component (``version``), while the latter two don't (``version_ref``):: 190 191 version ::= major [ "." minor [ "." micro ] ] [ "~" pre_release ] "-" revision 192 version_ref ::= major [ "." minor [ "." micro ] ] [ "~" pre_release ] [ "-" revision ] 193 major ::= alphanum_underline+ 194 minor ::= alphanum_underline+ 195 micro ::= alphanum_underline_dot+ 196 pre_release ::= alphanum_underline_dot+ 197 revision ::= positive_non_zero_integer 198 199The meaning of the major, minor, and micro version parts is vendor specific. A 200typical, but not universal (!), convention is to increment the major version 201when breaking binary compatibility (i.e. version a.d.e is backwards compatible 202to version a.b.c for all b.c <= d.e), to increment the minor version when adding 203new features (in a binary compatible way), and to increment the micro version 204for bug fix releases. There are, however, projects that use different 205conventions which don't imply that e.g. version 1.4 is backwards compatible with 206version 1.2. Which convention is used is important for the packager to know, as 207it is required for a correct declaration of the compatibility versions for the 208provided resolvables. The compatibility version specifies the oldest version the 209provided resolvable is backwards compatible with, thus implying the version 210range requested by a dependent package the resolvable can satisfy. When 211following the aforementioned convention a resolvable of version 2.4.3 should 212have compatibility version 2 (or, semantically virtually identical, 2.0.0). 213Not following the convention 2.4 may be correct instead. If no compatibility 214version is specified, the resolvable can only satisfy dependency constraints 215with an exactly matching version. 216 217The pre-release part of the version string has special semantics for comparison. 218Unlike minor and micro its presence makes the version older. E.g. version 219R1.0~alpha1 is considered to be older than version R1.0. When both version 220strings have a pre-release part, that part is compared naturally after the micro 221part (R1.0.1~alpha1 > R1.0 > R1.0~beta1 > R1.0~alpha2). 222 223The revision part of the version string is assigned by the packager (not by the 224vendor). It allows to uniquely identify updated packages of the same vendor 225version of a software. 226 227Package File Names 228------------------ 229A package file name should have the following form:: 230 231 file_name ::= name "-" version "-" architecture ".hpkg" 232 233Example package file 234-------------------- 235:: 236 237 name example 238 version 42.17-12 239 architecture x86_gcc2 240 summary "This is an example package file" 241 description "Haiku has a very powerful package management system. Really, you should try it! 242 it even supports muliline strings in package descriptions" 243 packager "John Doe <test@example.com>" 244 vendor "Haiku Project" 245 licenses { 246 "MIT" 247 } 248 copyrights { 249 "Copyright (C) 1812-2013 by John Doe <test@example.com>" 250 } 251 provides { 252 example = 42.17-12 253 cmd:example = 3.1 254 } 255 requires { 256 haiku >= r1~alpha4_pm_hrev46213-1 257 lib:libpython2.6 >= 1.0 258 } 259 urls { 260 "http://example.com/" 261 } 262 global-writable-files { 263 "settings/example/configurationFile" keep-old 264 "settings/example/servers" directory keep-old 265 } 266 source-urls { 267 "Download <http://example.com/source.zip>" 268 } 269 270Building a Package with "haikuporter" 271===================================== 272``haikuporter`` is a high level tool for building packages. As input it reads a 273build recipe file for a certain version of a software (aka port) and produces 274one or more packages, as declared in the recipe. A recipe specifies package 275requirements similar to how it is done in a ``.PackageInfo`` file. When asked to 276build a port, ``haikuporter`` resolves the respective dependencies and 277recursively builds all not-yet-built ports required for the requested port. 278``haikuporter`` itself and a large library of recipe files are hosted at 279HaikuPorts_. A detailed `documentation for haikuporter`_ and the 280`recipe format`_ can also be found there. 281 282.. _HaikuPorts: https://github.com/haikuports/ 283 284.. _documentation for haikuporter: 285 https://github.com/haikuports/haikuports/wiki/HaikuPorterForPM 286 287.. _recipe format: 288 https://github.com/haikuports/haikuports/wiki/HaikuPorter-BuildRecipes 289