bulk.8 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. .\" $OpenBSD: bulk.8,v 1.10 2016/09/18 22:09:12 schwarze Exp $
  2. .\"
  3. .\" Copyright (c) 2016 Marc Espie <espie@openbsd.org>
  4. .\"
  5. .\"
  6. .\" Permission to use, copy, modify, and distribute this software for any
  7. .\" purpose with or without fee is hereby granted, provided that the above
  8. .\" copyright notice and this permission notice appear in all copies.
  9. .\"
  10. .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. .Dd $Mdocdate: September 18 2016 $
  18. .Dt BULK 8
  19. .Os
  20. .Sh NAME
  21. .Nm bulk
  22. .Nd building OpenBSD packages in bulk
  23. .Sh DESCRIPTION
  24. There are quite a few steps necessary to build packages on a cluster.
  25. They are:
  26. .Pp
  27. .Bl -enum -compact -offset indent
  28. .It
  29. Choose master machine setup and create partitions.
  30. .It
  31. Setup chrooted builds on the master.
  32. .It
  33. Add slaves and do a full bulk.
  34. .It
  35. Clean up and do subsequent bulks.
  36. .It
  37. Perform additional maintenance.
  38. .El
  39. .Ss 1. Choose master machine setup and create partitions
  40. Setup a master machine with enough room for a chroot, say
  41. .Pa /build .
  42. Assuming you are using a cluster of machines,
  43. this chroot should contain NFS exportable partitions for distfiles,
  44. plists, and packages (one single partition can be used for simplicity).
  45. A full setup requires on the order of 50GB for distfiles and 50GB for packages.
  46. .Pp
  47. It is possible to build packages without a chroot, but the space
  48. requirement difference is negligible (a full
  49. .Ox
  50. install is less than 1GB), and having everything chrooted means you may
  51. install useful tools to help with the process outside of the chroot
  52. .Po
  53. for instance
  54. .Xr rsync 1
  55. .Pc .
  56. .Pp
  57. Reserve one "scratch" partition under the chroot for WRKOBJDIR
  58. (for instance, mfs, async, or SSD).
  59. This partition should be roughly 10GB if you want to be able to
  60. build all ports.
  61. This can often double as
  62. .Pa /tmp
  63. under the chroot.
  64. .Pp
  65. Alternately, you can setup your whole chroot as a scratch partition,
  66. and reserve one more permanent space under it for distfiles,
  67. packages, and plists.
  68. .Pp
  69. Choose a strategy for the ports tree itself.
  70. There must be a copy under
  71. .Pa /build .
  72. You can either copy it from outside the chroot, have it in an NFS
  73. partition, or manually make sure all machines on the cluster have the
  74. same ports tree (cvs checkout, rsync ...).
  75. .Pp
  76. Note that logs are only produced on the master, and thus do not
  77. need to be nfs exportable, nor even inside the chroot.
  78. .Pp
  79. .Ox
  80. now comes with default users for package builds, namely _pbuild and _pfetch.
  81. .Pp
  82. However, the default
  83. .Xr login.conf 5
  84. is too small for building the largest ports and for machines with
  85. lots of cores.
  86. You should probably increase the limit on the number of processes and
  87. on the default data size for _pbuild.
  88. .Pp
  89. Note that _pbuild does not need network access, and can be blocked using
  90. .Xr pf 4
  91. with a rule such as
  92. .Bd -literal -offset indent
  93. block out quick proto {tcp,udp} from self user _pbuild
  94. .Ed
  95. .Pp
  96. Recent
  97. .Ox
  98. systems do not need any kind of
  99. .Xr doas 1
  100. setup for bulk ports builds, as
  101. .Xr dpb 1
  102. is run as root and drops permissions appropriately.
  103. .Ss 2. Setup chrooted builds on the master
  104. Populate the initial chroot with
  105. .Xr proot 1 .
  106. Point DISTDIR, PACKAGE_REPOSITORY, PLIST_REPOSITORY, WRKOBJDIR
  107. to appropriate locations.
  108. .Pp
  109. Pay attention to nodev and wxallowed warnings.
  110. A chroot setup that can't have devices won't work at all.
  111. A setup without wxallowed in /usr/local and WRKOBJDIR won't
  112. build a lot of things.
  113. .Pp
  114. Check that this setup can build ports by running
  115. .Li dpb -B /build
  116. as root.
  117. Fix any issues related to file ownership at this point.
  118. See
  119. .Xr dpb 1
  120. for details.
  121. .Pp
  122. If your WRKOBJDIR is a temporary partition, make sure it
  123. belongs to _pbuild:_pbuild after a reboot.
  124. .Ss 3. Add slaves and do a full bulk
  125. Create identical slave machines with the same release material.
  126. Have them import the NFS partitions from the master, they
  127. don't need root access to the partitions.
  128. Set up
  129. .Xr ssh 1
  130. so that the master can connect to the slaves, using ssh protocol 2,
  131. as root, preferably without a password or passphrase (however,
  132. .Xr dpb 1
  133. uses a master connection, so a password would be required just once per host).
  134. .Pp
  135. Note that code on slave machines will only run as _pbuild
  136. (during builds) or root (during dependency installation).
  137. Slave machines only require highly restricted network access.
  138. They just need to act as nfs clients to the master and to be reachable
  139. through ssh from the master.
  140. .Pp
  141. Use a similar
  142. .Xr proot 1 config
  143. to populate each slave.
  144. .Pp
  145. You should now be able to build ports on the slaves.
  146. A simple config will just have
  147. .Bd -literal -offset indent
  148. DEFAULT chroot=/build
  149. localhost
  150. host1
  151. \&...
  152. .Ed
  153. .Pp
  154. Check that the full config can still build ports.
  155. .Pp
  156. You're now ready for a full bulk.
  157. Beware that even fast configs (3 amd64 with 8 cores each) may take over 24 hours
  158. to finish. It's generally appropriate to run
  159. .Xr dpb 1
  160. under
  161. .Xr tmux 1 .
  162. .Ss 4. Clean up and do subsequent bulks
  163. Before running the next bulk, you should set up rotating logs and move the
  164. PACKAGE_REPOSITORY away.
  165. Save the PLIST_REPOSITORY and DISTDIR though.
  166. PLIST_REPOSITORY will catch problems in packing-lists.
  167. .Pa ${PLIST_REPOSITORY}/${ARCH}/history
  168. is also used to store
  169. .Xr sha256 1
  170. history, necessary to reorder files inside packages to speed updates up.
  171. .Pp
  172. The DISTDIR contains history information as well as DISTDIR/build-stats
  173. to speed further runs up.
  174. .Pp
  175. How you wipe things out depends on your setup.
  176. If you run
  177. .Xr proot 1
  178. again each time, most things will get cleaned up automatically
  179. .Po
  180. .Pa /build/usr/local , /build/var/db/pkg ...
  181. .Pc .
  182. Note that known directories such as WRKOBJDIR do not get cleaned up
  183. automatically, so you may want to set up a STARTUP_SCRIPT in
  184. .Xr dpb 1 .
  185. .Ss 5. Perform additional maintenance
  186. .Xr clean-old-distfiles 1
  187. should be run occasionally since the DISTDIR will continue growing.
  188. .Pp
  189. .Xr check-problems 1
  190. should be run occasionally to find out conflicts and dependency issues.
  191. .Sh SEE ALSO
  192. .Xr check-problems 1 ,
  193. .Xr clean-old-distfiles 1 ,
  194. .Xr dpb 1 ,
  195. .Xr proot 1 ,
  196. .Xr register-plist 1 ,
  197. .Xr tmux 1 ,
  198. .Xr bsd.port.mk 5 ,
  199. .Xr release 8