xref: /dflybsd-src/usr.bin/dsynth/dsynth.1 (revision d19ab22d6e424786b9f5e2555381fe329833f9f8)
1.\"
2.\" Copyright (c) 2019 The DragonFly Project.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to The DragonFly Project
5.\" by Matthew Dillon <dillon@backplane.com>
6.\" This code is based on a concept originally developed by John R. Marino.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\"
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in
16.\"    the documentation and/or other materials provided with the
17.\"    distribution.
18.\" 3. Neither the name of The DragonFly Project nor the names of its
19.\"    contributors may be used to endorse or promote products derived
20.\"    from this software without specific, prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
26.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
28.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.Dd August 21, 2019
36.Dt DSYNTH 1
37.Os
38.Sh NAME
39.Nm dsynth
40.Nd dsynth bulk dports builder utility
41.Sh SYNOPSIS
42.Nm
43.Op Fl dhvyDS
44.Op Fl s Ar n
45.Op Fl m Ar gb
46.Ar directive
47.Op origins
48.Nm
49.Ar help
50.Sh DESCRIPTION
51The
52.Nm
53utility allows a user to build and maintain part or all of dports
54locally.
55.Nm
56figures out the dependency topology of the dport(s) you
57is capable of building any number of ports concurrently based
58on the configuration parameters you supply.
59.Pp
60.Nm
61is based on an application called
62.Xr synth 1
63which was written by John Marino in Ada and served as the conceptual base
64for this program.
65.Nm
66is written in C and designed to be as portable as possible given a
67ports-style infrastructure.
68.Pp
69Our recommended build topology is with a configuration as follows:
70.Bd -literal
71[Global Configuration]
72profile_selected= LiveSystem
73
74[LiveSystem]
75Operating_system= DragonFly
76Directory_packages= /build/synth/live_packages
77Directory_repository= /build/synth/live_packages/All
78Directory_portsdir= /build/synth/dports
79Directory_options= /build/synth/options
80Directory_distfiles= /build/synth/distfiles
81Directory_buildbase= /build/synth/build
82Directory_logs= /build/synth/logs
83Directory_ccache= disabled
84Directory_system= /
85Number_of_builders= 8
86Max_jobs_per_builder= 8
87Display_with_ncurses= true
88.Ed
89.Pp
90This places all major directories under
91.Pa /build/synth .
92If you want to use the same dports and the same distfiles as your base
93system, you can null-mount /usr/distfiles onto /build/synth/distfiles
94and /usr/dports onto /build/synth/dports with
95.Pa /etc/fstab
96entries as follows:
97.Bd -literal
98# Device              Mountpoint		FStype  Options DumpPass#
99/usr/distfiles        /build/synth/distfiles	null    rw      4 4
100/usr/dports           /build/synth/dports	null    rw      4 4
101.Ed
102.Pp
103Please set the number of builders and the maximum number of jobs per
104builder according to available system resources.
105Remember that the total
106load on the system can be as high as (builders x jobs), and at least 4x
107that value in processes.
108Systems are typically restricted by memory and CPU horsepower.
109Start conservative and ramp up according to what your system can handle.
110A good rule of thumb is to set workers to the number of CPU threads your
111machine has or to 1/2 the number of gigabytes of memory your system has,
112whichever is lower.
113Then set the jobs per worker to no more than the
114number of CPU threads your machine has.
115.Pp
116.Nm
117has numerous features to manage machine load and swap usage to
118prevent a machine from being overloaded, allowing more workers
119to be configured than you might otherwise think is reasonable
120(which helps a lot when building the smaller ports).
121However, users running this program should be aware that very high loads
122and modest swap use are still likely to develop when building a large
123number of ports or when building very large ports like chromium.
124If the system is not dedicated to building packages you can reduce the
125impact to the rest of the system by running
126.Nm
127at nice +20 and also by reducing the number of workers and number of
128jobs per worker somewhat.
129.Pp
130We recommend that a minimum of 64GB of SSD-based swap be configured,
131or twice as much swap as main memory, whichever is the higher value.
132.Pp
133We recommend a minimum of 500GB of storage be configured in
134.Pa /build
135or wherever you have configured various directories.
136A full set of distfiles requires at least 120GB, a full dports including
137the git repo requires at least 1.5GB, and a full set of built packages
138requires at least 75GB.
139If using a filesystem such as HAMMER or HAMMER2
140which frees space overnight, double all of those numbers.
141.Pp
142The actual build infrastructure uses tmpfs... memory and swap, and does
143not use regular filesystem space.
144.Sh OPTIONS
145.Bl -tag -width indent
146.It Fl d[d...]
147Run in debug mode.
148If specified two or more times this will turn off
149ncurses and output the primary log (00_last_results.log) to the standard
150output, along with additional spew.
151.It Fl h
152Quickly output a synopsis of options and directives and exit.
153.It Fl m Ar gb
154Override the default package dependency memory target, in gigabytes.
155The default is 1/2 physical memory.
156The number of workers will be limited
157such that the aggregate size of package dependencies installed in each
158worker slot does not exceed this value.
159.Pp
160This handles a well-known effect where the sheer amount of data that has
161to be installed in tmpfs filesystems for large ports, when multiplied by
162the number of worker slots, can force excessive paging to occur and leave
163preciously little memory available to actually run compiles.
164Some paging
165is necessary to maintain maximum CPU utilization, but excessive paging
166can cause the whole machine to essentially become idle for extended
167periods of time.
168.It Fl v
169Quickly output the version and exit.
170.It Fl y
171Automatically answer 'y'es to any questions.
172.It Fl s Ar n
173.Nm
174usually slow-starts the worker slots, beginning with one slot and increasing
175by one every 5 seconds until the maximum configured number of workers is
176reached.
177This gives
178.Nm
179a slower ramp that it can load manage against.
180Specifying 0 disables the slow-start feature and the maximum number of
181worker slots (limited by the dependency graph) will be loaded immediately.
182.It Fl D
183Turn on DEVELOPER mode when building ports.
184.It Fl S[S]
185Turn off curses for script friendliness.
186The output will be log 00 and
187should be redirected to /dev/null or something similar.
188If you supply the options twice, color output escapes will also be
189turned off.
190You may also wish to use the
191.Fl y
192option for scripting dsynth.
193.El
194.Sh DIRECTIVES
195Generally
196.Nm
197is run with a directive and some directives allow a list of ports to be
198specified.
199This list should be space-delimited in DIR/SUBDIR format, for example:
200.Ar www/chromium .
201For directives with an optional ports list, your current installed set
202of ports will be used if you do not specify a list.
203.Bl -tag -width indent
204.It Cm status
205This will do a dry-run of
206.Cm upgrade-system
207but not actually build anything.
208.It Cm cleanup
209This will clean up any left-over mounts from prior builds.
210.Nm
211attempts to clean up all processes and mounts when you interrupt
212a build but doesn't always succeed.
213.It Cm init
214Creates and initializes the
215.Pa /etc/dsynth
216directory if it does not exst.
217This directive will complain and exit if either
218.Pa /etc/dsynth
219or
220.Pa /usr/local/etc/dsynth
221exists.
222It will not create
223.Pa /etc/dsynth
224in this situation.
225.It Cm configure
226NOT CURRENTLY IMPLEMENTED
227.It Cm upgrade-system
228NOT CURRENTLY IMPLEMENTED.
229Incrementally build and upgrade your locally
230installed packages, then upgrade your local system with them.
231.It Cm prepare-system
232Incrementally build and upgrade your locally installed packages, but
233do not upgrade your system with them.
234.It Cm rebuild-repository
235Build or rebuild the database files for the configured repository.
236.It Cm purge-distfiles
237Delete any obsolete source distribution files.
238.It Cm status-everything
239This will do a dry-run of a full bulk build of everything,
240but not actually build anything.
241.It Cm everything
242This will build the entire dports tree and then rebuild the repository
243when it finishes.
244.It Cm version
245This is for synth compatibility.
246The version of
247.Nm
248will be printed and the program will exit.
249.It Cm help
250Output a synopsis of options and directives and exit.
251.It Cm status Op Ar ports
252Do a dry-run with 'build' of the given list.
253.It Cm build Op Ar ports
254Incrementally build dports based on the given list.
255When done, ask whether the repository should be rebuilt or not.
256.It Cm just-build Op Ar ports
257Incrementally build dports based on the given list, then
258exits.
259No post-build steps will be taken.
260.It Cm install Op Ar ports
261NOT CURRENTLY IMPLEMENTED.  'build' based on the supplied
262list (or using currently installed packages), then rebuild
263the repository and upgrade the system without asking any further
264questions.
265.It Cm force Op Ar ports
266This is the same as 'build' but will delete existing packages first.
267Dependencies are not deleted unless they are out of date.
268.It Cm test Op Ar ports
269This is the same as 'build' but sets the environment variable
270.Ev DEVELOPER
271to
272.Sq yes
273and pre-deletes specified packages.
274Dependencies are not deleted unless they are out of date.
275.El
276.Sh FILES
277.Bl -tag -width ".It Pa <fs>/abc/defghi/<name>" -compact
278.It Pa /etc/dsynth/synth.ini
279The primary configuration file.
280If not found,
281.Nm
282will also look in
283.Pa /usr/local/etc/dsynth/synth.ini .
284.Pp
285.It Pa /etc/dsynth/LiveSystem-make.conf
286Typically contains the environment variables that will be set in
287the workers.
288.Nm
289firewalls the environment it is run under from the environment it
290provides to the workers.
291.Pp
292.It Pa /build/synth/build
293Recommended setting for
294.Va Directory_buildbase ,
295contains the build infrastructure... typically a template, mirrored
296system directories, and mount points for all the worker slots.
297The template will be [re]generated if 'pkg' needs to be built or
298if the
299.Pa .template.good
300file in this directory is deleted.
301.Pp
302.It Pa /build/synth/distfiles
303Recommended setting for
304.Va Directory_distfiles ,
305ports to a directory into which
306.Nm
307will download any source distribution files required for building.
308.Pp
309.It Pa /build/synth/dports
310Recommended setting for
311.Va Directory_portsdir ,
312points to a checked out dports repo.
313Note that
314.Nm
315does not automatically 'git pull' or otherwise synchronize the dports repo,
316you must do that yourself prior to starting a build.
317.Pp
318.It Pa /build/synth/live_packages
319Recommended setting for
320.Va Directory_packages ,
321points to a directory which will contain the completed application
322packages.
323.Pp
324.It Pa /build/synth/logs
325Recommended setting for
326.Va Directory_logs ,
327all log files will be placed in this directory.
328Special management logfiles begin with the numeral '0' for easily
329location.
330The logfiles for ports while and after building are stored in the
331form subdir____portname.log, with three underscores.
332.Pp
333.It Pa /build/synth/options
334Recommended setting for
335.Va Directory_options ,
336where options overrides for specific ports may be located.
337.Pp
338.It Pa /
339Recommended setting for
340.Va Directory_system ,
341which
342.Nm
343uses as a basis for creating the jails or chroots in each worker slot
344during building.
345No part of the system root is ever NULL-mounted read-write... it is always
346NULL-mounted read-only.
347Some elements from the system base will be mirrored in the build-base
348as an optimization.
349.Pp
350Note that the packages directory and the distfiles directory is mounted
351read-write in jails or chroots.
352All other r/w filesystems in the workers are
353.Xr tmpfs 5
354based filesystems and will be created and torn-down for each port.
355.El
356.Sh EXIT STATUS
357.Ex -std
358.Sh SEE ALSO
359.Xr synth 1 ,
360.Xr dports 7
361.Sh HISTORY
362The
363.Nm
364utility first appeared in
365.Dx 5.7 .
366.Sh AUTHORS
367.An Matthew Dillon Aq Mt dillon@backplane.com
368