building.rst 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. Building with unibuild
  2. ======================
  3. **Unibuild** need a build spec. Build spec must be bash script. *name* *version* *release* *summary* *description* variables and *_setup* *_build* *_check* *_install* functions uses. For example:
  4. .. code-block:: shell
  5. #!/bin/bash
  6. name="bash"
  7. version="5.0"
  8. summary="bash shell"
  9. description="The bash shell"
  10. source=(https://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz)
  11. _setup(){
  12. ./configure --prefix=/usr
  13. }
  14. _build(){
  15. make
  16. }
  17. _install(){
  18. make install DESTDIR=$INSTALLDIR
  19. }
  20. BUILDDIR
  21. ^^^^^^^^
  22. Main directory that uses for all operations. Unibuild create 3 directory for building. **WORKDIR** **INSTALLDIR** **PKGDIR**
  23. All directories in builddir. Unibuild created builddir with **mktemp -d** command.
  24. **1. WORKDIR**
  25. Workdir is building directory. Before running functions, unibuild go workdir. Workdir is changeable variable. If only one source directory in workdir. unibuild automaticaly change workdir as source directory.
  26. **2. INSTALLDIR**
  27. Installdir is package destdir. Spec must store package files in here.
  28. **3. PKGDIR**
  29. Pkgdir is packaging directory required by target packager.
  30. Build functions
  31. ^^^^^^^^^^^^^^^
  32. If you dont define functions, unibuild try to detect build method and create automaticaly. Or you can define **BuildType** variable for creating build function as automaticaly. Also you can define **CONFIG_OPTIONS** variable for auto build options. For example:
  33. .. code-block:: shell
  34. #!/bin/bash
  35. name="bash"
  36. version="5.0"
  37. summary="Bash shell"
  38. description="The bash shell"
  39. builddepends=("gcc")
  40. depends=("readline")
  41. license="gplv3"
  42. source=(https://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz)
  43. BuildType="autotools"
  44. This example uses autotools for compiling. autotools define build functions look like this:
  45. .. code-block:: shell
  46. _setup(){
  47. ./configure --prefix=/usr $CONFIG_OPTIONS
  48. }
  49. _build(){
  50. make -j$(nproc)
  51. }
  52. _install(){
  53. make install DESTDIR=$INSTALLDIR
  54. }
  55. The gnu bash source code has ./configure script so if you dont define build functions, unibuild detect and set **BuildType** variable.
  56. Function calling order: _setup => _build => _check => _install
  57. Build target and host
  58. ^^^^^^^^^^^^^^^^^^^^^
  59. Unibuild is universal builder so supported most of distribution. You can define **TARGET** and **HOST** variables.
  60. ======== =================================================
  61. VARIABLE DESCRIPION
  62. ======== =================================================
  63. TARGET Package build target: debian, inary, appimage ...
  64. HOST Builder distribution: debian, inary ...
  65. ======== =================================================
  66. host and target automaticaly detected if you dont define.
  67. Spec variables
  68. ^^^^^^^^^^^^^^
  69. Unibuild spec variables and description avaiable here:
  70. ======== ============ ======================================================== =======
  71. OPTIONAL VARIABLE DESCRIPION Type
  72. ======== ============ ======================================================== =======
  73. no description Package description. String
  74. no license Source code license. String
  75. no name Package name. String
  76. no source Package source code url or path. Array
  77. no summary Package summary. String
  78. no version Package version. Only can use [0-9] or . or - String
  79. **yes** arch Package architecture. if dont define, auto detected. String
  80. **yes** backup Package backup names. Array
  81. **yes** builddepends Package names that required by compiling. Array
  82. **yes** categories Appilcation categories. Used by appimage String
  83. **yes** checkdepends Package check dependencies. Array
  84. **yes** conflicts Package conflict names. Array
  85. **yes** depends Package runtime dependencies. Array
  86. **yes** email Packager email. String
  87. **yes** executable Package main executable name. Used by appimage String
  88. **yes** groups Package group names. Array
  89. **yes** homepage Project homepage. String
  90. **yes** icon Application icon name or path. Used by appimage String
  91. **yes** isa Package type. Used by inary. Array
  92. **yes** maintainer Package maintainer name. String
  93. **yes** optdepends Package optional dependencies. Array
  94. **yes** partof Package section or component name. String
  95. **yes** PKGS Main and splited package names list. Array
  96. **yes** priority Package priority. String
  97. **yes** provides Package provide names. Array
  98. **yes** release Package release. Used by inary. Integer
  99. **yes** replaces Package replace names. Array
  100. ======== ============ ======================================================== =======
  101. Unibuild supported different source types. All known source types:
  102. 1. name::git://xxxx.git::branch
  103. 2. git+https://xxxxx.git::branch
  104. 3. name::https://xxxxx
  105. 4. /path/to/name/xxx
  106. 5. https://xxxxxx
  107. Split package
  108. ^^^^^^^^^^^^^
  109. Unibuild uses **PKGS** array for getting package names. We have *main* package and *splited* packages. Main package is first **PKGS** array item. If you did not define this aray unibuild use **name** value main package name and do not splite.
  110. Unibuild define and create **INSTALLDIR** and **PKGDIR** directories for every *splited* and *main* packages and run **_install** functions.
  111. Unibuild change **package** value when run **_install** function.
  112. You can split package like this:
  113. .. code-block:: shell
  114. PKGS=("main" "splited")
  115. _install(){
  116. if is_pkg "splited" ; then
  117. takedir "main" "/path/to/stuff"
  118. return
  119. fi
  120. make install DESTDIR=$INSTALLDIR
  121. }
  122. **takedir** function move files or directories from main package.
  123. **is_package** function return true if current package is splited package.
  124. **return** for stop function block