Annotation of pkgsrc/doc/pkgsrc.html, revision 1.76
1.75 rillig 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2: <html>
1.1 grant 3: <head>
1.75 rillig 4: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
5: <title>The pkgsrc guide</title>
6: <link rel="stylesheet" href="/NetBSD.css" type="text/css">
7: <meta name="generator" content="DocBook XSL Stylesheets VX.X.X">
8: <meta name="description" content="pkgsrc is a centralized package management system for
9: Unix-like operating systems. This guide provides information for
10: users and developers of pkgsrc. It covers installation of binary
11: and source packages, creation of binary and source packages and
12: a high-level overview about the infrastructure.">
13: </head>
14: <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" lang="en">
15: <div class="titlepage">
16: <div>
17: <div><h1 class="title">
18: <a name="the-pkgsrc-guide"></a>The pkgsrc guide</h1></div>
19: <div><h2 class="subtitle">Documentation on the NetBSD packages system</h2></div>
20: <div><div class="authorgroup">
21: <div class="author">
22: <h3 class="author">
23: <span class="firstname">Alistair</span> <span class="surname">Crooks</span>
24: </h3>
25: <div class="affiliation"><div class="address"><p><code class="email"><<a href="mailto:agc@NetBSD.org">agc@NetBSD.org</a>></code></p></div></div>
26: </div>
27: <div class="author">
28: <h3 class="author">
29: <span class="firstname">Hubert</span> <span class="surname">Feyrer</span>
30: </h3>
31: <div class="affiliation"><div class="address"><p><code class="email"><<a href="mailto:hubertf@NetBSD.org">hubertf@NetBSD.org</a>></code></p></div></div>
32: </div>
33: <h3 class="corpauthor">
34: The pkgsrc Developers
35: </h3>
36: </div></div>
37: <div><p class="copyright">Copyright © 1994-2006 The NetBSD Foundation, Inc</p></div>
1.76 ! rillig 38: <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.18 2006/05/19 22:05:09 rillig Exp $</p></div>
! 39: <div><div class="abstract">
1.75 rillig 40: <p class="title"><b>Abstract</b></p>
41: <p>pkgsrc is a centralized package management system for
42: Unix-like operating systems. This guide provides information for
43: users and developers of pkgsrc. It covers installation of binary
44: and source packages, creation of binary and source packages and
45: a high-level overview about the infrastructure.</p>
46: </div></div>
47: </div>
48: <hr>
49: </div>
50: <div class="toc">
51: <p><b>Table of Contents</b></p>
52: <dl>
53: <dt><span class="chapter"><a href="#introduction">1. What is pkgsrc?</a></span></dt>
54: <dd><dl>
55: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
56: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
57: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
58: <dd><dl><dt><span class="sect2"><a href="#term.people">1.3.1. People involved in pkgsrc</a></span></dt></dl></dd>
59: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
60: </dl></dd>
61: <dt><span class="part"><a href="#users-guide">I. The pkgsrc user's guide</a></span></dt>
62: <dd><dl>
63: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
64: <dd><dl>
65: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
66: <dd><dl>
67: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
68: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
69: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
70: </dl></dd>
71: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
72: <dd><dl>
73: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
74: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
75: </dl></dd>
76: </dl></dd>
77: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
78: <dd><dl>
79: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
80: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
81: <dd><dl>
82: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
83: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
84: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
85: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
86: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
87: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
88: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
89: </dl></dd>
90: </dl></dd>
91: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
92: <dd><dl>
93: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
94: <dd><dl>
95: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
96: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
97: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
98: </dl></dd>
99: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
100: <dd><dl>
101: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
102: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
103: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
104: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
105: </dl></dd>
106: </dl></dd>
107: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
108: <dd><dl>
109: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
110: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
111: <dt><span class="sect1"><a href="#developer-advanced-settings">5.3. Developer/advanced settings</a></span></dt>
112: <dt><span class="sect1"><a href="#selecting-build-options">5.4. Selecting Build Options</a></span></dt>
113: </dl></dd>
114: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
115: <dd><dl>
116: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
117: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
118: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
119: <dd><dl>
120: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
121: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
122: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
123: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
124: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
125: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
126: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
127: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
128: </dl></dd>
129: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
130: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
131: </dl></dd>
132: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
133: <dd><dl>
134: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
135: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
136: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
137: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
138: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
139: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
140: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
141: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
142: <dt><span class="sect1"><a href="#passive-ftp">7.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
143: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
144: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
145: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
146: <dt><span class="sect1"><a href="#bsd.own.mk-missing">7.12. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</a></span></dt>
147: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
148: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
149: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
150: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
151: </dl></dd>
152: </dl></dd>
153: <dt><span class="part"><a href="#developers-guide">II. The pkgsrc developer's guide</a></span></dt>
154: <dd><dl>
155: <dt><span class="chapter"><a href="#components">8. Package components - files, directories and contents</a></span></dt>
156: <dd><dl>
1.76 ! rillig 157: <dt><span class="sect1"><a href="#components.Makefile">8.1. <code class="filename">Makefile</code></a></span></dt>
! 158: <dt><span class="sect1"><a href="#components.distinfo">8.2. <code class="filename">distinfo</code></a></span></dt>
1.75 rillig 159: <dt><span class="sect1"><a href="#components.patches">8.3. patches/*</a></span></dt>
160: <dt><span class="sect1"><a href="#other-mandatory-files">8.4. Other mandatory files</a></span></dt>
161: <dt><span class="sect1"><a href="#components.optional">8.5. Optional files</a></span></dt>
1.76 ! rillig 162: <dt><span class="sect1"><a href="#work-dir">8.6. <code class="filename">work*</code></a></span></dt>
! 163: <dt><span class="sect1"><a href="#files-dir">8.7. <code class="filename">files/*</code></a></span></dt>
1.75 rillig 164: </dl></dd>
1.76 ! rillig 165: <dt><span class="chapter"><a href="#makefile">9. Programming in <code class="filename">Makefile</code>s</a></span></dt>
1.75 rillig 166: <dd><dl>
1.76 ! rillig 167: <dt><span class="sect1"><a href="#makefile.variables">9.1. <code class="filename">Makefile</code> variables</a></span></dt>
1.75 rillig 168: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">9.1.1. Naming conventions</a></span></dt></dl></dd>
169: <dt><span class="sect1"><a href="#makefile.code">9.2. Code snippets</a></span></dt>
170: <dd><dl>
171: <dt><span class="sect2"><a href="#adding-to-list">9.2.1. Adding things to a list</a></span></dt>
172: <dt><span class="sect2"><a href="#converting-internal-to-external">9.2.2. Converting an internal list into an external list</a></span></dt>
173: <dt><span class="sect2"><a href="#passing-variable-to-shell">9.2.3. Passing variables to a shell command</a></span></dt>
174: <dt><span class="sect2"><a href="#quoting-guideline">9.2.4. Quoting guideline</a></span></dt>
175: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">9.2.5. Workaround for a bug in BSD Make</a></span></dt>
176: </dl></dd>
177: </dl></dd>
178: <dt><span class="chapter"><a href="#plist">10. PLIST issues</a></span></dt>
179: <dd><dl>
180: <dt><span class="sect1"><a href="#rcs-id">10.1. RCS ID</a></span></dt>
1.76 ! rillig 181: <dt><span class="sect1"><a href="#automatic-plist-generation">10.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
1.75 rillig 182: <dt><span class="sect1"><a href="#print-PLIST">10.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
183: <dt><span class="sect1"><a href="#plist.misc">10.4. Variable substitution in PLIST</a></span></dt>
184: <dt><span class="sect1"><a href="#manpage-compression">10.5. Man page compression</a></span></dt>
185: <dt><span class="sect1"><a href="#using-PLIST_SRC">10.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
186: <dt><span class="sect1"><a href="#platform-specific-plist">10.7. Platform-specific and differing PLISTs</a></span></dt>
187: <dt><span class="sect1"><a href="#faq.common-dirs">10.8. Sharing directories between packages</a></span></dt>
188: </dl></dd>
189: <dt><span class="chapter"><a href="#buildlink">11. Buildlink methodology</a></span></dt>
190: <dd><dl>
191: <dt><span class="sect1"><a href="#converting-to-buildlink3">11.1. Converting packages to use buildlink3</a></span></dt>
1.76 ! rillig 192: <dt><span class="sect1"><a href="#creating-buildlink3.mk">11.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
1.75 rillig 193: <dd><dl>
194: <dt><span class="sect2"><a href="#anatomy-of-bl3">11.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
1.76 ! rillig 195: <dt><span class="sect2"><a href="#updating-buildlink-depends">11.2.2. Updating <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code> in <code class="filename">buildlink3.mk</code> files</a></span></dt>
1.75 rillig 196: </dl></dd>
1.76 ! rillig 197: <dt><span class="sect1"><a href="#writing-builtin.mk">11.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
1.75 rillig 198: <dd><dl>
1.76 ! rillig 199: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">11.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
1.75 rillig 200: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">11.3.2. Global preferences for native or pkgsrc software</a></span></dt>
201: </dl></dd>
202: </dl></dd>
203: <dt><span class="chapter"><a href="#pkginstall">12. The pkginstall framework</a></span></dt>
204: <dd><dl>
205: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">12.1. Files and directories outside the installation prefix</a></span></dt>
206: <dd><dl>
207: <dt><span class="sect2"><a href="#dirs-outside-prefix">12.1.1. Directory manipulation</a></span></dt>
208: <dt><span class="sect2"><a href="#files-outside-prefix">12.1.2. File manipulation</a></span></dt>
209: </dl></dd>
210: <dt><span class="sect1"><a href="#conf-files">12.2. Configuration files</a></span></dt>
211: <dd><dl>
212: <dt><span class="sect2"><a href="#conf-files-sysconfdir">12.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
213: <dt><span class="sect2"><a href="#conf-files-configure">12.2.2. Telling the software where configuration files are</a></span></dt>
214: <dt><span class="sect2"><a href="#conf-files-patching">12.2.3. Patching installations</a></span></dt>
215: <dt><span class="sect2"><a href="#conf-files-disable">12.2.4. Disabling handling of configuration files</a></span></dt>
216: </dl></dd>
217: <dt><span class="sect1"><a href="#rcd-scripts">12.3. System startup scripts</a></span></dt>
218: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">12.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
219: <dt><span class="sect1"><a href="#users-and-groups">12.4. System users and groups</a></span></dt>
220: <dt><span class="sect1"><a href="#shells">12.5. System shells</a></span></dt>
221: <dd><dl><dt><span class="sect2"><a href="#shells-disable">12.5.1. Disabling shell registration</a></span></dt></dl></dd>
222: <dt><span class="sect1"><a href="#fonts">12.6. Fonts</a></span></dt>
223: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">12.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
224: </dl></dd>
225: <dt><span class="chapter"><a href="#options">13. Options handling</a></span></dt>
226: <dd><dl>
227: <dt><span class="sect1"><a href="#global-default-options">13.1. Global default options</a></span></dt>
1.76 ! rillig 228: <dt><span class="sect1"><a href="#converting-to-options">13.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
1.75 rillig 229: <dt><span class="sect1"><a href="#option-names">13.3. Option Names</a></span></dt>
230: </dl></dd>
231: <dt><span class="chapter"><a href="#build">14. The build process</a></span></dt>
232: <dd><dl>
233: <dt><span class="sect1"><a href="#build.intro">14.1. Introduction</a></span></dt>
234: <dt><span class="sect1"><a href="#build.prefix">14.2. Program location</a></span></dt>
235: <dt><span class="sect1"><a href="#build.builddirs">14.3. Directories used during the build process</a></span></dt>
236: <dt><span class="sect1"><a href="#build.running">14.4. Running a phase</a></span></dt>
237: <dt><span class="sect1"><a href="#build.fetch">14.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
238: <dt><span class="sect1"><a href="#build.checksum">14.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
239: <dt><span class="sect1"><a href="#build.extract">14.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
240: <dt><span class="sect1"><a href="#build.patch">14.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
241: <dt><span class="sect1"><a href="#build.tools">14.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
242: <dt><span class="sect1"><a href="#build.wrapper">14.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
243: <dt><span class="sect1"><a href="#build.configure">14.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
244: <dt><span class="sect1"><a href="#build.build">14.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
245: <dt><span class="sect1"><a href="#build.test">14.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
246: <dt><span class="sect1"><a href="#build.install">14.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
247: <dt><span class="sect1"><a href="#build.package">14.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
248: <dt><span class="sect1"><a href="#build.helpful-targets">14.16. Other helpful targets</a></span></dt>
249: </dl></dd>
250: <dt><span class="chapter"><a href="#tools">15. Tools needed for building or running</a></span></dt>
251: <dd><dl>
252: <dt><span class="sect1"><a href="#pkgsrc-tools">15.1. Tools for pkgsrc builds</a></span></dt>
253: <dt><span class="sect1"><a href="#package-tools">15.2. Tools needed by packages</a></span></dt>
254: <dt><span class="sect1"><a href="#platform-tools">15.3. Tools provided by platforms</a></span></dt>
255: </dl></dd>
256: <dt><span class="chapter"><a href="#fixes">16. Making your package work</a></span></dt>
257: <dd><dl>
258: <dt><span class="sect1"><a href="#general-operation">16.1. General operation</a></span></dt>
259: <dd><dl>
260: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">16.1.1. How to pull in variables from /etc/mk.conf</a></span></dt>
261: <dt><span class="sect2"><a href="#where-to-install-documentation">16.1.2. Where to install documentation</a></span></dt>
262: <dt><span class="sect2"><a href="#restricted-packages">16.1.3. Restricted packages</a></span></dt>
263: <dt><span class="sect2"><a href="#dependencies">16.1.4. Handling dependencies</a></span></dt>
264: <dt><span class="sect2"><a href="#conflicts">16.1.5. Handling conflicts with other packages</a></span></dt>
265: <dt><span class="sect2"><a href="#not-building-packages">16.1.6. Packages that cannot or should not be built</a></span></dt>
266: <dt><span class="sect2"><a href="#undeletable-packages">16.1.7. Packages which should not be deleted, once installed</a></span></dt>
267: <dt><span class="sect2"><a href="#security-handling">16.1.8. Handling packages with security problems</a></span></dt>
268: <dt><span class="sect2"><a href="#compiler-bugs">16.1.9. How to handle compiler bugs</a></span></dt>
269: <dt><span class="sect2"><a href="#bumping-pkgrevision">16.1.10. How to handle incrementing versions when fixing an existing package</a></span></dt>
270: <dt><span class="sect2"><a href="#portability-of-packages">16.1.11. Portability of packages</a></span></dt>
271: </dl></dd>
272: <dt><span class="sect1"><a href="#downloading-issues">16.2. Possible downloading issues</a></span></dt>
273: <dd><dl>
274: <dt><span class="sect2"><a href="#no-plain-download">16.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
275: <dt><span class="sect2"><a href="#modified-distfiles-same-name">16.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
276: </dl></dd>
277: <dt><span class="sect1"><a href="#configuration-gotchas">16.3. Configuration gotchas</a></span></dt>
278: <dd><dl>
279: <dt><span class="sect2"><a href="#fixes.libtool">16.3.1. Shared libraries - libtool</a></span></dt>
280: <dt><span class="sect2"><a href="#using-libtool">16.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
281: <dt><span class="sect2"><a href="#autoconf-automake">16.3.3. GNU Autoconf/Automake</a></span></dt>
282: </dl></dd>
283: <dt><span class="sect1"><a href="#fixes-build">16.4. Building the package</a></span></dt>
284: <dd><dl>
285: <dt><span class="sect2"><a href="#cpp-defines">16.4.1. CPP defines</a></span></dt>
286: <dt><span class="sect2"><a href="#cpp-list-examples">16.4.2. Examples of CPP defines for some platforms</a></span></dt>
287: <dt><span class="sect2"><a href="#cpp-list">16.4.3. Getting a list of CPP defines</a></span></dt>
288: </dl></dd>
289: <dt><span class="sect1"><a href="#package-specific-actions">16.5. Package specific actions</a></span></dt>
290: <dd><dl>
291: <dt><span class="sect2"><a href="#user-interaction">16.5.1. User interaction</a></span></dt>
292: <dt><span class="sect2"><a href="#handling-licenses">16.5.2. Handling licenses</a></span></dt>
293: <dt><span class="sect2"><a href="#installing-score-files">16.5.3. Installing score files</a></span></dt>
294: <dt><span class="sect2"><a href="#perl-scripts">16.5.4. Packages containing perl scripts</a></span></dt>
295: <dt><span class="sect2"><a href="#hardcoded-paths">16.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
296: <dt><span class="sect2"><a href="#perl-modules">16.5.6. Packages installing perl modules</a></span></dt>
297: <dt><span class="sect2"><a href="#faq.info-files">16.5.7. Packages installing info files</a></span></dt>
298: <dt><span class="sect2"><a href="#manpages">16.5.8. Packages installing man pages</a></span></dt>
299: <dt><span class="sect2"><a href="#gconf2-data-files">16.5.9. Packages installing GConf2 data files</a></span></dt>
300: <dt><span class="sect2"><a href="#scrollkeeper-data-files">16.5.10. Packages installing scrollkeeper data files</a></span></dt>
301: <dt><span class="sect2"><a href="#x11-fonts">16.5.11. Packages installing X11 fonts</a></span></dt>
302: <dt><span class="sect2"><a href="#gtk2-modules">16.5.12. Packages installing GTK2 modules</a></span></dt>
303: <dt><span class="sect2"><a href="#sgml-xml-data">16.5.13. Packages installing SGML or XML data</a></span></dt>
304: <dt><span class="sect2"><a href="#mime-database">16.5.14. Packages installing extensions to the MIME database</a></span></dt>
305: <dt><span class="sect2"><a href="#intltool">16.5.15. Packages using intltool</a></span></dt>
306: <dt><span class="sect2"><a href="#startup-scripts">16.5.16. Packages installing startup scripts</a></span></dt>
307: <dt><span class="sect2"><a href="#tex-packages">16.5.17. Packages installing TeX modules</a></span></dt>
308: </dl></dd>
309: <dt><span class="sect1"><a href="#feedback-to-author">16.6. Feedback to the author</a></span></dt>
310: </dl></dd>
311: <dt><span class="chapter"><a href="#debug">17. Debugging</a></span></dt>
312: <dt><span class="chapter"><a href="#submit">18. Submitting and Committing</a></span></dt>
313: <dd><dl>
314: <dt><span class="sect1"><a href="#submitting-binary-packages">18.1. Submitting binary packages</a></span></dt>
315: <dt><span class="sect1"><a href="#submitting-your-package">18.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
316: <dt><span class="sect1"><a href="#general-notes-for-changes">18.3. General notes when adding, updating, or removing packages</a></span></dt>
317: <dt><span class="sect1"><a href="#committing-importing">18.4. Committing: Importing a package into CVS</a></span></dt>
318: <dt><span class="sect1"><a href="#updating-package">18.5. Updating a package to a newer version</a></span></dt>
319: <dt><span class="sect1"><a href="#moving-package">18.6. Moving a package in pkgsrc</a></span></dt>
320: </dl></dd>
321: <dt><span class="chapter"><a href="#devfaq">19. Frequently Asked Questions</a></span></dt>
322: </dl></dd>
323: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
324: <dd><dl>
325: <dt><span class="chapter"><a href="#infr.design">20. Design of the pkgsrc infrastructure</a></span></dt>
326: <dd><dl>
327: <dt><span class="sect1"><a href="#infr.var">20.1. Variable evaluation</a></span></dt>
328: <dd><dl>
329: <dt><span class="sect2"><a href="#infr.var.load">20.1.1. At load time</a></span></dt>
330: <dt><span class="sect2"><a href="#infr.var.run">20.1.2. At runtime</a></span></dt>
331: </dl></dd>
332: <dt><span class="sect1"><a href="#infr.design.intf">20.2. Designing interfaces for Makefile fragments</a></span></dt>
333: <dd><dl>
334: <dt><span class="sect2"><a href="#infr.design.intf.proc">20.2.1. Procedures with parameters</a></span></dt>
335: <dt><span class="sect2"><a href="#infr.design.intf.action">20.2.2. Actions taken on behalf of parameters</a></span></dt>
336: </dl></dd>
337: </dl></dd>
338: <dt><span class="chapter"><a href="#regression">21. Regression tests</a></span></dt>
339: <dd><dl>
340: <dt><span class="sect1"><a href="#regression.descr">21.1. The regression tests framework</a></span></dt>
341: <dt><span class="sect1"><a href="#regression.run">21.2. Running the regression tests</a></span></dt>
342: <dt><span class="sect1"><a href="#regression.new">21.3. Adding a new regression test</a></span></dt>
343: <dd><dl>
344: <dt><span class="sect2"><a href="#regression.fun.override">21.3.1. Overridable functions</a></span></dt>
345: <dt><span class="sect2"><a href="#regression.fun.helper">21.3.2. Helper functions</a></span></dt>
346: </dl></dd>
347: </dl></dd>
348: <dt><span class="chapter"><a href="#porting">22. Porting pkgsrc</a></span></dt>
349: <dd><dl>
350: <dt><span class="sect1"><a href="#porting.opsys">22.1. Porting pkgsrc to a new operating system</a></span></dt>
351: <dt><span class="sect1"><a href="#porting.compiler">22.2. Adding support for a new compiler</a></span></dt>
352: </dl></dd>
353: </dl></dd>
354: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
355: <dd><dl>
356: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
357: <dd><dl>
358: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
359: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
360: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
361: <dt><span class="sect2"><a href="#checking-package-with-pkglint">A.1.4. Checking a package with <span><strong class="command">pkglint</strong></span></a></span></dt>
362: </dl></dd>
363: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
364: </dl></dd>
365: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
366: <dd><dl>
367: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
368: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
369: </dl></dd>
1.76 ! rillig 370: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
! 371: <dd><dl>
! 372: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
! 373: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
! 374: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
! 375: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
! 376: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
! 377: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
! 378: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
! 379: source packages</a></span></dt>
! 380: </dl></dd>
1.75 rillig 381: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
382: <dd><dl>
383: <dt><span class="sect1"><a href="#targets">D.1. Targets</a></span></dt>
384: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
385: </dl></dd>
386: </dl>
387: </div>
388: <div class="chapter" lang="en">
389: <div class="titlepage"><div><div><h2 class="title">
390: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
391: <div class="toc">
392: <p><b>Table of Contents</b></p>
393: <dl>
394: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
395: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
396: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
397: <dd><dl><dt><span class="sect2"><a href="#term.people">1.3.1. People involved in pkgsrc</a></span></dt></dl></dd>
398: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
399: </dl>
400: </div>
401: <div class="sect1" lang="en">
402: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
403: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
404: <p> There is a lot of software freely available for Unix-based
405: systems, which usually runs on NetBSD and other Unix-flavoured
406: systems, too, sometimes with some modifications. The NetBSD
407: Packages Collection (pkgsrc) incorporates any such changes
408: necessary to make that software run, and makes the installation
409: (and de-installation) of the software package easy by means of a
410: single command. </p>
411: <p>Once the software
412: has been built, it is manipulated with the <span><strong class="command">pkg_*</strong></span> tools
413: so that installation
414: and de-installation, printing of an inventory of all installed packages and
415: retrieval of one-line comments or more verbose descriptions are all
416: simple.</p>
417: <p>pkgsrc currently contains several thousand packages,
418: including:</p>
419: <div class="itemizedlist"><ul type="disc">
1.76 ! rillig 420: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/apache/README.html" target="_top"><code class="filename">www/apache</code></a> - The Apache
1.75 rillig 421: web server</p></li>
1.76 ! rillig 422: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/mozilla/README.html" target="_top"><code class="filename">www/mozilla</code></a> - The Mozilla
1.75 rillig 423: web browser</p></li>
1.76 ! rillig 424: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome/README.html" target="_top"><code class="filename">meta-pkgs/gnome</code></a> - The GNOME
1.75 rillig 425: Desktop Environment</p></li>
1.76 ! rillig 426: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/kde3/README.html" target="_top"><code class="filename">meta-pkgs/kde3</code></a> - The K
1.75 rillig 427: Desktop Environment</p></li>
428: </ul></div>
429: <p>...just to name a few.</p>
430: <p>pkgsrc has built-in support for handling varying dependencies,
431: such as pthreads and X11, and extended features such as IPv6 support on
432: a range of platforms.</p>
433: <p>pkgsrc was derived from FreeBSD's ports system, and
434: initially developed for NetBSD only. Since then, pkgsrc has
435: grown a lot, and now supports the following platforms:</p>
436: <div class="itemizedlist"><ul type="disc">
437: <li><p><a href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
438: (<a href="http://www.apple.com/macosx/" target="_top">Mac OS X</a>)</p></li>
439: <li><p><a href="http://www.DragonFlyBSD.org/" target="_top">DragonFly BSD</a></p></li>
440: <li><p><a href="http://www.FreeBSD.org/" target="_top">FreeBSD</a></p></li>
441: <li><p>Microsoft Windows, via <a href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a></p></li>
442: <li><p><a href="http://www.sgi.com/software/irix6.5/" target="_top">IRIX</a></p></li>
443: <li><p><a href="http://www.linux.org/" target="_top">Linux</a></p></li>
444: <li><p><a href="http://www.NetBSD.org/" target="_top">NetBSD</a> (of
445: course)</p></li>
446: <li><p><a href="http://h30097.www3.hp.com/" target="_top">Tru64</a>
447: (Digital UNIX, OSF1)</p></li>
448: <li><p><a href="http://www.openbsd.org/" target="_top">OpenBSD</a></p></li>
449: <li><p><a href="http://www.sun.com/solaris/" target="_top">Solaris</a></p></li>
450: </ul></div>
451: </div>
452: <div class="sect1" lang="en">
453: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
454: <a name="overview"></a>1.2. Overview</h2></div></div></div>
455: <p>This document is divided into three parts. The first,
456: <a href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
457: describes how one can use one of the packages in the Package
458: Collection, either by installing a precompiled binary package,
459: or by building one's own copy using the NetBSD package system.
460: The second part, <a href="#developers-guide" title="Part II. The pkgsrc developer's guide">The pkgsrc developer's guide</a>, explains how to prepare a
461: package so it can be easily built by other NetBSD users without
462: knowing about the package's building details. The third part,
463: <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
464: is intended for those who want to understand how pkgsrc is
465: implemented.</p>
466: <p>This document is available in various formats:
467: <span class="simplelist"><a href="index.html" target="_top">HTML</a>, <a href="pkgsrc.pdf" target="_top">PDF</a>, <a href="pkgsrc.ps" target="_top">PS</a>, <a href="pkgsrc.txt" target="_top">TXT</a></span>.</p>
468: </div>
469: <div class="sect1" lang="en">
470: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
471: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
472: <p>There has been a lot of talk about “<span class="quote">ports</span>”,
473: “<span class="quote">packages</span>”, etc. so far. Here is a description of all the
474: terminology used within this document.</p>
475: <div class="variablelist"><dl>
476: <dt><span class="term">Package</span></dt>
477: <dd><p>A set of files and building instructions
478: that describe what's necessary
479: to build a certain piece of software using
480: pkgsrc. Packages are traditionally stored under
1.76 ! rillig 481: <code class="filename">/usr/pkgsrc</code>.</p></dd>
1.75 rillig 482: <dt><span class="term">The NetBSD package system</span></dt>
483: <dd><p>
484: This is the former name of “<span class="quote">pkgsrc</span>”. It is
485: part of the NetBSD operating system and can be bootstrapped to
486: run on non-NetBSD operating systems as well. It handles
487: building (compiling), installing, and removing of
488: packages.
489: </p></dd>
490: <dt><span class="term">Distfile</span></dt>
491: <dd><p>This term describes the file or files that are
492: provided by the author of the piece of software to
493: distribute his work. All the changes necessary to build on
494: NetBSD are reflected in the corresponding package. Usually
495: the distfile is in the form of a compressed tar-archive,
496: but other types are possible, too. Distfiles are usually
497: stored below
1.76 ! rillig 498: <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
1.75 rillig 499: <dt><span class="term">Port</span></dt>
500: <dd><p>This is the term used by FreeBSD and OpenBSD people
501: for what we call a package.
502: In NetBSD terminology, “<span class="quote">port</span>” refers to a different
503: architecture.</p></dd>
504: <dt><span class="term">Precompiled/binary package</span></dt>
505: <dd>
506: <p>A set of binaries built with pkgsrc from a distfile
1.76 ! rillig 507: and stuffed together in a single <code class="filename">.tgz</code>
1.75 rillig 508: file so it can be installed on machines of the same
509: machine architecture without the need to
510: recompile. Packages are usually generated in
1.76 ! rillig 511: <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.75 rillig 512: an archive on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
513: <p>Sometimes, this is referred to by the term “<span class="quote">package</span>” too,
514: especially in the context of precompiled packages.</p>
515: </dd>
516: <dt><span class="term">Program</span></dt>
517: <dd><p>The piece of software to be installed which will be constructed from
518: all the files in the distfile by the actions defined in the
519: corresponding package.</p></dd>
520: </dl></div>
521: <div class="sect2" lang="en">
522: <div class="titlepage"><div><div><h3 class="title">
523: <a name="term.people"></a>1.3.1. People involved in pkgsrc</h3></div></div></div>
524: <div class="variablelist"><dl>
525: <dt><span class="term">pkgsrc users</span></dt>
526: <dd>
527: <p>The
528: pkgsrc users are people who use the packages provided by pkgsrc.
529: Typically they are system administrators. The people using the
530: software that is inside the packages (maybe called “<span class="quote">end
531: users</span>”) are not covered by the pkgsrc guide.</p>
532: <p>There are two kinds of pkgsrc users: Some only want to
533: install pre-built binary packages. Others build the pkgsrc
534: packages from source, either for installing them directly or for
535: building binary packages themselves. For pkgsrc users <a href="#users-guide" title="Part I. The pkgsrc user's guide">Part I, “The pkgsrc user's guide”</a> should provide all necessary
536: documentation.</p>
537: </dd>
538: <dt><span class="term">package maintainers</span></dt>
539: <dd><p>A
540: package maintainer creates packages as described in <a href="#developers-guide" title="Part II. The pkgsrc developer's guide">Part II, “The pkgsrc developer's guide”</a>.</p></dd>
541: <dt><span class="term">infrastructure developers</span></dt>
542: <dd><p>These people are involved in all those files
1.76 ! rillig 543: that live in the <code class="filename">mk/</code> directory and below.
1.75 rillig 544: Only these people should need to read through <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">Part III, “The pkgsrc infrastructure internals”</a>, though others might be curious,
545: too.</p></dd>
546: </dl></div>
547: </div>
548: </div>
549: <div class="sect1" lang="en">
550: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
551: <a name="typography"></a>1.4. Typography</h2></div></div></div>
552: <p>When giving examples for commands, shell prompts are used to
553: show if the command should/can be issued as root, or if
554: “<span class="quote">normal</span>” user privileges are sufficient. We use a
555: <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
556: shell prompt, assuming they use the C-shell or tcsh.</p>
557: </div>
558: </div>
559: <div class="part" lang="en">
560: <div class="titlepage"><div><div><h1 class="title">
561: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
562: <div class="toc">
563: <p><b>Table of Contents</b></p>
564: <dl>
565: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
566: <dd><dl>
567: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
568: <dd><dl>
569: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
570: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
571: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
572: </dl></dd>
573: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
574: <dd><dl>
575: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
576: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
577: </dl></dd>
578: </dl></dd>
579: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
580: <dd><dl>
581: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
582: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
583: <dd><dl>
584: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
585: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
586: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
587: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
588: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
589: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
590: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
591: </dl></dd>
592: </dl></dd>
593: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
594: <dd><dl>
595: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
596: <dd><dl>
597: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
598: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
599: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
600: </dl></dd>
601: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
602: <dd><dl>
603: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
604: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
605: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
606: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
607: </dl></dd>
608: </dl></dd>
609: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
610: <dd><dl>
611: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
612: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
613: <dt><span class="sect1"><a href="#developer-advanced-settings">5.3. Developer/advanced settings</a></span></dt>
614: <dt><span class="sect1"><a href="#selecting-build-options">5.4. Selecting Build Options</a></span></dt>
615: </dl></dd>
616: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
617: <dd><dl>
618: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
619: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
620: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
621: <dd><dl>
622: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
623: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
624: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
625: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
626: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
627: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
628: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
629: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
630: </dl></dd>
631: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
632: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
633: </dl></dd>
634: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
635: <dd><dl>
636: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
637: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
638: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
639: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
640: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
641: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
642: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
643: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
644: <dt><span class="sect1"><a href="#passive-ftp">7.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
645: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
646: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
647: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
648: <dt><span class="sect1"><a href="#bsd.own.mk-missing">7.12. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</a></span></dt>
649: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
650: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
651: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
652: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
653: </dl></dd>
654: </dl>
655: </div>
656: <div class="chapter" lang="en">
657: <div class="titlepage"><div><div><h2 class="title">
658: <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
659: <div class="toc">
660: <p><b>Table of Contents</b></p>
661: <dl>
662: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
663: <dd><dl>
664: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
665: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
666: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
667: </dl></dd>
668: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
669: <dd><dl>
670: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
671: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
672: </dl></dd>
673: </dl>
674: </div>
675: <p>The most common location where pkgsrc is installed is
1.76 ! rillig 676: <code class="filename">/usr/pkgsrc</code> for the “<span class="quote">package
! 677: sources</span>” and <code class="filename">/usr/pkg</code> for the
1.75 rillig 678: installed binary packages. You are though free to install the
679: sources and binary packages wherever you want in your
680: filesystem, provided that both paths do not contain white-space
681: or other characters that are interpreted specially by the shell
682: and some other programs. A safe bet is to use only letters,
683: digits, underscores and dashes in the names.</p>
684: <div class="sect1" lang="en">
685: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
686: <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
687: <p>Before you download any pkgsrc files, you should decide
688: whether you want the <span class="emphasis"><em>current</em></span> branch or the
689: <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
690: quarterly basis from the current branch and only gets modified
691: for security updates. The names of the stable branches are built
692: from the year and the quarter, for example
693: <code class="literal">2006Q1</code>.</p>
694: <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
695: want to download pkgsrc. You can get it as a tar file, via SUP,
696: or via CVS. All three ways are described here.</p>
697: <div class="sect2" lang="en">
698: <div class="titlepage"><div><div><h3 class="title">
699: <a name="getting-via-tar"></a>2.1.1. As tar file</h3></div></div></div>
700: <p>The primary download location for all pkgsrc files is
701: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>. There are a
702: number of subdirectories for different purposes, which are
1.76 ! rillig 703: described in detail in <a href="#ftp-layout" title="Appendix C. Directory layout of the pkgsrc FTP server">Appendix C, <i>Directory layout of the pkgsrc FTP server</i></a>.</p>
1.75 rillig 704: <p>The tar file for the current branch is in the directory
1.76 ! rillig 705: <code class="filename">current</code> and is called <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz" target="_top"><code class="filename">pkgsrc.tar.gz</code></a>.
1.75 rillig 706: It is autogenerated daily.</p>
707: <p>The tar file for the stable branch 2006Q1 is in the
1.76 ! rillig 708: directory <code class="filename">2006Q1</code> and is also called <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/2006Q1/pkgsrc.tar.gz" target="_top"><code class="filename">pkgsrc.tar.gz</code></a>.</p>
1.75 rillig 709: <p>After downloading the tar file, change to the directory
710: where you want to have pkgsrc. This is usually
1.76 ! rillig 711: <code class="filename">/usr</code>. Then, run <span><strong class="command">tar xfz
1.75 rillig 712: pkgsrc.tar.gz</strong></span> to extract the files.</p>
713: </div>
714: <div class="sect2" lang="en">
715: <div class="titlepage"><div><div><h3 class="title">
716: <a name="getting-via-sup"></a>2.1.2. Via SUP</h3></div></div></div>
717: <p>As an alternative to the tar file, you can get pkgsrc via
718: the Software Update Protocol, SUP. To do so, make sure your
719: supfile has a line
1.1 grant 720:
1.75 rillig 721: </p>
722: <pre class="programlisting">
1.51 rillig 723: release=pkgsrc
1.1 grant 724: </pre>
1.75 rillig 725: <p>
1.1 grant 726:
1.75 rillig 727: in it, see the examples in
1.76 ! rillig 728: <code class="filename">/usr/share/examples/supfiles</code>, and that the
! 729: <code class="filename">/usr/pkgsrc</code> directory exists. Then, simply
1.75 rillig 730: run <span><strong class="command">sup -v
731: <em class="replaceable"><code>/path/to/your/supfile</code></em></strong></span>.</p>
732: </div>
733: <div class="sect2" lang="en">
734: <div class="titlepage"><div><div><h3 class="title">
735: <a name="getting-via-cvs"></a>2.1.3. Via CVS</h3></div></div></div>
736: <p>To get pkgsrc via CVS, make sure you have <a href="http://netbsd.gw.com/cgi-bin/man-cgi?cvs+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">cvs</span>(1)</span></a>
737: installed. To do an initial (full) checkout of pkgsrc, you first
738: have to set some environment variables. For the C-Shell,
739: type:</p>
740: <pre class="screen">
741: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
742: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVS_RSH ssh</code></strong>
743: </pre>
744: <p>Or, the same for the bourne shell:</p>
745: <pre class="screen">
746: <code class="prompt">$</code> <strong class="userinput"><code>CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"</code></strong>
747: <code class="prompt">$</code> <strong class="userinput"><code>CVS_RSH="ssh"</code></strong>
748: <code class="prompt">$</code> <strong class="userinput"><code>export CVSROOT CVS_RSH</code></strong>
749: </pre>
750: <p>Then, you change to the directory where you want to have
751: your copy of pkgsrc. In most cases this is
1.76 ! rillig 752: <code class="filename">/usr</code>. In that directory you run the
1.75 rillig 753: checkout command, which is <span><strong class="command">cvs -q checkout -P
754: pkgsrc</strong></span> for the current branch and <span><strong class="command">cvs -q
755: checkout -rpkgsrc-2006Q1 -P pkgsrc</strong></span> for the stable
756: branch. This command will create a directory called
1.76 ! rillig 757: <code class="filename">pkgsrc</code> with all the pkgsrc files in
1.75 rillig 758: it.</p>
759: </div>
760: </div>
761: <div class="sect1" lang="en">
762: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
763: <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
764: <p>The preferred way to keep pkgsrc up-to-date is via CVS
765: (which also works if you have first installed it via a tar
766: file). It saves bandwidth and hard disk activity, compared to
767: downloading the tar file again.</p>
768: <div class="sect2" lang="en">
769: <div class="titlepage"><div><div><h3 class="title">
770: <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
771: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
772: <h3 class="title">Warning</h3>
773: <p>Updating from tar file cannot detect or preserve
774: any changes you have done to your local copy of pkgsrc.
775: Therefore updating via CVS is strongly
776: recommended.</p>
777: </div>
778: <p>To update pkgsrc from a tar file, download the tar file as
779: explained above. Then, make sure that you have not made any
780: changes to the files in the pkgsrc directory. Remove the pkgsrc
781: directory and extract the new tar file. Done.</p>
782: </div>
783: <div class="sect2" lang="en">
784: <div class="titlepage"><div><div><h3 class="title">
785: <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
786: <p>To update pkgsrc via CVS, make sure the environment
787: variable <code class="varname">CVS_RSH</code> is set as above. Then,
788: change to the pkgsrc directory and run <span><strong class="command">cvs -q update
789: -dP</strong></span>. The “<span class="quote">-q</span>” option tells cvs to only
790: report those files that have changed. The “<span class="quote">-d</span>”
791: option fetches new packages (which is curiously not done by
792: default), and the “<span class="quote">-P</span>” option removes empty
793: directories after everything has been updated.</p>
794: <div class="sect3" lang="en">
795: <div class="titlepage"><div><div><h4 class="title">
796: <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
797: <p>When updating pkgsrc, the CVS program keeps track of the
798: branch you selected. But if you, for whatever reason, want to
799: switch from the stable branch to the current one, you can do it
800: by adding the option “<span class="quote">-A</span>” after the
801: “<span class="quote">update</span>” keyword. To switch from the current branch
802: back to the stable branch, add the
803: “<span class="quote">-rpkgsrc-2006Q1</span>” option.</p>
804: </div>
805: <div class="sect3" lang="en">
806: <div class="titlepage"><div><div><h4 class="title">
807: <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
808: <p>When you update pkgsrc, the CVS program will only touch
809: those files that are registered in the CVS repository. That
810: means that any packages that you created on your own will stay
811: unmodified. If you change files that are managed by CVS, later
812: updates will try to merge your changes with those that have been
813: done by others. See the CVS manual, chapter
814: “<span class="quote">update</span>” for details.</p>
815: </div>
816: </div>
817: </div>
818: </div>
819: <div class="chapter" lang="en">
820: <div class="titlepage"><div><div><h2 class="title">
821: <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
822: <div class="toc">
823: <p><b>Table of Contents</b></p>
824: <dl>
825: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
826: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
827: <dd><dl>
828: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
829: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
830: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
831: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
832: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
833: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
834: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
835: </dl></dd>
836: </dl>
837: </div>
838: <div class="sect1" lang="en">
839: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
840: <a name="bootstrapping-pkgsrc"></a>3.1. Bootstrapping pkgsrc</h2></div></div></div>
841: <p>For operating systems other than NetBSD, we provide a bootstrap kit to
842: build the required tools to use pkgsrc on your platform. Besides
843: support for native NetBSD, pkgsrc and the bootstrap kit have support for
844: the following operating systems:</p>
845: <div class="itemizedlist"><ul type="disc">
846: <li><p>Darwin (Mac OS X)</p></li>
847: <li><p>DragonFly BSD</p></li>
848: <li><p>FreeBSD</p></li>
849: <li><p>Interix (Windows 2000, XP, 2003)</p></li>
850: <li><p>IRIX</p></li>
851: <li><p>Linux</p></li>
852: <li><p>OpenBSD</p></li>
853: <li><p>Solaris</p></li>
854: <li><p>Tru64 (Digital UNIX/OSF1)</p></li>
855: </ul></div>
856: <p>Support for other platforms is under development.</p>
857: <p>Installing the bootstrap kit should be as simple as:</p>
858: <pre class="screen">
859: <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
860: <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
861: <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong></pre>
862: <p>See <a href="#getting" title="Chapter 2. Where to get pkgsrc and how to keep it up-to-date">Chapter 2, <i>Where to get pkgsrc and how to keep it up-to-date</i></a> for other ways to get
863: pkgsrc before bootstrapping. The given
864: <span><strong class="command">bootstrap</strong></span> command will use the defaults of
1.76 ! rillig 865: <code class="filename">/usr/pkg</code> for the
1.75 rillig 866: <span class="emphasis"><em>prefix</em></span> where programs will be installed in,
1.76 ! rillig 867: and <code class="filename">/var/db/pkg</code> for the package database
1.75 rillig 868: directory where pkgsrc will do its internal bookkeeping.
869: However, these can also be set using command-line
870: arguments.</p>
871: <p>Binary packages for the pkgsrc tools and an initial set of packages is
872: available for supported platforms. An up-to-date list of these can be
873: found on <a href="http://www.pkgsrc.org/" target="_top">www.pkgsrc.org</a>.
874: Note that this only works for privileged builds that install
1.76 ! rillig 875: into <code class="filename">/usr/pkg</code>.</p>
1.75 rillig 876: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
877: <h3 class="title">Note</h3>
878: <p>The bootstrap installs a <span><strong class="command">bmake</strong></span> tool.
879: Use this <span><strong class="command">bmake</strong></span> when building via pkgsrc.
880: For examples in this guide, use <span><strong class="command">bmake</strong></span>
881: instead of “<span class="quote">make</span>”.</p>
882: </div>
883: </div>
884: <div class="sect1" lang="en">
885: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
886: <a name="platform-specific-notes"></a>3.2. Platform-specific notes</h2></div></div></div>
887: <p>Here are some platform-specific notes you should be aware of.</p>
888: <div class="sect2" lang="en">
889: <div class="titlepage"><div><div><h3 class="title">
890: <a name="darwin"></a>3.2.1. Darwin (Mac OS X)</h3></div></div></div>
891: <p>Darwin 5.x and 6.x are supported. There are two methods of using
892: pkgsrc on Mac OS X, by using a <a href="#platform.osx-image" title="3.2.1.1. Using a disk image">disk
893: image</a>, or a <a href="#platform.osx-ufs" title="3.2.1.2. Using a UFS partition">UFS
894: partition</a>.</p>
895: <p>Before you start, you will need to download and install the Mac OS X Developer
896: Tools from Apple's Developer Connection. See <a href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
897: for details. Also, make sure you install X11 for Mac OS X and the X11 SDK
898: from <a href="http://www.apple.com/macosx/x11/download/" target="_top">http://www.apple.com/macosx/x11/download/</a>
899: if you intend to build packages that use the X11 Window System.</p>
900: <p>If you already have a UFS partition, or have a spare partition
901: that you can format as UFS, it is recommended to use that instead of
902: the disk image. It'll be somewhat faster and will mount automatically
903: at boot time, where you must manually mount a disk image.</p>
904: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
905: <h3 class="title">Note</h3>
906: <p>You cannot use a HFS+ file system for pkgsrc, because pkgsrc currently
907: requires the file system to be case-sensitive, and HFS+ is not.</p>
908: </div>
909: <div class="sect3" lang="en">
910: <div class="titlepage"><div><div><h4 class="title">
911: <a name="platform.osx-image"></a>3.2.1.1. Using a disk image</h4></div></div></div>
912: <p>Create the disk image:</p>
913: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
914: <code class="prompt">#</code> <strong class="userinput"><code>./ufsdiskimage create ~/Documents/NetBSD 512</code></strong> # megabytes - season to taste
915: <code class="prompt">#</code> <strong class="userinput"><code>./ufsdiskimage mount ~/Documents/NetBSD</code></strong>
916: <code class="prompt">#</code> <strong class="userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong></pre>
917: <p>That's it!</p>
918: </div>
919: <div class="sect3" lang="en">
920: <div class="titlepage"><div><div><h4 class="title">
921: <a name="platform.osx-ufs"></a>3.2.1.2. Using a UFS partition</h4></div></div></div>
1.76 ! rillig 922: <p>By default, <code class="filename">/usr</code> will be on your root file
1.75 rillig 923: system, normally HFS+. It is possible to use the default
1.76 ! rillig 924: <span class="emphasis"><em>prefix</em></span> of <code class="filename">/usr/pkg</code>
! 925: by symlinking <code class="filename">/usr/pkg</code> to a directory on a UFS
1.75 rillig 926: file system. Obviously, another symlink is required if you want to
927: place the package database directory outside the
928: <span class="emphasis"><em>prefix</em></span>. e.g.</p>
929: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb</code></strong></pre>
930: <p>If you created your partitions at the time of installing Mac OS X
931: and formatted the target partition as UFS, it should automatically
1.76 ! rillig 932: mount on <code class="filename">/Volumes/<volume name></code> when the
1.75 rillig 933: machine boots. If you are (re)formatting a partition as UFS, you need
934: to ensure that the partition map correctly reflects
935: “<span class="quote">Apple_UFS</span>” and not “<span class="quote">Apple_HFS</span>”.</p>
936: <p>The problem is that none of the disk tools will let you touch a
937: disk that is booted from. You can unmount the partition, but even if
938: you newfs it, the partition type will be incorrect and the
939: automounter won't mount it. It can be mounted manually, but it won't
940: appear in Finder.</p>
941: <p>You'll need to boot off of the OS X Installation (User) CD. When
942: the Installation program starts, go up to the menu and select Disk
943: Utility. Now, you will be able to select the partition you want
944: to be UFS, and Format it Apple UFS. Quit the Disk Utility, quit the
945: installer which will reboot your machine. The new UFS file system
946: will appear in Finder.</p>
947: <p>Be aware that the permissions on the new file system will be writable
948: by root only.</p>
949: <p>This note is as of 10.2 (Jaguar) and applies to earlier versions.
950: Hopefully Apple will fix Disk Utility in 10.3 (Panther).</p>
951: </div>
952: </div>
953: <div class="sect2" lang="en">
954: <div class="titlepage"><div><div><h3 class="title">
955: <a name="freebsd"></a>3.2.2. FreeBSD</h3></div></div></div>
956: <p>
957: FreeBSD 4.7 and 5.0 have been tested and are supported, other versions
958: may work.</p>
959: <p>Care should be taken so that the tools that this kit installs do not conflict
960: with the FreeBSD userland tools. There are several steps:</p>
961: <div class="orderedlist"><ol type="1">
962: <li><p>FreeBSD stores its ports pkg database in
1.76 ! rillig 963: <code class="filename">/var/db/pkg</code>. It is therefore
1.75 rillig 964: recommended that you choose a different location (e.g.
1.76 ! rillig 965: <code class="filename">/usr/pkgdb</code>) by
1.75 rillig 966: using the --pkgdbdir option to the bootstrap script.</p></li>
967: <li>
968: <p>If you do not intend to use the FreeBSD ports tools, it's probably a
969: good idea to move them out of the way to avoid confusion, e.g.</p>
970: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
971: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
972: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
973: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
974: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
975: </li>
1.76 ! rillig 976: <li><p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
! 977: <code class="filename">/etc/mk.conf.example</code> file
1.75 rillig 978: when you use the bootstrap script.</p></li>
979: </ol></div>
980: </div>
981: <div class="sect2" lang="en">
982: <div class="titlepage"><div><div><h3 class="title">
983: <a name="interix"></a>3.2.3. Interix</h3></div></div></div>
984: <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
985: providing a Unix-like environment with a tighter kernel integration than
986: available with Cygwin. It is part of the Windows Services for Unix
987: package, available for free for any licensed copy of Windows 2000, XP
988: (not including XP Home), or 2003. SFU can be downloaded from <a href="http://www.microsoft.com/windows/sfu/" target="_top">http://www.microsoft.com/windows/sfu/</a>.</p>
989: <p>Services for Unix 3.5, current as of this writing, has been tested. 3.0
990: or 3.1 may work, but are not officially supported. (The main difference
991: in 3.0/3.1 is lack of pthreads.)</p>
992: <div class="sect3" lang="en">
993: <div class="titlepage"><div><div><h4 class="title">
994: <a name="platform.interix-sfu-install"></a>3.2.3.1. When installing Interix/SFU</h4></div></div></div>
995: <p>At an absolute minimum, the following packages must be installed from
996: the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
997: <div class="itemizedlist"><ul type="disc">
998: <li><p>Utilities -> Base Utilities</p></li>
999: <li><p>Interix GNU Components -> (all)</p></li>
1000: <li><p>Remote Connectivity</p></li>
1001: <li><p>Interix SDK</p></li>
1002: </ul></div>
1003: <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
1004: "UNIX Perl". That is Perl 5.6 without shared module support, installed to
1005: /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
1006: pkgsrc (or from a binary package).</p>
1007: <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
1008: not need to be installed, but Remote Connectivity itself should be
1009: installed in order to have a working inetd.</p>
1010: <p>During installation you may be asked whether to enable setuid
1011: behavior for Interix programs, and whether to make pathnames default to
1012: case-sensitive. Setuid should be enabled, and case-sensitivity MUST be
1013: enabled. (Without case-sensitivity, a large number of packages including
1014: perl will not build.)</p>
1015: <p>NOTE: Newer Windows service packs change the way binary execution
1016: works (via the Data Execution Prevention feature). In order to use
1017: pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
1018: POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
1019: must be installed. Hotfixes are available from Microsoft through a
1020: support contract; however, a NetBSD developer has made most Interix
1021: hotfixes available for personal use from <a href="http://www.duh.org/interix/hotfixes.php" target="_top">http://www.duh.org/interix/hotfixes.php</a>.</p>
1022: </div>
1023: <div class="sect3" lang="en">
1024: <div class="titlepage"><div><div><h4 class="title">
1025: <a name="platform.interix-sfu-postinstall"></a>3.2.3.2. What to do if Interix/SFU is already installed</h4></div></div></div>
1026: <p>If SFU is already installed and you wish to alter these settings to work
1027: with pkgsrc, note the following things.</p>
1028: <div class="itemizedlist"><ul type="disc">
1029: <li><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
1030: Windows Services for UNIX, then click Change. In the installer, choose
1031: Add or Remove, then uncheck Utilities->UNIX Perl.</p></li>
1032: <li>
1033: <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
1034: change the following registry key:</p>
1035: <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
1036: <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
1037: </li>
1038: <li>
1039: <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
1040: following registry key:</p>
1041: <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
1042: <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
1043: </li>
1044: </ul></div>
1045: </div>
1046: <div class="sect3" lang="en">
1047: <div class="titlepage"><div><div><h4 class="title">
1048: <a name="platform.interix-notes"></a>3.2.3.3. Important notes for using pkgsrc</h4></div></div></div>
1049: <p>The package manager (either the pkgsrc "su" user, or the user
1050: running "pkg_add") must be a member of the local Administrators
1051: group. Such a user must also be used to run the bootstrap. This is
1052: slightly relaxed from the normal pkgsrc requirement of "root".</p>
1053: <p>The package manager should use a umask of 002. "make install" will
1054: automatically complain if this is not the case. This ensures that
1055: directories written in /var/db/pkg are Administrators-group writeable.</p>
1056: <p>The popular Interix binary packages from http://www.interopsystems.com/
1057: use an older version of pkgsrc's pkg_* tools. Ideally, these should
1058: NOT be used in conjunction with pkgsrc. If you choose to use them at
1059: the same time as the pkgsrc packages, ensure that you use the proper
1060: pkg_* tools for each type of binary package.</p>
1061: <p>The TERM setting used for DOS-type console windows (including those
1062: invoked by the csh and ksh startup shortcuts) is "interix". Most systems
1063: don't have a termcap/terminfo entry for it, but the following .termcap
1064: entry provides adequate emulation in most cases:</p>
1065: <pre class="programlisting">
1066: interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
1067: </pre>
1068: </div>
1069: <div class="sect3" lang="en">
1070: <div class="titlepage"><div><div><h4 class="title">
1071: <a name="platform.interix-limits"></a>3.2.3.4. Limitations of the Interix platform</h4></div></div></div>
1072: <p>Though Interix suffices as a familiar and flexible substitute
1073: for a full Unix-like platform, it has some drawbacks that should
1074: be noted for those desiring to make the most of Interix.</p>
1075: <div class="itemizedlist"><ul type="disc">
1076: <li>
1077: <p><span class="strong"><strong>X11:</strong></span></p>
1078: <p>Interix comes with the standard set of X11R6 client libraries,
1079: and can run X11 based applications, but it does
1080: <span class="emphasis"><em>not</em></span> come with an X server. Some options are
1081: <a href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
1082: <a href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
1083: (available in a trimmed version for Interix from Interop Systems as the
1084: <a href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
1085: and the free X11 server included with
1086: <a href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
1087: <p>Also, StarNet Communications has graciously provided a free
1088: version of their X-Win32 product that accepts connections only
1089: from localhost:
1090: <a href="http://www.starnet.com/xwin32LX/get_xwin32LX.htm" target="_top">X-Win32 LX</a>,
1091: recommended by the maintainer of Interix pkgsrc support.</p>
1092: </li>
1093: <li>
1094: <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
1095: <p>Because Interix runs in a completely different NT subsystem from
1096: Win32 applications, it does not currently support various X11
1097: protocol extensions for acceleration (such as MIT-SHM or DGA).
1098: Most interactive applications to a local X server will run
1099: reasonably fast, but full motion video and other graphics
1100: intensive applications may require a faster-than-expected CPU.</p>
1101: </li>
1102: <li>
1103: <p><span class="strong"><strong>Audio:</strong></span></p>
1104: <p>Interix has no native support for audio output. For audio
1105: support, pkgsrc uses the <span><strong class="command">esound</strong></span> client/server
1106: audio system on Interix. Unlike on most platforms, the
1.76 ! rillig 1107: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/audio/esound/README.html" target="_top"><code class="filename">audio/esound</code></a> package does
1.75 rillig 1108: <span class="emphasis"><em>not</em></span> contain the <span><strong class="command">esd</strong></span>
1109: server component. To output audio via an Interix host, the
1.76 ! rillig 1110: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/emulators/cygwin_esound/README.html" target="_top"><code class="filename">emulators/cygwin_esound</code></a> package
1.75 rillig 1111: must also be installed.</p>
1112: </li>
1113: <li>
1114: <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
1115: <p>Direct device access is not currently supported in Interix, so it
1116: is not currently possible to access CD/DVD drives, USB devices,
1117: or SCSI devices through non-filesystem means. Among other things,
1118: this makes it impossible to use Interix directly for CD/DVD
1119: burning.</p>
1120: </li>
1121: <li>
1122: <p><span class="strong"><strong>Tape drives:</strong></span></p>
1123: <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
1124: drives are also not directly accessible in Interix. However,
1125: support is in work to make tape drive access possible by using
1126: Cygwin as a bridge (similarly to audio bridged via Cygwin's
1127: esound server).</p>
1128: </li>
1129: </ul></div>
1130: </div>
1131: <div class="sect3" lang="en">
1132: <div class="titlepage"><div><div><h4 class="title">
1133: <a name="platform.interix-knownissues"></a>3.2.3.5. Known issues for pkgsrc on Interix</h4></div></div></div>
1134: <p>It is not necessary, in general, to have a "root" user on the
1135: Windows system; any member of the local Administrators group will
1136: suffice. However, some packages currently assume that the user
1137: named "root" is the privileged user. To accommodate these, you
1138: may create such a user; make sure it is in the local group
1139: Administrators (or your language equivalent).</p>
1140: <p>"pkg_add" creates directories of mode 0755, not 0775, in
1141: $PKG_DBDIR. For the time being, install packages as the local
1142: Administrator (or your language equivalent), or run the following
1143: command after installing a package to work around the issue:</p>
1144: <pre class="screen">
1145: <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong></pre>
1146: </div>
1147: </div>
1148: <div class="sect2" lang="en">
1149: <div class="titlepage"><div><div><h3 class="title">
1150: <a name="irix"></a>3.2.4. IRIX</h3></div></div></div>
1151: <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
1152: compiler (cc/c89). Please set the <code class="varname">CC</code> environment variable
1153: according to your preference. If you do not have a license for the MIPSpro
1154: compiler suite, you can download a gcc tardist file from <a href="http://freeware.sgi.com/" target="_top">http://freeware.sgi.com/</a>.</p>
1155: <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
1156: version of IRIX providing support for <a href="http://netbsd.gw.com/cgi-bin/man-cgi?if_indextoname+3+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">if_indextoname</span>(3)</span></a>, <a href="http://netbsd.gw.com/cgi-bin/man-cgi?if_nametoindex+3+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">if_nametoindex</span>(3)</span></a>,
1157: etc.</p>
1158: <p>At this point in time, pkgsrc only supports one ABI at a time. That is, you can not
1159: switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI. If
1160: you start out using "abi=n32", that's what all your packages will be built
1161: with.</p>
1162: <p>Therefore, please make sure that you have no conflicting
1163: <code class="varname">CFLAGS</code> in your environment or the
1.76 ! rillig 1164: <code class="filename">/etc/mk.conf</code>. Particularly, make sure that you do not
1.75 rillig 1165: try to link n32 object files with lib64 or vice versa. Check your
1.76 ! rillig 1166: <code class="filename">/etc/compiler.defaults</code>!</p>
1.75 rillig 1167: <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
1168: please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
1169: as it appears that IRIX linker occasionally runs into issues when trying to
1170: link over a network-mounted file system.</p>
1171: <p>The bootstrapping process should set all the right options for programs such
1172: as imake(1), but you may want to set some options depending on your local
1.76 ! rillig 1173: setup. Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
1.75 rillig 1174: course, your compiler's man pages for details.</p>
1175: <p>If you are using SGI's MIPSPro compiler, please set
1.1 grant 1176:
1.75 rillig 1177: </p>
1178: <pre class="programlisting">
1179: PKGSRC_COMPILER= mipspro
1180: </pre>
1181: <p>
1.1 grant 1182:
1.76 ! rillig 1183: in <code class="filename">/etc/mk.conf</code>. Otherwise, pkgsrc will assume you
1.75 rillig 1184: are using gcc and may end up passing invalid flags to the compiler. Note that
1.76 ! rillig 1185: bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
1.75 rillig 1186: default.</p>
1187: <p>If you have both the MIPSPro compiler chain installed as well as gcc,
1188: but want to make sure that MIPRPro is used, please set your <code class="varname">PATH</code>
1189: to <span class="emphasis"><em>not</em></span> include the location of gcc (often
1.76 ! rillig 1190: <code class="filename">/usr/freeware/bin</code>), and (important) pass the
1.75 rillig 1191: '--preserve-path' flag.</p>
1192: </div>
1193: <div class="sect2" lang="en">
1194: <div class="titlepage"><div><div><h3 class="title">
1195: <a name="linux"></a>3.2.5. Linux</h3></div></div></div>
1196: <p>
1197: Some versions of Linux (for example Debian GNU/Linux) need either
1198: libtermcap or libcurses (libncurses). Installing the distributions
1199: libncurses-dev package (or equivalent) should fix the problem.</p>
1200: <p>
1201: pkgsrc supports both gcc (GNU Compiler Collection) and icc (Intel C++
1202: Compiler). gcc is the default. icc 8.0 and 8.1 on i386 have been tested.
1203: </p>
1204: <p>To bootstrap using icc, assuming the default icc installation
1205: directory:</p>
1206: <pre class="programlisting">
1207: env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
1208: ac_cv___attribute__=yes ./bootstrap
1209: </pre>
1210: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1211: <h3 class="title">Note</h3>
1212: <p>icc 8.1 needs the `-i-static' argument instead of -static-libcxa.</p>
1213: </div>
1214: <p>icc supports __attribute__, but the GNU configure test uses a nested
1215: function, which icc does not support. #undef'ing __attribute__ has the
1216: unfortunate side-effect of breaking many of the Linux header files, which
1217: cannot be compiled properly without __attribute__. The test must be
1218: overridden so that __attribute__ is assumed supported by the
1219: compiler.</p>
1220: <p>After bootstrapping, you should set <code class="varname">PKGSRC_COMPILER</code>
1.76 ! rillig 1221: in <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1222: <pre class="programlisting">
1223: PKGSRC_COMPILER= icc
1224: </pre>
1225: <p>The default installation directory for icc is
1.76 ! rillig 1226: <code class="filename">/opt/intel_cc_80</code>, which
1.75 rillig 1227: is also the pkgsrc default. If you have installed it into a different
1228: directory, set <code class="varname">ICCBASE</code> in
1.76 ! rillig 1229: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1230: <pre class="programlisting">
1231: ICCBASE= /opt/icc
1232: </pre>
1233: <p>pkgsrc uses the static linking method of the runtime libraries
1234: provided by icc, so binaries can be run on other systems which do not
1235: have the shared libraries installed.</p>
1236: <p>Libtool, however, extracts a list of libraries from the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ld+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ld</span>(1)</span></a>
1237: command run when linking a C++ shared library and records it, throwing
1238: away the -Bstatic and -Bdynamic options interspersed between the libraries.
1239: This means that libtool-linked C++ shared libraries will have a
1240: runtime dependency on the icc libraries until this is fixed in libtool.
1241: </p>
1242: </div>
1243: <div class="sect2" lang="en">
1244: <div class="titlepage"><div><div><h3 class="title">
1245: <a name="openbsd"></a>3.2.6. OpenBSD</h3></div></div></div>
1246: <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
1247: <p>Care should be taken so that the tools that this kit installs do not conflict
1248: with the OpenBSD userland tools. There are several steps:</p>
1249: <div class="orderedlist"><ol type="1">
1250: <li><p>OpenBSD stores its ports pkg database in
1.76 ! rillig 1251: <code class="filename">/var/db/pkg</code>. It is therefore
1.75 rillig 1252: recommended that you choose a different location (e.g.
1.76 ! rillig 1253: <code class="filename">/usr/pkgdb</code>) by
1.75 rillig 1254: using the --pkgdbdir option to the bootstrap script.</p></li>
1255: <li>
1256: <p>If you do not intend to use the OpenBSD ports tools, it's probably a
1257: good idea to move them out of the way to avoid confusion, e.g.</p>
1258: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1259: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1260: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1261: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1262: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
1263: </li>
1264: <li>
1.76 ! rillig 1265: <p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
! 1266: <code class="filename">/etc/mk.conf.example</code> file
1.75 rillig 1267: when you use the bootstrap script. OpenBSD's make program uses
1.76 ! rillig 1268: <code class="filename">/etc/mk.conf</code>
1.75 rillig 1269: as well. You can work around this by enclosing all the pkgsrc-specific parts
1270: of the file with:</p>
1271: <pre class="programlisting">
1272: .ifdef BSD_PKG_MK
1273: # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
1274: .else
1275: # OpenBSD stuff
1.1 grant 1276: .endif
1277: </pre>
1.75 rillig 1278: </li>
1279: </ol></div>
1280: </div>
1281: <div class="sect2" lang="en">
1282: <div class="titlepage"><div><div><h3 class="title">
1283: <a name="solaris"></a>3.2.7. Solaris</h3></div></div></div>
1284: <p>Solaris 2.6 through 9 are supported on both x86 and sparc.
1285: You will need a working C compiler. Both gcc 2.95.3 and
1286: Sun WorkShop 5 have been tested.</p>
1287: <p>The following packages are required on Solaris 8 for the bootstrap
1288: process and to build packages.</p>
1289: <div class="itemizedlist"><ul type="disc">
1290: <li><p>SUNWsprot</p></li>
1291: <li><p>SUNWarc</p></li>
1292: <li><p>SUNWbtool</p></li>
1293: <li><p>SUNWtoo</p></li>
1294: <li><p>SUNWlibm</p></li>
1295: </ul></div>
1296: <p>Please note the use of GNU binutils on Solaris is
1297: <span class="emphasis"><em>not</em></span> supported.</p>
1298: <p>Whichever compiler you use, please ensure the compiler tools and
1299: your $prefix are in your <code class="varname">PATH</code>. This includes
1.76 ! rillig 1300: <code class="filename">/usr/ccs/{bin,lib}</code>
! 1301: and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1.75 rillig 1302: <div class="sect3" lang="en">
1303: <div class="titlepage"><div><div><h4 class="title">
1304: <a name="solaris-gcc-note"></a>3.2.7.1. If you are using gcc</h4></div></div></div>
1305: <p>It makes life much simpler if you only use the same gcc consistently
1306: for building all packages.</p>
1307: <p>It is recommended that an external gcc be used only for bootstrapping,
1308: then either build gcc from
1.76 ! rillig 1309: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/lang/gcc/README.html" target="_top"><code class="filename">lang/gcc</code></a> or install a binary gcc
1.75 rillig 1310: package, then remove gcc used during bootstrapping.</p>
1311: <p>Binary packages of gcc can be found through <a href="http://www.sun.com/bigadmin/common/freewareSearch.html" target="_top">http://www.sun.com/bigadmin/common/freewareSearch.html</a>.</p>
1312: </div>
1313: <div class="sect3" lang="en">
1314: <div class="titlepage"><div><div><h4 class="title">
1315: <a name="solaris-sun-workshop-note"></a>3.2.7.2. If you are using Sun WorkShop</h4></div></div></div>
1316: <p>You will need at least the following packages installed (from WorkShop
1317: 5.0)</p>
1318: <div class="itemizedlist"><ul type="disc">
1319: <li><p>SPROcc
1320: - Sun WorkShop Compiler C 5.0</p></li>
1321: <li><p>SPROcpl
1322: - Sun WorkShop Compiler C++ 5.0</p></li>
1323: <li><p>SPROild
1324: - Sun WorkShop Incremental Linker</p></li>
1325: <li><p>SPROlang
1326: - Sun WorkShop Compilers common components</p></li>
1327: </ul></div>
1328: <p>You should set <code class="varname">CC</code>, <code class="varname">CXX</code> and
1.76 ! rillig 1329: optionally, <code class="varname">CPP</code> in <code class="filename">/etc/mk.conf</code>,
1.75 rillig 1330: e.g.:</p>
1331: <pre class="programlisting">
1332: CC= cc
1333: CXX= CC
1334: CPP= /usr/ccs/lib/cpp
1.1 grant 1335: </pre>
1.75 rillig 1336: </div>
1337: <div class="sect3" lang="en">
1338: <div class="titlepage"><div><div><h4 class="title">
1339: <a name="solaris-sunpro-64"></a>3.2.7.3. Buildling 64-bit binaries with SunPro</h4></div></div></div>
1340: <p>Building 64-bit binaries is a little trickier. First, you
1341: need to bootstrap pkgsrc in 64-bit mode. One problem here is
1342: that while building one of the programs in the bootstrap kit
1.76 ! rillig 1343: (<code class="filename">bmake</code>), the <code class="varname">CFLAGS</code>
1.75 rillig 1344: variable is not honored, even if it is set in the environment.
1345: To work around this bug, you can create a simple shell script
1.76 ! rillig 1346: called <code class="filename">cc64</code> and put it somewhere in the
1.75 rillig 1347: <code class="varname">PATH</code>:</p>
1348: <pre class="programlisting">
1349: #! /bin/sh
1350: exec /opt/SUNWspro/bin/cc -xtarget=ultra -xarch=v9 ${1+"$@"}
1.1 grant 1351: </pre>
1.75 rillig 1352: <p>Then, pass the definition for <code class="varname">CC</code> in the
1353: environment of the <span><strong class="command">bootstrap</strong></span> command:</p>
1354: <pre class="programlisting">
1355: <code class="prompt">$</code> <strong class="userinput"><code>cd bootstrap</code></strong>
1356: <code class="prompt">$</code> <strong class="userinput"><code>CC=cc64 ./bootstrap</code></strong>
1357: </pre>
1358: <p>After bootstrapping, there are two alternative ways,
1359: depending on whether you want to find bugs in packages or get
1360: your system ready quickly. If you just want a running system,
1.76 ! rillig 1361: add the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1362: file:</p>
1363: <pre class="programlisting">
1364: CC= cc64
1365: CXX= CC64
1366: PKGSRC_COMPILER= sunpro
1.1 grant 1367: </pre>
1.75 rillig 1368: <p>This way, all calls to the compiler will be intercepted by
1369: the above wrapper and therefore get the necessary ABI options
1370: automatically. (Don't forget to create the shell script
1.76 ! rillig 1371: <code class="filename">CC64</code>, too.)</p>
1.75 rillig 1372: <p>To find packages that ignore the user-specified
1373: <code class="varname">CFLAGS</code> and <code class="varname">CXXFLAGS</code>, add
1.76 ! rillig 1374: the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1375: file:</p>
1376: <pre class="programlisting">
1377: CC= cc
1378: CXX= CC
1379: PKGSRC_COMPILER= sunpro
1380: CFLAGS= -xtarget=ultra -xarch=v9
1381: CXXFLAGS= -xtarget=ultra -xarch=v9
1382: LDFLAGS= -xtarget=ultra -xarch=v9
1.1 grant 1383: </pre>
1.75 rillig 1384: <p>Packages that don't use the flags provided in the
1385: configuration file will try to build 32-bit binaries and fail
1386: during linking. Detecting this is useful to prevent bugs on
1387: other platforms where the error would not show up but pass
1388: silently.</p>
1389: </div>
1390: <div class="sect3" lang="en">
1391: <div class="titlepage"><div><div><h4 class="title">
1392: <a name="plat.sunos.problems"></a>3.2.7.4. Common problems</h4></div></div></div>
1393: <p>Sometimes, when using <span><strong class="command">libtool</strong></span>,
1.76 ! rillig 1394: <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
1.75 rillig 1395: The workaround is to use another shell for the configure
1.76 ! rillig 1396: scripts, for example by installing <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/shells/bash/README.html" target="_top"><code class="filename">shells/bash</code></a> and adding the following lines
! 1397: to your <code class="filename">mk.conf</code>:</p>
1.75 rillig 1398: <pre class="programlisting">
1399: CONFIG_SHELL= ${LOCALBASE}/bin/bash
1400: WRAPPER_SHELL= ${LOCALBASE}/bin/bash
1.1 grant 1401: </pre>
1.76 ! rillig 1402: <p>Then, rebuild the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/libtool-base/README.html" target="_top"><code class="filename">devel/libtool-base</code></a> package.</p>
1.75 rillig 1403: </div>
1404: </div>
1405: </div>
1406: </div>
1407: <div class="chapter" lang="en">
1408: <div class="titlepage"><div><div><h2 class="title">
1409: <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
1410: <div class="toc">
1411: <p><b>Table of Contents</b></p>
1412: <dl>
1413: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
1414: <dd><dl>
1415: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
1416: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1417: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
1418: </dl></dd>
1419: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
1420: <dd><dl>
1421: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
1422: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
1423: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
1424: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
1425: </dl></dd>
1426: </dl>
1427: </div>
1428: <p>Basically, there are two ways of using pkgsrc. The first
1429: is to only install the package tools and to use binary packages
1430: that someone else has prepared. This is the “<span class="quote">pkg</span>”
1431: in pkgsrc. The second way is to install the “<span class="quote">src</span>”
1432: of pkgsrc, too. Then you are able to build your own packages,
1433: and you can still use binary packages from someone else.</p>
1434: <div class="sect1" lang="en">
1435: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1436: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
1437: <p>To use binary packages, you need some tools to manage
1438: them. On NetBSD, these tools are already installed. On all other
1439: operating systems, you need to install them first. For the
1440: following platforms, prebuilt versions of the package tools
1441: are available and can simply be downloaded and unpacked in the
1.76 ! rillig 1442: <code class="filename">/</code> directory:</p>
1.75 rillig 1443: <div class="informaltable">
1444: <a name="binary-bootstrap-kits"></a><table border="1">
1445: <colgroup>
1446: <col>
1447: <col>
1448: </colgroup>
1449: <thead><tr>
1450: <th>Platform</th>
1451: <th>URL</th>
1452: </tr></thead>
1453: <tbody>
1454: <tr>
1455: <td>Solaris 9</td>
1.76 ! rillig 1456: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1457: </tr>
1458: <tr>
1459: <td>Solaris 10</td>
1.76 ! rillig 1460: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1461: </tr>
1462: </tbody>
1463: </table>
1464: </div>
1465: <p>These prebuilt package tools use
1.76 ! rillig 1466: <code class="filename">/usr/pkg</code> for the base directory, and
! 1467: <code class="filename">/var/db/pkg</code> for the database of installed
1.75 rillig 1468: packages. If you cannot use these directories for whatever
1469: reasons (maybe because you're not root), you have to build the
1470: package tools yourself, which is explained in <a href="#bootstrapping-pkgsrc" title="3.1. Bootstrapping pkgsrc">Section 3.1, “Bootstrapping pkgsrc”</a>.</p>
1471: <div class="sect2" lang="en">
1472: <div class="titlepage"><div><div><h3 class="title">
1473: <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
1474: <p>To install binary packages, you first need to know from
1475: where to get them. You can get them on CD-ROMs, DVDs, or via FTP
1476: or HTTP.</p>
1477: <p>For NetBSD, the binary packages are made available on
1.76 ! rillig 1478: <code class="filename">ftp.NetBSD.org</code> and its mirrors, in the
1.75 rillig 1479: directory
1.76 ! rillig 1480: <code class="filename">/pub/NetBSD/packages/<em class="replaceable"><code>OSVERSION</code></em>/<em class="replaceable"><code>ARCH</code></em>/</code>.
1.75 rillig 1481: For <em class="replaceable"><code>OSVERSION</code></em>, you should insert the
1482: output of <span><strong class="command">uname -r</strong></span>, and for
1483: <em class="replaceable"><code>ARCH</code></em> the output of <span><strong class="command">uname
1484: -p</strong></span>.</p>
1485: <p>For some other platforms, binary packages can be found at
1486: the following locations:</p>
1487: <div class="informaltable">
1488: <a name="binary-packages"></a><table border="1">
1489: <colgroup>
1490: <col>
1491: <col>
1492: </colgroup>
1493: <thead><tr>
1494: <th>Platform</th>
1495: <th>URL</th>
1496: </tr></thead>
1497: <tbody>
1498: <tr>
1499: <td>Solaris 9</td>
1.76 ! rillig 1500: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/</code></td>
1.75 rillig 1501: </tr>
1502: <tr>
1503: <td>Solaris 10</td>
1.76 ! rillig 1504: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/</code></td>
1.75 rillig 1505: </tr>
1506: </tbody>
1507: </table>
1508: </div>
1509: <p>Most of these directories contain the pkgsrc distribution
1510: for multiple platforms. Select the appropriate subdirectories,
1511: according to your machine architecture and operating system,
1.76 ! rillig 1512: until you find a directory called <code class="filename">All</code>. This
1.75 rillig 1513: directory contains all the binary packages. Further, there are
1514: subdirectories for categories that contain symbolic links that
1515: point to the actual binary package in
1.76 ! rillig 1516: <code class="filename">../All</code>. This directory layout is used for
1.75 rillig 1517: all package repositories, no matter if they are accessed via
1518: HTTP, FTP, NFS, CD-ROM, or the local filesystem.</p>
1519: </div>
1520: <div class="sect2" lang="en">
1521: <div class="titlepage"><div><div><h3 class="title">
1522: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
1523: <p> If you have the files on a CD-ROM or downloaded them to
1524: your hard disk, you can install them with the following command
1525: (be sure to <span><strong class="command">su</strong></span> to root first):</p>
1526: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add /path/to/package.tgz</code></strong></pre>
1527: <p> If you have FTP access and you don't want to download the
1528: packages via FTP prior to installation, you can do this
1529: automatically by giving <span><strong class="command">pkg_add</strong></span> an FTP URL:
1530: </p>
1531: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add ftp://ftp.NetBSD.org/pub/NetBSD/packages/<OSVERSION>/<ARCH>/All/package.tgz</code></strong></pre>
1532: <p>Note that any prerequisite packages needed to run the
1533: package in question will be installed, too, assuming they are
1534: present where you install from. </p>
1535: <p>To save some typing, you can set the
1536: <code class="varname">PKG_PATH</code> environment variable to a semicolon-separated
1537: list of paths (including remote URLs); trailing slashes are not allowed.
1538: </p>
1.76 ! rillig 1539: <p>Additionally to the <code class="filename">All</code> directory
! 1540: there exists a <code class="filename">vulnerable</code> directory to
1.75 rillig 1541: which binary packages with known vulnerabilities are
1542: moved, since removing them could cause missing dependencies. To
1.76 ! rillig 1543: use these packages, add the <code class="filename">vulnerable</code>
1.75 rillig 1544: directory to your <code class="varname">PKG_PATH</code>. However, you should run
1.76 ! rillig 1545: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a> regularly,
1.75 rillig 1546: especially after installing new packages, and verify that the
1547: vulnerabilities are acceptable for your configuration. An example
1548: <code class="varname">PKG_PATH</code> would be:
1.76 ! rillig 1549: <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/<OSVERSION>/<ARCH>/All;ftp://ftp.NetBSD.org/pub/NetBSD/packages/<OSVERSION>/<ARCH>/vulnerable</code>
1.75 rillig 1550: Please note that semicolon (';') is a shell meta-character, so
1551: you'll probably have to quote it.</p>
1552: <p>After you've installed packages, be sure to have
1.76 ! rillig 1553: <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
1.75 rillig 1554: <code class="varname">PATH</code> so you can actually start the just
1555: installed program. </p>
1556: </div>
1557: <div class="sect2" lang="en">
1558: <div class="titlepage"><div><div><h3 class="title">
1559: <a name="a-word-of-warning"></a>4.1.3. A word of warning</h3></div></div></div>
1560: <p>Please pay very careful attention to the warnings
1561: expressed in the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> manual page about the
1562: inherent dangers of installing binary packages which you did
1563: not create yourself, and the security holes that can be
1564: introduced onto your system by indiscriminate adding of such
1565: files.</p>
1566: <p>The same warning of course applies to every package you
1567: install from source when you haven't completely read and
1568: understood the source code of the package, the compiler that
1569: is used to build the package and all the other tools that are
1570: involved.</p>
1571: </div>
1572: </div>
1573: <div class="sect1" lang="en">
1574: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1575: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
1576: <p> This assumes that the package is already in pkgsrc. If it
1577: is not, see <a href="#developers-guide" title="Part II. The pkgsrc developer's guide">Part II, “The pkgsrc developer's guide”</a> for instructions
1578: how to create your own packages.</p>
1579: <div class="sect2" lang="en">
1580: <div class="titlepage"><div><div><h3 class="title">
1581: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
1582: <p> To build packages from source on a NetBSD system the
1583: “<span class="quote">comp</span>” and the “<span class="quote">text</span>” distribution
1584: sets must be installed. If you want to build X11-related
1585: packages the “<span class="quote">xbase</span>” and “<span class="quote">xcomp</span>”
1586: distribution sets are required, too.</p>
1587: </div>
1588: <div class="sect2" lang="en">
1589: <div class="titlepage"><div><div><h3 class="title">
1590: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
1591: <p>The first step for building a package is downloading the
1592: distfiles (i.e. the unmodified source). If they have not yet been
1593: downloaded, pkgsrc will fetch them automatically.</p>
1594: <p>You can overwrite some of the major distribution sites to fit to sites
1595: that are close to your own. Have a look at
1.76 ! rillig 1596: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find some examples
1.75 rillig 1597: — in particular, look for the <code class="varname">MASTER_SORT</code>,
1598: <code class="varname">MASTER_SORT_REGEX</code> and
1599: <code class="varname">INET_COUNTRY</code> definitions. This may save some of your
1600: bandwidth and time.</p>
1601: <p>You can change these settings either in your shell's environment, or,
1602: if you want to keep the settings, by editing the
1.76 ! rillig 1603: <code class="filename">/etc/mk.conf</code> file,
1.75 rillig 1604: and adding the definitions there.</p>
1605: <p>If you don't have a permanent Internet connection and you want to know
1606: which files to download, <span><strong class="command">make fetch-list</strong></span> will tell you
1607: what you'll need. Put these distfiles into
1.76 ! rillig 1608: <code class="filename">/usr/pkgsrc/distfiles</code>.</p>
1.75 rillig 1609: </div>
1610: <div class="sect2" lang="en">
1611: <div class="titlepage"><div><div><h3 class="title">
1612: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
1613: <p>Assuming that the distfile has been fetched (see previous section), become
1614: root and change into the relevant directory and run
1615: <span><strong class="command">make</strong></span>.</p>
1616: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1617: <h3 class="title">Note</h3>
1618: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
1619: use the pkgsrc <span><strong class="command">bmake</strong></span> command instead of
1620: “<span class="quote">make</span>” in the examples in this guide.</p>
1621: </div>
1622: <p>For example, type </p>
1623: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
1624: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong></pre>
1625: <p>at the shell prompt to build the various components of the
1626: package, and</p>
1627: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong></pre>
1628: <p>to install the various components into the correct places
1629: on your system. Installing the package on your system requires
1630: you to be root. However, pkgsrc has a
1631: <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
1632: to only become root for the actual installation step</p>
1633: <p>Taking the figlet utility as an example, we can install it on our
1634: system by building as shown in <a href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
1635: <p>The program is installed under the default root of the packages tree -
1.76 ! rillig 1636: <code class="filename">/usr/pkg</code>. Should this not conform to your tastes,
1.75 rillig 1637: set the <code class="varname">LOCALBASE</code>
1638: variable in your environment, and it will use that value as the root of
1.76 ! rillig 1639: your packages tree. So, to use <code class="filename">/usr/local</code>, set
1.75 rillig 1640: <code class="varname">LOCALBASE=/usr/local</code> in your environment. Please note
1641: that you should use a directory which is
1642: dedicated to packages and not shared with other programs (i.e., do not try
1643: and use <code class="varname">LOCALBASE=/usr</code>). Also, you should not try to
1.76 ! rillig 1644: add any of your own files or directories (such as <code class="filename">src/</code>,
! 1645: <code class="filename">obj/</code>, or <code class="filename">pkgsrc/</code>) below the
1.75 rillig 1646: <code class="varname">LOCALBASE</code> tree. This is to prevent possible conflicts
1647: between programs and other files installed by the package system and
1648: whatever else may have been installed there.</p>
1.76 ! rillig 1649: <p>Some packages look in <code class="filename">/etc/mk.conf</code> to alter some
1.75 rillig 1650: configuration options at build time. Have a look at
1.76 ! rillig 1651: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to
1.75 rillig 1652: get an overview of what will be set there by default. Environment
1653: variables such as <code class="varname">LOCALBASE</code>
1.76 ! rillig 1654: can be set in <code class="filename">/etc/mk.conf</code> to
1.75 rillig 1655: save having to remember to set them each time you want to use pkgsrc.</p>
1656: <p>Occasionally, people want to “<span class="quote">look under the covers</span>” to see
1657: what is going on when a package is building or being installed. This may be
1658: for debugging purposes, or out of simple curiosity. A number of utility
1659: values have been added to help with this.</p>
1660: <div class="orderedlist"><ol type="1">
1661: <li>
1662: <p>If you invoke the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> command with <code class="varname">PKG_DEBUG_LEVEL=2</code>,
1663: then a huge amount of information will be displayed. For example,</p>
1664: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
1665: <p>will show all the commands that are invoked, up to and including the
1666: “<span class="quote">patch</span>” stage.</p>
1667: </li>
1668: <li>
1669: <p>If you want to know the value of a certain <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> definition, then
1670: the <code class="varname">VARNAME</code> definition should be used, in conjunction
1671: with the show-var target. e.g. to show the expansion of the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> variable
1672: <code class="varname">LOCALBASE</code>:</p>
1673: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
1674: /usr/pkg
1675: <code class="prompt">%</code>
1676: </pre>
1677: </li>
1678: </ol></div>
1679: <p>If you want to install a binary package that you've either
1680: created yourself (see next section), that you put into pkgsrc/packages manually or
1681: that is located on a remote FTP server, you can use the "bin-install"
1682: target. This target will install a binary package - if available - via
1683: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>, else do a <span><strong class="command">make package</strong></span>.
1684: The list of remote
1685: FTP sites searched is kept in the variable
1686: <code class="varname">BINPKG_SITES</code>, which defaults to
1687: ftp.NetBSD.org. Any flags that should be added to <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> can be put
1688: into <code class="varname">BIN_INSTALL_FLAGS</code>.
1.76 ! rillig 1689: See <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more details.</p>
1.75 rillig 1690: <p>A final word of warning: If you set up a system that has a non-standard
1691: setting for <code class="varname">LOCALBASE</code>, be sure to set that
1692: before any packages are installed, as you can not use several directories
1693: for the same purpose. Doing so will result in pkgsrc not being able to
1694: properly detect your installed packages, and fail miserably. Note also that
1695: precompiled binary packages are usually built with the default
1696: <code class="varname">LOCALBASE</code> of
1.76 ! rillig 1697: <code class="filename">/usr/pkg</code>, and that you should <span class="emphasis"><em>not</em></span>
1.75 rillig 1698: install any if you use a non-standard <code class="varname">LOCALBASE</code>.</p>
1699: </div>
1700: <div class="sect2" lang="en">
1701: <div class="titlepage"><div><div><h3 class="title">
1702: <a name="selecting-the-compiler"></a>4.2.4. Selecting the compiler</h3></div></div></div>
1703: <p>By default, pkgsrc will use GCC to build packages. This may be
1704: overridden by setting the following variables in /etc/mk.conf:
1705: </p>
1706: <div class="variablelist"><dl>
1707: <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
1708: <dd>
1709: <p> This is a list of values specifying the chain of
1710: compilers to invoke when building packages. Valid values
1711: are: </p>
1712: <div class="itemizedlist"><ul type="disc">
1713: <li><p><code class="varname">distcc</code>:
1714: distributed C/C++ (chainable)</p></li>
1715: <li><p><code class="varname">ccache</code>:
1716: compiler cache (chainable)</p></li>
1717: <li><p><code class="varname">gcc</code>:
1718: GNU C/C++ Compiler</p></li>
1719: <li><p><code class="varname">mipspro</code>:
1720: Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
1721: <li><p><code class="varname">mipspro</code>:
1722: Silicon Graphics, Inc. MIPSpro (o32)</p></li>
1723: <li><p><code class="varname">sunpro</code>:
1724: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
1725: </ul></div>
1726: <p> The default is
1727: “<span class="quote"><code class="varname">gcc</code></span>”. You can use
1728: <code class="varname">ccache</code> and/or
1729: <code class="varname">distcc</code> with an appropriate
1730: <code class="varname">PKGSRC_COMPILER</code> setting,
1731: e.g. “<span class="quote"><code class="varname">ccache gcc</code></span>”. This
1732: variable should always be
1733: terminated with a value for a real compiler. </p>
1734: </dd>
1735: <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
1736: <dd><p> This specifies the minimum version of GCC to use
1737: when building packages. If the system GCC doesn't
1738: satisfy this requirement, then pkgsrc will build and
1739: install one of the GCC packages to use instead. </p></dd>
1740: </dl></div>
1741: </div>
1742: </div>
1743: </div>
1744: <div class="chapter" lang="en">
1745: <div class="titlepage"><div><div><h2 class="title">
1746: <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
1747: <div class="toc">
1748: <p><b>Table of Contents</b></p>
1749: <dl>
1750: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
1751: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1752: <dt><span class="sect1"><a href="#developer-advanced-settings">5.3. Developer/advanced settings</a></span></dt>
1753: <dt><span class="sect1"><a href="#selecting-build-options">5.4. Selecting Build Options</a></span></dt>
1754: </dl>
1755: </div>
1756: <div class="sect1" lang="en">
1757: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1758: <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
1759: <p>In this section, you can find some variables that apply to all
1760: pkgsrc packages. The preferred method of setting these variables
1.76 ! rillig 1761: is by setting them in <code class="filename">/etc/mk.conf</code>.
1.75 rillig 1762: </p>
1763: <div class="itemizedlist"><ul type="disc">
1764: <li><p><code class="varname">LOCALBASE</code>: Where
1765: packages will be installed. The default is
1.76 ! rillig 1766: <code class="filename">/usr/pkg</code>. Do not mix binary packages
1.75 rillig 1767: with different <code class="varname">LOCALBASE</code>s!</p></li>
1768: <li><p><code class="varname">CROSSBASE</code>: Where
1769: “<span class="quote">cross</span>” category packages will be
1770: installed. The default is
1.76 ! rillig 1771: <code class="filename">${LOCALBASE}/cross</code>.</p></li>
1.75 rillig 1772: <li><p><code class="varname">X11BASE</code>: Where
1773: X11 is installed on the system. The default is
1.76 ! rillig 1774: <code class="filename">/usr/X11R6</code>.</p></li>
1.75 rillig 1775: <li><p><code class="varname">DISTDIR</code>: Where to store the
1776: downloaded copies of the original source distributions used
1777: for building pkgsrc packages. The default is
1.76 ! rillig 1778: <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
1.75 rillig 1779: <li><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
1780: If set, override the packages'
1781: <code class="varname">MASTER_SITES</code> with this value.</p></li>
1782: <li><p><code class="varname">MASTER_SITE_BACKUP</code>:
1783: Backup location(s) for distribution files and patch files
1784: if not found locally or in
1.76 ! rillig 1785: <code class="filename">${MASTER_SITES}</code> or
! 1786: <code class="filename">${PATCH_SITES}</code> respectively.
1.75 rillig 1787: The defaults are
1.76 ! rillig 1788: <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
1.75 rillig 1789: and
1.76 ! rillig 1790: <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
1.75 rillig 1791: <li><p><code class="varname">BINPKG_SITES</code>:
1792: List of sites carrying binary pkgs.</p></li>
1793: </ul></div>
1794: <p>
1795: </p>
1796: </div>
1797: <div class="sect1" lang="en">
1798: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1799: <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
1800: <p>XXX
1801: </p>
1802: <div class="itemizedlist"><ul type="disc">
1803: <li><p><code class="varname">PACKAGES</code>: The top level
1804: directory for the binary packages. The default is
1.76 ! rillig 1805: <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
1.75 rillig 1806: <li><p><code class="varname">WRKOBJDIR</code>:
1807: The top level directory where, if defined, the separate
1808: working directories will get created, and symbolically
1.76 ! rillig 1809: linked to from <code class="filename">${WRKDIR}</code> (see below).
1.75 rillig 1810: This is useful for building packages on several
1.76 ! rillig 1811: architectures, then <code class="filename">${PKGSRCDIR}</code>
! 1812: can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
1.75 rillig 1813: is local to every architecture. (It should be noted that
1814: <code class="varname">PKGSRCDIR</code> should not be set by the user
1815: — it is an internal definition which refers to the
1816: root of the pkgsrc tree. It is possible to have many
1817: pkgsrc tree instances.)</p></li>
1818: <li><p><code class="varname">LOCALPATCHES</code>:
1819: Directory for local patches that aren't part of pkgsrc.
1820: See <a href="#components.patches" title="8.3. patches/*">Section 8.3, “patches/*”</a> for more
1821: information. <em class="replaceable"><code>rel</code></em> and
1822: <em class="replaceable"><code>arch</code></em> are replaced with OS
1823: release (“<span class="quote">2.0</span>”, etc.) and architecture
1824: (“<span class="quote">mipsel</span>”, etc.).</p></li>
1825: <li><p><code class="varname">PKGMAKECONF</code>: Location of
1.76 ! rillig 1826: the <code class="filename">mk.conf</code> file used by a package's
1.75 rillig 1827: BSD-style Makefile. If this is not set,
1828: <code class="varname">MAKECONF</code> is set to
1.76 ! rillig 1829: <code class="filename">/dev/null</code> to avoid picking up
! 1830: settings used by builds in <code class="filename">/usr/src</code>.</p></li>
1.75 rillig 1831: </ul></div>
1832: <p>
1833: </p>
1834: </div>
1835: <div class="sect1" lang="en">
1836: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1837: <a name="developer-advanced-settings"></a>5.3. Developer/advanced settings</h2></div></div></div>
1838: <p>XXX
1839: </p>
1840: <div class="itemizedlist"><ul type="disc">
1841: <li>
1842: <p><code class="varname">PKG_DEVELOPER</code>:
1843: Run some sanity checks that package developers want:
1844: </p>
1845: <div class="itemizedlist"><ul type="circle">
1846: <li><p>make sure patches apply with zero fuzz</p></li>
1847: <li><p>run check-shlibs to see that all binaries will
1848: find their shared libs.</p></li>
1849: </ul></div>
1850: <p>
1851: </p>
1852: </li>
1853: <li><p><code class="varname">PKG_DEBUG_LEVEL</code>:
1854: The level of debugging output which is displayed whilst
1855: making and installing the package.
1856: The default value for this is 0, which will not display
1857: the commands as they are executed (normal, default, quiet
1858: operation); the value 1 will display all shell commands
1859: before their invocation, and the value 2 will display both
1860: the shell commands before their invocation, and their
1861: actual execution progress with <span><strong class="command">set -x</strong></span>
1862: will be displayed.</p></li>
1863: <li><p><code class="varname">ALLOW_VULNERABILITIES.<em class="replaceable"><code>pkgbase</code></em></code>:
1864: A space separated list of vulnerability IDs that may be ignored when
1865: performing the automated security checks. These IDs are listed in the
1866: pkg-vulnerabilities file and are displayed by
1867: <span><strong class="command">audit-packages</strong></span> when
1868: it finds a vulnerable package.
1869: </p></li>
1870: <li><p><code class="varname">SKIP_AUDIT_PACKAGES</code>:
1871: If this is set to “<span class="quote">yes</span>”, the automated security checks
1.76 ! rillig 1872: (which use the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>
1.75 rillig 1873: package) will be <span class="strong"><strong>entirely</strong></span> skipped
1874: for <span class="strong"><strong>all</strong></span> packages built. Normally
1875: you'll want to use ALLOW_VULNERABILITIES instead of this.
1876: </p></li>
1877: </ul></div>
1878: <p>
1879: </p>
1880: </div>
1881: <div class="sect1" lang="en">
1882: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1883: <a name="selecting-build-options"></a>5.4. Selecting Build Options</h2></div></div></div>
1884: <p>Some packages have build time options, usually to select between
1885: different dependencies, enable optional support for big dependencies
1886: or enable experimental features.</p>
1887: <p>To see which options, if any, a package supports, and which
1888: options are mutually exclusive, run <span><strong class="command">make show-options</strong></span>,
1889: for example:</p>
1890: <pre class="programlisting">
1891: The following options are supported by this package:
1892: ssl Enable SSL support.
1893: Exactly one of the following gecko options is required:
1894: firefox Use firefox as gecko rendering engine.
1895: mozilla Use mozilla as gecko rendering engine.
1896: At most one of the following database options may be selected:
1897: mysql Enable support for MySQL database.
1898: pgsql Enable support for PostgreSQL database.
1.1 grant 1899:
1.75 rillig 1900: These options are enabled by default: firefox
1901: These options are currently enabled: mozilla ssl
1.1 grant 1902: </pre>
1.75 rillig 1903: <p>The following variables can be defined in
1.76 ! rillig 1904: <code class="filename">/etc/mk.conf</code> to select which options to enable
1.75 rillig 1905: for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which can be
1906: used to select or disable options for all packages that support them,
1907: and <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
1908: which can be used to select or disable options specifically for
1909: package <em class="replaceable"><code>pkgbase</code></em>. Options listed in these
1910: variables are selected, options preceded by “<span class="quote">-</span>” are
1911: disabled. A few examples:</p>
1912: <pre class="screen">
1913: <code class="prompt">$</code> <span><strong class="command">grep "PKG.*OPTION" /etc/mk.conf</strong></span>
1914: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
1915: PKG_OPTIONS.kdebase= debug -sasl
1916: PKG_OPTIONS.apache= suexec </pre>
1917: <p>The following settings are consulted in the order given, and the
1918: last setting that selects or disables an option is used:</p>
1919: <div class="orderedlist"><ol type="1">
1920: <li><p>the default options as suggested by the package
1921: maintainer</p></li>
1922: <li><p>the options implied by the settings of legacy
1923: variables (see below)</p></li>
1924: <li><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
1925: <li><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
1926: </ol></div>
1927: <p>For groups of mutually exclusive options, the last option
1928: selected is used, all others are automatically disabled. If an option
1929: of the group is explicitly disabled, the previously selected option,
1930: if any, is used. It is an error if no option from a required group of
1931: options is selected, and building the package will fail.</p>
1932: <p>Before the options framework was introduced, build options were
1933: selected by setting a variable (often named
1934: <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
1.76 ! rillig 1935: <code class="filename">/etc/mk.conf</code> for each option. To ease transition
1.75 rillig 1936: to the options framework for the user, these legacy variables are
1937: converted to the appropriate options setting
1938: (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
1939: automatically. A warning is issued to prompt the user to
1.76 ! rillig 1940: update <code class="filename">/etc/mk.conf</code> to use the options framework
1.75 rillig 1941: directly. Support for the legacy variables will be removed
1942: eventually.</p>
1943: </div>
1944: </div>
1945: <div class="chapter" lang="en">
1946: <div class="titlepage"><div><div><h2 class="title">
1947: <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
1948: <div class="toc">
1949: <p><b>Table of Contents</b></p>
1950: <dl>
1951: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
1952: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
1953: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
1954: <dd><dl>
1955: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
1956: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
1957: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
1958: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
1959: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
1960: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
1961: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
1962: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
1963: </dl></dd>
1964: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
1965: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
1966: </dl>
1967: </div>
1968: <div class="sect1" lang="en">
1969: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1970: <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
1971: <p>
1972: Once you have built and installed a package, you can create a
1973: <span class="emphasis"><em>binary package</em></span> which can be installed on
1974: another system with <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>. This saves having to build
1975: the same package on a group of hosts and wasting CPU time. It
1976: also provides a simple means for others to install your package,
1977: should you distribute it.
1978: </p>
1979: <p>
1980: To create a binary package, change into the appropriate
1981: directory in pkgsrc, and run <span><strong class="command">make
1982: package</strong></span>:
1983: </p>
1984: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
1985: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
1986: <p>
1987: This will build and install your package (if not already done),
1988: and then build a binary package from what was installed. You can
1989: then use the <span><strong class="command">pkg_*</strong></span> tools to manipulate
1990: it. Binary packages are created by default in
1.76 ! rillig 1991: <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
1.75 rillig 1992: gzipped tar file. See <a href="#logs.package" title="B.2. Packaging figlet">Section B.2, “Packaging figlet”</a> for a
1.76 ! rillig 1993: continuation of the above <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/misc/figlet/README.html" target="_top"><code class="filename">misc/figlet</code></a> example.</p>
1.75 rillig 1994: <p>
1995: See <a href="#submit" title="Chapter 18. Submitting and Committing">Chapter 18, <i>Submitting and Committing</i></a> for information on how to submit
1996: such a binary package.</p>
1997: </div>
1998: <div class="sect1" lang="en">
1999: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2000: <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
2001: <p>See <a href="#build.helpful-targets" title="14.16. Other helpful targets">Section 14.16, “Other helpful targets”</a>.</p>
2002: </div>
2003: <div class="sect1" lang="en">
2004: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2005: <a name="bulkbuild"></a>6.3. Doing a bulk build of all packages</h2></div></div></div>
2006: <p>If you want to get a full set of precompiled binary
2007: packages, this section describes how to get them. Beware that
2008: the bulk build will remove all currently installed packages from
2009: your system!</p>
2010: <p>Having an FTP server configured either on the
2011: machine doing the bulk builds or on a nearby NFS server can help
2012: to make the packages available to other machines that can then
2013: save time by installing only the binary packages. See <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ftpd+8+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ftpd</span>(8)</span></a> for
2014: more information. If you use a remote NFS server's storage, be
2015: sure to not actually compile on NFS storage, as this slows
2016: things down a lot.</p>
2017: <div class="sect2" lang="en">
2018: <div class="titlepage"><div><div><h3 class="title">
2019: <a name="binary.configuration"></a>6.3.1. Configuration</h3></div></div></div>
2020: <div class="sect3" lang="en">
2021: <div class="titlepage"><div><div><h4 class="title">
1.76 ! rillig 2022: <a name="binary.bulk.build.conf"></a>6.3.1.1. <code class="filename">build.conf</code></h4></div></div></div>
! 2023: <p>The <code class="filename">build.conf</code> file is the main
1.75 rillig 2024: configuration file for bulk builds. You can configure how your
2025: copy of pkgsrc is kept up to date, how the distfiles are
2026: downloaded, how the packages are built and how the report is
2027: generated. You can find an annotated example file in
1.76 ! rillig 2028: <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
! 2029: it, copy <code class="filename">build.conf-example</code> to
! 2030: <code class="filename">build.conf</code> and edit it, following the
1.75 rillig 2031: comments in that file.</p>
2032: </div>
2033: <div class="sect3" lang="en">
2034: <div class="titlepage"><div><div><h4 class="title">
2035: <a name="binary.mk.conf"></a>6.3.1.2. /etc/mk.conf</h4></div></div></div>
2036: <p>You may want to set variables in
1.76 ! rillig 2037: <code class="filename">/etc/mk.conf</code>.
! 2038: Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
1.75 rillig 2039: details of the default settings. You will want to ensure that
2040: <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
2041: As used in this example, <code class="varname">_ACCEPTABLE=yes</code>
2042: accepts <span class="emphasis"><em>all</em></span> licenses.</p>
2043: <pre class="programlisting">
2044: PACKAGES?= ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
2045: WRKOBJDIR?= /usr/tmp/pkgsrc # build here instead of in pkgsrc
2046: BSDSRCDIR= /usr/src
2047: BSDXSRCDIR= /usr/xsrc # for x11/xservers
2048: OBJHOSTNAME?= yes # use work.`hostname`
2049: FAILOVER_FETCH= yes # insist on the correct checksum
2050: PKG_DEVELOPER?= yes
2051: _ACCEPTABLE= yes
1.1 grant 2052: </pre>
1.75 rillig 2053: <p>Some options that are especially useful for bulk builds
2054: can be found at the top lines of the file
1.76 ! rillig 2055: <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
1.75 rillig 2056: options of these are briefly described here.</p>
2057: <div class="itemizedlist"><ul type="disc">
2058: <li><p>If you are on a slow machine, you may want to
2059: set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
2060: “<span class="quote">no</span>”.</p></li>
2061: <li><p>If you are doing bulk builds from a read-only
2062: copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
2063: to the directory where all log files are created. Otherwise the
2064: log files are created in the pkgsrc directory.</p></li>
2065: <li><p>Another important variable is
2066: <code class="varname">BULK_PREREQ</code>, which is a list of packages that
2067: should be always available while building other
2068: packages.</p></li>
2069: </ul></div>
2070: <p>Some other options are scattered in the pkgsrc
2071: infrastructure:</p>
2072: <div class="itemizedlist"><ul type="disc">
2073: <li><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
2074: should be set to <code class="literal">yes</code>. The purpose of the bulk
2075: builds is creating binary packages, no matter if they are
2076: vulnerable or not. When uploading the packages to a public
2077: server, the vulnerable packages will be put into a directory of
2078: their own. Leaving this variable unset would prevent the bulk
2079: build system from even trying to build them, so possible
2080: building errors would not show up.</p></li>
2081: <li><p><code class="varname">CHECK_FILES</code>
1.76 ! rillig 2082: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75 rillig 2083: “<span class="quote">yes</span>” to check that the installed set of files
1.76 ! rillig 2084: matches the <code class="filename">PLIST</code>.</p></li>
1.75 rillig 2085: <li><p><code class="varname">CHECK_INTERPRETER</code>
1.76 ! rillig 2086: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75 rillig 2087: “<span class="quote">yes</span>” to check that the installed
2088: “<span class="quote">#!</span>”-scripts will find their
2089: interpreter.</p></li>
2090: </ul></div>
2091: </div>
2092: <div class="sect3" lang="en">
2093: <div class="titlepage"><div><div><h4 class="title">
1.76 ! rillig 2094: <a name="pre-build.local"></a>6.3.1.3. <code class="filename">pre-build.local</code></h4></div></div></div>
1.75 rillig 2095: <p>It is possible to configure the bulk build to perform
2096: certain site-specific tasks at the end of the pre-build
2097: stage. If the file
1.76 ! rillig 2098: <code class="filename">pre-build.local</code> exists in
! 2099: <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
1.75 rillig 2100: (as a <a href="http://netbsd.gw.com/cgi-bin/man-cgi?sh+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">sh</span>(1)</span></a> script) at the end of the usual pre-build
2101: stage. An example use of
1.76 ! rillig 2102: <code class="filename">pre-build.local</code> is to have the line:</p>
1.75 rillig 2103: <pre class="screen">echo "I do not have enough disk space to build this pig." \
2104: > misc/openoffice/$BROKENF</pre>
2105: <p>to prevent the system from trying to build a particular package
2106: which requires nearly 3 GB of disk space.</p>
2107: </div>
2108: </div>
2109: <div class="sect2" lang="en">
2110: <div class="titlepage"><div><div><h3 class="title">
2111: <a name="other-environmental-considerations"></a>6.3.2. Other environmental considerations</h3></div></div></div>
1.76 ! rillig 2112: <p>As <code class="filename">/usr/pkg</code> will be completely
1.75 rillig 2113: deleted at the start of bulk builds, make sure your login
2114: shell is placed somewhere else. Either drop it into
1.76 ! rillig 2115: <code class="filename">/usr/local/bin</code> (and adjust your login
1.75 rillig 2116: shell in the passwd file), or (re-)install it via
1.76 ! rillig 2117: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> from <code class="filename">/etc/rc.local</code>, so
1.75 rillig 2118: you can login after a reboot (remember that your current
2119: process won't die if the package is removed, you just can't
2120: start any new instances of the shell any more). Also, if you
2121: use NetBSD earlier than 1.5, or you still want to use the pkgsrc
2122: version of ssh for some reason, be sure to install ssh before
1.76 ! rillig 2123: starting it from <code class="filename">rc.local</code>:</p>
1.75 rillig 2124: <pre class="programlisting">
2125: ( cd /usr/pkgsrc/security/ssh ; make bulk-install )
2126: if [ -f /usr/pkg/etc/rc.d/sshd ]; then
2127: /usr/pkg/etc/rc.d/sshd
2128: fi
1.1 grant 2129: </pre>
1.75 rillig 2130: <p>Not doing so will result in you being not able to log in
2131: via ssh after the bulk build is finished or if the machine
2132: gets rebooted or crashes. You have been warned! :)</p>
2133: </div>
2134: <div class="sect2" lang="en">
2135: <div class="titlepage"><div><div><h3 class="title">
2136: <a name="operation"></a>6.3.3. Operation</h3></div></div></div>
2137: <p>Make sure you don't need any of the packages still
2138: installed.
2139: </p>
2140: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
2141: <h3 class="title">Warning</h3>
2142: <p>During the bulk build, <span class="emphasis"><em>all packages will be
2143: removed!</em></span></p>
2144: </div>
2145: <p>Be sure to remove all other things that might
2146: interfere with builds, like some libs installed in
1.76 ! rillig 2147: <code class="filename">/usr/local</code>, etc. then become root and type:</p>
1.75 rillig 2148: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2149: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong></pre>
2150: <p>If for some reason your last build didn't complete (power
2151: failure, system panic, ...), you can continue it by
2152: running:</p>
2153: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
2154: <p>
2155: At the end of the bulk build, you will get a summary via mail,
2156: and find build logs in the directory specified by
1.76 ! rillig 2157: <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
1.75 rillig 2158: file.
2159: </p>
2160: </div>
2161: <div class="sect2" lang="en">
2162: <div class="titlepage"><div><div><h3 class="title">
2163: <a name="what-it-does"></a>6.3.4. What it does</h3></div></div></div>
2164: <p>The bulk builds consist of three steps:</p>
2165: <div class="variablelist"><dl>
2166: <dt><span class="term">1. pre-build</span></dt>
2167: <dd><p>
2168: The script updates your pkgsrc tree via (anon)cvs, then
2169: cleans out any broken distfiles, and removes all
2170: packages installed.</p></dd>
2171: <dt><span class="term">2. the bulk build</span></dt>
2172: <dd><p>
2173: This is basically “<span class="quote">make bulk-package</span>” with
2174: an optimised order in which packages will be
2175: built. Packages that don't require other packages will
2176: be built first, and packages with many dependencies will
2177: be built later.
2178: </p></dd>
2179: <dt><span class="term">3. post-build</span></dt>
2180: <dd><p>
2181: Generates a report that's placed in the directory
1.76 ! rillig 2182: specified in the <code class="filename">build.conf</code> file
! 2183: named <code class="filename">broken.html</code>, a short version
1.75 rillig 2184: of that report will also be mailed to the build's
2185: admin.</p></dd>
2186: </dl></div>
2187: <p>
2188: During the build, a list of broken packages will be compiled
1.76 ! rillig 2189: in <code class="filename">/usr/pkgsrc/.broken</code> (or
! 2190: <code class="filename">.../.broken.${MACHINE}</code> if
1.75 rillig 2191: <code class="varname">OBJMACHINE</code> is set), individual build logs
2192: of broken builds can be found in the package's
2193: directory. These files are used by the bulk-targets to mark
2194: broken builds to not waste time trying to rebuild them, and
2195: they can be used to debug these broken package builds
2196: later.
2197: </p>
2198: </div>
2199: <div class="sect2" lang="en">
2200: <div class="titlepage"><div><div><h3 class="title">
2201: <a name="disk-space-requirements"></a>6.3.5. Disk space requirements</h3></div></div></div>
2202: <p>Currently, roughly the following requirements are valid for
2203: NetBSD 2.0/i386:</p>
2204: <div class="itemizedlist"><ul type="disc">
2205: <li><p>
2206: 10 GB - distfiles (NFS ok)
2207: </p></li>
2208: <li><p>
2209: 8 GB - full set of all binaries (NFS ok)
2210: </p></li>
2211: <li><p>
2212: 5 GB - temp space for compiling (local disk recommended)
2213: </p></li>
2214: </ul></div>
2215: <p>
2216: Note that all pkgs will be de-installed as soon as they are
2217: turned into a binary package, and that sources are removed,
2218: so there is no excessively huge demand to disk
2219: space. Afterwards, if the package is needed again, it will
2220: be installed via <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> instead of building again, so
2221: there are no cycles wasted by recompiling.
2222: </p>
2223: </div>
2224: <div class="sect2" lang="en">
2225: <div class="titlepage"><div><div><h3 class="title">
2226: <a name="setting-up-a-sandbox"></a>6.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
2227: <p>
2228: If you don't want all the packages nuked from a machine
2229: (rendering it useless for anything but pkg compiling), there
2230: is the possibility of doing the package bulk build inside a
2231: chroot environment.
2232: </p>
2233: <p>
2234: The first step is to set up a chroot sandbox,
1.76 ! rillig 2235: e.g. <code class="filename">/usr/sandbox</code>. This can be done by
1.75 rillig 2236: using null mounts, or manually.
2237: </p>
2238: <p>
2239: There is a shell script called
1.76 ! rillig 2240: <code class="filename">pkgsrc/mk/bulk/mksandbox</code> which will set
1.75 rillig 2241: up the sandbox environment using null mounts. It will also
1.76 ! rillig 2242: create a script called <code class="filename">sandbox</code> in the
1.75 rillig 2243: root of the sandbox environment, which will allow the null
2244: mounts to be activated using the <span><strong class="command">sandbox
2245: mount</strong></span> command and deactivated using the
2246: <span><strong class="command">sandbox umount</strong></span> command.
2247: </p>
2248: <p>
2249: To set up a sandbox environment by hand, after extracting all
2250: the sets from a NetBSD installation or doing a <span><strong class="command">make
2251: distribution DESTDIR=/usr/sandbox</strong></span> in
1.76 ! rillig 2252: <code class="filename">/usr/src/etc</code>, be sure the following items
1.75 rillig 2253: are present and properly configured:
2254: </p>
2255: <div class="procedure"><ol type="1">
2256: <li>
2257: <p>Kernel</p>
2258: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
2259: </li>
2260: <li>
1.76 ! rillig 2261: <p><code class="filename">/dev/*</code></p>
1.75 rillig 2262: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
2263: </li>
2264: <li>
1.76 ! rillig 2265: <p><code class="filename">/etc/resolv.conf</code> (for <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/smtpd/README.html" target="_top"><code class="filename">security/smtpd</code></a> and mail):</p>
1.75 rillig 2266: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
2267: </li>
2268: <li>
2269: <p>Working(!) mail config (hostname, sendmail.cf):</p>
2270: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
2271: </li>
2272: <li>
1.76 ! rillig 2273: <p><code class="filename">/etc/localtime</code> (for <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/smtpd/README.html" target="_top"><code class="filename">security/smtpd</code></a>):</p>
1.75 rillig 2274: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
2275: </li>
2276: <li>
1.76 ! rillig 2277: <p><code class="filename">/usr/src</code> (system sources,
! 2278: e. g. for <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/sysutils/aperture/README.html" target="_top"><code class="filename">sysutils/aperture</code></a>):</p>
1.75 rillig 2279: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
2280: <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
2281: </li>
2282: <li>
1.76 ! rillig 2283: <p>Create <code class="filename">/var/db/pkg</code> (not part of default install):</p>
1.75 rillig 2284: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong></pre>
2285: </li>
2286: <li>
1.76 ! rillig 2287: <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
1.75 rillig 2288: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
2289: </li>
2290: <li>
2291: <p>Checkout pkgsrc via cvs into
1.76 ! rillig 2292: <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
1.75 rillig 2293: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
2294: <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong></pre>
2295: <p>Do not mount/link this to the copy of your pkgsrc tree
2296: you do development in, as this will likely cause problems!
2297: </p>
2298: </li>
2299: <li><p>Make
1.76 ! rillig 2300: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
! 2301: <code class="filename">.../distfiles</code> point somewhere
1.75 rillig 2302: appropriate. NFS- and/or nullfs-mounts may come in handy!
2303: </p></li>
1.76 ! rillig 2304: <li><p>Edit <code class="filename">/etc/mk.conf</code>, see <a href="#binary.mk.conf" title="6.3.1.2. /etc/mk.conf">Section 6.3.1.2, “/etc/mk.conf”</a>.</p></li>
! 2305: <li><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
1.75 rillig 2306: </ol></div>
2307: <p>When the chroot sandbox is set up, you can start
2308: the build with the following steps:</p>
2309: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2310: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong></pre>
2311: <p>
2312: This will just jump inside the sandbox and start building. At
2313: the end of the build, mail will be sent with the results of
2314: the build. Created binary pkgs will be in
1.76 ! rillig 2315: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
1.75 rillig 2316: (wherever that points/mounts to/from).</p>
2317: </div>
2318: <div class="sect2" lang="en">
2319: <div class="titlepage"><div><div><h3 class="title">
2320: <a name="building-a-partial-set"></a>6.3.7. Building a partial set of packages</h3></div></div></div>
2321: <p> In addition to building a complete set of all packages in
1.76 ! rillig 2322: pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
1.75 rillig 2323: may be used to build a subset of the packages contained in
2324: pkgsrc. By setting <code class="varname">SPECIFIC_PKGS</code>
1.76 ! rillig 2325: in <code class="filename">/etc/mk.conf</code>, the variables</p>
1.75 rillig 2326: <div class="itemizedlist"><ul type="disc">
2327: <li><p>SITE_SPECIFIC_PKGS</p></li>
2328: <li><p>HOST_SPECIFIC_PKGS</p></li>
2329: <li><p>GROUP_SPECIFIC_PKGS</p></li>
2330: <li><p>USER_SPECIFIC_PKGS</p></li>
2331: </ul></div>
2332: <p> will define the set of packages which should be built.
2333: The bulk build code will also include any packages which are
2334: needed as dependencies for the explicitly listed packages.
2335: </p>
2336: <p> One use of this is to do a bulk build with
2337: <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
2338: periodically to have a complete set of the binary packages
2339: needed for your site available without the overhead of
2340: building extra packages that are not needed. </p>
2341: </div>
2342: <div class="sect2" lang="en">
2343: <div class="titlepage"><div><div><h3 class="title">
2344: <a name="bulk-upload"></a>6.3.8. Uploading results of a bulk build</h3></div></div></div>
2345: <p>
2346: This section describes how pkgsrc developers can upload binary
2347: pkgs built by bulk builds to ftp.NetBSD.org.
2348: </p>
2349: <p>
2350: If you would like to automatically create checksum files for the
2351: binary packages you intend to upload, remember to set
2352: <code class="varname">MKSUMS=yes</code> in your
1.76 ! rillig 2353: <code class="filename">mk/bulk/build.conf</code>.
1.75 rillig 2354: </p>
2355: <p>
2356: If you would like to PGP sign the checksum files (highly
2357: recommended!), remember to set
2358: <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
1.76 ! rillig 2359: <code class="filename">mk/bulk/build.conf</code>. This will prompt you for
1.75 rillig 2360: your GPG password to sign the files before uploading everything.
2361: </p>
2362: <p>
2363: Then, make sure that you have <code class="varname">RSYNC_DST</code>
1.76 ! rillig 2364: set properly in your <code class="filename">mk/bulk/build.conf</code>
1.75 rillig 2365: file, i.e. adjust it to something like one of the following:
2366: </p>
2367: <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
2368: <p>Please use appropriate values for "pkgsrc-200xQy",
2369: "NetBSD-a.b.c" and "arch" here. If your login on ftp.NetBSD.org
2370: is different from your local login, write your login directly
2371: into the variable, e.g. my local account is "feyrer", but for my
2372: login "hubertf", I use:</p>
2373: <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
2374: <p>
1.76 ! rillig 2375: A separate <code class="filename">upload</code> directory is used
1.75 rillig 2376: here to allow "closing" the directory during upload. To do
2377: so, run the following command on ftp.NetBSD.org next:
2378: </p>
2379: <pre class="screen">nbftp% <strong class="userinput"><code>mkdir -p -m 750 /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload</code></strong></pre>
2380: <p>
1.76 ! rillig 2381: Please note that <code class="filename">/pub/NetBSD/packages</code> is
1.75 rillig 2382: only appropriate for packages for the NetBSD operating
2383: system. Binary packages for other operating systems should go
1.76 ! rillig 2384: into <code class="filename">/pub/pkgsrc</code>.
1.75 rillig 2385: </p>
2386: <p>
2387: Before uploading the binary pkgs, ssh authentication needs to
2388: be set up. This example shows how to set up temporary keys
2389: for the root account <span class="emphasis"><em>inside the sandbox</em></span>
2390: (assuming that no keys should be present there usually):
2391: </p>
2392: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
2393: chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
2394: chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t dsa</code></strong>
2395: chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong> </pre>
2396: <p>
1.76 ! rillig 2397: Now take the output of <code class="filename">id-dsa.pub</code> and
! 2398: append it to your <code class="filename">~/.ssh/authorized_keys</code>
1.75 rillig 2399: file on ftp.NetBSD.org. You can remove the key after the
2400: upload is done!
2401: </p>
2402: <p>
2403: Next, test if your ssh connection really works:
2404: </p>
2405: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
2406: <p>
2407: Use "-l yourNetBSDlogin" here as appropriate!
2408: </p>
2409: <p>
2410: Now after all this works, you can exit the sandbox and start
2411: the upload:
2412: </p>
2413: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
2414: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2415: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong> </pre>
2416: <p>
2417: The upload process may take quite some time. Use <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ls+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ls</span>(1)</span></a> or
2418: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?du+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">du</span>(1)</span></a> on the FTP server to monitor progress of the
2419: upload. The upload script will take care of not uploading
2420: restricted packages and putting vulnerable packages into the
1.76 ! rillig 2421: <code class="filename">vulnerable</code> subdirectory.
1.75 rillig 2422: </p>
2423: <p>
2424: After the upload has ended, first thing is to revoke ssh access:
2425: </p>
2426: <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
2427: Gdd:x! </pre>
2428: <p>
2429: Use whatever is needed to remove the key you've entered
2430: before! Last, move the uploaded packages out of the
1.76 ! rillig 2431: <code class="filename">upload</code> directory to have them accessible
1.75 rillig 2432: to everyone:
2433: </p>
2434: <pre class="screen">nbftp% <strong class="userinput"><code>cd /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch</code></strong>
2435: nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
2436: nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
2437: nbftp% <strong class="userinput"><code>chmod 755 .</code></strong> </pre>
2438: </div>
2439: </div>
2440: <div class="sect1" lang="en">
2441: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2442: <a name="creating-cdroms"></a>6.4. Creating a multiple CD-ROM packages collection</h2></div></div></div>
2443: <p>
2444: After your pkgsrc bulk-build has completed, you may wish to
2445: create a CD-ROM set of the resulting binary packages to assist
2446: in installing packages on other machines. The
1.76 ! rillig 2447: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/cdpack/README.html" target="_top"><code class="filename">pkgtools/cdpack</code></a> package provides
1.75 rillig 2448: a simple tool for creating the ISO 9660 images.
2449: <span><strong class="command">cdpack</strong></span> arranges the packages on the CD-ROMs in a
2450: way that keeps all the dependencies for a given package on the same
2451: CD as that package.
2452: </p>
2453: <div class="sect2" lang="en">
2454: <div class="titlepage"><div><div><h3 class="title">
2455: <a name="cdpack-example"></a>6.4.1. Example of cdpack</h3></div></div></div>
2456: <p>
2457: Complete documentation for cdpack is found in the cdpack(1)
2458: man page. The following short example assumes that the binary
2459: packages are left in
1.76 ! rillig 2460: <code class="filename">/usr/pkgsrc/packages/All</code> and that
! 2461: sufficient disk space exists in <code class="filename">/u2</code> to
1.75 rillig 2462: hold the ISO 9660 images.</p>
2463: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
2464: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
2465: <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong></pre>
2466: <p>
2467: If you wish to include a common set of files
1.76 ! rillig 2468: (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
1.75 rillig 2469: etc.) on each CD in the collection, then you need to create a
2470: directory which contains these files. e.g.
2471: </p>
2472: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
2473: <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" > /tmp/common/README</code></strong>
2474: <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" > /tmp/common/COPYING</code></strong>
2475: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
2476: <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" > /tmp/common/bin/myscript</code></strong>
2477: <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" >> /tmp/common/bin/myscript</code></strong>
2478: <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong></pre>
2479: <p>Now create the images:</p>
2480: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images</code></strong></pre>
1.76 ! rillig 2481: <p>Each image will contain <code class="filename">README</code>,
! 2482: <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
1.75 rillig 2483: in their root directories.</p>
2484: </div>
2485: </div>
2486: </div>
2487: <div class="chapter" lang="en">
2488: <div class="titlepage"><div><div><h2 class="title">
2489: <a name="faq"></a>Chapter 7. Frequently Asked Questions</h2></div></div></div>
2490: <div class="toc">
2491: <p><b>Table of Contents</b></p>
2492: <dl>
2493: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
2494: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
2495: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
2496: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
2497: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
2498: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
2499: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
2500: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
2501: <dt><span class="sect1"><a href="#passive-ftp">7.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
2502: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
2503: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
2504: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
2505: <dt><span class="sect1"><a href="#bsd.own.mk-missing">7.12. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</a></span></dt>
2506: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
2507: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
2508: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
2509: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
2510: </dl>
2511: </div>
2512: <p>This section contains hints, tips & tricks on special things in
2513: pkgsrc that we didn't find a better place for in the previous chapters, and
2514: it contains items for both pkgsrc users and developers.</p>
2515: <div class="sect1" lang="en">
2516: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2517: <a name="mailing-list-pointers"></a>7.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
2518: <p>The following mailing lists may be of interest to pkgsrc users:</p>
2519: <div class="itemizedlist"><ul type="disc">
2520: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a>:
2521: All bug reports in category "pkg" sent with <a href="http://netbsd.gw.com/cgi-bin/man-cgi?send-pr+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">send-pr</span>(1)</span></a> appear
2522: here. Please do not report your bugs here directly; use one
2523: of the other mailing lists.
2524: discussed.</p></li>
2525: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
2526: A list where the results of pkgsrc bulk builds are sent and
2527: discussed.</p></li>
2528: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
2529: This list is for those who are interested in getting a
2530: commit message for every change committed to pkgsrc. It is
2531: also available in digest form, meaning one daily message
2532: containing all commit messages for changes to the package
2533: source tree in that 24 hour period.</p></li>
2534: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">pkgsrc-users</a>:
2535: This is a general purpose list for most issues regarding
2536: pkgsrc, regardless of platform, e.g. soliciting user help
2537: for pkgsrc configuration, unexpected build failures, using
2538: particular packages, upgrading pkgsrc installations,
2539: questions regarding the pkgsrc release branches, etc. General announcements or
2540: proposals for changes that impact the pkgsrc user community,
2541: e.g. major infrastructure changes, new features, package
2542: removals, etc., may also be posted.</p></li>
2543: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">tech-pkg</a>:
2544: This is a list for technical discussions related to pkgsrc
2545: development, e.g. soliciting feedback for changes to pkgsrc
2546: infrastructure, proposed new features, questions related
2547: to porting pkgsrc to a new platform, advice for maintaining
2548: a package, patches that affect many packages, help requests
2549: moved from pkgsrc-users when an infrastructure bug is found,
2550: etc.</p></li>
2551: </ul></div>
2552: <p>To subscribe, do:</p>
2553: <pre class="programlisting">
2554: <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
2555: </pre>
2556: <p>Archives for all these mailing lists are available from
2557: <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
2558: </div>
2559: <div class="sect1" lang="en">
2560: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2561: <a name="pkgviews-docs"></a>7.2. Where's the pkgviews documentation?</h2></div></div></div>
2562: <p>Pkgviews is tightly integrated with buildlink. You can find a
2563: pkgviews User's guide in
1.76 ! rillig 2564: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
1.75 rillig 2565: </div>
2566: <div class="sect1" lang="en">
2567: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2568: <a name="faq-pkgtools"></a>7.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.76 ! rillig 2569: <p>The <code class="filename">pkgsrc/pkgtools</code> directory pkgtools contains
1.75 rillig 2570: a number of useful utilities for both users and developers of pkgsrc. This
2571: section attempts only to make the reader aware of the utilities and when
2572: they might be useful, and not to duplicate the documentation that comes
2573: with each package.</p>
2574: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
1.76 ! rillig 2575: <div class="itemizedlist"><ul type="disc"><li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/x11-links/README.html" target="_top"><code class="filename">pkgtools/x11-links</code></a>:
1.75 rillig 2576: Symlinks for use by buildlink.</p></li></ul></div>
2577: <p>OS tool augmentation (automatically installed when needed):</p>
2578: <div class="itemizedlist"><ul type="disc">
1.76 ! rillig 2579: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/digest/README.html" target="_top"><code class="filename">pkgtools/digest</code></a>:
1.75 rillig 2580: Calculates various kinds of checksums (including SHA1).</p></li>
1.76 ! rillig 2581: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/libnbcompat/README.html" target="_top"><code class="filename">pkgtools/libnbcompat</code></a>:
1.75 rillig 2582: Compatibility library for pkgsrc tools.</p></li>
1.76 ! rillig 2583: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/mtree/README.html" target="_top"><code class="filename">pkgtools/mtree</code></a>: Installed on
1.75 rillig 2584: non-BSD systems due to lack of native mtree.
2585: </p></li>
1.76 ! rillig 2586: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a>:
1.75 rillig 2587: Up-to-date replacement for
1.76 ! rillig 2588: <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
1.75 rillig 2589: systems where pkg_install is not present.</p></li>
2590: </ul></div>
2591: <p>Utilities used by pkgsrc (not automatically installed):</p>
2592: <div class="itemizedlist"><ul type="disc">
1.76 ! rillig 2593: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_tarup/README.html" target="_top"><code class="filename">pkgtools/pkg_tarup</code></a>:
1.75 rillig 2594: Create a binary package from an
2595: already-installed package. Used by <span><strong class="command">make replace</strong></span> to
2596: save the old package.</p></li>
1.76 ! rillig 2597: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/dfdisk/README.html" target="_top"><code class="filename">pkgtools/dfdisk</code></a>:
1.75 rillig 2598: Adds extra functionality to pkgsrc, allowing it to fetch distfiles
2599: from multiple locations. It currently supports the following
2600: methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
1.76 ! rillig 2601: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a>: Put X11
1.75 rillig 2602: packages someplace else (enabled by default).</p></li>
1.76 ! rillig 2603: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/cpuflags/README.html" target="_top"><code class="filename">devel/cpuflags</code></a>: Determine the
1.75 rillig 2604: best compiler flags to optimise code for your current CPU and
2605: compiler.</p></li>
2606: </ul></div>
2607: <p>Utilities for keeping track of installed packages, being up to date,
2608: etc:</p>
2609: <div class="itemizedlist"><ul type="disc">
1.76 ! rillig 2610: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_chk/README.html" target="_top"><code class="filename">pkgtools/pkg_chk</code></a>: Reports on
1.75 rillig 2611: packages whose installed versions do not match the latest pkgsrc
2612: entries.</p></li>
1.76 ! rillig 2613: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdep/README.html" target="_top"><code class="filename">pkgtools/pkgdep</code></a>: Makes
1.75 rillig 2614: dependency graphs of packages, to aid in choosing a strategy for
2615: updating.</p></li>
1.76 ! rillig 2616: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdepgraph/README.html" target="_top"><code class="filename">pkgtools/pkgdepgraph</code></a>: Makes
! 2617: graphs from the output of <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdep/README.html" target="_top"><code class="filename">pkgtools/pkgdep</code></a> (uses graphviz).</p></li>
! 2618: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>: The
1.75 rillig 2619: pkglint(1) program checks a pkgsrc entry for errors, lintpkgsrc(1)
2620: does various checks on the complete pkgsrc system.</p></li>
1.76 ! rillig 2621: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgsurvey/README.html" target="_top"><code class="filename">pkgtools/pkgsurvey</code></a>: Report what
1.75 rillig 2622: packages you have installed.</p></li>
2623: </ul></div>
2624: <p>Utilities for people maintaining or creating individual packages:</p>
2625: <div class="itemizedlist"><ul type="disc">
1.76 ! rillig 2626: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a>: Automate
1.75 rillig 2627: making and maintaining patches for a package (includes pkgdiff,
2628: pkgvi, mkpatches, etc.).</p></li>
1.76 ! rillig 2629: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/rpm2pkg/README.html" target="_top"><code class="filename">pkgtools/rpm2pkg</code></a>,
! 2630: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a>: Aids in
1.75 rillig 2631: converting to pkgsrc.</p></li>
1.76 ! rillig 2632: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/gensolpkg/README.html" target="_top"><code class="filename">pkgtools/gensolpkg</code></a>: Convert
1.75 rillig 2633: pkgsrc to a Solaris package.</p></li>
2634: </ul></div>
2635: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
2636: utilities)</p>
2637: <div class="itemizedlist"><ul type="disc">
1.76 ! rillig 2638: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_comp/README.html" target="_top"><code class="filename">pkgtools/pkg_comp</code></a>: Build
1.75 rillig 2639: packages in a chrooted area.</p></li>
1.76 ! rillig 2640: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/libkver/README.html" target="_top"><code class="filename">pkgtools/libkver</code></a>: Spoof
1.75 rillig 2641: kernel version for chrooted cross builds.</p></li>
2642: </ul></div>
2643: </div>
2644: <div class="sect1" lang="en">
2645: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2646: <a name="non-root-pkgsrc"></a>7.4. How to use pkgsrc as non-root</h2></div></div></div>
2647: <p>If you want to use pkgsrc as non-root user, you can set some
2648: variables to make pkgsrc work under these conditions. At the very least,
2649: you need to set <code class="varname">UNPRIVILEGED</code> to “<span class="quote">yes</span>”; this
2650: will turn on unprivileged mode and set multiple related variables to allow
2651: installation of packages as non-root.</p>
2652: <p>In case the defaults are not enough, you may want to tune some other
2653: variables used. For example, if the automatic user/group detection leads
2654: to incorrect values (or not the ones you would like to use), you can change
2655: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
2656: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
2657: <p>As regards bootstrapping, please note that the
2658: <span><strong class="command">bootstrap</strong></span> script will ease non-root configuration when
2659: given the “<span class="quote">--ignore-user-check</span>” flag, as it will choose and
1.76 ! rillig 2660: use multiple default directories under <code class="filename">~/pkg</code> as the
1.75 rillig 2661: installation targets. These directories can be overriden by the
2662: “<span class="quote">--prefix</span>” flag provided by the script, as well as some others
2663: that allow finer tuning of the tree layout.</p>
2664: </div>
2665: <div class="sect1" lang="en">
2666: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2667: <a name="resume-transfers"></a>7.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
2668: <p>By default, resuming transfers in pkgsrc is disabled, but you can
2669: enable this feature by adding the option
2670: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.76 ! rillig 2671: <code class="filename">/etc/mk.conf</code>. If, during a fetch step, an incomplete
1.75 rillig 2672: distfile is found, pkgsrc will try to resume it.</p>
2673: <p>You can also
2674: use a different program than the default <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ftp+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ftp</span>(1)</span></a> by changing the
2675: <code class="varname">FETCH_CMD</code> variable. Don't forget to set
2676: <code class="varname">FETCH_RESUME_ARGS</code> and
2677: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
2678: values.</p>
2679: <p>For example, if you want to use
1.76 ! rillig 2680: <code class="filename">wget</code> to resume downloads, you'll have to use something
1.75 rillig 2681: like:</p>
2682: <pre class="programlisting">
2683: FETCH_CMD= wget
2684: FETCH_BEFORE_ARGS= --passive-ftp
2685: FETCH_RESUME_ARGS= -c
2686: FETCH_OUTPUT_ARGS= -O
1.1 grant 2687: </pre>
1.75 rillig 2688: </div>
2689: <div class="sect1" lang="en">
2690: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2691: <a name="XFree86-from-pkgsrc"></a>7.6. How can I install/use XFree86 from pkgsrc?</h2></div></div></div>
2692: <p>If you want to use XFree86 from pkgsrc instead of your system's own
1.76 ! rillig 2693: X11 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>,
1.75 rillig 2694: ...), you will have to add the following line into
1.76 ! rillig 2695: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2696: <pre class="programlisting">
2697: X11_TYPE=XFree86
1.1 grant 2698: </pre>
1.75 rillig 2699: </div>
2700: <div class="sect1" lang="en">
2701: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2702: <a name="x.org-from-pkgsrc"></a>7.7. How can I install/use X.org from pkgsrc?</h2></div></div></div>
2703: <p>If you want to use X.org from pkgsrc instead of your system's own X11
1.76 ! rillig 2704: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
1.75 rillig 2705: you will have to add the following line into
1.76 ! rillig 2706: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2707: <pre class="programlisting">
2708: X11_TYPE=xorg
1.1 grant 2709: </pre>
1.75 rillig 2710: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
2711: <h3 class="title">Note</h3>
2712: <p>The DragonFly operating system defaults to using
2713: this X.org X11 implementation from pkgsrc.
2714: </p>
2715: </div>
2716: </div>
2717: <div class="sect1" lang="en">
2718: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2719: <a name="fetch-behind-firewall"></a>7.8. How to fetch files from behind a firewall</h2></div></div></div>
2720: <p>If you are sitting behind a firewall which does not allow direct
2721: connections to Internet hosts (i.e. non-NAT), you may specify the
2722: relevant proxy hosts. This is done using an environment variable in the
2723: form of a URL, e.g. in Amdahl, the machine
2724: “<span class="quote">orpheus.amdahl.com</span>” is one of the firewalls, and it uses
2725: port 80 as the proxy port number. So the proxy environment variables
2726: are:</p>
2727: <pre class="programlisting">
2728: ftp_proxy=ftp://orpheus.amdahl.com:80/
2729: http_proxy=http://orpheus.amdahl.com:80/
1.1 grant 2730: </pre>
1.75 rillig 2731: </div>
2732: <div class="sect1" lang="en">
2733: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2734: <a name="passive-ftp"></a>7.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</h2></div></div></div>
2735: <p>This depends on which utility is used to retrieve distfiles. From
1.76 ! rillig 2736: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
1.75 rillig 2737: the first available command from the following list:</p>
2738: <div class="itemizedlist"><ul type="disc">
1.76 ! rillig 2739: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
! 2740: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
1.75 rillig 2741: </ul></div>
2742: <p>On a default NetBSD installation, this will be
1.76 ! rillig 2743: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
1.75 rillig 2744: connections first, and falls back to active connections if the server
2745: refuses to do passive. For the other tools, add the following to your
1.76 ! rillig 2746: <code class="filename">/etc/mk.conf</code> file:
1.75 rillig 2747: <code class="varname">PASSIVE_FETCH=1</code>.</p>
2748: <p>Having that option present will prevent
1.76 ! rillig 2749: <code class="filename">/usr/bin/ftp</code> from falling back to active
1.75 rillig 2750: transfers.</p>
2751: </div>
2752: <div class="sect1" lang="en">
2753: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2754: <a name="fetching-all-distfiles"></a>7.10. How to fetch all distfiles at once</h2></div></div></div>
2755: <p>You would like to download all the distfiles in a single batch from
2756: work or university, where you can't run a <span><strong class="command">make fetch</strong></span>.
2757: There is an archive of distfiles on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/" target="_top">ftp.NetBSD.org</a>,
2758: but downloading the entire directory may not be appropriate.</p>
2759: <p>The answer here is to do a <span><strong class="command">make fetch-list</strong></span> in
1.76 ! rillig 2760: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
1.75 rillig 2761: resulting list to your machine at work/school and use it there. If you
2762: don't have a NetBSD-compatible <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ftp+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ftp</span>(1)</span></a> (like tnftp) at work, don't
2763: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
2764: URL:</p>
2765: <p>At home:</p>
2766: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2767: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh</code></strong>
2768: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
2769: <p>At work:</p>
2770: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
1.76 ! rillig 2771: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
1.75 rillig 2772: home.</p>
2773: <p>If you have a machine running NetBSD, and you want to get
2774: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your machine
2775: architecture), you can do so by using the above-mentioned <span><strong class="command">make
2776: fetch-list</strong></span> approach, or fetch the distfiles directly by
2777: running:</p>
2778: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
2779: <p>If you even decide to ignore
2780: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
2781: by running:</p>
2782: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
2783: </div>
2784: <div class="sect1" lang="en">
2785: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2786: <a name="tmac.andoc-missing"></a>7.11. What does “<span class="quote">Don't know how to make
2787: /usr/share/tmac/tmac.andoc</span>” mean?</h2></div></div></div>
1.76 ! rillig 2788: <p>When compiling the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a>
1.75 rillig 2789: package, you get the error from make that it doesn't know how to make
1.76 ! rillig 2790: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
1.75 rillig 2791: you don't have installed the “<span class="quote">text</span>” set (nroff, ...) from
2792: the NetBSD base distribution on your machine. It is recommended to do
2793: that to format man pages.</p>
1.76 ! rillig 2794: <p>In the case of the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a> package, you
1.75 rillig 2795: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.76 ! rillig 2796: environment or in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 2797: </div>
2798: <div class="sect1" lang="en">
2799: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2800: <a name="bsd.own.mk-missing"></a>7.12. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</h2></div></div></div>
1.76 ! rillig 2801: <p> You didn't install the compiler set, <code class="filename">comp.tgz</code>,
1.75 rillig 2802: when you installed your NetBSD machine. Please get and install it, by
1.76 ! rillig 2803: extracting it in <code class="filename">/</code>:</p>
1.75 rillig 2804: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
2805: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
1.76 ! rillig 2806: <p><code class="filename">comp.tgz</code> is part of every NetBSD release. Get
1.75 rillig 2807: the one that corresponds to your release (determine via <span><strong class="command">uname
2808: -r</strong></span>).</p>
2809: </div>
2810: <div class="sect1" lang="en">
2811: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2812: <a name="using-sudo-with-pkgsrc"></a>7.13. Using 'sudo' with pkgsrc</h2></div></div></div>
2813: <p>When installing packages as non-root user and using the just-in-time
2814: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?su+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">su</span>(1)</span></a> feature of pkgsrc, it can become annoying to type in the root
2815: password for each required package installed. To avoid this, the sudo
2816: package can be used, which does password caching over a limited time. To
2817: use it, install sudo (either as binary package or from
1.76 ! rillig 2818: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/sudo/README.html" target="_top"><code class="filename">security/sudo</code></a>) and then put the following
! 2819: into your <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2820: <pre class="programlisting">
2821: .if exists(${LOCALBASE}/bin/sudo)
2822: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
2823: .endif
1.1 grant 2824: </pre>
1.75 rillig 2825: </div>
2826: <div class="sect1" lang="en">
2827: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2828: <a name="faq.conf"></a>7.14. How do I change the location of configuration files?</h2></div></div></div>
2829: <p>As the system administrator, you can choose where configuration files
2830: are installed. The default settings make all these files go into
1.76 ! rillig 2831: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
1.75 rillig 2832: be suboptimal depending on your expectations (e.g., a read-only,
2833: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
2834: configuration of the provided packages).</p>
2835: <p>In order to change the defaults, you can modify the
2836: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.76 ! rillig 2837: <code class="filename">/etc/mk.conf</code>) to point to your preferred configuration
! 2838: directory; some common examples include <code class="filename">/etc</code> or
! 2839: <code class="filename">/etc/pkg</code>.</p>
1.75 rillig 2840: <p>Furthermore, you can change this value on a per-package basis by
2841: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
2842: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
2843: package you would like to modify, that is, the contents of
2844: <code class="varname">PKGBASE</code>.</p>
2845: <p>Note that after changing these settings, you must rebuild and
2846: reinstall any affected packages.</p>
2847: </div>
2848: <div class="sect1" lang="en">
2849: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2850: <a name="audit-packages"></a>7.15. Automated security checks</h2></div></div></div>
2851: <p>Please be aware that there can often be bugs in third-party software,
2852: and some of these bugs can leave a machine vulnerable to exploitation by
2853: attackers. In an effort to lessen the exposure, the NetBSD packages team
2854: maintains a database of known-exploits to packages which have at one time
2855: been included in pkgsrc. The database can be downloaded automatically, and
2856: a security audit of all packages installed on a system can take place. To
1.76 ! rillig 2857: do this, install the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a> package. It has two
1.75 rillig 2858: components:</p>
2859: <div class="orderedlist"><ol type="1">
2860: <li>
2861: <p><span><strong class="command">download-vulnerability-list</strong></span>, an easy way to
2862: download a list of the security vulnerabilities information. This list
2863: is kept up to date by the NetBSD security officer and the NetBSD
2864: packages team, and is distributed from the NetBSD ftp server:</p>
2865: <p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/pkg-vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/pkg-vulnerabilities</a></p>
2866: </li>
2867: <li><p><span><strong class="command">audit-packages</strong></span>, an easy way to audit the
2868: current machine, checking each vulnerability which is known. If a
2869: vulnerable package is installed, it will be shown by output to stdout,
2870: including a description of the type of vulnerability, and a URL
2871: containing more information.</p></li>
2872: </ol></div>
1.76 ! rillig 2873: <p>Use of the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>
1.75 rillig 2874: package is strongly recommended! After
2875: “<span class="quote">audit-packages</span>” is installed, please read
2876: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
2877: audit-packages</code></strong>.</p>
2878: <p>If this package is installed, pkgsrc builds will use it to perform
2879: a security check before building any package. See
2880: <a href="#variables-affecting-build" title="5.2. Variables affecting the build process">Section 5.2, “Variables affecting the build process”</a> for ways to control this check.
2881: </p>
2882: </div>
2883: <div class="sect1" lang="en">
2884: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2885: <a name="ufaq-cflags"></a>7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
2886: <p>When you add your own preferences to the
2887: <code class="varname">CFLAGS</code> variable in your
1.76 ! rillig 2888: <code class="filename">mk.conf</code>, these flags are passed in
! 2889: environment variables to the <code class="filename">./configure</code>
1.75 rillig 2890: scripts and to <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>. Some package authors ignore the
2891: <code class="varname">CFLAGS</code> from the environment variable by
1.76 ! rillig 2892: overriding them in the <code class="filename">Makefile</code>s of their
1.75 rillig 2893: package.</p>
2894: <p>Currently there is no solution to this problem. If you
2895: really need the package to use your <code class="varname">CFLAGS</code>
2896: you should run <span><strong class="command">make patch</strong></span> in the package
1.76 ! rillig 2897: directory and then inspect any <code class="filename">Makefile</code> and
! 2898: <code class="filename">Makefile.in</code> for whether they define
1.75 rillig 2899: <code class="varname">CFLAGS</code> explicitly. Usually you can remove
2900: these lines. But be aware that some “<span class="quote">smart</span>”
2901: programmers write so bad code that it only works for the
2902: specific combination of <code class="varname">CFLAGS</code> they have
2903: chosen.</p>
2904: </div>
2905: </div>
2906: </div>
2907: <div class="part" lang="en">
2908: <div class="titlepage"><div><div><h1 class="title">
2909: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
2910: <div class="toc">
2911: <p><b>Table of Contents</b></p>
2912: <dl>
2913: <dt><span class="chapter"><a href="#components">8. Package components - files, directories and contents</a></span></dt>
2914: <dd><dl>
1.76 ! rillig 2915: <dt><span class="sect1"><a href="#components.Makefile">8.1. <code class="filename">Makefile</code></a></span></dt>
! 2916: <dt><span class="sect1"><a href="#components.distinfo">8.2. <code class="filename">distinfo</code></a></span></dt>
1.75 rillig 2917: <dt><span class="sect1"><a href="#components.patches">8.3. patches/*</a></span></dt>
2918: <dt><span class="sect1"><a href="#other-mandatory-files">8.4. Other mandatory files</a></span></dt>
2919: <dt><span class="sect1"><a href="#components.optional">8.5. Optional files</a></span></dt>
1.76 ! rillig 2920: <dt><span class="sect1"><a href="#work-dir">8.6. <code class="filename">work*</code></a></span></dt>
! 2921: <dt><span class="sect1"><a href="#files-dir">8.7. <code class="filename">files/*</code></a></span></dt>
1.75 rillig 2922: </dl></dd>
1.76 ! rillig 2923: <dt><span class="chapter"><a href="#makefile">9. Programming in <code class="filename">Makefile</code>s</a></span></dt>
1.75 rillig 2924: <dd><dl>
1.76 ! rillig 2925: <dt><span class="sect1"><a href="#makefile.variables">9.1. <code class="filename">Makefile</code> variables</a></span></dt>
1.75 rillig 2926: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">9.1.1. Naming conventions</a></span></dt></dl></dd>
2927: <dt><span class="sect1"><a href="#makefile.code">9.2. Code snippets</a></span></dt>
2928: <dd><dl>
2929: <dt><span class="sect2"><a href="#adding-to-list">9.2.1. Adding things to a list</a></span></dt>
2930: <dt><span class="sect2"><a href="#converting-internal-to-external">9.2.2. Converting an internal list into an external list</a></span></dt>
2931: <dt><span class="sect2"><a href="#passing-variable-to-shell">9.2.3. Passing variables to a shell command</a></span></dt>
2932: <dt><span class="sect2"><a href="#quoting-guideline">9.2.4. Quoting guideline</a></span></dt>
2933: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">9.2.5. Workaround for a bug in BSD Make</a></span></dt>
2934: </dl></dd>
2935: </dl></dd>
2936: <dt><span class="chapter"><a href="#plist">10. PLIST issues</a></span></dt>
2937: <dd><dl>
2938: <dt><span class="sect1"><a href="#rcs-id">10.1. RCS ID</a></span></dt>
1.76 ! rillig 2939: <dt><span class="sect1"><a href="#automatic-plist-generation">10.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
1.75 rillig 2940: <dt><span class="sect1"><a href="#print-PLIST">10.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
2941: <dt><span class="sect1"><a href="#plist.misc">10.4. Variable substitution in PLIST</a></span></dt>
2942: <dt><span class="sect1"><a href="#manpage-compression">10.5. Man page compression</a></span></dt>
2943: <dt><span class="sect1"><a href="#using-PLIST_SRC">10.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
2944: <dt><span class="sect1"><a href="#platform-specific-plist">10.7. Platform-specific and differing PLISTs</a></span></dt>
2945: <dt><span class="sect1"><a href="#faq.common-dirs">10.8. Sharing directories between packages</a></span></dt>
2946: </dl></dd>
2947: <dt><span class="chapter"><a href="#buildlink">11. Buildlink methodology</a></span></dt>
2948: <dd><dl>
2949: <dt><span class="sect1"><a href="#converting-to-buildlink3">11.1. Converting packages to use buildlink3</a></span></dt>
1.76 ! rillig 2950: <dt><span class="sect1"><a href="#creating-buildlink3.mk">11.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
1.75 rillig 2951: <dd><dl>
2952: <dt><span class="sect2"><a href="#anatomy-of-bl3">11.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
1.76 ! rillig 2953: <dt><span class="sect2"><a href="#updating-buildlink-depends">11.2.2. Updating <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code> in <code class="filename">buildlink3.mk</code> files</a></span></dt>
1.75 rillig 2954: </dl></dd>
1.76 ! rillig 2955: <dt><span class="sect1"><a href="#writing-builtin.mk">11.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
1.75 rillig 2956: <dd><dl>
1.76 ! rillig 2957: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">11.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
1.75 rillig 2958: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">11.3.2. Global preferences for native or pkgsrc software</a></span></dt>
2959: </dl></dd>
2960: </dl></dd>
2961: <dt><span class="chapter"><a href="#pkginstall">12. The pkginstall framework</a></span></dt>
2962: <dd><dl>
2963: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">12.1. Files and directories outside the installation prefix</a></span></dt>
2964: <dd><dl>
2965: <dt><span class="sect2"><a href="#dirs-outside-prefix">12.1.1. Directory manipulation</a></span></dt>
2966: <dt><span class="sect2"><a href="#files-outside-prefix">12.1.2. File manipulation</a></span></dt>
2967: </dl></dd>
2968: <dt><span class="sect1"><a href="#conf-files">12.2. Configuration files</a></span></dt>
2969: <dd><dl>
2970: <dt><span class="sect2"><a href="#conf-files-sysconfdir">12.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
2971: <dt><span class="sect2"><a href="#conf-files-configure">12.2.2. Telling the software where configuration files are</a></span></dt>
2972: <dt><span class="sect2"><a href="#conf-files-patching">12.2.3. Patching installations</a></span></dt>
2973: <dt><span class="sect2"><a href="#conf-files-disable">12.2.4. Disabling handling of configuration files</a></span></dt>
2974: </dl></dd>
2975: <dt><span class="sect1"><a href="#rcd-scripts">12.3. System startup scripts</a></span></dt>
2976: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">12.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
2977: <dt><span class="sect1"><a href="#users-and-groups">12.4. System users and groups</a></span></dt>
2978: <dt><span class="sect1"><a href="#shells">12.5. System shells</a></span></dt>
2979: <dd><dl><dt><span class="sect2"><a href="#shells-disable">12.5.1. Disabling shell registration</a></span></dt></dl></dd>
2980: <dt><span class="sect1"><a href="#fonts">12.6. Fonts</a></span></dt>
2981: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">12.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
2982: </dl></dd>
2983: <dt><span class="chapter"><a href="#options">13. Options handling</a></span></dt>
2984: <dd><dl>
2985: <dt><span class="sect1"><a href="#global-default-options">13.1. Global default options</a></span></dt>
1.76 ! rillig 2986: <dt><span class="sect1"><a href="#converting-to-options">13.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
1.75 rillig 2987: <dt><span class="sect1"><a href="#option-names">13.3. Option Names</a></span></dt>
2988: </dl></dd>
2989: <dt><span class="chapter"><a href="#build">14. The build process</a></span></dt>
2990: <dd><dl>
2991: <dt><span class="sect1"><a href="#build.intro">14.1. Introduction</a></span></dt>
2992: <dt><span class="sect1"><a href="#build.prefix">14.2. Program location</a></span></dt>
2993: <dt><span class="sect1"><a href="#build.builddirs">14.3. Directories used during the build process</a></span></dt>
2994: <dt><span class="sect1"><a href="#build.running">14.4. Running a phase</a></span></dt>
2995: <dt><span class="sect1"><a href="#build.fetch">14.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
2996: <dt><span class="sect1"><a href="#build.checksum">14.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
2997: <dt><span class="sect1"><a href="#build.extract">14.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
2998: <dt><span class="sect1"><a href="#build.patch">14.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
2999: <dt><span class="sect1"><a href="#build.tools">14.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
3000: <dt><span class="sect1"><a href="#build.wrapper">14.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
3001: <dt><span class="sect1"><a href="#build.configure">14.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
3002: <dt><span class="sect1"><a href="#build.build">14.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3003: <dt><span class="sect1"><a href="#build.test">14.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
3004: <dt><span class="sect1"><a href="#build.install">14.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3005: <dt><span class="sect1"><a href="#build.package">14.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
3006: <dt><span class="sect1"><a href="#build.helpful-targets">14.16. Other helpful targets</a></span></dt>
3007: </dl></dd>
3008: <dt><span class="chapter"><a href="#tools">15. Tools needed for building or running</a></span></dt>
3009: <dd><dl>
3010: <dt><span class="sect1"><a href="#pkgsrc-tools">15.1. Tools for pkgsrc builds</a></span></dt>
3011: <dt><span class="sect1"><a href="#package-tools">15.2. Tools needed by packages</a></span></dt>
3012: <dt><span class="sect1"><a href="#platform-tools">15.3. Tools provided by platforms</a></span></dt>
3013: </dl></dd>
3014: <dt><span class="chapter"><a href="#fixes">16. Making your package work</a></span></dt>
3015: <dd><dl>
3016: <dt><span class="sect1"><a href="#general-operation">16.1. General operation</a></span></dt>
3017: <dd><dl>
3018: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">16.1.1. How to pull in variables from /etc/mk.conf</a></span></dt>
3019: <dt><span class="sect2"><a href="#where-to-install-documentation">16.1.2. Where to install documentation</a></span></dt>
3020: <dt><span class="sect2"><a href="#restricted-packages">16.1.3. Restricted packages</a></span></dt>
3021: <dt><span class="sect2"><a href="#dependencies">16.1.4. Handling dependencies</a></span></dt>
3022: <dt><span class="sect2"><a href="#conflicts">16.1.5. Handling conflicts with other packages</a></span></dt>
3023: <dt><span class="sect2"><a href="#not-building-packages">16.1.6. Packages that cannot or should not be built</a></span></dt>
3024: <dt><span class="sect2"><a href="#undeletable-packages">16.1.7. Packages which should not be deleted, once installed</a></span></dt>
3025: <dt><span class="sect2"><a href="#security-handling">16.1.8. Handling packages with security problems</a></span></dt>
3026: <dt><span class="sect2"><a href="#compiler-bugs">16.1.9. How to handle compiler bugs</a></span></dt>
3027: <dt><span class="sect2"><a href="#bumping-pkgrevision">16.1.10. How to handle incrementing versions when fixing an existing package</a></span></dt>
3028: <dt><span class="sect2"><a href="#portability-of-packages">16.1.11. Portability of packages</a></span></dt>
3029: </dl></dd>
3030: <dt><span class="sect1"><a href="#downloading-issues">16.2. Possible downloading issues</a></span></dt>
3031: <dd><dl>
3032: <dt><span class="sect2"><a href="#no-plain-download">16.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
3033: <dt><span class="sect2"><a href="#modified-distfiles-same-name">16.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
3034: </dl></dd>
3035: <dt><span class="sect1"><a href="#configuration-gotchas">16.3. Configuration gotchas</a></span></dt>
3036: <dd><dl>
3037: <dt><span class="sect2"><a href="#fixes.libtool">16.3.1. Shared libraries - libtool</a></span></dt>
3038: <dt><span class="sect2"><a href="#using-libtool">16.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
3039: <dt><span class="sect2"><a href="#autoconf-automake">16.3.3. GNU Autoconf/Automake</a></span></dt>
3040: </dl></dd>
3041: <dt><span class="sect1"><a href="#fixes-build">16.4. Building the package</a></span></dt>
3042: <dd><dl>
3043: <dt><span class="sect2"><a href="#cpp-defines">16.4.1. CPP defines</a></span></dt>
3044: <dt><span class="sect2"><a href="#cpp-list-examples">16.4.2. Examples of CPP defines for some platforms</a></span></dt>
3045: <dt><span class="sect2"><a href="#cpp-list">16.4.3. Getting a list of CPP defines</a></span></dt>
3046: </dl></dd>
3047: <dt><span class="sect1"><a href="#package-specific-actions">16.5. Package specific actions</a></span></dt>
3048: <dd><dl>
3049: <dt><span class="sect2"><a href="#user-interaction">16.5.1. User interaction</a></span></dt>
3050: <dt><span class="sect2"><a href="#handling-licenses">16.5.2. Handling licenses</a></span></dt>
3051: <dt><span class="sect2"><a href="#installing-score-files">16.5.3. Installing score files</a></span></dt>
3052: <dt><span class="sect2"><a href="#perl-scripts">16.5.4. Packages containing perl scripts</a></span></dt>
3053: <dt><span class="sect2"><a href="#hardcoded-paths">16.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
3054: <dt><span class="sect2"><a href="#perl-modules">16.5.6. Packages installing perl modules</a></span></dt>
3055: <dt><span class="sect2"><a href="#faq.info-files">16.5.7. Packages installing info files</a></span></dt>
3056: <dt><span class="sect2"><a href="#manpages">16.5.8. Packages installing man pages</a></span></dt>
3057: <dt><span class="sect2"><a href="#gconf2-data-files">16.5.9. Packages installing GConf2 data files</a></span></dt>
3058: <dt><span class="sect2"><a href="#scrollkeeper-data-files">16.5.10. Packages installing scrollkeeper data files</a></span></dt>
3059: <dt><span class="sect2"><a href="#x11-fonts">16.5.11. Packages installing X11 fonts</a></span></dt>
3060: <dt><span class="sect2"><a href="#gtk2-modules">16.5.12. Packages installing GTK2 modules</a></span></dt>
3061: <dt><span class="sect2"><a href="#sgml-xml-data">16.5.13. Packages installing SGML or XML data</a></span></dt>
3062: <dt><span class="sect2"><a href="#mime-database">16.5.14. Packages installing extensions to the MIME database</a></span></dt>
3063: <dt><span class="sect2"><a href="#intltool">16.5.15. Packages using intltool</a></span></dt>
3064: <dt><span class="sect2"><a href="#startup-scripts">16.5.16. Packages installing startup scripts</a></span></dt>
3065: <dt><span class="sect2"><a href="#tex-packages">16.5.17. Packages installing TeX modules</a></span></dt>
3066: </dl></dd>
3067: <dt><span class="sect1"><a href="#feedback-to-author">16.6. Feedback to the author</a></span></dt>
3068: </dl></dd>
3069: <dt><span class="chapter"><a href="#debug">17. Debugging</a></span></dt>
3070: <dt><span class="chapter"><a href="#submit">18. Submitting and Committing</a></span></dt>
3071: <dd><dl>
3072: <dt><span class="sect1"><a href="#submitting-binary-packages">18.1. Submitting binary packages</a></span></dt>
3073: <dt><span class="sect1"><a href="#submitting-your-package">18.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
3074: <dt><span class="sect1"><a href="#general-notes-for-changes">18.3. General notes when adding, updating, or removing packages</a></span></dt>
3075: <dt><span class="sect1"><a href="#committing-importing">18.4. Committing: Importing a package into CVS</a></span></dt>
3076: <dt><span class="sect1"><a href="#updating-package">18.5. Updating a package to a newer version</a></span></dt>
3077: <dt><span class="sect1"><a href="#moving-package">18.6. Moving a package in pkgsrc</a></span></dt>
3078: </dl></dd>
3079: <dt><span class="chapter"><a href="#devfaq">19. Frequently Asked Questions</a></span></dt>
3080: </dl>
3081: </div>
3082: <div class="chapter" lang="en">
3083: <div class="titlepage"><div><div><h2 class="title">
3084: <a name="components"></a>Chapter 8. Package components - files, directories and contents</h2></div></div></div>
3085: <div class="toc">
3086: <p><b>Table of Contents</b></p>
3087: <dl>
1.76 ! rillig 3088: <dt><span class="sect1"><a href="#components.Makefile">8.1. <code class="filename">Makefile</code></a></span></dt>
! 3089: <dt><span class="sect1"><a href="#components.distinfo">8.2. <code class="filename">distinfo</code></a></span></dt>
1.75 rillig 3090: <dt><span class="sect1"><a href="#components.patches">8.3. patches/*</a></span></dt>
3091: <dt><span class="sect1"><a href="#other-mandatory-files">8.4. Other mandatory files</a></span></dt>
3092: <dt><span class="sect1"><a href="#components.optional">8.5. Optional files</a></span></dt>
1.76 ! rillig 3093: <dt><span class="sect1"><a href="#work-dir">8.6. <code class="filename">work*</code></a></span></dt>
! 3094: <dt><span class="sect1"><a href="#files-dir">8.7. <code class="filename">files/*</code></a></span></dt>
1.75 rillig 3095: </dl>
3096: </div>
3097: <p> Whenever you're preparing a package, there are a number of
3098: files involved which are described in the following
3099: sections. </p>
3100: <div class="sect1" lang="en">
3101: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.76 ! rillig 3102: <a name="components.Makefile"></a>8.1. <code class="filename">Makefile</code></h2></div></div></div>
1.75 rillig 3103: <p>Building, installation and creation of a binary package are all
1.76 ! rillig 3104: controlled by the package's <code class="filename">Makefile</code>.
! 3105: The <code class="filename">Makefile</code> describes various things about
1.75 rillig 3106: a package, for example from where to get it, how to configure,
3107: build, and install it.
3108: </p>
1.76 ! rillig 3109: <p>A package <code class="filename">Makefile</code> contains several
1.75 rillig 3110: sections that describe the package.</p>
3111: <p>In the first section there are the following variables, which
3112: should appear exactly in the order given here.
3113: </p>
3114: <div class="itemizedlist"><ul type="disc">
3115: <li><p><code class="varname">DISTNAME</code> is the basename of the
3116: distribution file to be downloaded from the package's
3117: website.</p></li>
3118: <li><p><code class="varname">PKGNAME</code> is the name of the
3119: package, as used by pkgsrc. You only need to provide it if it
3120: differs from <code class="varname">DISTNAME</code>. Usually it is the directory name together
3121: with the version number. It must match the regular expression
3122: <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
3123: starts with a letter or digit, and contains only letters, digits,
3124: dashes, underscores, dots and plus signs.</p></li>
3125: <li>
3126: <p><code class="varname">CATEGORIES</code> is a list of categories
3127: which the package fits in. You can choose any of the top-level
3128: directories of pkgsrc for it.</p>
3129: <p>Currently the following values are available for
3130: <code class="varname">CATEGORIES</code>. If more than
3131: one is used, they need to be separated by spaces:</p>
3132: <pre class="programlisting">
3133: archivers cross geography meta-pkgs security
3134: audio databases graphics misc shells
3135: benchmarks devel ham multimedia sysutils
3136: biology editors inputmethod net textproc
3137: cad emulators lang news time
3138: chat finance mail parallel wm
3139: comms fonts math pkgtools www
3140: converters games mbone print x11
1.1 grant 3141: </pre>
1.75 rillig 3142: </li>
3143: <li>
3144: <p><code class="varname">MASTER_SITES</code> is a list of URLs where
3145: the distribution files can be downloaded. Each URL must end with a
3146: slash.</p>
3147: <p>The <code class="varname">MASTER_SITES</code> may make use of
3148: the following predefined sites:</p>
3149: <pre class="programlisting">
3150: ${MASTER_SITE_APACHE}
3151: ${MASTER_SITE_BACKUP}
3152: ${MASTER_SITE_CYGWIN}
3153: ${MASTER_SITE_DEBIAN}
3154: ${MASTER_SITE_FREEBSD}
3155: ${MASTER_SITE_FREEBSD_LOCAL}
3156: ${MASTER_SITE_GNOME}
3157: ${MASTER_SITE_GNU}
3158: ${MASTER_SITE_GNUSTEP}
3159: ${MASTER_SITE_IFARCHIVE}
3160: ${MASTER_SITE_MOZILLA}
3161: ${MASTER_SITE_OPENOFFICE}
3162: ${MASTER_SITE_PERL_CPAN}
3163: ${MASTER_SITE_R_CRAN}
3164: ${MASTER_SITE_SOURCEFORGE}
3165: ${MASTER_SITE_SUNSITE}
3166: ${MASTER_SITE_SUSE}
3167: ${MASTER_SITE_TEX_CTAN}
3168: ${MASTER_SITE_XCONTRIB}
3169: ${MASTER_SITE_XEMACS}
1.74 rillig 3170: </pre>
1.75 rillig 3171: <p>If one of these predefined sites is chosen, you may
3172: want to specify a subdirectory of that
3173: site. Since these macros may expand to more than one
3174: actual site, you <span class="emphasis"><em>must</em></span> use the
3175: following construct to specify a subdirectory:</p>
3176: <pre class="programlisting">
3177: ${MASTER_SITE_GNU:=subdirectory/name/}
3178: ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1 grant 3179: </pre>
1.75 rillig 3180: <p>Note the trailing slash after the subdirectory name.</p>
3181: <p>If the package has multiple
3182: <code class="varname">DISTFILES</code> or multiple
3183: <code class="varname">PATCHFILES</code> from different
3184: sites, set <code class="varname">SITES.foo</code> to a list of URIs
3185: where file “<span class="quote">foo</span>” may be
3186: found. “<span class="quote">foo</span>” includes the suffix, e.g.:</p>
3187: <pre class="programlisting">
3188: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
3189: DISTFILES+= foo-file.tar.gz
3190: SITES.foo-file.tar.gz= \
3191: http://www.somewhere.com/somehow/ \
3192: http://www.somewhereelse.com/mirror/somehow/
1.1 grant 3193: </pre>
1.75 rillig 3194: </li>
3195: <li>
3196: <p><code class="varname">DISTFILES</code>: Name(s)
3197: of archive file(s) containing distribution. The default is
1.76 ! rillig 3198: <code class="filename">${DISTNAME}${EXTRACT_SUFX}</code>. Should only
1.75 rillig 3199: be set if you have more than one distfile.</p>
3200: <p>Note that the normal default setting of
3201: <code class="varname">DISTFILES</code> must be made explicit if you
3202: want to add to it (rather than replace it), as you usually
3203: would.</p>
3204: </li>
3205: <li><p><code class="varname">EXTRACT_SUFX</code>: Suffix of the
3206: distribution file, will be appended to
3207: <code class="varname">DISTNAME</code>. Defaults to
1.76 ! rillig 3208: <code class="filename">.tar.gz</code>.
1.75 rillig 3209: </p></li>
3210: </ul></div>
3211: <p>
3212: </p>
3213: <p>The second section contains information about separately
3214: downloaded patches, if any.
3215: </p>
3216: <div class="itemizedlist"><ul type="disc">
3217: <li><p><code class="varname">PATCHFILES:</code>
3218: Name(s) of additional files that contain distribution patches.
3219: There is no default. pkgsrc will look for them at
3220: <code class="varname">PATCH_SITES</code>.
3221: They will automatically be uncompressed before patching if
1.76 ! rillig 3222: the names end with <code class="filename">.gz</code> or
! 3223: <code class="filename">.Z</code>.</p></li>
1.75 rillig 3224: <li><p><code class="varname">PATCH_SITES</code>:
3225: Primary location(s) for distribution patch files (see
3226: <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
3227: </ul></div>
3228: <p>
3229: </p>
3230: <p>The third section contains the following variables.
3231: </p>
3232: <div class="itemizedlist"><ul type="disc">
3233: <li><p><code class="varname">MAINTAINER</code> is the email address
3234: of the person who feels responsible for this package, and who is
3235: most likely to look at problems or questions regarding this
3236: package which have been reported with <a href="http://netbsd.gw.com/cgi-bin/man-cgi?send-pr+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">send-pr</span>(1)</span></a>. Other
3237: developers should contact the <code class="varname">MAINTAINER</code> before
3238: making major changes to the package. When packaging a new program,
3239: set <code class="varname">MAINTAINER</code> to yourself. If you really can't
3240: maintain the package for future updates, set it to
3241: <code class="email"><<a href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>></code>.</p></li>
3242: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
3243: find more information about the package.</p></li>
3244: <li><p><code class="varname">COMMENT</code> is a one-line
3245: description of the package (should not include the package
3246: name).</p></li>
3247: </ul></div>
3248: <p>
3249: </p>
3250: <p>Other variables that affect the build:
3251: </p>
3252: <div class="itemizedlist"><ul type="disc"><li>
3253: <p><code class="varname">WRKSRC</code>: The directory where the
3254: interesting distribution files of the package are found. The
1.76 ! rillig 3255: default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
1.75 rillig 3256: works for most packages.</p>
3257: <p>If a package doesn't create a subdirectory for itself
3258: (most GNU software does, for instance), but extracts itself in
3259: the current directory, you should set <code class="varname">WRKSRC=
3260: ${WRKDIR}</code>.</p>
3261: <p>If a package doesn't create a subdirectory with the name
3262: of <code class="varname">DISTNAME</code> but some different name, set
3263: <code class="varname">WRKSRC</code> to point to the proper name in
1.76 ! rillig 3264: <code class="filename">${WRKDIR}</code>, for example <code class="varname">WRKSRC=
! 3265: ${WRKDIR}/${DISTNAME}/unix</code>. See <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/lang/tcl/README.html" target="_top"><code class="filename">lang/tcl</code></a> and <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/tk/README.html" target="_top"><code class="filename">x11/tk</code></a> for other examples.</p>
1.75 rillig 3266: <p>The name of the working directory created by pkgsrc is
3267: taken from the <code class="varname">WRKDIR_BASENAME</code> variable. By
1.76 ! rillig 3268: default, its value is <code class="filename">work</code>. If you want
1.75 rillig 3269: to use the same pkgsrc tree for building different kinds of
3270: binary packages, you can change the variable according to your
3271: needs. Two other variables handle common cases of setting
3272: <code class="varname">WRKDIR_BASENAME</code> individually. If
3273: <code class="varname">OBJHOSTNAME</code> is defined in
1.76 ! rillig 3274: <code class="filename">/etc/mk.conf</code>, the first component of the
1.75 rillig 3275: host's name is attached to the directory name. If
3276: <code class="varname">OBJMACHINE</code> is defined, the platform name is
1.76 ! rillig 3277: attached, which might look like <code class="filename">work.i386</code>
! 3278: or <code class="filename">work.sparc</code>.</p>
1.75 rillig 3279: </li></ul></div>
3280: <p>
3281: </p>
3282: <p>Please pay attention to the following gotchas:</p>
3283: <div class="itemizedlist"><ul type="disc">
3284: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are installed in
3285: compressed form by the package; see comment in
1.76 ! rillig 3286: <code class="filename">bsd.pkg.mk</code>.</p></li>
! 3287: <li><p>Replace <code class="filename">/usr/local</code> with
1.75 rillig 3288: “<span class="quote">${PREFIX}</span>” in all files (see patches, below).</p></li>
3289: <li><p>If the package installs any info files, see
3290: <a href="#faq.info-files" title="16.5.7. Packages installing info files">Section 16.5.7, “Packages installing info files”</a>.</p></li>
3291: </ul></div>
3292: </div>
3293: <div class="sect1" lang="en">
3294: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.76 ! rillig 3295: <a name="components.distinfo"></a>8.2. <code class="filename">distinfo</code></h2></div></div></div>
! 3296: <p>The <code class="filename">distinfo</code> file contains the message
1.75 rillig 3297: digest, or checksum, of each distfile needed for the package. This
3298: ensures that the distfiles retrieved from the Internet have not been
3299: corrupted during transfer or altered by a malign force to introduce
3300: a security hole. Due to recent rumor about weaknesses of digest
3301: algorithms, all distfiles are protected using both SHA1 and RMD160
3302: message digests, as well as the file size.</p>
1.76 ! rillig 3303: <p>The <code class="filename">distinfo</code> file also contains the
1.75 rillig 3304: checksums for all the patches found in the
1.76 ! rillig 3305: <code class="filename">patches</code> directory (see <a href="#components.patches" title="8.3. patches/*">Section 8.3, “patches/*”</a>).</p>
! 3306: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.75 rillig 3307: <span><strong class="command">make makedistinfo</strong></span> or <span><strong class="command">make mdi</strong></span>
3308: command.</p>
3309: <p>Some packages have different sets of distfiles depending on
1.76 ! rillig 3310: the platform, for example <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/navigator/README.html" target="_top"><code class="filename">www/navigator</code></a>). These are kept in the same
! 3311: <code class="filename">distinfo</code> file and care should be taken when
1.75 rillig 3312: upgrading such a package to ensure distfile information is not
3313: lost.</p>
3314: </div>
3315: <div class="sect1" lang="en">
3316: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3317: <a name="components.patches"></a>8.3. patches/*</h2></div></div></div>
3318: <p>This directory contains files that are used by the
3319: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?patch+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">patch</span>(1)</span></a> command to
3320: modify the sources as distributed in the distribution file into a form
3321: that will compile and run perfectly on NetBSD. The files are applied
3322: successively in alphabetic order (as returned by a shell
3323: “<span class="quote">patches/patch-*</span>” glob expansion), so
1.76 ! rillig 3324: <code class="filename">patch-aa</code> is applied before
! 3325: <code class="filename">patch-ab</code>, etc.</p>
! 3326: <p>The <code class="filename">patch-*</code> files should be in
1.75 rillig 3327: <span><strong class="command">diff -bu</strong></span> format, and apply without a fuzz to avoid
3328: problems. (To force patches to apply
3329: with fuzz you can set <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>).
3330: Furthermore, do not put changes for more than one file into a single
3331: patch file, as this will make future modifications more difficult.</p>
3332: <p>Similar, a file should be patched at most once, not several times by
3333: several different patches. If a file needs several patches, they should
3334: be combined into one file.</p>
3335: <p>One important thing to mention is to pay attention that no RCS IDs
3336: get stored in the patch files, as these will cause problems when
3337: later checked into the NetBSD CVS tree. Use the
3338: <span><strong class="command">pkgdiff</strong></span> from the
1.76 ! rillig 3339: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a> package to avoid
1.75 rillig 3340: these problems.</p>
3341: <p>For even more automation, we recommend using <span><strong class="command">mkpatches</strong></span> from the same
3342: package to make a whole set of patches. You just have to backup files
1.76 ! rillig 3343: before you edit them to <code class="filename">filename.orig</code>, e.g. with
1.75 rillig 3344: <span><strong class="command">cp -p filename filename.orig</strong></span> or, easier, by using
3345: <span><strong class="command">pkgvi</strong></span> again from the same package. If you upgrade a package
3346: this way, you can easily compare the new set of patches with the
3347: previously existing one with <span><strong class="command">patchdiff</strong></span>.</p>
3348: <p>When you have finished a package, remember to generate the checksums
3349: for the patch files by using the <span><strong class="command">make makepatchsum</strong></span>
1.76 ! rillig 3350: command, see <a href="#components.distinfo" title="8.2. distinfo">Section 8.2, “<code class="filename">distinfo</code>”</a>.</p>
1.75 rillig 3351: <p>When adding a patch that corrects a problem in the distfile (rather
3352: than e.g. enforcing pkgsrc's view of where man pages should go), send
3353: the patch as a bug report to the maintainer. This benefits
3354: non-pkgsrc users of the package, and usually enables removing
3355: the patch in future version.</p>
3356: <p>Patch files that are distributed by the author or other
3357: maintainers can be listed in
3358: <code class="varname">$PATCHFILES</code>. </p>
3359: <p>If it is desired to store any patches that should not be committed into
3360: pkgsrc, they can be kept outside the pkgsrc tree in the
1.76 ! rillig 3361: <code class="filename">$LOCALPATCHES</code>
1.75 rillig 3362: directory. The directory tree there is expected to have the same
3363: “<span class="quote">category/package</span>” structure as pkgsrc, and patches are
3364: expected to be stored inside these dirs (also known as
1.76 ! rillig 3365: <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
1.75 rillig 3366: example, if you want to keep a private patch for
1.76 ! rillig 3367: <code class="filename">pkgsrc/graphics/png</code>, keep
! 3368: it in <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
1.75 rillig 3369: files in the named directory are expected to be patch files, and
3370: <span class="emphasis"><em>they are applied after pkgsrc patches are applied</em></span>.</p>
3371: </div>
3372: <div class="sect1" lang="en">
3373: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3374: <a name="other-mandatory-files"></a>8.4. Other mandatory files</h2></div></div></div>
3375: <div class="variablelist"><dl>
1.76 ! rillig 3376: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
1.75 rillig 3377: <dd><p>A multi-line description of the piece of software. This should include
3378: any credits where they are due. Please bear in mind that others do not
3379: share your sense of humour (or spelling idiosyncrasies), and that others
3380: will read everything that you write here.</p></dd>
1.76 ! rillig 3381: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
1.75 rillig 3382: <dd><p>
3383: This file governs the files that are installed on your system: all the
3384: binaries, manual pages, etc. There are other directives which may be
3385: entered in this file, to control the creation and deletion of
3386: directories, and the location of inserted files.
3387: See <a href="#plist" title="Chapter 10. PLIST issues">Chapter 10, <i>PLIST issues</i></a> for more information. </p></dd>
3388: </dl></div>
3389: </div>
3390: <div class="sect1" lang="en">
3391: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3392: <a name="components.optional"></a>8.5. Optional files</h2></div></div></div>
3393: <div class="variablelist"><dl>
1.76 ! rillig 3394: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.75 rillig 3395: <dd><p>This shell script is invoked twice by <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>.
3396: First time after package
3397: extraction and before files are moved in place, the second time after
3398: the files to install are moved in place. This can be used to do any
3399: custom procedures not possible with @exec commands in
1.76 ! rillig 3400: <code class="filename">PLIST</code>. See
1.75 rillig 3401: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> and <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_create</span>(1)</span></a> for more information.</p></dd>
1.76 ! rillig 3402: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
1.75 rillig 3403: <dd><p>This script is executed before and after any files are removed. It is
3404: this script's responsibility to clean up any additional messy details
3405: around the package's installation, since all pkg_delete knows is how to
3406: delete the files created in the original distribution.
3407: See <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a>
3408: and <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_create</span>(1)</span></a> for more information.</p></dd>
1.76 ! rillig 3409: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
1.75 rillig 3410: <dd>
3411: <p>This file is displayed after installation of the package.
3412: Useful for things like legal notices on almost-free
3413: software and hints for updating config files after
3414: installing modules for apache, PHP etc.
3415: Please note that you can modify variables in it easily by using
3416: <code class="varname">MESSAGE_SUBST</code> in the package's
1.76 ! rillig 3417: <code class="filename">Makefile</code>:</p>
1.75 rillig 3418: <pre class="programlisting">
3419: MESSAGE_SUBST+= SOMEVAR="somevalue"
1.1 grant 3420: </pre>
1.75 rillig 3421: <p>replaces "${SOMEVAR}" with “<span class="quote">somevalue</span>” in
1.76 ! rillig 3422: <code class="filename">MESSAGE</code>.</p>
1.75 rillig 3423: </dd>
3424: </dl></div>
3425: </div>
3426: <div class="sect1" lang="en">
3427: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.76 ! rillig 3428: <a name="work-dir"></a>8.6. <code class="filename">work*</code></h2></div></div></div>
1.75 rillig 3429: <p>When you type <span><strong class="command">make</strong></span>, the distribution files are
3430: unpacked into the directory denoted by
3431: <code class="varname">WRKDIR</code>. It can be removed by running
3432: <span><strong class="command">make clean</strong></span>. Besides the sources, this
3433: directory is also used to keep various timestamp files.
3434: The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
1.76 ! rillig 3435: The default is <code class="filename">${.CURDIR}/work</code>
! 3436: or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
1.75 rillig 3437: if <code class="varname">OBJMACHINE</code> is set.</p>
3438: </div>
3439: <div class="sect1" lang="en">
3440: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.76 ! rillig 3441: <a name="files-dir"></a>8.7. <code class="filename">files/*</code></h2></div></div></div>
1.75 rillig 3442: <p>If you have any files that you wish to be placed in the package prior
3443: to configuration or building, you could place these files here and use
3444: a “<span class="quote">${CP}</span>” command in the
3445: “<span class="quote">pre-configure</span>” target to achieve
3446: this. Alternatively, you could simply diff the file against
1.76 ! rillig 3447: <code class="filename">/dev/null</code> and use the patch mechanism to manage
1.75 rillig 3448: the creation of this file.</p>
3449: </div>
3450: </div>
3451: <div class="chapter" lang="en">
3452: <div class="titlepage"><div><div><h2 class="title">
1.76 ! rillig 3453: <a name="makefile"></a>Chapter 9. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.75 rillig 3454: <div class="toc">
3455: <p><b>Table of Contents</b></p>
3456: <dl>
1.76 ! rillig 3457: <dt><span class="sect1"><a href="#makefile.variables">9.1. <code class="filename">Makefile</code> variables</a></span></dt>
1.75 rillig 3458: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">9.1.1. Naming conventions</a></span></dt></dl></dd>
3459: <dt><span class="sect1"><a href="#makefile.code">9.2. Code snippets</a></span></dt>
3460: <dd><dl>
3461: <dt><span class="sect2"><a href="#adding-to-list">9.2.1. Adding things to a list</a></span></dt>
3462: <dt><span class="sect2"><a href="#converting-internal-to-external">9.2.2. Converting an internal list into an external list</a></span></dt>
3463: <dt><span class="sect2"><a href="#passing-variable-to-shell">9.2.3. Passing variables to a shell command</a></span></dt>
3464: <dt><span class="sect2"><a href="#quoting-guideline">9.2.4. Quoting guideline</a></span></dt>
3465: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">9.2.5. Workaround for a bug in BSD Make</a></span></dt>
3466: </dl></dd>
3467: </dl>
3468: </div>
1.76 ! rillig 3469: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
1.75 rillig 3470: each of which forms a well-defined part of the pkgsrc system. Using
3471: the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> system as a programming language for a big system
3472: like pkgsrc requires some discipline to keep the code correct and
3473: understandable.</p>
1.76 ! rillig 3474: <p>The basic ingredients for <code class="filename">Makefile</code>
1.75 rillig 3475: programming are variables (which are actually macros) and shell
3476: commands. Among these shell commands may even be more complex ones
3477: like <a href="http://netbsd.gw.com/cgi-bin/man-cgi?awk+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">awk</span>(1)</span></a> programs. To make sure that every shell command runs
3478: as intended it is necessary to quote all variables correctly when they
3479: are used.</p>
3480: <p>This chapter describes some patterns, that appear quite often in
1.76 ! rillig 3481: <code class="filename">Makefile</code>s, including the pitfalls that come along
1.75 rillig 3482: with them.</p>
3483: <div class="sect1" lang="en">
3484: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.76 ! rillig 3485: <a name="makefile.variables"></a>9.1. <code class="filename">Makefile</code> variables</h2></div></div></div>
! 3486: <p><code class="filename">Makefile</code> variables contain strings that
1.75 rillig 3487: can be processed using the five operators ``='', ``+='', ``?='',
3488: ``:='', and ``!='', which are described in the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> man
3489: page.</p>
3490: <p>When a variable's value is parsed from a
1.76 ! rillig 3491: <code class="filename">Makefile</code>, the hash character ``#'' and the
1.75 rillig 3492: backslash character ``\'' are handled specially. If a backslash is
3493: followed by a newline, any whitespace immediately in front of the
3494: backslash, the backslash, the newline, and any whitespace
3495: immediately behind the newline are replaced with a single space. A
3496: backslash character and an immediately following hash character are
3497: replaced with a single hash character. Otherwise, the backslash is
3498: passed as is. In a variable assignment, any hash character that is
3499: not preceded by a backslash starts a comment that continues upto the
3500: end of the logical line.</p>
3501: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
3502: the only way to create a variable consisting of a single backslash
3503: is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
3504: <p>So far for defining variables. The other thing you can do with
3505: variables is evaluating them. A variable is evaluated when it is
3506: part of the right side of the ``:='' or the ``!='' operator, or
3507: directly before executing a shell command which the variable is part
3508: of. In all other cases, <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> performs lazy evaluation, that
3509: is, variables are not evaluated until there's no other way. The
3510: ``modifiers'' mentioned in the man page also evaluate the
3511: variable.</p>
3512: <p>Some of the modifiers split the string into words and then
3513: operate on the words, others operate on the string as a whole. When
3514: a string is split into words, it is split as you would expect
3515: it from <a href="http://netbsd.gw.com/cgi-bin/man-cgi?sh+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">sh</span>(1)</span></a>.</p>
3516: <p>No rule without exception—the <span><strong class="command">.for</strong></span>
3517: loop does not follow the shell quoting rules but splits at sequences
3518: of whitespace.</p>
3519: <p>There are several types of variables that should be handled
3520: differently. Strings and two types of lists.</p>
3521: <div class="itemizedlist"><ul type="disc">
3522: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
3523: characters. Nevertheless, you should restrict yourself to only
3524: using printable characters. Examples are
3525: <code class="varname">PREFIX</code> and
3526: <code class="varname">COMMENT</code>.</p></li>
3527: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
3528: are never exported to any shell command. Their elements are
3529: separated by whitespace. Therefore, the elements themselves cannot
3530: have embedded whitespace. Any other characters are allowed.
3531: Internal lists can be used in <span><strong class="command">.for</strong></span> loops.
3532: Examples are <code class="varname">DEPENDS</code> and
3533: <code class="varname">BUILD_DEPENDS</code>.</p></li>
3534: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
3535: may be exported to a shell command. Their elements can contain any
3536: characters, including whitespace. That's why they cannot be used
3537: in <span><strong class="command">.for</strong></span> loops. Examples are
3538: <code class="varname">DISTFILES</code> and
3539: <code class="varname">MASTER_SITES</code>.</p></li>
3540: </ul></div>
3541: <div class="sect2" lang="en">
3542: <div class="titlepage"><div><div><h3 class="title">
3543: <a name="makefile.variables.names"></a>9.1.1. Naming conventions</h3></div></div></div>
3544: <div class="itemizedlist"><ul type="disc">
3545: <li><p>All variable names starting with an underscore
3546: are reserved for use by the pkgsrc infrastructure. They shall
3547: not be used by package
1.76 ! rillig 3548: <code class="filename">Makefile</code>s.</p></li>
1.75 rillig 3549: <li><p>In <span><strong class="command">.for</strong></span> loops you should use
3550: lowercase variable names for the iteration
3551: variables.</p></li>
3552: <li><p>All list variables should have a ``plural''
3553: name, e.g. <code class="varname">PKG_OPTIONS</code> or
3554: <code class="varname">DISTFILES</code>.</p></li>
3555: </ul></div>
3556: </div>
3557: </div>
3558: <div class="sect1" lang="en">
3559: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3560: <a name="makefile.code"></a>9.2. Code snippets</h2></div></div></div>
3561: <p>This section presents you with some code snippets you should
3562: use in your own code. If you don't find anything appropriate here,
3563: you should test your code and add it here.</p>
3564: <div class="sect2" lang="en">
3565: <div class="titlepage"><div><div><h3 class="title">
3566: <a name="adding-to-list"></a>9.2.1. Adding things to a list</h3></div></div></div>
3567: <pre class="programlisting">
3568: STRING= foo * bar `date`
3569: INT_LIST= # empty
3570: ANOTHER_INT_LIST= apache-[0-9]*:../../www/apache
3571: EXT_LIST= # empty
3572: ANOTHER_EXT_LIST= a=b c=d
1.1 grant 3573:
1.75 rillig 3574: INT_LIST+= ${STRING} # 1
3575: INT_LIST+= ${ANOTHER_INT_LIST} # 2
3576: EXT_LIST+= ${STRING:Q} # 3
3577: EXT_LIST+= ${ANOTHER_EXT_LIST} # 4
1.1 grant 3578: </pre>
1.75 rillig 3579: <p>When you add a string to an external list (example 3), it
3580: must be quoted. In all other cases, you must not add a quoting
3581: level. You must not merge internal and external lists, unless you
3582: are sure that all entries are correctly interpreted in both
3583: lists.</p>
3584: </div>
3585: <div class="sect2" lang="en">
3586: <div class="titlepage"><div><div><h3 class="title">
3587: <a name="converting-internal-to-external"></a>9.2.2. Converting an internal list into an external list</h3></div></div></div>
3588: <pre class="programlisting">
3589: EXT_LIST= # empty
3590: .for i in ${INT_LIST}
3591: EXT_LIST+= ${i:Q}""
3592: .endfor
1.1 grant 3593: </pre>
1.75 rillig 3594: <p>This code converts the internal list
3595: <code class="varname">INT_LIST</code> into the external list
3596: <code class="varname">EXT_LIST</code>. As the elements of an internal list
3597: are unquoted they must be quoted here. The reason for appending
3598: <code class="varname">""</code> is explained below.</p>
3599: </div>
3600: <div class="sect2" lang="en">
3601: <div class="titlepage"><div><div><h3 class="title">
3602: <a name="passing-variable-to-shell"></a>9.2.3. Passing variables to a shell command</h3></div></div></div>
3603: <pre class="programlisting">
3604: STRING= foo bar < > * `date` $$HOME ' "
3605: EXT_LIST= string=${STRING:Q} x=second\ item
1.1 grant 3606:
1.75 rillig 3607: all:
3608: echo ${STRING} # 1
3609: echo "${STRING}" # 2
3610: echo "${STRING:Q}" # 3
3611: echo ${STRING:Q} # 4
3612: echo x${STRING:Q} | sed 1s,.,, # 5
3613: env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
1.1 grant 3614: </pre>
1.75 rillig 3615: <p>Example 1 leads to a syntax error in the shell, as the
3616: characters are just copied.</p>
3617: <p>Example 2 leads to a syntax error too, and if you leave out
3618: the last " character from <code class="varname">${STRING}</code>,
3619: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?date+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">date</span>(1)</span></a> will be executed. The <code class="varname">$HOME</code> shell
3620: variable would be evaluated, too.</p>
3621: <p>Example 3 outputs each space character preceded by a
3622: backslash (or not), depending on the implementation of the
3623: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">echo</span>(1)</span></a> command.</p>
3624: <p>Example 4 handles correctly every string that does not start
3625: with a dash. In that case, the result depends on the
3626: implementation of the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">echo</span>(1)</span></a> command. As long as you can
3627: guarantee that your input does not start with a dash, this form is
3628: appropriate.</p>
3629: <p>Example 5 handles even the case of a leading dash
3630: correctly.</p>
3631: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
3632: because the quoting has already been done when adding elements to
3633: the list.</p>
3634: <p>As internal lists shall not be passed to the shell, there is
3635: no example for it.</p>
3636: </div>
3637: <div class="sect2" lang="en">
3638: <div class="titlepage"><div><div><h3 class="title">
3639: <a name="quoting-guideline"></a>9.2.4. Quoting guideline</h3></div></div></div>
3640: <p>There are many possible sources of wrongly quoted variables.
3641: This section lists some of the commonly known ones.</p>
3642: <div class="itemizedlist"><ul type="disc">
3643: <li>
3644: <p>Whenever you use the value of a list, think
3645: about what happens to leading or trailing whitespace. If the
3646: list is a well-formed shell expression, you can apply the
3647: <code class="varname">:M*</code> modifier to strip leading and trailing
3648: whitespace from each word. The <code class="varname">:M</code> operator
3649: first splits its argument according to the rules of the shell,
3650: and then creates a new list consisting of all words that match
3651: the shell glob expression <code class="varname">*</code>, that is: all.
3652: One class of situations where this is needed is when adding a
3653: variable like <code class="varname">CPPFLAGS</code> to
3654: <code class="varname">CONFIGURE_ARGS</code>. If the configure script
3655: invokes other configure scripts, it strips the leading and
3656: trailing whitespace from the variable and then passes it to the
3657: other configure scripts. But these configure scripts expect the
3658: (child) <code class="varname">CPPFLAGS</code> variable to be the same as
3659: the parent <code class="varname">CPPFLAGS</code>. That's why we better
3660: pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
3661: here is how we do it:</p>
3662: <pre class="programlisting">
3663: CPPFLAGS= # empty
3664: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX:Q}\"
3665: CPPFLAGS+= ${MY_CPPFLAGS}
1.1 grant 3666:
1.75 rillig 3667: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
1.1 grant 3668:
1.75 rillig 3669: all:
3670: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
3671: echo x${CONFIGURE_ARGS}x # properly trimmed
1.1 grant 3672: </pre>
1.75 rillig 3673: </li>
3674: <li><p>The example above contains one bug: The
3675: <code class="varname">${PREFIX}</code> is a properly quoted shell
3676: expression, but there is the C compiler after it, which also
3677: expects a properly quoted string (this time in C syntax). The
3678: version above is therefore only correct if
3679: <code class="varname">${PREFIX}</code> does not have embedded backslashes
3680: or double quotes. If you want to allow these, you have to add
3681: another layer of quoting to each variable that is used as a C
3682: string literal. You cannot use the <code class="varname">:Q</code>
3683: operator for it, as this operator only works for the
3684: shell.</p></li>
3685: <li>
3686: <p>Whenever a variable can be empty, the
3687: <code class="varname">:Q</code> operator can have surprising results. Here
3688: are two completely different cases which can be solved with the
3689: same trick.</p>
3690: <pre class="programlisting">
3691: EMPTY= # empty
3692: empty_test:
3693: for i in a ${EMPTY:Q} c; do \
3694: echo "$$i"; \
3695: done
1.1 grant 3696:
1.75 rillig 3697: for_test:
3698: .for i in a:\ a:\test.txt
3699: echo ${i:Q}
3700: echo "foo"
3701: .endfor
1.1 grant 3702: </pre>
1.75 rillig 3703: <p>The first example will only print two of the three lines
3704: we might have expected. This is because
3705: <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
3706: the shell cannot see. The workaround is to write
3707: <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
3708: as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
3709: -f ${FNAME:Q}</code> (both of these are wrong).</p>
3710: <p>The second example will only print three lines instead of
3711: four. The first line looks like <code class="varname">a:\ echo foo</code>.
3712: This is because the backslash of the value
3713: <code class="varname">a:\</code> is interpreted as a line-continuation by
3714: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>, which makes the second line the arguments of the
3715: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">echo</span>(1)</span></a> command from the first line. To avoid this, write
3716: <code class="varname">${i:Q}""</code>.</p>
3717: </li>
3718: </ul></div>
3719: </div>
3720: <div class="sect2" lang="en">
3721: <div class="titlepage"><div><div><h3 class="title">
3722: <a name="bsd-make-bug-workaround"></a>9.2.5. Workaround for a bug in BSD Make</h3></div></div></div>
3723: <p>The pkgsrc bmake program does not handle the following
3724: assignment correctly. In case <code class="varname">_othervar_</code>
3725: contains a ``-'' character, one of the closing braces is included
3726: in <code class="varname">${VAR}</code> after this code executes.</p>
3727: <pre class="programlisting">
3728: VAR:= ${VAR:N${_othervar_:C/-//}}
1.1 grant 3729: </pre>
1.75 rillig 3730: <p>For a more complex code snippet and a workaround, see the
1.76 ! rillig 3731: package <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/regress/make-quoting/README.html" target="_top"><code class="filename">regress/make-quoting</code></a>, testcase
1.75 rillig 3732: <code class="varname">bug1</code>.</p>
3733: </div>
3734: </div>
3735: </div>
3736: <div class="chapter" lang="en">
3737: <div class="titlepage"><div><div><h2 class="title">
3738: <a name="plist"></a>Chapter 10. PLIST issues</h2></div></div></div>
3739: <div class="toc">
3740: <p><b>Table of Contents</b></p>
3741: <dl>
3742: <dt><span class="sect1"><a href="#rcs-id">10.1. RCS ID</a></span></dt>
1.76 ! rillig 3743: <dt><span class="sect1"><a href="#automatic-plist-generation">10.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
1.75 rillig 3744: <dt><span class="sect1"><a href="#print-PLIST">10.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
3745: <dt><span class="sect1"><a href="#plist.misc">10.4. Variable substitution in PLIST</a></span></dt>
3746: <dt><span class="sect1"><a href="#manpage-compression">10.5. Man page compression</a></span></dt>
3747: <dt><span class="sect1"><a href="#using-PLIST_SRC">10.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
3748: <dt><span class="sect1"><a href="#platform-specific-plist">10.7. Platform-specific and differing PLISTs</a></span></dt>
3749: <dt><span class="sect1"><a href="#faq.common-dirs">10.8. Sharing directories between packages</a></span></dt>
3750: </dl>
3751: </div>
1.76 ! rillig 3752: <p> The <code class="filename">PLIST</code> file contains a package's
1.75 rillig 3753: “<span class="quote">packing list</span>”, i.e. a list of files that belong to
1.76 ! rillig 3754: the package (relative to the <code class="filename">${PREFIX}</code>
1.75 rillig 3755: directory it's been installed in) plus some additional statements
3756: - see the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_create</span>(1)</span></a> man page for a full list.
3757: This chapter addresses some issues that need attention when
1.76 ! rillig 3758: dealing with the <code class="filename">PLIST</code> file (or files, see
1.75 rillig 3759: below!).</p>
3760: <div class="sect1" lang="en">
3761: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3762: <a name="rcs-id"></a>10.1. RCS ID</h2></div></div></div>
3763: <p>
3764: Be sure to add a RCS ID line as the first thing in any
1.76 ! rillig 3765: <code class="filename">PLIST</code> file you write:
1.75 rillig 3766: </p>
3767: <pre class="programlisting">
3768: @comment $NetBSD$
1.55 rillig 3769: </pre>
1.75 rillig 3770: </div>
3771: <div class="sect1" lang="en">
3772: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.76 ! rillig 3773: <a name="automatic-plist-generation"></a>10.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.75 rillig 3774: <p>You can use the <span><strong class="command">make print-PLIST</strong></span> command
3775: to output a PLIST that matches any new files since the package
3776: was extracted. See <a href="#build.helpful-targets" title="14.16. Other helpful targets">Section 14.16, “Other helpful targets”</a> for
3777: more information on this target.</p>
3778: </div>
3779: <div class="sect1" lang="en">
3780: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3781: <a name="print-PLIST"></a>10.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></h2></div></div></div>
3782: <p> If you have used any of the *-dirs packages, as explained in
3783: <a href="#faq.common-dirs" title="10.8. Sharing directories between packages">Section 10.8, “Sharing directories between packages”</a>, you may have noticed that
3784: <span><strong class="command">make print-PLIST</strong></span> outputs a set of
3785: <code class="varname">@comment</code>s instead of real
3786: <code class="varname">@dirrm</code> lines. You can also do this for
3787: specific directories and files, so that the results of that
3788: command are very close to reality. This helps <span class="emphasis"><em>a
3789: lot</em></span> during the update of packages. </p>
3790: <p> The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
3791: of AWK patterns and actions that are used to filter the output of
3792: print-PLIST. You can <span class="emphasis"><em>append</em></span> any chunk of AWK
3793: scripting you like to it, but be careful with quoting. </p>
3794: <p> For example, to get all files inside the
1.76 ! rillig 3795: <code class="filename">libdata/foo</code> directory removed from the
1.75 rillig 3796: resulting PLIST:</p>
3797: <pre class="programlisting">
3798: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
1.55 rillig 3799: </pre>
1.75 rillig 3800: <p> And to get all the <code class="varname">@dirrm</code> lines referring
3801: to a specific (shared) directory converted to
3802: <code class="varname">@comment</code>s: </p>
3803: <pre class="programlisting">
3804: PRINT_PLIST_AWK+= /^@dirrm share\/specific/ { print "@comment " $$0; next; }
1.51 rillig 3805: </pre>
1.75 rillig 3806: </div>
3807: <div class="sect1" lang="en">
3808: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3809: <a name="plist.misc"></a>10.4. Variable substitution in PLIST</h2></div></div></div>
3810: <p>
3811: A number of variables are substituted automatically in PLISTs
3812: when a package is installed on a system. This includes the
3813: following variables: </p>
3814: <div class="variablelist"><dl>
3815: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
3816: <dd>
3817: <p>Some packages like emacs and perl embed information
3818: about which architecture they were built on into the
3819: pathnames where they install their files. To handle this
3820: case, PLIST will be preprocessed before actually used, and
3821: the symbol
3822: “<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>” will be
3823: replaced by what <span><strong class="command">uname -p</strong></span> gives. The
3824: same is done if the string
3825: <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
3826: PLIST somewhere - use this on packages that have GNU
3827: autoconf-created configure scripts.</p>
3828: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
3829: <h3 class="title">Legacy note</h3>
3830: <p>There used to be a symbol
3831: “<span class="quote"><code class="varname">$ARCH</code></span>” that
3832: was replaced by the output of <span><strong class="command">uname
3833: -m</strong></span>, but that's no longer supported and has
3834: been removed.</p>
3835: </div>
3836: </dd>
3837: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
3838: <dd>
3839: <p>Some packages want to embed the OS name and version
3840: into some paths. To do this, use these variables in the
1.76 ! rillig 3841: <code class="filename">PLIST</code>:
1.75 rillig 3842: </p>
3843: <div class="itemizedlist"><ul type="disc">
3844: <li><p><code class="varname">${OPSYS}</code> - output of “<span class="quote"><span><strong class="command">uname -s</strong></span></span>”</p></li>
3845: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. “<span class="quote">solaris</span>”)</p></li>
3846: <li><p><code class="varname">${OS_VERSION}</code> - “<span class="quote"><span><strong class="command">uname -r</strong></span></span>”</p></li>
3847: </ul></div>
3848: </dd>
3849: </dl></div>
3850: <p> For a complete list of values which are replaced by
1.76 ! rillig 3851: default, please look in <code class="filename">bsd.pkg.mk</code> (and
1.75 rillig 3852: search for <span class="emphasis"><em>PLIST_SUBST</em></span>). </p>
3853: <p> If you want to change other variables not listed above, you
3854: can add variables and their expansions to this variable in the
3855: following way, similar to <code class="varname">MESSAGE_SUBST</code> (see <a href="#components.optional" title="8.5. Optional files">Section 8.5, “Optional files”</a>): </p>
3856: <pre class="programlisting">
3857: PLIST_SUBST+= SOMEVAR="somevalue"
1.1 grant 3858: </pre>
1.75 rillig 3859: <p>This replaces all occurrences of “<span class="quote">${SOMEVAR}</span>”
3860: in the PLIST with “<span class="quote">somevalue</span>”. </p>
3861: </div>
3862: <div class="sect1" lang="en">
3863: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3864: <a name="manpage-compression"></a>10.5. Man page compression</h2></div></div></div>
3865: <p>Man pages should be installed in compressed form if
1.76 ! rillig 3866: <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
1.75 rillig 3867: and uncompressed otherwise. To handle this in the
1.76 ! rillig 3868: <code class="filename">PLIST</code> file, the suffix “<span class="quote">.gz</span>” is
1.75 rillig 3869: appended/removed automatically for man pages according to
3870: <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
3871: or not, see above for details. This modification of the
1.76 ! rillig 3872: <code class="filename">PLIST</code> file is done on a copy of it, not
! 3873: <code class="filename">PLIST</code> itself.</p>
1.75 rillig 3874: </div>
3875: <div class="sect1" lang="en">
3876: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3877: <a name="using-PLIST_SRC"></a>10.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></h2></div></div></div>
1.76 ! rillig 3878: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
1.75 rillig 3879: in generating the binary package, set the variable
3880: <code class="varname">PLIST_SRC</code> to the names of that file(s).
3881: The files are later concatenated using <a href="http://netbsd.gw.com/cgi-bin/man-cgi?cat+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">cat</span>(1)</span></a>, and order of things is
3882: important.</p>
3883: </div>
3884: <div class="sect1" lang="en">
3885: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3886: <a name="platform-specific-plist"></a>10.7. Platform-specific and differing PLISTs</h2></div></div></div>
3887: <p>Some packages decide to install a different set of files based on
3888: the operating system being used. These differences can be
3889: automatically handled by using the following files:</p>
3890: <div class="itemizedlist"><ul type="disc">
1.76 ! rillig 3891: <li><p><code class="filename">PLIST.common</code></p></li>
! 3892: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
! 3893: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
! 3894: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
! 3895: <li><p><code class="filename">PLIST.common_end</code></p></li>
1.75 rillig 3896: </ul></div>
3897: </div>
3898: <div class="sect1" lang="en">
3899: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3900: <a name="faq.common-dirs"></a>10.8. Sharing directories between packages</h2></div></div></div>
3901: <p> A “<span class="quote">shared directory</span>” is a directory where
3902: multiple (and unrelated) packages install files. These
3903: directories are problematic because you have to add special tricks
3904: in the PLIST to conditionally remove them, or have some
3905: centralized package handle them. </p>
3906: <p> Within pkgsrc, you'll find both approaches. If a directory
3907: is shared by a few unrelated packages, it's often not worth to add
3908: an extra package to remove it. Therefore, one simply does:
3909: </p>
3910: <pre class="programlisting">
3911: @unexec ${RMDIR} %D/path/to/shared/directory 2>/dev/null || ${TRUE}
1.1 grant 3912: </pre>
1.75 rillig 3913: <p> in the PLISTs of all affected packages, instead of the
3914: regular "@dirrm" line. </p>
3915: <p> However, if the directory is shared across many packages, two
3916: different solutions are available: </p>
3917: <div class="orderedlist"><ol type="1">
3918: <li><p> If the packages have a common dependency, the directory
3919: can be removed in that. For example, see
1.76 ! rillig 3920: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/textproc/scrollkeeper/README.html" target="_top"><code class="filename">textproc/scrollkeeper</code></a>, which
1.75 rillig 3921: removes the shared directory
1.76 ! rillig 3922: <code class="filename">share/omf</code>. </p></li>
1.75 rillig 3923: <li><p> If the packages using the directory are not related at
3924: all (they have no common dependencies), a *-dirs package is
3925: used. </p></li>
3926: </ol></div>
3927: <p> From now on, we'll discuss the second solution. To get an
3928: idea of the *-dirs packages available, issue: </p>
3929: <pre class="programlisting">
3930: <code class="prompt">%</code> cd .../pkgsrc
3931: <code class="prompt">%</code> ls -d */*-dirs
1.1 grant 3932: </pre>
1.75 rillig 3933: <p> Their use from other packages is very simple. The
3934: <code class="varname">USE_DIRS</code> variable takes a list of package names
3935: (without the “<span class="quote">-dirs</span>” part) together with the required
3936: version number (always pick the latest one when writing new
3937: packages). </p>
3938: <p> For example, if a package installs files under
1.76 ! rillig 3939: <code class="filename">share/applications</code>, it should have the
1.75 rillig 3940: following line in it:
3941: </p>
3942: <pre class="programlisting">
3943: USE_DIRS+= xdg-1.1
1.1 grant 3944: </pre>
1.75 rillig 3945: <p> After regenerating the PLIST using <span><strong class="command">make
3946: print-PLIST</strong></span>, you should get the right (commented out)
3947: lines. </p>
3948: <p> Note that even if your package is using
1.76 ! rillig 3949: <code class="filename">$X11BASE</code>, it must not depend on the
1.75 rillig 3950: *-x11-dirs packages. Just specify the name without that part and
1.76 ! rillig 3951: pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
1.75 rillig 3952: care of it. </p>
3953: </div>
3954: </div>
3955: <div class="chapter" lang="en">
3956: <div class="titlepage"><div><div><h2 class="title">
3957: <a name="buildlink"></a>Chapter 11. Buildlink methodology</h2></div></div></div>
3958: <div class="toc">
3959: <p><b>Table of Contents</b></p>
3960: <dl>
3961: <dt><span class="sect1"><a href="#converting-to-buildlink3">11.1. Converting packages to use buildlink3</a></span></dt>
1.76 ! rillig 3962: <dt><span class="sect1"><a href="#creating-buildlink3.mk">11.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
1.75 rillig 3963: <dd><dl>
3964: <dt><span class="sect2"><a href="#anatomy-of-bl3">11.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
1.76 ! rillig 3965: <dt><span class="sect2"><a href="#updating-buildlink-depends">11.2.2. Updating <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code> in <code class="filename">buildlink3.mk</code> files</a></span></dt>
1.75 rillig 3966: </dl></dd>
1.76 ! rillig 3967: <dt><span class="sect1"><a href="#writing-builtin.mk">11.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
1.75 rillig 3968: <dd><dl>
1.76 ! rillig 3969: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">11.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
1.75 rillig 3970: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">11.3.2. Global preferences for native or pkgsrc software</a></span></dt>
3971: </dl></dd>
3972: </dl>
3973: </div>
3974: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
3975: are seen by a package's configure and build processes. This is implemented
3976: in a two step process:</p>
3977: <div class="orderedlist"><ol type="1">
3978: <li><p>Symlink headers and libraries for dependencies into
3979: <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
3980: of <code class="varname">WRKDIR</code>.</p></li>
3981: <li><p>Create wrapper scripts that are used in place of the normal compiler
3982: tools that translate <code class="option">-I${LOCALBASE}/include</code> and
3983: <code class="option">-L${LOCALBASE}/lib</code> into references to
3984: <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
3985: native compiler on some operating systems look like GCC, so that
3986: packages that expect GCC won't require modifications to build with
3987: those native compilers.</p></li>
3988: </ol></div>
3989: <p>This normalizes the environment in which a package is built so that the
3990: package may be built consistently despite what other software may be
3991: installed. Please note that the normal system header and library paths,
1.76 ! rillig 3992: e.g. <code class="filename">/usr/include</code>,
! 3993: <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
1.75 rillig 3994: designed to insulate the package build from non-system-supplied
3995: software. </p>
3996: <div class="sect1" lang="en">
3997: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3998: <a name="converting-to-buildlink3"></a>11.1. Converting packages to use buildlink3</h2></div></div></div>
3999: <p>The process of converting packages to use the buildlink3
4000: framework (“<span class="quote">bl3ifying</span>”) is fairly straightforward.
4001: The things to keep in mind are:</p>
4002: <div class="orderedlist"><ol type="1">
4003: <li><p> Ensure that the build always calls the wrapper scripts
4004: instead of the actual toolchain. Some packages are tricky,
4005: and the only way to know for sure is the check
1.76 ! rillig 4006: <code class="filename">${WRKDIR}/.work.log</code> to see if the
1.75 rillig 4007: wrappers are being invoked. </p></li>
4008: <li><p> Don't override <code class="varname">PREFIX</code> from within
4009: the package Makefile, e.g. Java VMs, standalone shells,
4010: etc., because the code to symlink files into
1.76 ! rillig 4011: <code class="filename">${BUILDLINK_DIR}</code> looks for files
1.75 rillig 4012: relative to “<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>”.
4013: </p></li>
4014: <li><p> Remember that <span class="emphasis"><em>only</em></span> the
1.76 ! rillig 4015: <code class="filename">buildlink3.mk</code> files that you list in a
1.75 rillig 4016: package's Makefile are added as dependencies for that package.
4017: </p></li>
4018: </ol></div>
4019: <p> If a dependency on a particular package is required for its libraries and
4020: headers, then we replace: </p>
4021: <pre class="programlisting">
4022: DEPENDS+= foo>=1.1.0:../../category/foo
1.1 grant 4023: </pre>
1.75 rillig 4024: <p>with</p>
4025: <pre class="programlisting">
4026: .include "../../category/foo/buildlink3.mk"
1.1 grant 4027: </pre>
1.75 rillig 4028: <p>The buildlink3.mk files usually define the required dependencies.
4029: If you need a newer version of the dependency when using buildlink3.mk
4030: files, then you can define it in your Makefile; for example:
4031: </p>
4032: <pre class="programlisting">
4033: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
4034: .include "../../category/foo/buildlink3.mk"
1.1 grant 4035: </pre>
1.76 ! rillig 4036: <p>There are several <code class="filename">buildlink3.mk</code>
! 4037: files in <code class="filename">pkgsrc/mk</code>
1.75 rillig 4038: that handle special package issues:</p>
4039: <div class="itemizedlist"><ul type="disc">
1.76 ! rillig 4040: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
1.75 rillig 4041: the native or a pkgsrc Berkeley DB implementation based on
4042: the values of <code class="varname">BDB_ACCEPTED</code> and
4043: <code class="varname">BDB_DEFAULT</code>.</p></li>
1.76 ! rillig 4044: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
1.75 rillig 4045: comes with neither Curses nor NCurses, this will take care
1.76 ! rillig 4046: to install the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/ncurses/README.html" target="_top"><code class="filename">devel/ncurses</code></a> package.</p></li>
! 4047: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
1.75 rillig 4048: of <code class="varname">KRB5_ACCEPTED</code> to choose between
4049: adding a dependency on Heimdal or MIT-krb5 for packages that
4050: require a Kerberos 5 implementation.</p></li>
1.76 ! rillig 4051: <li><p><code class="filename">motif.buildlink3.mk</code> checks
1.75 rillig 4052: for a system-provided
1.76 ! rillig 4053: Motif installation or adds a dependency on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/lesstif/README.html" target="_top"><code class="filename">x11/lesstif</code></a> or
! 4054: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/openmotif/README.html" target="_top"><code class="filename">x11/openmotif</code></a>.</p></li>
! 4055: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
1.75 rillig 4056: variables that may be used by packages that use the
4057: Open Sound System (OSS) API.</p></li>
1.76 ! rillig 4058: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
1.75 rillig 4059: either Postgres 7.3 or 7.4, whichever is found installed. See
4060: the file for more information. </p></li>
1.76 ! rillig 4061: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
1.75 rillig 4062: <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
1.76 ! rillig 4063: a dependency on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/pth/README.html" target="_top"><code class="filename">devel/pth</code></a> as needed.</p></li>
! 4064: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
1.75 rillig 4065: <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
4066: library.</p></li>
4067: </ul></div>
1.76 ! rillig 4068: <p>The comments in those <code class="filename">buildlink3.mk</code>
1.75 rillig 4069: files provide a more complete
4070: description of how to use them properly.</p>
4071: </div>
4072: <div class="sect1" lang="en">
4073: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.76 ! rillig 4074: <a name="creating-buildlink3.mk"></a>11.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
! 4075: <p> A package's <code class="filename">buildlink3.mk</code> file is
1.75 rillig 4076: included by Makefiles to indicate the need to compile and link
4077: against header files and libraries provided by the package. A
1.76 ! rillig 4078: <code class="filename">buildlink3.mk</code> file should always provide
1.75 rillig 4079: enough information to add the correct type of dependency
4080: relationship and include any other
1.76 ! rillig 4081: <code class="filename">buildlink3.mk</code> files that it needs to find
1.75 rillig 4082: headers and libraries that it needs in turn.</p>
1.76 ! rillig 4083: <p> To generate an initial <code class="filename">buildlink3.mk</code>
! 4084: file for further editing, Rene Hexel's <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/createbuildlink/README.html" target="_top"><code class="filename">pkgtools/createbuildlink</code></a>
1.75 rillig 4085: package is highly recommended. For most packages, the following
4086: command will generate a good starting point for
1.76 ! rillig 4087: <code class="filename">buildlink3.mk</code> files:</p>
1.75 rillig 4088: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>pkgdir</code></em>
4089: <code class="prompt">%</code> createbuildlink >buildlink3.mk</code></strong></pre>
4090: <div class="sect2" lang="en">
4091: <div class="titlepage"><div><div><h3 class="title">
4092: <a name="anatomy-of-bl3"></a>11.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
4093: <p>The following real-life example
1.76 ! rillig 4094: <code class="filename">buildlink3.mk</code> is taken
! 4095: from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
1.75 rillig 4096: <pre class="programlisting">
4097: # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
1.1 grant 4098:
1.75 rillig 4099: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
4100: TIFF_BUILDLINK3_MK:= ${TIFF_BUILDLINK3_MK}+
1.1 grant 4101:
1.75 rillig 4102: .if !empty(BUILDLINK_DEPTH:M+)
4103: BUILDLINK_DEPENDS+= tiff
4104: .endif
1.1 grant 4105:
1.75 rillig 4106: BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Ntiff}
4107: BUILDLINK_PACKAGES+= tiff
1.1 grant 4108:
1.75 rillig 4109: .if !empty(TIFF_BUILDLINK3_MK:M+)
4110: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
4111: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
4112: .endif # TIFF_BUILDLINK3_MK
1.1 grant 4113:
1.75 rillig 4114: .include "../../devel/zlib/buildlink3.mk"
4115: .include "../../graphics/jpeg/buildlink3.mk"
1.1 grant 4116:
1.75 rillig 4117: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
1.1 grant 4118: </pre>
1.75 rillig 4119: <p> The header and footer manipulate
4120: <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
1.76 ! rillig 4121: <code class="filename">buildlink3.mk</code> files and is used to track
1.75 rillig 4122: at what depth we are including
1.76 ! rillig 4123: <code class="filename">buildlink3.mk</code> files.</p>
1.75 rillig 4124: <p> The first section controls if the dependency on
4125: <em class="replaceable"><code>pkg</code></em> is added.
4126: <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
4127: packages for which dependencies are added by
4128: buildlink3.</p>
4129: <p> The second section advises pkgsrc that the
1.76 ! rillig 4130: <code class="filename">buildlink3.mk</code> file for
1.75 rillig 4131: <em class="replaceable"><code>pkg</code></em> has been included at some point.
4132: <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
1.76 ! rillig 4133: packages for which <code class="filename">buildlink3.mk</code> files
1.75 rillig 4134: have been included. It must <span class="emphasis"><em>always</em></span> be
1.76 ! rillig 4135: appended to within a <code class="filename">buildlink3.mk</code>
1.75 rillig 4136: file. </p>
4137: <p> The third section is protected from multiple inclusion
4138: and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
4139: added. Several important variables are set in the section:
4140: </p>
4141: <div class="itemizedlist"><ul type="disc">
4142: <li><p> <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4143: is the actual dependency recorded in the installed
4144: package; this should always be set using
4145: <span><strong class="command">+=</strong></span> to ensure that
4146: we're appending to any pre-existing list of values. This
4147: variable should be set to the first version of the
4148: package that had an API change.
4149: </p></li>
4150: <li><p> <code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
4151: is the location of the <em class="replaceable"><code>pkg</code></em>
4152: pkgsrc directory.</p></li>
4153: <li><p>
4154: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
4155: (not shown above) controls whether we use
4156: <code class="varname">BUILD_DEPENDS</code> or
4157: <code class="varname">DEPENDS</code> to add the dependency on
4158: <em class="replaceable"><code>pkg</code></em>.
4159: The build dependency is selected by setting
4160: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
4161: to “<span class="quote">build</span>”. By default, the
4162: full dependency is used.
4163: </p></li>
4164: <li><p>
4165: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
4166: and
4167: <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
4168: (not shown above) are lists of subdirectories of
1.76 ! rillig 4169: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4170: to add to the header and library search paths. These
4171: default to “<span class="quote">include</span>” and “<span class="quote">lib</span>”
4172: respectively. </p></li>
4173: <li><p>
4174: <code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
4175: (not shown above) is the list of preprocessor flags to add
4176: to <code class="varname">CPPFLAGS</code>, which are passed on to the
4177: configure and build phases. The “<span class="quote">-I</span>” option
4178: should be avoided and instead be handled using
4179: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
4180: above.</p></li>
4181: </ul></div>
4182: <p> The following variables are all optionally defined within
4183: this second section (protected against multiple inclusion) and
4184: control which package files are symlinked into
1.76 ! rillig 4185: <code class="filename">${BUILDLINK_DIR}</code> and how their names are
1.75 rillig 4186: transformed during the symlinking: </p>
4187: <div class="itemizedlist"><ul type="disc">
4188: <li><p>
4189: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
4190: (not shown above) is a shell glob pattern relative to
1.76 ! rillig 4191: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4192: to be symlinked into
1.76 ! rillig 4193: <code class="filename">${BUILDLINK_DIR}</code>,
! 4194: e.g. <code class="filename">include/*.h</code>. </p></li>
1.75 rillig 4195: <li><p>
4196: <code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
4197: (not shown above) is a shell pipeline that
4198: outputs to stdout a list of files relative to
1.76 ! rillig 4199: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
1.75 rillig 4200: The resulting files are to be symlinked
1.76 ! rillig 4201: into <code class="filename">${BUILDLINK_DIR}</code>. By default,
! 4202: this takes the <code class="filename">+CONTENTS</code> of a
1.75 rillig 4203: <em class="replaceable"><code>pkg</code></em> and filters it through
4204: <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.
4205: </p></li>
4206: <li><p>
4207: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
4208: (not shown above) is a filter command that filters
1.76 ! rillig 4209: <code class="filename">+CONTENTS</code> input into a list of files
1.75 rillig 4210: relative to
1.76 ! rillig 4211: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4212: on stdout. By default for overwrite packages,
4213: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.76 ! rillig 4214: outputs the contents of the <code class="filename">include</code>
! 4215: and <code class="filename">lib</code> directories in the package
! 4216: <code class="filename">+CONTENTS</code>, and for pkgviews packages,
1.75 rillig 4217: it outputs any libtool archives in
1.76 ! rillig 4218: <code class="filename">lib</code> directories.
1.75 rillig 4219: </p></li>
4220: <li><p>
4221: <code class="varname">BUILDLINK_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
4222: (not shown above) is a list of sed arguments used to
4223: transform the name of the source filename into a
4224: destination filename, e.g. <span><strong class="command">-e
4225: "s|/curses.h|/ncurses.h|g"</strong></span>.
4226: </p></li>
4227: </ul></div>
4228: <p> The last section includes any
1.76 ! rillig 4229: <code class="filename">buildlink3.mk</code> needed for
1.75 rillig 4230: <em class="replaceable"><code>pkg</code></em>'s library dependencies.
1.76 ! rillig 4231: Including these <code class="filename">buildlink3.mk</code> files
1.75 rillig 4232: means that the headers and libraries for these
4233: dependencies are also symlinked into
1.76 ! rillig 4234: <code class="filename">${BUILDLINK_DIR}</code>
1.75 rillig 4235: whenever the <em class="replaceable"><code>pkg</code></em>
1.76 ! rillig 4236: <code class="filename">buildlink3.mk</code>
1.75 rillig 4237: file is included.
4238: </p>
4239: </div>
4240: <div class="sect2" lang="en">
4241: <div class="titlepage"><div><div><h3 class="title">
1.76 ! rillig 4242: <a name="updating-buildlink-depends"></a>11.2.2. Updating <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code> in <code class="filename">buildlink3.mk</code> files</h3></div></div></div>
1.75 rillig 4243: <p>
4244: The situation that requires increasing the dependency listed in
4245: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4246: after a package update is when the API or interface to the
4247: header files change.</p>
4248: <p> In this case,
4249: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4250: should be adjusted to require at least the new package
4251: version. In some cases, the packages that depend on this new
4252: version may need their <code class="varname">PKGREVISION</code>s
1.76 ! rillig 4253: increased and, if they have <code class="filename">buildlink3.mk</code>
1.75 rillig 4254: files, their
4255: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4256: adjusted, too. This is needed so pkgsrc will require the
4257: correct package dependency and not settle for an older one
4258: when building the source.</p>
4259: <p>
4260: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4261: should be increased when the binary interface or sonames
4262: (major number of the library version) of any installed
4263: shared libraries change. This is needed so that binary
4264: packages made using it will require the correct package
4265: dependency and not settle for an older one which will not
4266: contain the necessary shared libraries. </p>
4267: <p>
4268: See <a href="#dependencies" title="16.1.4. Handling dependencies">Section 16.1.4, “Handling dependencies”</a> for
4269: more information about dependencies on other packages,
4270: including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
4271: <code class="varname">ABI_DEPENDS</code> definitions. </p>
4272: <p> Please take careful consideration before adjusting
4273: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4274: or
4275: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4276: as we don't want to cause unneeded package deletions and
4277: rebuilds. In many cases, new versions of packages work just
4278: fine with older dependencies.</p>
4279: <p>
4280: Also it is not needed to set
4281: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4282: when it is identical to
4283: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>. </p>
4284: </div>
4285: </div>
4286: <div class="sect1" lang="en">
4287: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.76 ! rillig 4288: <a name="writing-builtin.mk"></a>11.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.75 rillig 4289: <p>
4290: Some packages in pkgsrc install headers and libraries that
4291: coincide with headers and libraries present in the base system.
1.76 ! rillig 4292: Aside from a <code class="filename">buildlink3.mk</code> file, these
! 4293: packages should also include a <code class="filename">builtin.mk</code>
1.75 rillig 4294: file that includes the necessary checks to decide whether using
4295: the built-in software or the pkgsrc software is
4296: appropriate. </p>
4297: <p> The only requirements of a builtin.mk file for
4298: <em class="replaceable"><code>pkg</code></em> are:
4299: </p>
4300: <div class="orderedlist"><ol type="1">
4301: <li><p> It should set
4302: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4303: to either “<span class="quote">yes</span>” or “<span class="quote">no</span>”
4304: after it is included.
4305: </p></li>
4306: <li><p> It should <span class="emphasis"><em>not</em></span> override any
4307: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4308: which is already set before the
1.76 ! rillig 4309: <code class="filename">builtin.mk</code> file is included.
1.75 rillig 4310: </p></li>
4311: <li><p> It should be written to allow multiple inclusion. This
4312: is <span class="emphasis"><em>very</em></span> important and takes careful
1.76 ! rillig 4313: attention to <code class="filename">Makefile</code> coding.
1.75 rillig 4314: </p></li>
4315: </ol></div>
4316: <div class="sect2" lang="en">
4317: <div class="titlepage"><div><div><h3 class="title">
1.76 ! rillig 4318: <a name="anatomy-of-builtin.mk"></a>11.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</h3></div></div></div>
1.75 rillig 4319: <p>The following is the recommended template for builtin.mk
4320: files: </p>
4321: <pre class="programlisting">
4322: .if !defined(IS_BUILTIN.foo)
4323: #
4324: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
4325: # genuinely exists in the system or not.
4326: #
4327: IS_BUILTIN.foo?= no
1.1 grant 4328:
1.75 rillig 4329: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
4330: # version can be determined.
4331: #
4332: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
4333: BUILTIN_PKG.foo?= foo-1.0
4334: . endif
4335: .endif # IS_BUILTIN.foo
1.1 grant 4336:
1.75 rillig 4337: .if !defined(USE_BUILTIN.foo)
4338: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
4339: . if defined(BUILTIN_PKG.foo)
4340: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
4341: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
4342: USE_BUILTIN.foo!= \
4343: if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then \
4344: ${ECHO} "yes"; \
4345: else \
4346: ${ECHO} "no"; \
4347: fi
4348: . endif
4349: . endfor
4350: . endif
4351: .endif # USE_BUILTIN.foo
1.1 grant 4352:
1.75 rillig 4353: CHECK_BUILTIN.foo?= no
4354: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
4355: #
4356: # Here we place code that depends on whether USE_BUILTIN.foo is set to
4357: # "yes" or "no".
4358: #
4359: .endif # CHECK_BUILTIN.foo
1.1 grant 4360: </pre>
1.75 rillig 4361: <p> The first section sets
4362: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4363: depending on if <em class="replaceable"><code>pkg</code></em> really exists
4364: in the base system. This should not be a base system software
4365: with similar functionality to <em class="replaceable"><code>pkg</code></em>;
4366: it should only be “<span class="quote">yes</span>” if the actual package is
4367: included as part of the base system. This variable is only
1.76 ! rillig 4368: used internally within the <code class="filename">builtin.mk</code>
1.75 rillig 4369: file. </p>
4370: <p> The second section sets
4371: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
4372: to the version of <em class="replaceable"><code>pkg</code></em> in the base
4373: system if it exists (if
4374: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4375: is “<span class="quote">yes</span>”). This variable is only used internally
1.76 ! rillig 4376: within the <code class="filename">builtin.mk</code> file. </p>
1.75 rillig 4377: <p> The third section sets
4378: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4379: and is <span class="emphasis"><em>required</em></span> in all
1.76 ! rillig 4380: <code class="filename">builtin.mk</code> files. The code in this
1.75 rillig 4381: section must make the determination whether the built-in
4382: software is adequate to satisfy the dependencies listed in
4383: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
4384: This is typically done by comparing
4385: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
4386: against each of the dependencies in
4387: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
4388: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4389: <span class="emphasis"><em>must</em></span> be set to the correct value by the
1.76 ! rillig 4390: end of the <code class="filename">builtin.mk</code> file. Note that
1.75 rillig 4391: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4392: may be “<span class="quote">yes</span>” even if
4393: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4394: is “<span class="quote">no</span>” because we may make the determination
4395: that the built-in version of the software is similar enough to
4396: be used as a replacement. </p>
4397: <p> The last section is guarded by
4398: <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
4399: and includes code that uses the value of
4400: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4401: set in the previous section. This typically includes, e.g.,
4402: adding additional dependency restrictions and listing
4403: additional files to symlink into
1.76 ! rillig 4404: <code class="filename">${BUILDLINK_DIR}</code> (via
1.75 rillig 4405: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).
4406: </p>
4407: </div>
4408: <div class="sect2" lang="en">
4409: <div class="titlepage"><div><div><h3 class="title">
4410: <a name="native-or-pkgsrc-preference"></a>11.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
4411: <p>
4412: When building packages, it's possible to choose whether to set
4413: a global preference for using either the built-in (native)
4414: version or the pkgsrc version of software to satisfy a
4415: dependency. This is controlled by setting
4416: <code class="varname">PREFER_PKGSRC</code> and
4417: <code class="varname">PREFER_NATIVE</code>. These variables take values
4418: of either “<span class="quote">yes</span>”, “<span class="quote">no</span>”, or a list of
4419: packages. <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
4420: use the pkgsrc versions of software, while
4421: <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
4422: built-in versions. Preferences are determined by the most
4423: specific instance of the package in either
4424: <code class="varname">PREFER_PKGSRC</code> or
4425: <code class="varname">PREFER_NATIVE</code>. If a package is specified
4426: in neither or in both variables, then
4427: <code class="varname">PREFER_PKGSRC</code> has precedence over
4428: <code class="varname">PREFER_NATIVE</code>. For example, to require
4429: using pkgsrc versions of software for all but the most basic
4430: bits on a NetBSD system, you can set: </p>
4431: <pre class="programlisting">
4432: PREFER_PKGSRC= yes
4433: PREFER_NATIVE= getopt skey tcp_wrappers
1.1 grant 4434: </pre>
1.75 rillig 4435: <p> A package <span class="emphasis"><em>must</em></span> have a
1.76 ! rillig 4436: <code class="filename">builtin.mk</code>
1.75 rillig 4437: file to be listed in <code class="varname">PREFER_NATIVE</code>,
4438: otherwise it is simply ignored in that list.
4439: </p>
4440: </div>
4441: </div>
4442: </div>
4443: <div class="chapter" lang="en">
4444: <div class="titlepage"><div><div><h2 class="title">
4445: <a name="pkginstall"></a>Chapter 12. The pkginstall framework</h2></div></div></div>
4446: <div class="toc">
4447: <p><b>Table of Contents</b></p>
4448: <dl>
4449: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">12.1. Files and directories outside the installation prefix</a></span></dt>
4450: <dd><dl>
4451: <dt><span class="sect2"><a href="#dirs-outside-prefix">12.1.1. Directory manipulation</a></span></dt>
4452: <dt><span class="sect2"><a href="#files-outside-prefix">12.1.2. File manipulation</a></span></dt>
4453: </dl></dd>
4454: <dt><span class="sect1"><a href="#conf-files">12.2. Configuration files</a></span></dt>
4455: <dd><dl>
4456: <dt><span class="sect2"><a href="#conf-files-sysconfdir">12.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
4457: <dt><span class="sect2"><a href="#conf-files-configure">12.2.2. Telling the software where configuration files are</a></span></dt>
4458: <dt><span class="sect2"><a href="#conf-files-patching">12.2.3. Patching installations</a></span></dt>
4459: <dt><span class="sect2"><a href="#conf-files-disable">12.2.4. Disabling handling of configuration files</a></span></dt>
4460: </dl></dd>
4461: <dt><span class="sect1"><a href="#rcd-scripts">12.3. System startup scripts</a></span></dt>
4462: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">12.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
4463: <dt><span class="sect1"><a href="#users-and-groups">12.4. System users and groups</a></span></dt>
4464: <dt><span class="sect1"><a href="#shells">12.5. System shells</a></span></dt>
4465: <dd><dl><dt><span class="sect2"><a href="#shells-disable">12.5.1. Disabling shell registration</a></span></dt></dl></dd>
4466: <dt><span class="sect1"><a href="#fonts">12.6. Fonts</a></span></dt>
4467: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">12.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
4468: </dl>
4469: </div>
4470: <p>This chapter describes the framework known as
4471: <code class="literal">pkginstall</code>, whose key features are:</p>
4472: <div class="itemizedlist"><ul type="disc">
4473: <li><p>Generic installation and manipulation of directories and files
4474: outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
4475: <li><p>Automatic handling of configuration files during installation,
4476: provided that packages are correctly designed.</p></li>
4477: <li><p>Generation and installation of system startup scripts.</p></li>
4478: <li><p>Registration of system users and groups.</p></li>
4479: <li><p>Registration of system shells.</p></li>
4480: <li><p>Automatic updating of fonts databases.</p></li>
4481: </ul></div>
4482: <p>The following sections inspect each of the above points in detail.</p>
4483: <p>You may be thinking that many of the things described here could be
4484: easily done with simple code in the package's post-installation target
4485: (<code class="literal">post-install</code>). <span class="emphasis"><em>This is incorrect</em></span>,
4486: as the code in them is only executed when building from source. Machines
4487: using binary packages could not benefit from it at all (as the code itself
4488: could be unavailable). Therefore, the only way to achieve any of the items
4489: described above is by means of the installation scripts, which are
4490: automatically generated by pkginstall.</p>
4491: <div class="sect1" lang="en">
4492: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4493: <a name="files-and-dirs-outside-prefix"></a>12.1. Files and directories outside the installation prefix</h2></div></div></div>
1.76 ! rillig 4494: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
1.75 rillig 4495: of files and directories that belong to a package. The names used in it
1.76 ! rillig 4496: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
1.75 rillig 4497: which means that it cannot register files outside this directory (absolute
4498: path names are not allowed). Despite this restriction, some packages need
4499: to install files outside this location; e.g., under
1.76 ! rillig 4500: <code class="filename">${VARBASE}</code> or
! 4501: <code class="filename">${PKG_SYSCONFDIR}</code>.</p>
1.75 rillig 4502: <p>The only way to achieve this is to create such files during
4503: installation time by using the installation scripts. These scripts can run
4504: arbitrary commands, so they have the potential to create and manage files
4505: anywhere in the file system. Here is where pkginstall comes into play: it
4506: provides generic scripts to abstract the manipulation of such files and
4507: directories based on variables set in the package's
1.76 ! rillig 4508: <code class="filename">Makefile</code>. The rest of this section describes these
1.75 rillig 4509: variables.</p>
4510: <div class="sect2" lang="en">
4511: <div class="titlepage"><div><div><h3 class="title">
4512: <a name="dirs-outside-prefix"></a>12.1.1. Directory manipulation</h3></div></div></div>
4513: <p>The following variables can be set to request the creation of
4514: directories anywhere in the file system:</p>
4515: <div class="itemizedlist"><ul type="disc">
4516: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
4517: contain a list of directories that should be created and should attempt
4518: to be destroyed by the installation scripts. The difference between
4519: the two is that the latter prompts the administrator to remove any
4520: directories that may be left after deinstallation (because they were
4521: not empty), while the former does not.</p></li>
4522: <li>
4523: <p><code class="varname">MAKE_DIRS_PERMS</code> and
4524: <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
4525: which directories should be created and should attempt to be destroyed
4526: by the installation scripts. Each tuple holds the following values,
4527: separated by spaces: the directory name, its owner, its group and its
4528: numerical mode. For example:</p>
4529: <pre class="programlisting">
4530: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 4531: </pre>
1.75 rillig 4532: <p>The difference between the two is exactly the same as their
4533: non-<code class="varname">PERMS</code> counterparts.</p>
4534: </li>
4535: </ul></div>
4536: </div>
4537: <div class="sect2" lang="en">
4538: <div class="titlepage"><div><div><h3 class="title">
4539: <a name="files-outside-prefix"></a>12.1.2. File manipulation</h3></div></div></div>
4540: <p>Creating non-empty files outside the installation prefix is tricky
1.76 ! rillig 4541: because the <code class="filename">PLIST</code> forces all files to be inside it.
1.75 rillig 4542: To overcome this problem, the only solution is to extract the file in the
4543: known place (i.e., inside the installation prefix) and copy it to the
4544: appropriate location during installation (done by the installation scripts
4545: generated by pkginstall). We will call the former the <span class="emphasis"><em>master
4546: file</em></span> in the following paragraphs, which describe the variables
4547: that can be used to automatically and consistently handle files outside the
4548: installation prefix:</p>
4549: <div class="itemizedlist"><ul type="disc">
4550: <li>
4551: <p><code class="varname">CONF_FILES</code> and
4552: <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
4553: During installation time, the master file is copied to the target one
4554: if and only if the latter does not exist. Upon deinstallation, the
4555: target file is removed provided that it was not modified by the
4556: installation.</p>
4557: <p>The difference between the two is that the latter prompts the
4558: administrator to remove any files that may be left after
4559: deinstallation (because they were not empty), while the former does
4560: not.</p>
4561: </li>
4562: <li>
4563: <p><code class="varname">CONF_FILES_PERMS</code> and
4564: <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
4565: files as well as their target locations. For each of them, it also
4566: specifies their owner, their group and their numeric permissions, in
4567: this order. For example:</p>
4568: <pre class="programlisting">
4569: SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 4570: </pre>
1.75 rillig 4571: <p>The difference between the two is exactly the same as their
4572: non-<code class="varname">PERMS</code> counterparts.</p>
4573: </li>
4574: </ul></div>
4575: </div>
4576: </div>
4577: <div class="sect1" lang="en">
4578: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4579: <a name="conf-files"></a>12.2. Configuration files</h2></div></div></div>
4580: <p>Configuration files are special in the sense that they are installed
4581: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
4582: need special treatment during installation (most of which is automated by
4583: pkginstall). The main concept you must bear in mind is that files marked
4584: as configuration files are automatically copied to the right place (somewhere
4585: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
4586: and only if</em></span> they didn't exist before. Similarly, they will not
4587: be removed if they have local modifications. This ensures that
4588: administrators never lose any custom changes they may have made.</p>
4589: <div class="sect2" lang="en">
4590: <div class="titlepage"><div><div><h3 class="title">
4591: <a name="conf-files-sysconfdir"></a>12.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</h3></div></div></div>
4592: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
4593: specifies where configuration files shall be installed. Its contents are
4594: set based upon the following variables:</p>
4595: <div class="itemizedlist"><ul type="disc">
4596: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
1.76 ! rillig 4597: directory. Defaults to <code class="filename">${PREFIX}/etc</code> although it may
1.75 rillig 4598: be overridden by the user to point to his preferred location (e.g.,
1.76 ! rillig 4599: <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
1.75 rillig 4600: Packages must not use it directly.</p></li>
4601: <li>
4602: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
4603: <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
4604: for the package being built shall be installed. The definition of this
4605: variable only makes sense in the package's
1.76 ! rillig 4606: <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
1.75 rillig 4607: <p>As an example, consider the Apache package,
1.76 ! rillig 4608: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/apache2/README.html" target="_top"><code class="filename">www/apache2</code></a>, which places its
1.75 rillig 4609: configuration files under the
1.76 ! rillig 4610: <code class="filename">httpd/</code> subdirectory of
1.75 rillig 4611: <code class="varname">PKG_SYSCONFBASE</code>. This should be set in the package
4612: Makefile.</p>
4613: </li>
4614: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
4615: variable that holds this package's configuration directory (if
4616: different from <code class="varname">PKG_SYSCONFBASE</code>). It defaults to
4617: <code class="varname">PKGBASE</code>'s value, and is always prefixed with
4618: <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
4619: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
4620: directory where the configuration files for the package identified by
4621: <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
4622: </ul></div>
4623: <p>Based on the above variables, pkginstall determines the value of
4624: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
4625: variable that can be used within a package to refer to its configuration
4626: directory. The algorithm used to set its value is basically the
4627: following:</p>
4628: <div class="orderedlist"><ol type="1">
4629: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
4630: its value is used.</p></li>
4631: <li><p>If the previous variable is not defined but
4632: <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
1.76 ! rillig 4633: <code class="filename">Makefile</code>, the resulting value is
! 4634: <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
1.75 rillig 4635: <li><p>Otherwise, it is set to
1.76 ! rillig 4636: <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
1.75 rillig 4637: </ol></div>
1.76 ! rillig 4638: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
! 4639: automatically added to <code class="filename">OWN_DIRS</code>. See <a href="#dirs-outside-prefix" title="12.1.1. Directory manipulation">Section 12.1.1, “Directory manipulation”</a> what this means.</p>
1.75 rillig 4640: </div>
4641: <div class="sect2" lang="en">
4642: <div class="titlepage"><div><div><h3 class="title">
4643: <a name="conf-files-configure"></a>12.2.2. Telling the software where configuration files are</h3></div></div></div>
4644: <p>Given that pkgsrc (and users!) expect configuration files to be in a
4645: known place, you need to teach each package where it shall install its
4646: files. In some cases you will have to patch the package Makefiles to
4647: achieve it. If you are lucky, though, it may be as easy as passing an
4648: extra flag to the configuration script; this is the case of GNU Autoconf-
4649: generated files:</p>
4650: <pre class="programlisting">
4651: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1 grant 4652: </pre>
1.75 rillig 4653: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
4654: for</em></span> its configuration files, not where they will be originally
4655: installed (although the difference is never explicit,
4656: unfortunately).</p>
4657: </div>
4658: <div class="sect2" lang="en">
4659: <div class="titlepage"><div><div><h3 class="title">
4660: <a name="conf-files-patching"></a>12.2.3. Patching installations</h3></div></div></div>
4661: <p>As said before, pkginstall automatically handles configuration files.
4662: This means that <span class="strong"><strong>the packages themselves must not
1.76 ! rillig 4663: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
1.75 rillig 4664: directly</strong></span>. Bad news is that many software installation scripts
4665: will, out of the box, mess with the contents of that directory. So what is
4666: the correct procedure to fix this issue?</p>
4667: <p>You must teach the package (usually by manually patching it) to
4668: install any configuration files under the examples hierarchy,
1.76 ! rillig 4669: <code class="filename">share/examples/${PKGBASE}/</code>. This way, the
! 4670: <code class="filename">PLIST</code> registers them and the administrator always
1.75 rillig 4671: has the original copies available.</p>
4672: <p>Once the required configuration files are in place (i.e., under the
4673: examples hierarchy), the pkginstall framework can use them as master copies
4674: during the package installation to update what is in
1.76 ! rillig 4675: <code class="filename">${PKG_SYSCONFDIR}</code>. To achieve this, the variables
1.75 rillig 4676: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
4677: used. Check out <a href="#files-outside-prefix" title="12.1.2. File manipulation">Section 12.1.2, “File manipulation”</a> for information
4678: about their syntax and their purpose. Here is an example, taken from the
1.76 ! rillig 4679: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/mail/mutt/README.html" target="_top"><code class="filename">mail/mutt</code></a> package:</p>
1.75 rillig 4680: <pre class="programlisting">
4681: EGDIR= ${PREFIX}/share/doc/mutt/samples
4682: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1 grant 4683: </pre>
1.75 rillig 4684: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
4685: package and has no meaning outside it.</p>
4686: </div>
4687: <div class="sect2" lang="en">
4688: <div class="titlepage"><div><div><h3 class="title">
4689: <a name="conf-files-disable"></a>12.2.4. Disabling handling of configuration files</h3></div></div></div>
4690: <p>The automatic copying of config files can be toggled by setting the
4691: environment variable <code class="varname">PKG_CONFIG</code> prior to package
4692: installation.</p>
4693: </div>
4694: </div>
4695: <div class="sect1" lang="en">
4696: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4697: <a name="rcd-scripts"></a>12.3. System startup scripts</h2></div></div></div>
4698: <p>System startup scripts are special files because they must be
4699: installed in a place known by the underlying OS, usually outside the
4700: installation prefix. Therefore, the same rules described in <a href="#files-and-dirs-outside-prefix" title="12.1. Files and directories outside the installation prefix">Section 12.1, “Files and directories outside the installation prefix”</a> apply, and the same solutions
4701: can be used. However, pkginstall provides a special mechanism to handle
4702: these files.</p>
4703: <p>In order to provide system startup scripts, the package has
4704: to:</p>
4705: <div class="orderedlist"><ol type="1">
1.76 ! rillig 4706: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
1.75 rillig 4707: the <code class="literal">.sh</code> suffix appended. Considering the
1.76 ! rillig 4708: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/print/cups/README.html" target="_top"><code class="filename">print/cups</code></a> package as an example, it has a
! 4709: <code class="filename">cupsd.sh</code> in its files directory.</p></li>
1.75 rillig 4710: <li>
4711: <p>Tell pkginstall to handle it, appending the name of the script,
4712: without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
4713: Continuing the previous example:</p>
4714: <pre class="programlisting">
4715: RCD_SCRIPTS+= cupsd
1.1 grant 4716: </pre>
1.75 rillig 4717: </li>
4718: </ol></div>
4719: <p>Once this is done, pkginstall will do the following steps for each
4720: script in an automated fashion:</p>
4721: <div class="orderedlist"><ol type="1">
4722: <li><p>Process the file found in the files directory applying all the
1.76 ! rillig 4723: substitutions described in the <code class="filename">FILES_SUBST</code>
1.75 rillig 4724: variable.</p></li>
4725: <li><p>Copy the script from the files directory to the examples
1.76 ! rillig 4726: hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>. Note
1.75 rillig 4727: that this master file must be explicitly registered in the
1.76 ! rillig 4728: <code class="filename">PLIST</code>.</p></li>
1.75 rillig 4729: <li><p>Add code to the installation scripts to copy the startup script
4730: from the examples hierarchy into the system-wide startup scripts
4731: directory.</p></li>
4732: </ol></div>
4733: <div class="sect2" lang="en">
4734: <div class="titlepage"><div><div><h3 class="title">
4735: <a name="rcd-scripts-disable"></a>12.3.1. Disabling handling of system startup scripts</h3></div></div></div>
4736: <p>The automatic copying of config files can be toggled by setting the
4737: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
4738: installation. Note that the scripts will be always copied inside the
1.76 ! rillig 4739: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
1.75 rillig 4740: matter what the value of this variable is.</p>
4741: </div>
4742: </div>
4743: <div class="sect1" lang="en">
4744: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4745: <a name="users-and-groups"></a>12.4. System users and groups</h2></div></div></div>
4746: <p>If a package needs to create special users and/or groups during
4747: installation, it can do so by using the pkginstall framework.</p>
4748: <p>Users can be created by adding entries to the
4749: <code class="varname">PKG_USERS</code> variable. Each entry has the following
4750: syntax:</p>
4751: <pre class="programlisting">
4752: user:group
1.1 grant 4753: </pre>
1.75 rillig 4754: <p>Further specification of user details may be done by setting per-user
4755: variables.
4756: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the numeric
4757: UID for the user.
4758: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the user's
4759: description or comment.
4760: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the user's
1.76 ! rillig 4761: home directory, and defaults to <code class="filename">/nonexistent</code> if not
1.75 rillig 4762: specified.
4763: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the user's
1.76 ! rillig 4764: shell, and defaults to <code class="filename">/sbinno/login</code> if not specified.
1.75 rillig 4765: </p>
4766: <p>Similarly, groups can be created by adding entries to the
4767: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
4768: <pre class="programlisting">
4769: group
1.1 grant 4770: </pre>
1.75 rillig 4771: <p>The numeric GID of the group may be set by defining
4772: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
4773: <p>If a package needs to create the users and groups at an earlier
4774: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
4775: either <code class="literal">configure</code> or <code class="literal">build</code> to
4776: indicate the phase before which the users and groups are created. In
4777: this case, the numeric UIDs and GIDs of the created users and groups
4778: are automatically hardcoded into the final installation scripts.</p>
4779: </div>
4780: <div class="sect1" lang="en">
4781: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4782: <a name="shells"></a>12.5. System shells</h2></div></div></div>
4783: <p>Packages that install system shells should register them in the shell
1.76 ! rillig 4784: database, <code class="filename">/etc/shells</code>, to make things easier to the
1.75 rillig 4785: administrator. This must be done from the installation scripts to keep
4786: binary packages working on any system. pkginstall provides an easy way to
4787: accomplish this task.</p>
4788: <p>When a package provides a shell interpreter, it has to set the
4789: <code class="varname">PKG_SHELL</code> variable to its absolute file name. This will
4790: add some hooks to the installation scripts to handle it. Consider the
1.76 ! rillig 4791: following example, taken from <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/shells/zsh/README.html" target="_top"><code class="filename">shells/zsh</code></a>:</p>
1.75 rillig 4792: <pre class="programlisting">
4793: PKG_SHELL= ${PREFIX}/bin/zsh
1.1 grant 4794: </pre>
1.75 rillig 4795: <div class="sect2" lang="en">
4796: <div class="titlepage"><div><div><h3 class="title">
4797: <a name="shells-disable"></a>12.5.1. Disabling shell registration</h3></div></div></div>
4798: <p>The automatic registration of shell interpreters can be disabled by
1.76 ! rillig 4799: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
1.75 rillig 4800: environment variable to <code class="literal">NO</code>.</p>
4801: </div>
4802: </div>
4803: <div class="sect1" lang="en">
4804: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4805: <a name="fonts"></a>12.6. Fonts</h2></div></div></div>
4806: <p>Packages that install X11 fonts should update the database files
4807: that index the fonts within each fonts directory. This can easily be
4808: accomplished within the pkginstall framework.</p>
4809: <p>When a package installs X11 fonts, it must list the directories in
4810: which fonts are installed in the
4811: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
4812: where <em class="replaceable"><code>type</code></em> can be one of “<span class="quote">ttf</span>”,
4813: “<span class="quote">type1</span>” or “<span class="quote">x11</span>”. This will add hooks to the
4814: installation scripts to run the appropriate commands to update the fonts
4815: database files within each of those directories. For convenience, if the
4816: directory path is relative, it is taken to be relative to the package's
1.76 ! rillig 4817: installation prefix. Consider the following example, taken from <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/fonts/dbz-ttf/README.html" target="_top"><code class="filename">fonts/dbz-ttf</code></a>:</p>
1.75 rillig 4818: <pre class="programlisting">
4819: FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
1.1 grant 4820: </pre>
1.75 rillig 4821: <div class="sect2" lang="en">
4822: <div class="titlepage"><div><div><h3 class="title">
4823: <a name="fonts-disable"></a>12.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
4824: <p>The automatic update of fonts databases can be disabled by
1.76 ! rillig 4825: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
1.75 rillig 4826: environment variable to <code class="literal">NO</code>.</p>
4827: </div>
4828: </div>
4829: </div>
4830: <div class="chapter" lang="en">
4831: <div class="titlepage"><div><div><h2 class="title">
4832: <a name="options"></a>Chapter 13. Options handling</h2></div></div></div>
4833: <div class="toc">
4834: <p><b>Table of Contents</b></p>
4835: <dl>
4836: <dt><span class="sect1"><a href="#global-default-options">13.1. Global default options</a></span></dt>
1.76 ! rillig 4837: <dt><span class="sect1"><a href="#converting-to-options">13.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
1.75 rillig 4838: <dt><span class="sect1"><a href="#option-names">13.3. Option Names</a></span></dt>
4839: </dl>
4840: </div>
4841: <p>Many packages have the ability to be built to support different
1.76 ! rillig 4842: sets of features. <code class="filename">bsd.options.mk</code> is a framework
1.75 rillig 4843: in pkgsrc that provides generic handling of those options that
4844: determine different ways in which the packages can be built. It's
4845: possible for the user to specify exactly which sets of options will be
4846: built into a package or to allow a set of global default options
4847: apply.</p>
4848: <div class="sect1" lang="en">
4849: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4850: <a name="global-default-options"></a>13.1. Global default options</h2></div></div></div>
4851: <p>Global default options are listed in
4852: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
4853: that should be built into every package if that option is supported.
1.76 ! rillig 4854: This variable should be set in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 4855: </div>
4856: <div class="sect1" lang="en">
4857: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.76 ! rillig 4858: <a name="converting-to-options"></a>13.2. Converting packages to use <code class="filename">bsd.options.mk</code></h2></div></div></div>
1.75 rillig 4859: <p>The following example shows how
1.76 ! rillig 4860: <code class="filename">bsd.options.mk</code> should be used
1.75 rillig 4861: by the hypothetical ``wibble'' package, either in the package
1.76 ! rillig 4862: <code class="filename">Makefile</code>, or in a file,
! 4863: e.g. <code class="filename">options.mk</code>, that is included by the
! 4864: main package <code class="filename">Makefile</code>.</p>
1.75 rillig 4865: <pre class="programlisting">
4866: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
4867: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
4868: PKG_OPTIONS_OPTIONAL_GROUPS= database
4869: PKG_OPTIONS_GROUP.database= mysql pgsql
4870: PKG_SUGGESTED_OPTIONS= wibble-foo
4871: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
4872: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
1.1 grant 4873:
1.75 rillig 4874: .include "../../mk/bsd.prefs.mk"
1.69 rillig 4875:
1.75 rillig 4876: # this package was previously named wibble2
4877: .if defined(PKG_OPTIONS.wibble2)
4878: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
4879: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
4880: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR instead."
4881: .endif
1.69 rillig 4882:
1.75 rillig 4883: .include "../../mk/bsd.options.mk"
1.69 rillig 4884:
1.75 rillig 4885: # Package-specific option-handling
1.69 rillig 4886:
1.75 rillig 4887: ###
4888: ### FOO support
4889: ###
4890: .if !empty(PKG_OPTIONS:Mwibble-foo)
4891: CONFIGURE_ARGS+= --enable-foo
4892: .endif
1.69 rillig 4893:
1.75 rillig 4894: ###
4895: ### LDAP support
4896: ###
4897: .if !empty(PKG_OPTIONS:Mldap)
4898: . include "../../databases/openldap/buildlink3.mk"
4899: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap}
4900: .endif
1.69 rillig 4901:
1.75 rillig 4902: ###
4903: ### database support
4904: ###
4905: .if !empty(PKG_OPTIONS:Mmysql)
4906: . include "../../mk/mysql.buildlink3.mk"
4907: .endif
4908: .if !empty(PKG_OPTIONS:Mpgsql)
4909: . include "../../mk/pgsql.buildlink3.mk"
4910: .endif
4911: </pre>
4912: <p>The first section contains the information about which build
4913: options are supported by the package, and any default options settings
4914: if needed.</p>
4915: <div class="orderedlist"><ol type="1">
4916: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
4917: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> variable that the user can set to override the default
4918: options. It should be set to
4919: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
4920: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is set after
4921: <code class="varname">PKG_OPTIONS_VAR</code> is used.</p></li>
4922: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
4923: build options supported by the package.</p></li>
4924: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
4925: list of names of groups of mutually exclusive options. The options in
4926: each group are listed in
4927: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
4928: The most specific setting of any option from the group takes
4929: precedence over all other options in the group. Options from the
4930: groups will be automatically added to
4931: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
4932: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
4933: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
4934: packages will fail if no option from the group is
4935: selected.</p></li>
4936: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
4937: of names of sets of options. At least one option from each set must
4938: be selected. The options in each set are listed in
4939: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
4940: Options from the sets will be automatically added to
4941: <code class="varname">PKG_SUPPORTED_OPTIONS</code>. Building the package will
4942: fail if no option from the set is selected.</p></li>
4943: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
4944: build options which are enabled by default.</p></li>
4945: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
4946: of
4947: “<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>”
1.76 ! rillig 4948: pairs that map legacy <code class="filename">/etc/mk.conf</code> variables to
1.75 rillig 4949: their option counterparts. Pairs should be added with
4950: “<span class="quote">+=</span>” to keep the listing of global legacy variables. A
4951: warning will be issued if the user uses a legacy
4952: variable.</p></li>
4953: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
4954: of
4955: “<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>”
4956: pairs that map options that have been renamed to their new
4957: counterparts. Pairs should be added with “<span class="quote">+=</span>” to keep
4958: the listing of global legacy options. A warning will be issued if
4959: the user uses a legacy option.</p></li>
4960: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
4961: options implied by deprecated variables used. This can be used for
4962: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
4963: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
4964: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
4965: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
4966: a list of warnings about deprecated variables or options used, and
4967: what to use instead.</p></li>
4968: </ol></div>
4969: <p>A package should never modify
4970: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
4971: <code class="varname">PKG_OPTIONS_VAR</code>. These are strictly user-settable.
4972: To suggest a default set of options, use
4973: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
4974: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
1.76 ! rillig 4975: including <code class="filename">bsd.options.mk</code>. If none of
1.75 rillig 4976: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
4977: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
4978: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
4979: happen with platform-specific options if none of them is supported on
4980: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
4981: empty list and the package is otherwise treated as not using the
4982: options framework.</p>
1.76 ! rillig 4983: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
1.75 rillig 4984: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
4985: build options, properly filtered to remove unsupported and duplicate
4986: options.</p>
4987: <p>The remaining sections contain the logic that is specific to
4988: each option. The correct way to check for an option is to check
4989: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
4990: <pre class="programlisting">
4991: .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
4992: </pre>
4993: </div>
4994: <div class="sect1" lang="en">
4995: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4996: <a name="option-names"></a>13.3. Option Names</h2></div></div></div>
4997: <p>Options that enable similar features in different packages (like
4998: optional support for a library) should use a common name in all
4999: packages that support it (like the name of the library). If another
5000: package already has an option with the same meaning, use the same
5001: name.</p>
5002: <p>Options that enable features specific to one package, where it's
5003: unlikely that another (unrelated) package has the same (or a similar)
5004: optional feature, should use a name prefixed with
5005: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
5006: <p>If a group of related packages share an optional feature
5007: specific to that group, prefix it with the name of the
5008: “<span class="quote">main</span>” package
5009: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
5010: <p>For new options, add a line to
1.76 ! rillig 5011: <code class="filename">mk/defaults/options.description</code>. Lines have two
1.75 rillig 5012: fields, separated by tab. The first field is the option name, the
5013: second its description. The description should be a whole sentence
5014: (starting with an uppercase letter and ending with a period) that
5015: describes what enabling the option does. E. g. “<span class="quote">Enable ispell
5016: support.</span>” The file is sorted by option names.</p>
5017: </div>
5018: </div>
5019: <div class="chapter" lang="en">
5020: <div class="titlepage"><div><div><h2 class="title">
5021: <a name="build"></a>Chapter 14. The build process</h2></div></div></div>
5022: <div class="toc">
5023: <p><b>Table of Contents</b></p>
5024: <dl>
5025: <dt><span class="sect1"><a href="#build.intro">14.1. Introduction</a></span></dt>
5026: <dt><span class="sect1"><a href="#build.prefix">14.2. Program location</a></span></dt>
5027: <dt><span class="sect1"><a href="#build.builddirs">14.3. Directories used during the build process</a></span></dt>
5028: <dt><span class="sect1"><a href="#build.running">14.4. Running a phase</a></span></dt>
5029: <dt><span class="sect1"><a href="#build.fetch">14.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
5030: <dt><span class="sect1"><a href="#build.checksum">14.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
5031: <dt><span class="sect1"><a href="#build.extract">14.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
5032: <dt><span class="sect1"><a href="#build.patch">14.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
5033: <dt><span class="sect1"><a href="#build.tools">14.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
5034: <dt><span class="sect1"><a href="#build.wrapper">14.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
5035: <dt><span class="sect1"><a href="#build.configure">14.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
5036: <dt><span class="sect1"><a href="#build.build">14.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
5037: <dt><span class="sect1"><a href="#build.test">14.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
5038: <dt><span class="sect1"><a href="#build.install">14.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
5039: <dt><span class="sect1"><a href="#build.package">14.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
5040: <dt><span class="sect1"><a href="#build.helpful-targets">14.16. Other helpful targets</a></span></dt>
5041: </dl>
5042: </div>
5043: <div class="sect1" lang="en">
5044: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5045: <a name="build.intro"></a>14.1. Introduction</h2></div></div></div>
5046: <p>This chapter gives a detailed description on how a package is
5047: built. Building a package is separated into different
5048: <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
5049: <code class="varname">build</code>, <code class="varname">install</code>), all of which are
5050: described in the following sections. Each phase is splitted into
5051: so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
5052: containing phase, prefixed by one of <code class="varname">pre-</code>,
5053: <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
5054: <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
5055: of the actual work is done in the <code class="varname">do-*</code> stages.</p>
5056: <p>The basic steps for building a program are always the same. First
5057: the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
5058: the local system and then extracted. After any pkgsrc-specific patches
5059: to compile properly are applied, the software can be configured, then
5060: built (usually by compiling), and finally the generated binaries, etc.
5061: can be put into place on the system.</p>
5062: </div>
5063: <div class="sect1" lang="en">
5064: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5065: <a name="build.prefix"></a>14.2. Program location</h2></div></div></div>
5066: <p>Before outlining the process performed by the NetBSD package system in
5067: the next section, here's a brief discussion on where programs are
5068: installed, and which variables influence this.</p>
5069: <p>The automatic variable <code class="varname">PREFIX</code> indicates
5070: where all files of the final program shall be installed. It is
5071: usually set to <code class="varname">LOCALBASE</code>
1.76 ! rillig 5072: (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
1.75 rillig 5073: for pkgs in the “<span class="quote">cross</span>” category. The value of
5074: <code class="varname">PREFIX</code> needs to be put
5075: into the various places in the program's source where paths to
5076: these files are encoded. See <a href="#components.patches" title="8.3. patches/*">Section 8.3, “patches/*”</a> and <a href="#fixes.libtool" title="16.3.1. Shared libraries - libtool">Section 16.3.1, “Shared libraries - libtool”</a> for more details.</p>
5077: <p>When choosing which of these variables to use,
5078: follow the following rules:</p>
5079: <div class="itemizedlist"><ul type="disc">
5080: <li><p><code class="varname">PREFIX</code> always points to the location where the current
5081: pkg will be installed. When referring to a pkg's own installation path,
5082: use “<span class="quote">${PREFIX}</span>”.</p></li>
5083: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs are installed.
5084: If you need to construct a -I or -L argument to the compiler to find
5085: includes and libraries installed by another non-X11 pkg, use
5086: “<span class="quote">${LOCALBASE}</span>”.</p></li>
5087: <li><p><code class="varname">X11BASE</code> is where the actual X11 distribution (from
5088: xsrc, etc.) is installed. When looking for
5089: <span class="emphasis"><em>standard</em></span> X11 includes (not
5090: those installed by a pkg), use “<span class="quote">${X11BASE}</span>”.</p></li>
5091: <li>
5092: <p>X11-based packages are special in that they may be installed in
5093: either <code class="varname">X11BASE</code> or <code class="varname">LOCALBASE</code>.</p>
5094: <p>Usually, X11 packages should be installed under
5095: <code class="varname">LOCALBASE</code> whenever possible. Note that you will
1.76 ! rillig 5096: need to include <code class="filename">../../mk/x11.buildlink3.mk</code>
1.75 rillig 5097: in them to request the
5098: presence of X11 and to get the right compilation flags.</p>
5099: <p>Even though, there are some packages that cannot be installed
5100: under <code class="varname">LOCALBASE</code>: those that come with app-defaults
5101: files. These packages are special and they must be placed under
5102: <code class="varname">X11BASE</code>. To accomplish this, set either
5103: <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
5104: your package.</p>
5105: <p>Some notes: If you need
5106: to find includes or libraries installed by a pkg that has
5107: <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
1.76 ! rillig 5108: its pkg <code class="filename">Makefile</code>, you need to look in
! 5109: <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
! 5110: <code class="filename">${LOCALBASE}</code>. To force installation of
1.75 rillig 5111: all X11 packages in <code class="varname">LOCALBASE</code>, the
1.76 ! rillig 5112: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a> package
1.75 rillig 5113: is enabled by default.</p>
5114: </li>
5115: <li><p><code class="varname">X11PREFIX</code> should be used to refer to the installed
5116: location of an X11 package. <code class="varname">X11PREFIX</code> will be set to
5117: <code class="varname">X11BASE</code> if xpkgwedge is not installed,
5118: and to <code class="varname">LOCALBASE</code> if xpkgwedge is installed.</p></li>
5119: <li>
5120: <p>If xpkgwedge is installed, it is possible to have some packages installed
5121: in <code class="varname">X11BASE</code> and some in <code class="varname">LOCALBASE</code>.
5122: To determine the prefix of an installed package, the
5123: <code class="varname">EVAL_PREFIX</code> definition can be used. It takes pairs in the
5124: format “<span class="quote">DIRNAME=<package></span>”, and the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> variable
5125: <code class="varname">DIRNAME</code> will be set to the prefix of the installed
5126: package <package>, or “<span class="quote">${X11PREFIX}</span>” if the package is
5127: not installed.</p>
5128: <p>This is best illustrated by example.</p>
5129: <p>The following lines are taken from
1.76 ! rillig 5130: <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
1.75 rillig 5131: <pre class="programlisting">
5132: EVAL_PREFIX+= GTKDIR=gtk+
5133: CONFIGURE_ARGS+= --with-guile-prefix=${LOCALBASE:Q}
5134: CONFIGURE_ARGS+= --with-gtk-prefix=${GTKDIR:Q}
5135: CONFIGURE_ARGS+= --enable-multibyte
5136: </pre>
5137: <p>Specific defaults can be defined for the packages evaluated using
5138: <code class="varname">EVAL_PREFIX</code>, by using a definition of the form:</p>
5139: <pre class="programlisting">
5140: GTKDIR_DEFAULT= ${LOCALBASE}
5141: </pre>
5142: <p>where <code class="varname">GTKDIR</code> corresponds
5143: to the first definition in
5144: the <code class="varname">EVAL_PREFIX</code> pair.</p>
5145: </li>
1.76 ! rillig 5146: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.75 rillig 5147: install files according to <a href="http://netbsd.gw.com/cgi-bin/man-cgi?hier+7+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">hier</span>(7)</span></a>, with the exception that
1.76 ! rillig 5148: manual pages go into <code class="filename">${PREFIX}/man</code>, not
! 5149: <code class="filename">${PREFIX}/share/man</code>.</p></li>
1.75 rillig 5150: </ul></div>
5151: </div>
5152: <div class="sect1" lang="en">
5153: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5154: <a name="build.builddirs"></a>14.3. Directories used during the build process</h2></div></div></div>
5155: <p>When building a package, a number of directories is used to store
5156: source files, temporary files, pkgsrc-internal files, and so on. These
5157: directories are explained here.</p>
5158: <p>Some of the directory variables contain relative pathnames. There
5159: are two common base directories for these relative directories:
5160: <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
5161: pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
5162: inside the package itself.</p>
5163: <div class="variablelist"><dl>
5164: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
5165: <dd><p>This is an absolute pathname that points to the pkgsrc
5166: root directory. Generally, you don't need
5167: it.</p></dd>
5168: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
5169: <dd><p>This is a pathname relative to
5170: <code class="varname">PKGSRCDIR</code> that points to the current
5171: package.</p></dd>
5172: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
5173: <dd><p>This is an absolute pathname pointing to the directory
5174: where all work takes place. The distfiles are extraced to this
5175: directory. It also contains temporary directories and log files used by
5176: the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
5177: the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
5178: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
5179: <dd><p>This is an absolute pathname pointing to the directory
5180: where the distfiles are extracted. It is usually a direct subdirectory
5181: of <code class="varname">WRKDIR</code>, and often it's the only directory entry
5182: that isn't hidden. This variable may be changed by a package
1.76 ! rillig 5183: <code class="filename">Makefile</code>.</p></dd>
1.75 rillig 5184: </dl></div>
5185: </div>
5186: <div class="sect1" lang="en">
5187: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5188: <a name="build.running"></a>14.4. Running a phase</h2></div></div></div>
5189: <p>You can run a particular phase by typing <span><strong class="command">make
5190: phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
5191: phase. This will automatically run all phases that are required for this
5192: phase. The default phase is <code class="varname">build</code>, that is, when you
5193: run <span><strong class="command">make</strong></span> without parameters in a package directory,
5194: the package will be built, but not installed.</p>
5195: </div>
5196: <div class="sect1" lang="en">
5197: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5198: <a name="build.fetch"></a>14.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
5199: <p>This will check if the file(s) given in the variables
5200: <code class="varname">DISTFILES</code> and <code class="varname">PATCHFILES</code> (as
5201: defined in the package's Makefile) are present on the
1.76 ! rillig 5202: local system in <code class="filename">/usr/pkgsrc/distfiles</code>. If they
1.75 rillig 5203: are not present, an attempt will be made to fetch them using commands
5204: of the form:</p>
5205: <pre class="programlisting">
5206: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
5207: </pre>
5208: <p>where ${site} varies through several possibilities in turn: first,
5209: <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the sites
5210: specified in either <code class="varname">SITES.file</code> if defined, else
5211: <code class="varname">MASTER_SITES</code> or <code class="varname">PATCH_SITES</code>, as
5212: applies, then finally the value of
5213: <code class="varname">MASTER_SITE_BACKUP</code>. The order of all except the
5214: first can be optionally sorted by the user, via setting either
5215: <code class="varname">MASTER_SORT_AWK</code> or
5216: <code class="varname">MASTER_SORT_REGEX</code>.</p>
5217: </div>
5218: <div class="sect1" lang="en">
5219: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5220: <a name="build.checksum"></a>14.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
5221: <p>After the distfile(s) are fetched, their checksum is generated and
5222: compared with the checksums stored in the distinfo file. If the
5223: checksums don't match, the build is aborted. This is to ensure the same
5224: distfile is used for building, and that the distfile wasn't changed,
5225: e.g. by some malign force, deliberately changed distfiles on the master
5226: distribution site or network lossage.</p>
5227: </div>
5228: <div class="sect1" lang="en">
5229: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5230: <a name="build.extract"></a>14.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
5231: <p>When the distfiles are present on the local system, they
5232: need to be extracted, as they usually come in the form of some
5233: compressed archive format.</p>
5234: <p>By default, all <code class="varname">DISTFILES</code> are
5235: extracted. If you only need some of them, you can set the
5236: <code class="varname">EXTRACT_ONLY</code> variable to the list of those
5237: files.</p>
5238: <p>Extracting the files is usually done by a little program,
1.76 ! rillig 5239: <code class="filename">mk/scripts/extract</code>, which already knows how
1.75 rillig 5240: to extract various archive formats, so most likely you will not
5241: need to change anything here. But if you need, the following
5242: variables may help you:</p>
5243: <div class="variablelist"><dl>
5244: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
5245: <dd><p>Use these variables to override the default
5246: options for an extract command, which are defined in
1.76 ! rillig 5247: <code class="filename">mk/scripts/extract</code>.</p></dd>
1.75 rillig 5248: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
5249: <dd><p>This variable can be set to
5250: <code class="literal">pax</code>, <code class="literal">tar</code> or an absolute
5251: pathname pointing to the command with which tar archives should
5252: be extracted.</p></dd>
5253: </dl></div>
1.76 ! rillig 5254: <p>If the <code class="filename">extract</code> program doesn't serve
1.75 rillig 5255: your needs, you can also override the
5256: <code class="varname">EXTRACT_CMD</code> variable, which holds the command
5257: used for extracting the files. This command is executed in the
1.76 ! rillig 5258: <code class="filename">${WRKSRC}</code> directory. During execution of
1.75 rillig 5259: this command, the shell variable <code class="varname">extract_file</code>
5260: holds the absolute pathname of the file that is going to be
5261: extracted.</p>
5262: <p>And if that still does not suffice, you can override the
5263: <code class="varname">do-extract</code> target in the package
5264: Makefile.</p>
5265: </div>
5266: <div class="sect1" lang="en">
5267: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5268: <a name="build.patch"></a>14.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
5269: <p>After extraction, all the patches named by the
5270: <code class="varname">PATCHFILES</code>, those present in the patches
5271: subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
1.76 ! rillig 5272: <code class="filename">/usr/local/patches/graphics/png</code>) are applied.
! 5273: Patchfiles ending in <code class="filename">.Z</code> or
! 5274: <code class="filename">.gz</code> are uncompressed before they are applied,
! 5275: files ending in <code class="filename">.orig</code> or
! 5276: <code class="filename">.rej</code> are ignored. Any special options to <a href="http://netbsd.gw.com/cgi-bin/man-cgi?patch+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">patch</span>(1)</span></a>
1.75 rillig 5277: can be handed in <code class="varname">PATCH_DIST_ARGS</code>.
5278: See <a href="#components.patches" title="8.3. patches/*">Section 8.3, “patches/*”</a> for more details.</p>
5279: <p>By default <a href="http://netbsd.gw.com/cgi-bin/man-cgi?patch+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">patch</span>(1)</span></a> is given special args to make it fail if the
5280: patches apply with some lines of fuzz. Please fix (regen) the patches
5281: so that they apply cleanly. The rationale behind this is that
5282: patches that don't apply cleanly may end up being applied in the wrong
5283: place, and cause severe harm there.</p>
5284: </div>
5285: <div class="sect1" lang="en">
5286: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5287: <a name="build.tools"></a>14.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
5288: <p>This is covered in
5289: <a href="#tools" title="Chapter 15. Tools needed for building or running">Chapter 15, <i>Tools needed for building or running</i></a>.
5290: </p>
5291: </div>
5292: <div class="sect1" lang="en">
5293: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5294: <a name="build.wrapper"></a>14.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
5295: <p>This phase creates wrapper programs for the compilers and
5296: linkers. The following variables can be used to tweak the
5297: wrappers.</p>
5298: <div class="variablelist"><dl>
5299: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
5300: <dd><p>The command used to print progress
5301: messages. Does nothing by default. Set to
5302: <code class="literal">${ECHO}</code> to see the progress
5303: messages.</p></dd>
5304: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
5305: <dd><p>This variable can be set to
5306: <code class="literal">yes</code> (default) or
5307: <code class="literal">no</code>, depending on whether you want
5308: additional information in the wrapper log
5309: file.</p></dd>
5310: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
5311: <dd><p>This variable can be set to
5312: <code class="literal">yes</code> or <code class="literal">no</code>,
5313: depending on whether the wrapper should use its cache,
5314: which will improve the speed. The default value is
5315: <code class="literal">yes</code>, but is forced to
5316: <code class="literal">no</code> if the platform does not support
5317: it.</p></dd>
5318: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
5319: <dd><p>A list of reordering commands. A
5320: reordering command has the form
5321: <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
5322: It ensures that that
5323: <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code>
5324: occurs before
5325: <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
5326: </p></dd>
5327: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
5328: <dd><p>A list of transformation commands. [TODO:
5329: investigate further]</p></dd>
5330: </dl></div>
5331: </div>
5332: <div class="sect1" lang="en">
5333: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5334: <a name="build.configure"></a>14.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
5335: <p>Most pieces of software need information on the header files,
5336: system calls, and library routines which are available on the platform
5337: they run on. The process of determining this information is known as
5338: configuration, and is usually automated. In most cases, a script is
5339: supplied with the distfiles, and its invocation results in generation of
5340: header files, Makefiles, etc.</p>
5341: <p>If the package contains a configure script, this can be invoked by
5342: setting <code class="varname">HAS_CONFIGURE</code> to “<span class="quote">yes</span>”. If the
5343: configure script is a GNU autoconf script, you should set
5344: <code class="varname">GNU_CONFIGURE</code> to “<span class="quote">yes</span>” instead. What
5345: happens in the <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
5346: <pre class="programlisting">
5347: .for d in ${CONFIGURE_DIRS}
5348: cd ${WRKSRC} && cd ${d} && env ${CONFIGURE_ENV} \
5349: ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
5350: .endfor
5351: </pre>
5352: <p><code class="varname">CONFIGURE_DIRS</code> (default: “<span class="quote">.</span>”) is a
5353: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
5354: these directories, the configure script is run with the environment
5355: <code class="varname">CONFIGURE_ENV</code> and arguments
5356: <code class="varname">CONFIGURE_ARGS</code>. The variables
5357: <code class="varname">CONFIGURE_ENV</code>, <code class="varname">CONFIGURE_SCRIPT</code>
5358: (default: “<span class="quote">./configure</span>”) and
5359: <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
5360: package.</p>
1.76 ! rillig 5361: <p>If the program uses an <code class="filename">Imakefile</code> for
1.75 rillig 5362: configuration, the appropriate steps can be invoked by setting
5363: <code class="varname">USE_IMAKE</code> to “<span class="quote">yes</span>”. (If you only want
5364: the package installed in <code class="varname">${X11PREFIX}</code> but xmkmf not
5365: being run, set <code class="varname">USE_X11BASE</code> instead.)</p>
5366: </div>
5367: <div class="sect1" lang="en">
5368: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5369: <a name="build.build"></a>14.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
5370: <p>For building a package, a rough equivalent of the following code
5371: is executed.</p>
5372: <pre class="programlisting">
5373: .for d in ${BUILD_DIRS}
5374: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
5375: ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
5376: -f ${MAKEFILE} ${BUILD_TARGET}
5377: .endfor
5378: </pre>
5379: <p><code class="varname">BUILD_DIRS</code> (default: “<span class="quote">.</span>”) is a
5380: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
5381: these directories, <code class="varname">MAKE_PROGRAM</code> is run with the
5382: environment <code class="varname">MAKE_ENV</code> and arguments
5383: <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
5384: <code class="varname">MAKE_ENV</code>, <code class="varname">BUILD_MAKE_FLAGS</code>,
5385: <code class="varname">MAKEFILE</code> and <code class="varname">BUILD_TARGET</code> may all
5386: be changed by the package.</p>
5387: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
5388: “<span class="quote">gmake</span>” if <code class="varname">USE_TOOLS</code> contains
5389: “<span class="quote">gmake</span>”, “<span class="quote">make</span>” otherwise. The default value
5390: of <code class="varname">MAKEFILE</code> is “<span class="quote">Makefile</span>”, and
5391: <code class="varname">BUILD_TARGET</code> defaults to “<span class="quote">all</span>”.</p>
5392: </div>
5393: <div class="sect1" lang="en">
5394: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5395: <a name="build.test"></a>14.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
5396: <p>[TODO]</p>
5397: </div>
5398: <div class="sect1" lang="en">
5399: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5400: <a name="build.install"></a>14.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
5401: <p>Once the build stage has completed, the final step is to
5402: install the software in public directories, so users can access
5403: the programs and files.</p>
5404: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
5405: equivalent of the following code is executed. Additionally,
5406: before and after this code, much magic is performed to do
5407: consistency checks, registering the package, and so on.</p>
5408: <pre class="programlisting">
5409: .for d in ${INSTALL_DIRS}
5410: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
5411: ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
5412: -f ${MAKEFILE} ${BUILD_TARGET}
5413: .endfor
5414: </pre>
5415: <p>The variable's meanings are analogous to the ones in the
5416: <span class="emphasis"><em>build</em></span> phase.
5417: <code class="varname">INSTALL_DIRS</code> defaults to
5418: <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
5419: is “<span class="quote">install</span>” by default, plus
5420: “<span class="quote">install.man</span>” if <code class="varname">USE_IMAKE</code> is
5421: defined.</p>
5422: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
5423: variables are useful. They are all variations of the
5424: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?install+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">install</span>(1)</span></a> command that have the owner, group and
5425: permissions preset. <code class="varname">INSTALL</code> is the plain
5426: install command. The specialized variants, together with their
5427: intended use, are:</p>
5428: <div class="variablelist"><dl>
5429: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
5430: <dd><p>directories that contain binaries</p></dd>
5431: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
5432: <dd><p>directories that contain scripts</p></dd>
5433: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
5434: <dd><p>directories that contain shared and static libraries</p></dd>
5435: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
5436: <dd><p>directories that contain data files</p></dd>
5437: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
5438: <dd><p>directories that contain man pages</p></dd>
5439: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
5440: <dd><p>binaries that can be stripped from debugging symbols</p></dd>
5441: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
5442: <dd><p>binaries that cannot be stripped</p></dd>
5443: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
5444: <dd><p>game binaries</p></dd>
5445: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
5446: <dd><p>shared and static libraries</p></dd>
5447: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
5448: <dd><p>data files</p></dd>
5449: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
5450: <dd><p>data files for games</p></dd>
5451: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
5452: <dd><p>man pages</p></dd>
5453: </dl></div>
5454: <p>Some other variables are:</p>
5455: <div class="variablelist"><dl>
5456: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
5457: <dd><p>A list of directories relative to
5458: <code class="varname">PREFIX</code> that are created by pkgsrc at
5459: the beginning of the <span class="emphasis"><em>install</em></span> phase. If
5460: this variable is set,
5461: <code class="varname">NO_MTREE</code>=“<span class="quote">yes</span>” is
5462: assumed, which means that the package claims to create
5463: all needed directories itself before installing files to
5464: it. Therefore this variable should only be set in
1.76 ! rillig 5465: <code class="filename">Makefile</code>s that are under control of
1.75 rillig 5466: the package's author.</p></dd>
5467: </dl></div>
5468: </div>
5469: <div class="sect1" lang="en">
5470: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5471: <a name="build.package"></a>14.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
5472: <p>[TODO]</p>
5473: </div>
5474: <div class="sect1" lang="en">
5475: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5476: <a name="build.helpful-targets"></a>14.16. Other helpful targets</h2></div></div></div>
5477: <div class="variablelist"><dl>
5478: <dt><span class="term">pre/post-*</span></dt>
5479: <dd><p>For any of the main targets described in the previous section, two
5480: auxiliary targets exist with “<span class="quote">pre-</span>” and
5481: “<span class="quote">post-</span>” used as a prefix
5482: for the main target's name. These targets are invoked before and
5483: after the main target is called, allowing extra configuration or
5484: installation steps be performed from a package's Makefile, for
5485: example, which a program's configure script
5486: or install target omitted.</p></dd>
5487: <dt><span class="term">do-*</span></dt>
5488: <dd><p>Should one of the main targets do the wrong thing, and should there
5489: be no variable to fix this, you can redefine it with the do-*
5490: target. (Note that redefining the target itself instead of the
5491: do-* target is a bad idea, as the pre-* and post-* targets won't be
5492: called anymore, etc.) You will not usually need to do this.</p></dd>
5493: <dt><span class="term">reinstall</span></dt>
5494: <dd><p>If you did a <span><strong class="command">make install</strong></span> and you noticed some file
5495: was not installed properly, you can repeat the installation with this
5496: target, which will ignore the “<span class="quote">already installed</span>” flag.</p></dd>
5497: <dt><span class="term">deinstall</span></dt>
5498: <dd>
5499: <p>This target does a <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a> in the current directory,
5500: effectively de-installing the package. The following variables can
5501: be used to tune the behaviour:</p>
5502: <div class="variablelist"><dl>
5503: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
5504: <dd><p>Add a "-v" to the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a> command.</p></dd>
5505: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
5506: <dd><p>Remove all packages that require (depend on) the given package.
5507: This can be used to remove any packages that may have been pulled in
5508: by a given package, e.g. if <span><strong class="command">make deinstall
5509: DEINSTALLDEPENDS=1</strong></span> is done in
1.76 ! rillig 5510: <code class="filename">pkgsrc/x11/kde</code>, this is likely to remove whole
1.75 rillig 5511: KDE. Works by adding “<span class="quote">-R</span>” to the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a> command line.</p></dd>
5512: </dl></div>
5513: </dd>
5514: <dt><span class="term">update</span></dt>
5515: <dd>
5516: <p>This target causes the current package to be updated to the latest
5517: version. The package and all depending packages first get de-installed,
5518: then current versions of the corresponding packages get compiled and
5519: installed. This is similar to manually noting which packages are
5520: currently installed, then performing a series of <span><strong class="command">make
5521: deinstall</strong></span> and <span><strong class="command">make install</strong></span> (or whatever
5522: <code class="varname">UPDATE_TARGET</code> is set to) for these packages.</p>
5523: <p>You can use the “<span class="quote">update</span>” target to resume package
5524: updating in case a previous <span><strong class="command">make update</strong></span> was interrupted
5525: for some reason. However, in this case, make sure you don't call
5526: <span><strong class="command">make clean</strong></span> or otherwise remove the list of dependent
5527: packages in <code class="varname">WRKDIR</code>. Otherwise, you lose the
5528: ability to automatically update the current package along with the
5529: dependent packages you have installed.</p>
5530: <p>Resuming an interrupted <span><strong class="command">make update</strong></span> will only work as
5531: long as the package tree remains unchanged. If the source code for
5532: one of the packages to be updated has been changed, resuming
5533: <span><strong class="command">make update</strong></span> will most certainly fail!</p>
5534: <p>The following variables can be used either on the command line or in
1.76 ! rillig 5535: <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75 rillig 5536: <span><strong class="command">make update</strong></span>:</p>
5537: <div class="variablelist"><dl>
5538: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
5539: <dd><p>Install target to recursively use for the updated package and the
5540: dependent packages. Defaults to <code class="varname">DEPENDS_TARGET</code> if set,
5541: “<span class="quote">install</span>” otherwise for <span><strong class="command">make update</strong></span>.
5542: e.g. <span><strong class="command">make update UPDATE_TARGET=package</strong></span></p></dd>
5543: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
5544: <dd><p>Don't clean up after updating. Useful if you want to leave the
5545: work sources of the updated packages around for inspection or
5546: other purposes. Be sure you eventually clean up the source
5547: tree (see the “<span class="quote">clean-update</span>” target below) or you may
5548: run into troubles with old source code still lying around on your
5549: next <span><strong class="command">make</strong></span> or <span><strong class="command">make update</strong></span>.</p></dd>
5550: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
5551: <dd><p>Deinstall each package before installing (making
5552: <code class="varname">DEPENDS_TARGET</code>). This may be necessary if the
5553: “<span class="quote">clean-update</span>” target (see below) was called after
5554: interrupting a running <span><strong class="command">make update</strong></span>.</p></dd>
5555: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
5556: <dd><p>Allows you to disable recursion and hardcode the target for
5557: packages. The default is “<span class="quote">update</span>” for the update target,
5558: facilitating a recursive update of prerequisite packages.
5559: Only set <code class="varname">DEPENDS_TARGET</code> if you want to disable
5560: recursive updates. Use <code class="varname">UPDATE_TARGET</code> instead to just
5561: set a specific target for each package to be installed during
5562: <span><strong class="command">make update</strong></span> (see above).</p></dd>
5563: </dl></div>
5564: </dd>
5565: <dt><span class="term">clean-update</span></dt>
5566: <dd>
5567: <p>Clean the source tree for all packages that would get updated if
5568: <span><strong class="command">make update</strong></span> was called from the current directory.
5569: This target should not be used if the current package (or any of its
5570: depending packages) have already been de-installed (e.g., after calling
5571: <span><strong class="command">make update</strong></span>) or you may lose some packages you intended
5572: to update. As a rule of thumb: only use this target
5573: <span class="emphasis"><em>before</em></span> the first time you run
5574: <span><strong class="command">make update</strong></span> and only if you have a dirty package tree
5575: (e.g., if you used <code class="varname">NOCLEAN</code>).</p>
5576: <p>If you are unsure about whether your tree is clean, you can either
5577: perform a <span><strong class="command">make clean</strong></span> at the top of the tree, or use
5578: the following sequence of commands from the directory of the package
5579: you want to update (<span class="emphasis"><em>before</em></span> running
5580: <span><strong class="command">make update</strong></span> for the first time, otherwise you lose
5581: all the packages you wanted to update!):</p>
5582: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
5583: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
5584: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong></pre>
5585: <p>The following variables can be used either on the command line or in
1.76 ! rillig 5586: <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75 rillig 5587: <span><strong class="command">make clean-update</strong></span>:</p>
5588: <div class="variablelist"><dl>
5589: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
5590: <dd><p>After <span><strong class="command">make clean</strong></span>, do not reconstruct the list of
5591: directories to update for this package. Only use this if <span><strong class="command">make
5592: update</strong></span> successfully installed all packages you wanted to
5593: update. Normally, this is done automatically on <span><strong class="command">make
5594: update</strong></span>, but may have been suppressed by the
5595: <code class="varname">NOCLEAN</code> variable (see above).</p></dd>
5596: </dl></div>
5597: </dd>
5598: <dt><span class="term">info</span></dt>
5599: <dd><p>This target invokes <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_info+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_info</span>(1)</span></a> for the current
5600: package. You can use this to check which version of a package is
5601: installed.</p></dd>
5602: <dt><span class="term">readme</span></dt>
1.76 ! rillig 5603: <dd><p>This target generates a <code class="filename">README.html</code> file, which
1.75 rillig 5604: can be viewed using a browser such as
1.76 ! rillig 5605: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/mozilla/README.html" target="_top"><code class="filename">www/mozilla</code></a> or
! 5606: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/links/README.html" target="_top"><code class="filename">www/links</code></a>.
1.75 rillig 5607: The generated files contain references to any
5608: packages which are in the <code class="varname">PACKAGES</code> directory on
5609: the local host. The generated files can be made to refer to URLs based on
5610: <code class="varname">FTP_PKG_URL_HOST</code> and
5611: <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I wanted to generate
1.76 ! rillig 5612: <code class="filename">README.html</code> files which pointed to binary packages
1.75 rillig 5613: on the local machine, in the directory
1.76 ! rillig 5614: <code class="filename">/usr/packages</code>, set
1.75 rillig 5615: <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
5616: <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
5617: <code class="varname">${PACKAGES}</code> directory and its subdirectories will be
5618: searched for all the binary packages.</p></dd>
5619: <dt><span class="term">readme-all</span></dt>
1.76 ! rillig 5620: <dd><p>Use this target to create a file <code class="filename">README-all.html</code>
1.75 rillig 5621: which contains a list of all packages currently available in the NetBSD
5622: Packages Collection, together with the category they belong to and a
5623: short description. This file is compiled from the
1.76 ! rillig 5624: <code class="filename">pkgsrc/*/README.html</code> files, so be sure to run
1.75 rillig 5625: this <span class="emphasis"><em>after</em></span> a <span><strong class="command">make readme</strong></span>.</p></dd>
5626: <dt><span class="term">cdrom-readme</span></dt>
5627: <dd><p>This is very much the same as the “<span class="quote">readme</span>” target (see
5628: above), but is to be used when generating a pkgsrc tree to be written
5629: to a CD-ROM. This target also produces
1.76 ! rillig 5630: <code class="filename">README.html</code> files, and can be made to refer
1.75 rillig 5631: to URLs based on <code class="varname">CDROM_PKG_URL_HOST</code> and
5632: <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
5633: <dt><span class="term">show-distfiles</span></dt>
5634: <dd><p>This target shows which distfiles and patchfiles are needed to build
5635: the package. (<code class="varname">DISTFILES</code> and
1.76 ! rillig 5636: <code class="varname">PATCHFILES</code>, but not <code class="filename">patches/*</code>)</p></dd>
1.75 rillig 5637: <dt><span class="term">show-downlevel</span></dt>
5638: <dd><p>This target shows nothing if the package is not installed. If a version
5639: of this package is installed, but is not the version provided in this
5640: version of pkgsrc, then a warning message is displayed. This target can
5641: be used to show which of your installed packages are downlevel, and so
5642: the old versions can be deleted, and the current ones added.</p></dd>
5643: <dt><span class="term">show-pkgsrc-dir</span></dt>
5644: <dd><p>This target shows the directory in the pkgsrc hierarchy from which the
5645: package can be built and installed. This may not be the same directory
5646: as the one from which the package was installed. This target is intended
5647: to be used by people who may wish to upgrade many packages on a single
5648: host, and can be invoked from the top-level pkgsrc Makefile by using the
5649: “<span class="quote">show-host-specific-pkgs</span>” target.</p></dd>
5650: <dt><span class="term">show-installed-depends</span></dt>
5651: <dd><p>This target shows which installed packages match the current package's
5652: <code class="varname">DEPENDS</code>. Useful if out of date dependencies are
5653: causing build problems.</p></dd>
5654: <dt><span class="term">check-shlibs</span></dt>
5655: <dd><p>After a package is installed, check all its binaries and (on ELF
5656: platforms) shared libraries to see if they find the shared libs they need.
5657: Run by default if <code class="varname">PKG_DEVELOPER</code> is set in
1.76 ! rillig 5658: <code class="filename">/etc/mk.conf</code>.</p></dd>
1.75 rillig 5659: <dt><span class="term">print-PLIST</span></dt>
5660: <dd>
5661: <p>After a “<span class="quote">make install</span>” from a new or
5662: upgraded pkg, this prints out an attempt to generate a new
1.76 ! rillig 5663: <code class="filename">PLIST</code> from a <span><strong class="command">find -newer
1.75 rillig 5664: work/.extract_done</strong></span>. An attempt is made to care
5665: for shared libs etc., but it is
5666: <span class="emphasis"><em>strongly</em></span> recommended to review the
5667: result before putting it into
1.76 ! rillig 5668: <code class="filename">PLIST</code>. On upgrades, it's useful to
1.75 rillig 5669: diff the output of this command against an already
1.76 ! rillig 5670: existing <code class="filename">PLIST</code> file.</p>
1.75 rillig 5671: <p>If the package installs files via <a href="http://netbsd.gw.com/cgi-bin/man-cgi?tar+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span></a> or other
5672: methods that don't update file access times, be sure to
5673: add these files manually to your
1.76 ! rillig 5674: <code class="filename">PLIST</code>, as the “<span class="quote">find
1.75 rillig 5675: -newer</span>” command used by this target won't catch
5676: them!</p>
5677: <p> See <a href="#print-PLIST" title="10.3. Tweaking output of make print-PLIST">Section 10.3, “Tweaking output of <span><strong class="command">make print-PLIST</strong></span>”</a> for more
5678: information on this target.</p>
5679: </dd>
5680: <dt><span class="term">bulk-package</span></dt>
5681: <dd>
5682: <p>Used to do bulk builds. If an appropriate binary package already exists,
5683: no action is taken. If not, this target will compile, install and
5684: package it (and its depends, if <code class="varname">PKG_DEPENDS</code> is
5685: set properly. See <a href="#binary.configuration" title="6.3.1. Configuration">Section 6.3.1, “Configuration”</a>).
5686: After creating the binary
5687: package, the sources, the just-installed package and its required
5688: packages are removed, preserving free disk space.</p>
5689: <p><span class="emphasis"><em>Beware that this target may deinstall all
5690: packages installed on a system!</em></span></p>
5691: </dd>
5692: <dt><span class="term">bulk-install</span></dt>
5693: <dd>
5694: <p>Used during bulk-installs to install required packages. If an
5695: up-to-date binary package is available, it will be installed via
5696: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>. If not, <span><strong class="command">make bulk-package</strong></span> will be executed,
5697: but the installed binary won't be removed. </p>
5698: <p> A binary package is considered “<span class="quote">up-to-date</span>” to be
5699: installed via <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> if:</p>
5700: <div class="itemizedlist"><ul type="disc">
1.76 ! rillig 5701: <li><p>None of the package's files (<code class="filename">Makefile</code>,
1.75 rillig 5702: ...) were modified since it was built.</p></li>
5703: <li><p>None of the package's required (binary) packages were
5704: modified since it was built.</p></li>
5705: </ul></div>
5706: <p><span class="emphasis"><em>Beware that this target may deinstall all
5707: packages installed on a system!</em></span></p>
5708: </dd>
5709: </dl></div>
5710: </div>
5711: </div>
5712: <div class="chapter" lang="en">
5713: <div class="titlepage"><div><div><h2 class="title">
5714: <a name="tools"></a>Chapter 15. Tools needed for building or running</h2></div></div></div>
5715: <div class="toc">
5716: <p><b>Table of Contents</b></p>
5717: <dl>
5718: <dt><span class="sect1"><a href="#pkgsrc-tools">15.1. Tools for pkgsrc builds</a></span></dt>
5719: <dt><span class="sect1"><a href="#package-tools">15.2. Tools needed by packages</a></span></dt>
5720: <dt><span class="sect1"><a href="#platform-tools">15.3. Tools provided by platforms</a></span></dt>
5721: </dl>
5722: </div>
5723: <p>
5724: The <code class="varname">USE_TOOLS</code> definition is used both internally
5725: by pkgsrc and also for individual packages to define what commands
5726: are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
5727: or for later run-time of an installed packaged (such as
5728: <code class="varname">DEPENDS</code>).
5729: If the native system provides an adequate tool, then in many cases, a pkgsrc
5730: package will not be used.
5731: </p>
5732: <p>
5733: When building a package, the replacement tools are
5734: made available in a directory (as symlinks or wrapper scripts)
5735: that is early in the executable search path. Just like the buildlink
5736: system, this helps with consistent builds.
5737: </p>
5738: <p>
5739: A tool may be needed to help build a specific package. For example,
5740: perl, GNU make (gmake) or yacc may be needed.
5741: </p>
5742: <p>
5743: Also a tool may be needed, for example, because the native system's supplied
5744: tool may be inefficient for building a package with pkgsrc.
5745: For example, a package may need GNU awk, bison (instead of
5746: yacc) or a better sed.
5747: </p>
5748: <p>
5749: The tools used by a package can be listed by running
5750: <span><strong class="command">make show-tools</strong></span>.
5751: </p>
5752: <div class="sect1" lang="en">
5753: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5754: <a name="pkgsrc-tools"></a>15.1. Tools for pkgsrc builds</h2></div></div></div>
5755: <p>
5756: The default set of tools used by pkgsrc is defined in
1.76 ! rillig 5757: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.75 rillig 5758: such as: <span><strong class="command">cat</strong></span>, <span><strong class="command">awk</strong></span>,
5759: <span><strong class="command">chmod</strong></span>, <span><strong class="command">test</strong></span>, and so on.
5760: These can be seen by running:
5761: <span><strong class="command">make show-var VARNAME=USE_TOOLS</strong></span>.
5762: </p>
5763: <p>
5764: If a package needs a specific program to build
5765: then the <code class="varname">USE_TOOLS</code> variable can be used
5766: to define the tools needed.
5767: </p>
5768: </div>
5769: <div class="sect1" lang="en">
5770: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5771: <a name="package-tools"></a>15.2. Tools needed by packages</h2></div></div></div>
5772: <p>
5773: In the following examples, the :pkgsrc means to use the pkgsrc version
5774: and not the native version for a build dependency.
5775: And the :run means that it is used for a
5776: run-time dependencies also (and becomes a DEPENDS).
5777: The default is a build dependency which can be set with
5778: :build. (So in this example, it is the same as gmake:build
5779: and pkg-config:build.)
5780: </p>
5781: <pre class="programlisting">
5782: USE_TOOLS+= mktemp:pkgsrc
5783: USE_TOOLS+= gmake perl:run pkg-config
5784: </pre>
5785: <p>
5786: When using the tools framework, a
5787: <code class="varname">TOOLS_PATH.foo</code> variable is defined
5788: which contains the full path to the appropriate tool. For example,
5789: <code class="varname">TOOLS_PATH.bash</code> could be “<span class="quote">/bin/bash</span>”
5790: on Linux systems.
5791: </p>
5792: <p>
5793: If you always need a pkgsrc version of the
5794: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
5795:
5796: </p>
5797: </div>
5798: <div class="sect1" lang="en">
5799: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5800: <a name="platform-tools"></a>15.3. Tools provided by platforms</h2></div></div></div>
5801: <p>
5802: When improving or porting pkgsrc to a new platform, have a look
5803: at (or create) the corresponding platform specific make file fragment under
1.76 ! rillig 5804: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
1.75 rillig 5805: the name of the common tools. For example:</p>
5806: <pre class="programlisting">
5807: .if exists(/usr/bin/bzcat)
5808: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
5809: .elif exists(/usr/bin/bzip2)
5810: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
5811: .endif
1.69 rillig 5812:
1.75 rillig 5813: TOOLS_PLATFORM.true?= true # shell builtin
5814: </pre>
5815: </div>
5816: </div>
5817: <div class="chapter" lang="en">
5818: <div class="titlepage"><div><div><h2 class="title">
5819: <a name="fixes"></a>Chapter 16. Making your package work</h2></div></div></div>
5820: <div class="toc">
5821: <p><b>Table of Contents</b></p>
5822: <dl>
5823: <dt><span class="sect1"><a href="#general-operation">16.1. General operation</a></span></dt>
5824: <dd><dl>
5825: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">16.1.1. How to pull in variables from /etc/mk.conf</a></span></dt>
5826: <dt><span class="sect2"><a href="#where-to-install-documentation">16.1.2. Where to install documentation</a></span></dt>
5827: <dt><span class="sect2"><a href="#restricted-packages">16.1.3. Restricted packages</a></span></dt>
5828: <dt><span class="sect2"><a href="#dependencies">16.1.4. Handling dependencies</a></span></dt>
5829: <dt><span class="sect2"><a href="#conflicts">16.1.5. Handling conflicts with other packages</a></span></dt>
5830: <dt><span class="sect2"><a href="#not-building-packages">16.1.6. Packages that cannot or should not be built</a></span></dt>
5831: <dt><span class="sect2"><a href="#undeletable-packages">16.1.7. Packages which should not be deleted, once installed</a></span></dt>
5832: <dt><span class="sect2"><a href="#security-handling">16.1.8. Handling packages with security problems</a></span></dt>
5833: <dt><span class="sect2"><a href="#compiler-bugs">16.1.9. How to handle compiler bugs</a></span></dt>
5834: <dt><span class="sect2"><a href="#bumping-pkgrevision">16.1.10. How to handle incrementing versions when fixing an existing package</a></span></dt>
5835: <dt><span class="sect2"><a href="#portability-of-packages">16.1.11. Portability of packages</a></span></dt>
5836: </dl></dd>
5837: <dt><span class="sect1"><a href="#downloading-issues">16.2. Possible downloading issues</a></span></dt>
5838: <dd><dl>
5839: <dt><span class="sect2"><a href="#no-plain-download">16.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
5840: <dt><span class="sect2"><a href="#modified-distfiles-same-name">16.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
5841: </dl></dd>
5842: <dt><span class="sect1"><a href="#configuration-gotchas">16.3. Configuration gotchas</a></span></dt>
5843: <dd><dl>
5844: <dt><span class="sect2"><a href="#fixes.libtool">16.3.1. Shared libraries - libtool</a></span></dt>
5845: <dt><span class="sect2"><a href="#using-libtool">16.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
5846: <dt><span class="sect2"><a href="#autoconf-automake">16.3.3. GNU Autoconf/Automake</a></span></dt>
5847: </dl></dd>
5848: <dt><span class="sect1"><a href="#fixes-build">16.4. Building the package</a></span></dt>
5849: <dd><dl>
5850: <dt><span class="sect2"><a href="#cpp-defines">16.4.1. CPP defines</a></span></dt>
5851: <dt><span class="sect2"><a href="#cpp-list-examples">16.4.2. Examples of CPP defines for some platforms</a></span></dt>
5852: <dt><span class="sect2"><a href="#cpp-list">16.4.3. Getting a list of CPP defines</a></span></dt>
5853: </dl></dd>
5854: <dt><span class="sect1"><a href="#package-specific-actions">16.5. Package specific actions</a></span></dt>
5855: <dd><dl>
5856: <dt><span class="sect2"><a href="#user-interaction">16.5.1. User interaction</a></span></dt>
5857: <dt><span class="sect2"><a href="#handling-licenses">16.5.2. Handling licenses</a></span></dt>
5858: <dt><span class="sect2"><a href="#installing-score-files">16.5.3. Installing score files</a></span></dt>
5859: <dt><span class="sect2"><a href="#perl-scripts">16.5.4. Packages containing perl scripts</a></span></dt>
5860: <dt><span class="sect2"><a href="#hardcoded-paths">16.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
5861: <dt><span class="sect2"><a href="#perl-modules">16.5.6. Packages installing perl modules</a></span></dt>
5862: <dt><span class="sect2"><a href="#faq.info-files">16.5.7. Packages installing info files</a></span></dt>
5863: <dt><span class="sect2"><a href="#manpages">16.5.8. Packages installing man pages</a></span></dt>
5864: <dt><span class="sect2"><a href="#gconf2-data-files">16.5.9. Packages installing GConf2 data files</a></span></dt>
5865: <dt><span class="sect2"><a href="#scrollkeeper-data-files">16.5.10. Packages installing scrollkeeper data files</a></span></dt>
5866: <dt><span class="sect2"><a href="#x11-fonts">16.5.11. Packages installing X11 fonts</a></span></dt>
5867: <dt><span class="sect2"><a href="#gtk2-modules">16.5.12. Packages installing GTK2 modules</a></span></dt>
5868: <dt><span class="sect2"><a href="#sgml-xml-data">16.5.13. Packages installing SGML or XML data</a></span></dt>
5869: <dt><span class="sect2"><a href="#mime-database">16.5.14. Packages installing extensions to the MIME database</a></span></dt>
5870: <dt><span class="sect2"><a href="#intltool">16.5.15. Packages using intltool</a></span></dt>
5871: <dt><span class="sect2"><a href="#startup-scripts">16.5.16. Packages installing startup scripts</a></span></dt>
5872: <dt><span class="sect2"><a href="#tex-packages">16.5.17. Packages installing TeX modules</a></span></dt>
5873: </dl></dd>
5874: <dt><span class="sect1"><a href="#feedback-to-author">16.6. Feedback to the author</a></span></dt>
5875: </dl>
5876: </div>
5877: <div class="sect1" lang="en">
5878: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5879: <a name="general-operation"></a>16.1. General operation</h2></div></div></div>
5880: <div class="sect2" lang="en">
5881: <div class="titlepage"><div><div><h3 class="title">
5882: <a name="pulling-vars-from-etc-mk.conf"></a>16.1.1. How to pull in variables from /etc/mk.conf</h3></div></div></div>
5883: <p>The problem with package-defined variables that can be
5884: overridden via <code class="varname">MAKECONF</code> or
1.76 ! rillig 5885: <code class="filename">/etc/mk.conf</code> is that <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> expands a
1.75 rillig 5886: variable as it is used, but evaluates preprocessor-like
5887: statements (.if, .ifdef and .ifndef) as they are read. So, to
5888: use any variable (which may be set in
1.76 ! rillig 5889: <code class="filename">/etc/mk.conf</code>) in one of the .if*
! 5890: statements, the file <code class="filename">/etc/mk.conf</code> must be
1.75 rillig 5891: included before that .if* statement.</p>
5892: <p>Rather than having a number of ad-hoc ways of including
1.76 ! rillig 5893: <code class="filename">/etc/mk.conf</code>, should it exist, or
1.75 rillig 5894: <code class="varname">MAKECONF</code>, should it exist, include the
1.76 ! rillig 5895: <code class="filename">pkgsrc/mk/bsd.prefs.mk</code> file in the package
1.75 rillig 5896: Makefile before any preprocessor-like .if, .ifdef, or .ifndef
5897: statements:</p>
5898: <pre class="programlisting">
5899: .include "../../mk/bsd.prefs.mk"
1.69 rillig 5900:
1.75 rillig 5901: .if defined(USE_MENUS)
5902: # ...
5903: .endif
5904: </pre>
5905: <p>If you wish to set the <code class="varname">CFLAGS</code> variable
1.76 ! rillig 5906: in <code class="filename">/etc/mk.conf</code>, please make sure to use:
1.69 rillig 5907:
1.75 rillig 5908: </p>
5909: <pre class="programlisting">
5910: CFLAGS+= -your -flags
5911: </pre>
5912: <p>
1.69 rillig 5913:
1.75 rillig 5914: Using <code class="varname">CFLAGS=</code> (i.e. without the
5915: “<span class="quote">+</span>”) may lead to problems with packages that need
5916: to add their own flags. Also, you may want to take a look at
1.76 ! rillig 5917: the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/cpuflags/README.html" target="_top"><code class="filename">devel/cpuflags</code></a> package if
1.75 rillig 5918: you're interested in optimization for the current CPU.</p>
5919: </div>
5920: <div class="sect2" lang="en">
5921: <div class="titlepage"><div><div><h3 class="title">
5922: <a name="where-to-install-documentation"></a>16.1.2. Where to install documentation</h3></div></div></div>
5923: <p>Documentation should be installed into
1.76 ! rillig 5924: <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
! 5925: <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the
1.75 rillig 5926: latter includes the version number of the package).</p>
5927: </div>
5928: <div class="sect2" lang="en">
5929: <div class="titlepage"><div><div><h3 class="title">
5930: <a name="restricted-packages"></a>16.1.3. Restricted packages</h3></div></div></div>
5931: <p>Some licenses restrict how software may be re-distributed.
5932: In order to satisfy these restrictions, the package system
5933: defines five make variables that can be set to note these
5934: restrictions:</p>
5935: <div class="itemizedlist"><ul type="disc">
5936: <li>
5937: <p><code class="varname">RESTRICTED</code></p>
5938: <p>This variable should be set whenever a restriction
5939: exists (regardless of its kind). Set this variable to a
5940: string containing the reason for the restriction.</p>
5941: </li>
5942: <li>
5943: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
5944: <p>Binaries may not be placed on CD-ROM. Set this
5945: variable to <code class="varname">${RESTRICTED}</code> whenever a
5946: binary package may not be included on a CD-ROM.</p>
5947: </li>
5948: <li>
5949: <p><code class="varname">NO_BIN_ON_FTP</code></p>
5950: <p>Binaries may not be placed on an FTP server. Set
5951: this variable to <code class="varname">${RESTRICTED}</code>
5952: whenever a binary package may not not be made available
5953: on the Internet.</p>
5954: </li>
5955: <li>
5956: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
5957: <p>Distfiles may not be placed on CD-ROM. Set this
5958: variable to <code class="varname">${RESTRICTED}</code> if
5959: re-distribution of the source code or other distfile(s) is
5960: not allowed on CD-ROMs.</p>
5961: </li>
5962: <li>
5963: <p><code class="varname">NO_SRC_ON_FTP</code></p>
5964: <p>Distfiles may not be placed on FTP. Set this variable
5965: to <code class="varname">${RESTRICTED}</code> if re-distribution of
5966: the source code or other distfile(s) via the Internet is not
5967: allowed.</p>
5968: </li>
5969: </ul></div>
5970: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
5971: <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
5972: generic make variables to denote restrictions is deprecated,
5973: because they unconditionally prevent users from generating
5974: binary packages!</p>
5975: </div>
5976: <div class="sect2" lang="en">
5977: <div class="titlepage"><div><div><h3 class="title">
5978: <a name="dependencies"></a>16.1.4. Handling dependencies</h3></div></div></div>
5979: <p>Your package may depend on some other package being present
5980: - and there are various ways of expressing this
5981: dependency. pkgsrc supports the <code class="varname">BUILD_DEPENDS</code>
5982: and <code class="varname">DEPENDS</code> definitions, the
5983: <code class="varname">USE_TOOLS</code> definition, as well as
1.76 ! rillig 5984: dependencies via <code class="filename">buildlink3.mk</code>, which is
1.75 rillig 5985: the preferred way to handle dependencies, and which uses the
5986: variables named above. See <a href="#buildlink" title="Chapter 11. Buildlink methodology">Chapter 11, <i>Buildlink methodology</i></a> for more
5987: information.</p>
5988: <p>The basic difference between the two variables is as
5989: follows: The <code class="varname">DEPENDS</code> definition registers
5990: that pre-requisite in the binary package so it will be pulled in
5991: when the binary package is later installed, whilst the
5992: <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
5993: dependency that is only needed for building the package.
5994: </p>
5995: <p>This means that if you only need a package present whilst
5996: you are building, it should be noted as a
5997: <code class="varname">BUILD_DEPENDS</code>.</p>
5998: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
5999: <code class="varname">DEPENDS</code> definition is:</p>
6000: <pre class="programlisting">
6001: <pre-req-package-name>:../../<category>/<pre-req-package>
6002: </pre>
6003: <p>Please note that the “<span class="quote">pre-req-package-name</span>”
6004: may include any of the wildcard version numbers recognized by
6005: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_info+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_info</span>(1)</span></a>.</p>
6006: <div class="orderedlist"><ol type="1">
6007: <li>
6008: <p>If your package needs another package's binaries or
6009: libraries to build or run, and if that package has a
1.76 ! rillig 6010: <code class="filename">buildlink3.mk</code> file available, use it:
1.75 rillig 6011: </p>
6012: <pre class="programlisting">
6013: .include "../../graphics/jpeg/buildlink3.mk"
6014: </pre>
6015: </li>
6016: <li>
6017: <p>If your package needs to use another package to build
1.76 ! rillig 6018: itself and there is no <code class="filename">buildlink3.mk</code>
1.75 rillig 6019: file available, use the <code class="varname">BUILD_DEPENDS</code>
6020: definition:</p>
6021: <pre class="programlisting">
6022: BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
6023: </pre>
6024: </li>
6025: <li>
6026: <p>If your package needs a library with which to link and
1.76 ! rillig 6027: again there is no <code class="filename">buildlink3.mk</code> file
1.75 rillig 6028: available, this is specified using the
6029: <code class="varname">DEPENDS</code> definition. For example:</p>
6030: <pre class="programlisting">
6031: DEPENDS+= xpm-3.4j:../../graphics/xpm
6032: </pre>
6033: <p>You can also use wildcards in package dependences:</p>
6034: <pre class="programlisting">
6035: DEPENDS+= xpm-[0-9]*:../../graphics/xpm
6036: </pre>
6037: <p>Note that such wildcard dependencies are retained when
6038: creating binary packages. The dependency is checked when
6039: installing the binary package and any package which matches
6040: the pattern will be used. Wildcard dependencies should be
6041: used with care.</p>
6042: <p>The “<span class="quote">-[0-9]*</span>” should be used instead of
6043: “<span class="quote">-*</span>” to avoid potentially ambiguous matches
6044: such as “<span class="quote">tk-postgresql</span>” matching a
6045: “<span class="quote">tk-*</span>” <code class="varname">DEPENDS</code>.</p>
6046: <p>Wildcards can also be used to specify that a package
6047: will only build against a certain minimum version of a
6048: pre-requisite:</p>
6049: <pre class="programlisting">
6050: DEPENDS+= tiff>=3.5.4:../../graphics/tiff
6051: </pre>
6052: <p>This means that the package will build against version
6053: 3.5.4 of the tiff library or newer. Such a dependency may
6054: be warranted if, for example, the API of the library has
6055: changed with version 3.5.4 and a package would not compile
6056: against an earlier version of tiff.</p>
6057: <p>Please note that such dependencies should only be
6058: updated if a package requires a newer pre-requisite, but
6059: not to denote recommendations such as
6060: ABI changes that do not prevent a package from building
6061: correctly. Such recommendations can be expressed using
6062: <code class="varname">ABI_DEPENDS</code>:</p>
6063: <pre class="programlisting">
6064: ABI_DEPENDS+= tiff>=3.6.1:../../graphics/tiff
6065: </pre>
6066: <p>In addition to the above <code class="varname">DEPENDS</code>
6067: line, this denotes that while a package will build against
6068: tiff>=3.5.4, at least version 3.6.1 is recommended.
6069: <code class="varname">ABI_DEPENDS</code> entries will be turned into
6070: dependencies unless explicitly ignored (in which case a
6071: warning will be printed).</p>
6072: <p>To ignore these ABI dependency recommendations and just
6073: use the required <code class="varname">DEPENDS</code>, set
6074: <code class="varname">USE_ABI_DEPENDS=NO</code>. This may make
6075: it easier and faster to update packages built using pkgsrc,
6076: since older compatible dependencies can continue to be
6077: used. This is useful for people who watch their rebuilds
6078: very carefully; it is not very good as a general-purpose
6079: hammer. If you use it, you need to be mindful of possible
6080: ABI changes, including those from the underlying OS.
6081: </p>
6082: <p>Packages that are built with recommendations ignored
6083: may not be uploaded to ftp.NetBSD.org by developers and
6084: should not be used across different systems that may have
6085: different versions of binary packages installed.</p>
6086: <p>For security fixes, please update the package
6087: vulnerabilities file. See <a href="#security-handling" title="16.1.8. Handling packages with security problems">Section 16.1.8, “Handling packages with security problems”</a> for more
6088: information.</p>
6089: </li>
6090: <li>
6091: <p>If your package needs some executable to be able to run
6092: correctly and if there's no
1.76 ! rillig 6093: <code class="filename">buildlink3.mk</code> file, this is specified
1.75 rillig 6094: using the <code class="varname">DEPENDS</code> variable. The
1.76 ! rillig 6095: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/print/lyx/README.html" target="_top"><code class="filename">print/lyx</code></a> package needs to
1.75 rillig 6096: be able to execute the latex binary from the teTeX package
6097: when it runs, and that is specified:</p>
6098: <pre class="programlisting">
6099: DEPENDS+= teTeX-[0-9]*:../../print/teTeX
6100: </pre>
6101: <p>The comment about wildcard dependencies from previous
6102: paragraph applies here, too.</p>
6103: </li>
6104: </ol></div>
6105: <p>If your package needs files from another package to build,
6106: add the relevant distribution files to
6107: <code class="varname">DISTFILES</code>, so they will be extracted
1.76 ! rillig 6108: automatically. See the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/print/ghostscript/README.html" target="_top"><code class="filename">print/ghostscript</code></a> package for an example.
1.75 rillig 6109: (It relies on the jpeg sources being present in source form
6110: during the build.)</p>
6111: <p>Please also note the <code class="varname">BUILD_USES_MSGFMT</code>
6112: and <code class="varname">BUILD_USES_GETTEXT_M4</code> definitions, which
6113: are provided as convenience definitions. The former works out
6114: whether <a href="http://netbsd.gw.com/cgi-bin/man-cgi?msgfmt+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">msgfmt</span>(1)</span></a> is part of the base system, and, if it isn't,
1.76 ! rillig 6115: installs the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/gettext/README.html" target="_top"><code class="filename">devel/gettext</code></a> package.
1.75 rillig 6116: The latter adds a build dependency on either an installed
6117: version of an older gettext package, or if it isn't, installs the
1.76 ! rillig 6118: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/gettext-m4/README.html" target="_top"><code class="filename">devel/gettext-m4</code></a> package.</p>
1.75 rillig 6119: </div>
6120: <div class="sect2" lang="en">
6121: <div class="titlepage"><div><div><h3 class="title">
6122: <a name="conflicts"></a>16.1.5. Handling conflicts with other packages</h3></div></div></div>
6123: <p>Your package may conflict with other packages a user might
6124: already have installed on his system, e.g. if your package
6125: installs the same set of files like another package in our
6126: pkgsrc tree.</p>
6127: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
6128: space-separated list of packages (including version string) your
6129: package conflicts with.</p>
1.76 ! rillig 6130: <p>For example, <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/Xaw3d/README.html" target="_top"><code class="filename">x11/Xaw3d</code></a>
! 6131: and <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/Xaw-Xpm/README.html" target="_top"><code class="filename">x11/Xaw-Xpm</code></a>
1.75 rillig 6132: install the same shared library, thus you set in
1.76 ! rillig 6133: <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
1.75 rillig 6134: <pre class="programlisting">
6135: CONFLICTS= Xaw-Xpm-[0-9]*
6136: </pre>
1.76 ! rillig 6137: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:
1.75 rillig 6138: </p>
6139: <pre class="programlisting">
6140: CONFLICTS= Xaw3d-[0-9]*
6141: </pre>
6142: <p>Packages will automatically conflict with other packages
6143: with the name prefix and a different version
6144: string. “<span class="quote">Xaw3d-1.5</span>” e.g. will automatically
6145: conflict with the older version “<span class="quote">Xaw3d-1.3</span>”.
6146: </p>
6147: </div>
6148: <div class="sect2" lang="en">
6149: <div class="titlepage"><div><div><h3 class="title">
6150: <a name="not-building-packages"></a>16.1.6. Packages that cannot or should not be built</h3></div></div></div>
6151: <p>There are several reasons why a package might be
6152: instructed to not build under certain circumstances. If the
6153: package builds and runs on most platforms, the exceptions
6154: should be noted with <code class="varname">NOT_FOR_PLATFORM</code>. If
6155: the package builds and runs on a small handful of platforms,
6156: set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
6157: Both <code class="varname">ONLY_FOR_PLATFORM</code> and
6158: <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
6159: (OS-version-platform) that can use glob-style
6160: wildcards.</p>
6161: <p>If the package should be skipped (for example, because it
6162: provides functionality already provided by the system), set
6163: <code class="varname">PKG_SKIP_REASON</code> to a descriptive message.
6164: If the package should fail because some preconditions are not
6165: met, set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
6166: message.</p>
6167: </div>
6168: <div class="sect2" lang="en">
6169: <div class="titlepage"><div><div><h3 class="title">
6170: <a name="undeletable-packages"></a>16.1.7. Packages which should not be deleted, once installed</h3></div></div></div>
6171: <p>To ensure that a package may not be deleted, once it has been
6172: installed, the <code class="varname">PKG_PRESERVE</code> definition should
6173: be set in the package Makefile. This will be carried into any
6174: binary package that is made from this pkgsrc entry. A
6175: “<span class="quote">preserved</span>” package will
6176: not be deleted using <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a> unless the
6177: “<span class="quote">-f</span>” option is used.</p>
6178: </div>
6179: <div class="sect2" lang="en">
6180: <div class="titlepage"><div><div><h3 class="title">
6181: <a name="security-handling"></a>16.1.8. Handling packages with security problems</h3></div></div></div>
6182: <p>When a vulnerability is found, this should be noted in
1.76 ! rillig 6183: <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
1.75 rillig 6184: and after committing that file, use <span><strong class="command">make upload</strong></span>
6185: in the same directory to update the file on ftp.NetBSD.org.</p>
6186: <p>After fixing the vulnerability by a patch, its
6187: <code class="varname">PKGREVISION</code> should be increased (this
6188: is of course not necessary if the problem is fixed by using
6189: a newer release of the software).</p>
6190: <p>Also, if the fix should be applied to the stable pkgsrc
6191: branch, be sure to submit a pullup request!</p>
6192: <p>Binary packages already on ftp.NetBSD.org will be handled
6193: semi-automatically by a weekly cron job.</p>
6194: </div>
6195: <div class="sect2" lang="en">
6196: <div class="titlepage"><div><div><h3 class="title">
6197: <a name="compiler-bugs"></a>16.1.9. How to handle compiler bugs</h3></div></div></div>
6198: <p>Some source files trigger bugs in the compiler, based on
6199: combinations of compiler version and architecture and almost
6200: always relation to optimisation being enabled. Common symptoms
6201: are gcc internal errors or never finishing compiling a file.
6202: </p>
6203: <p>Typically, a workaround involves testing the
6204: <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
6205: optimisation for that
6206: file/<code class="varname">MACHINE_ARCH</code>/compiler combination, and
1.76 ! rillig 6207: documenting it in <code class="filename">pkgsrc/doc/HACKS</code>. See
1.75 rillig 6208: that file for a number of examples!</p>
6209: </div>
6210: <div class="sect2" lang="en">
6211: <div class="titlepage"><div><div><h3 class="title">
6212: <a name="bumping-pkgrevision"></a>16.1.10. How to handle incrementing versions when fixing an existing package</h3></div></div></div>
6213: <p>When making fixes to an existing package it can be useful
6214: to change the version number in <code class="varname">PKGNAME</code>. To
6215: avoid conflicting with future versions by the original author, a
6216: “<span class="quote">nb1</span>”, “<span class="quote">nb2</span>”, ... suffix can be used
6217: on package versions by setting <code class="varname">PKGREVISION=1</code>
6218: (2, ...). The “<span class="quote">nb</span>” is treated like a
6219: “<span class="quote">.</span>” by the pkg tools. e.g.</p>
6220: <pre class="programlisting">
6221: DISTNAME= foo-17.42
6222: PKGREVISION= 9
6223: </pre>
6224: <p>will result in a <code class="varname">PKGNAME</code> of
6225: “<span class="quote">foo-17.42nb9</span>”.</p>
6226: <p>When a new release of the package is released, the
6227: <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
6228: minor release of the above package, things should be like:</p>
6229: <pre class="programlisting">
6230: DISTNAME= foo-17.43
6231: </pre>
6232: </div>
6233: <div class="sect2" lang="en">
6234: <div class="titlepage"><div><div><h3 class="title">
6235: <a name="portability-of-packages"></a>16.1.11. Portability of packages</h3></div></div></div>
6236: <p>One appealing feature of pkgsrc is that it runs on many different
6237: platforms. As a result, it is important to ensure, where possible,
6238: that packages in pkgsrc are portable. There are some particular
6239: details you should pay attention to while working on pkgsrc.</p>
6240: <div class="sect3" lang="en">
6241: <div class="titlepage"><div><div><h4 class="title">
6242: <a name="install-scripts"></a>16.1.11.1. ${INSTALL}, ${INSTALL_DATA_DIR}, ...</h4></div></div></div>
6243: <p>The BSD-compatible <span><strong class="command">install</strong></span> supplied with some
6244: operating systems will not perform more than one operation at a time.
6245: As such, you should call “<span class="quote">${INSTALL}</span>”, etc. like this:</p>
6246: <pre class="programlisting">
6247: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
6248: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
6249: </pre>
6250: </div>
6251: </div>
6252: </div>
6253: <div class="sect1" lang="en">
6254: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6255: <a name="downloading-issues"></a>16.2. Possible downloading issues</h2></div></div></div>
6256: <div class="sect2" lang="en">
6257: <div class="titlepage"><div><div><h3 class="title">
6258: <a name="no-plain-download"></a>16.2.1. Packages whose distfiles aren't available for plain downloading</h3></div></div></div>
6259: <p>If you need to download from a dynamic URL you can set
6260: <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span><strong class="command">make
1.76 ! rillig 6261: fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
1.75 rillig 6262: with the name of each file to download as an argument, expecting
6263: it to output the URL of the directory from which to download
1.76 ! rillig 6264: it. <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/ns-cult3d/README.html" target="_top"><code class="filename">graphics/ns-cult3d</code></a> is an
1.75 rillig 6265: example of this usage.
6266: </p>
6267: <p>If the download can't be automated, because the user must
6268: submit personal information to apply for a password, or must pay
6269: for the source, or whatever, you can set
6270: <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
6271: displayed to the user before aborting the build. Example:</p>
6272: <pre class="programlisting">
6273: FETCH_MESSAGE= "Please download the files"
6274: FETCH_MESSAGE+= " "${DISTFILES:Q}
6275: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
6276: </pre>
6277: </div>
6278: <div class="sect2" lang="en">
6279: <div class="titlepage"><div><div><h3 class="title">
6280: <a name="modified-distfiles-same-name"></a>16.2.2. How to handle modified distfiles with the 'old' name</h3></div></div></div>
6281: <p>Sometimes authors of a software package make some
6282: modifications after the software was released, and they put up a
6283: new distfile without changing the package's version number. If a
6284: package is already in pkgsrc at that time, the checksum will
6285: no longer match. The contents of the new distfile should be
6286: compared against the old one before changing anything, to make
6287: sure the distfile was really updated on purpose, and that
6288: no trojan horse or so crept in.
6289: Then, the correct way to work around this is to
6290: set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
6291: usually based on <code class="varname">PKGNAME_NOREV</code>. In case this
6292: happens more often, <code class="varname">PKGNAME</code> can be used (thus
1.76 ! rillig 6293: including the <code class="filename">nbX</code> suffix) or a date stamp
1.75 rillig 6294: can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
1.76 ! rillig 6295: Do not forget regenerating the <code class="filename">distinfo</code> file
1.75 rillig 6296: after that, since it contains the <code class="varname">DIST_SUBDIR</code>
6297: path in the filenames.
6298: Furthermore, a mail to the package's authors seems appropriate
6299: telling them that changing distfiles after releases without
6300: changing the file names is not good practice.</p>
6301: </div>
6302: </div>
6303: <div class="sect1" lang="en">
6304: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6305: <a name="configuration-gotchas"></a>16.3. Configuration gotchas</h2></div></div></div>
6306: <div class="sect2" lang="en">
6307: <div class="titlepage"><div><div><h3 class="title">
6308: <a name="fixes.libtool"></a>16.3.1. Shared libraries - libtool</h3></div></div></div>
6309: <p>pkgsrc supports many different machines, with different
6310: object formats like a.out and ELF, and varying abilities to do
6311: shared library and dynamic loading at all. To accompany this,
6312: varying commands and options have to be passed to the
6313: compiler, linker, etc. to get the Right Thing, which can be
6314: pretty annoying especially if you don't have all the machines
6315: at your hand to test things. The
1.76 ! rillig 6316: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/libtool/README.html" target="_top"><code class="filename">devel/libtool</code></a> pkg
1.75 rillig 6317: can help here, as it just “<span class="quote">knows</span>” how to build
6318: both static and dynamic libraries from a set of source files,
6319: thus being platform-independent.</p>
6320: <p>Here's how to use libtool in a pkg in seven simple
6321: steps:</p>
6322: <div class="orderedlist"><ol type="1">
6323: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
6324: Makefile.</p></li>
6325: <li><p>For library objects, use “<span class="quote">${LIBTOOL} --mode=compile
6326: ${CC}</span>” in place of “<span class="quote">${CC}</span>”. You could even
6327: add it to the definition of <code class="varname">CC</code>, if only
6328: libraries are being built in a given Makefile. This one command
6329: will build both PIC and non-PIC library objects, so you need not
6330: have separate shared and non-shared library rules.</p></li>
6331: <li>
6332: <p>For the linking of the library, remove any
6333: “<span class="quote">ar</span>”, “<span class="quote">ranlib</span>”, and “<span class="quote">ld
6334: -Bshareable</span>” commands, and instead use:</p>
6335: <pre class="programlisting">
6336: ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
6337: -rpath ${PREFIX}/lib -version-info major:minor
6338: </pre>
6339: <p>Note that the library is changed to have a
1.76 ! rillig 6340: <code class="filename">.la</code> extension, and the objects are
! 6341: changed to have a <code class="filename">.lo</code>
1.75 rillig 6342: extension. Change <code class="varname">OBJS</code> as
6343: necessary. This automatically creates all of the
1.76 ! rillig 6344: <code class="filename">.a</code>,
! 6345: <code class="filename">.so.major.minor</code>, and ELF symlinks (if
1.75 rillig 6346: necessary) in the build directory. Be sure to include
6347: “<span class="quote">-version-info</span>”, especially when major and
6348: minor are zero, as libtool will otherwise strip off the
6349: shared library version.</p>
6350: <p>From the libtool manual:</p>
6351: <pre class="programlisting">
6352: So, libtool library versions are described by three integers:
1.69 rillig 6353:
1.75 rillig 6354: CURRENT
6355: The most recent interface number that this library implements.
1.69 rillig 6356:
1.75 rillig 6357: REVISION
6358: The implementation number of the CURRENT interface.
1.69 rillig 6359:
1.75 rillig 6360: AGE
6361: The difference between the newest and oldest interfaces that
6362: this library implements. In other words, the library implements
6363: all the interface numbers in the range from number `CURRENT -
6364: AGE' to `CURRENT'.
1.1 grant 6365:
1.75 rillig 6366: If two libraries have identical CURRENT and AGE numbers, then the
6367: dynamic linker chooses the library with the greater REVISION number.
6368: </pre>
6369: <p>The “<span class="quote">-release</span>” option will produce
6370: different results for a.out and ELF (excluding symlinks)
6371: in only one case. An ELF library of the form
6372: “<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
6373: will have a symlink of
6374: “<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
6375: on an a.out platform. This is handled
6376: automatically.</p>
6377: <p>The “<span class="quote">-rpath argument</span>” is the install
6378: directory of the library being built.</p>
1.76 ! rillig 6379: <p>In the <code class="filename">PLIST</code>, include only the
! 6380: <code class="filename">.la</code> file, the other files will be
1.75 rillig 6381: added automatically.</p>
6382: </li>
6383: <li>
1.76 ! rillig 6384: <p>When linking shared object (<code class="filename">.so</code>)
1.75 rillig 6385: files, i.e. files that are loaded via <a href="http://netbsd.gw.com/cgi-bin/man-cgi?dlopen+3+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">dlopen</span>(3)</span></a>, NOT
6386: shared libraries, use “<span class="quote">-module
6387: -avoid-version</span>” to prevent them getting version
6388: tacked on.</p>
1.76 ! rillig 6389: <p>The <code class="filename">PLIST</code> file gets the
! 6390: <code class="filename">foo.so</code> entry.</p>
1.75 rillig 6391: </li>
6392: <li>
6393: <p>When linking programs that depend on these libraries
6394: <span class="emphasis"><em>before</em></span> they are installed, preface
6395: the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?cc+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">cc</span>(1)</span></a> or <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ld+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ld</span>(1)</span></a> line with “<span class="quote">${LIBTOOL}
6396: --mode=link</span>”, and it will find the correct
6397: libraries (static or shared), but please be aware that
6398: libtool will not allow you to specify a relative path in
6399: -L (such as “<span class="quote">-L../somelib</span>”), because it
6400: expects you to change that argument to be the
1.76 ! rillig 6401: <code class="filename">.la</code> file. e.g.</p>
1.75 rillig 6402: <pre class="programlisting">
6403: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
6404: </pre>
6405: <p>should be changed to:</p>
6406: <pre class="programlisting">
6407: ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
6408: </pre>
6409: <p>and it will do the right thing with the libraries.</p>
6410: </li>
6411: <li>
6412: <p>When installing libraries, preface the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?install+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">install</span>(1)</span></a>
6413: or <a href="http://netbsd.gw.com/cgi-bin/man-cgi?cp+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">cp</span>(1)</span></a> command with “<span class="quote">${LIBTOOL}
6414: --mode=install</span>”, and change the library name to
1.76 ! rillig 6415: <code class="filename">.la</code>. e.g.</p>
1.75 rillig 6416: <pre class="programlisting">
6417: ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
6418: </pre>
1.76 ! rillig 6419: <p>This will install the static <code class="filename">.a</code>,
1.75 rillig 6420: shared library, any needed symlinks, and run
6421: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ldconfig+8+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ldconfig</span>(8)</span></a>.</p>
6422: </li>
1.76 ! rillig 6423: <li><p>In your <code class="filename">PLIST</code>, include only
! 6424: the <code class="filename">.la</code>
1.75 rillig 6425: file (this is a change from previous behaviour).</p></li>
6426: </ol></div>
6427: </div>
6428: <div class="sect2" lang="en">
6429: <div class="titlepage"><div><div><h3 class="title">
6430: <a name="using-libtool"></a>16.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
6431: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
6432: package Makefile. This will override the package's own libtool
6433: in most cases. For older libtool using packages, libtool is
6434: made by ltconfig script during the do-configure step; you can
6435: check the libtool script location by doing <span><strong class="command">make
6436: configure; find work*/ -name libtool</strong></span>.</p>
6437: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
6438: scripts, relative to <code class="varname">WRKSRC</code>, to override. By
6439: default, it is set to “<span class="quote">libtool */libtool
6440: */*/libtool</span>”. If this does not match the location of the
6441: package's libtool script(s), set it as appropriate.</p>
1.76 ! rillig 6442: <p>If you do not need <code class="filename">*.a</code> static
1.75 rillig 6443: libraries built and installed, then use
6444: <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
6445: <p>If your package makes use of the platform-independent library
6446: for loading dynamic shared objects, that comes with libtool
6447: (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
6448: <p>Some packages use libtool incorrectly so that the package may not work or
6449: build in some circumstances. Some of the more common errors are:</p>
6450: <div class="itemizedlist"><ul type="disc">
6451: <li>
6452: <p>The inclusion of a shared object (-module) as a dependent library in an
6453: executable or library. This in itself isn't a problem if one of two things
6454: has been done:</p>
6455: <div class="orderedlist"><ol type="1">
6456: <li><p>The shared object is named correctly, i.e.
1.76 ! rillig 6457: <code class="filename">libfoo.la</code>, not
! 6458: <code class="filename">foo.la</code></p></li>
1.75 rillig 6459: <li><p>The -dlopen option is used when linking an executable.</p></li>
6460: </ol></div>
6461: </li>
6462: <li><p>The use of libltdl without the correct calls to initialisation routines.
6463: The function lt_dlinit() should be called and the macro
6464: <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
6465: executables.</p></li>
6466: </ul></div>
6467: </div>
6468: <div class="sect2" lang="en">
6469: <div class="titlepage"><div><div><h3 class="title">
6470: <a name="autoconf-automake"></a>16.3.3. GNU Autoconf/Automake</h3></div></div></div>
6471: <p>If a package needs GNU autoconf or automake to be executed
6472: to regenerate the configure script and Makefile.in makefile
6473: templates, then they should be executed in a pre-configure
6474: target.</p>
6475: <p>For packages that need only autoconf:</p>
6476: <pre class="programlisting">
6477: AUTOCONF_REQD= 2.50 # if default version is not good enough
6478: USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
6479: ...
1.1 grant 6480:
1.75 rillig 6481: pre-configure:
6482: cd ${WRKSRC}; autoconf
1.1 grant 6483:
1.75 rillig 6484: ...
6485: </pre>
6486: <p>and for packages that need automake and autoconf:</p>
6487: <pre class="programlisting">
6488: AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
6489: USE_TOOLS+= automake # use "automake14" for automake-1.4
6490: ...
1.1 grant 6491:
1.75 rillig 6492: pre-configure:
6493: cd ${WRKSRC}; \
6494: aclocal; autoheader; \
6495: automake -a --foreign -i; autoconf
1.1 grant 6496:
1.75 rillig 6497: ...
6498: </pre>
6499: <p>Packages which use GNU Automake will almost certainly
6500: require GNU Make.</p>
6501: <p>There are times when the configure process makes
6502: additional changes to the generated files, which then causes
6503: the build process to try to re-execute the automake sequence.
6504: This is prevented by touching various files in the configure
6505: stage. If this causes problems with your package you can set
6506: <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
6507: Makefile.</p>
6508: </div>
6509: </div>
6510: <div class="sect1" lang="en">
6511: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6512: <a name="fixes-build"></a>16.4. Building the package</h2></div></div></div>
6513: <div class="sect2" lang="en">
6514: <div class="titlepage"><div><div><h3 class="title">
6515: <a name="cpp-defines"></a>16.4.1. CPP defines</h3></div></div></div>
6516: <p>Sometimes you need to compile different code depending on
6517: the target platform. The C preprocessor has a set of predefined
6518: macros that can be queried by using <code class="varname">#ifdef FOO</code>
6519: or <code class="varname">#if defined(FOO)</code>. Among these macros are
6520: usually ones that describe the target CPU and operating system.
6521: Depending of which of the macros are defined, you can write code
6522: that uses features unique to a specific platform. Generally you
6523: should rather use the GNU autotools (automake, autoconf, etc.) to
6524: check for specific features (like the existence of a header file,
6525: a function or a library), but sometimes this is not possible or
6526: desired.</p>
6527: <p>In that case you can use the predefined macros
6528: below to configure your code to the platform it runs on. Almost
6529: every operating system, hardware architecture and compiler has its
6530: own macro. For example, if the macros <code class="varname">__GNUC__</code>,
6531: <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code> are
6532: all defined, you know that you are using NetBSD on an i386
6533: compatible CPU, and your compiler is GCC.</p>
6534: <div class="sect3" lang="en">
6535: <div class="titlepage"><div><div><h4 class="title">
6536: <a name="fixes-build-cpp-opsys"></a>16.4.1.1. CPP defines for operating systems</h4></div></div></div>
6537: <p>To distinguish between 4.4 BSD-derived systems and the
6538: rest of the world, you should use the following code.</p>
6539: <pre class="programlisting">
6540: #include <sys/param.h>
6541: #if (defined(BSD) && BSD >= 199306)
6542: /* BSD-specific code goes here */
6543: #else
6544: /* non-BSD-specific code goes here */
6545: #endif
6546: </pre>
6547: <p>If this distinction is not fine enough, you can also use
6548: the following defines.</p>
6549: <pre class="programlisting">
6550: FreeBSD __FreeBSD__
6551: DragonFly __DragonFly__
6552: Interix __INTERIX
6553: Linux linux, __linux, __linux__
6554: NetBSD __NetBSD__
6555: OpenBSD __OpenBSD__
6556: Solaris sun, __sun
6557: </pre>
6558: </div>
6559: <div class="sect3" lang="en">
6560: <div class="titlepage"><div><div><h4 class="title">
6561: <a name="fixes-build-cpp-cpu"></a>16.4.1.2. CPP defines for CPUs</h4></div></div></div>
6562: <pre class="programlisting">
6563: i386 i386, __i386, __i386__
6564: MIPS __mips
6565: SPARC sparc, __sparc
6566: </pre>
6567: </div>
6568: <div class="sect3" lang="en">
6569: <div class="titlepage"><div><div><h4 class="title">
6570: <a name="fixes-build-cpp-compiler"></a>16.4.1.3. CPP defines for compilers</h4></div></div></div>
6571: <pre class="programlisting">
6572: GCC __GNUC__ (major version), __GNUC_MINOR__
6573: SunPro __SUNPRO_C (0x570 for version 5.7)
6574: </pre>
6575: </div>
6576: </div>
6577: <div class="sect2" lang="en">
6578: <div class="titlepage"><div><div><h3 class="title">
6579: <a name="cpp-list-examples"></a>16.4.2. Examples of CPP defines for some platforms</h3></div></div></div>
6580: <p>The list of the CPP identification macros for hardware and
6581: operating system may depend on the compiler that is used. The
6582: following list contains some examples that may help you to choose
6583: the right ones. For example, if you want to conditionally compile
6584: code on Solaris, don't use <code class="varname">__sun__</code>, as the
6585: SunPro compiler does not define it. Use <code class="varname">__sun</code>
6586: instead.</p>
6587: <div class="variablelist"><dl>
6588: <dt><span class="term">GCC 3.3.3 + SuSE Linux 9.1 + i386</span></dt>
6589: <dd><p>__ELF__, __gnu_linux__, __i386, __i386__,
6590: __linux, __linux__, __unix, __unix__, i386, linux,
6591: unix.</p></dd>
6592: <dt><span class="term">GCC 2.95 + NetBSD 1.6.2 + i386</span></dt>
6593: <dd><p>__ELF__, __NetBSD__, __i386, __i386__,
6594: i386.</p></dd>
6595: <dt><span class="term">GCC 3.3.3 + NetBSD 2.0 + i386</span></dt>
6596: <dd><p>__ELF__, __NetBSD__, __i386, __i386__,
6597: i386.</p></dd>
6598: <dt><span class="term">GCC 4 + Solaris 8 + SPARC</span></dt>
6599: <dd><p>__ELF__, __sparc, __sparc__, __sun, __sun__,
6600: __SVR4, __svr4__, __unix, __unix__, sparc, sun,
6601: unix.</p></dd>
6602: <dt><span class="term">SunPro 5.7 + Solaris 8 + SPARC</span></dt>
6603: <dd><p>__SVR4, __sparc, __sun, __unix, sparc, sun,
6604: unix.</p></dd>
6605: </dl></div>
6606: </div>
6607: <div class="sect2" lang="en">
6608: <div class="titlepage"><div><div><h3 class="title">
6609: <a name="cpp-list"></a>16.4.3. Getting a list of CPP defines</h3></div></div></div>
6610: <p>If your system uses the GNU C Compiler, you can get a list
6611: of symbols that are defined by default, e.g. to identify the
6612: platform, with the following command:</p>
6613: <pre class="programlisting">
6614: gcc -E -dM - < /dev/null
6615: </pre>
6616: <p>On other systems you may get the list by using the system's
6617: syscall trace utility (ktrace, truss, strace) to have a look which
6618: arguments are passed to the actual compiler.</p>
6619: </div>
6620: </div>
6621: <div class="sect1" lang="en">
6622: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6623: <a name="package-specific-actions"></a>16.5. Package specific actions</h2></div></div></div>
6624: <div class="sect2" lang="en">
6625: <div class="titlepage"><div><div><h3 class="title">
6626: <a name="user-interaction"></a>16.5.1. User interaction</h3></div></div></div>
6627: <p>Occasionally, packages require interaction from the user, and this can be
6628: in a number of ways:</p>
6629: <div class="itemizedlist"><ul type="disc">
6630: <li><p>help in fetching the distfiles</p></li>
6631: <li><p>help to configure the package before it is built</p></li>
6632: <li><p>help during the build process</p></li>
6633: <li><p>help during the installation of a package</p></li>
6634: </ul></div>
6635: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is provided to notify
6636: the pkgsrc mechanism of an interactive stage which will be needed, and
1.76 ! rillig 6637: this should be set in the package's <code class="filename">Makefile</code>, e.g.:</p>
1.75 rillig 6638: <pre class="programlisting">
6639: INTERACTIVE_STAGE= build
6640: </pre>
6641: <p>Multiple interactive stages can be specified:</p>
6642: <pre class="programlisting">
6643: INTERACTIVE_STAGE= configure install
6644: </pre>
6645: </div>
6646: <div class="sect2" lang="en">
6647: <div class="titlepage"><div><div><h3 class="title">
6648: <a name="handling-licenses"></a>16.5.2. Handling licenses</h3></div></div></div>
6649: <p>A package may be covered by a license which the user has
6650: or has not agreed to accept. For these cases, pkgsrc contains
6651: a mechanism to note that a package is covered by a particular
6652: license, and the package cannot be built unless the user has
6653: accepted the license. (Installation of binary packages are
6654: not currently subject to this mechanism.) Packages with
6655: licenses that are either Open Source according to the Open
6656: Source Initiative or Free according to the Free Software
6657: Foundation will not be marked with a license tag. Packages
6658: with licenses that have not been determined to meet either
6659: definition will be marked with a license tag referring to the
6660: license. This will prevent building unless pkgsrc is informed
6661: that the license is acceptable, and enables displaying the
6662: license.</p>
6663: <p>The license tag mechanism is intended to address
6664: copyright-related issues surrounding building, installing and
6665: using a package, and not to address redistribution issues (see
6666: <code class="varname">RESTRICTED</code> and
6667: <code class="varname">NO_SRC_ON_FTP</code>, etc.). However, the above
6668: definition of licenses for which tags are not needed implies
6669: that packages with redistribution restrictions should have
6670: tags.</p>
6671: <p>
6672: Denoting that a package is covered by a particular license is
6673: done by placing the license in
1.76 ! rillig 6674: <code class="filename">pkgsrc/licenses</code> and setting the
1.75 rillig 6675: <code class="varname">LICENSE</code> variable to a string identifying
6676: the license, e.g. in
1.76 ! rillig 6677: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>: </p>
1.75 rillig 6678: <pre class="programlisting">
6679: LICENSE= xv-license
6680: </pre>
6681: <p>
6682: When trying to build, the user will get a notice that the
6683: package is covered by a license which has not been
6684: accepted:</p>
6685: <pre class="programlisting">
6686: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
6687: ===> xv-3.10anb9 has an unacceptable license: xv-license.
6688: ===> To view the license, enter "/usr/bin/make show-license".
6689: ===> To indicate acceptance, add this line to your /etc/mk.conf:
6690: ===> ACCEPTABLE_LICENSES+=xv-license
6691: *** Error code 1
6692: </pre>
6693: <p>The license can be viewed with <span><strong class="command">make
6694: show-license</strong></span>, and if it is considered appropriate,
6695: the line printed above can be added to
1.76 ! rillig 6696: <code class="filename">/etc/mk.conf</code> to indicate acceptance of
1.75 rillig 6697: the particular license:</p>
6698: <pre class="programlisting">
6699: ACCEPTABLE_LICENSES+=xv-license
6700: </pre>
6701: <p>When adding a package with a new license, the license
1.76 ! rillig 6702: text should be added to <code class="filename">pkgsrc/licenses</code>
1.75 rillig 6703: for displaying. A list of known licenses can be seen in this
6704: directory as well as by looking at the list of (commented
6705: out) <code class="varname">ACCEPTABLE_LICENSES</code> variable
6706: settings in
1.76 ! rillig 6707: <code class="filename">pkgsrc/mk/defaults/mk.conf</code>.</p>
1.75 rillig 6708: <p>The use of <code class="varname">LICENSE=shareware</code>,
6709: <code class="varname">LICENSE=no-commercial-use</code>, and similar
6710: language is deprecated because it does not crisply refer to
6711: a particular license text. Another problem with such usage
6712: is that it does not enable a user to denote acceptance of
6713: the license for a single package without accepting the same
6714: license text for another package. In particular, this can
6715: be inappropriate when e.g. one accepts a particular license to
6716: indicate to pkgsrc that a fee has been paid.</p>
6717: </div>
6718: <div class="sect2" lang="en">
6719: <div class="titlepage"><div><div><h3 class="title">
6720: <a name="installing-score-files"></a>16.5.3. Installing score files</h3></div></div></div>
6721: <p>Certain packages, most of them in the games category, install
6722: a score file that allows all users on the system to record their
6723: highscores. In order for this to work, the binaries need to be
6724: installed setgid and the score files owned by the appropriate
6725: group and/or owner (traditionally the "games" user/group). The
6726: following variables, documented in more detail in
1.76 ! rillig 6727: <code class="filename">mk/defaults/mk.conf</code>, control this
1.75 rillig 6728: behaviour: <code class="varname">SETGIDGAME</code>,
6729: <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
6730: <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
6731: <p>Note that per default, setgid installation of games is
6732: disabled; setting <code class="varname">SETGIDGAME=YES</code> will set all
6733: the other variables accordingly.</p>
6734: <p>A package should therefor never hard code file ownership or
6735: access permissions but rely on <code class="varname">INSTALL_GAME</code> and
6736: <code class="varname">INSTALL_GAME_DATA</code> to set these
6737: correctly.</p>
6738: </div>
6739: <div class="sect2" lang="en">
6740: <div class="titlepage"><div><div><h3 class="title">
6741: <a name="perl-scripts"></a>16.5.4. Packages containing perl scripts</h3></div></div></div>
6742: <p>
6743: If your package contains interpreted perl scripts, set
6744: <code class="varname">REPLACE_PERL</code> to ensure that the proper
6745: interpreter path is set. <code class="varname">REPLACE_PERL</code> should
6746: contain a list of scripts, relative to
6747: <code class="varname">WRKSRC</code>, that you want adjusted.</p>
6748: </div>
6749: <div class="sect2" lang="en">
6750: <div class="titlepage"><div><div><h3 class="title">
6751: <a name="hardcoded-paths"></a>16.5.5. Packages with hardcoded paths to other interpreters</h3></div></div></div>
6752: <p>
6753: Your package may also contain scripts with hardcoded paths to
6754: other interpreters besides (or as well as) perl. To correct the
6755: full pathname to the script interpreter, you need to set the
1.76 ! rillig 6756: following definitions in your <code class="filename">Makefile</code> (we
1.75 rillig 6757: shall use <span><strong class="command">tclsh</strong></span> in this example):</p>
6758: <pre class="programlisting">
6759: REPLACE_INTERPRETER+= tcl
6760: REPLACE.tcl.old= .*/bin/tclsh
6761: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
6762: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
6763: # relative to ${WRKSRC}, just as in REPLACE_PERL
6764: </pre>
6765: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
6766: <h3 class="title">Note</h3>
6767: <p>Before March 2006, these variables were called
6768: <code class="varname">_REPLACE.*</code> and
6769: <code class="varname">_REPLACE_FILES.*</code>.</p>
6770: </div>
6771: </div>
6772: <div class="sect2" lang="en">
6773: <div class="titlepage"><div><div><h3 class="title">
6774: <a name="perl-modules"></a>16.5.6. Packages installing perl modules</h3></div></div></div>
6775: <p>Makefiles of packages providing perl5 modules should include
6776: the Makefile fragment
1.76 ! rillig 6777: <code class="filename">../../lang/perl5/module.mk</code>. It provides a
1.75 rillig 6778: <span><strong class="command">do-configure</strong></span> target for the standard perl
6779: configuration for such modules as well as various hooks to tune
6780: this configuration. See comments in this file for
6781: details.</p>
6782: <p>Perl5 modules will install into different places depending
6783: on the version of perl used during the build process. To
6784: address this, pkgsrc will append lines to the
1.76 ! rillig 6785: <code class="filename">PLIST</code> corresponding to the files listed in
! 6786: the installed <code class="filename">.packlist</code> file generated by
1.75 rillig 6787: most perl5 modules. This is invoked by defining
6788: <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
6789: paths to packlist files, e.g.:</p>
6790: <pre class="programlisting">
6791: PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
6792: </pre>
6793: <p>The variables <code class="varname">PERL5_SITELIB</code>,
6794: <code class="varname">PERL5_SITEARCH</code>, and
6795: <code class="varname">PERL5_ARCHLIB</code> represent the three locations
6796: in which perl5 modules may be installed, and may be used by
6797: perl5 packages that don't have a packlist. These three
6798: variables are also substituted for in the
1.76 ! rillig 6799: <code class="filename">PLIST</code>.</p>
1.75 rillig 6800: </div>
6801: <div class="sect2" lang="en">
6802: <div class="titlepage"><div><div><h3 class="title">
6803: <a name="faq.info-files"></a>16.5.7. Packages installing info files</h3></div></div></div>
6804: <p>Some packages install info files or use the
6805: “<span class="quote">makeinfo</span>” or “<span class="quote">install-info</span>”
6806: commands. <code class="varname">INFO_FILES</code> should be defined in
1.76 ! rillig 6807: the package Makefile so that <code class="filename">INSTALL</code> and
! 6808: <code class="filename">DEINSTALL</code> scripts will be generated to
1.75 rillig 6809: handle registration of the info files in the Info directory
6810: file. The “<span class="quote">install-info</span>” command used for the info
6811: files registration is either provided by the system, or by a
6812: special purpose package automatically added as dependency if
6813: needed.</p>
6814: <p><code class="varname">PKGINFODIR</code> is the directory under
1.76 ! rillig 6815: <code class="filename">${PREFIX}</code> where info files are primarily
1.75 rillig 6816: located. <code class="varname">PKGINFODIR</code> defaults to
6817: “<span class="quote">info</span>” and can be overridden by the user.</p>
6818: <p>The info files for the package should be listed in the
1.76 ! rillig 6819: package <code class="filename">PLIST</code>; however any split info files
1.75 rillig 6820: need not be listed.</p>
6821: <p>A package which needs the “<span class="quote">makeinfo</span>” command
6822: at build time must add “<span class="quote">makeinfo</span>” to
6823: <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
6824: version of the “<span class="quote">makeinfo</span>” command is needed it
6825: should be noted with the <code class="varname">TEXINFO_REQD</code>
1.76 ! rillig 6826: variable in the package <code class="filename">Makefile</code>. By
1.75 rillig 6827: default, a minimum version of 3.12 is required. If the system
6828: does not provide a <span><strong class="command">makeinfo</strong></span> command or if it
6829: does not match the required minimum, a build dependency on the
1.76 ! rillig 6830: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/gtexinfo/README.html" target="_top"><code class="filename">devel/gtexinfo</code></a> package will
1.75 rillig 6831: be added automatically.</p>
6832: <p>The build and installation process of the software provided
6833: by the package should not use the
6834: <span><strong class="command">install-info</strong></span> command as the registration of
6835: info files is the task of the package
1.76 ! rillig 6836: <code class="filename">INSTALL</code> script, and it must use the
1.75 rillig 6837: appropriate <span><strong class="command">makeinfo</strong></span> command.</p>
6838: <p>To achieve this goal, the pkgsrc infrastructure creates
6839: overriding scripts for the <span><strong class="command">install-info</strong></span> and
6840: <span><strong class="command">makeinfo</strong></span> commands in a directory listed early
6841: in <code class="varname">PATH</code>.</p>
6842: <p>The script overriding <span><strong class="command">install-info</strong></span> has
6843: no effect except the logging of a message. The script overriding
6844: <span><strong class="command">makeinfo</strong></span> logs a message and according to the
6845: value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
6846: <span><strong class="command">makeinfo</strong></span> command or exit on error.</p>
6847: </div>
6848: <div class="sect2" lang="en">
6849: <div class="titlepage"><div><div><h3 class="title">
6850: <a name="manpages"></a>16.5.8. Packages installing man pages</h3></div></div></div>
6851: <p>Many packages install manual pages. The man pages
6852: are installed under <code class="varname">${PREFIX}/${PKGMANDIR}</code>
1.76 ! rillig 6853: which is <code class="filename">/usr/pkg/man</code> by default.
1.75 rillig 6854: <code class="varname">PKGMANDIR</code> defaults to “<span class="quote">man</span>”.
6855: For example, you can set <code class="varname">PKGMANDIR</code> to
6856: “<span class="quote">share/man</span>” to have man pages install under
1.76 ! rillig 6857: <code class="filename">/usr/pkg/share/man/</code> by default.
1.75 rillig 6858: </p>
6859: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
6860: <h3 class="title">Note</h3>
6861: <p>The support for a custom <code class="varname">PKGMANDIR</code>
6862: is not complete.
6863: </p>
6864: </div>
1.76 ! rillig 6865: <p>The <code class="filename">PLIST</code> files can just
! 6866: use <code class="filename">man/</code> as the top level directory
1.75 rillig 6867: for the man page file entries
6868: and the pkgsrc framework will convert as needed.
6869: </p>
6870: <p> Packages that are
6871: configured with <code class="varname">GNU_CONFIGURE</code> set as
6872: “<span class="quote">yes</span>”, by default will use the
1.76 ! rillig 6873: <code class="filename">./configure</code>
1.75 rillig 6874: --mandir switch to set where the man pages should be installed.
6875: The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
6876: to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.
6877: </p>
6878: <p>
6879: Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
6880: use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
6881: to “<span class="quote">no</span>”.
1.76 ! rillig 6882: Or if the <code class="filename">./configure</code> script uses
1.75 rillig 6883: a non-standard use of --mandir, you can set
6884: <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.
6885: </p>
6886: <p>See <a href="#manpage-compression" title="10.5. Man page compression">Section 10.5, “Man page compression”</a> for
6887: information on installation of compressed manual pages.
6888: </p>
6889: </div>
6890: <div class="sect2" lang="en">
6891: <div class="titlepage"><div><div><h3 class="title">
6892: <a name="gconf2-data-files"></a>16.5.9. Packages installing GConf2 data files</h3></div></div></div>
6893: <p>
1.76 ! rillig 6894: If a package installs <code class="filename">.schemas</code> or
! 6895: <code class="filename">.entries</code> files, used by GConf2,
1.75 rillig 6896: you need to take some extra steps to make sure they get registered
6897: in the database:
6898: </p>
6899: <div class="orderedlist"><ol type="1">
1.76 ! rillig 6900: <li><p>Include <code class="filename">../../devel/GConf2/schemas.mk</code>
! 6901: instead of its <code class="filename">buildlink3.mk</code> file. This
1.75 rillig 6902: takes care of rebuilding the GConf2 database at installation and
6903: deinstallation time, and tells the package where to install
6904: GConf2 data files using some standard configure arguments. It
6905: also disallows any access to the database directly from the
6906: package.</p></li>
6907: <li><p>Ensure that the package installs its
1.76 ! rillig 6908: <code class="filename">.schemas</code> files under
! 6909: <code class="filename">${PREFIX}/share/gconf/schemas</code>. If they get
! 6910: installed under <code class="filename">${PREFIX}/etc</code>, you will
1.75 rillig 6911: need to manually patch the package.</p></li>
6912: <li><p>Check the PLIST and remove any entries under the etc/gconf
6913: directory, as they will be handled automatically. See
6914: <a href="#faq.conf" title="7.14. How do I change the location of configuration files?">Section 7.14, “How do I change the location of configuration files?”</a> for more information.</p></li>
6915: <li><p>Define the <code class="varname">GCONF2_SCHEMAS</code> variable in
1.76 ! rillig 6916: your <code class="filename">Makefile</code> with a list of all
! 6917: <code class="filename">.schemas</code> files installed by the package, if
1.75 rillig 6918: any. Names must not contain any directories in them.</p></li>
6919: <li><p>Define the <code class="varname">GCONF2_ENTRIES</code> variable in
1.76 ! rillig 6920: your <code class="filename">Makefile</code> with a
! 6921: list of all <code class="filename">.entries</code> files installed by the
1.75 rillig 6922: package, if any. Names must not contain any directories in
6923: them.</p></li>
6924: </ol></div>
6925: </div>
6926: <div class="sect2" lang="en">
6927: <div class="titlepage"><div><div><h3 class="title">
6928: <a name="scrollkeeper-data-files"></a>16.5.10. Packages installing scrollkeeper data files</h3></div></div></div>
6929: <p>
1.76 ! rillig 6930: If a package installs <code class="filename">.omf</code> files, used by
1.75 rillig 6931: scrollkeeper, you need to take some extra steps to make sure they
6932: get registered in the database:
6933: </p>
6934: <div class="orderedlist"><ol type="1">
6935: <li><p>Include
1.76 ! rillig 6936: <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
! 6937: instead of its <code class="filename">buildlink3.mk</code> file. This
1.75 rillig 6938: takes care of rebuilding the scrollkeeper database at
6939: installation and deinstallation time, and disallows any access
6940: to it directly from the package.
6941: </p></li>
6942: <li><p>Check the PLIST and remove any entries under the
1.76 ! rillig 6943: <code class="filename">libdata/scrollkeeper</code> directory, as they
1.75 rillig 6944: will be handled automatically.</p></li>
1.76 ! rillig 6945: <li><p>Remove the <code class="filename">share/omf</code> directory from
1.75 rillig 6946: the PLIST. It will be handled by scrollkeeper.</p></li>
6947: </ol></div>
6948: </div>
6949: <div class="sect2" lang="en">
6950: <div class="titlepage"><div><div><h3 class="title">
6951: <a name="x11-fonts"></a>16.5.11. Packages installing X11 fonts</h3></div></div></div>
6952: <p>If a package installs font files, you will need to rebuild
6953: the fonts database in the directory where they get installed at
6954: installation and deinstallation time. This can be automatically
6955: done by using the pkginstall framework.</p>
6956: <p>You can list the directories where fonts are installed in the
6957: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
6958: variables, where <em class="replaceable"><code>type</code></em> can be one of
6959: “<span class="quote">ttf</span>”, “<span class="quote">type1</span>” or “<span class="quote">x11</span>”.
6960: Also make sure that the database file
1.76 ! rillig 6961: <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
1.75 rillig 6962: <p>Note that you should not create new directories for fonts;
6963: instead use the standard ones to avoid that the user needs to
6964: manually configure his X server to find them.</p>
6965: </div>
6966: <div class="sect2" lang="en">
6967: <div class="titlepage"><div><div><h3 class="title">
6968: <a name="gtk2-modules"></a>16.5.12. Packages installing GTK2 modules</h3></div></div></div>
6969: <p>If a package installs GTK2 immodules or loaders, you need to
6970: take some extra steps to get them registered in the GTK2 database
6971: properly:</p>
6972: <div class="orderedlist"><ol type="1">
6973: <li><p>Include
1.76 ! rillig 6974: <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
! 6975: <code class="filename">buildlink3.mk</code> file. This takes care of
1.75 rillig 6976: rebuilding the database at installation and deinstallation time.
6977: </p></li>
6978: <li><p>
6979: Set <code class="varname">GTK2_IMMODULES=YES</code> if
6980: your package installs GTK2 immodules.</p></li>
6981: <li><p>
6982: Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
6983: GTK2 loaders.</p></li>
6984: <li>
6985: <p>
6986: Patch the package to not touch any of the GTK2 databases directly.
6987: These are:
6988:
6989: </p>
6990: <div class="itemizedlist"><ul type="disc">
1.76 ! rillig 6991: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
! 6992: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
1.75 rillig 6993: </ul></div>
6994: <p>
6995: </p>
6996: </li>
6997: <li><p>
6998: Check the PLIST and remove any entries under the
1.76 ! rillig 6999: <code class="filename">libdata/gtk-2.0</code> directory, as they will be
1.75 rillig 7000: handled automatically.</p></li>
7001: </ol></div>
7002: </div>
7003: <div class="sect2" lang="en">
7004: <div class="titlepage"><div><div><h3 class="title">
7005: <a name="sgml-xml-data"></a>16.5.13. Packages installing SGML or XML data</h3></div></div></div>
7006: <p>If a package installs SGML or XML data files that need to be
7007: registered in system-wide catalogs (like DTDs, sub-catalogs,
7008: etc.), you need to take some extra steps:
7009: </p>
7010: <div class="orderedlist"><ol type="1">
7011: <li><p>Include
1.76 ! rillig 7012: <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
! 7013: your <code class="filename">Makefile</code>, which takes care of
1.75 rillig 7014: registering those files in system-wide catalogs at
7015: installation and deinstallation time.</p></li>
7016: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
7017: any SGML catalogs installed by the package.</p></li>
7018: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
7019: any XML catalogs installed by the package.</p></li>
7020: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
7021: to be added to the SGML catalog. These come in groups of
7022: three strings; see xmlcatmgr(1) for more information
7023: (specifically, arguments recognized by the 'add' action).
7024: Note that you will normally not use this variable.</p></li>
7025: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
7026: to be added to the XML catalog. These come in groups of three
7027: strings; see xmlcatmgr(1) for more information (specifically,
7028: arguments recognized by the 'add' action). Note that you will
7029: normally not use this variable.
7030: </p></li>
7031: </ol></div>
7032: </div>
7033: <div class="sect2" lang="en">
7034: <div class="titlepage"><div><div><h3 class="title">
7035: <a name="mime-database"></a>16.5.14. Packages installing extensions to the MIME database</h3></div></div></div>
7036: <p>If a package provides extensions to the MIME database by
1.76 ! rillig 7037: installing <code class="filename">.xml</code> files inside
! 7038: <code class="filename">${PREFIX}/share/mime/packages</code>, you
1.75 rillig 7039: need to take some extra steps to ensure that the database is kept
7040: consistent with respect to these new files:
7041: </p>
7042: <div class="orderedlist"><ol type="1">
7043: <li><p>Include
1.76 ! rillig 7044: <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
! 7045: (avoid using the <code class="filename">buildlink3.mk</code> file from
1.75 rillig 7046: this same directory, which is reserved for inclusion from
1.76 ! rillig 7047: other <code class="filename">buildlink3.mk</code> files). It takes
1.75 rillig 7048: care of rebuilding the MIME database at installation and
7049: deinstallation time, and disallows any access to it directly
7050: from the package.</p></li>
7051: <li><p>Check the PLIST and remove any entries under the
1.76 ! rillig 7052: <code class="filename">share/mime</code> directory,
1.75 rillig 7053: <span class="emphasis"><em>except</em></span> for files saved under
1.76 ! rillig 7054: <code class="filename">share/mime/packages</code>. The former are
1.75 rillig 7055: handled automatically by
7056: the update-mime-database program, but the latter are
7057: package-dependent and must be removed by the package that
7058: installed them in the first place.</p></li>
1.76 ! rillig 7059: <li><p>Remove any <code class="filename">share/mime/*</code> directories
1.75 rillig 7060: from the PLIST. They will be handled by the shared-mime-info
7061: package.</p></li>
7062: </ol></div>
7063: </div>
7064: <div class="sect2" lang="en">
7065: <div class="titlepage"><div><div><h3 class="title">
7066: <a name="intltool"></a>16.5.15. Packages using intltool</h3></div></div></div>
7067: <p>If a package uses intltool during its build, include the
1.76 ! rillig 7068: <code class="filename">../../textproc/intltool/buildlink3.mk</code> file,
1.75 rillig 7069: which forces it to use the intltool package provided by pkgsrc,
7070: instead of the one bundled with the distribution file.
7071: </p>
7072: <p>This tracks intltool's build-time dependencies and uses the
7073: latest available version; this way, the package benefits of any
7074: bug fixes that may have appeared since it was released.
7075: </p>
7076: </div>
7077: <div class="sect2" lang="en">
7078: <div class="titlepage"><div><div><h3 class="title">
7079: <a name="startup-scripts"></a>16.5.16. Packages installing startup scripts</h3></div></div></div>
7080: <p>If a package contains a rc.d script, it won't be copied into
7081: the startup directory by default, but you can enable it, by adding
7082: the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
1.76 ! rillig 7083: <code class="filename">/etc/mk.conf</code>. This option will copy the scripts
! 7084: into <code class="filename">/etc/rc.d</code> when a package is installed, and
1.75 rillig 7085: it will automatically remove the scripts when the package is
7086: deinstalled.</p>
7087: </div>
7088: <div class="sect2" lang="en">
7089: <div class="titlepage"><div><div><h3 class="title">
7090: <a name="tex-packages"></a>16.5.17. Packages installing TeX modules</h3></div></div></div>
7091: <p>If a package installs TeX packages into the texmf tree,
1.76 ! rillig 7092: the <code class="filename">ls-R</code> database of the tree needs to be
1.75 rillig 7093: updated.</p>
7094: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7095: <h3 class="title">Note</h3>
7096: <p>Except the main TeX packages such as teTeX-texmf,
7097: packages should install files
7098: into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
7099: not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
7100: </div>
7101: <div class="orderedlist"><ol type="1">
7102: <li><p>Include
1.76 ! rillig 7103: <code class="filename">../../print/teTeX/module.mk</code> instead
! 7104: of <code class="filename">../../mk/tex.buildlink3.mk</code>. This
! 7105: takes care of rebuilding the <code class="filename">ls-R</code>
1.75 rillig 7106: database at installation and deinstallation time.</p></li>
7107: <li>
7108: <p>If your package installs files into a texmf
7109: tree other than the one
7110: at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
7111: set <code class="varname">TEXMFDIRS</code> to the list of all texmf
7112: trees that need database update.</p>
7113: <p>If your package also installs font map files that need
7114: to be registered using <span><strong class="command">updmap</strong></span>,
7115: set <code class="varname">TEX_FONTMAPS</code> to the list of all
7116: such font map files. Then <span><strong class="command">updmap</strong></span> will
7117: be run automatically at installation/deinstallation to
7118: enable/disable font map files for TeX output
7119: drivers.</p>
7120: </li>
1.76 ! rillig 7121: <li><p>Make sure that none of <code class="filename">ls-R</code>
! 7122: databases are included in <code class="filename">PLIST</code>, as
1.75 rillig 7123: they will be removed only by the teTeX-bin package.</p></li>
7124: </ol></div>
7125: </div>
7126: </div>
7127: <div class="sect1" lang="en">
7128: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7129: <a name="feedback-to-author"></a>16.6. Feedback to the author</h2></div></div></div>
7130: <p>If you have found any bugs in the package you make available,
7131: if you had to do special steps to make it run under NetBSD or
7132: if you enhanced the software in various other ways, be sure
7133: to report these changes back to the original author of the
7134: program! With that kind of support, the next release of the
7135: program can incorporate these fixes, and people not using the
7136: NetBSD packages system can win from your efforts.</p>
7137: <p>Support the idea of free software!</p>
7138: </div>
7139: </div>
7140: <div class="chapter" lang="en">
7141: <div class="titlepage"><div><div><h2 class="title">
7142: <a name="debug"></a>Chapter 17. Debugging</h2></div></div></div>
7143: <p>To check out all the gotchas when building a package, here are the steps
7144: that I do in order to get a package working. Please note this is basically
7145: the same as what was explained in the previous sections, only with some
7146: debugging aids.</p>
7147: <div class="itemizedlist"><ul type="disc">
7148: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=1</code>
1.76 ! rillig 7149: in <code class="filename">/etc/mk.conf</code></p></li>
1.75 rillig 7150: <li>
1.76 ! rillig 7151: <p>Install <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a>,
1.75 rillig 7152: create a directory for a new package, change into it, then run
7153: <span><strong class="command">url2pkg</strong></span>:</p>
7154: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>mkdir /usr/pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>examplepkg</code></em></code></strong>
7155: <code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>examplepkg</code></em></code></strong>
7156: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
7157: </li>
1.76 ! rillig 7158: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
! 7159: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.75 rillig 7160: <li><p>Run <span><strong class="command">make configure</strong></span>
7161: </p></li>
7162: <li><p>Add any dependencies glimpsed from documentation and the
7163: configure step to the package's
1.76 ! rillig 7164: <code class="filename">Makefile</code>.</p></li>
1.75 rillig 7165: <li>
7166: <p>Make the package compile, doing multiple rounds of</p>
7167: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
7168: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
7169: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
7170: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
7171: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
7172: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
7173: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
7174: <p>Doing as non-root user will ensure that no files are modified that
7175: shouldn't be, especially during the build
7176: phase. <span><strong class="command">mkpatches</strong></span>,
7177: <span><strong class="command">patchdiff</strong></span> and <span><strong class="command">pkgvi</strong></span> are
1.76 ! rillig 7178: from the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a>
1.75 rillig 7179: package. </p>
7180: </li>
1.76 ! rillig 7181: <li><p>Look at the <code class="filename">Makefile</code>, fix if necessary;
! 7182: see <a href="#components.Makefile" title="8.1. Makefile">Section 8.1, “<code class="filename">Makefile</code>”</a>.</p></li>
1.75 rillig 7183: <li>
1.76 ! rillig 7184: <p>Generate a <code class="filename">PLIST</code>:</p>
1.75 rillig 7185: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
7186: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST >PLIST</code></strong>
7187: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
7188: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
7189: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
1.76 ! rillig 7190: <p>You usually need to be <code class="username">root</code> to do this.
1.75 rillig 7191: Look if there are any files left:</p>
7192: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
7193: <p>If this reveals any files that are missing in
1.76 ! rillig 7194: <code class="filename">PLIST</code>, add them.</p>
1.75 rillig 7195: </li>
7196: <li>
1.76 ! rillig 7197: <p>Now that the <code class="filename">PLIST</code> is OK,
1.75 rillig 7198: install the package again and make a binary package:</p>
7199: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
7200: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
7201: </li>
7202: <li>
7203: <p>Delete the installed package:</p>
7204: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete blub</code></strong></pre>
7205: </li>
7206: <li>
7207: <p>Repeat the above <span><strong class="command">make print-PLIST</strong></span> command,
7208: which shouldn't find anything now:</p>
7209: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
7210: </li>
7211: <li>
7212: <p>Reinstall the binary package:</p>
7213: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkgadd .../blub.tgz</code></strong></pre>
7214: </li>
7215: <li><p>Play with it. Make sure everything works.</p></li>
7216: <li>
7217: <p>Run <span><strong class="command">pkglint</strong></span> from
1.76 ! rillig 7218: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>,
1.75 rillig 7219: and fix the problems it reports:</p>
7220: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
7221: </li>
7222: <li><p>Submit (or commit, if you have cvs access);
7223: see <a href="#submit" title="Chapter 18. Submitting and Committing">Chapter 18, <i>Submitting and Committing</i></a>.</p></li>
7224: </ul></div>
7225: </div>
7226: <div class="chapter" lang="en">
7227: <div class="titlepage"><div><div><h2 class="title">
7228: <a name="submit"></a>Chapter 18. Submitting and Committing</h2></div></div></div>
7229: <div class="toc">
7230: <p><b>Table of Contents</b></p>
7231: <dl>
7232: <dt><span class="sect1"><a href="#submitting-binary-packages">18.1. Submitting binary packages</a></span></dt>
7233: <dt><span class="sect1"><a href="#submitting-your-package">18.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
7234: <dt><span class="sect1"><a href="#general-notes-for-changes">18.3. General notes when adding, updating, or removing packages</a></span></dt>
7235: <dt><span class="sect1"><a href="#committing-importing">18.4. Committing: Importing a package into CVS</a></span></dt>
7236: <dt><span class="sect1"><a href="#updating-package">18.5. Updating a package to a newer version</a></span></dt>
7237: <dt><span class="sect1"><a href="#moving-package">18.6. Moving a package in pkgsrc</a></span></dt>
7238: </dl>
7239: </div>
7240: <div class="sect1" lang="en">
7241: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7242: <a name="submitting-binary-packages"></a>18.1. Submitting binary packages</h2></div></div></div>
7243: <p>Our policy is that we accept binaries only from pkgsrc
7244: developers to guarantee that the packages don't contain any
7245: trojan horses etc. This is not to annoy anyone but rather to
7246: protect our users! You're still free to put up your home-made
7247: binary packages and tell the world where to get them. NetBSD
7248: developers doing bulk builds and wanting to upload them please
7249: see <a href="#bulk-upload" title="6.3.8. Uploading results of a bulk build">Section 6.3.8, “Uploading results of a bulk build”</a>.</p>
7250: </div>
7251: <div class="sect1" lang="en">
7252: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7253: <a name="submitting-your-package"></a>18.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
7254: <p>First, check that your package is complete, compiles and
7255: runs well; see <a href="#debug" title="Chapter 17. Debugging">Chapter 17, <i>Debugging</i></a> and the rest of this
7256: document. Next, generate an uuencoded gzipped <a href="http://netbsd.gw.com/cgi-bin/man-cgi?tar+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span></a>
7257: archive, preferably with all files in a single directory.
7258: Finally, <span><strong class="command">send-pr</strong></span> with category
7259: “<span class="quote">pkg</span>”, a synopsis which includes the package name
7260: and version number, a short description of your package
7261: (contents of the COMMENT variable or DESCR file are OK) and
7262: attach the archive to your PR.</p>
7263: <p>If you want to submit several packages, please send a
7264: separate PR for each one, it's easier for us to track things
7265: that way.</p>
7266: <p>Alternatively, you can also import new packages into
7267: pkgsrc-wip (“<span class="quote">pkgsrc work-in-progress</span>”); see the
7268: homepage at <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
7269: for details.</p>
7270: </div>
7271: <div class="sect1" lang="en">
7272: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7273: <a name="general-notes-for-changes"></a>18.3. General notes when adding, updating, or removing packages</h2></div></div></div>
7274: <p>Please note all package additions, updates, moves, and
1.76 ! rillig 7275: removals in <code class="filename">pkgsrc/doc/CHANGES</code>. It's very
1.75 rillig 7276: important to keep this file up to date and conforming to the
7277: existing format, because it will be used by scripts to
7278: automatically update pages on <a href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
7279: sites. Additionally, check the
1.76 ! rillig 7280: <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
1.75 rillig 7281: for the package you updated or removed, in case it was mentioned
7282: there.</p>
7283: <p>When the <code class="varname">PKGREVISION</code> of a package is
7284: bumped, the change should appear in
1.76 ! rillig 7285: <code class="filename">pkgsrc/doc/CHANGES</code> if it is security
1.75 rillig 7286: related or otherwise relevant. Mass bumps that result from a
7287: dependency being updated should not be mentioned. In all other
7288: cases it's the developer's decision.</p>
7289: <p>There is a make target that helps in creating proper
1.76 ! rillig 7290: <code class="filename">CHANGES</code> entries: <span><strong class="command">make
1.75 rillig 7291: changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
7292: and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
1.76 ! rillig 7293: usage is to first make sure that your <code class="filename">CHANGES</code>
1.75 rillig 7294: file is up-to-date (to avoid having to resolve conflicts later-on)
7295: and then to <span><strong class="command">cd</strong></span> to the package directory. For
7296: package updates, <span><strong class="command">make changes-entry</strong></span> is enough.
7297: For new packages, or package moves or removals, set the
7298: <code class="varname">CTYPE</code> variable on the command line to "Added",
7299: "Moved", or "Removed". You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.76 ! rillig 7300: in <code class="filename">/etc/mk.conf</code> if your local login name is
1.75 rillig 7301: not the same as your NetBSD login name. Don't forget to commit
1.76 ! rillig 7302: the changes to <code class="filename">pkgsrc/doc/CHANGES</code>!</p>
1.75 rillig 7303: </div>
7304: <div class="sect1" lang="en">
7305: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7306: <a name="committing-importing"></a>18.4. Committing: Importing a package into CVS</h2></div></div></div>
7307: <p>
7308: This section is only of interest for pkgsrc developers with write
7309: access to the pkgsrc repository. Please remember that cvs
7310: imports files relative to the current working directory, and that
7311: the pathname that you
7312: give the <span><strong class="command">cvs import</strong></span> command is so that it knows where
7313: to place the files in the repository. Newly created packages should be
7314: imported with a vendor tag of “<span class="quote">TNF</span>” and a release tag of
7315: “<span class="quote">pkgsrc-base</span>”, e.g:
7316: </p>
7317: <pre class="programlisting">
7318: <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
7319: <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
7320: </pre>
7321: <p>
7322: Remember to move the directory from which you imported out of
7323: the way, or cvs will complain the next time you “<span class="quote">cvs
7324: update</span>” your source tree. Also don't forget to add the new
1.76 ! rillig 7325: package to the category's <code class="filename">Makefile</code>.
1.75 rillig 7326: </p>
7327: <p>
7328: The commit message of the initial import should include part of the
1.76 ! rillig 7329: <code class="filename">DESCR</code> file, so people reading the mailing lists know
1.75 rillig 7330: what the package is/does.
7331: </p>
7332: <p>
7333: For new packages, “<span class="quote">cvs import</span>” is preferred to “<span class="quote">cvs
7334: add</span>” because the former gets everything with a single command,
7335: and provides a consistent tag.
7336: </p>
7337: </div>
7338: <div class="sect1" lang="en">
7339: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7340: <a name="updating-package"></a>18.5. Updating a package to a newer version</h2></div></div></div>
7341: <p>
7342: Please always put a concise, appropriate and relevant summary of the
7343: changes between old and new versions into the commit log when updating
7344: a package. There are various reasons for this:
7345: </p>
7346: <div class="itemizedlist"><ul type="disc">
7347: <li><p>
7348: A URL is volatile, and can change over time. It may go away completely
7349: or its information may be overwritten by newer information.
7350: </p></li>
7351: <li><p>
7352: Having the change information between old and new versions in our CVS
7353: repository is very useful for people who use either cvs or anoncvs.
7354: </p></li>
7355: <li><p>
7356: Having the change information between old and new versions in our CVS
7357: repository is very useful for people who read the pkgsrc-changes mailing
7358: list, so that they can make tactical decisions about when to upgrade
7359: the package.
7360: </p></li>
7361: </ul></div>
7362: <p>
7363: Please also recognize that, just because a new version of a package
7364: has been released, it should not automatically be upgraded in the CVS
7365: repository. We prefer to be conservative in the packages that are
7366: included in pkgsrc - development or beta packages are not really the
7367: best thing for most places in which pkgsrc is used. Please use your
7368: judgement about what should go into pkgsrc, and bear in mind that
7369: stability is to be preferred above new and possibly untested features.
7370: </p>
7371: </div>
7372: <div class="sect1" lang="en">
7373: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7374: <a name="moving-package"></a>18.6. Moving a package in pkgsrc</h2></div></div></div>
7375: <div class="orderedlist"><ol type="1">
7376: <li><p>Make a copy of the directory somewhere else.</p></li>
7377: <li>
7378: <p>Remove all CVS dirs.</p>
7379: <p>
7380: Alternatively to the first two steps you can also do:
7381: </p>
7382: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package</code></strong></pre>
7383: <p>
7384: and use that for further work.
7385: </p>
7386: </li>
7387: <li><p>Fix <code class="varname">CATEGORIES</code> and any
7388: <code class="varname">DEPENDS</code> paths that just did “<span class="quote">../package</span>”
7389: instead of “<span class="quote">../../category/package</span>”.</p></li>
7390: <li><p><span><strong class="command">cvs import</strong></span> the modified package in the new
7391: place.</p></li>
7392: <li>
7393: <p>Check if any package depends on it:
7394: </p>
7395: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
7396: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
7397: <p>
7398: </p>
7399: </li>
7400: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
7401: <li><p><span><strong class="command">cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.76 ! rillig 7402: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
! 7403: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
1.75 rillig 7404: <li>
7405: <p>Commit the changed and removed files:</p>
7406: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong></pre>
7407: <p>
7408: (and any packages from step 5, of course).
7409: </p>
7410: </li>
7411: </ol></div>
7412: </div>
7413: </div>
7414: <div class="chapter" lang="en">
7415: <div class="titlepage"><div><div><h2 class="title">
7416: <a name="devfaq"></a>Chapter 19. Frequently Asked Questions</h2></div></div></div>
7417: <p>This section contains the answers to questions that may
7418: arise when you are writing a package. If you don't find your
7419: question answered here, first have a look in the other chapters,
7420: and if you still don't have the answer, ask on the
7421: <code class="literal">pkgsrc-users</code> mailing list.</p>
7422: <div class="qandaset">
7423: <dl>
1.76 ! rillig 7424: <dt>19.1. <a href="#id2654892">What is the difference between
1.75 rillig 7425: MAKEFLAGS, .MAKEFLAGS and
7426: MAKE_FLAGS?</a>
7427: </dt>
1.76 ! rillig 7428: <dt>19.2. <a href="#id2654929">What is the difference between
1.75 rillig 7429: MAKE, GMAKE and
7430: MAKE_PROGRAM?</a>
7431: </dt>
1.76 ! rillig 7432: <dt>19.3. <a href="#id2655035">What is the difference between
1.75 rillig 7433: CC, PKG_CC and
7434: PKGSRC_COMPILER?</a>
7435: </dt>
1.76 ! rillig 7436: <dt>19.4. <a href="#id2655073">What is the difference between
1.75 rillig 7437: BUILDLINK_LDFLAGS,
7438: BUILDLINK_LDADD and
7439: BUILDLINK_LIBS?</a>
7440: </dt>
1.76 ! rillig 7441: <dt>19.5. <a href="#id2655091">Why does make show-var
1.75 rillig 7442: VARNAME=BUILDLINK_PREFIX.foo
7443: say it's empty?</a>
7444: </dt>
7445: </dl>
7446: <table border="0" summary="Q and A Set">
7447: <col align="left" width="1%">
7448: <tbody>
7449: <tr class="question">
7450: <td align="left" valign="top">
1.76 ! rillig 7451: <a name="id2654892"></a><a name="id2654893"></a><b>19.1.</b>
1.75 rillig 7452: </td>
7453: <td align="left" valign="top"><p>What is the difference between
7454: <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
7455: <code class="varname">MAKE_FLAGS</code>?</p></td>
7456: </tr>
7457: <tr class="answer">
7458: <td align="left" valign="top"><b></b></td>
7459: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
7460: to the pkgsrc-internal invocations of <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>, while
7461: <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
7462: the <code class="varname">MAKE_PROGRAM</code> when building the
7463: package. [FIXME: What is .MAKEFLAGS for?]</p></td>
7464: </tr>
7465: <tr class="question">
7466: <td align="left" valign="top">
1.76 ! rillig 7467: <a name="id2654929"></a><a name="id2654930"></a><b>19.2.</b>
1.75 rillig 7468: </td>
7469: <td align="left" valign="top"><p>What is the difference between
7470: <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
7471: <code class="varname">MAKE_PROGRAM</code>?</p></td>
7472: </tr>
7473: <tr class="answer">
7474: <td align="left" valign="top"><b></b></td>
7475: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
7476: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> program that is used in the pkgsrc
7477: infrastructure. <code class="varname">GMAKE</code> is the path to GNU
7478: Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
7479: use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
7480: Make program that is used for building the
7481: package.</p></td>
7482: </tr>
7483: <tr class="question">
7484: <td align="left" valign="top">
1.76 ! rillig 7485: <a name="id2655035"></a><a name="id2655036"></a><b>19.3.</b>
1.75 rillig 7486: </td>
7487: <td align="left" valign="top"><p>What is the difference between
7488: <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
7489: <code class="varname">PKGSRC_COMPILER</code>?</p></td>
7490: </tr>
7491: <tr class="answer">
7492: <td align="left" valign="top"><b></b></td>
7493: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
7494: compiler, which can be configured by the pkgsrc user.
7495: <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
7496: <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
7497: path to a compiler, but the type of compiler that should be
1.76 ! rillig 7498: used. See <code class="filename">mk/compiler.mk</code> for more
1.75 rillig 7499: information about the latter variable.</p></td>
7500: </tr>
7501: <tr class="question">
7502: <td align="left" valign="top">
1.76 ! rillig 7503: <a name="id2655073"></a><a name="id2655074"></a><b>19.4.</b>
1.75 rillig 7504: </td>
7505: <td align="left" valign="top"><p>What is the difference between
7506: <code class="varname">BUILDLINK_LDFLAGS</code>,
7507: <code class="varname">BUILDLINK_LDADD</code> and
7508: <code class="varname">BUILDLINK_LIBS</code>?</p></td>
7509: </tr>
7510: <tr class="answer">
7511: <td align="left" valign="top"><b></b></td>
7512: <td align="left" valign="top"><p>[FIXME]</p></td>
7513: </tr>
7514: <tr class="question">
7515: <td align="left" valign="top">
1.76 ! rillig 7516: <a name="id2655091"></a><a name="id2655092"></a><b>19.5.</b>
1.75 rillig 7517: </td>
7518: <td align="left" valign="top"><p>Why does <span><strong class="command">make show-var
7519: VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
7520: say it's empty?</p></td>
7521: </tr>
7522: <tr class="answer">
7523: <td align="left" valign="top"><b></b></td>
7524: <td align="left" valign="top"><p>For optimization reasons, some variables are only
7525: available in the “<span class="quote">wrapper</span>” phase and later. To
7526: “<span class="quote">simulate</span>” the wrapper phase, append
7527: <span><strong class="command">PKG_PHASE=wrapper</strong></span> to the above
7528: command.</p></td>
7529: </tr>
7530: </tbody>
7531: </table>
7532: </div>
7533: </div>
7534: </div>
7535: <div class="part" lang="en">
7536: <div class="titlepage"><div><div><h1 class="title">
7537: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
7538: <div class="partintro" lang="en">
7539: <div></div>
7540: <p>This part of the guide deals with everything
7541: from the infrastructure that is behind the interfaces described
7542: in the developer's guide. A casual package maintainer should not
7543: need anything from this part.</p>
7544: <div class="toc">
7545: <p><b>Table of Contents</b></p>
7546: <dl>
7547: <dt><span class="chapter"><a href="#infr.design">20. Design of the pkgsrc infrastructure</a></span></dt>
7548: <dd><dl>
7549: <dt><span class="sect1"><a href="#infr.var">20.1. Variable evaluation</a></span></dt>
7550: <dd><dl>
7551: <dt><span class="sect2"><a href="#infr.var.load">20.1.1. At load time</a></span></dt>
7552: <dt><span class="sect2"><a href="#infr.var.run">20.1.2. At runtime</a></span></dt>
7553: </dl></dd>
7554: <dt><span class="sect1"><a href="#infr.design.intf">20.2. Designing interfaces for Makefile fragments</a></span></dt>
7555: <dd><dl>
7556: <dt><span class="sect2"><a href="#infr.design.intf.proc">20.2.1. Procedures with parameters</a></span></dt>
7557: <dt><span class="sect2"><a href="#infr.design.intf.action">20.2.2. Actions taken on behalf of parameters</a></span></dt>
7558: </dl></dd>
7559: </dl></dd>
7560: <dt><span class="chapter"><a href="#regression">21. Regression tests</a></span></dt>
7561: <dd><dl>
7562: <dt><span class="sect1"><a href="#regression.descr">21.1. The regression tests framework</a></span></dt>
7563: <dt><span class="sect1"><a href="#regression.run">21.2. Running the regression tests</a></span></dt>
7564: <dt><span class="sect1"><a href="#regression.new">21.3. Adding a new regression test</a></span></dt>
7565: <dd><dl>
7566: <dt><span class="sect2"><a href="#regression.fun.override">21.3.1. Overridable functions</a></span></dt>
7567: <dt><span class="sect2"><a href="#regression.fun.helper">21.3.2. Helper functions</a></span></dt>
7568: </dl></dd>
7569: </dl></dd>
7570: <dt><span class="chapter"><a href="#porting">22. Porting pkgsrc</a></span></dt>
7571: <dd><dl>
7572: <dt><span class="sect1"><a href="#porting.opsys">22.1. Porting pkgsrc to a new operating system</a></span></dt>
7573: <dt><span class="sect1"><a href="#porting.compiler">22.2. Adding support for a new compiler</a></span></dt>
7574: </dl></dd>
7575: </dl>
7576: </div>
7577: </div>
7578: <div class="chapter" lang="en">
7579: <div class="titlepage"><div><div><h2 class="title">
7580: <a name="infr.design"></a>Chapter 20. Design of the pkgsrc infrastructure</h2></div></div></div>
7581: <div class="toc">
7582: <p><b>Table of Contents</b></p>
7583: <dl>
7584: <dt><span class="sect1"><a href="#infr.var">20.1. Variable evaluation</a></span></dt>
7585: <dd><dl>
7586: <dt><span class="sect2"><a href="#infr.var.load">20.1.1. At load time</a></span></dt>
7587: <dt><span class="sect2"><a href="#infr.var.run">20.1.2. At runtime</a></span></dt>
7588: </dl></dd>
7589: <dt><span class="sect1"><a href="#infr.design.intf">20.2. Designing interfaces for Makefile fragments</a></span></dt>
7590: <dd><dl>
7591: <dt><span class="sect2"><a href="#infr.design.intf.proc">20.2.1. Procedures with parameters</a></span></dt>
7592: <dt><span class="sect2"><a href="#infr.design.intf.action">20.2.2. Actions taken on behalf of parameters</a></span></dt>
7593: </dl></dd>
7594: </dl>
7595: </div>
7596: <p>The pkgsrc infrastructure consists of many small Makefile
7597: fragments. Each such fragment needs a properly specified
7598: interface. This chapter explains how such an interface looks
7599: like.</p>
7600: <div class="sect1" lang="en">
7601: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7602: <a name="infr.var"></a>20.1. Variable evaluation</h2></div></div></div>
7603: <div class="sect2" lang="en">
7604: <div class="titlepage"><div><div><h3 class="title">
7605: <a name="infr.var.load"></a>20.1.1. At load time</h3></div></div></div>
7606: <p>Variable evaluation takes place either at load time or at
7607: runtime, depending on the context in which they occur. The
7608: contexts where variables are evaluated at load time are:</p>
7609: <div class="itemizedlist"><ul type="disc">
7610: <li><p>The right hand side of the <code class="literal">:=</code>
7611: and <code class="literal">!=</code> operators,</p></li>
7612: <li><p>Make directives like <code class="literal">.if</code> or
7613: <code class="literal">.for</code>,</p></li>
7614: <li><p>Dependency lines.</p></li>
7615: </ul></div>
7616: <p>A special exception are references to the iteration
7617: variables of <code class="literal">.for</code> loops, which are expanded
7618: inline, no matter in which context they appear.</p>
7619: <p>As the values of variables may change during load time,
7620: care must be taken not to evaluate them by accident. Typical
7621: examples for variables that should not be evaluated at load time
7622: are <code class="varname">DEPENDS</code> and
7623: <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
7624: clear, here is an example:</p>
7625: <pre class="programlisting">
7626: CONFIGURE_ARGS= # none
7627: CFLAGS= -O
7628: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
1.1 grant 7629:
1.75 rillig 7630: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
1.1 grant 7631:
1.75 rillig 7632: CFLAGS+= -Wall
7633: </pre>
7634: <p>This code shows how the use of the <code class="literal">:=</code>
7635: operator can quickly lead to unexpected results. The first
7636: paragraph is fairly common code. The second paragraph evaluates
7637: the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
7638: <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
7639: <code class="literal">-Wall</code> is appended to the
7640: <code class="varname">CFLAGS</code>, but this addition will not appear in
7641: <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
7642: paragraphs from above typically occur in completely unrelated
7643: files.</p>
7644: </div>
7645: <div class="sect2" lang="en">
7646: <div class="titlepage"><div><div><h3 class="title">
7647: <a name="infr.var.run"></a>20.1.2. At runtime</h3></div></div></div>
7648: <p>After all the files have been loaded, the values of the
7649: variables cannot be changed anymore. Variables that are used in
7650: the shell commands are expanded at this point.</p>
7651: </div>
7652: </div>
7653: <div class="sect1" lang="en">
7654: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7655: <a name="infr.design.intf"></a>20.2. Designing interfaces for Makefile fragments</h2></div></div></div>
1.76 ! rillig 7656: <p>Most of the <code class="filename">.mk</code> files fall into one
1.75 rillig 7657: of the following classes. Cases where a file falls into more
7658: than one class should be avoided as it often leads to subtle
7659: bugs.</p>
7660: <div class="sect2" lang="en">
7661: <div class="titlepage"><div><div><h3 class="title">
7662: <a name="infr.design.intf.proc"></a>20.2.1. Procedures with parameters</h3></div></div></div>
7663: <p>In a traditional imperative programming language some of
1.76 ! rillig 7664: the <code class="filename">.mk</code> files could be described as
1.75 rillig 7665: procedures. They take some input parameters and—after
7666: inclusion—provide a result in output parameters. Since all
1.76 ! rillig 7667: variables in <code class="filename">Makefile</code>s have global scope
1.75 rillig 7668: care must be taken not to use parameter names that have already
7669: another meaning. For example, <code class="varname">PKGNAME</code> is a
7670: bad choice for a parameter name.</p>
7671: <p>Procedures are completely evaluated at preprocessing time.
7672: That is, when calling a procedure all input parameters must be
7673: completely resolvable. For example,
7674: <code class="varname">CONFIGURE_ARGS</code> should never be an input
7675: parameter since it is very likely that further text will be
7676: added after calling the procedure, which would effectively apply
7677: the procedure to only a part of the variable. Also, references
7678: to other variables wit will be modified after calling the
7679: procedure.</p>
7680: <p>A procedure can declare its output parameters either as
7681: suitable for use in preprocessing directives or as only
7682: available at runtime. The latter alternative is for variables
7683: that contain references to other runtime variables.</p>
7684: <p>Procedures shall be written such that it is possible to
7685: call the procedure more than once. That is, the file must not
7686: contain multiple-inclusion guards.</p>
7687: <p>Examples for procedures are
1.76 ! rillig 7688: <code class="filename">mk/bsd.options.mk</code> and
! 7689: <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
1.75 rillig 7690: that the parameters are evaluated at load time, they should be
7691: assigned using the <code class="literal">:=</code> operator, which should
7692: be used only for this purpose.</p>
7693: </div>
7694: <div class="sect2" lang="en">
7695: <div class="titlepage"><div><div><h3 class="title">
7696: <a name="infr.design.intf.action"></a>20.2.2. Actions taken on behalf of parameters</h3></div></div></div>
7697: <p>Action files take some input parameters and may define
7698: runtime variables. They shall not define loadtime variables.
7699: There are action files that are included implicitly by the
7700: pkgsrc infrastructure, while other must be included
7701: explicitly.</p>
7702: <p>An example for action files is
1.76 ! rillig 7703: <code class="filename">mk/subst.mk</code>.</p>
1.75 rillig 7704: </div>
7705: </div>
7706: </div>
7707: <div class="chapter" lang="en">
7708: <div class="titlepage"><div><div><h2 class="title">
7709: <a name="regression"></a>Chapter 21. Regression tests</h2></div></div></div>
7710: <div class="toc">
7711: <p><b>Table of Contents</b></p>
7712: <dl>
7713: <dt><span class="sect1"><a href="#regression.descr">21.1. The regression tests framework</a></span></dt>
7714: <dt><span class="sect1"><a href="#regression.run">21.2. Running the regression tests</a></span></dt>
7715: <dt><span class="sect1"><a href="#regression.new">21.3. Adding a new regression test</a></span></dt>
7716: <dd><dl>
7717: <dt><span class="sect2"><a href="#regression.fun.override">21.3.1. Overridable functions</a></span></dt>
7718: <dt><span class="sect2"><a href="#regression.fun.helper">21.3.2. Helper functions</a></span></dt>
7719: </dl></dd>
7720: </dl>
7721: </div>
7722: <p>The pkgsrc infrastructure consists of a large codebase,
7723: and there are many corners where every little bit of a file is
7724: well thought out, making pkgsrc likely to fail as soon as
7725: anything is changed near those parts. To prevent most changes
7726: from breaking anything, a suite of regression tests should go
7727: along with every important part of the pkgsrc infrastructure.
7728: This chapter describes how regression tests work in pkgsrc and
7729: how you can add new tests.</p>
7730: <div class="sect1" lang="en">
7731: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7732: <a name="regression.descr"></a>21.1. The regression tests framework</h2></div></div></div>
7733: <p></p>
7734: </div>
7735: <div class="sect1" lang="en">
7736: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7737: <a name="regression.run"></a>21.2. Running the regression tests</h2></div></div></div>
1.76 ! rillig 7738: <p>You first need to install the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_regress/README.html" target="_top"><code class="filename">pkgtools/pkg_regress</code></a> package, which
1.75 rillig 7739: provides the <span><strong class="command">pkg_regress</strong></span> command. Then you
7740: can simply run that command, which will run all tests in the
1.76 ! rillig 7741: <code class="filename">regress</code> category.</p>
1.75 rillig 7742: </div>
7743: <div class="sect1" lang="en">
7744: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7745: <a name="regression.new"></a>21.3. Adding a new regression test</h2></div></div></div>
1.76 ! rillig 7746: <p>Every directory in the <code class="filename">regress</code>
! 7747: category that contains a file called <code class="filename">spec</code>
1.75 rillig 7748: is considered a regression test. This file is a shell program
7749: that is included by the <span><strong class="command">pkg_regress</strong></span> command.
7750: The following functions can be overridden to suit your
7751: needs.</p>
7752: <div class="sect2" lang="en">
7753: <div class="titlepage"><div><div><h3 class="title">
7754: <a name="regression.fun.override"></a>21.3.1. Overridable functions</h3></div></div></div>
7755: <p>These functions do not take any parameters. They are all
7756: called in “<span class="quote">set -e</span>” mode, so you should be careful
7757: to check the exitcodes of any commands you run in the
7758: test.</p>
7759: <div class="variablelist"><dl>
7760: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
7761: <dd><p>This function prepares the environment for the
7762: test. By default it does nothing.</p></dd>
7763: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
7764: <dd><p>This function runs the actual test. By default,
7765: it calls <code class="varname">TEST_MAKE</code> with the arguments
7766: <code class="varname">MAKEARGS_TEST</code> and writes its output including
7767: error messages into the file
7768: <code class="varname">TEST_OUTFILE</code>.</p></dd>
7769: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
7770: <dd><p>This function is run after the test and is
7771: typically used to compare the actual output from the one that is
7772: expected. It can make use of the various helper functions from
7773: the next section.</p></dd>
7774: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
7775: <dd><p>This function cleans everything up after the
7776: test has been run. By default it does nothing.</p></dd>
7777: </dl></div>
7778: </div>
7779: <div class="sect2" lang="en">
7780: <div class="titlepage"><div><div><h3 class="title">
7781: <a name="regression.fun.helper"></a>21.3.2. Helper functions</h3></div></div></div>
7782: <div class="variablelist"><dl>
7783: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
7784: <dd><p>This function compares the exitcode of the
7785: <span><strong class="command">do_test()</strong></span> function with its first parameter.
7786: If they differ, the test will fail.</p></dd>
7787: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
7788: <dd><p>This function checks for each of its parameters
7789: if the output from <span><strong class="command">do_test()</strong></span> matches the
7790: extended regular expression. If it does not, the test will
7791: fail.</p></dd>
7792: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
7793: <dd><p>This function checks for each of its parameters
7794: if the output from <span><strong class="command">do_test()</strong></span> does
7795: <span class="emphasis"><em>not</em></span> match the extended regular expression.
7796: If any of the regular expressions matches, the test will
7797: fail.</p></dd>
7798: </dl></div>
7799: </div>
7800: </div>
7801: </div>
7802: <div class="chapter" lang="en">
7803: <div class="titlepage"><div><div><h2 class="title">
7804: <a name="porting"></a>Chapter 22. Porting pkgsrc</h2></div></div></div>
7805: <div class="toc">
7806: <p><b>Table of Contents</b></p>
7807: <dl>
7808: <dt><span class="sect1"><a href="#porting.opsys">22.1. Porting pkgsrc to a new operating system</a></span></dt>
7809: <dt><span class="sect1"><a href="#porting.compiler">22.2. Adding support for a new compiler</a></span></dt>
7810: </dl>
7811: </div>
7812: <p>The pkgsrc system has already been ported to many
7813: operating systems, hardware architectures and compilers. This
7814: chapter explains the necessary steps to make pkgsrc even more
7815: portable.</p>
7816: <div class="sect1" lang="en">
7817: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7818: <a name="porting.opsys"></a>22.1. Porting pkgsrc to a new operating system</h2></div></div></div>
7819: <p>To port pkgsrc to a new operating system (called
7820: <code class="literal">MyOS</code> in this example), you need to touch the
7821: following files:</p>
7822: <div class="variablelist"><dl>
1.76 ! rillig 7823: <dt><span class="term"><code class="filename">bootstrap/mods/mk/<em class="replaceable"><code>MyOS</code></em>.sys.mk</code></span></dt>
1.75 rillig 7824: <dd><p>This file contains some basic definitions, for
7825: example the name of the C
7826: compiler.</p></dd>
1.76 ! rillig 7827: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
1.75 rillig 7828: <dd><p>Insert code that defines the variables
7829: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
7830: <code class="varname">LOWER_OS_VERSION</code>,
7831: <code class="varname">LOWER_VENDOR</code>,
7832: <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
7833: <code class="varname">APPEND_ELF</code>, and the other variables that
7834: appear in this file.</p></dd>
1.76 ! rillig 7835: <dt><span class="term"><code class="filename">mk/platform/MyOS.mk</code></span></dt>
1.75 rillig 7836: <dd><p>This file contains the platform-specific
7837: definitions that are used by pkgsrc. Start by copying one of the
7838: other files and edit it to your
7839: needs.</p></dd>
1.76 ! rillig 7840: <dt><span class="term"><code class="filename">mk/platform/MyOS.pkg.dist</code></span></dt>
1.75 rillig 7841: <dd><p>This file contains a list of directories,
7842: together with their permission bits and ownership. These
7843: directories will be created automatically with every package
7844: that does not explicitly set <code class="varname">NO_MTREE</code>. There
7845: have been some discussions about whether this file is needed at
7846: all, but with no result.</p></dd>
1.76 ! rillig 7847: <dt><span class="term"><code class="filename">mk/platform/MyOS.x11.dist</code></span></dt>
1.75 rillig 7848: <dd><p>Just copy one of the pre-existing x11.dist files
7849: to your
1.76 ! rillig 7850: <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
! 7851: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
1.75 rillig 7852: <dd><p>On some operating systems, the tools that are
7853: provided with the base system are not good enough for pkgsrc.
7854: For example, there are many versions of <a href="http://netbsd.gw.com/cgi-bin/man-cgi?sed+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">sed</span>(1)</span></a> that have a
7855: narrow limit on the line length they can process. Therefore
7856: pkgsrc brings its own tools, which can be enabled
7857: here.</p></dd>
1.76 ! rillig 7858: <dt><span class="term"><code class="filename">mk/tools/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
1.75 rillig 7859: <dd><p>This file defines the paths to all the tools
7860: that are needed by one or the other package in pkgsrc, as well
7861: as by pkgsrc itself. Find out where these tools are on your
7862: platform and add them.</p></dd>
7863: </dl></div>
7864: <p>Now, you should be able to build some basic packages, like
1.76 ! rillig 7865: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/lang/perl5/README.html" target="_top"><code class="filename">lang/perl5</code></a>, <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/shells/bash/README.html" target="_top"><code class="filename">shells/bash</code></a>.</p>
1.75 rillig 7866: </div>
7867: <div class="sect1" lang="en">
7868: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7869: <a name="porting.compiler"></a>22.2. Adding support for a new compiler</h2></div></div></div>
7870: <p>TODO</p>
7871: </div>
7872: </div>
7873: </div>
7874: <div class="appendix" lang="en">
7875: <div class="titlepage"><div><div><h2 class="title">
7876: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
7877: <div class="toc">
7878: <p><b>Table of Contents</b></p>
7879: <dl>
7880: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
7881: <dd><dl>
7882: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
7883: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
7884: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
7885: <dt><span class="sect2"><a href="#checking-package-with-pkglint">A.1.4. Checking a package with <span><strong class="command">pkglint</strong></span></a></span></dt>
7886: </dl></dd>
7887: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
7888: </dl>
7889: </div>
7890: <p>We checked to find a piece of software that wasn't in the packages
7891: collection, and picked GNU bison. Quite why someone would want to have
7892: <span><strong class="command">bison</strong></span> when Berkeley <span><strong class="command">yacc</strong></span> is already
7893: present in the tree is beyond us, but it's useful for the purposes of
7894: this exercise.</p>
7895: <div class="sect1" lang="en">
7896: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7897: <a name="example-files"></a>A.1. files</h2></div></div></div>
7898: <div class="sect2" lang="en">
7899: <div class="titlepage"><div><div><h3 class="title">
7900: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
7901: <pre class="programlisting">
1.51 rillig 7902: # $NetBSD$
7903: #
1.1 grant 7904:
1.51 rillig 7905: DISTNAME= bison-1.25
7906: CATEGORIES= devel
7907: MASTER_SITES= ${MASTER_SITE_GNU}
1.1 grant 7908:
1.51 rillig 7909: MAINTAINER= thorpej@NetBSD.org
7910: HOMEPAGE= http://www.gnu.org/software/bison/bison.html
7911: COMMENT= GNU yacc clone
1.1 grant 7912:
1.51 rillig 7913: GNU_CONFIGURE= yes
7914: INFO_FILES= bison.info
1.1 grant 7915:
1.51 rillig 7916: .include "../../mk/bsd.pkg.mk"
1.1 grant 7917: </pre>
1.75 rillig 7918: </div>
7919: <div class="sect2" lang="en">
7920: <div class="titlepage"><div><div><h3 class="title">
7921: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
7922: <pre class="programlisting">
1.51 rillig 7923: GNU version of yacc. Can make re-entrant parsers, and numerous other
1.75 rillig 7924: improvements. Why you would want this when Berkeley <a href="http://netbsd.gw.com/cgi-bin/man-cgi?yacc+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">yacc</span>(1)</span></a> is part
1.51 rillig 7925: of the NetBSD source tree is beyond me.
1.1 grant 7926: </pre>
1.75 rillig 7927: </div>
7928: <div class="sect2" lang="en">
7929: <div class="titlepage"><div><div><h3 class="title">
7930: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
7931: <pre class="programlisting">
1.51 rillig 7932: @comment $NetBSD$
7933: bin/bison
7934: man/man1/bison.1.gz
7935: share/bison.simple
7936: share/bison.hairy
1.1 grant 7937: </pre>
1.75 rillig 7938: </div>
7939: <div class="sect2" lang="en">
7940: <div class="titlepage"><div><div><h3 class="title">
7941: <a name="checking-package-with-pkglint"></a>A.1.4. Checking a package with <span><strong class="command">pkglint</strong></span></h3></div></div></div>
7942: <p>The NetBSD package system comes with
1.76 ! rillig 7943: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>
1.75 rillig 7944: which helps to check the contents of these
7945: files. After installation it is quite easy to use, just change to the
7946: directory of the package you wish to examine and execute
7947: <span><strong class="command">pkglint</strong></span>:</p>
7948: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
7949: looks fine.</pre>
7950: <p>Depending on the supplied command line arguments (see pkglint(1)),
7951: more checks will be performed. Use e.g. <span><strong class="command">pkglint -Call
7952: -Wall</strong></span> for a very thorough check.</p>
7953: </div>
7954: </div>
7955: <div class="sect1" lang="en">
7956: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7957: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
7958: <p>Create the directory where the package lives,
7959: plus any auxiliary directories:</p>
7960: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
7961: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
7962: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
7963: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
1.76 ! rillig 7964: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
! 7965: <code class="filename">PLIST</code> (see <a href="#components" title="Chapter 8. Package components - files, directories and contents">Chapter 8, <i>Package components - files, directories and contents</i></a>)
1.75 rillig 7966: then continue with fetching the distfile:</p>
7967: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
1.1 grant 7968: >> bison-1.25.tar.gz doesn't seem to exist on this system.
7969: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
7970: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
7971: ftp: Error retrieving file: 500 Internal error
7972:
7973: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
7974: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
7975: ftp: Error retrieving file: 500 Internal error
7976:
7977: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
7978: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
1.75 rillig 7979: Successfully retrieved file.</pre>
7980: <p>Generate the checksum of the distfile into
1.76 ! rillig 7981: <code class="filename">distinfo</code>:</p>
1.75 rillig 7982: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makesum</code></strong></pre>
7983: <p>Now compile:</p>
7984: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 7985: >> Checksum OK for bison-1.25.tar.gz.
7986: ===> Extracting for bison-1.25
7987: ===> Patching for bison-1.25
7988: ===> Ignoring empty patch directory
7989: ===> Configuring for bison-1.25
7990: creating cache ./config.cache
7991: checking for gcc... cc
7992: checking whether we are using GNU C... yes
7993: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
7994: checking how to run the C preprocessor... cc -E
7995: checking for minix/config.h... no
7996: checking for POSIXized ISC... no
7997: checking whether cross-compiling... no
7998: checking for ANSI C header files... yes
7999: checking for string.h... yes
8000: checking for stdlib.h... yes
8001: checking for memory.h... yes
8002: checking for working const... yes
8003: checking for working alloca.h... no
8004: checking for alloca... yes
8005: checking for strerror... yes
8006: updating cache ./config.cache
8007: creating ./config.status
8008: creating Makefile
8009: ===> Building for bison-1.25
8010: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g LR0.c
8011: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g allocate.c
8012: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g closure.c
8013: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g conflicts.c
8014: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g derives.c
1.68 rillig 8015: cc -c -DXPFILE=\"/usr/pkg/share/bison.simple\" -DXPFILE1=\"/usr/pkg/share/bison.hairy\" -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -g ./files.c
1.1 grant 8016: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g getargs.c
8017: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g gram.c
8018: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g lalr.c
8019: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g lex.c
8020: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g main.c
8021: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g nullable.c
8022: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g output.c
8023: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g print.c
8024: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g reader.c
8025: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g reduce.c
8026: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g symtab.c
8027: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g warshall.c
8028: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g version.c
8029: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g getopt.c
8030: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g getopt1.c
8031: cc -g -o bison LR0.o allocate.o closure.o conflicts.o derives.o files.o getargs.o gram.o lalr.o lex.o main.o nullable.o output.o print.o reader.o reduce.o symtab.o warshall.o version.o getopt.o getopt1.o
8032: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
8033: rm -f bison.s1
1.75 rillig 8034: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1</pre>
8035: <p>Everything seems OK, so install the files:</p>
8036: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 8037: >> Checksum OK for bison-1.25.tar.gz.
8038: ===> Installing for bison-1.25
8039: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
8040: rm -f /usr/pkg/bin/bison
8041: cd /usr/pkg/share; rm -f bison.simple bison.hairy
8042: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
8043: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
8044: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
8045: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
8046: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
8047: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
1.75 rillig 8048: ===> Registering installation for bison-1.25</pre>
8049: <p>You can now use bison, and also - if you decide so - remove it with
8050: <span><strong class="command">pkg_delete bison</strong></span>. Should you decide that you want a
8051: binary package, do this now:</p>
8052: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 8053: >> Checksum OK for bison-1.25.tar.gz.
8054: ===> Building package for bison-1.25
8055: Creating package bison-1.25.tgz
8056: Registering depends:.
1.75 rillig 8057: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
8058: <p>Now that you don't need the source and object files
8059: any more, clean up:</p>
8060: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
8061: ===> Cleaning for bison-1.25</pre>
8062: </div>
8063: </div>
8064: <div class="appendix" lang="en">
8065: <div class="titlepage"><div><div><h2 class="title">
8066: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
8067: <div class="toc">
8068: <p><b>Table of Contents</b></p>
8069: <dl>
8070: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
8071: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
8072: </dl>
8073: </div>
8074: <div class="sect1" lang="en">
8075: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8076: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
8077: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 8078: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8079: => figlet221.tar.gz doesn't seem to exist on this system.
8080: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
8081: => [172219 bytes]
8082: Connected to ftp.plig.net.
8083: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
8084: 331 Guest login ok, send your complete e-mail address as password.
8085: 230-You are user #5 of 500 simultaneous users allowed.
8086: 230-
1.68 rillig 8087: 230- ___ _ _ _
8088: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
1.1 grant 8089: 230- | _| _| . |_| . | | | . |_| . | _| . |
8090: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
8091: 230- |_| |_| |___| |___|
8092: 230-
8093: 230-** Welcome to ftp.plig.org **
8094: 230-
8095: 230-Please note that all transfers from this FTP site are logged. If you
8096: 230-do not like this, please disconnect now.
8097: 230-
8098: 230-This arhive is available via
8099: 230-
8100: 230-HTTP: http://ftp.plig.org/
8101: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
8102: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
8103: 230-
8104: 230-Please email comments, bug reports and requests for packages to be
1.68 rillig 8105: 230-mirrored to ftp-admin@plig.org.
1.1 grant 8106: 230-
8107: 230-
8108: 230 Logged in anonymously.
8109: Remote system type is UNIX.
8110: Using binary mode to transfer files.
8111: 200 Type okay.
8112: 250 "/pub" is new cwd.
8113: 250-"/pub/figlet" is new cwd.
8114: 250-
8115: 250-Welcome to the figlet archive at ftp.figlet.org
1.68 rillig 8116: 250-
1.75 rillig 8117: 250- ftp://ftp.figlet.org/pub/figlet/
1.1 grant 8118: 250-
8119: 250-The official FIGlet web page is:
1.75 rillig 8120: 250- http://www.figlet.org/
1.1 grant 8121: 250-
8122: 250-If you have questions, please mailto:info@figlet.org. If you want to
8123: 250-contribute a font or something else, you can email us.
1.68 rillig 8124: 250
1.1 grant 8125: 250 "/pub/figlet/program" is new cwd.
8126: 250 "/pub/figlet/program/unix" is new cwd.
8127: local: figlet221.tar.gz remote: figlet221.tar.gz
8128: 502 Unimplemented command.
8129: 227 Entering Passive Mode (195,40,6,41,246,104)
8130: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
8131: 38% |************** | 65800 64.16 KB/s 00:01 ETA
8132: 226 Transfer completed.
8133: 172219 bytes received in 00:02 (75.99 KB/s)
8134: 221 Goodbye.
8135: => Checksum OK for figlet221.tar.gz.
8136: ===> Extracting for figlet-2.2.1nb2
8137: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
8138: ===> Patching for figlet-2.2.1nb2
8139: ===> Applying pkgsrc patches for figlet-2.2.1nb2
8140: ===> Overriding tools for figlet-2.2.1nb2
8141: ===> Creating toolchain wrappers for figlet-2.2.1nb2
8142: ===> Configuring for figlet-2.2.1nb2
8143: ===> Building for figlet-2.2.1nb2
8144: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
8145: chmod a+x figlet
8146: gcc -O2 -o chkfont chkfont.c
8147: => Unwrapping files-to-be-installed.
1.14 xtraeme 8148: <code class="prompt">#</code>
1.75 rillig 8149: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 8150: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8151: ===> Installing for figlet-2.2.1nb2
8152: install -d -o root -g wheel -m 755 /usr/pkg/bin
8153: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
8154: mkdir -p /usr/pkg/share/figlet
8155: cp figlet /usr/pkg/bin
8156: cp chkfont /usr/pkg/bin
8157: chmod 555 figlist showfigfonts
8158: cp figlist /usr/pkg/bin
8159: cp showfigfonts /usr/pkg/bin
8160: cp fonts/*.flf /usr/pkg/share/figlet
8161: cp fonts/*.flc /usr/pkg/share/figlet
8162: cp figlet.6 /usr/pkg/man/man6
8163: ===> Registering installation for figlet-2.2.1nb2
1.75 rillig 8164: <code class="prompt">#</code></pre>
8165: </div>
8166: <div class="sect1" lang="en">
8167: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8168: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
8169: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 8170: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8171: ===> Packaging figlet-2.2.1nb2
8172: ===> Building binary package for figlet-2.2.1nb2
8173: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
8174: Using SrcDir value of /usr/pkg
1.68 rillig 8175: Registering depends:.
1.75 rillig 8176: <code class="prompt">#</code></pre>
8177: </div>
8178: </div>
8179: <div class="appendix" lang="en">
8180: <div class="titlepage"><div><div><h2 class="title">
1.76 ! rillig 8181: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
! 8182: <div class="toc">
! 8183: <p><b>Table of Contents</b></p>
! 8184: <dl>
! 8185: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
! 8186: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
! 8187: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
! 8188: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
! 8189: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
! 8190: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
! 8191: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
! 8192: source packages</a></span></dt>
! 8193: </dl>
! 8194: </div>
! 8195: <p>As in other big projects, the directory layout of pkgsrc
! 8196: is quite complex for newbies. This chapter explains where you
! 8197: find things on the FTP server. The base directory on
! 8198: <code class="filename">ftp.NetBSD.org</code> is <a href="ftp://ftp.NetBSD.org/pub/pkgsrc" target="_top"><code class="filename">/pub/pkgsrc</code></a>.
! 8199: This directory contains some subdirectories, which are explained
! 8200: below.</p>
! 8201: <div class="sect1" lang="en">
! 8202: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 8203: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
! 8204: <p>For those who only want to manage binary packages on
! 8205: systems other than NetBSD, we provide the package management
! 8206: tools in a separate, small tar file.</p>
! 8207: </div>
! 8208: <div class="sect1" lang="en">
! 8209: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 8210: <a name="ftp-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
! 8211: <p>The directory <code class="filename">distfiles</code> contains lots
! 8212: of archive files from all pkgsrc packages, which are mirrored
! 8213: here. The subdirectories are called after their package names
! 8214: and are used when the distributed files have names that don't
! 8215: explicitly contain a version number or are otherwise too generic
! 8216: (for example <code class="filename">release.tar.gz</code>).</p>
! 8217: </div>
! 8218: <div class="sect1" lang="en">
! 8219: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 8220: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
! 8221: <p>This directory is currently not in use.</p>
! 8222: </div>
! 8223: <div class="sect1" lang="en">
! 8224: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 8225: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
! 8226: <p>This directory contains things that individual pkgsrc
! 8227: developers find worth publishing.</p>
! 8228: </div>
! 8229: <div class="sect1" lang="en">
! 8230: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 8231: <a name="ftp-packages"></a>C.5. <code class="filename">packages*</code>: Binary packages</h2></div></div></div>
! 8232: <p>These directories contain binary packages. Those
! 8233: directories that have a branch name
! 8234: (200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>)
! 8235: contain packages from that particular branch. The directory
! 8236: <code class="filename">packages</code> contains binary packages from
! 8237: pkgsrc-current. (However, this does not necessarily mean that
! 8238: the packages are still current anymore.)</p>
! 8239: <p>Below the <code class="filename">packages*</code> directories are
! 8240: directories that distinguish the packages by operating system
! 8241: and version, the next directory level specifies the hardware
! 8242: architecture.</p>
! 8243: <p>In each of the platform-specific directories, there is a
! 8244: whole binary packages collection. It has a directory called
! 8245: <code class="filename">All</code> which contains all binary packages.
! 8246: Besides that, there are various category directories that
! 8247: contain symbolic links to the real binary packages.</p>
! 8248: </div>
! 8249: <div class="sect1" lang="en">
! 8250: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 8251: <a name="ftp-source"></a>C.6. <code class="filename">current</code>,
! 8252: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
! 8253: source packages</h2></div></div></div>
! 8254: <p>These directories contain the “<span class="quote">real</span>” pkgsrc,
! 8255: that is the files that define how to create binary packages from
! 8256: source archives.</p>
! 8257: <p>The directory <code class="filename">pkgsrc</code> contains a
! 8258: snapshot of the CVS repository, which is updated on a regularly
! 8259: basis. The file <code class="filename">pkgsrc.tar.gz</code> contains the
! 8260: same as the directory, ready to be downloaded as a whole.</p>
! 8261: <p>In the directories for the quarterly branches, there is an
! 8262: additional file called
! 8263: <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
! 8264: which contains the state of pkgsrc when it was branched.</p>
! 8265: </div>
1.75 rillig 8266: </div>
8267: <div class="appendix" lang="en">
8268: <div class="titlepage"><div><div><h2 class="title">
8269: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
8270: <div class="toc">
8271: <p><b>Table of Contents</b></p>
8272: <dl>
8273: <dt><span class="sect1"><a href="#targets">D.1. Targets</a></span></dt>
8274: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
8275: </dl>
8276: </div>
8277: <p>
8278: This section contains information on editing the pkgsrc guide
8279: itself.
8280: </p>
8281: <div class="sect1" lang="en">
8282: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8283: <a name="targets"></a>D.1. Targets</h2></div></div></div>
8284: <p>
8285: The pkgsrc guide's source code is stored in
1.76 ! rillig 8286: <code class="filename">pkgsrc/doc/guide/files</code>, and several files are
1.75 rillig 8287: created from it:
8288: </p>
8289: <div class="itemizedlist"><ul type="disc">
8290: <li><p>
1.76 ! rillig 8291: <code class="filename">pkgsrc/doc/pkgsrc.txt</code>
1.75 rillig 8292: </p></li>
8293: <li><p>
1.76 ! rillig 8294: <code class="filename">pkgsrc/doc/pkgsrc.html</code>
1.75 rillig 8295: </p></li>
8296: <li><p>
1.76 ! rillig 8297: <code class="filename">http://www.NetBSD.org/Documentation/pkgsrc/</code>:
1.75 rillig 8298: the documentation on the NetBSD website will be built from
8299: pkgsrc and kept up to date on the web server itself. This
8300: means you <span class="emphasis"><em>must</em></span> make sure that your
8301: changes haven't broken the build!
8302: </p></li>
8303: <li><p>
1.76 ! rillig 8304: <code class="filename">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</code>:
1.75 rillig 8305: PDF version of the pkgsrc guide.
8306: </p></li>
8307: <li><p>
1.76 ! rillig 8308: <code class="filename">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</code>:
1.75 rillig 8309: PostScript version of the pkgsrc guide.
8310: </p></li>
8311: </ul></div>
8312: </div>
8313: <div class="sect1" lang="en">
8314: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8315: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
8316: <p>
8317: The procedure to edit the pkgsrc guide is:
8318: </p>
8319: <div class="itemizedlist"><ul type="disc">
8320: <li><p>
8321: Make sure you have the packages needed to re-generate the
8322: pkgsrc guide (and other XML-based NetBSD documentation)
8323: installed. These are “<span class="quote">netbsd-doc</span>” for creating the
8324: ASCII and HTML versions, and
8325: “<span class="quote">netbsd-doc-print</span>” for the PostScript and PDF
8326: versions. You will need both packages installed, to make sure
8327: documentation is consistent across all formats. The packages
8328: can be found in
1.76 ! rillig 8329: <code class="filename">pkgsrc/meta-pkgs/netbsd-doc</code> and
! 8330: <code class="filename">pkgsrc/meta-pkgs/netbsd-doc-print</code>.
1.75 rillig 8331: </p></li>
8332: <li><p>
8333: Edit the XML file(s) in
1.76 ! rillig 8334: <code class="filename">pkgsrc/doc/guide/files</code>.
1.75 rillig 8335: </p></li>
8336: <li><p>
8337: Run <span><strong class="command">make extract && make do-lint</strong></span> in
1.76 ! rillig 8338: <code class="filename">pkgsrc/doc/guide</code> to check the XML
1.75 rillig 8339: syntax, and fix it if needed.
8340: </p></li>
8341: <li><p>
8342: Run <span><strong class="command">make</strong></span> in
1.76 ! rillig 8343: <code class="filename">pkgsrc/doc/guide</code> to build the HTML and
1.75 rillig 8344: ASCII version.
8345: </p></li>
8346: <li><p>
8347: If all is well, run <span><strong class="command">make install-doc</strong></span> to put
1.76 ! rillig 8348: the generated files into <code class="filename">pkgsrc/doc</code>.
1.75 rillig 8349: </p></li>
8350: <li><p>
8351: <span><strong class="command">cvs commit pkgsrc/doc/guide/files</strong></span>
8352: </p></li>
8353: <li><p>
8354: <span><strong class="command">cvs commit -m re-generate pkgsrc/doc/pkgsrc.{html,txt}</strong></span>
8355: </p></li>
8356: <li><p>
8357: Until the webserver on www.NetBSD.org is really updated
8358: automatically to pick up changes to the pkgsrc guide
8359: automatically, also run <span><strong class="command">make install-htdocs
8360: HTDOCSDIR=../../../htdocs</strong></span> (or similar, adjust
8361: <code class="varname">HTDOCSDIR</code>!).
8362: </p></li>
8363: <li><p>
8364: <span><strong class="command">cvs commit htdocs/Documentation/pkgsrc</strong></span>
8365: </p></li>
8366: </ul></div>
8367: </div>
8368: </div>
8369: </div></body>
1.1 grant 8370: </html>
CVSweb <webmaster@jp.NetBSD.org>