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