1 .\" $NetBSD: pkg_comp.8,v 1.36 2012/02/27 22:42:27 jmmv Exp $
3 .\" pkg_comp - Build packages inside a clean chroot environment
4 .\" Copyright (c) 2002, 2003, 2004, 2005 Julio M. Merino Vidal <jmmv@NetBSD.org>
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Neither the name of The NetBSD Foundation nor the names of its
12 .\" contributors may be used to endorse or promote products derived
13 .\" from this software without specific prior written permission.
14 .\" 3. Neither the name of author nor the names of its contributors may
15 .\" be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
35 .Nd build packages inside a sandbox
51 is a tool that makes easy the compilation of packages inside a clean
53 This allows an easy tracking of exact dependencies
54 and the correct behavior of a package in a fresh system installation.
58 is controlled through a small configuration file and a target (keep
59 reading to learn more).
60 The configuration file tells
62 how to configure the new chroot environment, and the target specifies
65 The following options are recognized:
66 .Bl -tag -width XcXconf_file
70 as configuration file (full path expected).
74 as configuration file (only base name expected).
80 avoid installation of default packages as well as
84 during the creation of the chroot.
90 during the creation of the chroot.
92 .Ss What to use it for?
95 to achieve many goals when building packages.
99 Build packages for other system versions.
100 For example, build packages for
102 while you are running
105 Build packages using different
107 options than your current system, like changing the threading library,
109 placement of configuration files, etc.
111 Debug the build process of a package, checking if buildlinks work
114 Avoid autoconf's side effects by keeping a separate chroot for each
115 project, like one for GNOME2 and another one for KDE3.
117 Schedule builds of package sets for several different machines.
119 .Sh CONTROL DIRECTORY
121 needs to store several pieces of information when it is running.
122 Instead of using normal system trees, it uses a special directory inside the
123 chroot to avoid polluting the system.
124 It stores there scripts, object files, built packages, etc.
126 .Pa $DESTDIR/pkg_comp ;
129 is automatically created to ease pathnames when working inside the chroot.
133 you can maintain several configuration files so you can work with
134 different chroot jails easily.
135 To make this easy, configuration files are stored inside
137 followed by the configuration file name and the .conf suffix.
138 The default configuration file is
139 .Pa $HOME/pkg_comp/default.conf ,
140 and is always used if you do not specify another one.
141 The configuration file name is specified by the argument of the
144 Alternatively you can specify any pathname as a configuration file
145 with the argument of the
149 Configuration files are simple shell scripts that define
151 The default values shown here are those written in the template when
152 issuing a maketemplate.
153 .Bl -tag -width indent
155 A list of packages to automatically build during the
158 A package is in the form
166 The pkgsrc target to use when building packages in an automated fashion
174 as other values are useless.
178 A list of packages to automatically build after the
181 A package is in the form
189 The pkgsrc target to use when building packages.
190 It can contain any target supported by the pkgsrc system, but
191 reasonable values are:
201 all configuration files (not directories) that reside inside
208 The chroot jail directory.
210 .Pa /var/chroot/pkg_comp/default .
212 This is the directory which holds
214 binary sets and X sets.
215 Its structure is the same as official release
216 distributions, that is, tgz files must reside inside
217 .Pa $DISTRIBDIR/binary/sets .
219 .Pa /var/pub/NetBSD .
221 Specifies a whitespace-separated list of files that must be appended to
222 .Pa $DESTDIR/etc/mk.conf .
223 This is useful to add special items to this configuration file.
226 A list of packages to automatically install after the
228 and before installing
230 These are also installed within the sandbox created by the
232 target, but before anything is built.
233 Each name must be the full package name, including the tgz suffix.
234 Packages are searched inside
235 .Pa $REAL_PACKAGES/All .
237 .It GENERATE_PKG_SUMMARY
241 .Pa $REAL_PACKAGES/pkg_summary.gz
242 file at the end of every package build by both the
248 Where binary packages get installed.
252 A list of variable names that will be appended to the generated
254 file, together with their values set in the configuration file.
255 Its default value contains all variables listed here.
257 Specifies which version number of
259 is installed inside the chroot.
262 no special action is taken (this is useful if the system version inside
263 the chroot matches the outside one).
264 Otherwise, the package
266 will be installed inside the chroot, in a special purpose
267 prefix whose value can be set in
268 .Pa $DESTDIR/etc/mk.conf
269 via the configuration file
271 .Va LIBKVER_STANDALONE_PREFIX
273 The libkver library will be configured inside the chroot, with the symbolic link
274 .Pa $DESTDIR/libkver_osrelease
277 in default shells environments,
282 overrides the host system version.
285 for more information.
289 Location of the packages database.
293 Base directory of configuration files.
297 List of values specifying the chain of compilers to invoke when building
305 to this variable's value.
309 file will be installed (inside the chroot).
313 Directory where the system-wide
315 file resides (outside the chroot).
317 .Pa /usr/pkgsrc/distfiles .
319 The shell of the root user.
323 A list of binary sets to be extracted inside
326 .Ql base.tgz comp.tgz etc.tgz kern-GENERIC.tgz text.tgz .
327 If no kernel is extracted by these sets, an empty
329 file is created inside the chroot.
331 A list of binary sets of the X Window system.
332 This has the same behavior
335 If this variable is set to
337 no X Window is configured inside the chroot
338 jail and no other X variables take effect.
340 .Ql xbase.tgz xcomp.tgz xetc.tgz xfont.tgz xserver.tgz .
346 three times after all file systems have been unmounted.
349 .It USE_AUDIT_PACKAGES
357 This means that it will install the system-wide
359 file inside the chroot when needed, keeping both in sync.
365 the GNU C Compiler version 3 will be installed inside the chroot
366 environment and used to build all packages, using the
374 you want xpkgwedge to be compiled and installed automatically inside the
376 This takes care of setting up
380 for xpkgwedge to work.
381 Has no effect if X is unconfigured.
385 .Ss Mounted file systems
386 In order to avoid duplicating huge system trees,
388 takes advantage of file system layers.
391 which duplicates a file system tree into another directory; although
395 .Xr mount_overlay 8 .
397 content of these variables is empty, that file system is not mounted.
399 You can control which layer to use and which options you want with
400 special configuration options, as explained below.
402 These file systems are mounted before entering the chroot and unmounted
404 In order to know if file systems are mounted or not, the
405 program uses a temporary file, called
406 .Pa $DESTDIR/pkg_comp/tmp/mount.stat ,
407 which controls the number of
409 processes using the chroot environment.
410 If some of them crashes unexpectedly and you notice it does not try
411 to unmount the file systems, this status file may get out of sync.
412 Be sure to check that NO file systems are mounted when issuing a
414 .Bl -tag -width indent
416 Specifies where a global ccache directory resides in the real system.
417 Defaults to nothing, which disables the global cache.
418 Keep in mind that this is specially useful to keep the cache across
419 rebuilds of the sandbox, but be very careful if you plan to share a
420 cache directory between different sandboxes, as this can lead to problems.
422 Specifies where distfiles reside in the real system.
424 .Pa /usr/pkgsrc/distfiles .
425 .It REAL_DISTFILES_OPTS
430 Specifies where to build binary packages.
431 This variable is specially useful.
433 .Pa /usr/pkgsrc/packages .
434 .It REAL_PACKAGES_OPTS
440 This can be useful if you want to use several pkgsrc trees independently.
449 Usually useless, but may be needed by some packages, like sysutils/aperture.
457 A whitespace separated list of functions or external scripts to be executed
458 after the sandbox is created.
459 Two arguments are given to each of them:
465 A whitespace separated list of functions or external scripts to be executed
466 after file systems are mounted.
467 Two arguments are given to each of them:
473 A whitespace separated list of functions or external scripts to be executed
474 before file systems are unmounted.
475 Two arguments are given to each of them:
482 A target specifies what
484 should do (as in make).
485 The following list describes all supported targets,
486 in the logical order you should call them.
487 .Bl -tag -width indent
491 You should edit it after the creation as you will probably want to change
492 the default configuration, specially paths.
494 Create the chroot environment, based on the specs of the configuration file.
495 This step is required before trying any other, except maketemplate.
497 Builds the specified packages inside the chroot.
498 You can pass the package names as a relative path within pkgsrc or as the
499 basename of the package directory (i.e. omitting the directory name).
501 Install the specified binary packages into the chroot.
502 Package names can contain globs.
503 The package files will be taken from within
506 Enters the chroot environment.
507 If no arguments are given,
509 is executed, otherwise whatever you typed.
510 If the first argument begins with a word prefixed by
514 argument can be omitted (it is implied).
516 Remove the entire chroot tree.
517 You should do it with this target because it
518 will take care to umount needed mount points.
520 This executes several targets automatically, using
525 The order is: makeroot, build and removeroot.
526 This is useful to create binary packages of several pkgsrc and their
527 dependencies automatically.
528 For this to be useful, you need to set
532 or pass package names through the command line.
536 is passed as the unique argument to this target,
538 will attempt to resume a previous automatic build for the given configuration.
541 This program uses nullfs to create virtual copies of real trees inside the
544 You need to install the
545 .Pa security/audit-packages
546 package in the host system (and have an up to date vulnerabilities database)
547 if you want security checks to work inside the
556 .An Julio M. Merino Vidal Aq jmmv@NetBSD.org