xref: /dragonfly/usr.bin/dsynth/dsynth.1 (revision 7d2302ac)
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 October 24, 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) for you and
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= /
85Package_suffix= .txz
86Number_of_builders= 8
87Max_jobs_per_builder= 8
88Display_with_ncurses= true
89.Ed
90.Pp
91This places all major directories under
92.Pa /build/synth .
93If you want to use the same dports and the same distfiles as your base
94system, you can null-mount /usr/distfiles onto /build/synth/distfiles
95and /usr/dports onto /build/synth/dports with
96.Pa /etc/fstab
97entries as follows:
98.Bd -literal
99# Device              Mountpoint		FStype  Options DumpPass#
100/usr/distfiles        /build/synth/distfiles	null    rw      4 4
101/usr/dports           /build/synth/dports	null    rw      4 4
102.Ed
103.Pp
104Please set the number of builders and the maximum number of jobs per
105builder according to available system resources.
106Remember that the total
107load on the system can be as high as (builders x jobs), and at least 4x
108that value in processes.
109Systems are typically restricted by memory and CPU horsepower.
110Start conservative and ramp up according to what your system can handle.
111A good rule of thumb is to set workers to the number of CPU threads your
112machine has or to 1/2 the number of gigabytes of memory your system has,
113whichever is lower.
114Then set the jobs per worker to no more than the
115number of CPU threads your machine has.
116.Pp
117.Nm
118has numerous features to manage machine load and swap usage to
119prevent a machine from being overloaded, allowing more workers
120to be configured than you might otherwise think is reasonable
121(which helps a lot when building the smaller ports).
122However, users running this program should be aware that very high loads
123and modest swap use are still likely to develop when building a large
124number of ports or when building very large ports like chromium.
125If the system is not dedicated to building packages you can reduce the
126impact to the rest of the system by running
127.Nm
128at nice +20 and also by reducing the number of workers and number of
129jobs per worker somewhat.
130.Pp
131We recommend that a minimum of 64GB of SSD-based swap be configured,
132or twice as much swap as main memory, whichever is the higher value.
133.Pp
134We recommend a minimum of 500GB of storage be configured in
135.Pa /build
136or wherever you have configured various directories.
137A full set of distfiles requires at least 120GB, a full dports including
138the git repo requires at least 1.5GB, and a full set of built packages
139requires at least 75GB.
140If using a filesystem such as HAMMER or HAMMER2
141which frees space overnight, double all of those numbers.
142.Pp
143The actual build infrastructure uses tmpfs... memory and swap, and does
144not use regular filesystem space.
145.Sh OPTIONS
146.Bl -tag -width indent
147.It Fl d[d...]
148Run in debug mode.
149If specified two or more times this will turn off
150ncurses and output the primary log (00_last_results.log) to the standard
151output, along with additional spew.
152.It Fl h
153Quickly output a synopsis of options and directives and exit.
154.It Fl m Ar gb
155Override the default package dependency memory target, in gigabytes.
156The default is 1/2 physical memory.
157The number of workers will be limited
158such that the aggregate size of package dependencies installed in each
159worker slot does not exceed this value.
160.Pp
161This handles a well-known effect where the sheer amount of data that has
162to be installed in tmpfs filesystems for large ports, when multiplied by
163the number of worker slots, can force excessive paging to occur and leave
164preciously little memory available to actually run compiles.
165Some paging
166is necessary to maintain maximum CPU utilization, but excessive paging
167can cause the whole machine to essentially become idle for extended
168periods of time.
169.It Fl v
170Quickly output the version and exit.
171.It Fl y
172Automatically answer 'y'es to any questions.
173.It Fl s Ar n
174.Nm
175usually slow-starts the worker slots, beginning with one slot and increasing
176by one every 5 seconds until the maximum configured number of workers is
177reached.
178This gives
179.Nm
180a slower ramp that it can load manage against.
181Specifying 0 disables the slow-start feature and the maximum number of
182worker slots (limited by the dependency graph) will be loaded immediately.
183.It Fl D
184Turn on DEVELOPER mode when building ports.
185.It Fl S[S]
186Turn off curses for script friendliness.
187The output will be log 00 and
188should be redirected to /dev/null or something similar.
189If you supply the options twice, color output escapes will also be
190turned off.
191You may also wish to use the
192.Fl y
193option for scripting dsynth.
194.El
195.Sh DIRECTIVES
196Generally
197.Nm
198is run with a directive and some directives allow a list of ports to be
199specified.
200This list should be space-delimited in DIR/SUBDIR format, for example:
201.Ar www/chromium .
202For directives with an optional ports list, your current installed set
203of ports will be used if you do not specify a list.
204.Bl -tag -width indent
205.It Cm status
206This will do a dry-run of
207.Cm upgrade-system
208but not actually build anything.
209.It Cm cleanup
210This will clean up any left-over mounts from prior builds.
211.Nm
212attempts to clean up all processes and mounts when you interrupt
213a build but doesn't always succeed.
214.It Cm init
215Creates and initializes the
216.Pa /etc/dsynth
217directory if it does not exst.
218This directive will complain and exit if either
219.Pa /etc/dsynth
220or
221.Pa /usr/local/etc/dsynth
222exists.
223It will not create
224.Pa /etc/dsynth
225in this situation.
226.It Cm configure
227NOT CURRENTLY IMPLEMENTED
228.It Cm upgrade-system
229NOT CURRENTLY IMPLEMENTED.
230Incrementally build and upgrade your locally
231installed packages, then upgrade your local system with them.
232.It Cm prepare-system
233Incrementally build and upgrade your locally installed packages, but
234do not upgrade your system with them.
235.It Cm rebuild-repository
236Build or rebuild the database files for the configured repository.
237.It Cm purge-distfiles
238Delete any obsolete source distribution files.
239.It Cm status-everything
240This will do a dry-run of a full bulk build of everything,
241but not actually build anything.
242.It Cm everything
243This will build the entire dports tree and then rebuild the repository
244when it finishes.
245.It Cm version
246This is for synth compatibility.
247The version of
248.Nm
249will be printed and the program will exit.
250.It Cm help
251Output a synopsis of options and directives and exit.
252.It Cm status Op Ar ports
253Do a dry-run with 'build' of the given list.
254.It Cm build Op Ar ports
255Incrementally build dports based on the given list.
256When done, ask whether the repository should be rebuilt or not.
257.It Cm just-build Op Ar ports
258Incrementally build dports based on the given list, then
259exits.
260No post-build steps will be taken.
261.It Cm install Op Ar ports
262NOT CURRENTLY IMPLEMENTED.  'build' based on the supplied
263list (or using currently installed packages), then rebuild
264the repository and upgrade the system without asking any further
265questions.
266.It Cm force Op Ar ports
267This is the same as 'build' but will delete existing packages first.
268Dependencies are not deleted unless they are out of date.
269.It Cm test Op Ar ports
270This is the same as 'build' but sets the environment variable
271.Ev DEVELOPER
272to
273.Sq yes
274and pre-deletes specified packages.
275Dependencies are not deleted unless they are out of date.
276.El
277.Sh FILES
278.Bl -tag -width ".It Pa <fs>/abc/defghi/<name>" -compact
279.It Pa /etc/dsynth/synth.ini
280The primary configuration file.
281If not found,
282.Nm
283will also look in
284.Pa /usr/local/etc/dsynth/synth.ini .
285.Pp
286.It Pa /etc/dsynth/LiveSystem-make.conf
287Typically contains the environment variables that will be set in
288the workers.
289.Nm
290firewalls the environment it is run under from the environment it
291provides to the workers.
292.Pp
293.It Pa /build/synth/build
294Recommended setting for
295.Va Directory_buildbase ,
296contains the build infrastructure... typically a template, mirrored
297system directories, and mount points for all the worker slots.
298The template will be [re]generated if 'pkg' needs to be built or
299if the
300.Pa .template.good
301file in this directory is deleted.
302.Pp
303.It Pa /build/synth/distfiles
304Recommended setting for
305.Va Directory_distfiles ,
306ports to a directory into which
307.Nm
308will download any source distribution files required for building.
309.Pp
310.It Pa /build/synth/dports
311Recommended setting for
312.Va Directory_portsdir ,
313points to a checked out dports repo.
314Note that
315.Nm
316does not automatically 'git pull' or otherwise synchronize the dports repo,
317you must do that yourself prior to starting a build.
318.Pp
319.It Pa /build/synth/live_packages
320Recommended setting for
321.Va Directory_packages ,
322points to a directory which will contain the completed application
323packages.
324.Pp
325.It Pa /build/synth/logs
326Recommended setting for
327.Va Directory_logs ,
328all log files will be placed in this directory.
329Special management logfiles begin with the numeral '0' for easily
330location.
331The logfiles for ports while and after building are stored in the
332form subdir____portname.log, with three underscores.
333.Pp
334.It Pa /build/synth/options
335Recommended setting for
336.Va Directory_options ,
337where options overrides for specific ports may be located.
338.Pp
339.It Pa /
340Recommended setting for
341.Va Directory_system ,
342which
343.Nm
344uses as a basis for creating the jails or chroots in each worker slot
345during building.
346No part of the system root is ever NULL-mounted read-write... it is always
347NULL-mounted read-only.
348Some elements from the system base will be mirrored in the build-base
349as an optimization.
350.Pp
351Note that the packages directory and the distfiles directory is mounted
352read-write in jails or chroots.
353All other r/w filesystems in the workers are
354.Xr tmpfs 5
355based filesystems and will be created and torn-down for each port.
356.Pp
357.It Pa .txz
358.It Pa .tgz
359.It Pa .tar
360.It Pa .tbz
361The recommended setting for
362.Va Package_suffix
363is either
364.Pa .txz
365or
366.Pa .tgz .
367Use
368.Pa .txz
369for better compression at the cost of somewhat slower bulk builds due
370to the time overhead for compression and decompression, or
371use
372.Pa .tgz
373for modest compression and very fast compression and decompression.
374Due to the way the builder works, package dependencies are fresly
375installed into the chroot slot for each package being built, so
376decompression time matters.
377.El
378.Sh EXIT STATUS
379.Ex -std
380.Sh SEE ALSO
381.Xr synth 1 ,
382.Xr dports 7
383.Sh HISTORY
384The
385.Nm
386utility first appeared in
387.Dx 5.7 .
388.Sh AUTHORS
389.An Matthew Dillon Aq Mt dillon@backplane.com
390