Annotation of pkgsrc/doc/pkgsrc.html, revision 1.80
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.80 ! rillig 38: <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.21 2006/07/03 23:51:01 rillig Exp $</p></div>
1.76 rillig 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>
1.78 rillig 58: <dd><dl>
59: <dt><span class="sect2"><a href="#term.abbrev">1.3.1. Commonly used abbreviations</a></span></dt>
60: <dt><span class="sect2"><a href="#term.people">1.3.2. People involved in pkgsrc</a></span></dt>
61: </dl></dd>
1.75 rillig 62: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
63: </dl></dd>
64: <dt><span class="part"><a href="#users-guide">I. The pkgsrc user's guide</a></span></dt>
65: <dd><dl>
66: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
67: <dd><dl>
68: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
69: <dd><dl>
70: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
71: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
72: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
73: </dl></dd>
74: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
75: <dd><dl>
76: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
77: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
78: </dl></dd>
79: </dl></dd>
80: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
81: <dd><dl>
82: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
83: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
84: <dd><dl>
85: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
86: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
87: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
88: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
89: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
90: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
91: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
92: </dl></dd>
93: </dl></dd>
94: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
95: <dd><dl>
96: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
97: <dd><dl>
98: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
99: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
100: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
101: </dl></dd>
102: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
103: <dd><dl>
104: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
105: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
106: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
107: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
108: </dl></dd>
109: </dl></dd>
110: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
111: <dd><dl>
112: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
113: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 114: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
115: <dd><dl><dt><span class="sect2"><a href="#conf.cflags">5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt></dl></dd>
116: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
117: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 118: </dl></dd>
119: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
120: <dd><dl>
121: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
122: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
123: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
124: <dd><dl>
125: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
126: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
127: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
128: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
129: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
130: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
131: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
132: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
133: </dl></dd>
134: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
135: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
136: </dl></dd>
137: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
138: <dd><dl>
139: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
140: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
141: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
142: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
143: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
144: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
145: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
146: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
147: <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>
148: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
149: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
150: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
151: <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>
152: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
153: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
154: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
155: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
1.80 ! rillig 156: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.75 rillig 157: </dl></dd>
158: </dl></dd>
159: <dt><span class="part"><a href="#developers-guide">II. The pkgsrc developer's guide</a></span></dt>
160: <dd><dl>
1.77 rillig 161: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
162: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75 rillig 163: <dd><dl>
1.77 rillig 164: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
165: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
166: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
167: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
168: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 169: <dd><dl>
170: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
171: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
172: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
173: </dl></dd>
1.77 rillig 174: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
175: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
176: </dl></dd>
177: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
178: <dd><dl>
179: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
180: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
181: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
182: <dd><dl>
183: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
184: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
185: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
186: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
187: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
188: </dl></dd>
189: </dl></dd>
190: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
191: <dd><dl>
192: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
193: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
194: <dt><span class="sect1"><a href="#print-PLIST">11.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
195: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
196: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
197: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
198: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
199: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
200: </dl></dd>
201: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
202: <dd><dl>
203: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
204: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
205: <dd><dl>
206: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
207: <dt><span class="sect2"><a href="#updating-buildlink-depends">12.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>
208: </dl></dd>
209: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
210: <dd><dl>
211: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">12.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
212: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
213: </dl></dd>
214: </dl></dd>
215: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
216: <dd><dl>
217: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
218: <dd><dl>
219: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
220: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
221: </dl></dd>
222: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
223: <dd><dl>
224: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
225: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
226: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
227: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
228: </dl></dd>
229: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
230: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">13.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
231: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
232: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
233: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
234: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
235: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">13.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
236: </dl></dd>
237: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
238: <dd><dl>
239: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
240: <dt><span class="sect1"><a href="#converting-to-options">14.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
241: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
242: </dl></dd>
243: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
244: <dd><dl>
245: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
246: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
247: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
248: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
249: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
250: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
251: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
252: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
253: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
254: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
255: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
256: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
257: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
258: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
259: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
260: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
261: </dl></dd>
262: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
263: <dd><dl>
264: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
265: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
266: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
267: </dl></dd>
268: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
269: <dd><dl>
270: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
271: <dd><dl>
1.78 rillig 272: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
273: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">17.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
274: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
275: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
276: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
277: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
278: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
279: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
280: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
281: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
282: <dt><span class="sect2"><a href="#bumping-pkgrevision">17.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
1.79 rillig 283: <dt><span class="sect2"><a href="#fixes.subst">17.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
1.77 rillig 284: </dl></dd>
285: <dt><span class="sect1"><a href="#fixes.fetch">17.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
286: <dd><dl>
287: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
288: <dt><span class="sect2"><a href="#modified-distfiles-same-name">17.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
289: </dl></dd>
290: <dt><span class="sect1"><a href="#fixes.configure">17.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
291: <dd><dl>
292: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
293: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
294: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
295: </dl></dd>
296: <dt><span class="sect1"><a href="#fixes.build">17.4. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
297: <dd><dl>
1.78 rillig 298: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
299: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
300: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
301: </dl></dd>
302: <dt><span class="sect1"><a href="#fixes.install">17.5. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
303: <dd><dl>
304: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
305: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
306: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
307: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
308: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
309: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
310: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
311: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
312: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
313: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
314: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
315: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
316: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
317: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
318: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
319: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
320: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.77 rillig 321: </dl></dd>
1.78 rillig 322: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.77 rillig 323: </dl></dd>
324: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
325: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
326: <dd><dl>
327: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
328: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
329: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
330: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
331: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
332: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 333: </dl></dd>
1.77 rillig 334: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.75 rillig 335: </dl></dd>
336: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
337: <dd><dl>
1.77 rillig 338: <dt><span class="chapter"><a href="#infr.design">21. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 339: <dd><dl>
1.77 rillig 340: <dt><span class="sect1"><a href="#infr.var">21.1. Variable evaluation</a></span></dt>
1.75 rillig 341: <dd><dl>
1.77 rillig 342: <dt><span class="sect2"><a href="#infr.var.load">21.1.1. At load time</a></span></dt>
343: <dt><span class="sect2"><a href="#infr.var.run">21.1.2. At runtime</a></span></dt>
1.75 rillig 344: </dl></dd>
1.78 rillig 345: <dt><span class="sect1"><a href="#infr.varspec">21.2. How can variables be specified?</a></span></dt>
346: <dt><span class="sect1"><a href="#infr.design.intf">21.3. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 347: <dd><dl>
1.78 rillig 348: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.3.1. Procedures with parameters</a></span></dt>
349: <dt><span class="sect2"><a href="#infr.design.intf.action">21.3.2. Actions taken on behalf of parameters</a></span></dt>
1.75 rillig 350: </dl></dd>
351: </dl></dd>
1.77 rillig 352: <dt><span class="chapter"><a href="#regression">22. Regression tests</a></span></dt>
1.75 rillig 353: <dd><dl>
1.77 rillig 354: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
355: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
356: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 357: <dd><dl>
1.77 rillig 358: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
359: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 360: </dl></dd>
361: </dl></dd>
1.80 ! rillig 362: <dt><span class="chapter"><a href="#porting">23. Porting pkgsrc</a></span></dt>
1.75 rillig 363: <dd><dl>
1.80 ! rillig 364: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
! 365: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 366: </dl></dd>
367: </dl></dd>
368: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
369: <dd><dl>
370: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
371: <dd><dl>
372: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
373: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
374: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
375: <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>
376: </dl></dd>
377: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
378: </dl></dd>
379: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
380: <dd><dl>
381: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
382: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
383: </dl></dd>
1.76 rillig 384: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
385: <dd><dl>
386: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
387: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
388: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
389: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
390: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
391: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
392: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
393: source packages</a></span></dt>
394: </dl></dd>
1.75 rillig 395: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
396: <dd><dl>
1.79 rillig 397: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75 rillig 398: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
399: </dl></dd>
400: </dl>
401: </div>
402: <div class="chapter" lang="en">
403: <div class="titlepage"><div><div><h2 class="title">
404: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
405: <div class="toc">
406: <p><b>Table of Contents</b></p>
407: <dl>
408: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
409: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
410: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.78 rillig 411: <dd><dl>
412: <dt><span class="sect2"><a href="#term.abbrev">1.3.1. Commonly used abbreviations</a></span></dt>
413: <dt><span class="sect2"><a href="#term.people">1.3.2. People involved in pkgsrc</a></span></dt>
414: </dl></dd>
1.75 rillig 415: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
416: </dl>
417: </div>
418: <div class="sect1" lang="en">
419: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
420: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
421: <p> There is a lot of software freely available for Unix-based
422: systems, which usually runs on NetBSD and other Unix-flavoured
423: systems, too, sometimes with some modifications. The NetBSD
424: Packages Collection (pkgsrc) incorporates any such changes
425: necessary to make that software run, and makes the installation
426: (and de-installation) of the software package easy by means of a
427: single command. </p>
428: <p>Once the software
429: has been built, it is manipulated with the <span><strong class="command">pkg_*</strong></span> tools
430: so that installation
431: and de-installation, printing of an inventory of all installed packages and
432: retrieval of one-line comments or more verbose descriptions are all
433: simple.</p>
434: <p>pkgsrc currently contains several thousand packages,
435: including:</p>
436: <div class="itemizedlist"><ul type="disc">
1.76 rillig 437: <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 438: web server</p></li>
1.76 rillig 439: <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 440: web browser</p></li>
1.76 rillig 441: <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 442: Desktop Environment</p></li>
1.76 rillig 443: <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 444: Desktop Environment</p></li>
445: </ul></div>
446: <p>...just to name a few.</p>
447: <p>pkgsrc has built-in support for handling varying dependencies,
448: such as pthreads and X11, and extended features such as IPv6 support on
449: a range of platforms.</p>
450: <p>pkgsrc was derived from FreeBSD's ports system, and
451: initially developed for NetBSD only. Since then, pkgsrc has
452: grown a lot, and now supports the following platforms:</p>
453: <div class="itemizedlist"><ul type="disc">
454: <li><p><a href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
455: (<a href="http://www.apple.com/macosx/" target="_top">Mac OS X</a>)</p></li>
456: <li><p><a href="http://www.DragonFlyBSD.org/" target="_top">DragonFly BSD</a></p></li>
457: <li><p><a href="http://www.FreeBSD.org/" target="_top">FreeBSD</a></p></li>
458: <li><p>Microsoft Windows, via <a href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a></p></li>
459: <li><p><a href="http://www.sgi.com/software/irix6.5/" target="_top">IRIX</a></p></li>
460: <li><p><a href="http://www.linux.org/" target="_top">Linux</a></p></li>
461: <li><p><a href="http://www.NetBSD.org/" target="_top">NetBSD</a> (of
462: course)</p></li>
463: <li><p><a href="http://h30097.www3.hp.com/" target="_top">Tru64</a>
464: (Digital UNIX, OSF1)</p></li>
465: <li><p><a href="http://www.openbsd.org/" target="_top">OpenBSD</a></p></li>
466: <li><p><a href="http://www.sun.com/solaris/" target="_top">Solaris</a></p></li>
467: </ul></div>
468: </div>
469: <div class="sect1" lang="en">
470: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
471: <a name="overview"></a>1.2. Overview</h2></div></div></div>
472: <p>This document is divided into three parts. The first,
473: <a href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
474: describes how one can use one of the packages in the Package
475: Collection, either by installing a precompiled binary package,
476: or by building one's own copy using the NetBSD package system.
477: 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
478: package so it can be easily built by other NetBSD users without
479: knowing about the package's building details. The third part,
480: <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
481: is intended for those who want to understand how pkgsrc is
482: implemented.</p>
483: <p>This document is available in various formats:
484: <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>
485: </div>
486: <div class="sect1" lang="en">
487: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
488: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
489: <p>There has been a lot of talk about “<span class="quote">ports</span>”,
490: “<span class="quote">packages</span>”, etc. so far. Here is a description of all the
491: terminology used within this document.</p>
492: <div class="variablelist"><dl>
493: <dt><span class="term">Package</span></dt>
494: <dd><p>A set of files and building instructions
495: that describe what's necessary
496: to build a certain piece of software using
497: pkgsrc. Packages are traditionally stored under
1.76 rillig 498: <code class="filename">/usr/pkgsrc</code>.</p></dd>
1.75 rillig 499: <dt><span class="term">The NetBSD package system</span></dt>
500: <dd><p>
501: This is the former name of “<span class="quote">pkgsrc</span>”. It is
502: part of the NetBSD operating system and can be bootstrapped to
503: run on non-NetBSD operating systems as well. It handles
504: building (compiling), installing, and removing of
505: packages.
506: </p></dd>
507: <dt><span class="term">Distfile</span></dt>
508: <dd><p>This term describes the file or files that are
509: provided by the author of the piece of software to
510: distribute his work. All the changes necessary to build on
511: NetBSD are reflected in the corresponding package. Usually
512: the distfile is in the form of a compressed tar-archive,
513: but other types are possible, too. Distfiles are usually
514: stored below
1.76 rillig 515: <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
1.75 rillig 516: <dt><span class="term">Port</span></dt>
517: <dd><p>This is the term used by FreeBSD and OpenBSD people
518: for what we call a package.
519: In NetBSD terminology, “<span class="quote">port</span>” refers to a different
520: architecture.</p></dd>
521: <dt><span class="term">Precompiled/binary package</span></dt>
522: <dd>
523: <p>A set of binaries built with pkgsrc from a distfile
1.76 rillig 524: and stuffed together in a single <code class="filename">.tgz</code>
1.75 rillig 525: file so it can be installed on machines of the same
526: machine architecture without the need to
527: recompile. Packages are usually generated in
1.76 rillig 528: <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.75 rillig 529: an archive on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
530: <p>Sometimes, this is referred to by the term “<span class="quote">package</span>” too,
531: especially in the context of precompiled packages.</p>
532: </dd>
533: <dt><span class="term">Program</span></dt>
534: <dd><p>The piece of software to be installed which will be constructed from
535: all the files in the distfile by the actions defined in the
536: corresponding package.</p></dd>
537: </dl></div>
538: <div class="sect2" lang="en">
539: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 540: <a name="term.abbrev"></a>1.3.1. Commonly used abbreviations</h3></div></div></div>
541: <div class="variablelist"><dl>
542: <dt><span class="term">ICE</span></dt>
543: <dd><p>Internal Compiler
544: Error</p></dd>
545: </dl></div>
546: </div>
547: <div class="sect2" lang="en">
548: <div class="titlepage"><div><div><h3 class="title">
549: <a name="term.people"></a>1.3.2. People involved in pkgsrc</h3></div></div></div>
1.75 rillig 550: <div class="variablelist"><dl>
551: <dt><span class="term">pkgsrc users</span></dt>
552: <dd>
553: <p>The
554: pkgsrc users are people who use the packages provided by pkgsrc.
555: Typically they are system administrators. The people using the
556: software that is inside the packages (maybe called “<span class="quote">end
557: users</span>”) are not covered by the pkgsrc guide.</p>
558: <p>There are two kinds of pkgsrc users: Some only want to
559: install pre-built binary packages. Others build the pkgsrc
560: packages from source, either for installing them directly or for
561: 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
562: documentation.</p>
563: </dd>
564: <dt><span class="term">package maintainers</span></dt>
565: <dd><p>A
566: 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>
567: <dt><span class="term">infrastructure developers</span></dt>
568: <dd><p>These people are involved in all those files
1.76 rillig 569: that live in the <code class="filename">mk/</code> directory and below.
1.75 rillig 570: 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,
571: too.</p></dd>
572: </dl></div>
573: </div>
574: </div>
575: <div class="sect1" lang="en">
576: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
577: <a name="typography"></a>1.4. Typography</h2></div></div></div>
578: <p>When giving examples for commands, shell prompts are used to
579: show if the command should/can be issued as root, or if
580: “<span class="quote">normal</span>” user privileges are sufficient. We use a
581: <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
582: shell prompt, assuming they use the C-shell or tcsh.</p>
583: </div>
584: </div>
585: <div class="part" lang="en">
586: <div class="titlepage"><div><div><h1 class="title">
587: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
588: <div class="toc">
589: <p><b>Table of Contents</b></p>
590: <dl>
591: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
592: <dd><dl>
593: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
594: <dd><dl>
595: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
596: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
597: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
598: </dl></dd>
599: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
600: <dd><dl>
601: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
602: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
603: </dl></dd>
604: </dl></dd>
605: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
606: <dd><dl>
607: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
608: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
609: <dd><dl>
610: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
611: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
612: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
613: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
614: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
615: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
616: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
617: </dl></dd>
618: </dl></dd>
619: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
620: <dd><dl>
621: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
622: <dd><dl>
623: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
624: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
625: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
626: </dl></dd>
627: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
628: <dd><dl>
629: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
630: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
631: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
632: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
633: </dl></dd>
634: </dl></dd>
635: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
636: <dd><dl>
637: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
638: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 639: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
640: <dd><dl><dt><span class="sect2"><a href="#conf.cflags">5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt></dl></dd>
641: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
642: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 643: </dl></dd>
644: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
645: <dd><dl>
646: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
647: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
648: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
649: <dd><dl>
650: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
651: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
652: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
653: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
654: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
655: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
656: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
657: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
658: </dl></dd>
659: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
660: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
661: </dl></dd>
662: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
663: <dd><dl>
664: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
665: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
666: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
667: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
668: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
669: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
670: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
671: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
672: <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>
673: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
674: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
675: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
676: <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>
677: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
678: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
679: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
680: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
1.80 ! rillig 681: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.75 rillig 682: </dl></dd>
683: </dl>
684: </div>
685: <div class="chapter" lang="en">
686: <div class="titlepage"><div><div><h2 class="title">
687: <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
688: <div class="toc">
689: <p><b>Table of Contents</b></p>
690: <dl>
691: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
692: <dd><dl>
693: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
694: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
695: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
696: </dl></dd>
697: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
698: <dd><dl>
699: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
700: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
701: </dl></dd>
702: </dl>
703: </div>
704: <p>The most common location where pkgsrc is installed is
1.76 rillig 705: <code class="filename">/usr/pkgsrc</code> for the “<span class="quote">package
706: sources</span>” and <code class="filename">/usr/pkg</code> for the
1.75 rillig 707: installed binary packages. You are though free to install the
708: sources and binary packages wherever you want in your
709: filesystem, provided that both paths do not contain white-space
710: or other characters that are interpreted specially by the shell
711: and some other programs. A safe bet is to use only letters,
712: digits, underscores and dashes in the names.</p>
713: <div class="sect1" lang="en">
714: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
715: <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
716: <p>Before you download any pkgsrc files, you should decide
717: whether you want the <span class="emphasis"><em>current</em></span> branch or the
718: <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
719: quarterly basis from the current branch and only gets modified
720: for security updates. The names of the stable branches are built
721: from the year and the quarter, for example
722: <code class="literal">2006Q1</code>.</p>
723: <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
724: want to download pkgsrc. You can get it as a tar file, via SUP,
725: or via CVS. All three ways are described here.</p>
726: <div class="sect2" lang="en">
727: <div class="titlepage"><div><div><h3 class="title">
728: <a name="getting-via-tar"></a>2.1.1. As tar file</h3></div></div></div>
729: <p>The primary download location for all pkgsrc files is
730: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>. There are a
731: number of subdirectories for different purposes, which are
1.76 rillig 732: 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 733: <p>The tar file for the current branch is in the directory
1.76 rillig 734: <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 735: It is autogenerated daily.</p>
736: <p>The tar file for the stable branch 2006Q1 is in the
1.76 rillig 737: 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 738: <p>After downloading the tar file, change to the directory
739: where you want to have pkgsrc. This is usually
1.76 rillig 740: <code class="filename">/usr</code>. Then, run <span><strong class="command">tar xfz
1.75 rillig 741: pkgsrc.tar.gz</strong></span> to extract the files.</p>
742: </div>
743: <div class="sect2" lang="en">
744: <div class="titlepage"><div><div><h3 class="title">
745: <a name="getting-via-sup"></a>2.1.2. Via SUP</h3></div></div></div>
746: <p>As an alternative to the tar file, you can get pkgsrc via
747: the Software Update Protocol, SUP. To do so, make sure your
748: supfile has a line
1.1 grant 749:
1.75 rillig 750: </p>
751: <pre class="programlisting">
1.51 rillig 752: release=pkgsrc
1.1 grant 753: </pre>
1.75 rillig 754: <p>
1.1 grant 755:
1.75 rillig 756: in it, see the examples in
1.76 rillig 757: <code class="filename">/usr/share/examples/supfiles</code>, and that the
758: <code class="filename">/usr/pkgsrc</code> directory exists. Then, simply
1.75 rillig 759: run <span><strong class="command">sup -v
760: <em class="replaceable"><code>/path/to/your/supfile</code></em></strong></span>.</p>
761: </div>
762: <div class="sect2" lang="en">
763: <div class="titlepage"><div><div><h3 class="title">
764: <a name="getting-via-cvs"></a>2.1.3. Via CVS</h3></div></div></div>
765: <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>
766: installed. To do an initial (full) checkout of pkgsrc, you first
767: have to set some environment variables. For the C-Shell,
768: type:</p>
769: <pre class="screen">
770: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
771: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVS_RSH ssh</code></strong>
772: </pre>
773: <p>Or, the same for the bourne shell:</p>
774: <pre class="screen">
775: <code class="prompt">$</code> <strong class="userinput"><code>CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"</code></strong>
776: <code class="prompt">$</code> <strong class="userinput"><code>CVS_RSH="ssh"</code></strong>
777: <code class="prompt">$</code> <strong class="userinput"><code>export CVSROOT CVS_RSH</code></strong>
778: </pre>
779: <p>Then, you change to the directory where you want to have
780: your copy of pkgsrc. In most cases this is
1.76 rillig 781: <code class="filename">/usr</code>. In that directory you run the
1.75 rillig 782: checkout command, which is <span><strong class="command">cvs -q checkout -P
783: pkgsrc</strong></span> for the current branch and <span><strong class="command">cvs -q
784: checkout -rpkgsrc-2006Q1 -P pkgsrc</strong></span> for the stable
785: branch. This command will create a directory called
1.76 rillig 786: <code class="filename">pkgsrc</code> with all the pkgsrc files in
1.75 rillig 787: it.</p>
788: </div>
789: </div>
790: <div class="sect1" lang="en">
791: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
792: <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
793: <p>The preferred way to keep pkgsrc up-to-date is via CVS
794: (which also works if you have first installed it via a tar
795: file). It saves bandwidth and hard disk activity, compared to
796: downloading the tar file again.</p>
797: <div class="sect2" lang="en">
798: <div class="titlepage"><div><div><h3 class="title">
799: <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
800: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
801: <h3 class="title">Warning</h3>
1.77 rillig 802: <p>When updating from a tar file, you first need to
803: completely remove the old pkgsrc directory. Otherwise those
804: files that have been removed from pkgsrc in the mean time will
805: not be removed on your local disk, resulting in inconsistencies.
806: When removing the old files, any changes that you have done to
807: the pkgsrc files will be lost after updating. Therefore updating
808: via CVS is strongly recommended.</p>
1.75 rillig 809: </div>
810: <p>To update pkgsrc from a tar file, download the tar file as
811: explained above. Then, make sure that you have not made any
812: changes to the files in the pkgsrc directory. Remove the pkgsrc
813: directory and extract the new tar file. Done.</p>
814: </div>
815: <div class="sect2" lang="en">
816: <div class="titlepage"><div><div><h3 class="title">
817: <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
818: <p>To update pkgsrc via CVS, make sure the environment
819: variable <code class="varname">CVS_RSH</code> is set as above. Then,
820: change to the pkgsrc directory and run <span><strong class="command">cvs -q update
1.77 rillig 821: -dP</strong></span>.</p>
1.75 rillig 822: <div class="sect3" lang="en">
823: <div class="titlepage"><div><div><h4 class="title">
824: <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
825: <p>When updating pkgsrc, the CVS program keeps track of the
826: branch you selected. But if you, for whatever reason, want to
827: switch from the stable branch to the current one, you can do it
828: by adding the option “<span class="quote">-A</span>” after the
829: “<span class="quote">update</span>” keyword. To switch from the current branch
830: back to the stable branch, add the
831: “<span class="quote">-rpkgsrc-2006Q1</span>” option.</p>
832: </div>
833: <div class="sect3" lang="en">
834: <div class="titlepage"><div><div><h4 class="title">
835: <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
836: <p>When you update pkgsrc, the CVS program will only touch
837: those files that are registered in the CVS repository. That
838: means that any packages that you created on your own will stay
839: unmodified. If you change files that are managed by CVS, later
840: updates will try to merge your changes with those that have been
841: done by others. See the CVS manual, chapter
842: “<span class="quote">update</span>” for details.</p>
843: </div>
844: </div>
845: </div>
846: </div>
847: <div class="chapter" lang="en">
848: <div class="titlepage"><div><div><h2 class="title">
849: <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
850: <div class="toc">
851: <p><b>Table of Contents</b></p>
852: <dl>
853: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
854: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
855: <dd><dl>
856: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
857: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
858: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
859: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
860: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
861: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
862: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
863: </dl></dd>
864: </dl>
865: </div>
866: <div class="sect1" lang="en">
867: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
868: <a name="bootstrapping-pkgsrc"></a>3.1. Bootstrapping pkgsrc</h2></div></div></div>
869: <p>For operating systems other than NetBSD, we provide a bootstrap kit to
870: build the required tools to use pkgsrc on your platform. Besides
871: support for native NetBSD, pkgsrc and the bootstrap kit have support for
872: the following operating systems:</p>
873: <div class="itemizedlist"><ul type="disc">
874: <li><p>Darwin (Mac OS X)</p></li>
875: <li><p>DragonFly BSD</p></li>
876: <li><p>FreeBSD</p></li>
877: <li><p>Interix (Windows 2000, XP, 2003)</p></li>
878: <li><p>IRIX</p></li>
879: <li><p>Linux</p></li>
880: <li><p>OpenBSD</p></li>
881: <li><p>Solaris</p></li>
882: <li><p>Tru64 (Digital UNIX/OSF1)</p></li>
883: </ul></div>
884: <p>Support for other platforms is under development.</p>
885: <p>Installing the bootstrap kit should be as simple as:</p>
886: <pre class="screen">
887: <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
888: <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
889: <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong></pre>
890: <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
891: pkgsrc before bootstrapping. The given
892: <span><strong class="command">bootstrap</strong></span> command will use the defaults of
1.76 rillig 893: <code class="filename">/usr/pkg</code> for the
1.75 rillig 894: <span class="emphasis"><em>prefix</em></span> where programs will be installed in,
1.76 rillig 895: and <code class="filename">/var/db/pkg</code> for the package database
1.75 rillig 896: directory where pkgsrc will do its internal bookkeeping.
897: However, these can also be set using command-line
898: arguments.</p>
899: <p>Binary packages for the pkgsrc tools and an initial set of packages is
900: available for supported platforms. An up-to-date list of these can be
901: found on <a href="http://www.pkgsrc.org/" target="_top">www.pkgsrc.org</a>.
902: Note that this only works for privileged builds that install
1.76 rillig 903: into <code class="filename">/usr/pkg</code>.</p>
1.75 rillig 904: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
905: <h3 class="title">Note</h3>
906: <p>The bootstrap installs a <span><strong class="command">bmake</strong></span> tool.
907: Use this <span><strong class="command">bmake</strong></span> when building via pkgsrc.
908: For examples in this guide, use <span><strong class="command">bmake</strong></span>
909: instead of “<span class="quote">make</span>”.</p>
910: </div>
911: </div>
912: <div class="sect1" lang="en">
913: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
914: <a name="platform-specific-notes"></a>3.2. Platform-specific notes</h2></div></div></div>
915: <p>Here are some platform-specific notes you should be aware of.</p>
916: <div class="sect2" lang="en">
917: <div class="titlepage"><div><div><h3 class="title">
918: <a name="darwin"></a>3.2.1. Darwin (Mac OS X)</h3></div></div></div>
919: <p>Darwin 5.x and 6.x are supported. There are two methods of using
920: pkgsrc on Mac OS X, by using a <a href="#platform.osx-image" title="3.2.1.1. Using a disk image">disk
921: image</a>, or a <a href="#platform.osx-ufs" title="3.2.1.2. Using a UFS partition">UFS
922: partition</a>.</p>
923: <p>Before you start, you will need to download and install the Mac OS X Developer
924: Tools from Apple's Developer Connection. See <a href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
925: for details. Also, make sure you install X11 for Mac OS X and the X11 SDK
926: from <a href="http://www.apple.com/macosx/x11/download/" target="_top">http://www.apple.com/macosx/x11/download/</a>
927: if you intend to build packages that use the X11 Window System.</p>
928: <p>If you already have a UFS partition, or have a spare partition
929: that you can format as UFS, it is recommended to use that instead of
930: the disk image. It'll be somewhat faster and will mount automatically
931: at boot time, where you must manually mount a disk image.</p>
932: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
933: <h3 class="title">Note</h3>
934: <p>You cannot use a HFS+ file system for pkgsrc, because pkgsrc currently
935: requires the file system to be case-sensitive, and HFS+ is not.</p>
936: </div>
937: <div class="sect3" lang="en">
938: <div class="titlepage"><div><div><h4 class="title">
939: <a name="platform.osx-image"></a>3.2.1.1. Using a disk image</h4></div></div></div>
940: <p>Create the disk image:</p>
941: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
942: <code class="prompt">#</code> <strong class="userinput"><code>./ufsdiskimage create ~/Documents/NetBSD 512</code></strong> # megabytes - season to taste
943: <code class="prompt">#</code> <strong class="userinput"><code>./ufsdiskimage mount ~/Documents/NetBSD</code></strong>
944: <code class="prompt">#</code> <strong class="userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong></pre>
945: <p>That's it!</p>
946: </div>
947: <div class="sect3" lang="en">
948: <div class="titlepage"><div><div><h4 class="title">
949: <a name="platform.osx-ufs"></a>3.2.1.2. Using a UFS partition</h4></div></div></div>
1.76 rillig 950: <p>By default, <code class="filename">/usr</code> will be on your root file
1.75 rillig 951: system, normally HFS+. It is possible to use the default
1.76 rillig 952: <span class="emphasis"><em>prefix</em></span> of <code class="filename">/usr/pkg</code>
953: by symlinking <code class="filename">/usr/pkg</code> to a directory on a UFS
1.75 rillig 954: file system. Obviously, another symlink is required if you want to
955: place the package database directory outside the
956: <span class="emphasis"><em>prefix</em></span>. e.g.</p>
957: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb</code></strong></pre>
958: <p>If you created your partitions at the time of installing Mac OS X
959: and formatted the target partition as UFS, it should automatically
1.76 rillig 960: mount on <code class="filename">/Volumes/<volume name></code> when the
1.75 rillig 961: machine boots. If you are (re)formatting a partition as UFS, you need
962: to ensure that the partition map correctly reflects
963: “<span class="quote">Apple_UFS</span>” and not “<span class="quote">Apple_HFS</span>”.</p>
964: <p>The problem is that none of the disk tools will let you touch a
965: disk that is booted from. You can unmount the partition, but even if
966: you newfs it, the partition type will be incorrect and the
967: automounter won't mount it. It can be mounted manually, but it won't
968: appear in Finder.</p>
969: <p>You'll need to boot off of the OS X Installation (User) CD. When
970: the Installation program starts, go up to the menu and select Disk
971: Utility. Now, you will be able to select the partition you want
972: to be UFS, and Format it Apple UFS. Quit the Disk Utility, quit the
973: installer which will reboot your machine. The new UFS file system
974: will appear in Finder.</p>
975: <p>Be aware that the permissions on the new file system will be writable
976: by root only.</p>
977: <p>This note is as of 10.2 (Jaguar) and applies to earlier versions.
978: Hopefully Apple will fix Disk Utility in 10.3 (Panther).</p>
979: </div>
980: </div>
981: <div class="sect2" lang="en">
982: <div class="titlepage"><div><div><h3 class="title">
983: <a name="freebsd"></a>3.2.2. FreeBSD</h3></div></div></div>
984: <p>
985: FreeBSD 4.7 and 5.0 have been tested and are supported, other versions
986: may work.</p>
987: <p>Care should be taken so that the tools that this kit installs do not conflict
988: with the FreeBSD userland tools. There are several steps:</p>
989: <div class="orderedlist"><ol type="1">
990: <li><p>FreeBSD stores its ports pkg database in
1.76 rillig 991: <code class="filename">/var/db/pkg</code>. It is therefore
1.75 rillig 992: recommended that you choose a different location (e.g.
1.76 rillig 993: <code class="filename">/usr/pkgdb</code>) by
1.75 rillig 994: using the --pkgdbdir option to the bootstrap script.</p></li>
995: <li>
996: <p>If you do not intend to use the FreeBSD ports tools, it's probably a
997: good idea to move them out of the way to avoid confusion, e.g.</p>
998: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
999: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1000: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1001: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1002: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
1003: </li>
1.76 rillig 1004: <li><p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1005: <code class="filename">/etc/mk.conf.example</code> file
1.75 rillig 1006: when you use the bootstrap script.</p></li>
1007: </ol></div>
1008: </div>
1009: <div class="sect2" lang="en">
1010: <div class="titlepage"><div><div><h3 class="title">
1011: <a name="interix"></a>3.2.3. Interix</h3></div></div></div>
1012: <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
1013: providing a Unix-like environment with a tighter kernel integration than
1014: available with Cygwin. It is part of the Windows Services for Unix
1015: package, available for free for any licensed copy of Windows 2000, XP
1016: (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>
1017: <p>Services for Unix 3.5, current as of this writing, has been tested. 3.0
1018: or 3.1 may work, but are not officially supported. (The main difference
1019: in 3.0/3.1 is lack of pthreads.)</p>
1020: <div class="sect3" lang="en">
1021: <div class="titlepage"><div><div><h4 class="title">
1022: <a name="platform.interix-sfu-install"></a>3.2.3.1. When installing Interix/SFU</h4></div></div></div>
1023: <p>At an absolute minimum, the following packages must be installed from
1024: the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
1025: <div class="itemizedlist"><ul type="disc">
1026: <li><p>Utilities -> Base Utilities</p></li>
1027: <li><p>Interix GNU Components -> (all)</p></li>
1028: <li><p>Remote Connectivity</p></li>
1029: <li><p>Interix SDK</p></li>
1030: </ul></div>
1031: <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
1032: "UNIX Perl". That is Perl 5.6 without shared module support, installed to
1033: /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
1034: pkgsrc (or from a binary package).</p>
1035: <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
1036: not need to be installed, but Remote Connectivity itself should be
1037: installed in order to have a working inetd.</p>
1038: <p>During installation you may be asked whether to enable setuid
1039: behavior for Interix programs, and whether to make pathnames default to
1040: case-sensitive. Setuid should be enabled, and case-sensitivity MUST be
1041: enabled. (Without case-sensitivity, a large number of packages including
1042: perl will not build.)</p>
1043: <p>NOTE: Newer Windows service packs change the way binary execution
1044: works (via the Data Execution Prevention feature). In order to use
1045: pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
1046: POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
1047: must be installed. Hotfixes are available from Microsoft through a
1048: support contract; however, a NetBSD developer has made most Interix
1049: 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>
1050: </div>
1051: <div class="sect3" lang="en">
1052: <div class="titlepage"><div><div><h4 class="title">
1053: <a name="platform.interix-sfu-postinstall"></a>3.2.3.2. What to do if Interix/SFU is already installed</h4></div></div></div>
1054: <p>If SFU is already installed and you wish to alter these settings to work
1055: with pkgsrc, note the following things.</p>
1056: <div class="itemizedlist"><ul type="disc">
1057: <li><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
1058: Windows Services for UNIX, then click Change. In the installer, choose
1059: Add or Remove, then uncheck Utilities->UNIX Perl.</p></li>
1060: <li>
1061: <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
1062: change the following registry key:</p>
1063: <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
1064: <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
1065: </li>
1066: <li>
1067: <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
1068: following registry key:</p>
1069: <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
1070: <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
1071: </li>
1072: </ul></div>
1073: </div>
1074: <div class="sect3" lang="en">
1075: <div class="titlepage"><div><div><h4 class="title">
1076: <a name="platform.interix-notes"></a>3.2.3.3. Important notes for using pkgsrc</h4></div></div></div>
1077: <p>The package manager (either the pkgsrc "su" user, or the user
1078: running "pkg_add") must be a member of the local Administrators
1079: group. Such a user must also be used to run the bootstrap. This is
1080: slightly relaxed from the normal pkgsrc requirement of "root".</p>
1081: <p>The package manager should use a umask of 002. "make install" will
1082: automatically complain if this is not the case. This ensures that
1083: directories written in /var/db/pkg are Administrators-group writeable.</p>
1084: <p>The popular Interix binary packages from http://www.interopsystems.com/
1085: use an older version of pkgsrc's pkg_* tools. Ideally, these should
1086: NOT be used in conjunction with pkgsrc. If you choose to use them at
1087: the same time as the pkgsrc packages, ensure that you use the proper
1088: pkg_* tools for each type of binary package.</p>
1089: <p>The TERM setting used for DOS-type console windows (including those
1090: invoked by the csh and ksh startup shortcuts) is "interix". Most systems
1091: don't have a termcap/terminfo entry for it, but the following .termcap
1092: entry provides adequate emulation in most cases:</p>
1093: <pre class="programlisting">
1094: interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
1095: </pre>
1096: </div>
1097: <div class="sect3" lang="en">
1098: <div class="titlepage"><div><div><h4 class="title">
1099: <a name="platform.interix-limits"></a>3.2.3.4. Limitations of the Interix platform</h4></div></div></div>
1100: <p>Though Interix suffices as a familiar and flexible substitute
1101: for a full Unix-like platform, it has some drawbacks that should
1102: be noted for those desiring to make the most of Interix.</p>
1103: <div class="itemizedlist"><ul type="disc">
1104: <li>
1105: <p><span class="strong"><strong>X11:</strong></span></p>
1106: <p>Interix comes with the standard set of X11R6 client libraries,
1107: and can run X11 based applications, but it does
1108: <span class="emphasis"><em>not</em></span> come with an X server. Some options are
1109: <a href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
1110: <a href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
1111: (available in a trimmed version for Interix from Interop Systems as the
1112: <a href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
1113: and the free X11 server included with
1114: <a href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
1115: <p>Also, StarNet Communications has graciously provided a free
1116: version of their X-Win32 product that accepts connections only
1117: from localhost:
1118: <a href="http://www.starnet.com/xwin32LX/get_xwin32LX.htm" target="_top">X-Win32 LX</a>,
1119: recommended by the maintainer of Interix pkgsrc support.</p>
1120: </li>
1121: <li>
1122: <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
1123: <p>Because Interix runs in a completely different NT subsystem from
1124: Win32 applications, it does not currently support various X11
1125: protocol extensions for acceleration (such as MIT-SHM or DGA).
1126: Most interactive applications to a local X server will run
1127: reasonably fast, but full motion video and other graphics
1128: intensive applications may require a faster-than-expected CPU.</p>
1129: </li>
1130: <li>
1131: <p><span class="strong"><strong>Audio:</strong></span></p>
1132: <p>Interix has no native support for audio output. For audio
1133: support, pkgsrc uses the <span><strong class="command">esound</strong></span> client/server
1134: audio system on Interix. Unlike on most platforms, the
1.76 rillig 1135: <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 1136: <span class="emphasis"><em>not</em></span> contain the <span><strong class="command">esd</strong></span>
1137: server component. To output audio via an Interix host, the
1.76 rillig 1138: <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 1139: must also be installed.</p>
1140: </li>
1141: <li>
1142: <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
1143: <p>Direct device access is not currently supported in Interix, so it
1144: is not currently possible to access CD/DVD drives, USB devices,
1145: or SCSI devices through non-filesystem means. Among other things,
1146: this makes it impossible to use Interix directly for CD/DVD
1147: burning.</p>
1148: </li>
1149: <li>
1150: <p><span class="strong"><strong>Tape drives:</strong></span></p>
1151: <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
1152: drives are also not directly accessible in Interix. However,
1153: support is in work to make tape drive access possible by using
1154: Cygwin as a bridge (similarly to audio bridged via Cygwin's
1155: esound server).</p>
1156: </li>
1157: </ul></div>
1158: </div>
1159: <div class="sect3" lang="en">
1160: <div class="titlepage"><div><div><h4 class="title">
1161: <a name="platform.interix-knownissues"></a>3.2.3.5. Known issues for pkgsrc on Interix</h4></div></div></div>
1162: <p>It is not necessary, in general, to have a "root" user on the
1163: Windows system; any member of the local Administrators group will
1164: suffice. However, some packages currently assume that the user
1165: named "root" is the privileged user. To accommodate these, you
1166: may create such a user; make sure it is in the local group
1167: Administrators (or your language equivalent).</p>
1168: <p>"pkg_add" creates directories of mode 0755, not 0775, in
1169: $PKG_DBDIR. For the time being, install packages as the local
1170: Administrator (or your language equivalent), or run the following
1171: command after installing a package to work around the issue:</p>
1172: <pre class="screen">
1173: <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong></pre>
1174: </div>
1175: </div>
1176: <div class="sect2" lang="en">
1177: <div class="titlepage"><div><div><h3 class="title">
1178: <a name="irix"></a>3.2.4. IRIX</h3></div></div></div>
1179: <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
1180: compiler (cc/c89). Please set the <code class="varname">CC</code> environment variable
1181: according to your preference. If you do not have a license for the MIPSpro
1182: compiler suite, you can download a gcc tardist file from <a href="http://freeware.sgi.com/" target="_top">http://freeware.sgi.com/</a>.</p>
1183: <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
1184: 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>,
1185: etc.</p>
1186: <p>At this point in time, pkgsrc only supports one ABI at a time. That is, you can not
1187: switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI. If
1188: you start out using "abi=n32", that's what all your packages will be built
1189: with.</p>
1190: <p>Therefore, please make sure that you have no conflicting
1191: <code class="varname">CFLAGS</code> in your environment or the
1.76 rillig 1192: <code class="filename">/etc/mk.conf</code>. Particularly, make sure that you do not
1.75 rillig 1193: try to link n32 object files with lib64 or vice versa. Check your
1.76 rillig 1194: <code class="filename">/etc/compiler.defaults</code>!</p>
1.75 rillig 1195: <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
1196: please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
1197: as it appears that IRIX linker occasionally runs into issues when trying to
1198: link over a network-mounted file system.</p>
1199: <p>The bootstrapping process should set all the right options for programs such
1200: as imake(1), but you may want to set some options depending on your local
1.76 rillig 1201: setup. Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
1.75 rillig 1202: course, your compiler's man pages for details.</p>
1203: <p>If you are using SGI's MIPSPro compiler, please set
1.1 grant 1204:
1.75 rillig 1205: </p>
1206: <pre class="programlisting">
1207: PKGSRC_COMPILER= mipspro
1208: </pre>
1209: <p>
1.1 grant 1210:
1.76 rillig 1211: in <code class="filename">/etc/mk.conf</code>. Otherwise, pkgsrc will assume you
1.75 rillig 1212: are using gcc and may end up passing invalid flags to the compiler. Note that
1.76 rillig 1213: bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
1.75 rillig 1214: default.</p>
1215: <p>If you have both the MIPSPro compiler chain installed as well as gcc,
1216: but want to make sure that MIPRPro is used, please set your <code class="varname">PATH</code>
1217: to <span class="emphasis"><em>not</em></span> include the location of gcc (often
1.76 rillig 1218: <code class="filename">/usr/freeware/bin</code>), and (important) pass the
1.75 rillig 1219: '--preserve-path' flag.</p>
1220: </div>
1221: <div class="sect2" lang="en">
1222: <div class="titlepage"><div><div><h3 class="title">
1223: <a name="linux"></a>3.2.5. Linux</h3></div></div></div>
1224: <p>
1225: Some versions of Linux (for example Debian GNU/Linux) need either
1226: libtermcap or libcurses (libncurses). Installing the distributions
1227: libncurses-dev package (or equivalent) should fix the problem.</p>
1228: <p>
1229: pkgsrc supports both gcc (GNU Compiler Collection) and icc (Intel C++
1230: Compiler). gcc is the default. icc 8.0 and 8.1 on i386 have been tested.
1231: </p>
1232: <p>To bootstrap using icc, assuming the default icc installation
1233: directory:</p>
1234: <pre class="programlisting">
1235: env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
1236: ac_cv___attribute__=yes ./bootstrap
1237: </pre>
1238: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1239: <h3 class="title">Note</h3>
1240: <p>icc 8.1 needs the `-i-static' argument instead of -static-libcxa.</p>
1241: </div>
1242: <p>icc supports __attribute__, but the GNU configure test uses a nested
1243: function, which icc does not support. #undef'ing __attribute__ has the
1244: unfortunate side-effect of breaking many of the Linux header files, which
1245: cannot be compiled properly without __attribute__. The test must be
1246: overridden so that __attribute__ is assumed supported by the
1247: compiler.</p>
1248: <p>After bootstrapping, you should set <code class="varname">PKGSRC_COMPILER</code>
1.76 rillig 1249: in <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1250: <pre class="programlisting">
1251: PKGSRC_COMPILER= icc
1252: </pre>
1253: <p>The default installation directory for icc is
1.76 rillig 1254: <code class="filename">/opt/intel_cc_80</code>, which
1.75 rillig 1255: is also the pkgsrc default. If you have installed it into a different
1256: directory, set <code class="varname">ICCBASE</code> in
1.76 rillig 1257: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1258: <pre class="programlisting">
1259: ICCBASE= /opt/icc
1260: </pre>
1261: <p>pkgsrc uses the static linking method of the runtime libraries
1262: provided by icc, so binaries can be run on other systems which do not
1263: have the shared libraries installed.</p>
1264: <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>
1265: command run when linking a C++ shared library and records it, throwing
1266: away the -Bstatic and -Bdynamic options interspersed between the libraries.
1267: This means that libtool-linked C++ shared libraries will have a
1268: runtime dependency on the icc libraries until this is fixed in libtool.
1269: </p>
1270: </div>
1271: <div class="sect2" lang="en">
1272: <div class="titlepage"><div><div><h3 class="title">
1273: <a name="openbsd"></a>3.2.6. OpenBSD</h3></div></div></div>
1274: <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
1275: <p>Care should be taken so that the tools that this kit installs do not conflict
1276: with the OpenBSD userland tools. There are several steps:</p>
1277: <div class="orderedlist"><ol type="1">
1278: <li><p>OpenBSD stores its ports pkg database in
1.76 rillig 1279: <code class="filename">/var/db/pkg</code>. It is therefore
1.75 rillig 1280: recommended that you choose a different location (e.g.
1.76 rillig 1281: <code class="filename">/usr/pkgdb</code>) by
1.75 rillig 1282: using the --pkgdbdir option to the bootstrap script.</p></li>
1283: <li>
1284: <p>If you do not intend to use the OpenBSD ports tools, it's probably a
1285: good idea to move them out of the way to avoid confusion, e.g.</p>
1286: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1287: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1288: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1289: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1290: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
1291: </li>
1292: <li>
1.76 rillig 1293: <p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1294: <code class="filename">/etc/mk.conf.example</code> file
1.75 rillig 1295: when you use the bootstrap script. OpenBSD's make program uses
1.76 rillig 1296: <code class="filename">/etc/mk.conf</code>
1.75 rillig 1297: as well. You can work around this by enclosing all the pkgsrc-specific parts
1298: of the file with:</p>
1299: <pre class="programlisting">
1300: .ifdef BSD_PKG_MK
1301: # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
1302: .else
1303: # OpenBSD stuff
1.1 grant 1304: .endif
1305: </pre>
1.75 rillig 1306: </li>
1307: </ol></div>
1308: </div>
1309: <div class="sect2" lang="en">
1310: <div class="titlepage"><div><div><h3 class="title">
1311: <a name="solaris"></a>3.2.7. Solaris</h3></div></div></div>
1312: <p>Solaris 2.6 through 9 are supported on both x86 and sparc.
1313: You will need a working C compiler. Both gcc 2.95.3 and
1314: Sun WorkShop 5 have been tested.</p>
1315: <p>The following packages are required on Solaris 8 for the bootstrap
1316: process and to build packages.</p>
1317: <div class="itemizedlist"><ul type="disc">
1318: <li><p>SUNWsprot</p></li>
1319: <li><p>SUNWarc</p></li>
1320: <li><p>SUNWbtool</p></li>
1321: <li><p>SUNWtoo</p></li>
1322: <li><p>SUNWlibm</p></li>
1323: </ul></div>
1.78 rillig 1324: <p>Please note that the use of GNU binutils on Solaris is
1325: <span class="emphasis"><em>not</em></span> supported, as of June 2006.</p>
1.75 rillig 1326: <p>Whichever compiler you use, please ensure the compiler tools and
1327: your $prefix are in your <code class="varname">PATH</code>. This includes
1.76 rillig 1328: <code class="filename">/usr/ccs/{bin,lib}</code>
1329: and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1.75 rillig 1330: <div class="sect3" lang="en">
1331: <div class="titlepage"><div><div><h4 class="title">
1332: <a name="solaris-gcc-note"></a>3.2.7.1. If you are using gcc</h4></div></div></div>
1333: <p>It makes life much simpler if you only use the same gcc consistently
1334: for building all packages.</p>
1335: <p>It is recommended that an external gcc be used only for bootstrapping,
1336: then either build gcc from
1.76 rillig 1337: <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 1338: package, then remove gcc used during bootstrapping.</p>
1339: <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>
1340: </div>
1341: <div class="sect3" lang="en">
1342: <div class="titlepage"><div><div><h4 class="title">
1343: <a name="solaris-sun-workshop-note"></a>3.2.7.2. If you are using Sun WorkShop</h4></div></div></div>
1344: <p>You will need at least the following packages installed (from WorkShop
1345: 5.0)</p>
1346: <div class="itemizedlist"><ul type="disc">
1347: <li><p>SPROcc
1348: - Sun WorkShop Compiler C 5.0</p></li>
1349: <li><p>SPROcpl
1350: - Sun WorkShop Compiler C++ 5.0</p></li>
1351: <li><p>SPROild
1352: - Sun WorkShop Incremental Linker</p></li>
1353: <li><p>SPROlang
1354: - Sun WorkShop Compilers common components</p></li>
1355: </ul></div>
1356: <p>You should set <code class="varname">CC</code>, <code class="varname">CXX</code> and
1.76 rillig 1357: optionally, <code class="varname">CPP</code> in <code class="filename">/etc/mk.conf</code>,
1.75 rillig 1358: e.g.:</p>
1359: <pre class="programlisting">
1360: CC= cc
1361: CXX= CC
1362: CPP= /usr/ccs/lib/cpp
1.1 grant 1363: </pre>
1.75 rillig 1364: </div>
1365: <div class="sect3" lang="en">
1366: <div class="titlepage"><div><div><h4 class="title">
1367: <a name="solaris-sunpro-64"></a>3.2.7.3. Buildling 64-bit binaries with SunPro</h4></div></div></div>
1368: <p>Building 64-bit binaries is a little trickier. First, you
1369: need to bootstrap pkgsrc in 64-bit mode. One problem here is
1370: that while building one of the programs in the bootstrap kit
1.76 rillig 1371: (<code class="filename">bmake</code>), the <code class="varname">CFLAGS</code>
1.75 rillig 1372: variable is not honored, even if it is set in the environment.
1373: To work around this bug, you can create a simple shell script
1.76 rillig 1374: called <code class="filename">cc64</code> and put it somewhere in the
1.75 rillig 1375: <code class="varname">PATH</code>:</p>
1376: <pre class="programlisting">
1377: #! /bin/sh
1378: exec /opt/SUNWspro/bin/cc -xtarget=ultra -xarch=v9 ${1+"$@"}
1.1 grant 1379: </pre>
1.75 rillig 1380: <p>Then, pass the definition for <code class="varname">CC</code> in the
1381: environment of the <span><strong class="command">bootstrap</strong></span> command:</p>
1382: <pre class="programlisting">
1383: <code class="prompt">$</code> <strong class="userinput"><code>cd bootstrap</code></strong>
1384: <code class="prompt">$</code> <strong class="userinput"><code>CC=cc64 ./bootstrap</code></strong>
1385: </pre>
1386: <p>After bootstrapping, there are two alternative ways,
1387: depending on whether you want to find bugs in packages or get
1388: your system ready quickly. If you just want a running system,
1.76 rillig 1389: add the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1390: file:</p>
1391: <pre class="programlisting">
1392: CC= cc64
1393: CXX= CC64
1394: PKGSRC_COMPILER= sunpro
1.1 grant 1395: </pre>
1.75 rillig 1396: <p>This way, all calls to the compiler will be intercepted by
1397: the above wrapper and therefore get the necessary ABI options
1398: automatically. (Don't forget to create the shell script
1.76 rillig 1399: <code class="filename">CC64</code>, too.)</p>
1.75 rillig 1400: <p>To find packages that ignore the user-specified
1401: <code class="varname">CFLAGS</code> and <code class="varname">CXXFLAGS</code>, add
1.76 rillig 1402: the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1403: file:</p>
1404: <pre class="programlisting">
1405: CC= cc
1406: CXX= CC
1407: PKGSRC_COMPILER= sunpro
1408: CFLAGS= -xtarget=ultra -xarch=v9
1409: CXXFLAGS= -xtarget=ultra -xarch=v9
1410: LDFLAGS= -xtarget=ultra -xarch=v9
1.1 grant 1411: </pre>
1.75 rillig 1412: <p>Packages that don't use the flags provided in the
1413: configuration file will try to build 32-bit binaries and fail
1414: during linking. Detecting this is useful to prevent bugs on
1415: other platforms where the error would not show up but pass
1416: silently.</p>
1417: </div>
1418: <div class="sect3" lang="en">
1419: <div class="titlepage"><div><div><h4 class="title">
1420: <a name="plat.sunos.problems"></a>3.2.7.4. Common problems</h4></div></div></div>
1421: <p>Sometimes, when using <span><strong class="command">libtool</strong></span>,
1.76 rillig 1422: <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
1.75 rillig 1423: The workaround is to use another shell for the configure
1.76 rillig 1424: 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
1425: to your <code class="filename">mk.conf</code>:</p>
1.75 rillig 1426: <pre class="programlisting">
1427: CONFIG_SHELL= ${LOCALBASE}/bin/bash
1428: WRAPPER_SHELL= ${LOCALBASE}/bin/bash
1.1 grant 1429: </pre>
1.76 rillig 1430: <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 1431: </div>
1432: </div>
1433: </div>
1434: </div>
1435: <div class="chapter" lang="en">
1436: <div class="titlepage"><div><div><h2 class="title">
1437: <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
1438: <div class="toc">
1439: <p><b>Table of Contents</b></p>
1440: <dl>
1441: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
1442: <dd><dl>
1443: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
1444: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1445: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
1446: </dl></dd>
1447: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
1448: <dd><dl>
1449: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
1450: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
1451: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
1452: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
1453: </dl></dd>
1454: </dl>
1455: </div>
1456: <p>Basically, there are two ways of using pkgsrc. The first
1457: is to only install the package tools and to use binary packages
1458: that someone else has prepared. This is the “<span class="quote">pkg</span>”
1459: in pkgsrc. The second way is to install the “<span class="quote">src</span>”
1460: of pkgsrc, too. Then you are able to build your own packages,
1461: and you can still use binary packages from someone else.</p>
1462: <div class="sect1" lang="en">
1463: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1464: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
1465: <p>To use binary packages, you need some tools to manage
1466: them. On NetBSD, these tools are already installed. On all other
1467: operating systems, you need to install them first. For the
1468: following platforms, prebuilt versions of the package tools
1469: are available and can simply be downloaded and unpacked in the
1.76 rillig 1470: <code class="filename">/</code> directory:</p>
1.75 rillig 1471: <div class="informaltable">
1472: <a name="binary-bootstrap-kits"></a><table border="1">
1473: <colgroup>
1474: <col>
1475: <col>
1476: </colgroup>
1477: <thead><tr>
1478: <th>Platform</th>
1479: <th>URL</th>
1480: </tr></thead>
1481: <tbody>
1482: <tr>
1483: <td>Solaris 9</td>
1.76 rillig 1484: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1485: </tr>
1486: <tr>
1487: <td>Solaris 10</td>
1.76 rillig 1488: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1489: </tr>
1490: </tbody>
1491: </table>
1492: </div>
1493: <p>These prebuilt package tools use
1.76 rillig 1494: <code class="filename">/usr/pkg</code> for the base directory, and
1495: <code class="filename">/var/db/pkg</code> for the database of installed
1.75 rillig 1496: packages. If you cannot use these directories for whatever
1497: reasons (maybe because you're not root), you have to build the
1498: package tools yourself, which is explained in <a href="#bootstrapping-pkgsrc" title="3.1. Bootstrapping pkgsrc">Section 3.1, “Bootstrapping pkgsrc”</a>.</p>
1499: <div class="sect2" lang="en">
1500: <div class="titlepage"><div><div><h3 class="title">
1501: <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
1502: <p>To install binary packages, you first need to know from
1503: where to get them. You can get them on CD-ROMs, DVDs, or via FTP
1504: or HTTP.</p>
1505: <p>For NetBSD, the binary packages are made available on
1.76 rillig 1506: <code class="filename">ftp.NetBSD.org</code> and its mirrors, in the
1.75 rillig 1507: directory
1.76 rillig 1508: <code class="filename">/pub/NetBSD/packages/<em class="replaceable"><code>OSVERSION</code></em>/<em class="replaceable"><code>ARCH</code></em>/</code>.
1.75 rillig 1509: For <em class="replaceable"><code>OSVERSION</code></em>, you should insert the
1510: output of <span><strong class="command">uname -r</strong></span>, and for
1511: <em class="replaceable"><code>ARCH</code></em> the output of <span><strong class="command">uname
1512: -p</strong></span>.</p>
1513: <p>For some other platforms, binary packages can be found at
1514: the following locations:</p>
1515: <div class="informaltable">
1516: <a name="binary-packages"></a><table border="1">
1517: <colgroup>
1518: <col>
1519: <col>
1520: </colgroup>
1521: <thead><tr>
1522: <th>Platform</th>
1523: <th>URL</th>
1524: </tr></thead>
1525: <tbody>
1526: <tr>
1527: <td>Solaris 9</td>
1.76 rillig 1528: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/</code></td>
1.75 rillig 1529: </tr>
1530: <tr>
1531: <td>Solaris 10</td>
1.76 rillig 1532: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/</code></td>
1.75 rillig 1533: </tr>
1534: </tbody>
1535: </table>
1536: </div>
1537: <p>Most of these directories contain the pkgsrc distribution
1538: for multiple platforms. Select the appropriate subdirectories,
1539: according to your machine architecture and operating system,
1.76 rillig 1540: until you find a directory called <code class="filename">All</code>. This
1.75 rillig 1541: directory contains all the binary packages. Further, there are
1542: subdirectories for categories that contain symbolic links that
1543: point to the actual binary package in
1.76 rillig 1544: <code class="filename">../All</code>. This directory layout is used for
1.75 rillig 1545: all package repositories, no matter if they are accessed via
1546: HTTP, FTP, NFS, CD-ROM, or the local filesystem.</p>
1547: </div>
1548: <div class="sect2" lang="en">
1549: <div class="titlepage"><div><div><h3 class="title">
1550: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
1551: <p> If you have the files on a CD-ROM or downloaded them to
1552: your hard disk, you can install them with the following command
1553: (be sure to <span><strong class="command">su</strong></span> to root first):</p>
1554: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add /path/to/package.tgz</code></strong></pre>
1555: <p> If you have FTP access and you don't want to download the
1556: packages via FTP prior to installation, you can do this
1557: automatically by giving <span><strong class="command">pkg_add</strong></span> an FTP URL:
1558: </p>
1559: <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>
1560: <p>Note that any prerequisite packages needed to run the
1561: package in question will be installed, too, assuming they are
1562: present where you install from. </p>
1563: <p>To save some typing, you can set the
1564: <code class="varname">PKG_PATH</code> environment variable to a semicolon-separated
1565: list of paths (including remote URLs); trailing slashes are not allowed.
1566: </p>
1.76 rillig 1567: <p>Additionally to the <code class="filename">All</code> directory
1568: there exists a <code class="filename">vulnerable</code> directory to
1.75 rillig 1569: which binary packages with known vulnerabilities are
1570: moved, since removing them could cause missing dependencies. To
1.76 rillig 1571: use these packages, add the <code class="filename">vulnerable</code>
1.75 rillig 1572: directory to your <code class="varname">PKG_PATH</code>. However, you should run
1.76 rillig 1573: <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 1574: especially after installing new packages, and verify that the
1575: vulnerabilities are acceptable for your configuration. An example
1576: <code class="varname">PKG_PATH</code> would be:
1.76 rillig 1577: <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 1578: Please note that semicolon (';') is a shell meta-character, so
1579: you'll probably have to quote it.</p>
1580: <p>After you've installed packages, be sure to have
1.76 rillig 1581: <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
1.75 rillig 1582: <code class="varname">PATH</code> so you can actually start the just
1583: installed program. </p>
1584: </div>
1585: <div class="sect2" lang="en">
1586: <div class="titlepage"><div><div><h3 class="title">
1587: <a name="a-word-of-warning"></a>4.1.3. A word of warning</h3></div></div></div>
1588: <p>Please pay very careful attention to the warnings
1589: 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
1590: inherent dangers of installing binary packages which you did
1591: not create yourself, and the security holes that can be
1592: introduced onto your system by indiscriminate adding of such
1593: files.</p>
1594: <p>The same warning of course applies to every package you
1595: install from source when you haven't completely read and
1596: understood the source code of the package, the compiler that
1597: is used to build the package and all the other tools that are
1598: involved.</p>
1599: </div>
1600: </div>
1601: <div class="sect1" lang="en">
1602: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1603: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
1604: <p> This assumes that the package is already in pkgsrc. If it
1605: 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
1606: how to create your own packages.</p>
1607: <div class="sect2" lang="en">
1608: <div class="titlepage"><div><div><h3 class="title">
1609: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
1610: <p> To build packages from source on a NetBSD system the
1611: “<span class="quote">comp</span>” and the “<span class="quote">text</span>” distribution
1612: sets must be installed. If you want to build X11-related
1613: packages the “<span class="quote">xbase</span>” and “<span class="quote">xcomp</span>”
1614: distribution sets are required, too.</p>
1615: </div>
1616: <div class="sect2" lang="en">
1617: <div class="titlepage"><div><div><h3 class="title">
1618: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
1619: <p>The first step for building a package is downloading the
1620: distfiles (i.e. the unmodified source). If they have not yet been
1621: downloaded, pkgsrc will fetch them automatically.</p>
1622: <p>You can overwrite some of the major distribution sites to fit to sites
1623: that are close to your own. Have a look at
1.76 rillig 1624: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find some examples
1.78 rillig 1625: — in particular, look for the <code class="varname">MASTER_SORT</code>,
1.75 rillig 1626: <code class="varname">MASTER_SORT_REGEX</code> and
1627: <code class="varname">INET_COUNTRY</code> definitions. This may save some of your
1628: bandwidth and time.</p>
1629: <p>You can change these settings either in your shell's environment, or,
1630: if you want to keep the settings, by editing the
1.76 rillig 1631: <code class="filename">/etc/mk.conf</code> file,
1.75 rillig 1632: and adding the definitions there.</p>
1633: <p>If you don't have a permanent Internet connection and you want to know
1634: which files to download, <span><strong class="command">make fetch-list</strong></span> will tell you
1635: what you'll need. Put these distfiles into
1.76 rillig 1636: <code class="filename">/usr/pkgsrc/distfiles</code>.</p>
1.75 rillig 1637: </div>
1638: <div class="sect2" lang="en">
1639: <div class="titlepage"><div><div><h3 class="title">
1640: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
1641: <p>Assuming that the distfile has been fetched (see previous section), become
1642: root and change into the relevant directory and run
1643: <span><strong class="command">make</strong></span>.</p>
1644: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1645: <h3 class="title">Note</h3>
1646: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
1647: use the pkgsrc <span><strong class="command">bmake</strong></span> command instead of
1648: “<span class="quote">make</span>” in the examples in this guide.</p>
1649: </div>
1650: <p>For example, type </p>
1651: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
1652: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong></pre>
1653: <p>at the shell prompt to build the various components of the
1654: package, and</p>
1655: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong></pre>
1656: <p>to install the various components into the correct places
1657: on your system. Installing the package on your system requires
1658: you to be root. However, pkgsrc has a
1659: <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
1660: to only become root for the actual installation step</p>
1661: <p>Taking the figlet utility as an example, we can install it on our
1662: system by building as shown in <a href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
1663: <p>The program is installed under the default root of the packages tree -
1.76 rillig 1664: <code class="filename">/usr/pkg</code>. Should this not conform to your tastes,
1.75 rillig 1665: set the <code class="varname">LOCALBASE</code>
1666: variable in your environment, and it will use that value as the root of
1.76 rillig 1667: your packages tree. So, to use <code class="filename">/usr/local</code>, set
1.75 rillig 1668: <code class="varname">LOCALBASE=/usr/local</code> in your environment. Please note
1669: that you should use a directory which is
1670: dedicated to packages and not shared with other programs (i.e., do not try
1671: and use <code class="varname">LOCALBASE=/usr</code>). Also, you should not try to
1.76 rillig 1672: add any of your own files or directories (such as <code class="filename">src/</code>,
1673: <code class="filename">obj/</code>, or <code class="filename">pkgsrc/</code>) below the
1.75 rillig 1674: <code class="varname">LOCALBASE</code> tree. This is to prevent possible conflicts
1675: between programs and other files installed by the package system and
1676: whatever else may have been installed there.</p>
1.76 rillig 1677: <p>Some packages look in <code class="filename">/etc/mk.conf</code> to alter some
1.75 rillig 1678: configuration options at build time. Have a look at
1.76 rillig 1679: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to
1.75 rillig 1680: get an overview of what will be set there by default. Environment
1681: variables such as <code class="varname">LOCALBASE</code>
1.76 rillig 1682: can be set in <code class="filename">/etc/mk.conf</code> to
1.75 rillig 1683: save having to remember to set them each time you want to use pkgsrc.</p>
1684: <p>Occasionally, people want to “<span class="quote">look under the covers</span>” to see
1685: what is going on when a package is building or being installed. This may be
1686: for debugging purposes, or out of simple curiosity. A number of utility
1687: values have been added to help with this.</p>
1688: <div class="orderedlist"><ol type="1">
1689: <li>
1690: <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>,
1691: then a huge amount of information will be displayed. For example,</p>
1692: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
1693: <p>will show all the commands that are invoked, up to and including the
1694: “<span class="quote">patch</span>” stage.</p>
1695: </li>
1696: <li>
1697: <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
1698: the <code class="varname">VARNAME</code> definition should be used, in conjunction
1699: 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
1700: <code class="varname">LOCALBASE</code>:</p>
1701: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
1702: /usr/pkg
1703: <code class="prompt">%</code>
1704: </pre>
1705: </li>
1706: </ol></div>
1707: <p>If you want to install a binary package that you've either
1708: created yourself (see next section), that you put into pkgsrc/packages manually or
1709: that is located on a remote FTP server, you can use the "bin-install"
1710: target. This target will install a binary package - if available - via
1711: <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>.
1712: The list of remote
1713: FTP sites searched is kept in the variable
1714: <code class="varname">BINPKG_SITES</code>, which defaults to
1715: 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
1716: into <code class="varname">BIN_INSTALL_FLAGS</code>.
1.76 rillig 1717: See <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more details.</p>
1.75 rillig 1718: <p>A final word of warning: If you set up a system that has a non-standard
1719: setting for <code class="varname">LOCALBASE</code>, be sure to set that
1720: before any packages are installed, as you can not use several directories
1721: for the same purpose. Doing so will result in pkgsrc not being able to
1722: properly detect your installed packages, and fail miserably. Note also that
1723: precompiled binary packages are usually built with the default
1724: <code class="varname">LOCALBASE</code> of
1.76 rillig 1725: <code class="filename">/usr/pkg</code>, and that you should <span class="emphasis"><em>not</em></span>
1.75 rillig 1726: install any if you use a non-standard <code class="varname">LOCALBASE</code>.</p>
1727: </div>
1728: <div class="sect2" lang="en">
1729: <div class="titlepage"><div><div><h3 class="title">
1730: <a name="selecting-the-compiler"></a>4.2.4. Selecting the compiler</h3></div></div></div>
1731: <p>By default, pkgsrc will use GCC to build packages. This may be
1732: overridden by setting the following variables in /etc/mk.conf:
1733: </p>
1734: <div class="variablelist"><dl>
1735: <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
1736: <dd>
1737: <p> This is a list of values specifying the chain of
1738: compilers to invoke when building packages. Valid values
1739: are: </p>
1740: <div class="itemizedlist"><ul type="disc">
1741: <li><p><code class="varname">distcc</code>:
1742: distributed C/C++ (chainable)</p></li>
1743: <li><p><code class="varname">ccache</code>:
1744: compiler cache (chainable)</p></li>
1745: <li><p><code class="varname">gcc</code>:
1746: GNU C/C++ Compiler</p></li>
1747: <li><p><code class="varname">mipspro</code>:
1748: Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
1749: <li><p><code class="varname">mipspro</code>:
1750: Silicon Graphics, Inc. MIPSpro (o32)</p></li>
1751: <li><p><code class="varname">sunpro</code>:
1752: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
1753: </ul></div>
1754: <p> The default is
1755: “<span class="quote"><code class="varname">gcc</code></span>”. You can use
1756: <code class="varname">ccache</code> and/or
1757: <code class="varname">distcc</code> with an appropriate
1758: <code class="varname">PKGSRC_COMPILER</code> setting,
1759: e.g. “<span class="quote"><code class="varname">ccache gcc</code></span>”. This
1760: variable should always be
1761: terminated with a value for a real compiler. </p>
1762: </dd>
1763: <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
1764: <dd><p> This specifies the minimum version of GCC to use
1765: when building packages. If the system GCC doesn't
1766: satisfy this requirement, then pkgsrc will build and
1767: install one of the GCC packages to use instead. </p></dd>
1768: </dl></div>
1769: </div>
1770: </div>
1771: </div>
1772: <div class="chapter" lang="en">
1773: <div class="titlepage"><div><div><h2 class="title">
1774: <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
1775: <div class="toc">
1776: <p><b>Table of Contents</b></p>
1777: <dl>
1778: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
1779: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 1780: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
1781: <dd><dl><dt><span class="sect2"><a href="#conf.cflags">5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt></dl></dd>
1782: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
1783: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 1784: </dl>
1785: </div>
1786: <div class="sect1" lang="en">
1787: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1788: <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
1789: <p>In this section, you can find some variables that apply to all
1790: pkgsrc packages. The preferred method of setting these variables
1.76 rillig 1791: is by setting them in <code class="filename">/etc/mk.conf</code>.
1.75 rillig 1792: </p>
1793: <div class="itemizedlist"><ul type="disc">
1794: <li><p><code class="varname">LOCALBASE</code>: Where
1795: packages will be installed. The default is
1.76 rillig 1796: <code class="filename">/usr/pkg</code>. Do not mix binary packages
1.75 rillig 1797: with different <code class="varname">LOCALBASE</code>s!</p></li>
1798: <li><p><code class="varname">CROSSBASE</code>: Where
1799: “<span class="quote">cross</span>” category packages will be
1800: installed. The default is
1.76 rillig 1801: <code class="filename">${LOCALBASE}/cross</code>.</p></li>
1.75 rillig 1802: <li><p><code class="varname">X11BASE</code>: Where
1803: X11 is installed on the system. The default is
1.76 rillig 1804: <code class="filename">/usr/X11R6</code>.</p></li>
1.75 rillig 1805: <li><p><code class="varname">DISTDIR</code>: Where to store the
1806: downloaded copies of the original source distributions used
1807: for building pkgsrc packages. The default is
1.76 rillig 1808: <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
1.75 rillig 1809: <li><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
1810: If set, override the packages'
1811: <code class="varname">MASTER_SITES</code> with this value.</p></li>
1812: <li><p><code class="varname">MASTER_SITE_BACKUP</code>:
1813: Backup location(s) for distribution files and patch files
1814: if not found locally or in
1.76 rillig 1815: <code class="filename">${MASTER_SITES}</code> or
1816: <code class="filename">${PATCH_SITES}</code> respectively.
1.75 rillig 1817: The defaults are
1.76 rillig 1818: <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
1.75 rillig 1819: and
1.76 rillig 1820: <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
1.75 rillig 1821: <li><p><code class="varname">BINPKG_SITES</code>:
1822: List of sites carrying binary pkgs.</p></li>
1823: </ul></div>
1824: <p>
1825: </p>
1826: </div>
1827: <div class="sect1" lang="en">
1828: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1829: <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
1830: <p>XXX
1831: </p>
1832: <div class="itemizedlist"><ul type="disc">
1833: <li><p><code class="varname">PACKAGES</code>: The top level
1834: directory for the binary packages. The default is
1.76 rillig 1835: <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
1.75 rillig 1836: <li><p><code class="varname">WRKOBJDIR</code>:
1837: The top level directory where, if defined, the separate
1838: working directories will get created, and symbolically
1.76 rillig 1839: linked to from <code class="filename">${WRKDIR}</code> (see below).
1.75 rillig 1840: This is useful for building packages on several
1.76 rillig 1841: architectures, then <code class="filename">${PKGSRCDIR}</code>
1842: can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
1.75 rillig 1843: is local to every architecture. (It should be noted that
1844: <code class="varname">PKGSRCDIR</code> should not be set by the user
1.78 rillig 1845: — it is an internal definition which refers to the
1.75 rillig 1846: root of the pkgsrc tree. It is possible to have many
1847: pkgsrc tree instances.)</p></li>
1848: <li><p><code class="varname">LOCALPATCHES</code>:
1849: Directory for local patches that aren't part of pkgsrc.
1.77 rillig 1850: See <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a> for more
1.75 rillig 1851: information. <em class="replaceable"><code>rel</code></em> and
1852: <em class="replaceable"><code>arch</code></em> are replaced with OS
1853: release (“<span class="quote">2.0</span>”, etc.) and architecture
1854: (“<span class="quote">mipsel</span>”, etc.).</p></li>
1855: <li><p><code class="varname">PKGMAKECONF</code>: Location of
1.76 rillig 1856: the <code class="filename">mk.conf</code> file used by a package's
1.75 rillig 1857: BSD-style Makefile. If this is not set,
1858: <code class="varname">MAKECONF</code> is set to
1.76 rillig 1859: <code class="filename">/dev/null</code> to avoid picking up
1860: settings used by builds in <code class="filename">/usr/src</code>.</p></li>
1.75 rillig 1861: </ul></div>
1862: <p>
1863: </p>
1864: </div>
1865: <div class="sect1" lang="en">
1866: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 1867: <a name="conf.compiler"></a>5.3. Selecting and configuring the compiler</h2></div></div></div>
1868: <div class="sect2" lang="en">
1869: <div class="titlepage"><div><div><h3 class="title">
1870: <a name="conf.cflags"></a>5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</h3></div></div></div>
1871: <p>If you wish to set the <code class="varname">CFLAGS</code> variable,
1872: please make sure to use the <code class="literal">+=</code> operator
1873: instead of the <code class="literal">=</code> operator:</p>
1874: <pre class="programlisting">
1875: CFLAGS+= -your -flags
1876: </pre>
1877: <p>Using <code class="varname">CFLAGS=</code> (i.e. without the
1878: “<span class="quote">+</span>”) may lead to problems with packages that need
1879: to add their own flags. Also, you may want to take a look at
1880: 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
1881: you're interested in optimization for the current CPU.</p>
1882: </div>
1883: </div>
1884: <div class="sect1" lang="en">
1885: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1886: <a name="developer-advanced-settings"></a>5.4. Developer/advanced settings</h2></div></div></div>
1.75 rillig 1887: <p>XXX
1888: </p>
1889: <div class="itemizedlist"><ul type="disc">
1890: <li>
1891: <p><code class="varname">PKG_DEVELOPER</code>:
1892: Run some sanity checks that package developers want:
1893: </p>
1894: <div class="itemizedlist"><ul type="circle">
1895: <li><p>make sure patches apply with zero fuzz</p></li>
1896: <li><p>run check-shlibs to see that all binaries will
1897: find their shared libs.</p></li>
1898: </ul></div>
1899: <p>
1900: </p>
1901: </li>
1902: <li><p><code class="varname">PKG_DEBUG_LEVEL</code>:
1903: The level of debugging output which is displayed whilst
1904: making and installing the package.
1905: The default value for this is 0, which will not display
1906: the commands as they are executed (normal, default, quiet
1907: operation); the value 1 will display all shell commands
1908: before their invocation, and the value 2 will display both
1909: the shell commands before their invocation, and their
1910: actual execution progress with <span><strong class="command">set -x</strong></span>
1911: will be displayed.</p></li>
1912: <li><p><code class="varname">ALLOW_VULNERABILITIES.<em class="replaceable"><code>pkgbase</code></em></code>:
1913: A space separated list of vulnerability IDs that may be ignored when
1914: performing the automated security checks. These IDs are listed in the
1915: pkg-vulnerabilities file and are displayed by
1916: <span><strong class="command">audit-packages</strong></span> when
1917: it finds a vulnerable package.
1918: </p></li>
1919: <li><p><code class="varname">SKIP_AUDIT_PACKAGES</code>:
1920: If this is set to “<span class="quote">yes</span>”, the automated security checks
1.76 rillig 1921: (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 1922: package) will be <span class="strong"><strong>entirely</strong></span> skipped
1923: for <span class="strong"><strong>all</strong></span> packages built. Normally
1924: you'll want to use ALLOW_VULNERABILITIES instead of this.
1925: </p></li>
1926: </ul></div>
1927: <p>
1928: </p>
1929: </div>
1930: <div class="sect1" lang="en">
1931: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 1932: <a name="selecting-build-options"></a>5.5. Selecting Build Options</h2></div></div></div>
1.75 rillig 1933: <p>Some packages have build time options, usually to select between
1934: different dependencies, enable optional support for big dependencies
1935: or enable experimental features.</p>
1936: <p>To see which options, if any, a package supports, and which
1937: options are mutually exclusive, run <span><strong class="command">make show-options</strong></span>,
1938: for example:</p>
1939: <pre class="programlisting">
1940: The following options are supported by this package:
1941: ssl Enable SSL support.
1942: Exactly one of the following gecko options is required:
1943: firefox Use firefox as gecko rendering engine.
1944: mozilla Use mozilla as gecko rendering engine.
1945: At most one of the following database options may be selected:
1946: mysql Enable support for MySQL database.
1947: pgsql Enable support for PostgreSQL database.
1.1 grant 1948:
1.75 rillig 1949: These options are enabled by default: firefox
1950: These options are currently enabled: mozilla ssl
1.1 grant 1951: </pre>
1.75 rillig 1952: <p>The following variables can be defined in
1.76 rillig 1953: <code class="filename">/etc/mk.conf</code> to select which options to enable
1.75 rillig 1954: for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which can be
1955: used to select or disable options for all packages that support them,
1956: and <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
1957: which can be used to select or disable options specifically for
1958: package <em class="replaceable"><code>pkgbase</code></em>. Options listed in these
1959: variables are selected, options preceded by “<span class="quote">-</span>” are
1960: disabled. A few examples:</p>
1961: <pre class="screen">
1962: <code class="prompt">$</code> <span><strong class="command">grep "PKG.*OPTION" /etc/mk.conf</strong></span>
1963: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
1964: PKG_OPTIONS.kdebase= debug -sasl
1965: PKG_OPTIONS.apache= suexec </pre>
1966: <p>The following settings are consulted in the order given, and the
1967: last setting that selects or disables an option is used:</p>
1968: <div class="orderedlist"><ol type="1">
1969: <li><p>the default options as suggested by the package
1970: maintainer</p></li>
1971: <li><p>the options implied by the settings of legacy
1972: variables (see below)</p></li>
1973: <li><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
1974: <li><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
1975: </ol></div>
1976: <p>For groups of mutually exclusive options, the last option
1977: selected is used, all others are automatically disabled. If an option
1978: of the group is explicitly disabled, the previously selected option,
1979: if any, is used. It is an error if no option from a required group of
1980: options is selected, and building the package will fail.</p>
1981: <p>Before the options framework was introduced, build options were
1982: selected by setting a variable (often named
1983: <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
1.76 rillig 1984: <code class="filename">/etc/mk.conf</code> for each option. To ease transition
1.75 rillig 1985: to the options framework for the user, these legacy variables are
1986: converted to the appropriate options setting
1987: (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
1988: automatically. A warning is issued to prompt the user to
1.76 rillig 1989: update <code class="filename">/etc/mk.conf</code> to use the options framework
1.75 rillig 1990: directly. Support for the legacy variables will be removed
1991: eventually.</p>
1992: </div>
1993: </div>
1994: <div class="chapter" lang="en">
1995: <div class="titlepage"><div><div><h2 class="title">
1996: <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
1997: <div class="toc">
1998: <p><b>Table of Contents</b></p>
1999: <dl>
2000: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
2001: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
2002: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
2003: <dd><dl>
2004: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
2005: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
2006: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
2007: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
2008: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
2009: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
2010: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
2011: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
2012: </dl></dd>
2013: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
2014: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
2015: </dl>
2016: </div>
2017: <div class="sect1" lang="en">
2018: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2019: <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
2020: <p>
2021: Once you have built and installed a package, you can create a
2022: <span class="emphasis"><em>binary package</em></span> which can be installed on
2023: 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
2024: the same package on a group of hosts and wasting CPU time. It
2025: also provides a simple means for others to install your package,
2026: should you distribute it.
2027: </p>
2028: <p>
2029: To create a binary package, change into the appropriate
2030: directory in pkgsrc, and run <span><strong class="command">make
2031: package</strong></span>:
2032: </p>
2033: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
2034: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
2035: <p>
2036: This will build and install your package (if not already done),
2037: and then build a binary package from what was installed. You can
2038: then use the <span><strong class="command">pkg_*</strong></span> tools to manipulate
2039: it. Binary packages are created by default in
1.76 rillig 2040: <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
1.75 rillig 2041: gzipped tar file. See <a href="#logs.package" title="B.2. Packaging figlet">Section B.2, “Packaging figlet”</a> for a
1.76 rillig 2042: 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 2043: <p>
1.77 rillig 2044: See <a href="#submit" title="Chapter 19. Submitting and Committing">Chapter 19, <i>Submitting and Committing</i></a> for information on how to submit
1.75 rillig 2045: such a binary package.</p>
2046: </div>
2047: <div class="sect1" lang="en">
2048: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2049: <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
1.77 rillig 2050: <p>See <a href="#build.helpful-targets" title="15.16. Other helpful targets">Section 15.16, “Other helpful targets”</a>.</p>
1.75 rillig 2051: </div>
2052: <div class="sect1" lang="en">
2053: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2054: <a name="bulkbuild"></a>6.3. Doing a bulk build of all packages</h2></div></div></div>
2055: <p>If you want to get a full set of precompiled binary
2056: packages, this section describes how to get them. Beware that
2057: the bulk build will remove all currently installed packages from
2058: your system!</p>
2059: <p>Having an FTP server configured either on the
2060: machine doing the bulk builds or on a nearby NFS server can help
2061: to make the packages available to other machines that can then
2062: 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
2063: more information. If you use a remote NFS server's storage, be
2064: sure to not actually compile on NFS storage, as this slows
2065: things down a lot.</p>
2066: <div class="sect2" lang="en">
2067: <div class="titlepage"><div><div><h3 class="title">
2068: <a name="binary.configuration"></a>6.3.1. Configuration</h3></div></div></div>
2069: <div class="sect3" lang="en">
2070: <div class="titlepage"><div><div><h4 class="title">
1.76 rillig 2071: <a name="binary.bulk.build.conf"></a>6.3.1.1. <code class="filename">build.conf</code></h4></div></div></div>
2072: <p>The <code class="filename">build.conf</code> file is the main
1.75 rillig 2073: configuration file for bulk builds. You can configure how your
2074: copy of pkgsrc is kept up to date, how the distfiles are
2075: downloaded, how the packages are built and how the report is
2076: generated. You can find an annotated example file in
1.76 rillig 2077: <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
2078: it, copy <code class="filename">build.conf-example</code> to
2079: <code class="filename">build.conf</code> and edit it, following the
1.75 rillig 2080: comments in that file.</p>
2081: </div>
2082: <div class="sect3" lang="en">
2083: <div class="titlepage"><div><div><h4 class="title">
2084: <a name="binary.mk.conf"></a>6.3.1.2. /etc/mk.conf</h4></div></div></div>
2085: <p>You may want to set variables in
1.76 rillig 2086: <code class="filename">/etc/mk.conf</code>.
2087: Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
1.75 rillig 2088: details of the default settings. You will want to ensure that
2089: <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
2090: As used in this example, <code class="varname">_ACCEPTABLE=yes</code>
2091: accepts <span class="emphasis"><em>all</em></span> licenses.</p>
2092: <pre class="programlisting">
2093: PACKAGES?= ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
2094: WRKOBJDIR?= /usr/tmp/pkgsrc # build here instead of in pkgsrc
2095: BSDSRCDIR= /usr/src
2096: BSDXSRCDIR= /usr/xsrc # for x11/xservers
2097: OBJHOSTNAME?= yes # use work.`hostname`
2098: FAILOVER_FETCH= yes # insist on the correct checksum
2099: PKG_DEVELOPER?= yes
2100: _ACCEPTABLE= yes
1.1 grant 2101: </pre>
1.75 rillig 2102: <p>Some options that are especially useful for bulk builds
2103: can be found at the top lines of the file
1.76 rillig 2104: <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
1.75 rillig 2105: options of these are briefly described here.</p>
2106: <div class="itemizedlist"><ul type="disc">
2107: <li><p>If you are on a slow machine, you may want to
2108: set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
2109: “<span class="quote">no</span>”.</p></li>
2110: <li><p>If you are doing bulk builds from a read-only
2111: copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
2112: to the directory where all log files are created. Otherwise the
2113: log files are created in the pkgsrc directory.</p></li>
2114: <li><p>Another important variable is
2115: <code class="varname">BULK_PREREQ</code>, which is a list of packages that
2116: should be always available while building other
2117: packages.</p></li>
2118: </ul></div>
2119: <p>Some other options are scattered in the pkgsrc
2120: infrastructure:</p>
2121: <div class="itemizedlist"><ul type="disc">
2122: <li><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
2123: should be set to <code class="literal">yes</code>. The purpose of the bulk
2124: builds is creating binary packages, no matter if they are
2125: vulnerable or not. When uploading the packages to a public
2126: server, the vulnerable packages will be put into a directory of
2127: their own. Leaving this variable unset would prevent the bulk
2128: build system from even trying to build them, so possible
2129: building errors would not show up.</p></li>
2130: <li><p><code class="varname">CHECK_FILES</code>
1.76 rillig 2131: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75 rillig 2132: “<span class="quote">yes</span>” to check that the installed set of files
1.76 rillig 2133: matches the <code class="filename">PLIST</code>.</p></li>
1.75 rillig 2134: <li><p><code class="varname">CHECK_INTERPRETER</code>
1.76 rillig 2135: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75 rillig 2136: “<span class="quote">yes</span>” to check that the installed
2137: “<span class="quote">#!</span>”-scripts will find their
2138: interpreter.</p></li>
2139: </ul></div>
2140: </div>
2141: <div class="sect3" lang="en">
2142: <div class="titlepage"><div><div><h4 class="title">
1.76 rillig 2143: <a name="pre-build.local"></a>6.3.1.3. <code class="filename">pre-build.local</code></h4></div></div></div>
1.75 rillig 2144: <p>It is possible to configure the bulk build to perform
2145: certain site-specific tasks at the end of the pre-build
2146: stage. If the file
1.76 rillig 2147: <code class="filename">pre-build.local</code> exists in
2148: <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
1.75 rillig 2149: (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
2150: stage. An example use of
1.76 rillig 2151: <code class="filename">pre-build.local</code> is to have the line:</p>
1.75 rillig 2152: <pre class="screen">echo "I do not have enough disk space to build this pig." \
2153: > misc/openoffice/$BROKENF</pre>
2154: <p>to prevent the system from trying to build a particular package
2155: which requires nearly 3 GB of disk space.</p>
2156: </div>
2157: </div>
2158: <div class="sect2" lang="en">
2159: <div class="titlepage"><div><div><h3 class="title">
2160: <a name="other-environmental-considerations"></a>6.3.2. Other environmental considerations</h3></div></div></div>
1.76 rillig 2161: <p>As <code class="filename">/usr/pkg</code> will be completely
1.75 rillig 2162: deleted at the start of bulk builds, make sure your login
2163: shell is placed somewhere else. Either drop it into
1.76 rillig 2164: <code class="filename">/usr/local/bin</code> (and adjust your login
1.75 rillig 2165: shell in the passwd file), or (re-)install it via
1.76 rillig 2166: <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 2167: you can login after a reboot (remember that your current
2168: process won't die if the package is removed, you just can't
2169: start any new instances of the shell any more). Also, if you
2170: use NetBSD earlier than 1.5, or you still want to use the pkgsrc
2171: version of ssh for some reason, be sure to install ssh before
1.76 rillig 2172: starting it from <code class="filename">rc.local</code>:</p>
1.75 rillig 2173: <pre class="programlisting">
2174: ( cd /usr/pkgsrc/security/ssh ; make bulk-install )
2175: if [ -f /usr/pkg/etc/rc.d/sshd ]; then
2176: /usr/pkg/etc/rc.d/sshd
2177: fi
1.1 grant 2178: </pre>
1.75 rillig 2179: <p>Not doing so will result in you being not able to log in
2180: via ssh after the bulk build is finished or if the machine
2181: gets rebooted or crashes. You have been warned! :)</p>
2182: </div>
2183: <div class="sect2" lang="en">
2184: <div class="titlepage"><div><div><h3 class="title">
2185: <a name="operation"></a>6.3.3. Operation</h3></div></div></div>
2186: <p>Make sure you don't need any of the packages still
2187: installed.
2188: </p>
2189: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
2190: <h3 class="title">Warning</h3>
2191: <p>During the bulk build, <span class="emphasis"><em>all packages will be
2192: removed!</em></span></p>
2193: </div>
2194: <p>Be sure to remove all other things that might
2195: interfere with builds, like some libs installed in
1.76 rillig 2196: <code class="filename">/usr/local</code>, etc. then become root and type:</p>
1.75 rillig 2197: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2198: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong></pre>
2199: <p>If for some reason your last build didn't complete (power
2200: failure, system panic, ...), you can continue it by
2201: running:</p>
2202: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
2203: <p>
2204: At the end of the bulk build, you will get a summary via mail,
2205: and find build logs in the directory specified by
1.76 rillig 2206: <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
1.75 rillig 2207: file.
2208: </p>
2209: </div>
2210: <div class="sect2" lang="en">
2211: <div class="titlepage"><div><div><h3 class="title">
2212: <a name="what-it-does"></a>6.3.4. What it does</h3></div></div></div>
2213: <p>The bulk builds consist of three steps:</p>
2214: <div class="variablelist"><dl>
2215: <dt><span class="term">1. pre-build</span></dt>
2216: <dd><p>
2217: The script updates your pkgsrc tree via (anon)cvs, then
2218: cleans out any broken distfiles, and removes all
2219: packages installed.</p></dd>
2220: <dt><span class="term">2. the bulk build</span></dt>
2221: <dd><p>
2222: This is basically “<span class="quote">make bulk-package</span>” with
2223: an optimised order in which packages will be
2224: built. Packages that don't require other packages will
2225: be built first, and packages with many dependencies will
2226: be built later.
2227: </p></dd>
2228: <dt><span class="term">3. post-build</span></dt>
2229: <dd><p>
2230: Generates a report that's placed in the directory
1.76 rillig 2231: specified in the <code class="filename">build.conf</code> file
2232: named <code class="filename">broken.html</code>, a short version
1.75 rillig 2233: of that report will also be mailed to the build's
2234: admin.</p></dd>
2235: </dl></div>
2236: <p>
2237: During the build, a list of broken packages will be compiled
1.76 rillig 2238: in <code class="filename">/usr/pkgsrc/.broken</code> (or
2239: <code class="filename">.../.broken.${MACHINE}</code> if
1.75 rillig 2240: <code class="varname">OBJMACHINE</code> is set), individual build logs
2241: of broken builds can be found in the package's
2242: directory. These files are used by the bulk-targets to mark
2243: broken builds to not waste time trying to rebuild them, and
2244: they can be used to debug these broken package builds
2245: later.
2246: </p>
2247: </div>
2248: <div class="sect2" lang="en">
2249: <div class="titlepage"><div><div><h3 class="title">
2250: <a name="disk-space-requirements"></a>6.3.5. Disk space requirements</h3></div></div></div>
2251: <p>Currently, roughly the following requirements are valid for
2252: NetBSD 2.0/i386:</p>
2253: <div class="itemizedlist"><ul type="disc">
2254: <li><p>
2255: 10 GB - distfiles (NFS ok)
2256: </p></li>
2257: <li><p>
2258: 8 GB - full set of all binaries (NFS ok)
2259: </p></li>
2260: <li><p>
2261: 5 GB - temp space for compiling (local disk recommended)
2262: </p></li>
2263: </ul></div>
2264: <p>
2265: Note that all pkgs will be de-installed as soon as they are
2266: turned into a binary package, and that sources are removed,
2267: so there is no excessively huge demand to disk
2268: space. Afterwards, if the package is needed again, it will
2269: 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
2270: there are no cycles wasted by recompiling.
2271: </p>
2272: </div>
2273: <div class="sect2" lang="en">
2274: <div class="titlepage"><div><div><h3 class="title">
2275: <a name="setting-up-a-sandbox"></a>6.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
2276: <p>
2277: If you don't want all the packages nuked from a machine
2278: (rendering it useless for anything but pkg compiling), there
2279: is the possibility of doing the package bulk build inside a
2280: chroot environment.
2281: </p>
2282: <p>
2283: The first step is to set up a chroot sandbox,
1.76 rillig 2284: e.g. <code class="filename">/usr/sandbox</code>. This can be done by
1.75 rillig 2285: using null mounts, or manually.
2286: </p>
2287: <p>
2288: There is a shell script called
1.76 rillig 2289: <code class="filename">pkgsrc/mk/bulk/mksandbox</code> which will set
1.75 rillig 2290: up the sandbox environment using null mounts. It will also
1.76 rillig 2291: create a script called <code class="filename">sandbox</code> in the
1.75 rillig 2292: root of the sandbox environment, which will allow the null
2293: mounts to be activated using the <span><strong class="command">sandbox
2294: mount</strong></span> command and deactivated using the
2295: <span><strong class="command">sandbox umount</strong></span> command.
2296: </p>
2297: <p>
2298: To set up a sandbox environment by hand, after extracting all
2299: the sets from a NetBSD installation or doing a <span><strong class="command">make
2300: distribution DESTDIR=/usr/sandbox</strong></span> in
1.76 rillig 2301: <code class="filename">/usr/src/etc</code>, be sure the following items
1.75 rillig 2302: are present and properly configured:
2303: </p>
2304: <div class="procedure"><ol type="1">
2305: <li>
2306: <p>Kernel</p>
2307: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
2308: </li>
2309: <li>
1.76 rillig 2310: <p><code class="filename">/dev/*</code></p>
1.75 rillig 2311: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
2312: </li>
2313: <li>
1.76 rillig 2314: <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 2315: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
2316: </li>
2317: <li>
2318: <p>Working(!) mail config (hostname, sendmail.cf):</p>
2319: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
2320: </li>
2321: <li>
1.76 rillig 2322: <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 2323: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
2324: </li>
2325: <li>
1.76 rillig 2326: <p><code class="filename">/usr/src</code> (system sources,
1.78 rillig 2327: 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 2328: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
2329: <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
2330: </li>
2331: <li>
1.76 rillig 2332: <p>Create <code class="filename">/var/db/pkg</code> (not part of default install):</p>
1.75 rillig 2333: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong></pre>
2334: </li>
2335: <li>
1.76 rillig 2336: <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
1.75 rillig 2337: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
2338: </li>
2339: <li>
2340: <p>Checkout pkgsrc via cvs into
1.76 rillig 2341: <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
1.75 rillig 2342: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
2343: <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong></pre>
2344: <p>Do not mount/link this to the copy of your pkgsrc tree
2345: you do development in, as this will likely cause problems!
2346: </p>
2347: </li>
2348: <li><p>Make
1.76 rillig 2349: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
2350: <code class="filename">.../distfiles</code> point somewhere
1.75 rillig 2351: appropriate. NFS- and/or nullfs-mounts may come in handy!
2352: </p></li>
1.76 rillig 2353: <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>
2354: <li><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
1.75 rillig 2355: </ol></div>
2356: <p>When the chroot sandbox is set up, you can start
2357: the build with the following steps:</p>
2358: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2359: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong></pre>
2360: <p>
2361: This will just jump inside the sandbox and start building. At
2362: the end of the build, mail will be sent with the results of
2363: the build. Created binary pkgs will be in
1.76 rillig 2364: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
1.75 rillig 2365: (wherever that points/mounts to/from).</p>
2366: </div>
2367: <div class="sect2" lang="en">
2368: <div class="titlepage"><div><div><h3 class="title">
2369: <a name="building-a-partial-set"></a>6.3.7. Building a partial set of packages</h3></div></div></div>
2370: <p> In addition to building a complete set of all packages in
1.76 rillig 2371: pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
1.75 rillig 2372: may be used to build a subset of the packages contained in
2373: pkgsrc. By setting <code class="varname">SPECIFIC_PKGS</code>
1.76 rillig 2374: in <code class="filename">/etc/mk.conf</code>, the variables</p>
1.75 rillig 2375: <div class="itemizedlist"><ul type="disc">
2376: <li><p>SITE_SPECIFIC_PKGS</p></li>
2377: <li><p>HOST_SPECIFIC_PKGS</p></li>
2378: <li><p>GROUP_SPECIFIC_PKGS</p></li>
2379: <li><p>USER_SPECIFIC_PKGS</p></li>
2380: </ul></div>
2381: <p> will define the set of packages which should be built.
2382: The bulk build code will also include any packages which are
2383: needed as dependencies for the explicitly listed packages.
2384: </p>
2385: <p> One use of this is to do a bulk build with
2386: <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
2387: periodically to have a complete set of the binary packages
2388: needed for your site available without the overhead of
2389: building extra packages that are not needed. </p>
2390: </div>
2391: <div class="sect2" lang="en">
2392: <div class="titlepage"><div><div><h3 class="title">
2393: <a name="bulk-upload"></a>6.3.8. Uploading results of a bulk build</h3></div></div></div>
2394: <p>
2395: This section describes how pkgsrc developers can upload binary
2396: pkgs built by bulk builds to ftp.NetBSD.org.
2397: </p>
2398: <p>
2399: If you would like to automatically create checksum files for the
2400: binary packages you intend to upload, remember to set
2401: <code class="varname">MKSUMS=yes</code> in your
1.76 rillig 2402: <code class="filename">mk/bulk/build.conf</code>.
1.75 rillig 2403: </p>
2404: <p>
2405: If you would like to PGP sign the checksum files (highly
2406: recommended!), remember to set
2407: <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
1.76 rillig 2408: <code class="filename">mk/bulk/build.conf</code>. This will prompt you for
1.75 rillig 2409: your GPG password to sign the files before uploading everything.
2410: </p>
2411: <p>
2412: Then, make sure that you have <code class="varname">RSYNC_DST</code>
1.76 rillig 2413: set properly in your <code class="filename">mk/bulk/build.conf</code>
1.75 rillig 2414: file, i.e. adjust it to something like one of the following:
2415: </p>
2416: <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
2417: <p>Please use appropriate values for "pkgsrc-200xQy",
2418: "NetBSD-a.b.c" and "arch" here. If your login on ftp.NetBSD.org
2419: is different from your local login, write your login directly
2420: into the variable, e.g. my local account is "feyrer", but for my
2421: login "hubertf", I use:</p>
2422: <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
2423: <p>
1.76 rillig 2424: A separate <code class="filename">upload</code> directory is used
1.75 rillig 2425: here to allow "closing" the directory during upload. To do
2426: so, run the following command on ftp.NetBSD.org next:
2427: </p>
2428: <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>
2429: <p>
1.76 rillig 2430: Please note that <code class="filename">/pub/NetBSD/packages</code> is
1.75 rillig 2431: only appropriate for packages for the NetBSD operating
2432: system. Binary packages for other operating systems should go
1.76 rillig 2433: into <code class="filename">/pub/pkgsrc</code>.
1.75 rillig 2434: </p>
2435: <p>
2436: Before uploading the binary pkgs, ssh authentication needs to
2437: be set up. This example shows how to set up temporary keys
2438: for the root account <span class="emphasis"><em>inside the sandbox</em></span>
2439: (assuming that no keys should be present there usually):
2440: </p>
2441: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
2442: chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
2443: chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t dsa</code></strong>
2444: chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong> </pre>
2445: <p>
1.76 rillig 2446: Now take the output of <code class="filename">id-dsa.pub</code> and
2447: append it to your <code class="filename">~/.ssh/authorized_keys</code>
1.75 rillig 2448: file on ftp.NetBSD.org. You can remove the key after the
2449: upload is done!
2450: </p>
2451: <p>
2452: Next, test if your ssh connection really works:
2453: </p>
2454: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
2455: <p>
2456: Use "-l yourNetBSDlogin" here as appropriate!
2457: </p>
2458: <p>
2459: Now after all this works, you can exit the sandbox and start
2460: the upload:
2461: </p>
2462: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
2463: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2464: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong> </pre>
2465: <p>
2466: 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
2467: <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
2468: upload. The upload script will take care of not uploading
2469: restricted packages and putting vulnerable packages into the
1.76 rillig 2470: <code class="filename">vulnerable</code> subdirectory.
1.75 rillig 2471: </p>
2472: <p>
2473: After the upload has ended, first thing is to revoke ssh access:
2474: </p>
2475: <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
2476: Gdd:x! </pre>
2477: <p>
2478: Use whatever is needed to remove the key you've entered
2479: before! Last, move the uploaded packages out of the
1.76 rillig 2480: <code class="filename">upload</code> directory to have them accessible
1.75 rillig 2481: to everyone:
2482: </p>
2483: <pre class="screen">nbftp% <strong class="userinput"><code>cd /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch</code></strong>
2484: nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
2485: nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
2486: nbftp% <strong class="userinput"><code>chmod 755 .</code></strong> </pre>
2487: </div>
2488: </div>
2489: <div class="sect1" lang="en">
2490: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2491: <a name="creating-cdroms"></a>6.4. Creating a multiple CD-ROM packages collection</h2></div></div></div>
2492: <p>
2493: After your pkgsrc bulk-build has completed, you may wish to
2494: create a CD-ROM set of the resulting binary packages to assist
2495: in installing packages on other machines. The
1.76 rillig 2496: <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 2497: a simple tool for creating the ISO 9660 images.
2498: <span><strong class="command">cdpack</strong></span> arranges the packages on the CD-ROMs in a
2499: way that keeps all the dependencies for a given package on the same
2500: CD as that package.
2501: </p>
2502: <div class="sect2" lang="en">
2503: <div class="titlepage"><div><div><h3 class="title">
2504: <a name="cdpack-example"></a>6.4.1. Example of cdpack</h3></div></div></div>
2505: <p>
2506: Complete documentation for cdpack is found in the cdpack(1)
2507: man page. The following short example assumes that the binary
2508: packages are left in
1.76 rillig 2509: <code class="filename">/usr/pkgsrc/packages/All</code> and that
2510: sufficient disk space exists in <code class="filename">/u2</code> to
1.75 rillig 2511: hold the ISO 9660 images.</p>
2512: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
2513: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
2514: <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong></pre>
2515: <p>
2516: If you wish to include a common set of files
1.76 rillig 2517: (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
1.75 rillig 2518: etc.) on each CD in the collection, then you need to create a
2519: directory which contains these files. e.g.
2520: </p>
2521: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
2522: <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" > /tmp/common/README</code></strong>
2523: <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" > /tmp/common/COPYING</code></strong>
2524: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
2525: <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" > /tmp/common/bin/myscript</code></strong>
2526: <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" >> /tmp/common/bin/myscript</code></strong>
2527: <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong></pre>
2528: <p>Now create the images:</p>
2529: <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 2530: <p>Each image will contain <code class="filename">README</code>,
2531: <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
1.75 rillig 2532: in their root directories.</p>
2533: </div>
2534: </div>
2535: </div>
2536: <div class="chapter" lang="en">
2537: <div class="titlepage"><div><div><h2 class="title">
2538: <a name="faq"></a>Chapter 7. Frequently Asked Questions</h2></div></div></div>
2539: <div class="toc">
2540: <p><b>Table of Contents</b></p>
2541: <dl>
2542: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
2543: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
2544: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
2545: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
2546: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
2547: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
2548: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
2549: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
2550: <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>
2551: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
2552: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
2553: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
2554: <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>
2555: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
2556: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
2557: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
2558: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
1.80 ! rillig 2559: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.75 rillig 2560: </dl>
2561: </div>
2562: <p>This section contains hints, tips & tricks on special things in
2563: pkgsrc that we didn't find a better place for in the previous chapters, and
2564: it contains items for both pkgsrc users and developers.</p>
2565: <div class="sect1" lang="en">
2566: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2567: <a name="mailing-list-pointers"></a>7.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
2568: <p>The following mailing lists may be of interest to pkgsrc users:</p>
2569: <div class="itemizedlist"><ul type="disc">
1.78 rillig 2570: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-users" target="_top">pkgsrc-users</a>:
2571: This is a general purpose list for most issues regarding
2572: pkgsrc, regardless of platform, e.g. soliciting user help
2573: for pkgsrc configuration, unexpected build failures, using
2574: particular packages, upgrading pkgsrc installations,
2575: questions regarding the pkgsrc release branches, etc. General announcements or
2576: proposals for changes that impact the pkgsrc user community,
2577: e.g. major infrastructure changes, new features, package
2578: removals, etc., may also be posted.</p></li>
1.75 rillig 2579: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
2580: A list where the results of pkgsrc bulk builds are sent and
2581: discussed.</p></li>
2582: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
2583: This list is for those who are interested in getting a
2584: commit message for every change committed to pkgsrc. It is
2585: also available in digest form, meaning one daily message
2586: containing all commit messages for changes to the package
2587: source tree in that 24 hour period.</p></li>
2588: </ul></div>
2589: <p>To subscribe, do:</p>
2590: <pre class="programlisting">
2591: <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
2592: </pre>
2593: <p>Archives for all these mailing lists are available from
2594: <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
2595: </div>
2596: <div class="sect1" lang="en">
2597: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2598: <a name="pkgviews-docs"></a>7.2. Where's the pkgviews documentation?</h2></div></div></div>
2599: <p>Pkgviews is tightly integrated with buildlink. You can find a
2600: pkgviews User's guide in
1.76 rillig 2601: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
1.75 rillig 2602: </div>
2603: <div class="sect1" lang="en">
2604: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2605: <a name="faq-pkgtools"></a>7.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.80 ! rillig 2606: <p>The directory <code class="filename">pkgsrc/pkgtools</code> contains
1.75 rillig 2607: a number of useful utilities for both users and developers of pkgsrc. This
2608: section attempts only to make the reader aware of the utilities and when
2609: they might be useful, and not to duplicate the documentation that comes
2610: with each package.</p>
2611: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
1.76 rillig 2612: <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 2613: Symlinks for use by buildlink.</p></li></ul></div>
2614: <p>OS tool augmentation (automatically installed when needed):</p>
2615: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2616: <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 2617: Calculates various kinds of checksums (including SHA1).</p></li>
1.76 rillig 2618: <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 2619: Compatibility library for pkgsrc tools.</p></li>
1.76 rillig 2620: <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 2621: non-BSD systems due to lack of native mtree.
2622: </p></li>
1.76 rillig 2623: <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 2624: Up-to-date replacement for
1.76 rillig 2625: <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
1.75 rillig 2626: systems where pkg_install is not present.</p></li>
2627: </ul></div>
2628: <p>Utilities used by pkgsrc (not automatically installed):</p>
2629: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2630: <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 2631: Create a binary package from an
2632: already-installed package. Used by <span><strong class="command">make replace</strong></span> to
2633: save the old package.</p></li>
1.76 rillig 2634: <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 2635: Adds extra functionality to pkgsrc, allowing it to fetch distfiles
2636: from multiple locations. It currently supports the following
2637: methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
1.76 rillig 2638: <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 2639: packages someplace else (enabled by default).</p></li>
1.76 rillig 2640: <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 2641: best compiler flags to optimise code for your current CPU and
2642: compiler.</p></li>
2643: </ul></div>
2644: <p>Utilities for keeping track of installed packages, being up to date,
2645: etc:</p>
2646: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2647: <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 2648: packages whose installed versions do not match the latest pkgsrc
2649: entries.</p></li>
1.76 rillig 2650: <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 2651: dependency graphs of packages, to aid in choosing a strategy for
2652: updating.</p></li>
1.76 rillig 2653: <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
2654: 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>
2655: <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 2656: pkglint(1) program checks a pkgsrc entry for errors, lintpkgsrc(1)
2657: does various checks on the complete pkgsrc system.</p></li>
1.76 rillig 2658: <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 2659: packages you have installed.</p></li>
2660: </ul></div>
2661: <p>Utilities for people maintaining or creating individual packages:</p>
2662: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2663: <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 2664: making and maintaining patches for a package (includes pkgdiff,
2665: pkgvi, mkpatches, etc.).</p></li>
1.76 rillig 2666: <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>,
2667: <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 2668: converting to pkgsrc.</p></li>
1.76 rillig 2669: <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 2670: pkgsrc to a Solaris package.</p></li>
2671: </ul></div>
2672: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
2673: utilities)</p>
2674: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2675: <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 2676: packages in a chrooted area.</p></li>
1.76 rillig 2677: <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 2678: kernel version for chrooted cross builds.</p></li>
2679: </ul></div>
2680: </div>
2681: <div class="sect1" lang="en">
2682: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2683: <a name="non-root-pkgsrc"></a>7.4. How to use pkgsrc as non-root</h2></div></div></div>
2684: <p>If you want to use pkgsrc as non-root user, you can set some
2685: variables to make pkgsrc work under these conditions. At the very least,
2686: you need to set <code class="varname">UNPRIVILEGED</code> to “<span class="quote">yes</span>”; this
2687: will turn on unprivileged mode and set multiple related variables to allow
2688: installation of packages as non-root.</p>
2689: <p>In case the defaults are not enough, you may want to tune some other
2690: variables used. For example, if the automatic user/group detection leads
2691: to incorrect values (or not the ones you would like to use), you can change
2692: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
2693: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
2694: <p>As regards bootstrapping, please note that the
2695: <span><strong class="command">bootstrap</strong></span> script will ease non-root configuration when
2696: given the “<span class="quote">--ignore-user-check</span>” flag, as it will choose and
1.76 rillig 2697: use multiple default directories under <code class="filename">~/pkg</code> as the
1.75 rillig 2698: installation targets. These directories can be overriden by the
2699: “<span class="quote">--prefix</span>” flag provided by the script, as well as some others
2700: that allow finer tuning of the tree layout.</p>
2701: </div>
2702: <div class="sect1" lang="en">
2703: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2704: <a name="resume-transfers"></a>7.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
2705: <p>By default, resuming transfers in pkgsrc is disabled, but you can
2706: enable this feature by adding the option
2707: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.76 rillig 2708: <code class="filename">/etc/mk.conf</code>. If, during a fetch step, an incomplete
1.75 rillig 2709: distfile is found, pkgsrc will try to resume it.</p>
2710: <p>You can also
2711: 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
2712: <code class="varname">FETCH_CMD</code> variable. Don't forget to set
2713: <code class="varname">FETCH_RESUME_ARGS</code> and
2714: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
2715: values.</p>
2716: <p>For example, if you want to use
1.76 rillig 2717: <code class="filename">wget</code> to resume downloads, you'll have to use something
1.75 rillig 2718: like:</p>
2719: <pre class="programlisting">
2720: FETCH_CMD= wget
2721: FETCH_BEFORE_ARGS= --passive-ftp
2722: FETCH_RESUME_ARGS= -c
2723: FETCH_OUTPUT_ARGS= -O
1.1 grant 2724: </pre>
1.75 rillig 2725: </div>
2726: <div class="sect1" lang="en">
2727: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2728: <a name="XFree86-from-pkgsrc"></a>7.6. How can I install/use XFree86 from pkgsrc?</h2></div></div></div>
2729: <p>If you want to use XFree86 from pkgsrc instead of your system's own
1.76 rillig 2730: X11 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>,
1.75 rillig 2731: ...), you will have to add the following line into
1.76 rillig 2732: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2733: <pre class="programlisting">
2734: X11_TYPE=XFree86
1.1 grant 2735: </pre>
1.75 rillig 2736: </div>
2737: <div class="sect1" lang="en">
2738: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2739: <a name="x.org-from-pkgsrc"></a>7.7. How can I install/use X.org from pkgsrc?</h2></div></div></div>
2740: <p>If you want to use X.org from pkgsrc instead of your system's own X11
1.76 rillig 2741: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
1.75 rillig 2742: you will have to add the following line into
1.76 rillig 2743: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2744: <pre class="programlisting">
2745: X11_TYPE=xorg
1.1 grant 2746: </pre>
1.75 rillig 2747: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
2748: <h3 class="title">Note</h3>
2749: <p>The DragonFly operating system defaults to using
2750: this X.org X11 implementation from pkgsrc.
2751: </p>
2752: </div>
2753: </div>
2754: <div class="sect1" lang="en">
2755: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2756: <a name="fetch-behind-firewall"></a>7.8. How to fetch files from behind a firewall</h2></div></div></div>
2757: <p>If you are sitting behind a firewall which does not allow direct
2758: connections to Internet hosts (i.e. non-NAT), you may specify the
2759: relevant proxy hosts. This is done using an environment variable in the
2760: form of a URL, e.g. in Amdahl, the machine
2761: “<span class="quote">orpheus.amdahl.com</span>” is one of the firewalls, and it uses
2762: port 80 as the proxy port number. So the proxy environment variables
2763: are:</p>
2764: <pre class="programlisting">
2765: ftp_proxy=ftp://orpheus.amdahl.com:80/
2766: http_proxy=http://orpheus.amdahl.com:80/
1.1 grant 2767: </pre>
1.75 rillig 2768: </div>
2769: <div class="sect1" lang="en">
2770: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2771: <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>
2772: <p>This depends on which utility is used to retrieve distfiles. From
1.76 rillig 2773: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
1.75 rillig 2774: the first available command from the following list:</p>
2775: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2776: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
2777: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
1.75 rillig 2778: </ul></div>
2779: <p>On a default NetBSD installation, this will be
1.76 rillig 2780: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
1.75 rillig 2781: connections first, and falls back to active connections if the server
2782: refuses to do passive. For the other tools, add the following to your
1.76 rillig 2783: <code class="filename">/etc/mk.conf</code> file:
1.75 rillig 2784: <code class="varname">PASSIVE_FETCH=1</code>.</p>
2785: <p>Having that option present will prevent
1.76 rillig 2786: <code class="filename">/usr/bin/ftp</code> from falling back to active
1.75 rillig 2787: transfers.</p>
2788: </div>
2789: <div class="sect1" lang="en">
2790: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2791: <a name="fetching-all-distfiles"></a>7.10. How to fetch all distfiles at once</h2></div></div></div>
2792: <p>You would like to download all the distfiles in a single batch from
2793: work or university, where you can't run a <span><strong class="command">make fetch</strong></span>.
2794: There is an archive of distfiles on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/" target="_top">ftp.NetBSD.org</a>,
2795: but downloading the entire directory may not be appropriate.</p>
2796: <p>The answer here is to do a <span><strong class="command">make fetch-list</strong></span> in
1.76 rillig 2797: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
1.75 rillig 2798: resulting list to your machine at work/school and use it there. If you
2799: 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
2800: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
2801: URL:</p>
2802: <p>At home:</p>
2803: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2804: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh</code></strong>
2805: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
2806: <p>At work:</p>
2807: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
1.76 rillig 2808: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
1.75 rillig 2809: home.</p>
2810: <p>If you have a machine running NetBSD, and you want to get
2811: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your machine
2812: architecture), you can do so by using the above-mentioned <span><strong class="command">make
2813: fetch-list</strong></span> approach, or fetch the distfiles directly by
2814: running:</p>
2815: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
2816: <p>If you even decide to ignore
2817: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
2818: by running:</p>
2819: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
2820: </div>
2821: <div class="sect1" lang="en">
2822: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2823: <a name="tmac.andoc-missing"></a>7.11. What does “<span class="quote">Don't know how to make
2824: /usr/share/tmac/tmac.andoc</span>” mean?</h2></div></div></div>
1.76 rillig 2825: <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 2826: package, you get the error from make that it doesn't know how to make
1.76 rillig 2827: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
1.75 rillig 2828: you don't have installed the “<span class="quote">text</span>” set (nroff, ...) from
2829: the NetBSD base distribution on your machine. It is recommended to do
2830: that to format man pages.</p>
1.76 rillig 2831: <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 2832: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.76 rillig 2833: environment or in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 2834: </div>
2835: <div class="sect1" lang="en">
2836: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2837: <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 2838: <p> You didn't install the compiler set, <code class="filename">comp.tgz</code>,
1.75 rillig 2839: when you installed your NetBSD machine. Please get and install it, by
1.76 rillig 2840: extracting it in <code class="filename">/</code>:</p>
1.75 rillig 2841: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
2842: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
1.76 rillig 2843: <p><code class="filename">comp.tgz</code> is part of every NetBSD release. Get
1.75 rillig 2844: the one that corresponds to your release (determine via <span><strong class="command">uname
2845: -r</strong></span>).</p>
2846: </div>
2847: <div class="sect1" lang="en">
2848: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2849: <a name="using-sudo-with-pkgsrc"></a>7.13. Using 'sudo' with pkgsrc</h2></div></div></div>
2850: <p>When installing packages as non-root user and using the just-in-time
2851: <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
2852: password for each required package installed. To avoid this, the sudo
2853: package can be used, which does password caching over a limited time. To
2854: use it, install sudo (either as binary package or from
1.76 rillig 2855: <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
2856: into your <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2857: <pre class="programlisting">
2858: .if exists(${LOCALBASE}/bin/sudo)
2859: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
2860: .endif
1.1 grant 2861: </pre>
1.75 rillig 2862: </div>
2863: <div class="sect1" lang="en">
2864: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2865: <a name="faq.conf"></a>7.14. How do I change the location of configuration files?</h2></div></div></div>
2866: <p>As the system administrator, you can choose where configuration files
2867: are installed. The default settings make all these files go into
1.76 rillig 2868: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
1.75 rillig 2869: be suboptimal depending on your expectations (e.g., a read-only,
2870: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
2871: configuration of the provided packages).</p>
2872: <p>In order to change the defaults, you can modify the
2873: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.76 rillig 2874: <code class="filename">/etc/mk.conf</code>) to point to your preferred configuration
2875: directory; some common examples include <code class="filename">/etc</code> or
2876: <code class="filename">/etc/pkg</code>.</p>
1.75 rillig 2877: <p>Furthermore, you can change this value on a per-package basis by
2878: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
2879: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
2880: package you would like to modify, that is, the contents of
2881: <code class="varname">PKGBASE</code>.</p>
2882: <p>Note that after changing these settings, you must rebuild and
2883: reinstall any affected packages.</p>
2884: </div>
2885: <div class="sect1" lang="en">
2886: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2887: <a name="audit-packages"></a>7.15. Automated security checks</h2></div></div></div>
2888: <p>Please be aware that there can often be bugs in third-party software,
2889: and some of these bugs can leave a machine vulnerable to exploitation by
2890: attackers. In an effort to lessen the exposure, the NetBSD packages team
2891: maintains a database of known-exploits to packages which have at one time
2892: been included in pkgsrc. The database can be downloaded automatically, and
2893: a security audit of all packages installed on a system can take place. To
1.76 rillig 2894: 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 2895: components:</p>
2896: <div class="orderedlist"><ol type="1">
2897: <li>
2898: <p><span><strong class="command">download-vulnerability-list</strong></span>, an easy way to
2899: download a list of the security vulnerabilities information. This list
2900: is kept up to date by the NetBSD security officer and the NetBSD
2901: packages team, and is distributed from the NetBSD ftp server:</p>
2902: <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>
2903: </li>
2904: <li><p><span><strong class="command">audit-packages</strong></span>, an easy way to audit the
2905: current machine, checking each vulnerability which is known. If a
2906: vulnerable package is installed, it will be shown by output to stdout,
2907: including a description of the type of vulnerability, and a URL
2908: containing more information.</p></li>
2909: </ol></div>
1.76 rillig 2910: <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 2911: package is strongly recommended! After
2912: “<span class="quote">audit-packages</span>” is installed, please read
2913: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
2914: audit-packages</code></strong>.</p>
2915: <p>If this package is installed, pkgsrc builds will use it to perform
2916: a security check before building any package. See
2917: <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.
2918: </p>
2919: </div>
2920: <div class="sect1" lang="en">
2921: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2922: <a name="ufaq-cflags"></a>7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
2923: <p>When you add your own preferences to the
2924: <code class="varname">CFLAGS</code> variable in your
1.76 rillig 2925: <code class="filename">mk.conf</code>, these flags are passed in
2926: environment variables to the <code class="filename">./configure</code>
1.75 rillig 2927: 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
2928: <code class="varname">CFLAGS</code> from the environment variable by
1.76 rillig 2929: overriding them in the <code class="filename">Makefile</code>s of their
1.75 rillig 2930: package.</p>
2931: <p>Currently there is no solution to this problem. If you
2932: really need the package to use your <code class="varname">CFLAGS</code>
2933: you should run <span><strong class="command">make patch</strong></span> in the package
1.76 rillig 2934: directory and then inspect any <code class="filename">Makefile</code> and
2935: <code class="filename">Makefile.in</code> for whether they define
1.75 rillig 2936: <code class="varname">CFLAGS</code> explicitly. Usually you can remove
2937: these lines. But be aware that some “<span class="quote">smart</span>”
2938: programmers write so bad code that it only works for the
2939: specific combination of <code class="varname">CFLAGS</code> they have
2940: chosen.</p>
2941: </div>
1.80 ! rillig 2942: <div class="sect1" lang="en">
! 2943: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 2944: <a name="ufaq-fail"></a>7.17. A package does not build. What shall I do?</h2></div></div></div>
! 2945: <div class="procedure"><ol type="1">
! 2946: <li><p>Make sure that your copy of pkgsrc is consistent. A
! 2947: case that occurs often is that people only update pkgsrc in
! 2948: parts, because of performance reasons. Since pkgsrc is one large
! 2949: system, not a collection of many small systems, there are
! 2950: sometimes changes that only work when the whole pkgsrc tree is
! 2951: updated.</p></li>
! 2952: <li><p>Make sure that you don't have any CVS conflicts.
! 2953: Search for “<span class="quote"><<<<<<</span>” or
! 2954: “<span class="quote">>>>>>></span>” in all your pkgsrc
! 2955: files.</p></li>
! 2956: <li><p>Make sure that you don't have old copies of the packages
! 2957: extracted. Run <span><strong class="command">make clean clean-depends</strong></span> to
! 2958: verify this.</p></li>
! 2959: <li><p>If the problem still exists, write a mail to the
! 2960: <code class="literal">pkgsrc-users</code> mailing list.</p></li>
! 2961: </ol></div>
! 2962: </div>
1.75 rillig 2963: </div>
2964: </div>
2965: <div class="part" lang="en">
2966: <div class="titlepage"><div><div><h1 class="title">
2967: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
1.77 rillig 2968: <div class="partintro" lang="en">
2969: <div></div>
2970: <p>This part of the book deals with creating and
2971: modifying packages. It starts with a “<span class="quote">HOWTO</span>”-like
2972: guide on creating a new package. The remaining chapters are more
2973: like a reference manual for pkgsrc.</p>
1.75 rillig 2974: <div class="toc">
2975: <p><b>Table of Contents</b></p>
2976: <dl>
1.77 rillig 2977: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
2978: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75 rillig 2979: <dd><dl>
1.77 rillig 2980: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
2981: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
2982: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
2983: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
2984: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 2985: <dd><dl>
2986: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
2987: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
2988: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
2989: </dl></dd>
1.77 rillig 2990: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
2991: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
2992: </dl></dd>
2993: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
2994: <dd><dl>
2995: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
2996: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
2997: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
2998: <dd><dl>
2999: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
3000: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
3001: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
3002: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
3003: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
3004: </dl></dd>
3005: </dl></dd>
3006: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
3007: <dd><dl>
3008: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
3009: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
3010: <dt><span class="sect1"><a href="#print-PLIST">11.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
3011: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
3012: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
3013: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
3014: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
3015: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
3016: </dl></dd>
3017: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
3018: <dd><dl>
3019: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
3020: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
3021: <dd><dl>
3022: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
3023: <dt><span class="sect2"><a href="#updating-buildlink-depends">12.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>
3024: </dl></dd>
3025: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
3026: <dd><dl>
3027: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">12.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
3028: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
3029: </dl></dd>
3030: </dl></dd>
3031: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
3032: <dd><dl>
3033: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
3034: <dd><dl>
3035: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
3036: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
3037: </dl></dd>
3038: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
3039: <dd><dl>
3040: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
3041: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
3042: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
3043: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
3044: </dl></dd>
3045: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
3046: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">13.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
3047: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
3048: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
3049: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
3050: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
3051: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">13.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
3052: </dl></dd>
3053: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
3054: <dd><dl>
3055: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
3056: <dt><span class="sect1"><a href="#converting-to-options">14.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
3057: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
3058: </dl></dd>
3059: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
3060: <dd><dl>
3061: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
3062: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
3063: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
3064: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
3065: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
3066: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
3067: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
3068: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
3069: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
3070: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
3071: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
3072: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3073: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
3074: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3075: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
3076: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
3077: </dl></dd>
3078: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
3079: <dd><dl>
3080: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
3081: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
3082: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
3083: </dl></dd>
3084: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
3085: <dd><dl>
3086: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
3087: <dd><dl>
1.78 rillig 3088: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
3089: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">17.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
3090: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
3091: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
3092: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
3093: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
3094: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
3095: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
3096: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
3097: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
3098: <dt><span class="sect2"><a href="#bumping-pkgrevision">17.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
1.79 rillig 3099: <dt><span class="sect2"><a href="#fixes.subst">17.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
1.77 rillig 3100: </dl></dd>
3101: <dt><span class="sect1"><a href="#fixes.fetch">17.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
3102: <dd><dl>
3103: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
3104: <dt><span class="sect2"><a href="#modified-distfiles-same-name">17.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
3105: </dl></dd>
3106: <dt><span class="sect1"><a href="#fixes.configure">17.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
3107: <dd><dl>
3108: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
3109: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
3110: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
3111: </dl></dd>
3112: <dt><span class="sect1"><a href="#fixes.build">17.4. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3113: <dd><dl>
1.78 rillig 3114: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
3115: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
3116: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
3117: </dl></dd>
3118: <dt><span class="sect1"><a href="#fixes.install">17.5. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3119: <dd><dl>
3120: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
3121: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
3122: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
3123: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
3124: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
3125: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
3126: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
3127: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
3128: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
3129: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
3130: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
3131: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
3132: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
3133: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
3134: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
3135: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
3136: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.77 rillig 3137: </dl></dd>
1.78 rillig 3138: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.77 rillig 3139: </dl></dd>
3140: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
3141: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
3142: <dd><dl>
3143: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
3144: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
3145: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
3146: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
3147: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
3148: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 3149: </dl></dd>
1.77 rillig 3150: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.75 rillig 3151: </dl>
3152: </div>
1.77 rillig 3153: </div>
3154: <div class="chapter" lang="en">
3155: <div class="titlepage"><div><div><h2 class="title">
3156: <a name="creating"></a>Chapter 8. Creating a new pkgsrc package from scratch</h2></div></div></div>
3157: <p>When you find a package that is not yet in pkgsrc, you
3158: most likely have a URL from where you can download the source
3159: code. Starting with this URL, creating a package involves only a
3160: few steps.</p>
3161: <div class="procedure"><ol type="1">
3162: <li><p>First, install the packages <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a> and <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>.</p></li>
3163: <li><p>Then, choose one of the top-level directories as the
3164: category in which you want to place your package. You can also
3165: create a directory of your own (maybe called
3166: <code class="filename">local</code>). In that category directory, create
3167: another directory for your package and change into
3168: it.</p></li>
3169: <li><p>Run the program <span><strong class="command">url2pkg</strong></span>, which
3170: will ask you for a URL. Enter the URL of the distribution file
3171: (in most cases a <code class="filename">.tar.gz</code> file) and watch
3172: how the basic ingredients of your package are created
3173: automatically. The distribution file is extracted automatically
3174: to fill in some details in the <code class="filename">Makefile</code>
3175: that would otherwise have to be done manually.</p></li>
3176: <li>
3177: <p>Examine the extracted files to determine the
3178: dependencies of your package. Ideally, this is mentioned in some
3179: <code class="filename">README</code> file, but things may differ. For
3180: each of these dependencies, look where it exists in pkgsrc, and
3181: if there is a file called <code class="filename">buildlink3.mk</code> in
3182: that directory, add a line to your package
3183: <code class="filename">Makefile</code> which includes that file just
3184: before the last line. If the <code class="filename">buildlink3.mk</code>
3185: file does not exist, add a <code class="varname">DEPENDS</code> line to
3186: the Makefile, which specifies the version of the dependency and
3187: where it can be found in pkgsrc. This line should be placed in
3188: the third paragraph. If the dependency is only needed for
3189: building the package, but not when using it, use
3190: <code class="varname">BUILD_DEPENDS</code> instead of
3191: <code class="varname">DEPENDS</code>. Your package may then look like
3192: this:</p>
3193: <pre class="programlisting">
3194: [...]
3195:
3196: BUILD_DEPENDS+= lua>=5.0:../../lang/lua
3197: DEPENDS+= screen-[0-9]*:../../misc/screen
3198: DEPENDS+= screen>=4.0:../../misc/screen
3199:
3200: [...]
3201:
3202: .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
3203: .include "../../devel/glib2/buildlink3.mk"
3204: .include "../../mk/bsd.pkg.mk"
3205: </pre>
3206: </li>
3207: <li><p>Run <span><strong class="command">pkglint</strong></span> to see what things
3208: still need to be done to make your package a “<span class="quote">good</span>”
3209: one. If you don't know what pkglint's warnings want to tell you,
3210: try <span><strong class="command">pkglint --explain</strong></span> or <span><strong class="command">pkglint
3211: -e</strong></span>, which outputs additional
3212: explanations.</p></li>
3213: <li><p>Now, run <span><strong class="command">bmake</strong></span> to build the
3214: package. For the various things that can go wrong in this phase,
3215: consult <a href="#fixes" title="Chapter 17. Making your package work">Chapter 17, <i>Making your package work</i></a>.</p></li>
3216: <li><p>When the package builds fine, the next step is to
3217: install the package. Run <span><strong class="command">bmake install</strong></span> and
3218: hope that everything works.</p></li>
3219: <li><p>Up to now, the file <code class="filename">PLIST</code>,
3220: which contains a list of the files that are installed by the
3221: package, is nearly empty. Run <span><strong class="command">bmake print-PLIST
3222: >PLIST</strong></span> to generate a probably correct list. Check
3223: the file using your preferred text editor to see if the list of
3224: files looks plausible.</p></li>
3225: <li><p>Run <span><strong class="command">pkglint</strong></span> again to see if the
3226: generated <code class="filename">PLIST</code> contains garbage or
3227: not.</p></li>
3228: <li><p>When you ran <span><strong class="command">bmake install</strong></span>, the
3229: package has been registered in the database of installed files,
3230: but with an empty list of files. To fix this, run <span><strong class="command">bmake
3231: deinstall</strong></span> and <span><strong class="command">bmake install</strong></span> again.
3232: Now the package is registered with the list of files from
3233: <code class="filename">PLIST</code>.</p></li>
3234: <li><p>Run <span><strong class="command">bmake package</strong></span> to create a
3235: binary package from the set of installed files.</p></li>
3236: </ol></div>
3237: </div>
1.75 rillig 3238: <div class="chapter" lang="en">
3239: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3240: <a name="components"></a>Chapter 9. Package components - files, directories and contents</h2></div></div></div>
1.75 rillig 3241: <div class="toc">
3242: <p><b>Table of Contents</b></p>
3243: <dl>
1.77 rillig 3244: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
3245: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
3246: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
3247: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
3248: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 3249: <dd><dl>
3250: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
3251: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
3252: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
3253: </dl></dd>
1.77 rillig 3254: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
3255: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
1.75 rillig 3256: </dl>
3257: </div>
3258: <p> Whenever you're preparing a package, there are a number of
3259: files involved which are described in the following
3260: sections. </p>
3261: <div class="sect1" lang="en">
3262: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3263: <a name="components.Makefile"></a>9.1. <code class="filename">Makefile</code></h2></div></div></div>
1.75 rillig 3264: <p>Building, installation and creation of a binary package are all
1.76 rillig 3265: controlled by the package's <code class="filename">Makefile</code>.
3266: The <code class="filename">Makefile</code> describes various things about
1.75 rillig 3267: a package, for example from where to get it, how to configure,
3268: build, and install it.
3269: </p>
1.76 rillig 3270: <p>A package <code class="filename">Makefile</code> contains several
1.75 rillig 3271: sections that describe the package.</p>
3272: <p>In the first section there are the following variables, which
3273: should appear exactly in the order given here.
3274: </p>
3275: <div class="itemizedlist"><ul type="disc">
3276: <li><p><code class="varname">DISTNAME</code> is the basename of the
3277: distribution file to be downloaded from the package's
3278: website.</p></li>
3279: <li><p><code class="varname">PKGNAME</code> is the name of the
3280: package, as used by pkgsrc. You only need to provide it if it
3281: differs from <code class="varname">DISTNAME</code>. Usually it is the directory name together
3282: with the version number. It must match the regular expression
3283: <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
3284: starts with a letter or digit, and contains only letters, digits,
3285: dashes, underscores, dots and plus signs.</p></li>
3286: <li>
3287: <p><code class="varname">CATEGORIES</code> is a list of categories
3288: which the package fits in. You can choose any of the top-level
3289: directories of pkgsrc for it.</p>
3290: <p>Currently the following values are available for
3291: <code class="varname">CATEGORIES</code>. If more than
3292: one is used, they need to be separated by spaces:</p>
3293: <pre class="programlisting">
3294: archivers cross geography meta-pkgs security
3295: audio databases graphics misc shells
3296: benchmarks devel ham multimedia sysutils
3297: biology editors inputmethod net textproc
3298: cad emulators lang news time
3299: chat finance mail parallel wm
3300: comms fonts math pkgtools www
3301: converters games mbone print x11
1.1 grant 3302: </pre>
1.75 rillig 3303: </li>
3304: <li>
3305: <p><code class="varname">MASTER_SITES</code> is a list of URLs where
3306: the distribution files can be downloaded. Each URL must end with a
3307: slash.</p>
3308: <p>The <code class="varname">MASTER_SITES</code> may make use of
3309: the following predefined sites:</p>
3310: <pre class="programlisting">
3311: ${MASTER_SITE_APACHE}
3312: ${MASTER_SITE_BACKUP}
3313: ${MASTER_SITE_CYGWIN}
3314: ${MASTER_SITE_DEBIAN}
3315: ${MASTER_SITE_FREEBSD}
3316: ${MASTER_SITE_FREEBSD_LOCAL}
3317: ${MASTER_SITE_GNOME}
3318: ${MASTER_SITE_GNU}
3319: ${MASTER_SITE_GNUSTEP}
3320: ${MASTER_SITE_IFARCHIVE}
3321: ${MASTER_SITE_MOZILLA}
3322: ${MASTER_SITE_OPENOFFICE}
3323: ${MASTER_SITE_PERL_CPAN}
3324: ${MASTER_SITE_R_CRAN}
3325: ${MASTER_SITE_SOURCEFORGE}
3326: ${MASTER_SITE_SUNSITE}
3327: ${MASTER_SITE_SUSE}
3328: ${MASTER_SITE_TEX_CTAN}
3329: ${MASTER_SITE_XCONTRIB}
3330: ${MASTER_SITE_XEMACS}
1.74 rillig 3331: </pre>
1.75 rillig 3332: <p>If one of these predefined sites is chosen, you may
3333: want to specify a subdirectory of that
3334: site. Since these macros may expand to more than one
3335: actual site, you <span class="emphasis"><em>must</em></span> use the
3336: following construct to specify a subdirectory:</p>
3337: <pre class="programlisting">
3338: ${MASTER_SITE_GNU:=subdirectory/name/}
3339: ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1 grant 3340: </pre>
1.75 rillig 3341: <p>Note the trailing slash after the subdirectory name.</p>
3342: <p>If the package has multiple
3343: <code class="varname">DISTFILES</code> or multiple
3344: <code class="varname">PATCHFILES</code> from different
3345: sites, set <code class="varname">SITES.foo</code> to a list of URIs
3346: where file “<span class="quote">foo</span>” may be
3347: found. “<span class="quote">foo</span>” includes the suffix, e.g.:</p>
3348: <pre class="programlisting">
3349: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
3350: DISTFILES+= foo-file.tar.gz
3351: SITES.foo-file.tar.gz= \
3352: http://www.somewhere.com/somehow/ \
3353: http://www.somewhereelse.com/mirror/somehow/
1.1 grant 3354: </pre>
1.75 rillig 3355: </li>
3356: <li>
3357: <p><code class="varname">DISTFILES</code>: Name(s)
3358: of archive file(s) containing distribution. The default is
1.76 rillig 3359: <code class="filename">${DISTNAME}${EXTRACT_SUFX}</code>. Should only
1.75 rillig 3360: be set if you have more than one distfile.</p>
3361: <p>Note that the normal default setting of
3362: <code class="varname">DISTFILES</code> must be made explicit if you
3363: want to add to it (rather than replace it), as you usually
3364: would.</p>
3365: </li>
3366: <li><p><code class="varname">EXTRACT_SUFX</code>: Suffix of the
3367: distribution file, will be appended to
3368: <code class="varname">DISTNAME</code>. Defaults to
1.76 rillig 3369: <code class="filename">.tar.gz</code>.
1.75 rillig 3370: </p></li>
3371: </ul></div>
3372: <p>
3373: </p>
3374: <p>The second section contains information about separately
3375: downloaded patches, if any.
3376: </p>
3377: <div class="itemizedlist"><ul type="disc">
3378: <li><p><code class="varname">PATCHFILES:</code>
3379: Name(s) of additional files that contain distribution patches.
3380: There is no default. pkgsrc will look for them at
3381: <code class="varname">PATCH_SITES</code>.
3382: They will automatically be uncompressed before patching if
1.76 rillig 3383: the names end with <code class="filename">.gz</code> or
3384: <code class="filename">.Z</code>.</p></li>
1.75 rillig 3385: <li><p><code class="varname">PATCH_SITES</code>:
3386: Primary location(s) for distribution patch files (see
3387: <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
3388: </ul></div>
3389: <p>
3390: </p>
3391: <p>The third section contains the following variables.
3392: </p>
3393: <div class="itemizedlist"><ul type="disc">
3394: <li><p><code class="varname">MAINTAINER</code> is the email address
3395: of the person who feels responsible for this package, and who is
3396: most likely to look at problems or questions regarding this
3397: 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
3398: developers should contact the <code class="varname">MAINTAINER</code> before
3399: making major changes to the package. When packaging a new program,
3400: set <code class="varname">MAINTAINER</code> to yourself. If you really can't
3401: maintain the package for future updates, set it to
3402: <code class="email"><<a href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>></code>.</p></li>
3403: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
3404: find more information about the package.</p></li>
3405: <li><p><code class="varname">COMMENT</code> is a one-line
3406: description of the package (should not include the package
3407: name).</p></li>
3408: </ul></div>
3409: <p>
3410: </p>
3411: <p>Other variables that affect the build:
3412: </p>
3413: <div class="itemizedlist"><ul type="disc"><li>
3414: <p><code class="varname">WRKSRC</code>: The directory where the
3415: interesting distribution files of the package are found. The
1.76 rillig 3416: default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
1.75 rillig 3417: works for most packages.</p>
3418: <p>If a package doesn't create a subdirectory for itself
3419: (most GNU software does, for instance), but extracts itself in
3420: the current directory, you should set <code class="varname">WRKSRC=
3421: ${WRKDIR}</code>.</p>
3422: <p>If a package doesn't create a subdirectory with the name
3423: of <code class="varname">DISTNAME</code> but some different name, set
3424: <code class="varname">WRKSRC</code> to point to the proper name in
1.76 rillig 3425: <code class="filename">${WRKDIR}</code>, for example <code class="varname">WRKSRC=
3426: ${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 3427: <p>The name of the working directory created by pkgsrc is
3428: taken from the <code class="varname">WRKDIR_BASENAME</code> variable. By
1.76 rillig 3429: default, its value is <code class="filename">work</code>. If you want
1.75 rillig 3430: to use the same pkgsrc tree for building different kinds of
3431: binary packages, you can change the variable according to your
3432: needs. Two other variables handle common cases of setting
3433: <code class="varname">WRKDIR_BASENAME</code> individually. If
3434: <code class="varname">OBJHOSTNAME</code> is defined in
1.76 rillig 3435: <code class="filename">/etc/mk.conf</code>, the first component of the
1.75 rillig 3436: host's name is attached to the directory name. If
3437: <code class="varname">OBJMACHINE</code> is defined, the platform name is
1.76 rillig 3438: attached, which might look like <code class="filename">work.i386</code>
3439: or <code class="filename">work.sparc</code>.</p>
1.75 rillig 3440: </li></ul></div>
3441: <p>
3442: </p>
3443: <p>Please pay attention to the following gotchas:</p>
3444: <div class="itemizedlist"><ul type="disc">
3445: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are installed in
3446: compressed form by the package; see comment in
1.76 rillig 3447: <code class="filename">bsd.pkg.mk</code>.</p></li>
3448: <li><p>Replace <code class="filename">/usr/local</code> with
1.75 rillig 3449: “<span class="quote">${PREFIX}</span>” in all files (see patches, below).</p></li>
3450: <li><p>If the package installs any info files, see
1.78 rillig 3451: <a href="#faq.info-files" title="17.5.7. Packages installing info files">Section 17.5.7, “Packages installing info files”</a>.</p></li>
1.75 rillig 3452: </ul></div>
3453: </div>
3454: <div class="sect1" lang="en">
3455: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3456: <a name="components.distinfo"></a>9.2. <code class="filename">distinfo</code></h2></div></div></div>
1.76 rillig 3457: <p>The <code class="filename">distinfo</code> file contains the message
1.75 rillig 3458: digest, or checksum, of each distfile needed for the package. This
3459: ensures that the distfiles retrieved from the Internet have not been
3460: corrupted during transfer or altered by a malign force to introduce
3461: a security hole. Due to recent rumor about weaknesses of digest
3462: algorithms, all distfiles are protected using both SHA1 and RMD160
3463: message digests, as well as the file size.</p>
1.76 rillig 3464: <p>The <code class="filename">distinfo</code> file also contains the
1.75 rillig 3465: checksums for all the patches found in the
1.77 rillig 3466: <code class="filename">patches</code> directory (see <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a>).</p>
1.76 rillig 3467: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.75 rillig 3468: <span><strong class="command">make makedistinfo</strong></span> or <span><strong class="command">make mdi</strong></span>
3469: command.</p>
3470: <p>Some packages have different sets of distfiles depending on
1.76 rillig 3471: 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
3472: <code class="filename">distinfo</code> file and care should be taken when
1.75 rillig 3473: upgrading such a package to ensure distfile information is not
3474: lost.</p>
3475: </div>
3476: <div class="sect1" lang="en">
3477: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3478: <a name="components.patches"></a>9.3. patches/*</h2></div></div></div>
1.75 rillig 3479: <p>This directory contains files that are used by the
3480: <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
3481: modify the sources as distributed in the distribution file into a form
3482: that will compile and run perfectly on NetBSD. The files are applied
3483: successively in alphabetic order (as returned by a shell
3484: “<span class="quote">patches/patch-*</span>” glob expansion), so
1.76 rillig 3485: <code class="filename">patch-aa</code> is applied before
3486: <code class="filename">patch-ab</code>, etc.</p>
3487: <p>The <code class="filename">patch-*</code> files should be in
1.75 rillig 3488: <span><strong class="command">diff -bu</strong></span> format, and apply without a fuzz to avoid
3489: problems. (To force patches to apply
3490: with fuzz you can set <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>).
3491: Furthermore, do not put changes for more than one file into a single
3492: patch file, as this will make future modifications more difficult.</p>
3493: <p>Similar, a file should be patched at most once, not several times by
3494: several different patches. If a file needs several patches, they should
3495: be combined into one file.</p>
3496: <p>One important thing to mention is to pay attention that no RCS IDs
3497: get stored in the patch files, as these will cause problems when
3498: later checked into the NetBSD CVS tree. Use the
3499: <span><strong class="command">pkgdiff</strong></span> from the
1.76 rillig 3500: <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 3501: these problems.</p>
3502: <p>For even more automation, we recommend using <span><strong class="command">mkpatches</strong></span> from the same
3503: package to make a whole set of patches. You just have to backup files
1.76 rillig 3504: before you edit them to <code class="filename">filename.orig</code>, e.g. with
1.75 rillig 3505: <span><strong class="command">cp -p filename filename.orig</strong></span> or, easier, by using
3506: <span><strong class="command">pkgvi</strong></span> again from the same package. If you upgrade a package
3507: this way, you can easily compare the new set of patches with the
3508: previously existing one with <span><strong class="command">patchdiff</strong></span>.</p>
3509: <p>When you have finished a package, remember to generate the checksums
3510: for the patch files by using the <span><strong class="command">make makepatchsum</strong></span>
1.77 rillig 3511: command, see <a href="#components.distinfo" title="9.2. distinfo">Section 9.2, “<code class="filename">distinfo</code>”</a>.</p>
1.75 rillig 3512: <p>When adding a patch that corrects a problem in the distfile (rather
3513: than e.g. enforcing pkgsrc's view of where man pages should go), send
3514: the patch as a bug report to the maintainer. This benefits
3515: non-pkgsrc users of the package, and usually enables removing
3516: the patch in future version.</p>
3517: <p>Patch files that are distributed by the author or other
3518: maintainers can be listed in
3519: <code class="varname">$PATCHFILES</code>. </p>
3520: <p>If it is desired to store any patches that should not be committed into
3521: pkgsrc, they can be kept outside the pkgsrc tree in the
1.76 rillig 3522: <code class="filename">$LOCALPATCHES</code>
1.75 rillig 3523: directory. The directory tree there is expected to have the same
3524: “<span class="quote">category/package</span>” structure as pkgsrc, and patches are
3525: expected to be stored inside these dirs (also known as
1.76 rillig 3526: <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
1.75 rillig 3527: example, if you want to keep a private patch for
1.76 rillig 3528: <code class="filename">pkgsrc/graphics/png</code>, keep
3529: it in <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
1.75 rillig 3530: files in the named directory are expected to be patch files, and
3531: <span class="emphasis"><em>they are applied after pkgsrc patches are applied</em></span>.</p>
3532: </div>
3533: <div class="sect1" lang="en">
3534: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3535: <a name="other-mandatory-files"></a>9.4. Other mandatory files</h2></div></div></div>
1.75 rillig 3536: <div class="variablelist"><dl>
1.76 rillig 3537: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
1.75 rillig 3538: <dd><p>A multi-line description of the piece of software. This should include
3539: any credits where they are due. Please bear in mind that others do not
3540: share your sense of humour (or spelling idiosyncrasies), and that others
3541: will read everything that you write here.</p></dd>
1.76 rillig 3542: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
1.75 rillig 3543: <dd><p>
3544: This file governs the files that are installed on your system: all the
3545: binaries, manual pages, etc. There are other directives which may be
3546: entered in this file, to control the creation and deletion of
3547: directories, and the location of inserted files.
1.77 rillig 3548: See <a href="#plist" title="Chapter 11. PLIST issues">Chapter 11, <i>PLIST issues</i></a> for more information. </p></dd>
1.75 rillig 3549: </dl></div>
3550: </div>
3551: <div class="sect1" lang="en">
3552: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3553: <a name="components.optional"></a>9.5. Optional files</h2></div></div></div>
1.78 rillig 3554: <div class="sect2" lang="en">
3555: <div class="titlepage"><div><div><h3 class="title">
3556: <a name="components.optional.bin"></a>9.5.1. Files affecting the binary package</h3></div></div></div>
1.75 rillig 3557: <div class="variablelist"><dl>
1.76 rillig 3558: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.75 rillig 3559: <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>.
3560: First time after package
3561: extraction and before files are moved in place, the second time after
3562: the files to install are moved in place. This can be used to do any
3563: custom procedures not possible with @exec commands in
1.76 rillig 3564: <code class="filename">PLIST</code>. See
1.75 rillig 3565: <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 3566: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
1.75 rillig 3567: <dd><p>This script is executed before and after any files are removed. It is
3568: this script's responsibility to clean up any additional messy details
3569: around the package's installation, since all pkg_delete knows is how to
3570: delete the files created in the original distribution.
3571: 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>
3572: 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 3573: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
1.75 rillig 3574: <dd>
3575: <p>This file is displayed after installation of the package.
3576: Useful for things like legal notices on almost-free
3577: software and hints for updating config files after
3578: installing modules for apache, PHP etc.
3579: Please note that you can modify variables in it easily by using
3580: <code class="varname">MESSAGE_SUBST</code> in the package's
1.76 rillig 3581: <code class="filename">Makefile</code>:</p>
1.75 rillig 3582: <pre class="programlisting">
3583: MESSAGE_SUBST+= SOMEVAR="somevalue"
1.1 grant 3584: </pre>
1.75 rillig 3585: <p>replaces "${SOMEVAR}" with “<span class="quote">somevalue</span>” in
1.76 rillig 3586: <code class="filename">MESSAGE</code>.</p>
1.75 rillig 3587: </dd>
1.78 rillig 3588: <dt><span class="term"><code class="filename">ALTERNATIVES</code></span></dt>
3589: <dd><p>FIXME: There is no documentation on the
3590: alternatives framework.</p></dd>
3591: </dl></div>
3592: </div>
3593: <div class="sect2" lang="en">
3594: <div class="titlepage"><div><div><h3 class="title">
3595: <a name="components.optional.build"></a>9.5.2. Files affecting the build process</h3></div></div></div>
3596: <div class="variablelist"><dl>
3597: <dt><span class="term"><code class="filename">Makefile.common</code></span></dt>
3598: <dd><p>This file contains arbitrary things that could
3599: also go into a <code class="filename">Makefile</code>, but its purpose is
3600: to be used by more than one package. This file should only be
3601: used when the packages that will use the file are known in
3602: advance. For other purposes it is often better to write a
3603: <code class="filename">*.mk</code> file and give it a good name that
3604: describes what it does.</p></dd>
3605: <dt><span class="term"><code class="filename">buildlink3.mk</code></span></dt>
3606: <dd><p>This file contains the dependency information
3607: for the buildlink3 framework (see <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a>).</p></dd>
3608: <dt><span class="term"><code class="filename">hacks.mk</code></span></dt>
3609: <dd><p>This file contains workarounds for compiler bugs
3610: and similar things. It is included automatically by the pkgsrc
3611: infrastructure, so you don't need an extra
3612: <code class="literal">.include</code> line for
3613: it.</p></dd>
3614: <dt><span class="term"><code class="filename">options.mk</code></span></dt>
3615: <dd><p>This file contains the code for the
3616: package-specific options (see <a href="#options" title="Chapter 14. Options handling">Chapter 14, <i>Options handling</i></a>) that can be
3617: selected by the user. If a package has only one or two options,
3618: it is equally acceptable to put the code directly into the
3619: <code class="filename">Makefile</code>.</p></dd>
3620: </dl></div>
3621: </div>
3622: <div class="sect2" lang="en">
3623: <div class="titlepage"><div><div><h3 class="title">
3624: <a name="components.optional.none"></a>9.5.3. Files affecting nothing at all</h3></div></div></div>
3625: <div class="variablelist"><dl>
3626: <dt><span class="term"><code class="filename">README*</code></span></dt>
3627: <dd><p>These files do not take place in the creation of
3628: a package and thus are purely informative to the package
3629: developer.</p></dd>
3630: <dt><span class="term"><code class="filename">TODO</code></span></dt>
3631: <dd><p>This file contains things that need to be done
3632: to make the package even
3633: better.</p></dd>
1.75 rillig 3634: </dl></div>
3635: </div>
1.78 rillig 3636: </div>
1.75 rillig 3637: <div class="sect1" lang="en">
3638: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3639: <a name="work-dir"></a>9.6. <code class="filename">work*</code></h2></div></div></div>
1.75 rillig 3640: <p>When you type <span><strong class="command">make</strong></span>, the distribution files are
3641: unpacked into the directory denoted by
3642: <code class="varname">WRKDIR</code>. It can be removed by running
3643: <span><strong class="command">make clean</strong></span>. Besides the sources, this
3644: directory is also used to keep various timestamp files.
3645: The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
1.76 rillig 3646: The default is <code class="filename">${.CURDIR}/work</code>
3647: or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
1.75 rillig 3648: if <code class="varname">OBJMACHINE</code> is set.</p>
3649: </div>
3650: <div class="sect1" lang="en">
3651: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3652: <a name="files-dir"></a>9.7. <code class="filename">files/*</code></h2></div></div></div>
1.75 rillig 3653: <p>If you have any files that you wish to be placed in the package prior
3654: to configuration or building, you could place these files here and use
3655: a “<span class="quote">${CP}</span>” command in the
3656: “<span class="quote">pre-configure</span>” target to achieve
3657: this. Alternatively, you could simply diff the file against
1.76 rillig 3658: <code class="filename">/dev/null</code> and use the patch mechanism to manage
1.75 rillig 3659: the creation of this file.</p>
3660: </div>
3661: </div>
3662: <div class="chapter" lang="en">
3663: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3664: <a name="makefile"></a>Chapter 10. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.75 rillig 3665: <div class="toc">
3666: <p><b>Table of Contents</b></p>
3667: <dl>
1.77 rillig 3668: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
3669: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
3670: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
3671: <dd><dl>
3672: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
3673: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
3674: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
3675: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
3676: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
1.75 rillig 3677: </dl></dd>
3678: </dl>
3679: </div>
1.76 rillig 3680: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
1.75 rillig 3681: each of which forms a well-defined part of the pkgsrc system. Using
3682: 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
3683: like pkgsrc requires some discipline to keep the code correct and
3684: understandable.</p>
1.76 rillig 3685: <p>The basic ingredients for <code class="filename">Makefile</code>
1.75 rillig 3686: programming are variables (which are actually macros) and shell
3687: commands. Among these shell commands may even be more complex ones
3688: 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
3689: as intended it is necessary to quote all variables correctly when they
3690: are used.</p>
3691: <p>This chapter describes some patterns, that appear quite often in
1.76 rillig 3692: <code class="filename">Makefile</code>s, including the pitfalls that come along
1.75 rillig 3693: with them.</p>
3694: <div class="sect1" lang="en">
3695: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3696: <a name="makefile.variables"></a>10.1. <code class="filename">Makefile</code> variables</h2></div></div></div>
1.76 rillig 3697: <p><code class="filename">Makefile</code> variables contain strings that
1.75 rillig 3698: can be processed using the five operators ``='', ``+='', ``?='',
3699: ``:='', 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
3700: page.</p>
3701: <p>When a variable's value is parsed from a
1.76 rillig 3702: <code class="filename">Makefile</code>, the hash character ``#'' and the
1.75 rillig 3703: backslash character ``\'' are handled specially. If a backslash is
3704: followed by a newline, any whitespace immediately in front of the
3705: backslash, the backslash, the newline, and any whitespace
3706: immediately behind the newline are replaced with a single space. A
3707: backslash character and an immediately following hash character are
3708: replaced with a single hash character. Otherwise, the backslash is
3709: passed as is. In a variable assignment, any hash character that is
3710: not preceded by a backslash starts a comment that continues upto the
3711: end of the logical line.</p>
3712: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
3713: the only way to create a variable consisting of a single backslash
3714: is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
3715: <p>So far for defining variables. The other thing you can do with
3716: variables is evaluating them. A variable is evaluated when it is
3717: part of the right side of the ``:='' or the ``!='' operator, or
3718: directly before executing a shell command which the variable is part
3719: 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
3720: is, variables are not evaluated until there's no other way. The
3721: ``modifiers'' mentioned in the man page also evaluate the
3722: variable.</p>
3723: <p>Some of the modifiers split the string into words and then
3724: operate on the words, others operate on the string as a whole. When
3725: a string is split into words, it is split as you would expect
3726: 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>
1.78 rillig 3727: <p>No rule without exception—the <span><strong class="command">.for</strong></span>
1.75 rillig 3728: loop does not follow the shell quoting rules but splits at sequences
3729: of whitespace.</p>
3730: <p>There are several types of variables that should be handled
3731: differently. Strings and two types of lists.</p>
3732: <div class="itemizedlist"><ul type="disc">
3733: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
3734: characters. Nevertheless, you should restrict yourself to only
3735: using printable characters. Examples are
3736: <code class="varname">PREFIX</code> and
3737: <code class="varname">COMMENT</code>.</p></li>
3738: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
3739: are never exported to any shell command. Their elements are
3740: separated by whitespace. Therefore, the elements themselves cannot
3741: have embedded whitespace. Any other characters are allowed.
3742: Internal lists can be used in <span><strong class="command">.for</strong></span> loops.
3743: Examples are <code class="varname">DEPENDS</code> and
3744: <code class="varname">BUILD_DEPENDS</code>.</p></li>
3745: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
3746: may be exported to a shell command. Their elements can contain any
3747: characters, including whitespace. That's why they cannot be used
3748: in <span><strong class="command">.for</strong></span> loops. Examples are
3749: <code class="varname">DISTFILES</code> and
3750: <code class="varname">MASTER_SITES</code>.</p></li>
3751: </ul></div>
3752: <div class="sect2" lang="en">
3753: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3754: <a name="makefile.variables.names"></a>10.1.1. Naming conventions</h3></div></div></div>
1.75 rillig 3755: <div class="itemizedlist"><ul type="disc">
3756: <li><p>All variable names starting with an underscore
3757: are reserved for use by the pkgsrc infrastructure. They shall
3758: not be used by package
1.76 rillig 3759: <code class="filename">Makefile</code>s.</p></li>
1.75 rillig 3760: <li><p>In <span><strong class="command">.for</strong></span> loops you should use
3761: lowercase variable names for the iteration
3762: variables.</p></li>
3763: <li><p>All list variables should have a ``plural''
3764: name, e.g. <code class="varname">PKG_OPTIONS</code> or
3765: <code class="varname">DISTFILES</code>.</p></li>
3766: </ul></div>
3767: </div>
3768: </div>
3769: <div class="sect1" lang="en">
3770: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3771: <a name="makefile.code"></a>10.2. Code snippets</h2></div></div></div>
1.75 rillig 3772: <p>This section presents you with some code snippets you should
3773: use in your own code. If you don't find anything appropriate here,
3774: you should test your code and add it here.</p>
3775: <div class="sect2" lang="en">
3776: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3777: <a name="adding-to-list"></a>10.2.1. Adding things to a list</h3></div></div></div>
1.75 rillig 3778: <pre class="programlisting">
3779: STRING= foo * bar `date`
3780: INT_LIST= # empty
3781: ANOTHER_INT_LIST= apache-[0-9]*:../../www/apache
3782: EXT_LIST= # empty
3783: ANOTHER_EXT_LIST= a=b c=d
1.1 grant 3784:
1.75 rillig 3785: INT_LIST+= ${STRING} # 1
3786: INT_LIST+= ${ANOTHER_INT_LIST} # 2
3787: EXT_LIST+= ${STRING:Q} # 3
3788: EXT_LIST+= ${ANOTHER_EXT_LIST} # 4
1.1 grant 3789: </pre>
1.75 rillig 3790: <p>When you add a string to an external list (example 3), it
3791: must be quoted. In all other cases, you must not add a quoting
3792: level. You must not merge internal and external lists, unless you
3793: are sure that all entries are correctly interpreted in both
3794: lists.</p>
3795: </div>
3796: <div class="sect2" lang="en">
3797: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3798: <a name="converting-internal-to-external"></a>10.2.2. Converting an internal list into an external list</h3></div></div></div>
1.75 rillig 3799: <pre class="programlisting">
3800: EXT_LIST= # empty
3801: .for i in ${INT_LIST}
3802: EXT_LIST+= ${i:Q}""
3803: .endfor
1.1 grant 3804: </pre>
1.75 rillig 3805: <p>This code converts the internal list
3806: <code class="varname">INT_LIST</code> into the external list
3807: <code class="varname">EXT_LIST</code>. As the elements of an internal list
3808: are unquoted they must be quoted here. The reason for appending
3809: <code class="varname">""</code> is explained below.</p>
3810: </div>
3811: <div class="sect2" lang="en">
3812: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3813: <a name="passing-variable-to-shell"></a>10.2.3. Passing variables to a shell command</h3></div></div></div>
1.79 rillig 3814: <p>Sometimes you may want to print an arbitrary string. There
3815: are many ways to get it wrong and only few that can handle every
3816: nastiness.</p>
1.75 rillig 3817: <pre class="programlisting">
3818: STRING= foo bar < > * `date` $$HOME ' "
3819: EXT_LIST= string=${STRING:Q} x=second\ item
1.1 grant 3820:
1.75 rillig 3821: all:
3822: echo ${STRING} # 1
3823: echo "${STRING}" # 2
3824: echo "${STRING:Q}" # 3
3825: echo ${STRING:Q} # 4
3826: echo x${STRING:Q} | sed 1s,.,, # 5
1.79 rillig 3827: printf "%s\\n" ${STRING:Q}"" # 6
1.75 rillig 3828: env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
1.1 grant 3829: </pre>
1.75 rillig 3830: <p>Example 1 leads to a syntax error in the shell, as the
3831: characters are just copied.</p>
3832: <p>Example 2 leads to a syntax error too, and if you leave out
3833: the last " character from <code class="varname">${STRING}</code>,
3834: <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
3835: variable would be evaluated, too.</p>
3836: <p>Example 3 outputs each space character preceded by a
3837: backslash (or not), depending on the implementation of the
3838: <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>
3839: <p>Example 4 handles correctly every string that does not start
3840: with a dash. In that case, the result depends on the
3841: 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
3842: guarantee that your input does not start with a dash, this form is
3843: appropriate.</p>
3844: <p>Example 5 handles even the case of a leading dash
3845: correctly.</p>
1.79 rillig 3846: <p>Example 6 also works with every string and is the
3847: light-weight solution, since it does not involve a pipe, which has
3848: its own problems.</p>
1.75 rillig 3849: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
3850: because the quoting has already been done when adding elements to
3851: the list.</p>
3852: <p>As internal lists shall not be passed to the shell, there is
3853: no example for it.</p>
3854: </div>
3855: <div class="sect2" lang="en">
3856: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3857: <a name="quoting-guideline"></a>10.2.4. Quoting guideline</h3></div></div></div>
1.75 rillig 3858: <p>There are many possible sources of wrongly quoted variables.
3859: This section lists some of the commonly known ones.</p>
3860: <div class="itemizedlist"><ul type="disc">
3861: <li>
3862: <p>Whenever you use the value of a list, think
3863: about what happens to leading or trailing whitespace. If the
3864: list is a well-formed shell expression, you can apply the
3865: <code class="varname">:M*</code> modifier to strip leading and trailing
3866: whitespace from each word. The <code class="varname">:M</code> operator
3867: first splits its argument according to the rules of the shell,
3868: and then creates a new list consisting of all words that match
3869: the shell glob expression <code class="varname">*</code>, that is: all.
3870: One class of situations where this is needed is when adding a
3871: variable like <code class="varname">CPPFLAGS</code> to
3872: <code class="varname">CONFIGURE_ARGS</code>. If the configure script
3873: invokes other configure scripts, it strips the leading and
3874: trailing whitespace from the variable and then passes it to the
3875: other configure scripts. But these configure scripts expect the
3876: (child) <code class="varname">CPPFLAGS</code> variable to be the same as
3877: the parent <code class="varname">CPPFLAGS</code>. That's why we better
3878: pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
3879: here is how we do it:</p>
3880: <pre class="programlisting">
3881: CPPFLAGS= # empty
3882: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX:Q}\"
3883: CPPFLAGS+= ${MY_CPPFLAGS}
1.1 grant 3884:
1.75 rillig 3885: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
1.1 grant 3886:
1.75 rillig 3887: all:
3888: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
3889: echo x${CONFIGURE_ARGS}x # properly trimmed
1.1 grant 3890: </pre>
1.75 rillig 3891: </li>
3892: <li><p>The example above contains one bug: The
3893: <code class="varname">${PREFIX}</code> is a properly quoted shell
3894: expression, but there is the C compiler after it, which also
3895: expects a properly quoted string (this time in C syntax). The
3896: version above is therefore only correct if
3897: <code class="varname">${PREFIX}</code> does not have embedded backslashes
3898: or double quotes. If you want to allow these, you have to add
3899: another layer of quoting to each variable that is used as a C
3900: string literal. You cannot use the <code class="varname">:Q</code>
3901: operator for it, as this operator only works for the
3902: shell.</p></li>
3903: <li>
3904: <p>Whenever a variable can be empty, the
3905: <code class="varname">:Q</code> operator can have surprising results. Here
3906: are two completely different cases which can be solved with the
3907: same trick.</p>
3908: <pre class="programlisting">
3909: EMPTY= # empty
3910: empty_test:
3911: for i in a ${EMPTY:Q} c; do \
3912: echo "$$i"; \
3913: done
1.1 grant 3914:
1.75 rillig 3915: for_test:
3916: .for i in a:\ a:\test.txt
3917: echo ${i:Q}
3918: echo "foo"
3919: .endfor
1.1 grant 3920: </pre>
1.75 rillig 3921: <p>The first example will only print two of the three lines
3922: we might have expected. This is because
3923: <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
3924: the shell cannot see. The workaround is to write
3925: <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
3926: as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
3927: -f ${FNAME:Q}</code> (both of these are wrong).</p>
3928: <p>The second example will only print three lines instead of
3929: four. The first line looks like <code class="varname">a:\ echo foo</code>.
3930: This is because the backslash of the value
3931: <code class="varname">a:\</code> is interpreted as a line-continuation by
3932: <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
3933: <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
3934: <code class="varname">${i:Q}""</code>.</p>
3935: </li>
3936: </ul></div>
3937: </div>
3938: <div class="sect2" lang="en">
3939: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3940: <a name="bsd-make-bug-workaround"></a>10.2.5. Workaround for a bug in BSD Make</h3></div></div></div>
1.75 rillig 3941: <p>The pkgsrc bmake program does not handle the following
3942: assignment correctly. In case <code class="varname">_othervar_</code>
3943: contains a ``-'' character, one of the closing braces is included
3944: in <code class="varname">${VAR}</code> after this code executes.</p>
3945: <pre class="programlisting">
3946: VAR:= ${VAR:N${_othervar_:C/-//}}
1.1 grant 3947: </pre>
1.75 rillig 3948: <p>For a more complex code snippet and a workaround, see the
1.76 rillig 3949: 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 3950: <code class="varname">bug1</code>.</p>
3951: </div>
3952: </div>
3953: </div>
3954: <div class="chapter" lang="en">
3955: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3956: <a name="plist"></a>Chapter 11. PLIST issues</h2></div></div></div>
1.75 rillig 3957: <div class="toc">
3958: <p><b>Table of Contents</b></p>
3959: <dl>
1.77 rillig 3960: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
3961: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
3962: <dt><span class="sect1"><a href="#print-PLIST">11.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
3963: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
3964: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
3965: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
3966: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
3967: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
1.75 rillig 3968: </dl>
3969: </div>
1.76 rillig 3970: <p> The <code class="filename">PLIST</code> file contains a package's
1.75 rillig 3971: “<span class="quote">packing list</span>”, i.e. a list of files that belong to
1.76 rillig 3972: the package (relative to the <code class="filename">${PREFIX}</code>
1.75 rillig 3973: directory it's been installed in) plus some additional statements
3974: - 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.
3975: This chapter addresses some issues that need attention when
1.76 rillig 3976: dealing with the <code class="filename">PLIST</code> file (or files, see
1.75 rillig 3977: below!).</p>
3978: <div class="sect1" lang="en">
3979: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3980: <a name="rcs-id"></a>11.1. RCS ID</h2></div></div></div>
1.75 rillig 3981: <p>
3982: Be sure to add a RCS ID line as the first thing in any
1.76 rillig 3983: <code class="filename">PLIST</code> file you write:
1.75 rillig 3984: </p>
3985: <pre class="programlisting">
3986: @comment $NetBSD$
1.55 rillig 3987: </pre>
1.75 rillig 3988: </div>
3989: <div class="sect1" lang="en">
3990: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3991: <a name="automatic-plist-generation"></a>11.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.75 rillig 3992: <p>You can use the <span><strong class="command">make print-PLIST</strong></span> command
3993: to output a PLIST that matches any new files since the package
1.77 rillig 3994: was extracted. See <a href="#build.helpful-targets" title="15.16. Other helpful targets">Section 15.16, “Other helpful targets”</a> for
1.75 rillig 3995: more information on this target.</p>
3996: </div>
3997: <div class="sect1" lang="en">
3998: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3999: <a name="print-PLIST"></a>11.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></h2></div></div></div>
1.75 rillig 4000: <p> If you have used any of the *-dirs packages, as explained in
1.77 rillig 4001: <a href="#faq.common-dirs" title="11.8. Sharing directories between packages">Section 11.8, “Sharing directories between packages”</a>, you may have noticed that
1.75 rillig 4002: <span><strong class="command">make print-PLIST</strong></span> outputs a set of
4003: <code class="varname">@comment</code>s instead of real
4004: <code class="varname">@dirrm</code> lines. You can also do this for
4005: specific directories and files, so that the results of that
4006: command are very close to reality. This helps <span class="emphasis"><em>a
4007: lot</em></span> during the update of packages. </p>
4008: <p> The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
4009: of AWK patterns and actions that are used to filter the output of
4010: print-PLIST. You can <span class="emphasis"><em>append</em></span> any chunk of AWK
4011: scripting you like to it, but be careful with quoting. </p>
4012: <p> For example, to get all files inside the
1.76 rillig 4013: <code class="filename">libdata/foo</code> directory removed from the
1.75 rillig 4014: resulting PLIST:</p>
4015: <pre class="programlisting">
4016: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
1.55 rillig 4017: </pre>
1.75 rillig 4018: <p> And to get all the <code class="varname">@dirrm</code> lines referring
4019: to a specific (shared) directory converted to
4020: <code class="varname">@comment</code>s: </p>
4021: <pre class="programlisting">
4022: PRINT_PLIST_AWK+= /^@dirrm share\/specific/ { print "@comment " $$0; next; }
1.51 rillig 4023: </pre>
1.75 rillig 4024: </div>
4025: <div class="sect1" lang="en">
4026: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4027: <a name="plist.misc"></a>11.4. Variable substitution in PLIST</h2></div></div></div>
1.75 rillig 4028: <p>
4029: A number of variables are substituted automatically in PLISTs
4030: when a package is installed on a system. This includes the
4031: following variables: </p>
4032: <div class="variablelist"><dl>
4033: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
4034: <dd>
4035: <p>Some packages like emacs and perl embed information
4036: about which architecture they were built on into the
4037: pathnames where they install their files. To handle this
4038: case, PLIST will be preprocessed before actually used, and
4039: the symbol
4040: “<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>” will be
4041: replaced by what <span><strong class="command">uname -p</strong></span> gives. The
4042: same is done if the string
4043: <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
4044: PLIST somewhere - use this on packages that have GNU
4045: autoconf-created configure scripts.</p>
4046: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
4047: <h3 class="title">Legacy note</h3>
4048: <p>There used to be a symbol
4049: “<span class="quote"><code class="varname">$ARCH</code></span>” that
4050: was replaced by the output of <span><strong class="command">uname
4051: -m</strong></span>, but that's no longer supported and has
4052: been removed.</p>
4053: </div>
4054: </dd>
4055: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
4056: <dd>
4057: <p>Some packages want to embed the OS name and version
4058: into some paths. To do this, use these variables in the
1.76 rillig 4059: <code class="filename">PLIST</code>:
1.75 rillig 4060: </p>
4061: <div class="itemizedlist"><ul type="disc">
4062: <li><p><code class="varname">${OPSYS}</code> - output of “<span class="quote"><span><strong class="command">uname -s</strong></span></span>”</p></li>
4063: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. “<span class="quote">solaris</span>”)</p></li>
4064: <li><p><code class="varname">${OS_VERSION}</code> - “<span class="quote"><span><strong class="command">uname -r</strong></span></span>”</p></li>
4065: </ul></div>
4066: </dd>
4067: </dl></div>
4068: <p> For a complete list of values which are replaced by
1.76 rillig 4069: default, please look in <code class="filename">bsd.pkg.mk</code> (and
1.75 rillig 4070: search for <span class="emphasis"><em>PLIST_SUBST</em></span>). </p>
4071: <p> If you want to change other variables not listed above, you
4072: can add variables and their expansions to this variable in the
1.77 rillig 4073: following way, similar to <code class="varname">MESSAGE_SUBST</code> (see <a href="#components.optional" title="9.5. Optional files">Section 9.5, “Optional files”</a>): </p>
1.75 rillig 4074: <pre class="programlisting">
4075: PLIST_SUBST+= SOMEVAR="somevalue"
1.1 grant 4076: </pre>
1.75 rillig 4077: <p>This replaces all occurrences of “<span class="quote">${SOMEVAR}</span>”
4078: in the PLIST with “<span class="quote">somevalue</span>”. </p>
4079: </div>
4080: <div class="sect1" lang="en">
4081: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4082: <a name="manpage-compression"></a>11.5. Man page compression</h2></div></div></div>
1.75 rillig 4083: <p>Man pages should be installed in compressed form if
1.76 rillig 4084: <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
1.75 rillig 4085: and uncompressed otherwise. To handle this in the
1.76 rillig 4086: <code class="filename">PLIST</code> file, the suffix “<span class="quote">.gz</span>” is
1.75 rillig 4087: appended/removed automatically for man pages according to
4088: <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
4089: or not, see above for details. This modification of the
1.76 rillig 4090: <code class="filename">PLIST</code> file is done on a copy of it, not
4091: <code class="filename">PLIST</code> itself.</p>
1.75 rillig 4092: </div>
4093: <div class="sect1" lang="en">
4094: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4095: <a name="using-PLIST_SRC"></a>11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></h2></div></div></div>
1.76 rillig 4096: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
1.75 rillig 4097: in generating the binary package, set the variable
4098: <code class="varname">PLIST_SRC</code> to the names of that file(s).
4099: 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
4100: important.</p>
4101: </div>
4102: <div class="sect1" lang="en">
4103: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4104: <a name="platform-specific-plist"></a>11.7. Platform-specific and differing PLISTs</h2></div></div></div>
1.75 rillig 4105: <p>Some packages decide to install a different set of files based on
4106: the operating system being used. These differences can be
4107: automatically handled by using the following files:</p>
4108: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4109: <li><p><code class="filename">PLIST.common</code></p></li>
4110: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
4111: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
4112: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
4113: <li><p><code class="filename">PLIST.common_end</code></p></li>
1.75 rillig 4114: </ul></div>
4115: </div>
4116: <div class="sect1" lang="en">
4117: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4118: <a name="faq.common-dirs"></a>11.8. Sharing directories between packages</h2></div></div></div>
1.75 rillig 4119: <p> A “<span class="quote">shared directory</span>” is a directory where
4120: multiple (and unrelated) packages install files. These
4121: directories are problematic because you have to add special tricks
4122: in the PLIST to conditionally remove them, or have some
4123: centralized package handle them. </p>
4124: <p> Within pkgsrc, you'll find both approaches. If a directory
4125: is shared by a few unrelated packages, it's often not worth to add
4126: an extra package to remove it. Therefore, one simply does:
4127: </p>
4128: <pre class="programlisting">
4129: @unexec ${RMDIR} %D/path/to/shared/directory 2>/dev/null || ${TRUE}
1.1 grant 4130: </pre>
1.75 rillig 4131: <p> in the PLISTs of all affected packages, instead of the
4132: regular "@dirrm" line. </p>
4133: <p> However, if the directory is shared across many packages, two
4134: different solutions are available: </p>
4135: <div class="orderedlist"><ol type="1">
4136: <li><p> If the packages have a common dependency, the directory
4137: can be removed in that. For example, see
1.76 rillig 4138: <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 4139: removes the shared directory
1.76 rillig 4140: <code class="filename">share/omf</code>. </p></li>
1.75 rillig 4141: <li><p> If the packages using the directory are not related at
4142: all (they have no common dependencies), a *-dirs package is
4143: used. </p></li>
4144: </ol></div>
4145: <p> From now on, we'll discuss the second solution. To get an
4146: idea of the *-dirs packages available, issue: </p>
4147: <pre class="programlisting">
4148: <code class="prompt">%</code> cd .../pkgsrc
4149: <code class="prompt">%</code> ls -d */*-dirs
1.1 grant 4150: </pre>
1.75 rillig 4151: <p> Their use from other packages is very simple. The
4152: <code class="varname">USE_DIRS</code> variable takes a list of package names
4153: (without the “<span class="quote">-dirs</span>” part) together with the required
4154: version number (always pick the latest one when writing new
4155: packages). </p>
4156: <p> For example, if a package installs files under
1.76 rillig 4157: <code class="filename">share/applications</code>, it should have the
1.75 rillig 4158: following line in it:
4159: </p>
4160: <pre class="programlisting">
4161: USE_DIRS+= xdg-1.1
1.1 grant 4162: </pre>
1.75 rillig 4163: <p> After regenerating the PLIST using <span><strong class="command">make
4164: print-PLIST</strong></span>, you should get the right (commented out)
4165: lines. </p>
4166: <p> Note that even if your package is using
1.76 rillig 4167: <code class="filename">$X11BASE</code>, it must not depend on the
1.75 rillig 4168: *-x11-dirs packages. Just specify the name without that part and
1.76 rillig 4169: pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
1.75 rillig 4170: care of it. </p>
4171: </div>
4172: </div>
4173: <div class="chapter" lang="en">
4174: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4175: <a name="buildlink"></a>Chapter 12. Buildlink methodology</h2></div></div></div>
1.75 rillig 4176: <div class="toc">
4177: <p><b>Table of Contents</b></p>
4178: <dl>
1.77 rillig 4179: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
4180: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
1.75 rillig 4181: <dd><dl>
1.77 rillig 4182: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
4183: <dt><span class="sect2"><a href="#updating-buildlink-depends">12.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 4184: </dl></dd>
1.77 rillig 4185: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
1.75 rillig 4186: <dd><dl>
1.77 rillig 4187: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">12.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
4188: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
1.75 rillig 4189: </dl></dd>
4190: </dl>
4191: </div>
4192: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
4193: are seen by a package's configure and build processes. This is implemented
4194: in a two step process:</p>
4195: <div class="orderedlist"><ol type="1">
4196: <li><p>Symlink headers and libraries for dependencies into
4197: <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
4198: of <code class="varname">WRKDIR</code>.</p></li>
4199: <li><p>Create wrapper scripts that are used in place of the normal compiler
4200: tools that translate <code class="option">-I${LOCALBASE}/include</code> and
4201: <code class="option">-L${LOCALBASE}/lib</code> into references to
4202: <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
4203: native compiler on some operating systems look like GCC, so that
4204: packages that expect GCC won't require modifications to build with
4205: those native compilers.</p></li>
4206: </ol></div>
4207: <p>This normalizes the environment in which a package is built so that the
4208: package may be built consistently despite what other software may be
4209: installed. Please note that the normal system header and library paths,
1.76 rillig 4210: e.g. <code class="filename">/usr/include</code>,
4211: <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
1.75 rillig 4212: designed to insulate the package build from non-system-supplied
4213: software. </p>
4214: <div class="sect1" lang="en">
4215: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4216: <a name="converting-to-buildlink3"></a>12.1. Converting packages to use buildlink3</h2></div></div></div>
1.75 rillig 4217: <p>The process of converting packages to use the buildlink3
4218: framework (“<span class="quote">bl3ifying</span>”) is fairly straightforward.
4219: The things to keep in mind are:</p>
4220: <div class="orderedlist"><ol type="1">
4221: <li><p> Ensure that the build always calls the wrapper scripts
4222: instead of the actual toolchain. Some packages are tricky,
4223: and the only way to know for sure is the check
1.76 rillig 4224: <code class="filename">${WRKDIR}/.work.log</code> to see if the
1.75 rillig 4225: wrappers are being invoked. </p></li>
4226: <li><p> Don't override <code class="varname">PREFIX</code> from within
4227: the package Makefile, e.g. Java VMs, standalone shells,
4228: etc., because the code to symlink files into
1.76 rillig 4229: <code class="filename">${BUILDLINK_DIR}</code> looks for files
1.75 rillig 4230: relative to “<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>”.
4231: </p></li>
4232: <li><p> Remember that <span class="emphasis"><em>only</em></span> the
1.76 rillig 4233: <code class="filename">buildlink3.mk</code> files that you list in a
1.75 rillig 4234: package's Makefile are added as dependencies for that package.
4235: </p></li>
4236: </ol></div>
4237: <p> If a dependency on a particular package is required for its libraries and
4238: headers, then we replace: </p>
4239: <pre class="programlisting">
4240: DEPENDS+= foo>=1.1.0:../../category/foo
1.1 grant 4241: </pre>
1.75 rillig 4242: <p>with</p>
4243: <pre class="programlisting">
4244: .include "../../category/foo/buildlink3.mk"
1.1 grant 4245: </pre>
1.75 rillig 4246: <p>The buildlink3.mk files usually define the required dependencies.
4247: If you need a newer version of the dependency when using buildlink3.mk
4248: files, then you can define it in your Makefile; for example:
4249: </p>
4250: <pre class="programlisting">
4251: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
4252: .include "../../category/foo/buildlink3.mk"
1.1 grant 4253: </pre>
1.76 rillig 4254: <p>There are several <code class="filename">buildlink3.mk</code>
4255: files in <code class="filename">pkgsrc/mk</code>
1.75 rillig 4256: that handle special package issues:</p>
4257: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4258: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
1.75 rillig 4259: the native or a pkgsrc Berkeley DB implementation based on
4260: the values of <code class="varname">BDB_ACCEPTED</code> and
4261: <code class="varname">BDB_DEFAULT</code>.</p></li>
1.76 rillig 4262: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
1.75 rillig 4263: comes with neither Curses nor NCurses, this will take care
1.76 rillig 4264: 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>
4265: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
1.75 rillig 4266: of <code class="varname">KRB5_ACCEPTED</code> to choose between
4267: adding a dependency on Heimdal or MIT-krb5 for packages that
4268: require a Kerberos 5 implementation.</p></li>
1.76 rillig 4269: <li><p><code class="filename">motif.buildlink3.mk</code> checks
1.75 rillig 4270: for a system-provided
1.76 rillig 4271: 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
4272: <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>
4273: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
1.75 rillig 4274: variables that may be used by packages that use the
4275: Open Sound System (OSS) API.</p></li>
1.76 rillig 4276: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
1.75 rillig 4277: either Postgres 7.3 or 7.4, whichever is found installed. See
4278: the file for more information. </p></li>
1.76 rillig 4279: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
1.75 rillig 4280: <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
1.76 rillig 4281: 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>
4282: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
1.75 rillig 4283: <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
4284: library.</p></li>
4285: </ul></div>
1.76 rillig 4286: <p>The comments in those <code class="filename">buildlink3.mk</code>
1.75 rillig 4287: files provide a more complete
4288: description of how to use them properly.</p>
4289: </div>
4290: <div class="sect1" lang="en">
4291: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4292: <a name="creating-buildlink3.mk"></a>12.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
1.76 rillig 4293: <p> A package's <code class="filename">buildlink3.mk</code> file is
1.75 rillig 4294: included by Makefiles to indicate the need to compile and link
4295: against header files and libraries provided by the package. A
1.76 rillig 4296: <code class="filename">buildlink3.mk</code> file should always provide
1.75 rillig 4297: enough information to add the correct type of dependency
4298: relationship and include any other
1.76 rillig 4299: <code class="filename">buildlink3.mk</code> files that it needs to find
1.75 rillig 4300: headers and libraries that it needs in turn.</p>
1.76 rillig 4301: <p> To generate an initial <code class="filename">buildlink3.mk</code>
4302: 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 4303: package is highly recommended. For most packages, the following
4304: command will generate a good starting point for
1.76 rillig 4305: <code class="filename">buildlink3.mk</code> files:</p>
1.75 rillig 4306: <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>
4307: <code class="prompt">%</code> createbuildlink >buildlink3.mk</code></strong></pre>
4308: <div class="sect2" lang="en">
4309: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4310: <a name="anatomy-of-bl3"></a>12.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
1.75 rillig 4311: <p>The following real-life example
1.76 rillig 4312: <code class="filename">buildlink3.mk</code> is taken
4313: from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
1.75 rillig 4314: <pre class="programlisting">
4315: # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
1.1 grant 4316:
1.75 rillig 4317: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
4318: TIFF_BUILDLINK3_MK:= ${TIFF_BUILDLINK3_MK}+
1.1 grant 4319:
1.75 rillig 4320: .if !empty(BUILDLINK_DEPTH:M+)
4321: BUILDLINK_DEPENDS+= tiff
4322: .endif
1.1 grant 4323:
1.75 rillig 4324: BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Ntiff}
4325: BUILDLINK_PACKAGES+= tiff
1.1 grant 4326:
1.75 rillig 4327: .if !empty(TIFF_BUILDLINK3_MK:M+)
4328: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
4329: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
4330: .endif # TIFF_BUILDLINK3_MK
1.1 grant 4331:
1.75 rillig 4332: .include "../../devel/zlib/buildlink3.mk"
4333: .include "../../graphics/jpeg/buildlink3.mk"
1.1 grant 4334:
1.75 rillig 4335: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
1.1 grant 4336: </pre>
1.75 rillig 4337: <p> The header and footer manipulate
4338: <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
1.76 rillig 4339: <code class="filename">buildlink3.mk</code> files and is used to track
1.75 rillig 4340: at what depth we are including
1.76 rillig 4341: <code class="filename">buildlink3.mk</code> files.</p>
1.75 rillig 4342: <p> The first section controls if the dependency on
4343: <em class="replaceable"><code>pkg</code></em> is added.
4344: <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
4345: packages for which dependencies are added by
4346: buildlink3.</p>
4347: <p> The second section advises pkgsrc that the
1.76 rillig 4348: <code class="filename">buildlink3.mk</code> file for
1.75 rillig 4349: <em class="replaceable"><code>pkg</code></em> has been included at some point.
4350: <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
1.76 rillig 4351: packages for which <code class="filename">buildlink3.mk</code> files
1.75 rillig 4352: have been included. It must <span class="emphasis"><em>always</em></span> be
1.76 rillig 4353: appended to within a <code class="filename">buildlink3.mk</code>
1.75 rillig 4354: file. </p>
4355: <p> The third section is protected from multiple inclusion
4356: and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
4357: added. Several important variables are set in the section:
4358: </p>
4359: <div class="itemizedlist"><ul type="disc">
4360: <li><p> <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4361: is the actual dependency recorded in the installed
4362: package; this should always be set using
4363: <span><strong class="command">+=</strong></span> to ensure that
4364: we're appending to any pre-existing list of values. This
4365: variable should be set to the first version of the
4366: package that had an API change.
4367: </p></li>
4368: <li><p> <code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
4369: is the location of the <em class="replaceable"><code>pkg</code></em>
4370: pkgsrc directory.</p></li>
4371: <li><p>
4372: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
4373: (not shown above) controls whether we use
4374: <code class="varname">BUILD_DEPENDS</code> or
4375: <code class="varname">DEPENDS</code> to add the dependency on
4376: <em class="replaceable"><code>pkg</code></em>.
4377: The build dependency is selected by setting
4378: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
4379: to “<span class="quote">build</span>”. By default, the
4380: full dependency is used.
4381: </p></li>
4382: <li><p>
4383: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
4384: and
4385: <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
4386: (not shown above) are lists of subdirectories of
1.76 rillig 4387: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4388: to add to the header and library search paths. These
4389: default to “<span class="quote">include</span>” and “<span class="quote">lib</span>”
4390: respectively. </p></li>
4391: <li><p>
4392: <code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
4393: (not shown above) is the list of preprocessor flags to add
4394: to <code class="varname">CPPFLAGS</code>, which are passed on to the
4395: configure and build phases. The “<span class="quote">-I</span>” option
4396: should be avoided and instead be handled using
4397: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
4398: above.</p></li>
4399: </ul></div>
4400: <p> The following variables are all optionally defined within
4401: this second section (protected against multiple inclusion) and
4402: control which package files are symlinked into
1.76 rillig 4403: <code class="filename">${BUILDLINK_DIR}</code> and how their names are
1.75 rillig 4404: transformed during the symlinking: </p>
4405: <div class="itemizedlist"><ul type="disc">
4406: <li><p>
4407: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
4408: (not shown above) is a shell glob pattern relative to
1.76 rillig 4409: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4410: to be symlinked into
1.76 rillig 4411: <code class="filename">${BUILDLINK_DIR}</code>,
4412: e.g. <code class="filename">include/*.h</code>. </p></li>
1.75 rillig 4413: <li><p>
4414: <code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
4415: (not shown above) is a shell pipeline that
4416: outputs to stdout a list of files relative to
1.76 rillig 4417: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
1.75 rillig 4418: The resulting files are to be symlinked
1.76 rillig 4419: into <code class="filename">${BUILDLINK_DIR}</code>. By default,
4420: this takes the <code class="filename">+CONTENTS</code> of a
1.75 rillig 4421: <em class="replaceable"><code>pkg</code></em> and filters it through
4422: <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.
4423: </p></li>
4424: <li><p>
4425: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
4426: (not shown above) is a filter command that filters
1.76 rillig 4427: <code class="filename">+CONTENTS</code> input into a list of files
1.75 rillig 4428: relative to
1.76 rillig 4429: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4430: on stdout. By default for overwrite packages,
4431: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.76 rillig 4432: outputs the contents of the <code class="filename">include</code>
4433: and <code class="filename">lib</code> directories in the package
4434: <code class="filename">+CONTENTS</code>, and for pkgviews packages,
1.75 rillig 4435: it outputs any libtool archives in
1.76 rillig 4436: <code class="filename">lib</code> directories.
1.75 rillig 4437: </p></li>
4438: <li><p>
4439: <code class="varname">BUILDLINK_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
4440: (not shown above) is a list of sed arguments used to
4441: transform the name of the source filename into a
4442: destination filename, e.g. <span><strong class="command">-e
4443: "s|/curses.h|/ncurses.h|g"</strong></span>.
4444: </p></li>
4445: </ul></div>
4446: <p> The last section includes any
1.76 rillig 4447: <code class="filename">buildlink3.mk</code> needed for
1.75 rillig 4448: <em class="replaceable"><code>pkg</code></em>'s library dependencies.
1.76 rillig 4449: Including these <code class="filename">buildlink3.mk</code> files
1.75 rillig 4450: means that the headers and libraries for these
4451: dependencies are also symlinked into
1.76 rillig 4452: <code class="filename">${BUILDLINK_DIR}</code>
1.75 rillig 4453: whenever the <em class="replaceable"><code>pkg</code></em>
1.76 rillig 4454: <code class="filename">buildlink3.mk</code>
1.75 rillig 4455: file is included.
4456: </p>
4457: </div>
4458: <div class="sect2" lang="en">
4459: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4460: <a name="updating-buildlink-depends"></a>12.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 4461: <p>
4462: The situation that requires increasing the dependency listed in
4463: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4464: after a package update is when the API or interface to the
4465: header files change.</p>
4466: <p> In this case,
4467: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4468: should be adjusted to require at least the new package
4469: version. In some cases, the packages that depend on this new
4470: version may need their <code class="varname">PKGREVISION</code>s
1.76 rillig 4471: increased and, if they have <code class="filename">buildlink3.mk</code>
1.75 rillig 4472: files, their
4473: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4474: adjusted, too. This is needed so pkgsrc will require the
4475: correct package dependency and not settle for an older one
4476: when building the source.</p>
4477: <p>
4478: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4479: should be increased when the binary interface or sonames
4480: (major number of the library version) of any installed
4481: shared libraries change. This is needed so that binary
4482: packages made using it will require the correct package
4483: dependency and not settle for an older one which will not
4484: contain the necessary shared libraries. </p>
4485: <p>
1.78 rillig 4486: See <a href="#dependencies" title="17.1.6. Handling dependencies">Section 17.1.6, “Handling dependencies”</a> for
1.75 rillig 4487: more information about dependencies on other packages,
4488: including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
4489: <code class="varname">ABI_DEPENDS</code> definitions. </p>
4490: <p> Please take careful consideration before adjusting
4491: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4492: or
4493: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4494: as we don't want to cause unneeded package deletions and
4495: rebuilds. In many cases, new versions of packages work just
4496: fine with older dependencies.</p>
4497: <p>
4498: Also it is not needed to set
4499: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4500: when it is identical to
4501: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>. </p>
4502: </div>
4503: </div>
4504: <div class="sect1" lang="en">
4505: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4506: <a name="writing-builtin.mk"></a>12.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.75 rillig 4507: <p>
4508: Some packages in pkgsrc install headers and libraries that
4509: coincide with headers and libraries present in the base system.
1.76 rillig 4510: Aside from a <code class="filename">buildlink3.mk</code> file, these
4511: packages should also include a <code class="filename">builtin.mk</code>
1.75 rillig 4512: file that includes the necessary checks to decide whether using
4513: the built-in software or the pkgsrc software is
4514: appropriate. </p>
4515: <p> The only requirements of a builtin.mk file for
4516: <em class="replaceable"><code>pkg</code></em> are:
4517: </p>
4518: <div class="orderedlist"><ol type="1">
4519: <li><p> It should set
4520: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4521: to either “<span class="quote">yes</span>” or “<span class="quote">no</span>”
4522: after it is included.
4523: </p></li>
4524: <li><p> It should <span class="emphasis"><em>not</em></span> override any
4525: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4526: which is already set before the
1.76 rillig 4527: <code class="filename">builtin.mk</code> file is included.
1.75 rillig 4528: </p></li>
4529: <li><p> It should be written to allow multiple inclusion. This
4530: is <span class="emphasis"><em>very</em></span> important and takes careful
1.76 rillig 4531: attention to <code class="filename">Makefile</code> coding.
1.75 rillig 4532: </p></li>
4533: </ol></div>
4534: <div class="sect2" lang="en">
4535: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4536: <a name="anatomy-of-builtin.mk"></a>12.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</h3></div></div></div>
1.75 rillig 4537: <p>The following is the recommended template for builtin.mk
4538: files: </p>
4539: <pre class="programlisting">
4540: .if !defined(IS_BUILTIN.foo)
4541: #
4542: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
4543: # genuinely exists in the system or not.
4544: #
4545: IS_BUILTIN.foo?= no
1.1 grant 4546:
1.75 rillig 4547: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
4548: # version can be determined.
4549: #
4550: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
4551: BUILTIN_PKG.foo?= foo-1.0
4552: . endif
4553: .endif # IS_BUILTIN.foo
1.1 grant 4554:
1.75 rillig 4555: .if !defined(USE_BUILTIN.foo)
4556: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
4557: . if defined(BUILTIN_PKG.foo)
4558: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
4559: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
4560: USE_BUILTIN.foo!= \
4561: if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then \
4562: ${ECHO} "yes"; \
4563: else \
4564: ${ECHO} "no"; \
4565: fi
4566: . endif
4567: . endfor
4568: . endif
4569: .endif # USE_BUILTIN.foo
1.1 grant 4570:
1.75 rillig 4571: CHECK_BUILTIN.foo?= no
4572: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
4573: #
4574: # Here we place code that depends on whether USE_BUILTIN.foo is set to
4575: # "yes" or "no".
4576: #
4577: .endif # CHECK_BUILTIN.foo
1.1 grant 4578: </pre>
1.75 rillig 4579: <p> The first section sets
4580: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4581: depending on if <em class="replaceable"><code>pkg</code></em> really exists
4582: in the base system. This should not be a base system software
4583: with similar functionality to <em class="replaceable"><code>pkg</code></em>;
4584: it should only be “<span class="quote">yes</span>” if the actual package is
4585: included as part of the base system. This variable is only
1.76 rillig 4586: used internally within the <code class="filename">builtin.mk</code>
1.75 rillig 4587: file. </p>
4588: <p> The second section sets
4589: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
4590: to the version of <em class="replaceable"><code>pkg</code></em> in the base
4591: system if it exists (if
4592: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4593: is “<span class="quote">yes</span>”). This variable is only used internally
1.76 rillig 4594: within the <code class="filename">builtin.mk</code> file. </p>
1.75 rillig 4595: <p> The third section sets
4596: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4597: and is <span class="emphasis"><em>required</em></span> in all
1.76 rillig 4598: <code class="filename">builtin.mk</code> files. The code in this
1.75 rillig 4599: section must make the determination whether the built-in
4600: software is adequate to satisfy the dependencies listed in
4601: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
4602: This is typically done by comparing
4603: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
4604: against each of the dependencies in
4605: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
4606: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4607: <span class="emphasis"><em>must</em></span> be set to the correct value by the
1.76 rillig 4608: end of the <code class="filename">builtin.mk</code> file. Note that
1.75 rillig 4609: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4610: may be “<span class="quote">yes</span>” even if
4611: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4612: is “<span class="quote">no</span>” because we may make the determination
4613: that the built-in version of the software is similar enough to
4614: be used as a replacement. </p>
4615: <p> The last section is guarded by
4616: <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
4617: and includes code that uses the value of
4618: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4619: set in the previous section. This typically includes, e.g.,
4620: adding additional dependency restrictions and listing
4621: additional files to symlink into
1.76 rillig 4622: <code class="filename">${BUILDLINK_DIR}</code> (via
1.75 rillig 4623: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).
4624: </p>
4625: </div>
4626: <div class="sect2" lang="en">
4627: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4628: <a name="native-or-pkgsrc-preference"></a>12.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
1.75 rillig 4629: <p>
4630: When building packages, it's possible to choose whether to set
4631: a global preference for using either the built-in (native)
4632: version or the pkgsrc version of software to satisfy a
4633: dependency. This is controlled by setting
4634: <code class="varname">PREFER_PKGSRC</code> and
4635: <code class="varname">PREFER_NATIVE</code>. These variables take values
4636: of either “<span class="quote">yes</span>”, “<span class="quote">no</span>”, or a list of
4637: packages. <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
4638: use the pkgsrc versions of software, while
4639: <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
4640: built-in versions. Preferences are determined by the most
4641: specific instance of the package in either
4642: <code class="varname">PREFER_PKGSRC</code> or
4643: <code class="varname">PREFER_NATIVE</code>. If a package is specified
4644: in neither or in both variables, then
4645: <code class="varname">PREFER_PKGSRC</code> has precedence over
4646: <code class="varname">PREFER_NATIVE</code>. For example, to require
4647: using pkgsrc versions of software for all but the most basic
4648: bits on a NetBSD system, you can set: </p>
4649: <pre class="programlisting">
4650: PREFER_PKGSRC= yes
4651: PREFER_NATIVE= getopt skey tcp_wrappers
1.1 grant 4652: </pre>
1.75 rillig 4653: <p> A package <span class="emphasis"><em>must</em></span> have a
1.76 rillig 4654: <code class="filename">builtin.mk</code>
1.75 rillig 4655: file to be listed in <code class="varname">PREFER_NATIVE</code>,
4656: otherwise it is simply ignored in that list.
4657: </p>
4658: </div>
4659: </div>
4660: </div>
4661: <div class="chapter" lang="en">
4662: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4663: <a name="pkginstall"></a>Chapter 13. The pkginstall framework</h2></div></div></div>
1.75 rillig 4664: <div class="toc">
4665: <p><b>Table of Contents</b></p>
4666: <dl>
1.77 rillig 4667: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
1.75 rillig 4668: <dd><dl>
1.77 rillig 4669: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
4670: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
1.75 rillig 4671: </dl></dd>
1.77 rillig 4672: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
1.75 rillig 4673: <dd><dl>
1.77 rillig 4674: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
4675: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
4676: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
4677: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
4678: </dl></dd>
4679: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
4680: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">13.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
4681: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
4682: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
4683: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
4684: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
4685: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">13.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
1.75 rillig 4686: </dl>
4687: </div>
4688: <p>This chapter describes the framework known as
4689: <code class="literal">pkginstall</code>, whose key features are:</p>
4690: <div class="itemizedlist"><ul type="disc">
4691: <li><p>Generic installation and manipulation of directories and files
4692: outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
4693: <li><p>Automatic handling of configuration files during installation,
4694: provided that packages are correctly designed.</p></li>
4695: <li><p>Generation and installation of system startup scripts.</p></li>
4696: <li><p>Registration of system users and groups.</p></li>
4697: <li><p>Registration of system shells.</p></li>
4698: <li><p>Automatic updating of fonts databases.</p></li>
4699: </ul></div>
4700: <p>The following sections inspect each of the above points in detail.</p>
4701: <p>You may be thinking that many of the things described here could be
4702: easily done with simple code in the package's post-installation target
4703: (<code class="literal">post-install</code>). <span class="emphasis"><em>This is incorrect</em></span>,
4704: as the code in them is only executed when building from source. Machines
4705: using binary packages could not benefit from it at all (as the code itself
4706: could be unavailable). Therefore, the only way to achieve any of the items
4707: described above is by means of the installation scripts, which are
4708: automatically generated by pkginstall.</p>
4709: <div class="sect1" lang="en">
4710: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4711: <a name="files-and-dirs-outside-prefix"></a>13.1. Files and directories outside the installation prefix</h2></div></div></div>
1.76 rillig 4712: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
1.75 rillig 4713: of files and directories that belong to a package. The names used in it
1.76 rillig 4714: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
1.75 rillig 4715: which means that it cannot register files outside this directory (absolute
4716: path names are not allowed). Despite this restriction, some packages need
4717: to install files outside this location; e.g., under
1.76 rillig 4718: <code class="filename">${VARBASE}</code> or
4719: <code class="filename">${PKG_SYSCONFDIR}</code>.</p>
1.75 rillig 4720: <p>The only way to achieve this is to create such files during
4721: installation time by using the installation scripts. These scripts can run
4722: arbitrary commands, so they have the potential to create and manage files
4723: anywhere in the file system. Here is where pkginstall comes into play: it
4724: provides generic scripts to abstract the manipulation of such files and
4725: directories based on variables set in the package's
1.76 rillig 4726: <code class="filename">Makefile</code>. The rest of this section describes these
1.75 rillig 4727: variables.</p>
4728: <div class="sect2" lang="en">
4729: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4730: <a name="dirs-outside-prefix"></a>13.1.1. Directory manipulation</h3></div></div></div>
1.75 rillig 4731: <p>The following variables can be set to request the creation of
4732: directories anywhere in the file system:</p>
4733: <div class="itemizedlist"><ul type="disc">
4734: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
4735: contain a list of directories that should be created and should attempt
4736: to be destroyed by the installation scripts. The difference between
4737: the two is that the latter prompts the administrator to remove any
4738: directories that may be left after deinstallation (because they were
4739: not empty), while the former does not.</p></li>
4740: <li>
4741: <p><code class="varname">MAKE_DIRS_PERMS</code> and
4742: <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
4743: which directories should be created and should attempt to be destroyed
4744: by the installation scripts. Each tuple holds the following values,
4745: separated by spaces: the directory name, its owner, its group and its
4746: numerical mode. For example:</p>
4747: <pre class="programlisting">
4748: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 4749: </pre>
1.75 rillig 4750: <p>The difference between the two is exactly the same as their
4751: non-<code class="varname">PERMS</code> counterparts.</p>
4752: </li>
4753: </ul></div>
4754: </div>
4755: <div class="sect2" lang="en">
4756: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4757: <a name="files-outside-prefix"></a>13.1.2. File manipulation</h3></div></div></div>
1.75 rillig 4758: <p>Creating non-empty files outside the installation prefix is tricky
1.76 rillig 4759: because the <code class="filename">PLIST</code> forces all files to be inside it.
1.75 rillig 4760: To overcome this problem, the only solution is to extract the file in the
4761: known place (i.e., inside the installation prefix) and copy it to the
4762: appropriate location during installation (done by the installation scripts
4763: generated by pkginstall). We will call the former the <span class="emphasis"><em>master
4764: file</em></span> in the following paragraphs, which describe the variables
4765: that can be used to automatically and consistently handle files outside the
4766: installation prefix:</p>
4767: <div class="itemizedlist"><ul type="disc">
4768: <li>
4769: <p><code class="varname">CONF_FILES</code> and
4770: <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
4771: During installation time, the master file is copied to the target one
4772: if and only if the latter does not exist. Upon deinstallation, the
4773: target file is removed provided that it was not modified by the
4774: installation.</p>
4775: <p>The difference between the two is that the latter prompts the
4776: administrator to remove any files that may be left after
4777: deinstallation (because they were not empty), while the former does
4778: not.</p>
4779: </li>
4780: <li>
4781: <p><code class="varname">CONF_FILES_PERMS</code> and
4782: <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
4783: files as well as their target locations. For each of them, it also
4784: specifies their owner, their group and their numeric permissions, in
4785: this order. For example:</p>
4786: <pre class="programlisting">
4787: SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 4788: </pre>
1.75 rillig 4789: <p>The difference between the two is exactly the same as their
4790: non-<code class="varname">PERMS</code> counterparts.</p>
4791: </li>
4792: </ul></div>
4793: </div>
4794: </div>
4795: <div class="sect1" lang="en">
4796: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4797: <a name="conf-files"></a>13.2. Configuration files</h2></div></div></div>
1.75 rillig 4798: <p>Configuration files are special in the sense that they are installed
4799: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
4800: need special treatment during installation (most of which is automated by
4801: pkginstall). The main concept you must bear in mind is that files marked
4802: as configuration files are automatically copied to the right place (somewhere
4803: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
4804: and only if</em></span> they didn't exist before. Similarly, they will not
4805: be removed if they have local modifications. This ensures that
4806: administrators never lose any custom changes they may have made.</p>
4807: <div class="sect2" lang="en">
4808: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4809: <a name="conf-files-sysconfdir"></a>13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</h3></div></div></div>
1.75 rillig 4810: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
4811: specifies where configuration files shall be installed. Its contents are
4812: set based upon the following variables:</p>
4813: <div class="itemizedlist"><ul type="disc">
4814: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
1.76 rillig 4815: directory. Defaults to <code class="filename">${PREFIX}/etc</code> although it may
1.75 rillig 4816: be overridden by the user to point to his preferred location (e.g.,
1.76 rillig 4817: <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
1.75 rillig 4818: Packages must not use it directly.</p></li>
4819: <li>
4820: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
4821: <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
4822: for the package being built shall be installed. The definition of this
4823: variable only makes sense in the package's
1.76 rillig 4824: <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
1.75 rillig 4825: <p>As an example, consider the Apache package,
1.76 rillig 4826: <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 4827: configuration files under the
1.76 rillig 4828: <code class="filename">httpd/</code> subdirectory of
1.75 rillig 4829: <code class="varname">PKG_SYSCONFBASE</code>. This should be set in the package
4830: Makefile.</p>
4831: </li>
4832: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
4833: variable that holds this package's configuration directory (if
4834: different from <code class="varname">PKG_SYSCONFBASE</code>). It defaults to
4835: <code class="varname">PKGBASE</code>'s value, and is always prefixed with
4836: <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
4837: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
4838: directory where the configuration files for the package identified by
4839: <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
4840: </ul></div>
4841: <p>Based on the above variables, pkginstall determines the value of
4842: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
4843: variable that can be used within a package to refer to its configuration
4844: directory. The algorithm used to set its value is basically the
4845: following:</p>
4846: <div class="orderedlist"><ol type="1">
4847: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
4848: its value is used.</p></li>
4849: <li><p>If the previous variable is not defined but
4850: <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
1.76 rillig 4851: <code class="filename">Makefile</code>, the resulting value is
4852: <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
1.75 rillig 4853: <li><p>Otherwise, it is set to
1.76 rillig 4854: <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
1.75 rillig 4855: </ol></div>
1.76 rillig 4856: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
1.77 rillig 4857: automatically added to <code class="filename">OWN_DIRS</code>. See <a href="#dirs-outside-prefix" title="13.1.1. Directory manipulation">Section 13.1.1, “Directory manipulation”</a> what this means.</p>
1.75 rillig 4858: </div>
4859: <div class="sect2" lang="en">
4860: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4861: <a name="conf-files-configure"></a>13.2.2. Telling the software where configuration files are</h3></div></div></div>
1.75 rillig 4862: <p>Given that pkgsrc (and users!) expect configuration files to be in a
4863: known place, you need to teach each package where it shall install its
4864: files. In some cases you will have to patch the package Makefiles to
4865: achieve it. If you are lucky, though, it may be as easy as passing an
4866: extra flag to the configuration script; this is the case of GNU Autoconf-
4867: generated files:</p>
4868: <pre class="programlisting">
4869: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1 grant 4870: </pre>
1.75 rillig 4871: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
4872: for</em></span> its configuration files, not where they will be originally
4873: installed (although the difference is never explicit,
4874: unfortunately).</p>
4875: </div>
4876: <div class="sect2" lang="en">
4877: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4878: <a name="conf-files-patching"></a>13.2.3. Patching installations</h3></div></div></div>
1.75 rillig 4879: <p>As said before, pkginstall automatically handles configuration files.
4880: This means that <span class="strong"><strong>the packages themselves must not
1.76 rillig 4881: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
1.75 rillig 4882: directly</strong></span>. Bad news is that many software installation scripts
4883: will, out of the box, mess with the contents of that directory. So what is
4884: the correct procedure to fix this issue?</p>
4885: <p>You must teach the package (usually by manually patching it) to
4886: install any configuration files under the examples hierarchy,
1.76 rillig 4887: <code class="filename">share/examples/${PKGBASE}/</code>. This way, the
4888: <code class="filename">PLIST</code> registers them and the administrator always
1.75 rillig 4889: has the original copies available.</p>
4890: <p>Once the required configuration files are in place (i.e., under the
4891: examples hierarchy), the pkginstall framework can use them as master copies
4892: during the package installation to update what is in
1.76 rillig 4893: <code class="filename">${PKG_SYSCONFDIR}</code>. To achieve this, the variables
1.75 rillig 4894: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
1.77 rillig 4895: used. Check out <a href="#files-outside-prefix" title="13.1.2. File manipulation">Section 13.1.2, “File manipulation”</a> for information
1.75 rillig 4896: about their syntax and their purpose. Here is an example, taken from the
1.76 rillig 4897: <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 4898: <pre class="programlisting">
4899: EGDIR= ${PREFIX}/share/doc/mutt/samples
4900: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1 grant 4901: </pre>
1.75 rillig 4902: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
4903: package and has no meaning outside it.</p>
4904: </div>
4905: <div class="sect2" lang="en">
4906: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4907: <a name="conf-files-disable"></a>13.2.4. Disabling handling of configuration files</h3></div></div></div>
1.75 rillig 4908: <p>The automatic copying of config files can be toggled by setting the
4909: environment variable <code class="varname">PKG_CONFIG</code> prior to package
4910: installation.</p>
4911: </div>
4912: </div>
4913: <div class="sect1" lang="en">
4914: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4915: <a name="rcd-scripts"></a>13.3. System startup scripts</h2></div></div></div>
1.75 rillig 4916: <p>System startup scripts are special files because they must be
4917: installed in a place known by the underlying OS, usually outside the
1.77 rillig 4918: installation prefix. Therefore, the same rules described in <a href="#files-and-dirs-outside-prefix" title="13.1. Files and directories outside the installation prefix">Section 13.1, “Files and directories outside the installation prefix”</a> apply, and the same solutions
1.75 rillig 4919: can be used. However, pkginstall provides a special mechanism to handle
4920: these files.</p>
4921: <p>In order to provide system startup scripts, the package has
4922: to:</p>
4923: <div class="orderedlist"><ol type="1">
1.76 rillig 4924: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
1.75 rillig 4925: the <code class="literal">.sh</code> suffix appended. Considering the
1.76 rillig 4926: <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
4927: <code class="filename">cupsd.sh</code> in its files directory.</p></li>
1.75 rillig 4928: <li>
4929: <p>Tell pkginstall to handle it, appending the name of the script,
4930: without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
4931: Continuing the previous example:</p>
4932: <pre class="programlisting">
4933: RCD_SCRIPTS+= cupsd
1.1 grant 4934: </pre>
1.75 rillig 4935: </li>
4936: </ol></div>
4937: <p>Once this is done, pkginstall will do the following steps for each
4938: script in an automated fashion:</p>
4939: <div class="orderedlist"><ol type="1">
4940: <li><p>Process the file found in the files directory applying all the
1.76 rillig 4941: substitutions described in the <code class="filename">FILES_SUBST</code>
1.75 rillig 4942: variable.</p></li>
4943: <li><p>Copy the script from the files directory to the examples
1.76 rillig 4944: hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>. Note
1.75 rillig 4945: that this master file must be explicitly registered in the
1.76 rillig 4946: <code class="filename">PLIST</code>.</p></li>
1.75 rillig 4947: <li><p>Add code to the installation scripts to copy the startup script
4948: from the examples hierarchy into the system-wide startup scripts
4949: directory.</p></li>
4950: </ol></div>
4951: <div class="sect2" lang="en">
4952: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4953: <a name="rcd-scripts-disable"></a>13.3.1. Disabling handling of system startup scripts</h3></div></div></div>
1.75 rillig 4954: <p>The automatic copying of config files can be toggled by setting the
4955: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
4956: installation. Note that the scripts will be always copied inside the
1.76 rillig 4957: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
1.75 rillig 4958: matter what the value of this variable is.</p>
4959: </div>
4960: </div>
4961: <div class="sect1" lang="en">
4962: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4963: <a name="users-and-groups"></a>13.4. System users and groups</h2></div></div></div>
1.75 rillig 4964: <p>If a package needs to create special users and/or groups during
4965: installation, it can do so by using the pkginstall framework.</p>
4966: <p>Users can be created by adding entries to the
4967: <code class="varname">PKG_USERS</code> variable. Each entry has the following
4968: syntax:</p>
4969: <pre class="programlisting">
4970: user:group
1.1 grant 4971: </pre>
1.75 rillig 4972: <p>Further specification of user details may be done by setting per-user
4973: variables.
4974: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the numeric
4975: UID for the user.
4976: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the user's
4977: description or comment.
4978: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the user's
1.76 rillig 4979: home directory, and defaults to <code class="filename">/nonexistent</code> if not
1.75 rillig 4980: specified.
4981: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the user's
1.76 rillig 4982: shell, and defaults to <code class="filename">/sbinno/login</code> if not specified.
1.75 rillig 4983: </p>
4984: <p>Similarly, groups can be created by adding entries to the
4985: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
4986: <pre class="programlisting">
4987: group
1.1 grant 4988: </pre>
1.75 rillig 4989: <p>The numeric GID of the group may be set by defining
4990: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
4991: <p>If a package needs to create the users and groups at an earlier
4992: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
4993: either <code class="literal">configure</code> or <code class="literal">build</code> to
4994: indicate the phase before which the users and groups are created. In
4995: this case, the numeric UIDs and GIDs of the created users and groups
4996: are automatically hardcoded into the final installation scripts.</p>
4997: </div>
4998: <div class="sect1" lang="en">
4999: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5000: <a name="shells"></a>13.5. System shells</h2></div></div></div>
1.75 rillig 5001: <p>Packages that install system shells should register them in the shell
1.76 rillig 5002: database, <code class="filename">/etc/shells</code>, to make things easier to the
1.75 rillig 5003: administrator. This must be done from the installation scripts to keep
5004: binary packages working on any system. pkginstall provides an easy way to
5005: accomplish this task.</p>
5006: <p>When a package provides a shell interpreter, it has to set the
5007: <code class="varname">PKG_SHELL</code> variable to its absolute file name. This will
5008: add some hooks to the installation scripts to handle it. Consider the
1.76 rillig 5009: 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 5010: <pre class="programlisting">
5011: PKG_SHELL= ${PREFIX}/bin/zsh
1.1 grant 5012: </pre>
1.75 rillig 5013: <div class="sect2" lang="en">
5014: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5015: <a name="shells-disable"></a>13.5.1. Disabling shell registration</h3></div></div></div>
1.75 rillig 5016: <p>The automatic registration of shell interpreters can be disabled by
1.76 rillig 5017: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
1.75 rillig 5018: environment variable to <code class="literal">NO</code>.</p>
5019: </div>
5020: </div>
5021: <div class="sect1" lang="en">
5022: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5023: <a name="fonts"></a>13.6. Fonts</h2></div></div></div>
1.75 rillig 5024: <p>Packages that install X11 fonts should update the database files
5025: that index the fonts within each fonts directory. This can easily be
5026: accomplished within the pkginstall framework.</p>
5027: <p>When a package installs X11 fonts, it must list the directories in
5028: which fonts are installed in the
5029: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
5030: where <em class="replaceable"><code>type</code></em> can be one of “<span class="quote">ttf</span>”,
5031: “<span class="quote">type1</span>” or “<span class="quote">x11</span>”. This will add hooks to the
5032: installation scripts to run the appropriate commands to update the fonts
5033: database files within each of those directories. For convenience, if the
5034: directory path is relative, it is taken to be relative to the package's
1.76 rillig 5035: 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 5036: <pre class="programlisting">
5037: FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
1.1 grant 5038: </pre>
1.75 rillig 5039: <div class="sect2" lang="en">
5040: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5041: <a name="fonts-disable"></a>13.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
1.75 rillig 5042: <p>The automatic update of fonts databases can be disabled by
1.76 rillig 5043: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
1.75 rillig 5044: environment variable to <code class="literal">NO</code>.</p>
5045: </div>
5046: </div>
5047: </div>
5048: <div class="chapter" lang="en">
5049: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5050: <a name="options"></a>Chapter 14. Options handling</h2></div></div></div>
1.75 rillig 5051: <div class="toc">
5052: <p><b>Table of Contents</b></p>
5053: <dl>
1.77 rillig 5054: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
5055: <dt><span class="sect1"><a href="#converting-to-options">14.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
5056: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
1.75 rillig 5057: </dl>
5058: </div>
5059: <p>Many packages have the ability to be built to support different
1.76 rillig 5060: sets of features. <code class="filename">bsd.options.mk</code> is a framework
1.75 rillig 5061: in pkgsrc that provides generic handling of those options that
5062: determine different ways in which the packages can be built. It's
5063: possible for the user to specify exactly which sets of options will be
5064: built into a package or to allow a set of global default options
5065: apply.</p>
5066: <div class="sect1" lang="en">
5067: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5068: <a name="global-default-options"></a>14.1. Global default options</h2></div></div></div>
1.75 rillig 5069: <p>Global default options are listed in
5070: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
5071: that should be built into every package if that option is supported.
1.76 rillig 5072: This variable should be set in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 5073: </div>
5074: <div class="sect1" lang="en">
5075: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5076: <a name="converting-to-options"></a>14.2. Converting packages to use <code class="filename">bsd.options.mk</code></h2></div></div></div>
1.75 rillig 5077: <p>The following example shows how
1.76 rillig 5078: <code class="filename">bsd.options.mk</code> should be used
1.75 rillig 5079: by the hypothetical ``wibble'' package, either in the package
1.76 rillig 5080: <code class="filename">Makefile</code>, or in a file,
5081: e.g. <code class="filename">options.mk</code>, that is included by the
5082: main package <code class="filename">Makefile</code>.</p>
1.75 rillig 5083: <pre class="programlisting">
5084: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
5085: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
5086: PKG_OPTIONS_OPTIONAL_GROUPS= database
5087: PKG_OPTIONS_GROUP.database= mysql pgsql
5088: PKG_SUGGESTED_OPTIONS= wibble-foo
5089: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
5090: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
1.1 grant 5091:
1.75 rillig 5092: .include "../../mk/bsd.prefs.mk"
1.69 rillig 5093:
1.75 rillig 5094: # this package was previously named wibble2
5095: .if defined(PKG_OPTIONS.wibble2)
5096: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
5097: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
1.78 rillig 5098: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
1.75 rillig 5099: .endif
1.69 rillig 5100:
1.75 rillig 5101: .include "../../mk/bsd.options.mk"
1.69 rillig 5102:
1.75 rillig 5103: # Package-specific option-handling
1.69 rillig 5104:
1.75 rillig 5105: ###
5106: ### FOO support
5107: ###
5108: .if !empty(PKG_OPTIONS:Mwibble-foo)
5109: CONFIGURE_ARGS+= --enable-foo
5110: .endif
1.69 rillig 5111:
1.75 rillig 5112: ###
5113: ### LDAP support
5114: ###
5115: .if !empty(PKG_OPTIONS:Mldap)
1.77 rillig 5116: . include "../../databases/openldap-client/buildlink3.mk"
5117: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
1.75 rillig 5118: .endif
1.69 rillig 5119:
1.75 rillig 5120: ###
5121: ### database support
5122: ###
5123: .if !empty(PKG_OPTIONS:Mmysql)
5124: . include "../../mk/mysql.buildlink3.mk"
5125: .endif
5126: .if !empty(PKG_OPTIONS:Mpgsql)
5127: . include "../../mk/pgsql.buildlink3.mk"
5128: .endif
5129: </pre>
5130: <p>The first section contains the information about which build
5131: options are supported by the package, and any default options settings
5132: if needed.</p>
5133: <div class="orderedlist"><ol type="1">
5134: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
5135: <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
5136: options. It should be set to
1.78 rillig 5137: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
5138: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is not defined
5139: at the point where the options are processed.</p></li>
1.75 rillig 5140: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
5141: build options supported by the package.</p></li>
5142: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
5143: list of names of groups of mutually exclusive options. The options in
5144: each group are listed in
5145: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
5146: The most specific setting of any option from the group takes
5147: precedence over all other options in the group. Options from the
5148: groups will be automatically added to
5149: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
5150: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
5151: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
5152: packages will fail if no option from the group is
5153: selected.</p></li>
5154: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
5155: of names of sets of options. At least one option from each set must
5156: be selected. The options in each set are listed in
5157: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
5158: Options from the sets will be automatically added to
5159: <code class="varname">PKG_SUPPORTED_OPTIONS</code>. Building the package will
5160: fail if no option from the set is selected.</p></li>
5161: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
5162: build options which are enabled by default.</p></li>
5163: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
5164: of
5165: “<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>”
1.76 rillig 5166: pairs that map legacy <code class="filename">/etc/mk.conf</code> variables to
1.75 rillig 5167: their option counterparts. Pairs should be added with
5168: “<span class="quote">+=</span>” to keep the listing of global legacy variables. A
5169: warning will be issued if the user uses a legacy
5170: variable.</p></li>
5171: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
5172: of
5173: “<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>”
5174: pairs that map options that have been renamed to their new
5175: counterparts. Pairs should be added with “<span class="quote">+=</span>” to keep
5176: the listing of global legacy options. A warning will be issued if
5177: the user uses a legacy option.</p></li>
5178: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
5179: options implied by deprecated variables used. This can be used for
5180: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
5181: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
5182: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
5183: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
5184: a list of warnings about deprecated variables or options used, and
5185: what to use instead.</p></li>
5186: </ol></div>
5187: <p>A package should never modify
5188: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
5189: <code class="varname">PKG_OPTIONS_VAR</code>. These are strictly user-settable.
5190: To suggest a default set of options, use
5191: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
5192: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
1.76 rillig 5193: including <code class="filename">bsd.options.mk</code>. If none of
1.75 rillig 5194: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
5195: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
5196: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
5197: happen with platform-specific options if none of them is supported on
5198: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
5199: empty list and the package is otherwise treated as not using the
5200: options framework.</p>
1.76 rillig 5201: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
1.75 rillig 5202: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
5203: build options, properly filtered to remove unsupported and duplicate
5204: options.</p>
5205: <p>The remaining sections contain the logic that is specific to
5206: each option. The correct way to check for an option is to check
5207: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
5208: <pre class="programlisting">
5209: .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
5210: </pre>
5211: </div>
5212: <div class="sect1" lang="en">
5213: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5214: <a name="option-names"></a>14.3. Option Names</h2></div></div></div>
1.75 rillig 5215: <p>Options that enable similar features in different packages (like
5216: optional support for a library) should use a common name in all
5217: packages that support it (like the name of the library). If another
5218: package already has an option with the same meaning, use the same
5219: name.</p>
5220: <p>Options that enable features specific to one package, where it's
5221: unlikely that another (unrelated) package has the same (or a similar)
5222: optional feature, should use a name prefixed with
5223: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
5224: <p>If a group of related packages share an optional feature
5225: specific to that group, prefix it with the name of the
5226: “<span class="quote">main</span>” package
5227: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
5228: <p>For new options, add a line to
1.76 rillig 5229: <code class="filename">mk/defaults/options.description</code>. Lines have two
1.75 rillig 5230: fields, separated by tab. The first field is the option name, the
5231: second its description. The description should be a whole sentence
5232: (starting with an uppercase letter and ending with a period) that
5233: describes what enabling the option does. E. g. “<span class="quote">Enable ispell
5234: support.</span>” The file is sorted by option names.</p>
5235: </div>
5236: </div>
5237: <div class="chapter" lang="en">
5238: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5239: <a name="build"></a>Chapter 15. The build process</h2></div></div></div>
1.75 rillig 5240: <div class="toc">
5241: <p><b>Table of Contents</b></p>
5242: <dl>
1.77 rillig 5243: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
5244: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
5245: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
5246: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
5247: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
5248: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
5249: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
5250: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
5251: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
5252: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
5253: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
5254: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
5255: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
5256: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
5257: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
5258: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
1.75 rillig 5259: </dl>
5260: </div>
5261: <div class="sect1" lang="en">
5262: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5263: <a name="build.intro"></a>15.1. Introduction</h2></div></div></div>
1.75 rillig 5264: <p>This chapter gives a detailed description on how a package is
5265: built. Building a package is separated into different
5266: <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
5267: <code class="varname">build</code>, <code class="varname">install</code>), all of which are
5268: described in the following sections. Each phase is splitted into
5269: so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
5270: containing phase, prefixed by one of <code class="varname">pre-</code>,
5271: <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
5272: <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
5273: of the actual work is done in the <code class="varname">do-*</code> stages.</p>
5274: <p>The basic steps for building a program are always the same. First
5275: the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
5276: the local system and then extracted. After any pkgsrc-specific patches
5277: to compile properly are applied, the software can be configured, then
5278: built (usually by compiling), and finally the generated binaries, etc.
5279: can be put into place on the system.</p>
5280: </div>
5281: <div class="sect1" lang="en">
5282: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5283: <a name="build.prefix"></a>15.2. Program location</h2></div></div></div>
1.75 rillig 5284: <p>Before outlining the process performed by the NetBSD package system in
5285: the next section, here's a brief discussion on where programs are
5286: installed, and which variables influence this.</p>
5287: <p>The automatic variable <code class="varname">PREFIX</code> indicates
5288: where all files of the final program shall be installed. It is
5289: usually set to <code class="varname">LOCALBASE</code>
1.76 rillig 5290: (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
1.75 rillig 5291: for pkgs in the “<span class="quote">cross</span>” category. The value of
5292: <code class="varname">PREFIX</code> needs to be put
5293: into the various places in the program's source where paths to
1.77 rillig 5294: these files are encoded. See <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a> and <a href="#fixes.libtool" title="17.3.1. Shared libraries - libtool">Section 17.3.1, “Shared libraries - libtool”</a> for more details.</p>
1.75 rillig 5295: <p>When choosing which of these variables to use,
5296: follow the following rules:</p>
5297: <div class="itemizedlist"><ul type="disc">
5298: <li><p><code class="varname">PREFIX</code> always points to the location where the current
5299: pkg will be installed. When referring to a pkg's own installation path,
5300: use “<span class="quote">${PREFIX}</span>”.</p></li>
5301: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs are installed.
5302: If you need to construct a -I or -L argument to the compiler to find
5303: includes and libraries installed by another non-X11 pkg, use
1.78 rillig 5304: “<span class="quote">${LOCALBASE}</span>”. The name
5305: <code class="varname">LOCALBASE</code> stems from FreeBSD, which
5306: installed all packages in <code class="filename">/usr/local</code>. As
5307: pkgsrc leaves <code class="filename">/usr/local</code> for the system
5308: administrator, this variable is a misnomer.</p></li>
1.75 rillig 5309: <li><p><code class="varname">X11BASE</code> is where the actual X11 distribution (from
5310: xsrc, etc.) is installed. When looking for
5311: <span class="emphasis"><em>standard</em></span> X11 includes (not
5312: those installed by a pkg), use “<span class="quote">${X11BASE}</span>”.</p></li>
5313: <li>
5314: <p>X11-based packages are special in that they may be installed in
5315: either <code class="varname">X11BASE</code> or <code class="varname">LOCALBASE</code>.</p>
5316: <p>Usually, X11 packages should be installed under
5317: <code class="varname">LOCALBASE</code> whenever possible. Note that you will
1.76 rillig 5318: need to include <code class="filename">../../mk/x11.buildlink3.mk</code>
1.75 rillig 5319: in them to request the
5320: presence of X11 and to get the right compilation flags.</p>
5321: <p>Even though, there are some packages that cannot be installed
5322: under <code class="varname">LOCALBASE</code>: those that come with app-defaults
5323: files. These packages are special and they must be placed under
5324: <code class="varname">X11BASE</code>. To accomplish this, set either
5325: <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
5326: your package.</p>
5327: <p>Some notes: If you need
5328: to find includes or libraries installed by a pkg that has
5329: <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
1.76 rillig 5330: its pkg <code class="filename">Makefile</code>, you need to look in
5331: <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
5332: <code class="filename">${LOCALBASE}</code>. To force installation of
1.75 rillig 5333: all X11 packages in <code class="varname">LOCALBASE</code>, the
1.76 rillig 5334: <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 5335: is enabled by default.</p>
5336: </li>
5337: <li><p><code class="varname">X11PREFIX</code> should be used to refer to the installed
5338: location of an X11 package. <code class="varname">X11PREFIX</code> will be set to
5339: <code class="varname">X11BASE</code> if xpkgwedge is not installed,
5340: and to <code class="varname">LOCALBASE</code> if xpkgwedge is installed.</p></li>
5341: <li>
5342: <p>If xpkgwedge is installed, it is possible to have some packages installed
5343: in <code class="varname">X11BASE</code> and some in <code class="varname">LOCALBASE</code>.
5344: To determine the prefix of an installed package, the
5345: <code class="varname">EVAL_PREFIX</code> definition can be used. It takes pairs in the
5346: 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
5347: <code class="varname">DIRNAME</code> will be set to the prefix of the installed
5348: package <package>, or “<span class="quote">${X11PREFIX}</span>” if the package is
5349: not installed.</p>
5350: <p>This is best illustrated by example.</p>
5351: <p>The following lines are taken from
1.76 rillig 5352: <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
1.75 rillig 5353: <pre class="programlisting">
5354: EVAL_PREFIX+= GTKDIR=gtk+
5355: CONFIGURE_ARGS+= --with-guile-prefix=${LOCALBASE:Q}
5356: CONFIGURE_ARGS+= --with-gtk-prefix=${GTKDIR:Q}
5357: CONFIGURE_ARGS+= --enable-multibyte
5358: </pre>
5359: <p>Specific defaults can be defined for the packages evaluated using
5360: <code class="varname">EVAL_PREFIX</code>, by using a definition of the form:</p>
5361: <pre class="programlisting">
5362: GTKDIR_DEFAULT= ${LOCALBASE}
5363: </pre>
5364: <p>where <code class="varname">GTKDIR</code> corresponds
5365: to the first definition in
5366: the <code class="varname">EVAL_PREFIX</code> pair.</p>
5367: </li>
1.76 rillig 5368: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.75 rillig 5369: 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 5370: manual pages go into <code class="filename">${PREFIX}/man</code>, not
5371: <code class="filename">${PREFIX}/share/man</code>.</p></li>
1.75 rillig 5372: </ul></div>
5373: </div>
5374: <div class="sect1" lang="en">
5375: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5376: <a name="build.builddirs"></a>15.3. Directories used during the build process</h2></div></div></div>
1.75 rillig 5377: <p>When building a package, a number of directories is used to store
5378: source files, temporary files, pkgsrc-internal files, and so on. These
5379: directories are explained here.</p>
5380: <p>Some of the directory variables contain relative pathnames. There
5381: are two common base directories for these relative directories:
5382: <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
5383: pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
5384: inside the package itself.</p>
5385: <div class="variablelist"><dl>
5386: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
5387: <dd><p>This is an absolute pathname that points to the pkgsrc
5388: root directory. Generally, you don't need
5389: it.</p></dd>
5390: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
5391: <dd><p>This is a pathname relative to
5392: <code class="varname">PKGSRCDIR</code> that points to the current
5393: package.</p></dd>
5394: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
5395: <dd><p>This is an absolute pathname pointing to the directory
5396: where all work takes place. The distfiles are extraced to this
5397: directory. It also contains temporary directories and log files used by
5398: the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
5399: the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
5400: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
5401: <dd><p>This is an absolute pathname pointing to the directory
5402: where the distfiles are extracted. It is usually a direct subdirectory
5403: of <code class="varname">WRKDIR</code>, and often it's the only directory entry
5404: that isn't hidden. This variable may be changed by a package
1.76 rillig 5405: <code class="filename">Makefile</code>.</p></dd>
1.75 rillig 5406: </dl></div>
5407: </div>
5408: <div class="sect1" lang="en">
5409: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5410: <a name="build.running"></a>15.4. Running a phase</h2></div></div></div>
1.75 rillig 5411: <p>You can run a particular phase by typing <span><strong class="command">make
5412: phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
5413: phase. This will automatically run all phases that are required for this
5414: phase. The default phase is <code class="varname">build</code>, that is, when you
5415: run <span><strong class="command">make</strong></span> without parameters in a package directory,
5416: the package will be built, but not installed.</p>
5417: </div>
5418: <div class="sect1" lang="en">
5419: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5420: <a name="build.fetch"></a>15.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.75 rillig 5421: <p>This will check if the file(s) given in the variables
5422: <code class="varname">DISTFILES</code> and <code class="varname">PATCHFILES</code> (as
5423: defined in the package's Makefile) are present on the
1.76 rillig 5424: local system in <code class="filename">/usr/pkgsrc/distfiles</code>. If they
1.75 rillig 5425: are not present, an attempt will be made to fetch them using commands
5426: of the form:</p>
5427: <pre class="programlisting">
5428: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
5429: </pre>
5430: <p>where ${site} varies through several possibilities in turn: first,
5431: <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the sites
5432: specified in either <code class="varname">SITES.file</code> if defined, else
5433: <code class="varname">MASTER_SITES</code> or <code class="varname">PATCH_SITES</code>, as
5434: applies, then finally the value of
5435: <code class="varname">MASTER_SITE_BACKUP</code>. The order of all except the
5436: first can be optionally sorted by the user, via setting either
5437: <code class="varname">MASTER_SORT_AWK</code> or
5438: <code class="varname">MASTER_SORT_REGEX</code>.</p>
5439: </div>
5440: <div class="sect1" lang="en">
5441: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5442: <a name="build.checksum"></a>15.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
1.75 rillig 5443: <p>After the distfile(s) are fetched, their checksum is generated and
5444: compared with the checksums stored in the distinfo file. If the
5445: checksums don't match, the build is aborted. This is to ensure the same
5446: distfile is used for building, and that the distfile wasn't changed,
5447: e.g. by some malign force, deliberately changed distfiles on the master
5448: distribution site or network lossage.</p>
5449: </div>
5450: <div class="sect1" lang="en">
5451: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5452: <a name="build.extract"></a>15.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
1.75 rillig 5453: <p>When the distfiles are present on the local system, they
5454: need to be extracted, as they usually come in the form of some
5455: compressed archive format.</p>
5456: <p>By default, all <code class="varname">DISTFILES</code> are
5457: extracted. If you only need some of them, you can set the
5458: <code class="varname">EXTRACT_ONLY</code> variable to the list of those
5459: files.</p>
5460: <p>Extracting the files is usually done by a little program,
1.76 rillig 5461: <code class="filename">mk/scripts/extract</code>, which already knows how
1.75 rillig 5462: to extract various archive formats, so most likely you will not
5463: need to change anything here. But if you need, the following
5464: variables may help you:</p>
5465: <div class="variablelist"><dl>
5466: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
5467: <dd><p>Use these variables to override the default
5468: options for an extract command, which are defined in
1.76 rillig 5469: <code class="filename">mk/scripts/extract</code>.</p></dd>
1.75 rillig 5470: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
5471: <dd><p>This variable can be set to
5472: <code class="literal">pax</code>, <code class="literal">tar</code> or an absolute
5473: pathname pointing to the command with which tar archives should
5474: be extracted.</p></dd>
5475: </dl></div>
1.76 rillig 5476: <p>If the <code class="filename">extract</code> program doesn't serve
1.75 rillig 5477: your needs, you can also override the
5478: <code class="varname">EXTRACT_CMD</code> variable, which holds the command
5479: used for extracting the files. This command is executed in the
1.76 rillig 5480: <code class="filename">${WRKSRC}</code> directory. During execution of
1.75 rillig 5481: this command, the shell variable <code class="varname">extract_file</code>
5482: holds the absolute pathname of the file that is going to be
5483: extracted.</p>
5484: <p>And if that still does not suffice, you can override the
5485: <code class="varname">do-extract</code> target in the package
5486: Makefile.</p>
5487: </div>
5488: <div class="sect1" lang="en">
5489: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5490: <a name="build.patch"></a>15.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
1.75 rillig 5491: <p>After extraction, all the patches named by the
5492: <code class="varname">PATCHFILES</code>, those present in the patches
5493: subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
1.76 rillig 5494: <code class="filename">/usr/local/patches/graphics/png</code>) are applied.
5495: Patchfiles ending in <code class="filename">.Z</code> or
5496: <code class="filename">.gz</code> are uncompressed before they are applied,
5497: files ending in <code class="filename">.orig</code> or
5498: <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 5499: can be handed in <code class="varname">PATCH_DIST_ARGS</code>.
1.77 rillig 5500: See <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a> for more details.</p>
1.75 rillig 5501: <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
5502: patches apply with some lines of fuzz. Please fix (regen) the patches
5503: so that they apply cleanly. The rationale behind this is that
5504: patches that don't apply cleanly may end up being applied in the wrong
5505: place, and cause severe harm there.</p>
5506: </div>
5507: <div class="sect1" lang="en">
5508: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5509: <a name="build.tools"></a>15.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
1.75 rillig 5510: <p>This is covered in
1.77 rillig 5511: <a href="#tools" title="Chapter 16. Tools needed for building or running">Chapter 16, <i>Tools needed for building or running</i></a>.
1.75 rillig 5512: </p>
5513: </div>
5514: <div class="sect1" lang="en">
5515: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5516: <a name="build.wrapper"></a>15.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
1.75 rillig 5517: <p>This phase creates wrapper programs for the compilers and
5518: linkers. The following variables can be used to tweak the
5519: wrappers.</p>
5520: <div class="variablelist"><dl>
5521: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
5522: <dd><p>The command used to print progress
5523: messages. Does nothing by default. Set to
5524: <code class="literal">${ECHO}</code> to see the progress
5525: messages.</p></dd>
5526: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
5527: <dd><p>This variable can be set to
5528: <code class="literal">yes</code> (default) or
5529: <code class="literal">no</code>, depending on whether you want
5530: additional information in the wrapper log
5531: file.</p></dd>
5532: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
5533: <dd><p>This variable can be set to
5534: <code class="literal">yes</code> or <code class="literal">no</code>,
5535: depending on whether the wrapper should use its cache,
5536: which will improve the speed. The default value is
5537: <code class="literal">yes</code>, but is forced to
5538: <code class="literal">no</code> if the platform does not support
5539: it.</p></dd>
5540: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
5541: <dd><p>A list of reordering commands. A
5542: reordering command has the form
5543: <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
5544: It ensures that that
5545: <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code>
5546: occurs before
5547: <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
5548: </p></dd>
5549: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
5550: <dd><p>A list of transformation commands. [TODO:
5551: investigate further]</p></dd>
5552: </dl></div>
5553: </div>
5554: <div class="sect1" lang="en">
5555: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5556: <a name="build.configure"></a>15.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.75 rillig 5557: <p>Most pieces of software need information on the header files,
5558: system calls, and library routines which are available on the platform
5559: they run on. The process of determining this information is known as
5560: configuration, and is usually automated. In most cases, a script is
5561: supplied with the distfiles, and its invocation results in generation of
5562: header files, Makefiles, etc.</p>
5563: <p>If the package contains a configure script, this can be invoked by
5564: setting <code class="varname">HAS_CONFIGURE</code> to “<span class="quote">yes</span>”. If the
5565: configure script is a GNU autoconf script, you should set
5566: <code class="varname">GNU_CONFIGURE</code> to “<span class="quote">yes</span>” instead. What
5567: happens in the <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
5568: <pre class="programlisting">
5569: .for d in ${CONFIGURE_DIRS}
5570: cd ${WRKSRC} && cd ${d} && env ${CONFIGURE_ENV} \
5571: ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
5572: .endfor
5573: </pre>
5574: <p><code class="varname">CONFIGURE_DIRS</code> (default: “<span class="quote">.</span>”) is a
5575: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
5576: these directories, the configure script is run with the environment
5577: <code class="varname">CONFIGURE_ENV</code> and arguments
5578: <code class="varname">CONFIGURE_ARGS</code>. The variables
5579: <code class="varname">CONFIGURE_ENV</code>, <code class="varname">CONFIGURE_SCRIPT</code>
5580: (default: “<span class="quote">./configure</span>”) and
5581: <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
5582: package.</p>
1.76 rillig 5583: <p>If the program uses an <code class="filename">Imakefile</code> for
1.75 rillig 5584: configuration, the appropriate steps can be invoked by setting
5585: <code class="varname">USE_IMAKE</code> to “<span class="quote">yes</span>”. (If you only want
5586: the package installed in <code class="varname">${X11PREFIX}</code> but xmkmf not
5587: being run, set <code class="varname">USE_X11BASE</code> instead.)</p>
5588: </div>
5589: <div class="sect1" lang="en">
5590: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5591: <a name="build.build"></a>15.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.75 rillig 5592: <p>For building a package, a rough equivalent of the following code
5593: is executed.</p>
5594: <pre class="programlisting">
5595: .for d in ${BUILD_DIRS}
5596: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
5597: ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
5598: -f ${MAKEFILE} ${BUILD_TARGET}
5599: .endfor
5600: </pre>
5601: <p><code class="varname">BUILD_DIRS</code> (default: “<span class="quote">.</span>”) is a
5602: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
5603: these directories, <code class="varname">MAKE_PROGRAM</code> is run with the
5604: environment <code class="varname">MAKE_ENV</code> and arguments
5605: <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
5606: <code class="varname">MAKE_ENV</code>, <code class="varname">BUILD_MAKE_FLAGS</code>,
5607: <code class="varname">MAKEFILE</code> and <code class="varname">BUILD_TARGET</code> may all
5608: be changed by the package.</p>
5609: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
5610: “<span class="quote">gmake</span>” if <code class="varname">USE_TOOLS</code> contains
5611: “<span class="quote">gmake</span>”, “<span class="quote">make</span>” otherwise. The default value
5612: of <code class="varname">MAKEFILE</code> is “<span class="quote">Makefile</span>”, and
5613: <code class="varname">BUILD_TARGET</code> defaults to “<span class="quote">all</span>”.</p>
5614: </div>
5615: <div class="sect1" lang="en">
5616: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5617: <a name="build.test"></a>15.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
1.75 rillig 5618: <p>[TODO]</p>
5619: </div>
5620: <div class="sect1" lang="en">
5621: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5622: <a name="build.install"></a>15.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75 rillig 5623: <p>Once the build stage has completed, the final step is to
5624: install the software in public directories, so users can access
5625: the programs and files.</p>
5626: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
5627: equivalent of the following code is executed. Additionally,
5628: before and after this code, much magic is performed to do
5629: consistency checks, registering the package, and so on.</p>
5630: <pre class="programlisting">
5631: .for d in ${INSTALL_DIRS}
5632: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
5633: ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
5634: -f ${MAKEFILE} ${BUILD_TARGET}
5635: .endfor
5636: </pre>
5637: <p>The variable's meanings are analogous to the ones in the
5638: <span class="emphasis"><em>build</em></span> phase.
5639: <code class="varname">INSTALL_DIRS</code> defaults to
5640: <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
5641: is “<span class="quote">install</span>” by default, plus
5642: “<span class="quote">install.man</span>” if <code class="varname">USE_IMAKE</code> is
5643: defined.</p>
5644: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
5645: variables are useful. They are all variations of the
5646: <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
5647: permissions preset. <code class="varname">INSTALL</code> is the plain
5648: install command. The specialized variants, together with their
5649: intended use, are:</p>
5650: <div class="variablelist"><dl>
5651: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
5652: <dd><p>directories that contain binaries</p></dd>
5653: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
5654: <dd><p>directories that contain scripts</p></dd>
5655: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
5656: <dd><p>directories that contain shared and static libraries</p></dd>
5657: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
5658: <dd><p>directories that contain data files</p></dd>
5659: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
5660: <dd><p>directories that contain man pages</p></dd>
5661: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
5662: <dd><p>binaries that can be stripped from debugging symbols</p></dd>
5663: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
5664: <dd><p>binaries that cannot be stripped</p></dd>
5665: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
5666: <dd><p>game binaries</p></dd>
5667: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
5668: <dd><p>shared and static libraries</p></dd>
5669: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
5670: <dd><p>data files</p></dd>
5671: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
5672: <dd><p>data files for games</p></dd>
5673: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
5674: <dd><p>man pages</p></dd>
5675: </dl></div>
5676: <p>Some other variables are:</p>
5677: <div class="variablelist"><dl>
5678: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
5679: <dd><p>A list of directories relative to
5680: <code class="varname">PREFIX</code> that are created by pkgsrc at
1.78 rillig 5681: the beginning of the <span class="emphasis"><em>install</em></span> phase.
5682: If this variable is set,
1.75 rillig 5683: <code class="varname">NO_MTREE</code>=“<span class="quote">yes</span>” is
5684: assumed, which means that the package claims to create
5685: all needed directories itself before installing files to
5686: it. Therefore this variable should only be set in
1.76 rillig 5687: <code class="filename">Makefile</code>s that are under control of
1.78 rillig 5688: the package's author. The directories are created with
5689: the correct ownership, depending on their
5690: name.</p></dd>
1.75 rillig 5691: </dl></div>
5692: </div>
5693: <div class="sect1" lang="en">
5694: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5695: <a name="build.package"></a>15.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
1.75 rillig 5696: <p>[TODO]</p>
5697: </div>
5698: <div class="sect1" lang="en">
5699: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5700: <a name="build.helpful-targets"></a>15.16. Other helpful targets</h2></div></div></div>
1.75 rillig 5701: <div class="variablelist"><dl>
5702: <dt><span class="term">pre/post-*</span></dt>
5703: <dd><p>For any of the main targets described in the previous section, two
5704: auxiliary targets exist with “<span class="quote">pre-</span>” and
5705: “<span class="quote">post-</span>” used as a prefix
5706: for the main target's name. These targets are invoked before and
5707: after the main target is called, allowing extra configuration or
5708: installation steps be performed from a package's Makefile, for
5709: example, which a program's configure script
5710: or install target omitted.</p></dd>
5711: <dt><span class="term">do-*</span></dt>
5712: <dd><p>Should one of the main targets do the wrong thing, and should there
5713: be no variable to fix this, you can redefine it with the do-*
5714: target. (Note that redefining the target itself instead of the
5715: do-* target is a bad idea, as the pre-* and post-* targets won't be
5716: called anymore, etc.) You will not usually need to do this.</p></dd>
5717: <dt><span class="term">reinstall</span></dt>
5718: <dd><p>If you did a <span><strong class="command">make install</strong></span> and you noticed some file
5719: was not installed properly, you can repeat the installation with this
5720: target, which will ignore the “<span class="quote">already installed</span>” flag.</p></dd>
5721: <dt><span class="term">deinstall</span></dt>
5722: <dd>
5723: <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,
5724: effectively de-installing the package. The following variables can
5725: be used to tune the behaviour:</p>
5726: <div class="variablelist"><dl>
5727: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
5728: <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>
5729: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
5730: <dd><p>Remove all packages that require (depend on) the given package.
5731: This can be used to remove any packages that may have been pulled in
5732: by a given package, e.g. if <span><strong class="command">make deinstall
5733: DEINSTALLDEPENDS=1</strong></span> is done in
1.76 rillig 5734: <code class="filename">pkgsrc/x11/kde</code>, this is likely to remove whole
1.75 rillig 5735: 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>
5736: </dl></div>
5737: </dd>
5738: <dt><span class="term">update</span></dt>
5739: <dd>
5740: <p>This target causes the current package to be updated to the latest
5741: version. The package and all depending packages first get de-installed,
5742: then current versions of the corresponding packages get compiled and
5743: installed. This is similar to manually noting which packages are
5744: currently installed, then performing a series of <span><strong class="command">make
5745: deinstall</strong></span> and <span><strong class="command">make install</strong></span> (or whatever
5746: <code class="varname">UPDATE_TARGET</code> is set to) for these packages.</p>
5747: <p>You can use the “<span class="quote">update</span>” target to resume package
5748: updating in case a previous <span><strong class="command">make update</strong></span> was interrupted
5749: for some reason. However, in this case, make sure you don't call
5750: <span><strong class="command">make clean</strong></span> or otherwise remove the list of dependent
5751: packages in <code class="varname">WRKDIR</code>. Otherwise, you lose the
5752: ability to automatically update the current package along with the
5753: dependent packages you have installed.</p>
5754: <p>Resuming an interrupted <span><strong class="command">make update</strong></span> will only work as
5755: long as the package tree remains unchanged. If the source code for
5756: one of the packages to be updated has been changed, resuming
5757: <span><strong class="command">make update</strong></span> will most certainly fail!</p>
5758: <p>The following variables can be used either on the command line or in
1.76 rillig 5759: <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75 rillig 5760: <span><strong class="command">make update</strong></span>:</p>
5761: <div class="variablelist"><dl>
5762: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
5763: <dd><p>Install target to recursively use for the updated package and the
5764: dependent packages. Defaults to <code class="varname">DEPENDS_TARGET</code> if set,
5765: “<span class="quote">install</span>” otherwise for <span><strong class="command">make update</strong></span>.
5766: e.g. <span><strong class="command">make update UPDATE_TARGET=package</strong></span></p></dd>
5767: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
5768: <dd><p>Don't clean up after updating. Useful if you want to leave the
5769: work sources of the updated packages around for inspection or
5770: other purposes. Be sure you eventually clean up the source
5771: tree (see the “<span class="quote">clean-update</span>” target below) or you may
5772: run into troubles with old source code still lying around on your
5773: next <span><strong class="command">make</strong></span> or <span><strong class="command">make update</strong></span>.</p></dd>
5774: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
5775: <dd><p>Deinstall each package before installing (making
5776: <code class="varname">DEPENDS_TARGET</code>). This may be necessary if the
5777: “<span class="quote">clean-update</span>” target (see below) was called after
5778: interrupting a running <span><strong class="command">make update</strong></span>.</p></dd>
5779: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
5780: <dd><p>Allows you to disable recursion and hardcode the target for
5781: packages. The default is “<span class="quote">update</span>” for the update target,
5782: facilitating a recursive update of prerequisite packages.
5783: Only set <code class="varname">DEPENDS_TARGET</code> if you want to disable
5784: recursive updates. Use <code class="varname">UPDATE_TARGET</code> instead to just
5785: set a specific target for each package to be installed during
5786: <span><strong class="command">make update</strong></span> (see above).</p></dd>
5787: </dl></div>
5788: </dd>
5789: <dt><span class="term">clean-update</span></dt>
5790: <dd>
5791: <p>Clean the source tree for all packages that would get updated if
5792: <span><strong class="command">make update</strong></span> was called from the current directory.
5793: This target should not be used if the current package (or any of its
5794: depending packages) have already been de-installed (e.g., after calling
5795: <span><strong class="command">make update</strong></span>) or you may lose some packages you intended
5796: to update. As a rule of thumb: only use this target
5797: <span class="emphasis"><em>before</em></span> the first time you run
5798: <span><strong class="command">make update</strong></span> and only if you have a dirty package tree
5799: (e.g., if you used <code class="varname">NOCLEAN</code>).</p>
5800: <p>If you are unsure about whether your tree is clean, you can either
5801: perform a <span><strong class="command">make clean</strong></span> at the top of the tree, or use
5802: the following sequence of commands from the directory of the package
5803: you want to update (<span class="emphasis"><em>before</em></span> running
5804: <span><strong class="command">make update</strong></span> for the first time, otherwise you lose
5805: all the packages you wanted to update!):</p>
5806: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
5807: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
5808: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong></pre>
5809: <p>The following variables can be used either on the command line or in
1.76 rillig 5810: <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75 rillig 5811: <span><strong class="command">make clean-update</strong></span>:</p>
5812: <div class="variablelist"><dl>
5813: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
5814: <dd><p>After <span><strong class="command">make clean</strong></span>, do not reconstruct the list of
5815: directories to update for this package. Only use this if <span><strong class="command">make
5816: update</strong></span> successfully installed all packages you wanted to
5817: update. Normally, this is done automatically on <span><strong class="command">make
5818: update</strong></span>, but may have been suppressed by the
5819: <code class="varname">NOCLEAN</code> variable (see above).</p></dd>
5820: </dl></div>
5821: </dd>
5822: <dt><span class="term">info</span></dt>
5823: <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
5824: package. You can use this to check which version of a package is
5825: installed.</p></dd>
5826: <dt><span class="term">readme</span></dt>
1.76 rillig 5827: <dd><p>This target generates a <code class="filename">README.html</code> file, which
1.75 rillig 5828: can be viewed using a browser such as
1.76 rillig 5829: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/mozilla/README.html" target="_top"><code class="filename">www/mozilla</code></a> or
5830: <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 5831: The generated files contain references to any
5832: packages which are in the <code class="varname">PACKAGES</code> directory on
5833: the local host. The generated files can be made to refer to URLs based on
5834: <code class="varname">FTP_PKG_URL_HOST</code> and
5835: <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I wanted to generate
1.76 rillig 5836: <code class="filename">README.html</code> files which pointed to binary packages
1.75 rillig 5837: on the local machine, in the directory
1.76 rillig 5838: <code class="filename">/usr/packages</code>, set
1.75 rillig 5839: <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
5840: <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
5841: <code class="varname">${PACKAGES}</code> directory and its subdirectories will be
5842: searched for all the binary packages.</p></dd>
5843: <dt><span class="term">readme-all</span></dt>
1.76 rillig 5844: <dd><p>Use this target to create a file <code class="filename">README-all.html</code>
1.75 rillig 5845: which contains a list of all packages currently available in the NetBSD
5846: Packages Collection, together with the category they belong to and a
5847: short description. This file is compiled from the
1.76 rillig 5848: <code class="filename">pkgsrc/*/README.html</code> files, so be sure to run
1.75 rillig 5849: this <span class="emphasis"><em>after</em></span> a <span><strong class="command">make readme</strong></span>.</p></dd>
5850: <dt><span class="term">cdrom-readme</span></dt>
5851: <dd><p>This is very much the same as the “<span class="quote">readme</span>” target (see
5852: above), but is to be used when generating a pkgsrc tree to be written
5853: to a CD-ROM. This target also produces
1.76 rillig 5854: <code class="filename">README.html</code> files, and can be made to refer
1.75 rillig 5855: to URLs based on <code class="varname">CDROM_PKG_URL_HOST</code> and
5856: <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
5857: <dt><span class="term">show-distfiles</span></dt>
5858: <dd><p>This target shows which distfiles and patchfiles are needed to build
5859: the package. (<code class="varname">DISTFILES</code> and
1.76 rillig 5860: <code class="varname">PATCHFILES</code>, but not <code class="filename">patches/*</code>)</p></dd>
1.75 rillig 5861: <dt><span class="term">show-downlevel</span></dt>
5862: <dd><p>This target shows nothing if the package is not installed. If a version
5863: of this package is installed, but is not the version provided in this
5864: version of pkgsrc, then a warning message is displayed. This target can
5865: be used to show which of your installed packages are downlevel, and so
5866: the old versions can be deleted, and the current ones added.</p></dd>
5867: <dt><span class="term">show-pkgsrc-dir</span></dt>
5868: <dd><p>This target shows the directory in the pkgsrc hierarchy from which the
5869: package can be built and installed. This may not be the same directory
5870: as the one from which the package was installed. This target is intended
5871: to be used by people who may wish to upgrade many packages on a single
5872: host, and can be invoked from the top-level pkgsrc Makefile by using the
5873: “<span class="quote">show-host-specific-pkgs</span>” target.</p></dd>
5874: <dt><span class="term">show-installed-depends</span></dt>
5875: <dd><p>This target shows which installed packages match the current package's
5876: <code class="varname">DEPENDS</code>. Useful if out of date dependencies are
5877: causing build problems.</p></dd>
5878: <dt><span class="term">check-shlibs</span></dt>
5879: <dd><p>After a package is installed, check all its binaries and (on ELF
5880: platforms) shared libraries to see if they find the shared libs they need.
5881: Run by default if <code class="varname">PKG_DEVELOPER</code> is set in
1.76 rillig 5882: <code class="filename">/etc/mk.conf</code>.</p></dd>
1.75 rillig 5883: <dt><span class="term">print-PLIST</span></dt>
5884: <dd>
5885: <p>After a “<span class="quote">make install</span>” from a new or
5886: upgraded pkg, this prints out an attempt to generate a new
1.76 rillig 5887: <code class="filename">PLIST</code> from a <span><strong class="command">find -newer
1.75 rillig 5888: work/.extract_done</strong></span>. An attempt is made to care
5889: for shared libs etc., but it is
5890: <span class="emphasis"><em>strongly</em></span> recommended to review the
5891: result before putting it into
1.76 rillig 5892: <code class="filename">PLIST</code>. On upgrades, it's useful to
1.75 rillig 5893: diff the output of this command against an already
1.76 rillig 5894: existing <code class="filename">PLIST</code> file.</p>
1.75 rillig 5895: <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
5896: methods that don't update file access times, be sure to
5897: add these files manually to your
1.76 rillig 5898: <code class="filename">PLIST</code>, as the “<span class="quote">find
1.75 rillig 5899: -newer</span>” command used by this target won't catch
5900: them!</p>
1.77 rillig 5901: <p> See <a href="#print-PLIST" title="11.3. Tweaking output of make print-PLIST">Section 11.3, “Tweaking output of <span><strong class="command">make print-PLIST</strong></span>”</a> for more
1.75 rillig 5902: information on this target.</p>
5903: </dd>
5904: <dt><span class="term">bulk-package</span></dt>
5905: <dd>
5906: <p>Used to do bulk builds. If an appropriate binary package already exists,
5907: no action is taken. If not, this target will compile, install and
5908: package it (and its depends, if <code class="varname">PKG_DEPENDS</code> is
5909: set properly. See <a href="#binary.configuration" title="6.3.1. Configuration">Section 6.3.1, “Configuration”</a>).
5910: After creating the binary
5911: package, the sources, the just-installed package and its required
5912: packages are removed, preserving free disk space.</p>
5913: <p><span class="emphasis"><em>Beware that this target may deinstall all
5914: packages installed on a system!</em></span></p>
5915: </dd>
5916: <dt><span class="term">bulk-install</span></dt>
5917: <dd>
5918: <p>Used during bulk-installs to install required packages. If an
5919: up-to-date binary package is available, it will be installed via
5920: <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,
5921: but the installed binary won't be removed. </p>
5922: <p> A binary package is considered “<span class="quote">up-to-date</span>” to be
5923: 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>
5924: <div class="itemizedlist"><ul type="disc">
1.76 rillig 5925: <li><p>None of the package's files (<code class="filename">Makefile</code>,
1.75 rillig 5926: ...) were modified since it was built.</p></li>
5927: <li><p>None of the package's required (binary) packages were
5928: modified since it was built.</p></li>
5929: </ul></div>
5930: <p><span class="emphasis"><em>Beware that this target may deinstall all
5931: packages installed on a system!</em></span></p>
5932: </dd>
5933: </dl></div>
5934: </div>
5935: </div>
5936: <div class="chapter" lang="en">
5937: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5938: <a name="tools"></a>Chapter 16. Tools needed for building or running</h2></div></div></div>
1.75 rillig 5939: <div class="toc">
5940: <p><b>Table of Contents</b></p>
5941: <dl>
1.77 rillig 5942: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
5943: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
5944: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
1.75 rillig 5945: </dl>
5946: </div>
5947: <p>
5948: The <code class="varname">USE_TOOLS</code> definition is used both internally
5949: by pkgsrc and also for individual packages to define what commands
5950: are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
5951: or for later run-time of an installed packaged (such as
5952: <code class="varname">DEPENDS</code>).
5953: If the native system provides an adequate tool, then in many cases, a pkgsrc
5954: package will not be used.
5955: </p>
5956: <p>
5957: When building a package, the replacement tools are
5958: made available in a directory (as symlinks or wrapper scripts)
5959: that is early in the executable search path. Just like the buildlink
5960: system, this helps with consistent builds.
5961: </p>
5962: <p>
5963: A tool may be needed to help build a specific package. For example,
5964: perl, GNU make (gmake) or yacc may be needed.
5965: </p>
5966: <p>
5967: Also a tool may be needed, for example, because the native system's supplied
5968: tool may be inefficient for building a package with pkgsrc.
5969: For example, a package may need GNU awk, bison (instead of
5970: yacc) or a better sed.
5971: </p>
5972: <p>
5973: The tools used by a package can be listed by running
5974: <span><strong class="command">make show-tools</strong></span>.
5975: </p>
5976: <div class="sect1" lang="en">
5977: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5978: <a name="pkgsrc-tools"></a>16.1. Tools for pkgsrc builds</h2></div></div></div>
1.75 rillig 5979: <p>
5980: The default set of tools used by pkgsrc is defined in
1.76 rillig 5981: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.75 rillig 5982: such as: <span><strong class="command">cat</strong></span>, <span><strong class="command">awk</strong></span>,
5983: <span><strong class="command">chmod</strong></span>, <span><strong class="command">test</strong></span>, and so on.
5984: These can be seen by running:
5985: <span><strong class="command">make show-var VARNAME=USE_TOOLS</strong></span>.
5986: </p>
5987: <p>
5988: If a package needs a specific program to build
5989: then the <code class="varname">USE_TOOLS</code> variable can be used
5990: to define the tools needed.
5991: </p>
5992: </div>
5993: <div class="sect1" lang="en">
5994: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5995: <a name="package-tools"></a>16.2. Tools needed by packages</h2></div></div></div>
1.75 rillig 5996: <p>
5997: In the following examples, the :pkgsrc means to use the pkgsrc version
5998: and not the native version for a build dependency.
5999: And the :run means that it is used for a
6000: run-time dependencies also (and becomes a DEPENDS).
6001: The default is a build dependency which can be set with
6002: :build. (So in this example, it is the same as gmake:build
6003: and pkg-config:build.)
6004: </p>
6005: <pre class="programlisting">
6006: USE_TOOLS+= mktemp:pkgsrc
6007: USE_TOOLS+= gmake perl:run pkg-config
6008: </pre>
6009: <p>
6010: When using the tools framework, a
6011: <code class="varname">TOOLS_PATH.foo</code> variable is defined
6012: which contains the full path to the appropriate tool. For example,
6013: <code class="varname">TOOLS_PATH.bash</code> could be “<span class="quote">/bin/bash</span>”
6014: on Linux systems.
6015: </p>
6016: <p>
6017: If you always need a pkgsrc version of the
6018: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
6019:
6020: </p>
6021: </div>
6022: <div class="sect1" lang="en">
6023: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6024: <a name="platform-tools"></a>16.3. Tools provided by platforms</h2></div></div></div>
1.75 rillig 6025: <p>
6026: When improving or porting pkgsrc to a new platform, have a look
6027: at (or create) the corresponding platform specific make file fragment under
1.76 rillig 6028: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
1.75 rillig 6029: the name of the common tools. For example:</p>
6030: <pre class="programlisting">
6031: .if exists(/usr/bin/bzcat)
6032: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
6033: .elif exists(/usr/bin/bzip2)
6034: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
6035: .endif
1.69 rillig 6036:
1.75 rillig 6037: TOOLS_PLATFORM.true?= true # shell builtin
6038: </pre>
6039: </div>
6040: </div>
6041: <div class="chapter" lang="en">
6042: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 6043: <a name="fixes"></a>Chapter 17. Making your package work</h2></div></div></div>
1.75 rillig 6044: <div class="toc">
6045: <p><b>Table of Contents</b></p>
6046: <dl>
1.77 rillig 6047: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
1.75 rillig 6048: <dd><dl>
1.78 rillig 6049: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
6050: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">17.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
6051: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
6052: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
6053: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
6054: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
6055: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
6056: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
6057: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
6058: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
6059: <dt><span class="sect2"><a href="#bumping-pkgrevision">17.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
1.79 rillig 6060: <dt><span class="sect2"><a href="#fixes.subst">17.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
1.77 rillig 6061: </dl></dd>
6062: <dt><span class="sect1"><a href="#fixes.fetch">17.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
6063: <dd><dl>
6064: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
6065: <dt><span class="sect2"><a href="#modified-distfiles-same-name">17.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
6066: </dl></dd>
6067: <dt><span class="sect1"><a href="#fixes.configure">17.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
6068: <dd><dl>
6069: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
6070: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
6071: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
6072: </dl></dd>
6073: <dt><span class="sect1"><a href="#fixes.build">17.4. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
6074: <dd><dl>
1.78 rillig 6075: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
6076: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
6077: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
6078: </dl></dd>
6079: <dt><span class="sect1"><a href="#fixes.install">17.5. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
6080: <dd><dl>
6081: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
6082: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
6083: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
6084: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
6085: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
6086: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
6087: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
6088: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
6089: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
6090: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
6091: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
6092: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
6093: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
6094: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
6095: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
6096: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
6097: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.75 rillig 6098: </dl></dd>
1.78 rillig 6099: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.75 rillig 6100: </dl>
6101: </div>
6102: <div class="sect1" lang="en">
6103: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6104: <a name="general-operation"></a>17.1. General operation</h2></div></div></div>
1.75 rillig 6105: <div class="sect2" lang="en">
6106: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6107: <a name="portability-of-packages"></a>17.1.1. Portability of packages</h3></div></div></div>
6108: <p>One appealing feature of pkgsrc is that it runs on many
6109: different platforms. As a result, it is important to ensure,
6110: where possible, that packages in pkgsrc are portable. This
6111: chapter mentions some particular details you should pay
6112: attention to while working on pkgsrc.</p>
6113: </div>
6114: <div class="sect2" lang="en">
6115: <div class="titlepage"><div><div><h3 class="title">
6116: <a name="pulling-vars-from-etc-mk.conf"></a>17.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></h3></div></div></div>
6117: <p>The pkgsrc user can configure pkgsrc by overriding several
6118: variables in the file pointed to by <code class="varname">MAKECONF</code>,
6119: which is <code class="filename">/etc/mk.conf</code> by default. When you
6120: want to use those variables in the preprocessor directives of
6121: <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> (for example <code class="literal">.if</code> or
6122: <code class="literal">.for</code>), you need to include the file
6123: <code class="filename">../../mk/bsd.prefs.mk</code> before, which in turn
6124: loads the user preferences.</p>
6125: <p>But note that some variables may not be completely defined
6126: after <code class="filename">../../mk/bsd.prefs.mk</code> has been
6127: included, as they may contain references to variables that are
6128: not yet defined. In shell commands this is no problem, since
6129: variables are actually macros, which are only expanded when they
6130: are used. But in the preprocessor directives mentioned above and
6131: in dependency lines (of the form <code class="literal">target:
6132: dependencies</code>) the variables are expanded at load
6133: time.</p>
6134: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
6135: <h3 class="title">Note</h3>
6136: <p>Currently there is no exhaustive list of all
6137: variables that tells you whether they can be used at load time
6138: or only at run time, but it is in preparation.</p>
6139: </div>
6140: </div>
6141: <div class="sect2" lang="en">
6142: <div class="titlepage"><div><div><h3 class="title">
6143: <a name="user-interaction"></a>17.1.3. User interaction</h3></div></div></div>
6144: <p>Occasionally, packages require interaction from the user, and this can be
6145: in a number of ways:</p>
6146: <div class="itemizedlist"><ul type="disc">
1.79 rillig 6147: <li><p>When fetching the distfiles, some packages require user
6148: interaction such as entering username/password or accepting a
6149: license on a web page.</p></li>
1.78 rillig 6150: <li><p>When extracting the distfiles, some packages may ask for passwords.</p></li>
6151: <li><p>help to configure the package before it is built</p></li>
6152: <li><p>help during the build process</p></li>
6153: <li><p>help during the installation of a package</p></li>
6154: </ul></div>
6155: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is provided to notify
6156: the pkgsrc mechanism of an interactive stage which will be needed, and
6157: this should be set in the package's <code class="filename">Makefile</code>, e.g.:</p>
1.75 rillig 6158: <pre class="programlisting">
1.78 rillig 6159: INTERACTIVE_STAGE= build
1.75 rillig 6160: </pre>
1.78 rillig 6161: <p>Multiple interactive stages can be specified:</p>
1.75 rillig 6162: <pre class="programlisting">
1.78 rillig 6163: INTERACTIVE_STAGE= configure install
1.75 rillig 6164: </pre>
6165: </div>
6166: <div class="sect2" lang="en">
6167: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6168: <a name="handling-licenses"></a>17.1.4. Handling licenses</h3></div></div></div>
6169: <p>A package may be covered by a license which the user has
6170: or has not agreed to accept. For these cases, pkgsrc contains
6171: a mechanism to note that a package is covered by a particular
6172: license, and the package cannot be built unless the user has
6173: accepted the license. (Installation of binary packages are
6174: not currently subject to this mechanism.) Packages with
6175: licenses that are either Open Source according to the Open
6176: Source Initiative or Free according to the Free Software
6177: Foundation will not be marked with a license tag. Packages
6178: with licenses that have not been determined to meet either
6179: definition will be marked with a license tag referring to the
6180: license. This will prevent building unless pkgsrc is informed
6181: that the license is acceptable, and enables displaying the
6182: license.</p>
6183: <p>The license tag mechanism is intended to address
6184: copyright-related issues surrounding building, installing and
6185: using a package, and not to address redistribution issues (see
6186: <code class="varname">RESTRICTED</code> and
6187: <code class="varname">NO_SRC_ON_FTP</code>, etc.). However, the above
6188: definition of licenses for which tags are not needed implies
6189: that packages with redistribution restrictions should have
6190: tags.</p>
6191: <p>
6192: Denoting that a package is covered by a particular license is
6193: done by placing the license in
6194: <code class="filename">pkgsrc/licenses</code> and setting the
6195: <code class="varname">LICENSE</code> variable to a string identifying
6196: the license, e.g. in
6197: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>: </p>
6198: <pre class="programlisting">
6199: LICENSE= xv-license
6200: </pre>
6201: <p>
6202: When trying to build, the user will get a notice that the
6203: package is covered by a license which has not been
6204: accepted:</p>
6205: <pre class="programlisting">
6206: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
6207: ===> xv-3.10anb9 has an unacceptable license: xv-license.
6208: ===> To view the license, enter "/usr/bin/make show-license".
6209: ===> To indicate acceptance, add this line to your /etc/mk.conf:
6210: ===> ACCEPTABLE_LICENSES+=xv-license
6211: *** Error code 1
6212: </pre>
6213: <p>The license can be viewed with <span><strong class="command">make
6214: show-license</strong></span>, and if it is considered appropriate,
6215: the line printed above can be added to
6216: <code class="filename">/etc/mk.conf</code> to indicate acceptance of
6217: the particular license:</p>
6218: <pre class="programlisting">
6219: ACCEPTABLE_LICENSES+=xv-license
6220: </pre>
6221: <p>When adding a package with a new license, the license
6222: text should be added to <code class="filename">pkgsrc/licenses</code>
6223: for displaying. A list of known licenses can be seen in this
6224: directory as well as by looking at the list of (commented
6225: out) <code class="varname">ACCEPTABLE_LICENSES</code> variable
6226: settings in
6227: <code class="filename">pkgsrc/mk/defaults/mk.conf</code>.</p>
6228: <p>The use of <code class="varname">LICENSE=shareware</code>,
6229: <code class="varname">LICENSE=no-commercial-use</code>, and similar
6230: language is deprecated because it does not crisply refer to
6231: a particular license text. Another problem with such usage
6232: is that it does not enable a user to denote acceptance of
6233: the license for a single package without accepting the same
6234: license text for another package. In particular, this can
6235: be inappropriate when e.g. one accepts a particular license to
6236: indicate to pkgsrc that a fee has been paid.</p>
1.75 rillig 6237: </div>
6238: <div class="sect2" lang="en">
6239: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6240: <a name="restricted-packages"></a>17.1.5. Restricted packages</h3></div></div></div>
1.75 rillig 6241: <p>Some licenses restrict how software may be re-distributed.
6242: In order to satisfy these restrictions, the package system
6243: defines five make variables that can be set to note these
6244: restrictions:</p>
6245: <div class="itemizedlist"><ul type="disc">
6246: <li>
6247: <p><code class="varname">RESTRICTED</code></p>
6248: <p>This variable should be set whenever a restriction
6249: exists (regardless of its kind). Set this variable to a
6250: string containing the reason for the restriction.</p>
6251: </li>
6252: <li>
6253: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
6254: <p>Binaries may not be placed on CD-ROM. Set this
6255: variable to <code class="varname">${RESTRICTED}</code> whenever a
6256: binary package may not be included on a CD-ROM.</p>
6257: </li>
6258: <li>
6259: <p><code class="varname">NO_BIN_ON_FTP</code></p>
6260: <p>Binaries may not be placed on an FTP server. Set
6261: this variable to <code class="varname">${RESTRICTED}</code>
6262: whenever a binary package may not not be made available
6263: on the Internet.</p>
6264: </li>
6265: <li>
6266: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
6267: <p>Distfiles may not be placed on CD-ROM. Set this
6268: variable to <code class="varname">${RESTRICTED}</code> if
6269: re-distribution of the source code or other distfile(s) is
6270: not allowed on CD-ROMs.</p>
6271: </li>
6272: <li>
6273: <p><code class="varname">NO_SRC_ON_FTP</code></p>
6274: <p>Distfiles may not be placed on FTP. Set this variable
6275: to <code class="varname">${RESTRICTED}</code> if re-distribution of
6276: the source code or other distfile(s) via the Internet is not
6277: allowed.</p>
6278: </li>
6279: </ul></div>
6280: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
6281: <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
6282: generic make variables to denote restrictions is deprecated,
6283: because they unconditionally prevent users from generating
6284: binary packages!</p>
6285: </div>
6286: <div class="sect2" lang="en">
6287: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6288: <a name="dependencies"></a>17.1.6. Handling dependencies</h3></div></div></div>
1.75 rillig 6289: <p>Your package may depend on some other package being present
6290: - and there are various ways of expressing this
6291: dependency. pkgsrc supports the <code class="varname">BUILD_DEPENDS</code>
6292: and <code class="varname">DEPENDS</code> definitions, the
6293: <code class="varname">USE_TOOLS</code> definition, as well as
1.76 rillig 6294: dependencies via <code class="filename">buildlink3.mk</code>, which is
1.75 rillig 6295: the preferred way to handle dependencies, and which uses the
1.77 rillig 6296: variables named above. See <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a> for more
1.75 rillig 6297: information.</p>
6298: <p>The basic difference between the two variables is as
6299: follows: The <code class="varname">DEPENDS</code> definition registers
6300: that pre-requisite in the binary package so it will be pulled in
6301: when the binary package is later installed, whilst the
6302: <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
6303: dependency that is only needed for building the package.
6304: </p>
6305: <p>This means that if you only need a package present whilst
6306: you are building, it should be noted as a
6307: <code class="varname">BUILD_DEPENDS</code>.</p>
6308: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
6309: <code class="varname">DEPENDS</code> definition is:</p>
6310: <pre class="programlisting">
6311: <pre-req-package-name>:../../<category>/<pre-req-package>
6312: </pre>
6313: <p>Please note that the “<span class="quote">pre-req-package-name</span>”
6314: may include any of the wildcard version numbers recognized by
6315: <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>
6316: <div class="orderedlist"><ol type="1">
6317: <li>
6318: <p>If your package needs another package's binaries or
6319: libraries to build or run, and if that package has a
1.76 rillig 6320: <code class="filename">buildlink3.mk</code> file available, use it:
1.75 rillig 6321: </p>
6322: <pre class="programlisting">
6323: .include "../../graphics/jpeg/buildlink3.mk"
6324: </pre>
6325: </li>
6326: <li>
6327: <p>If your package needs to use another package to build
1.76 rillig 6328: itself and there is no <code class="filename">buildlink3.mk</code>
1.75 rillig 6329: file available, use the <code class="varname">BUILD_DEPENDS</code>
6330: definition:</p>
6331: <pre class="programlisting">
6332: BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
6333: </pre>
6334: </li>
6335: <li>
6336: <p>If your package needs a library with which to link and
1.76 rillig 6337: again there is no <code class="filename">buildlink3.mk</code> file
1.75 rillig 6338: available, this is specified using the
6339: <code class="varname">DEPENDS</code> definition. For example:</p>
6340: <pre class="programlisting">
6341: DEPENDS+= xpm-3.4j:../../graphics/xpm
6342: </pre>
6343: <p>You can also use wildcards in package dependences:</p>
6344: <pre class="programlisting">
6345: DEPENDS+= xpm-[0-9]*:../../graphics/xpm
6346: </pre>
6347: <p>Note that such wildcard dependencies are retained when
6348: creating binary packages. The dependency is checked when
6349: installing the binary package and any package which matches
6350: the pattern will be used. Wildcard dependencies should be
6351: used with care.</p>
6352: <p>The “<span class="quote">-[0-9]*</span>” should be used instead of
6353: “<span class="quote">-*</span>” to avoid potentially ambiguous matches
6354: such as “<span class="quote">tk-postgresql</span>” matching a
6355: “<span class="quote">tk-*</span>” <code class="varname">DEPENDS</code>.</p>
6356: <p>Wildcards can also be used to specify that a package
6357: will only build against a certain minimum version of a
6358: pre-requisite:</p>
6359: <pre class="programlisting">
6360: DEPENDS+= tiff>=3.5.4:../../graphics/tiff
6361: </pre>
6362: <p>This means that the package will build against version
6363: 3.5.4 of the tiff library or newer. Such a dependency may
6364: be warranted if, for example, the API of the library has
6365: changed with version 3.5.4 and a package would not compile
6366: against an earlier version of tiff.</p>
6367: <p>Please note that such dependencies should only be
6368: updated if a package requires a newer pre-requisite, but
6369: not to denote recommendations such as
6370: ABI changes that do not prevent a package from building
6371: correctly. Such recommendations can be expressed using
6372: <code class="varname">ABI_DEPENDS</code>:</p>
6373: <pre class="programlisting">
6374: ABI_DEPENDS+= tiff>=3.6.1:../../graphics/tiff
6375: </pre>
6376: <p>In addition to the above <code class="varname">DEPENDS</code>
6377: line, this denotes that while a package will build against
6378: tiff>=3.5.4, at least version 3.6.1 is recommended.
6379: <code class="varname">ABI_DEPENDS</code> entries will be turned into
6380: dependencies unless explicitly ignored (in which case a
6381: warning will be printed).</p>
6382: <p>To ignore these ABI dependency recommendations and just
6383: use the required <code class="varname">DEPENDS</code>, set
6384: <code class="varname">USE_ABI_DEPENDS=NO</code>. This may make
6385: it easier and faster to update packages built using pkgsrc,
6386: since older compatible dependencies can continue to be
6387: used. This is useful for people who watch their rebuilds
6388: very carefully; it is not very good as a general-purpose
6389: hammer. If you use it, you need to be mindful of possible
6390: ABI changes, including those from the underlying OS.
6391: </p>
6392: <p>Packages that are built with recommendations ignored
6393: may not be uploaded to ftp.NetBSD.org by developers and
6394: should not be used across different systems that may have
6395: different versions of binary packages installed.</p>
6396: <p>For security fixes, please update the package
1.78 rillig 6397: vulnerabilities file. See <a href="#security-handling" title="17.1.10. Handling packages with security problems">Section 17.1.10, “Handling packages with security problems”</a> for more
1.75 rillig 6398: information.</p>
6399: </li>
6400: <li>
6401: <p>If your package needs some executable to be able to run
6402: correctly and if there's no
1.76 rillig 6403: <code class="filename">buildlink3.mk</code> file, this is specified
1.75 rillig 6404: using the <code class="varname">DEPENDS</code> variable. The
1.76 rillig 6405: <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 6406: be able to execute the latex binary from the teTeX package
6407: when it runs, and that is specified:</p>
6408: <pre class="programlisting">
6409: DEPENDS+= teTeX-[0-9]*:../../print/teTeX
6410: </pre>
6411: <p>The comment about wildcard dependencies from previous
6412: paragraph applies here, too.</p>
6413: </li>
6414: </ol></div>
6415: <p>If your package needs files from another package to build,
6416: add the relevant distribution files to
6417: <code class="varname">DISTFILES</code>, so they will be extracted
1.76 rillig 6418: 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 6419: (It relies on the jpeg sources being present in source form
6420: during the build.)</p>
6421: <p>Please also note the <code class="varname">BUILD_USES_MSGFMT</code>
6422: and <code class="varname">BUILD_USES_GETTEXT_M4</code> definitions, which
6423: are provided as convenience definitions. The former works out
6424: 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 6425: 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 6426: The latter adds a build dependency on either an installed
6427: version of an older gettext package, or if it isn't, installs the
1.76 rillig 6428: <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 6429: </div>
6430: <div class="sect2" lang="en">
6431: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6432: <a name="conflicts"></a>17.1.7. Handling conflicts with other packages</h3></div></div></div>
1.75 rillig 6433: <p>Your package may conflict with other packages a user might
6434: already have installed on his system, e.g. if your package
6435: installs the same set of files like another package in our
6436: pkgsrc tree.</p>
6437: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
6438: space-separated list of packages (including version string) your
6439: package conflicts with.</p>
1.76 rillig 6440: <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>
6441: 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 6442: install the same shared library, thus you set in
1.76 rillig 6443: <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
1.75 rillig 6444: <pre class="programlisting">
6445: CONFLICTS= Xaw-Xpm-[0-9]*
6446: </pre>
1.76 rillig 6447: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:
1.75 rillig 6448: </p>
6449: <pre class="programlisting">
6450: CONFLICTS= Xaw3d-[0-9]*
6451: </pre>
6452: <p>Packages will automatically conflict with other packages
6453: with the name prefix and a different version
6454: string. “<span class="quote">Xaw3d-1.5</span>” e.g. will automatically
6455: conflict with the older version “<span class="quote">Xaw3d-1.3</span>”.
6456: </p>
6457: </div>
6458: <div class="sect2" lang="en">
6459: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6460: <a name="not-building-packages"></a>17.1.8. Packages that cannot or should not be built</h3></div></div></div>
1.75 rillig 6461: <p>There are several reasons why a package might be
6462: instructed to not build under certain circumstances. If the
6463: package builds and runs on most platforms, the exceptions
6464: should be noted with <code class="varname">NOT_FOR_PLATFORM</code>. If
6465: the package builds and runs on a small handful of platforms,
6466: set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
6467: Both <code class="varname">ONLY_FOR_PLATFORM</code> and
6468: <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
6469: (OS-version-platform) that can use glob-style
6470: wildcards.</p>
6471: <p>If the package should be skipped (for example, because it
6472: provides functionality already provided by the system), set
6473: <code class="varname">PKG_SKIP_REASON</code> to a descriptive message.
6474: If the package should fail because some preconditions are not
6475: met, set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
6476: message.</p>
6477: </div>
6478: <div class="sect2" lang="en">
6479: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6480: <a name="undeletable-packages"></a>17.1.9. Packages which should not be deleted, once installed</h3></div></div></div>
1.75 rillig 6481: <p>To ensure that a package may not be deleted, once it has been
6482: installed, the <code class="varname">PKG_PRESERVE</code> definition should
6483: be set in the package Makefile. This will be carried into any
6484: binary package that is made from this pkgsrc entry. A
6485: “<span class="quote">preserved</span>” package will
6486: 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
6487: “<span class="quote">-f</span>” option is used.</p>
6488: </div>
6489: <div class="sect2" lang="en">
6490: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6491: <a name="security-handling"></a>17.1.10. Handling packages with security problems</h3></div></div></div>
1.75 rillig 6492: <p>When a vulnerability is found, this should be noted in
1.76 rillig 6493: <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
1.75 rillig 6494: and after committing that file, use <span><strong class="command">make upload</strong></span>
6495: in the same directory to update the file on ftp.NetBSD.org.</p>
6496: <p>After fixing the vulnerability by a patch, its
6497: <code class="varname">PKGREVISION</code> should be increased (this
6498: is of course not necessary if the problem is fixed by using
6499: a newer release of the software).</p>
6500: <p>Also, if the fix should be applied to the stable pkgsrc
6501: branch, be sure to submit a pullup request!</p>
6502: <p>Binary packages already on ftp.NetBSD.org will be handled
6503: semi-automatically by a weekly cron job.</p>
6504: </div>
6505: <div class="sect2" lang="en">
6506: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6507: <a name="bumping-pkgrevision"></a>17.1.11. How to handle incrementing versions when fixing an existing package</h3></div></div></div>
1.75 rillig 6508: <p>When making fixes to an existing package it can be useful
6509: to change the version number in <code class="varname">PKGNAME</code>. To
6510: avoid conflicting with future versions by the original author, a
6511: “<span class="quote">nb1</span>”, “<span class="quote">nb2</span>”, ... suffix can be used
6512: on package versions by setting <code class="varname">PKGREVISION=1</code>
6513: (2, ...). The “<span class="quote">nb</span>” is treated like a
6514: “<span class="quote">.</span>” by the pkg tools. e.g.</p>
6515: <pre class="programlisting">
6516: DISTNAME= foo-17.42
6517: PKGREVISION= 9
6518: </pre>
6519: <p>will result in a <code class="varname">PKGNAME</code> of
6520: “<span class="quote">foo-17.42nb9</span>”.</p>
6521: <p>When a new release of the package is released, the
6522: <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
6523: minor release of the above package, things should be like:</p>
6524: <pre class="programlisting">
6525: DISTNAME= foo-17.43
6526: </pre>
1.78 rillig 6527: <p>PKGREVISION should be incremented for any non-trivial change in the
6528: resulting binary package. Without a PKGREVISION bump, someone with
6529: the previous version installed has no way of knowing that their
6530: package is out of date. Thus, changes without increasing PKGREVISION
6531: are essentially labeled "this is so trivial that no reasonable person
6532: would want to upgrade", and this is the rough test for when increasing
6533: PKGREVISION is appropriate. Examples of changes that do not merit
6534: increasing PKGREVISION are:</p>
6535: <pre class="programlisting">
6536: Changing HOMEPAGE, MAINTAINER, or comments in Makefile.
6537: Changing build variables if the resulting binary package is the same.
6538: Changing DESCR.
6539: Adding PKG_OPTIONS if the default options don't change.
6540: </pre>
6541: <p>Examples of changes that do merit an increase to PKGREVISION
6542: include:</p>
6543: <pre class="programlisting">
6544: Security fixes
6545: Changes or additions to a patch file
6546: Changes to the PLIST
1.75 rillig 6547: </pre>
1.78 rillig 6548: <p>PKGREVISION must also be incremented when dependencies have ABI
6549: changes.</p>
1.75 rillig 6550: </div>
1.79 rillig 6551: <div class="sect2" lang="en">
6552: <div class="titlepage"><div><div><h3 class="title">
6553: <a name="fixes.subst"></a>17.1.12. Substituting variable text in the package files (the SUBST framework)</h3></div></div></div>
6554: <p>When you want to replace the same text in multiple files
6555: or when the replacement text varies, patches alone cannot help.
6556: This is where the SUBST framework comes in. It provides an
6557: easy-to-use interface for replacing text in files.
6558: Example:</p>
6559: <pre class="programlisting">
6560: SUBST_CLASSES+= fix-paths
6561: SUBST_STAGE.fix-paths= pre-configure
6562: SUBST_MESSAGE.fix-paths= Fixing absolute paths.
6563: SUBST_FILES.fix-paths= src/*.c
6564: SUBST_FILES.fix-paths+= scripts/*.sh
6565: SUBST_SED.fix-paths= -e 's,"/usr/local,"${PREFIX},g'
6566: SUBST_SED.fix-paths+= -e 's,"/var/log,"${VARBASE}/log,g'
6567: </pre>
6568: <p><code class="varname">SUBST_CLASSES</code> is a list of identifiers
6569: that are used to identify the different SUBST blocks that are
6570: defined. The SUBST framework is heavily used by pkgsrc, so it is
6571: important to always use the <code class="literal">+=</code> operator with
6572: this variable. Otherwise some substitutions may be
6573: skipped.</p>
6574: <p>The remaining variables of each SUBST block are
6575: parameterized with the identifier from the first line
6576: (<code class="literal">fix-paths</code> in this case.) They can be seen as
6577: parameters to a function call.</p>
6578: <p><code class="varname">SUBST_STAGE.*</code> specifies the stage at
6579: which the replacement will take place. All combinations of
6580: <code class="literal">pre-</code>, <code class="literal">do-</code> and
6581: <code class="literal">post-</code> together with a phase name are
6582: possible, though only few are actually used. Most commonly used
6583: are <code class="literal">post-patch</code> and
6584: <code class="literal">pre-configure</code>. Of these two,
6585: <code class="literal">pre-configure</code> should be preferred because
6586: then it is possible to run <span><strong class="command">bmake patch</strong></span> and
6587: have the state after applying the patches but before making any
6588: other changes. This is especially useful when you are debugging
6589: a package in order to create new patches for it. Similarly,
6590: <code class="literal">post-build</code> is preferred over
6591: <code class="literal">pre-install</code>, because the install phase should
6592: generally be kept as simple as possible. When you use
6593: <code class="literal">post-build</code>, you have the same files in the
6594: working directory that will be installed later, so you can check
6595: if the substitution has succeeded.</p>
6596: <p><code class="varname">SUBST_MESSAGE.*</code> is an optional text
6597: that is printed just before the substitution is done.</p>
6598: <p><code class="varname">SUBST_FILES.*</code> is the list of shell
6599: globbing patterns that specifies the files in which the
6600: substitution will take place. The patterns are interpreted
6601: relatively to the <code class="varname">WRKSRC</code> directory.</p>
6602: <p><code class="varname">SUBST_SED.*</code> is a list of arguments to
6603: <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 specify the actual substitution. Every sed
6604: command should be prefixed with <code class="literal">-e</code>, so that
6605: all SUBST blocks look uniform.</p>
6606: <p>There are some more variables, but they are so seldomly
6607: used that they are only documented in the
1.80 ! rillig 6608: <code class="filename">mk/subst.mk</code> file.</p>
1.79 rillig 6609: </div>
1.75 rillig 6610: </div>
6611: <div class="sect1" lang="en">
6612: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6613: <a name="fixes.fetch"></a>17.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.75 rillig 6614: <div class="sect2" lang="en">
6615: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6616: <a name="no-plain-download"></a>17.2.1. Packages whose distfiles aren't available for plain downloading</h3></div></div></div>
1.75 rillig 6617: <p>If you need to download from a dynamic URL you can set
6618: <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span><strong class="command">make
1.76 rillig 6619: fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
1.75 rillig 6620: with the name of each file to download as an argument, expecting
6621: it to output the URL of the directory from which to download
1.76 rillig 6622: 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.79 rillig 6623: example of this usage.</p>
1.75 rillig 6624: <p>If the download can't be automated, because the user must
6625: submit personal information to apply for a password, or must pay
6626: for the source, or whatever, you can set
6627: <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
6628: displayed to the user before aborting the build. Example:</p>
6629: <pre class="programlisting">
6630: FETCH_MESSAGE= "Please download the files"
6631: FETCH_MESSAGE+= " "${DISTFILES:Q}
6632: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
6633: </pre>
6634: </div>
6635: <div class="sect2" lang="en">
6636: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6637: <a name="modified-distfiles-same-name"></a>17.2.2. How to handle modified distfiles with the 'old' name</h3></div></div></div>
1.75 rillig 6638: <p>Sometimes authors of a software package make some
6639: modifications after the software was released, and they put up a
6640: new distfile without changing the package's version number. If a
6641: package is already in pkgsrc at that time, the checksum will
6642: no longer match. The contents of the new distfile should be
6643: compared against the old one before changing anything, to make
6644: sure the distfile was really updated on purpose, and that
6645: no trojan horse or so crept in.
6646: Then, the correct way to work around this is to
6647: set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
6648: usually based on <code class="varname">PKGNAME_NOREV</code>. In case this
6649: happens more often, <code class="varname">PKGNAME</code> can be used (thus
1.76 rillig 6650: including the <code class="filename">nbX</code> suffix) or a date stamp
1.75 rillig 6651: can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
1.76 rillig 6652: Do not forget regenerating the <code class="filename">distinfo</code> file
1.75 rillig 6653: after that, since it contains the <code class="varname">DIST_SUBDIR</code>
6654: path in the filenames.
6655: Furthermore, a mail to the package's authors seems appropriate
6656: telling them that changing distfiles after releases without
6657: changing the file names is not good practice.</p>
6658: </div>
6659: </div>
6660: <div class="sect1" lang="en">
6661: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6662: <a name="fixes.configure"></a>17.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.75 rillig 6663: <div class="sect2" lang="en">
6664: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6665: <a name="fixes.libtool"></a>17.3.1. Shared libraries - libtool</h3></div></div></div>
1.75 rillig 6666: <p>pkgsrc supports many different machines, with different
6667: object formats like a.out and ELF, and varying abilities to do
6668: shared library and dynamic loading at all. To accompany this,
6669: varying commands and options have to be passed to the
6670: compiler, linker, etc. to get the Right Thing, which can be
6671: pretty annoying especially if you don't have all the machines
6672: at your hand to test things. The
1.76 rillig 6673: <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 6674: can help here, as it just “<span class="quote">knows</span>” how to build
6675: both static and dynamic libraries from a set of source files,
6676: thus being platform-independent.</p>
6677: <p>Here's how to use libtool in a pkg in seven simple
6678: steps:</p>
6679: <div class="orderedlist"><ol type="1">
6680: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
6681: Makefile.</p></li>
6682: <li><p>For library objects, use “<span class="quote">${LIBTOOL} --mode=compile
6683: ${CC}</span>” in place of “<span class="quote">${CC}</span>”. You could even
6684: add it to the definition of <code class="varname">CC</code>, if only
6685: libraries are being built in a given Makefile. This one command
6686: will build both PIC and non-PIC library objects, so you need not
6687: have separate shared and non-shared library rules.</p></li>
6688: <li>
6689: <p>For the linking of the library, remove any
6690: “<span class="quote">ar</span>”, “<span class="quote">ranlib</span>”, and “<span class="quote">ld
6691: -Bshareable</span>” commands, and instead use:</p>
6692: <pre class="programlisting">
6693: ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
6694: -rpath ${PREFIX}/lib -version-info major:minor
6695: </pre>
6696: <p>Note that the library is changed to have a
1.76 rillig 6697: <code class="filename">.la</code> extension, and the objects are
6698: changed to have a <code class="filename">.lo</code>
1.75 rillig 6699: extension. Change <code class="varname">OBJS</code> as
6700: necessary. This automatically creates all of the
1.76 rillig 6701: <code class="filename">.a</code>,
6702: <code class="filename">.so.major.minor</code>, and ELF symlinks (if
1.75 rillig 6703: necessary) in the build directory. Be sure to include
6704: “<span class="quote">-version-info</span>”, especially when major and
6705: minor are zero, as libtool will otherwise strip off the
6706: shared library version.</p>
6707: <p>From the libtool manual:</p>
6708: <pre class="programlisting">
6709: So, libtool library versions are described by three integers:
1.69 rillig 6710:
1.75 rillig 6711: CURRENT
6712: The most recent interface number that this library implements.
1.69 rillig 6713:
1.75 rillig 6714: REVISION
6715: The implementation number of the CURRENT interface.
1.69 rillig 6716:
1.75 rillig 6717: AGE
6718: The difference between the newest and oldest interfaces that
6719: this library implements. In other words, the library implements
6720: all the interface numbers in the range from number `CURRENT -
6721: AGE' to `CURRENT'.
1.1 grant 6722:
1.75 rillig 6723: If two libraries have identical CURRENT and AGE numbers, then the
6724: dynamic linker chooses the library with the greater REVISION number.
6725: </pre>
6726: <p>The “<span class="quote">-release</span>” option will produce
6727: different results for a.out and ELF (excluding symlinks)
6728: in only one case. An ELF library of the form
6729: “<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
6730: will have a symlink of
6731: “<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
6732: on an a.out platform. This is handled
6733: automatically.</p>
6734: <p>The “<span class="quote">-rpath argument</span>” is the install
6735: directory of the library being built.</p>
1.76 rillig 6736: <p>In the <code class="filename">PLIST</code>, include only the
6737: <code class="filename">.la</code> file, the other files will be
1.75 rillig 6738: added automatically.</p>
6739: </li>
6740: <li>
1.76 rillig 6741: <p>When linking shared object (<code class="filename">.so</code>)
1.75 rillig 6742: 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
6743: shared libraries, use “<span class="quote">-module
6744: -avoid-version</span>” to prevent them getting version
6745: tacked on.</p>
1.76 rillig 6746: <p>The <code class="filename">PLIST</code> file gets the
6747: <code class="filename">foo.so</code> entry.</p>
1.75 rillig 6748: </li>
6749: <li>
6750: <p>When linking programs that depend on these libraries
6751: <span class="emphasis"><em>before</em></span> they are installed, preface
6752: 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}
6753: --mode=link</span>”, and it will find the correct
6754: libraries (static or shared), but please be aware that
6755: libtool will not allow you to specify a relative path in
6756: -L (such as “<span class="quote">-L../somelib</span>”), because it
6757: expects you to change that argument to be the
1.76 rillig 6758: <code class="filename">.la</code> file. e.g.</p>
1.75 rillig 6759: <pre class="programlisting">
6760: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
6761: </pre>
6762: <p>should be changed to:</p>
6763: <pre class="programlisting">
6764: ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
6765: </pre>
6766: <p>and it will do the right thing with the libraries.</p>
6767: </li>
6768: <li>
6769: <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>
6770: 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}
6771: --mode=install</span>”, and change the library name to
1.76 rillig 6772: <code class="filename">.la</code>. e.g.</p>
1.75 rillig 6773: <pre class="programlisting">
6774: ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
6775: </pre>
1.76 rillig 6776: <p>This will install the static <code class="filename">.a</code>,
1.75 rillig 6777: shared library, any needed symlinks, and run
6778: <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>
6779: </li>
1.76 rillig 6780: <li><p>In your <code class="filename">PLIST</code>, include only
6781: the <code class="filename">.la</code>
1.75 rillig 6782: file (this is a change from previous behaviour).</p></li>
6783: </ol></div>
6784: </div>
6785: <div class="sect2" lang="en">
6786: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6787: <a name="using-libtool"></a>17.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
1.75 rillig 6788: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
6789: package Makefile. This will override the package's own libtool
6790: in most cases. For older libtool using packages, libtool is
6791: made by ltconfig script during the do-configure step; you can
6792: check the libtool script location by doing <span><strong class="command">make
6793: configure; find work*/ -name libtool</strong></span>.</p>
6794: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
6795: scripts, relative to <code class="varname">WRKSRC</code>, to override. By
6796: default, it is set to “<span class="quote">libtool */libtool
6797: */*/libtool</span>”. If this does not match the location of the
6798: package's libtool script(s), set it as appropriate.</p>
1.76 rillig 6799: <p>If you do not need <code class="filename">*.a</code> static
1.75 rillig 6800: libraries built and installed, then use
6801: <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
6802: <p>If your package makes use of the platform-independent library
6803: for loading dynamic shared objects, that comes with libtool
6804: (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
6805: <p>Some packages use libtool incorrectly so that the package may not work or
6806: build in some circumstances. Some of the more common errors are:</p>
6807: <div class="itemizedlist"><ul type="disc">
6808: <li>
6809: <p>The inclusion of a shared object (-module) as a dependent library in an
6810: executable or library. This in itself isn't a problem if one of two things
6811: has been done:</p>
6812: <div class="orderedlist"><ol type="1">
6813: <li><p>The shared object is named correctly, i.e.
1.76 rillig 6814: <code class="filename">libfoo.la</code>, not
6815: <code class="filename">foo.la</code></p></li>
1.75 rillig 6816: <li><p>The -dlopen option is used when linking an executable.</p></li>
6817: </ol></div>
6818: </li>
6819: <li><p>The use of libltdl without the correct calls to initialisation routines.
6820: The function lt_dlinit() should be called and the macro
6821: <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
6822: executables.</p></li>
6823: </ul></div>
6824: </div>
6825: <div class="sect2" lang="en">
6826: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6827: <a name="autoconf-automake"></a>17.3.3. GNU Autoconf/Automake</h3></div></div></div>
1.75 rillig 6828: <p>If a package needs GNU autoconf or automake to be executed
6829: to regenerate the configure script and Makefile.in makefile
6830: templates, then they should be executed in a pre-configure
6831: target.</p>
6832: <p>For packages that need only autoconf:</p>
6833: <pre class="programlisting">
6834: AUTOCONF_REQD= 2.50 # if default version is not good enough
6835: USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
6836: ...
1.1 grant 6837:
1.75 rillig 6838: pre-configure:
6839: cd ${WRKSRC}; autoconf
1.1 grant 6840:
1.75 rillig 6841: ...
6842: </pre>
6843: <p>and for packages that need automake and autoconf:</p>
6844: <pre class="programlisting">
6845: AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
6846: USE_TOOLS+= automake # use "automake14" for automake-1.4
6847: ...
1.1 grant 6848:
1.75 rillig 6849: pre-configure:
6850: cd ${WRKSRC}; \
6851: aclocal; autoheader; \
6852: automake -a --foreign -i; autoconf
1.1 grant 6853:
1.75 rillig 6854: ...
6855: </pre>
6856: <p>Packages which use GNU Automake will almost certainly
6857: require GNU Make.</p>
6858: <p>There are times when the configure process makes
6859: additional changes to the generated files, which then causes
6860: the build process to try to re-execute the automake sequence.
6861: This is prevented by touching various files in the configure
6862: stage. If this causes problems with your package you can set
6863: <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
6864: Makefile.</p>
6865: </div>
6866: </div>
6867: <div class="sect1" lang="en">
6868: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6869: <a name="fixes.build"></a>17.4. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
6870: <p>The most common failures when building a package are that
6871: some platforms do not provide certain header files, functions or
6872: libraries, or they provide the functions in a library that the
6873: original package author didn't know. To work around this, you
6874: can rewrite the source code in most cases so that it does not
6875: use the missing functions or provides a replacement function.</p>
6876: <div class="sect2" lang="en">
6877: <div class="titlepage"><div><div><h3 class="title">
6878: <a name="fixes.build.cpp"></a>17.4.1. Compiling C and C++ code conditionally</h3></div></div></div>
6879: <p>If a package already comes with a GNU configure script, the
6880: preferred way to fix the build failure is to change the
6881: configure script, not the code. In the other cases, you can
6882: utilize the C preprocessor, which defines certain macros
6883: depending on the operating system and hardware architecture it
6884: compiles for. These macros can be queried using for example
6885: <code class="varname">#if defined(__i386)</code>. Almost every operating
6886: system, hardware architecture and compiler has its own macro.
6887: For example, if the macros <code class="varname">__GNUC__</code>,
6888: <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
6889: are all defined, you know that you are using NetBSD on an i386
6890: compatible CPU, and your compiler is GCC.</p>
6891: <p>The list of the following macros for hardware and
6892: operating system depends on the compiler that is used. For
6893: example, if you want to conditionally compile code on Solaris,
6894: don't use <code class="varname">__sun__</code>, as the SunPro compiler
6895: does not define it. Use <code class="varname">__sun</code> instead.</p>
1.75 rillig 6896: <div class="sect3" lang="en">
6897: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 6898: <a name="fixes.build.cpp.os"></a>17.4.1.1. C preprocessor macros to identify the operating system</h4></div></div></div>
1.75 rillig 6899: <p>To distinguish between 4.4 BSD-derived systems and the
6900: rest of the world, you should use the following code.</p>
6901: <pre class="programlisting">
6902: #include <sys/param.h>
6903: #if (defined(BSD) && BSD >= 199306)
6904: /* BSD-specific code goes here */
6905: #else
6906: /* non-BSD-specific code goes here */
6907: #endif
6908: </pre>
1.77 rillig 6909: <p>If this distinction is not fine enough, you can also test
6910: for the following macros.</p>
1.75 rillig 6911: <pre class="programlisting">
6912: FreeBSD __FreeBSD__
6913: DragonFly __DragonFly__
6914: Interix __INTERIX
6915: Linux linux, __linux, __linux__
6916: NetBSD __NetBSD__
6917: OpenBSD __OpenBSD__
6918: Solaris sun, __sun
6919: </pre>
6920: </div>
6921: <div class="sect3" lang="en">
6922: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 6923: <a name="fixes.build.cpp.arch"></a>17.4.1.2. C preprocessor macros to identify the hardware architecture</h4></div></div></div>
1.75 rillig 6924: <pre class="programlisting">
6925: i386 i386, __i386, __i386__
6926: MIPS __mips
6927: SPARC sparc, __sparc
6928: </pre>
6929: </div>
6930: <div class="sect3" lang="en">
6931: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 6932: <a name="fixes.build.cpp.compiler"></a>17.4.1.3. C preprocessor macros to identify the compiler</h4></div></div></div>
1.75 rillig 6933: <pre class="programlisting">
6934: GCC __GNUC__ (major version), __GNUC_MINOR__
6935: SunPro __SUNPRO_C (0x570 for version 5.7)
6936: </pre>
6937: </div>
6938: </div>
1.78 rillig 6939: <div class="sect2" lang="en">
6940: <div class="titlepage"><div><div><h3 class="title">
6941: <a name="compiler-bugs"></a>17.4.2. How to handle compiler bugs</h3></div></div></div>
6942: <p>Some source files trigger bugs in the compiler, based on
6943: combinations of compiler version and architecture and almost
6944: always relation to optimisation being enabled. Common symptoms
6945: are gcc internal errors or never finishing compiling a
6946: file.</p>
6947: <p>Typically, a workaround involves testing the
6948: <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
6949: optimisation for that combination of file,
6950: <code class="varname">MACHINE_ARCH</code> and compiler, and documenting it
6951: in <code class="filename">pkgsrc/doc/HACKS</code>. See that file for a
6952: number of examples.</p>
6953: </div>
6954: <div class="sect2" lang="en">
6955: <div class="titlepage"><div><div><h3 class="title">
6956: <a name="undefined-reference"></a>17.4.3. Undefined reference to “<span class="quote">...</span>”</h3></div></div></div>
6957: <p>This compiler error often means that a package did not
6958: link to a shared library it needs. The following functions are
6959: known to cause this error message over and over.</p>
6960: <div class="informaltable">
6961: <a name="undefined-reference-functions"></a><table border="1">
6962: <colgroup>
6963: <col>
6964: <col>
6965: <col>
6966: </colgroup>
6967: <thead><tr>
6968: <th>Function</th>
6969: <th>Library</th>
6970: <th>Affected platforms</th>
6971: </tr></thead>
6972: <tbody>
6973: <tr>
6974: <td>accept, bind, connect</td>
6975: <td>-lsocket</td>
6976: <td>Solaris</td>
6977: </tr>
6978: <tr>
6979: <td>crypt</td>
6980: <td>-lcrypt</td>
6981: <td>DragonFly, NetBSD</td>
6982: </tr>
6983: <tr>
6984: <td>dlopen, dlsym</td>
6985: <td>-ldl</td>
6986: <td>Linux</td>
6987: </tr>
6988: <tr>
6989: <td>gethost*</td>
6990: <td>-lnsl</td>
6991: <td>Solaris</td>
6992: </tr>
6993: <tr>
6994: <td>inet_aton</td>
6995: <td>-lresolv</td>
6996: <td>Solaris</td>
6997: </tr>
6998: <tr>
6999: <td>nanosleep, sem_*, timer_*</td>
7000: <td>-lrt</td>
7001: <td>Solaris</td>
7002: </tr>
7003: <tr>
7004: <td>openpty</td>
7005: <td>-lutil</td>
7006: <td>Linux</td>
7007: </tr>
7008: </tbody>
7009: </table>
7010: </div>
7011: <p>To fix these linker errors, it is often sufficient to say
7012: <code class="literal">LIBS.<em class="replaceable"><code>OperatingSystem</code></em>+=
7013: -l<em class="replaceable"><code>foo</code></em></code> to the package
7014: <code class="filename">Makefile</code> and then say <span><strong class="command">bmake clean;
7015: bmake</strong></span>.</p>
7016: </div>
1.75 rillig 7017: </div>
7018: <div class="sect1" lang="en">
7019: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 7020: <a name="fixes.install"></a>17.5. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75 rillig 7021: <div class="sect2" lang="en">
7022: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7023: <a name="install-scripts"></a>17.5.1. Creating needed directories</h3></div></div></div>
7024: <p>The BSD-compatible <span><strong class="command">install</strong></span> supplied
7025: with some operating systems cannot create more than one
7026: directory at a time. As such, you should call
7027: <code class="literal">${INSTALL_*_DIR}</code> like this:</p>
1.75 rillig 7028: <pre class="programlisting">
1.78 rillig 7029: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
7030: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
1.75 rillig 7031: </pre>
1.78 rillig 7032: <p>You can also just append “<span class="quote"><code class="literal">dir1
7033: dir2</code></span>” to the
7034: <code class="varname">INSTALLATION_DIRS</code> variable, which will
7035: automatically do the right thing.</p>
1.75 rillig 7036: </div>
7037: <div class="sect2" lang="en">
7038: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7039: <a name="where-to-install-documentation"></a>17.5.2. Where to install documentation</h3></div></div></div>
7040: <p>Documentation should be installed into
7041: <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
7042: <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the latter
7043: includes the version number of the package).</p>
1.75 rillig 7044: </div>
7045: <div class="sect2" lang="en">
7046: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7047: <a name="installing-score-files"></a>17.5.3. Installing score files</h3></div></div></div>
1.75 rillig 7048: <p>Certain packages, most of them in the games category, install
7049: a score file that allows all users on the system to record their
7050: highscores. In order for this to work, the binaries need to be
7051: installed setgid and the score files owned by the appropriate
7052: group and/or owner (traditionally the "games" user/group). The
7053: following variables, documented in more detail in
1.76 rillig 7054: <code class="filename">mk/defaults/mk.conf</code>, control this
1.75 rillig 7055: behaviour: <code class="varname">SETGIDGAME</code>,
7056: <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
7057: <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
7058: <p>Note that per default, setgid installation of games is
7059: disabled; setting <code class="varname">SETGIDGAME=YES</code> will set all
7060: the other variables accordingly.</p>
7061: <p>A package should therefor never hard code file ownership or
7062: access permissions but rely on <code class="varname">INSTALL_GAME</code> and
7063: <code class="varname">INSTALL_GAME_DATA</code> to set these
7064: correctly.</p>
7065: </div>
7066: <div class="sect2" lang="en">
7067: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7068: <a name="perl-scripts"></a>17.5.4. Packages containing perl scripts</h3></div></div></div>
1.75 rillig 7069: <p>
7070: If your package contains interpreted perl scripts, set
7071: <code class="varname">REPLACE_PERL</code> to ensure that the proper
7072: interpreter path is set. <code class="varname">REPLACE_PERL</code> should
7073: contain a list of scripts, relative to
7074: <code class="varname">WRKSRC</code>, that you want adjusted.</p>
7075: </div>
7076: <div class="sect2" lang="en">
7077: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7078: <a name="hardcoded-paths"></a>17.5.5. Packages with hardcoded paths to other interpreters</h3></div></div></div>
1.75 rillig 7079: <p>
7080: Your package may also contain scripts with hardcoded paths to
7081: other interpreters besides (or as well as) perl. To correct the
7082: full pathname to the script interpreter, you need to set the
1.76 rillig 7083: following definitions in your <code class="filename">Makefile</code> (we
1.75 rillig 7084: shall use <span><strong class="command">tclsh</strong></span> in this example):</p>
7085: <pre class="programlisting">
7086: REPLACE_INTERPRETER+= tcl
7087: REPLACE.tcl.old= .*/bin/tclsh
7088: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
7089: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
7090: # relative to ${WRKSRC}, just as in REPLACE_PERL
7091: </pre>
7092: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7093: <h3 class="title">Note</h3>
7094: <p>Before March 2006, these variables were called
7095: <code class="varname">_REPLACE.*</code> and
7096: <code class="varname">_REPLACE_FILES.*</code>.</p>
7097: </div>
7098: </div>
7099: <div class="sect2" lang="en">
7100: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7101: <a name="perl-modules"></a>17.5.6. Packages installing perl modules</h3></div></div></div>
1.75 rillig 7102: <p>Makefiles of packages providing perl5 modules should include
7103: the Makefile fragment
1.76 rillig 7104: <code class="filename">../../lang/perl5/module.mk</code>. It provides a
1.75 rillig 7105: <span><strong class="command">do-configure</strong></span> target for the standard perl
7106: configuration for such modules as well as various hooks to tune
7107: this configuration. See comments in this file for
7108: details.</p>
7109: <p>Perl5 modules will install into different places depending
7110: on the version of perl used during the build process. To
7111: address this, pkgsrc will append lines to the
1.76 rillig 7112: <code class="filename">PLIST</code> corresponding to the files listed in
7113: the installed <code class="filename">.packlist</code> file generated by
1.75 rillig 7114: most perl5 modules. This is invoked by defining
7115: <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
7116: paths to packlist files, e.g.:</p>
7117: <pre class="programlisting">
7118: PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
7119: </pre>
7120: <p>The variables <code class="varname">PERL5_SITELIB</code>,
7121: <code class="varname">PERL5_SITEARCH</code>, and
7122: <code class="varname">PERL5_ARCHLIB</code> represent the three locations
7123: in which perl5 modules may be installed, and may be used by
7124: perl5 packages that don't have a packlist. These three
7125: variables are also substituted for in the
1.76 rillig 7126: <code class="filename">PLIST</code>.</p>
1.75 rillig 7127: </div>
7128: <div class="sect2" lang="en">
7129: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7130: <a name="faq.info-files"></a>17.5.7. Packages installing info files</h3></div></div></div>
1.75 rillig 7131: <p>Some packages install info files or use the
7132: “<span class="quote">makeinfo</span>” or “<span class="quote">install-info</span>”
7133: commands. <code class="varname">INFO_FILES</code> should be defined in
1.76 rillig 7134: the package Makefile so that <code class="filename">INSTALL</code> and
7135: <code class="filename">DEINSTALL</code> scripts will be generated to
1.75 rillig 7136: handle registration of the info files in the Info directory
7137: file. The “<span class="quote">install-info</span>” command used for the info
7138: files registration is either provided by the system, or by a
7139: special purpose package automatically added as dependency if
7140: needed.</p>
7141: <p><code class="varname">PKGINFODIR</code> is the directory under
1.76 rillig 7142: <code class="filename">${PREFIX}</code> where info files are primarily
1.75 rillig 7143: located. <code class="varname">PKGINFODIR</code> defaults to
7144: “<span class="quote">info</span>” and can be overridden by the user.</p>
7145: <p>The info files for the package should be listed in the
1.76 rillig 7146: package <code class="filename">PLIST</code>; however any split info files
1.75 rillig 7147: need not be listed.</p>
7148: <p>A package which needs the “<span class="quote">makeinfo</span>” command
7149: at build time must add “<span class="quote">makeinfo</span>” to
7150: <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
7151: version of the “<span class="quote">makeinfo</span>” command is needed it
7152: should be noted with the <code class="varname">TEXINFO_REQD</code>
1.76 rillig 7153: variable in the package <code class="filename">Makefile</code>. By
1.75 rillig 7154: default, a minimum version of 3.12 is required. If the system
7155: does not provide a <span><strong class="command">makeinfo</strong></span> command or if it
7156: does not match the required minimum, a build dependency on the
1.76 rillig 7157: <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 7158: be added automatically.</p>
7159: <p>The build and installation process of the software provided
7160: by the package should not use the
7161: <span><strong class="command">install-info</strong></span> command as the registration of
7162: info files is the task of the package
1.76 rillig 7163: <code class="filename">INSTALL</code> script, and it must use the
1.75 rillig 7164: appropriate <span><strong class="command">makeinfo</strong></span> command.</p>
7165: <p>To achieve this goal, the pkgsrc infrastructure creates
7166: overriding scripts for the <span><strong class="command">install-info</strong></span> and
7167: <span><strong class="command">makeinfo</strong></span> commands in a directory listed early
7168: in <code class="varname">PATH</code>.</p>
7169: <p>The script overriding <span><strong class="command">install-info</strong></span> has
7170: no effect except the logging of a message. The script overriding
7171: <span><strong class="command">makeinfo</strong></span> logs a message and according to the
7172: value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
7173: <span><strong class="command">makeinfo</strong></span> command or exit on error.</p>
7174: </div>
7175: <div class="sect2" lang="en">
7176: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7177: <a name="manpages"></a>17.5.8. Packages installing man pages</h3></div></div></div>
1.75 rillig 7178: <p>Many packages install manual pages. The man pages
7179: are installed under <code class="varname">${PREFIX}/${PKGMANDIR}</code>
1.76 rillig 7180: which is <code class="filename">/usr/pkg/man</code> by default.
1.75 rillig 7181: <code class="varname">PKGMANDIR</code> defaults to “<span class="quote">man</span>”.
7182: For example, you can set <code class="varname">PKGMANDIR</code> to
7183: “<span class="quote">share/man</span>” to have man pages install under
1.76 rillig 7184: <code class="filename">/usr/pkg/share/man/</code> by default.
1.75 rillig 7185: </p>
7186: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7187: <h3 class="title">Note</h3>
7188: <p>The support for a custom <code class="varname">PKGMANDIR</code>
7189: is not complete.
7190: </p>
7191: </div>
1.76 rillig 7192: <p>The <code class="filename">PLIST</code> files can just
7193: use <code class="filename">man/</code> as the top level directory
1.75 rillig 7194: for the man page file entries
7195: and the pkgsrc framework will convert as needed.
7196: </p>
7197: <p> Packages that are
7198: configured with <code class="varname">GNU_CONFIGURE</code> set as
7199: “<span class="quote">yes</span>”, by default will use the
1.76 rillig 7200: <code class="filename">./configure</code>
1.75 rillig 7201: --mandir switch to set where the man pages should be installed.
7202: The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
7203: to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.
7204: </p>
7205: <p>
7206: Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
7207: use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
7208: to “<span class="quote">no</span>”.
1.76 rillig 7209: Or if the <code class="filename">./configure</code> script uses
1.75 rillig 7210: a non-standard use of --mandir, you can set
7211: <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.
7212: </p>
1.77 rillig 7213: <p>See <a href="#manpage-compression" title="11.5. Man page compression">Section 11.5, “Man page compression”</a> for
1.75 rillig 7214: information on installation of compressed manual pages.
7215: </p>
7216: </div>
7217: <div class="sect2" lang="en">
7218: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7219: <a name="gconf2-data-files"></a>17.5.9. Packages installing GConf2 data files</h3></div></div></div>
1.75 rillig 7220: <p>
1.76 rillig 7221: If a package installs <code class="filename">.schemas</code> or
7222: <code class="filename">.entries</code> files, used by GConf2,
1.75 rillig 7223: you need to take some extra steps to make sure they get registered
7224: in the database:
7225: </p>
7226: <div class="orderedlist"><ol type="1">
1.76 rillig 7227: <li><p>Include <code class="filename">../../devel/GConf2/schemas.mk</code>
7228: instead of its <code class="filename">buildlink3.mk</code> file. This
1.75 rillig 7229: takes care of rebuilding the GConf2 database at installation and
7230: deinstallation time, and tells the package where to install
7231: GConf2 data files using some standard configure arguments. It
7232: also disallows any access to the database directly from the
7233: package.</p></li>
7234: <li><p>Ensure that the package installs its
1.76 rillig 7235: <code class="filename">.schemas</code> files under
7236: <code class="filename">${PREFIX}/share/gconf/schemas</code>. If they get
7237: installed under <code class="filename">${PREFIX}/etc</code>, you will
1.75 rillig 7238: need to manually patch the package.</p></li>
7239: <li><p>Check the PLIST and remove any entries under the etc/gconf
7240: directory, as they will be handled automatically. See
7241: <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>
7242: <li><p>Define the <code class="varname">GCONF2_SCHEMAS</code> variable in
1.76 rillig 7243: your <code class="filename">Makefile</code> with a list of all
7244: <code class="filename">.schemas</code> files installed by the package, if
1.75 rillig 7245: any. Names must not contain any directories in them.</p></li>
7246: <li><p>Define the <code class="varname">GCONF2_ENTRIES</code> variable in
1.76 rillig 7247: your <code class="filename">Makefile</code> with a
7248: list of all <code class="filename">.entries</code> files installed by the
1.75 rillig 7249: package, if any. Names must not contain any directories in
7250: them.</p></li>
7251: </ol></div>
7252: </div>
7253: <div class="sect2" lang="en">
7254: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7255: <a name="scrollkeeper-data-files"></a>17.5.10. Packages installing scrollkeeper data files</h3></div></div></div>
1.75 rillig 7256: <p>
1.76 rillig 7257: If a package installs <code class="filename">.omf</code> files, used by
1.75 rillig 7258: scrollkeeper, you need to take some extra steps to make sure they
7259: get registered in the database:
7260: </p>
7261: <div class="orderedlist"><ol type="1">
7262: <li><p>Include
1.76 rillig 7263: <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
7264: instead of its <code class="filename">buildlink3.mk</code> file. This
1.75 rillig 7265: takes care of rebuilding the scrollkeeper database at
7266: installation and deinstallation time, and disallows any access
7267: to it directly from the package.
7268: </p></li>
7269: <li><p>Check the PLIST and remove any entries under the
1.76 rillig 7270: <code class="filename">libdata/scrollkeeper</code> directory, as they
1.75 rillig 7271: will be handled automatically.</p></li>
1.76 rillig 7272: <li><p>Remove the <code class="filename">share/omf</code> directory from
1.75 rillig 7273: the PLIST. It will be handled by scrollkeeper.</p></li>
7274: </ol></div>
7275: </div>
7276: <div class="sect2" lang="en">
7277: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7278: <a name="x11-fonts"></a>17.5.11. Packages installing X11 fonts</h3></div></div></div>
1.75 rillig 7279: <p>If a package installs font files, you will need to rebuild
7280: the fonts database in the directory where they get installed at
7281: installation and deinstallation time. This can be automatically
7282: done by using the pkginstall framework.</p>
7283: <p>You can list the directories where fonts are installed in the
7284: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
7285: variables, where <em class="replaceable"><code>type</code></em> can be one of
7286: “<span class="quote">ttf</span>”, “<span class="quote">type1</span>” or “<span class="quote">x11</span>”.
7287: Also make sure that the database file
1.76 rillig 7288: <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
1.75 rillig 7289: <p>Note that you should not create new directories for fonts;
7290: instead use the standard ones to avoid that the user needs to
7291: manually configure his X server to find them.</p>
7292: </div>
7293: <div class="sect2" lang="en">
7294: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7295: <a name="gtk2-modules"></a>17.5.12. Packages installing GTK2 modules</h3></div></div></div>
1.75 rillig 7296: <p>If a package installs GTK2 immodules or loaders, you need to
7297: take some extra steps to get them registered in the GTK2 database
7298: properly:</p>
7299: <div class="orderedlist"><ol type="1">
7300: <li><p>Include
1.76 rillig 7301: <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
7302: <code class="filename">buildlink3.mk</code> file. This takes care of
1.75 rillig 7303: rebuilding the database at installation and deinstallation time.
7304: </p></li>
7305: <li><p>
7306: Set <code class="varname">GTK2_IMMODULES=YES</code> if
7307: your package installs GTK2 immodules.</p></li>
7308: <li><p>
7309: Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
7310: GTK2 loaders.</p></li>
7311: <li>
7312: <p>
7313: Patch the package to not touch any of the GTK2 databases directly.
7314: These are:
7315:
7316: </p>
7317: <div class="itemizedlist"><ul type="disc">
1.76 rillig 7318: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
7319: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
1.75 rillig 7320: </ul></div>
7321: <p>
7322: </p>
7323: </li>
7324: <li><p>
7325: Check the PLIST and remove any entries under the
1.76 rillig 7326: <code class="filename">libdata/gtk-2.0</code> directory, as they will be
1.75 rillig 7327: handled automatically.</p></li>
7328: </ol></div>
7329: </div>
7330: <div class="sect2" lang="en">
7331: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7332: <a name="sgml-xml-data"></a>17.5.13. Packages installing SGML or XML data</h3></div></div></div>
1.75 rillig 7333: <p>If a package installs SGML or XML data files that need to be
7334: registered in system-wide catalogs (like DTDs, sub-catalogs,
7335: etc.), you need to take some extra steps:
7336: </p>
7337: <div class="orderedlist"><ol type="1">
7338: <li><p>Include
1.76 rillig 7339: <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
7340: your <code class="filename">Makefile</code>, which takes care of
1.75 rillig 7341: registering those files in system-wide catalogs at
7342: installation and deinstallation time.</p></li>
7343: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
7344: any SGML catalogs installed by the package.</p></li>
7345: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
7346: any XML catalogs installed by the package.</p></li>
7347: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
7348: to be added to the SGML catalog. These come in groups of
7349: three strings; see xmlcatmgr(1) for more information
7350: (specifically, arguments recognized by the 'add' action).
7351: Note that you will normally not use this variable.</p></li>
7352: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
7353: to be added to the XML catalog. These come in groups of three
7354: strings; see xmlcatmgr(1) for more information (specifically,
7355: arguments recognized by the 'add' action). Note that you will
7356: normally not use this variable.
7357: </p></li>
7358: </ol></div>
7359: </div>
7360: <div class="sect2" lang="en">
7361: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7362: <a name="mime-database"></a>17.5.14. Packages installing extensions to the MIME database</h3></div></div></div>
1.75 rillig 7363: <p>If a package provides extensions to the MIME database by
1.76 rillig 7364: installing <code class="filename">.xml</code> files inside
7365: <code class="filename">${PREFIX}/share/mime/packages</code>, you
1.75 rillig 7366: need to take some extra steps to ensure that the database is kept
7367: consistent with respect to these new files:
7368: </p>
7369: <div class="orderedlist"><ol type="1">
7370: <li><p>Include
1.76 rillig 7371: <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
7372: (avoid using the <code class="filename">buildlink3.mk</code> file from
1.75 rillig 7373: this same directory, which is reserved for inclusion from
1.76 rillig 7374: other <code class="filename">buildlink3.mk</code> files). It takes
1.75 rillig 7375: care of rebuilding the MIME database at installation and
7376: deinstallation time, and disallows any access to it directly
7377: from the package.</p></li>
7378: <li><p>Check the PLIST and remove any entries under the
1.76 rillig 7379: <code class="filename">share/mime</code> directory,
1.75 rillig 7380: <span class="emphasis"><em>except</em></span> for files saved under
1.76 rillig 7381: <code class="filename">share/mime/packages</code>. The former are
1.75 rillig 7382: handled automatically by
7383: the update-mime-database program, but the latter are
7384: package-dependent and must be removed by the package that
7385: installed them in the first place.</p></li>
1.76 rillig 7386: <li><p>Remove any <code class="filename">share/mime/*</code> directories
1.75 rillig 7387: from the PLIST. They will be handled by the shared-mime-info
7388: package.</p></li>
7389: </ol></div>
7390: </div>
7391: <div class="sect2" lang="en">
7392: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7393: <a name="intltool"></a>17.5.15. Packages using intltool</h3></div></div></div>
1.75 rillig 7394: <p>If a package uses intltool during its build, include the
1.76 rillig 7395: <code class="filename">../../textproc/intltool/buildlink3.mk</code> file,
1.75 rillig 7396: which forces it to use the intltool package provided by pkgsrc,
7397: instead of the one bundled with the distribution file.
7398: </p>
7399: <p>This tracks intltool's build-time dependencies and uses the
7400: latest available version; this way, the package benefits of any
7401: bug fixes that may have appeared since it was released.
7402: </p>
7403: </div>
7404: <div class="sect2" lang="en">
7405: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7406: <a name="startup-scripts"></a>17.5.16. Packages installing startup scripts</h3></div></div></div>
1.75 rillig 7407: <p>If a package contains a rc.d script, it won't be copied into
7408: the startup directory by default, but you can enable it, by adding
7409: the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
1.76 rillig 7410: <code class="filename">/etc/mk.conf</code>. This option will copy the scripts
7411: into <code class="filename">/etc/rc.d</code> when a package is installed, and
1.75 rillig 7412: it will automatically remove the scripts when the package is
7413: deinstalled.</p>
7414: </div>
7415: <div class="sect2" lang="en">
7416: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7417: <a name="tex-packages"></a>17.5.17. Packages installing TeX modules</h3></div></div></div>
1.75 rillig 7418: <p>If a package installs TeX packages into the texmf tree,
1.76 rillig 7419: the <code class="filename">ls-R</code> database of the tree needs to be
1.75 rillig 7420: updated.</p>
7421: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7422: <h3 class="title">Note</h3>
7423: <p>Except the main TeX packages such as teTeX-texmf,
7424: packages should install files
7425: into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
7426: not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
7427: </div>
7428: <div class="orderedlist"><ol type="1">
7429: <li><p>Include
1.76 rillig 7430: <code class="filename">../../print/teTeX/module.mk</code> instead
7431: of <code class="filename">../../mk/tex.buildlink3.mk</code>. This
7432: takes care of rebuilding the <code class="filename">ls-R</code>
1.75 rillig 7433: database at installation and deinstallation time.</p></li>
7434: <li>
7435: <p>If your package installs files into a texmf
7436: tree other than the one
7437: at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
7438: set <code class="varname">TEXMFDIRS</code> to the list of all texmf
7439: trees that need database update.</p>
7440: <p>If your package also installs font map files that need
7441: to be registered using <span><strong class="command">updmap</strong></span>,
7442: set <code class="varname">TEX_FONTMAPS</code> to the list of all
7443: such font map files. Then <span><strong class="command">updmap</strong></span> will
7444: be run automatically at installation/deinstallation to
7445: enable/disable font map files for TeX output
7446: drivers.</p>
7447: </li>
1.76 rillig 7448: <li><p>Make sure that none of <code class="filename">ls-R</code>
7449: databases are included in <code class="filename">PLIST</code>, as
1.75 rillig 7450: they will be removed only by the teTeX-bin package.</p></li>
7451: </ol></div>
7452: </div>
7453: </div>
7454: <div class="sect1" lang="en">
7455: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 7456: <a name="feedback-to-author"></a>17.6. Feedback to the author</h2></div></div></div>
1.75 rillig 7457: <p>If you have found any bugs in the package you make available,
7458: if you had to do special steps to make it run under NetBSD or
7459: if you enhanced the software in various other ways, be sure
7460: to report these changes back to the original author of the
7461: program! With that kind of support, the next release of the
7462: program can incorporate these fixes, and people not using the
7463: NetBSD packages system can win from your efforts.</p>
7464: <p>Support the idea of free software!</p>
7465: </div>
7466: </div>
7467: <div class="chapter" lang="en">
7468: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7469: <a name="debug"></a>Chapter 18. Debugging</h2></div></div></div>
1.75 rillig 7470: <p>To check out all the gotchas when building a package, here are the steps
7471: that I do in order to get a package working. Please note this is basically
7472: the same as what was explained in the previous sections, only with some
7473: debugging aids.</p>
7474: <div class="itemizedlist"><ul type="disc">
7475: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=1</code>
1.76 rillig 7476: in <code class="filename">/etc/mk.conf</code></p></li>
1.75 rillig 7477: <li>
1.76 rillig 7478: <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 7479: create a directory for a new package, change into it, then run
7480: <span><strong class="command">url2pkg</strong></span>:</p>
7481: <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>
7482: <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>
7483: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
7484: </li>
1.76 rillig 7485: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
7486: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.75 rillig 7487: <li><p>Run <span><strong class="command">make configure</strong></span>
7488: </p></li>
7489: <li><p>Add any dependencies glimpsed from documentation and the
7490: configure step to the package's
1.76 rillig 7491: <code class="filename">Makefile</code>.</p></li>
1.75 rillig 7492: <li>
7493: <p>Make the package compile, doing multiple rounds of</p>
7494: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
7495: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
7496: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
7497: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
7498: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
7499: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
7500: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
7501: <p>Doing as non-root user will ensure that no files are modified that
7502: shouldn't be, especially during the build
7503: phase. <span><strong class="command">mkpatches</strong></span>,
7504: <span><strong class="command">patchdiff</strong></span> and <span><strong class="command">pkgvi</strong></span> are
1.76 rillig 7505: 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 7506: package. </p>
7507: </li>
1.76 rillig 7508: <li><p>Look at the <code class="filename">Makefile</code>, fix if necessary;
1.77 rillig 7509: see <a href="#components.Makefile" title="9.1. Makefile">Section 9.1, “<code class="filename">Makefile</code>”</a>.</p></li>
1.75 rillig 7510: <li>
1.76 rillig 7511: <p>Generate a <code class="filename">PLIST</code>:</p>
1.75 rillig 7512: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
7513: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST >PLIST</code></strong>
7514: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
7515: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
7516: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
1.76 rillig 7517: <p>You usually need to be <code class="username">root</code> to do this.
1.75 rillig 7518: Look if there are any files left:</p>
7519: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
7520: <p>If this reveals any files that are missing in
1.76 rillig 7521: <code class="filename">PLIST</code>, add them.</p>
1.75 rillig 7522: </li>
7523: <li>
1.76 rillig 7524: <p>Now that the <code class="filename">PLIST</code> is OK,
1.75 rillig 7525: install the package again and make a binary package:</p>
7526: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
7527: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
7528: </li>
7529: <li>
7530: <p>Delete the installed package:</p>
7531: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete blub</code></strong></pre>
7532: </li>
7533: <li>
7534: <p>Repeat the above <span><strong class="command">make print-PLIST</strong></span> command,
7535: which shouldn't find anything now:</p>
7536: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
7537: </li>
7538: <li>
7539: <p>Reinstall the binary package:</p>
7540: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkgadd .../blub.tgz</code></strong></pre>
7541: </li>
7542: <li><p>Play with it. Make sure everything works.</p></li>
7543: <li>
7544: <p>Run <span><strong class="command">pkglint</strong></span> from
1.76 rillig 7545: <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 7546: and fix the problems it reports:</p>
7547: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
7548: </li>
7549: <li><p>Submit (or commit, if you have cvs access);
1.77 rillig 7550: see <a href="#submit" title="Chapter 19. Submitting and Committing">Chapter 19, <i>Submitting and Committing</i></a>.</p></li>
1.75 rillig 7551: </ul></div>
7552: </div>
7553: <div class="chapter" lang="en">
7554: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7555: <a name="submit"></a>Chapter 19. Submitting and Committing</h2></div></div></div>
1.75 rillig 7556: <div class="toc">
7557: <p><b>Table of Contents</b></p>
7558: <dl>
1.77 rillig 7559: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
7560: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
7561: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
7562: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
7563: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
7564: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 7565: </dl>
7566: </div>
7567: <div class="sect1" lang="en">
7568: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7569: <a name="submitting-binary-packages"></a>19.1. Submitting binary packages</h2></div></div></div>
1.75 rillig 7570: <p>Our policy is that we accept binaries only from pkgsrc
7571: developers to guarantee that the packages don't contain any
7572: trojan horses etc. This is not to annoy anyone but rather to
7573: protect our users! You're still free to put up your home-made
7574: binary packages and tell the world where to get them. NetBSD
7575: developers doing bulk builds and wanting to upload them please
7576: 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>
7577: </div>
7578: <div class="sect1" lang="en">
7579: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7580: <a name="submitting-your-package"></a>19.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
1.75 rillig 7581: <p>First, check that your package is complete, compiles and
1.77 rillig 7582: runs well; see <a href="#debug" title="Chapter 18. Debugging">Chapter 18, <i>Debugging</i></a> and the rest of this
1.75 rillig 7583: 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>
7584: archive, preferably with all files in a single directory.
7585: Finally, <span><strong class="command">send-pr</strong></span> with category
7586: “<span class="quote">pkg</span>”, a synopsis which includes the package name
7587: and version number, a short description of your package
7588: (contents of the COMMENT variable or DESCR file are OK) and
7589: attach the archive to your PR.</p>
7590: <p>If you want to submit several packages, please send a
7591: separate PR for each one, it's easier for us to track things
7592: that way.</p>
7593: <p>Alternatively, you can also import new packages into
7594: pkgsrc-wip (“<span class="quote">pkgsrc work-in-progress</span>”); see the
7595: homepage at <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
7596: for details.</p>
7597: </div>
7598: <div class="sect1" lang="en">
7599: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7600: <a name="general-notes-for-changes"></a>19.3. General notes when adding, updating, or removing packages</h2></div></div></div>
1.75 rillig 7601: <p>Please note all package additions, updates, moves, and
1.76 rillig 7602: removals in <code class="filename">pkgsrc/doc/CHANGES</code>. It's very
1.75 rillig 7603: important to keep this file up to date and conforming to the
7604: existing format, because it will be used by scripts to
7605: automatically update pages on <a href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
7606: sites. Additionally, check the
1.76 rillig 7607: <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
1.75 rillig 7608: for the package you updated or removed, in case it was mentioned
7609: there.</p>
7610: <p>When the <code class="varname">PKGREVISION</code> of a package is
7611: bumped, the change should appear in
1.76 rillig 7612: <code class="filename">pkgsrc/doc/CHANGES</code> if it is security
1.75 rillig 7613: related or otherwise relevant. Mass bumps that result from a
7614: dependency being updated should not be mentioned. In all other
7615: cases it's the developer's decision.</p>
7616: <p>There is a make target that helps in creating proper
1.76 rillig 7617: <code class="filename">CHANGES</code> entries: <span><strong class="command">make
1.75 rillig 7618: changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
7619: and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
1.76 rillig 7620: usage is to first make sure that your <code class="filename">CHANGES</code>
1.75 rillig 7621: file is up-to-date (to avoid having to resolve conflicts later-on)
7622: and then to <span><strong class="command">cd</strong></span> to the package directory. For
7623: package updates, <span><strong class="command">make changes-entry</strong></span> is enough.
7624: For new packages, or package moves or removals, set the
7625: <code class="varname">CTYPE</code> variable on the command line to "Added",
7626: "Moved", or "Removed". You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.76 rillig 7627: in <code class="filename">/etc/mk.conf</code> if your local login name is
1.75 rillig 7628: not the same as your NetBSD login name. Don't forget to commit
1.76 rillig 7629: the changes to <code class="filename">pkgsrc/doc/CHANGES</code>!</p>
1.75 rillig 7630: </div>
7631: <div class="sect1" lang="en">
7632: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7633: <a name="committing-importing"></a>19.4. Committing: Importing a package into CVS</h2></div></div></div>
1.75 rillig 7634: <p>
7635: This section is only of interest for pkgsrc developers with write
7636: access to the pkgsrc repository. Please remember that cvs
7637: imports files relative to the current working directory, and that
7638: the pathname that you
7639: give the <span><strong class="command">cvs import</strong></span> command is so that it knows where
7640: to place the files in the repository. Newly created packages should be
7641: imported with a vendor tag of “<span class="quote">TNF</span>” and a release tag of
7642: “<span class="quote">pkgsrc-base</span>”, e.g:
7643: </p>
7644: <pre class="programlisting">
7645: <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
7646: <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
7647: </pre>
7648: <p>
7649: Remember to move the directory from which you imported out of
7650: the way, or cvs will complain the next time you “<span class="quote">cvs
7651: update</span>” your source tree. Also don't forget to add the new
1.76 rillig 7652: package to the category's <code class="filename">Makefile</code>.
1.75 rillig 7653: </p>
7654: <p>
7655: The commit message of the initial import should include part of the
1.76 rillig 7656: <code class="filename">DESCR</code> file, so people reading the mailing lists know
1.75 rillig 7657: what the package is/does.
7658: </p>
7659: <p>
7660: For new packages, “<span class="quote">cvs import</span>” is preferred to “<span class="quote">cvs
7661: add</span>” because the former gets everything with a single command,
7662: and provides a consistent tag.
7663: </p>
7664: </div>
7665: <div class="sect1" lang="en">
7666: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7667: <a name="updating-package"></a>19.5. Updating a package to a newer version</h2></div></div></div>
1.75 rillig 7668: <p>
7669: Please always put a concise, appropriate and relevant summary of the
7670: changes between old and new versions into the commit log when updating
7671: a package. There are various reasons for this:
7672: </p>
7673: <div class="itemizedlist"><ul type="disc">
7674: <li><p>
7675: A URL is volatile, and can change over time. It may go away completely
7676: or its information may be overwritten by newer information.
7677: </p></li>
7678: <li><p>
7679: Having the change information between old and new versions in our CVS
7680: repository is very useful for people who use either cvs or anoncvs.
7681: </p></li>
7682: <li><p>
7683: Having the change information between old and new versions in our CVS
7684: repository is very useful for people who read the pkgsrc-changes mailing
7685: list, so that they can make tactical decisions about when to upgrade
7686: the package.
7687: </p></li>
7688: </ul></div>
7689: <p>
7690: Please also recognize that, just because a new version of a package
7691: has been released, it should not automatically be upgraded in the CVS
7692: repository. We prefer to be conservative in the packages that are
7693: included in pkgsrc - development or beta packages are not really the
7694: best thing for most places in which pkgsrc is used. Please use your
7695: judgement about what should go into pkgsrc, and bear in mind that
7696: stability is to be preferred above new and possibly untested features.
7697: </p>
7698: </div>
7699: <div class="sect1" lang="en">
7700: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7701: <a name="moving-package"></a>19.6. Moving a package in pkgsrc</h2></div></div></div>
1.75 rillig 7702: <div class="orderedlist"><ol type="1">
7703: <li><p>Make a copy of the directory somewhere else.</p></li>
7704: <li>
7705: <p>Remove all CVS dirs.</p>
7706: <p>
7707: Alternatively to the first two steps you can also do:
7708: </p>
7709: <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>
7710: <p>
7711: and use that for further work.
7712: </p>
7713: </li>
7714: <li><p>Fix <code class="varname">CATEGORIES</code> and any
7715: <code class="varname">DEPENDS</code> paths that just did “<span class="quote">../package</span>”
7716: instead of “<span class="quote">../../category/package</span>”.</p></li>
7717: <li><p><span><strong class="command">cvs import</strong></span> the modified package in the new
7718: place.</p></li>
7719: <li>
7720: <p>Check if any package depends on it:
7721: </p>
7722: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
7723: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
7724: <p>
7725: </p>
7726: </li>
7727: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
7728: <li><p><span><strong class="command">cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.76 rillig 7729: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
7730: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
1.75 rillig 7731: <li>
7732: <p>Commit the changed and removed files:</p>
7733: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong></pre>
7734: <p>
7735: (and any packages from step 5, of course).
7736: </p>
7737: </li>
7738: </ol></div>
7739: </div>
7740: </div>
7741: <div class="chapter" lang="en">
7742: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7743: <a name="devfaq"></a>Chapter 20. Frequently Asked Questions</h2></div></div></div>
1.75 rillig 7744: <p>This section contains the answers to questions that may
7745: arise when you are writing a package. If you don't find your
7746: question answered here, first have a look in the other chapters,
7747: and if you still don't have the answer, ask on the
7748: <code class="literal">pkgsrc-users</code> mailing list.</p>
7749: <div class="qandaset">
7750: <dl>
1.80 ! rillig 7751: <dt>20.1. <a href="#id2655006">What is the difference between
1.75 rillig 7752: MAKEFLAGS, .MAKEFLAGS and
7753: MAKE_FLAGS?</a>
7754: </dt>
1.80 ! rillig 7755: <dt>20.2. <a href="#id2655043">What is the difference between
1.75 rillig 7756: MAKE, GMAKE and
7757: MAKE_PROGRAM?</a>
7758: </dt>
1.80 ! rillig 7759: <dt>20.3. <a href="#id2655081">What is the difference between
1.75 rillig 7760: CC, PKG_CC and
7761: PKGSRC_COMPILER?</a>
7762: </dt>
1.80 ! rillig 7763: <dt>20.4. <a href="#id2655118">What is the difference between
1.75 rillig 7764: BUILDLINK_LDFLAGS,
7765: BUILDLINK_LDADD and
7766: BUILDLINK_LIBS?</a>
7767: </dt>
1.80 ! rillig 7768: <dt>20.5. <a href="#id2655137">Why does make show-var
1.75 rillig 7769: VARNAME=BUILDLINK_PREFIX.foo
7770: say it's empty?</a>
7771: </dt>
1.80 ! rillig 7772: <dt>20.6. <a href="#id2655164">What does
1.78 rillig 7773: ${MASTER_SITE_SOURCEFORGE:=package/} mean? I
7774: don't understand the := inside
7775: it.</a>
7776: </dt>
1.80 ! rillig 7777: <dt>20.7. <a href="#id2655239">Which mailing lists are there for package
1.78 rillig 7778: developers?</a>
7779: </dt>
1.80 ! rillig 7780: <dt>20.8. <a href="#id2655275">Where is the pkgsrc
! 7781: documentation?</a>
! 7782: </dt>
1.75 rillig 7783: </dl>
7784: <table border="0" summary="Q and A Set">
7785: <col align="left" width="1%">
7786: <tbody>
7787: <tr class="question">
7788: <td align="left" valign="top">
1.80 ! rillig 7789: <a name="id2655006"></a><a name="id2655008"></a><b>20.1.</b>
1.75 rillig 7790: </td>
7791: <td align="left" valign="top"><p>What is the difference between
7792: <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
7793: <code class="varname">MAKE_FLAGS</code>?</p></td>
7794: </tr>
7795: <tr class="answer">
7796: <td align="left" valign="top"><b></b></td>
7797: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
7798: 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
7799: <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
7800: the <code class="varname">MAKE_PROGRAM</code> when building the
7801: package. [FIXME: What is .MAKEFLAGS for?]</p></td>
7802: </tr>
7803: <tr class="question">
7804: <td align="left" valign="top">
1.80 ! rillig 7805: <a name="id2655043"></a><a name="id2655044"></a><b>20.2.</b>
1.75 rillig 7806: </td>
7807: <td align="left" valign="top"><p>What is the difference between
7808: <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
7809: <code class="varname">MAKE_PROGRAM</code>?</p></td>
7810: </tr>
7811: <tr class="answer">
7812: <td align="left" valign="top"><b></b></td>
7813: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
7814: <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
7815: infrastructure. <code class="varname">GMAKE</code> is the path to GNU
7816: Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
7817: use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
7818: Make program that is used for building the
7819: package.</p></td>
7820: </tr>
7821: <tr class="question">
7822: <td align="left" valign="top">
1.80 ! rillig 7823: <a name="id2655081"></a><a name="id2655082"></a><b>20.3.</b>
1.75 rillig 7824: </td>
7825: <td align="left" valign="top"><p>What is the difference between
7826: <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
7827: <code class="varname">PKGSRC_COMPILER</code>?</p></td>
7828: </tr>
7829: <tr class="answer">
7830: <td align="left" valign="top"><b></b></td>
7831: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
7832: compiler, which can be configured by the pkgsrc user.
7833: <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
7834: <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
7835: path to a compiler, but the type of compiler that should be
1.76 rillig 7836: used. See <code class="filename">mk/compiler.mk</code> for more
1.75 rillig 7837: information about the latter variable.</p></td>
7838: </tr>
7839: <tr class="question">
7840: <td align="left" valign="top">
1.80 ! rillig 7841: <a name="id2655118"></a><a name="id2655120"></a><b>20.4.</b>
1.75 rillig 7842: </td>
7843: <td align="left" valign="top"><p>What is the difference between
7844: <code class="varname">BUILDLINK_LDFLAGS</code>,
7845: <code class="varname">BUILDLINK_LDADD</code> and
7846: <code class="varname">BUILDLINK_LIBS</code>?</p></td>
7847: </tr>
7848: <tr class="answer">
7849: <td align="left" valign="top"><b></b></td>
7850: <td align="left" valign="top"><p>[FIXME]</p></td>
7851: </tr>
7852: <tr class="question">
7853: <td align="left" valign="top">
1.80 ! rillig 7854: <a name="id2655137"></a><a name="id2655138"></a><b>20.5.</b>
1.75 rillig 7855: </td>
7856: <td align="left" valign="top"><p>Why does <span><strong class="command">make show-var
7857: VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
7858: say it's empty?</p></td>
7859: </tr>
7860: <tr class="answer">
7861: <td align="left" valign="top"><b></b></td>
7862: <td align="left" valign="top"><p>For optimization reasons, some variables are only
7863: available in the “<span class="quote">wrapper</span>” phase and later. To
7864: “<span class="quote">simulate</span>” the wrapper phase, append
7865: <span><strong class="command">PKG_PHASE=wrapper</strong></span> to the above
7866: command.</p></td>
7867: </tr>
1.78 rillig 7868: <tr class="question">
7869: <td align="left" valign="top">
1.80 ! rillig 7870: <a name="id2655164"></a><a name="id2655165"></a><b>20.6.</b>
1.78 rillig 7871: </td>
7872: <td align="left" valign="top"><p>What does
7873: <code class="literal">${MASTER_SITE_SOURCEFORGE:=package/}</code> mean? I
7874: don't understand the <code class="literal">:=</code> inside
7875: it.</p></td>
7876: </tr>
7877: <tr class="answer">
7878: <td align="left" valign="top"><b></b></td>
7879: <td align="left" valign="top"><p>The <code class="literal">:=</code> is not really an
7880: assignment operator, like you might expect at first sight.
7881: Instead, it is a degenerate form of
7882: <code class="literal">${LIST:<em class="replaceable"><code>old_string</code></em>=<em class="replaceable"><code>new_string</code></em>}</code>,
7883: which is documented 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 page and which you
7884: may have seen as in <code class="literal">${SRCS:.c=.o}</code>. In the
7885: case of <code class="varname">MASTER_SITE_*</code>,
7886: <em class="replaceable"><code>old_string</code></em> is the empty string and
7887: <em class="replaceable"><code>new_string</code></em> is
7888: <code class="literal">package/</code>. That's where the
7889: <code class="literal">:</code> and the <code class="literal">=</code> fall
7890: together.</p></td>
7891: </tr>
7892: <tr class="question">
7893: <td align="left" valign="top">
1.80 ! rillig 7894: <a name="id2655239"></a><a name="id2655240"></a><b>20.7.</b>
1.78 rillig 7895: </td>
7896: <td align="left" valign="top"><p>Which mailing lists are there for package
7897: developers?</p></td>
7898: </tr>
7899: <tr class="answer">
7900: <td align="left" valign="top"><b></b></td>
7901: <td align="left" valign="top"><div class="variablelist"><dl>
7902: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">tech-pkg</a></span></dt>
7903: <dd><p>This is a list for technical discussions related
7904: to pkgsrc development, e.g. soliciting feedback for changes to
7905: pkgsrc infrastructure, proposed new features, questions related
7906: to porting pkgsrc to a new platform, advice for maintaining a
7907: package, patches that affect many packages, help requests moved
7908: from pkgsrc-users when an infrastructure bug is found,
7909: etc.</p></dd>
7910: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a></span></dt>
7911: <dd><p>All bug reports in category "pkg" sent with
7912: <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 here. Please do not report your bugs here
7913: directly; use one of the other mailing
7914: lists.</p></dd>
7915: </dl></div></td>
7916: </tr>
1.80 ! rillig 7917: <tr class="question">
! 7918: <td align="left" valign="top">
! 7919: <a name="id2655275"></a><a name="id2655276"></a><b>20.8.</b>
! 7920: </td>
! 7921: <td align="left" valign="top"><p>Where is the pkgsrc
! 7922: documentation?</p></td>
! 7923: </tr>
! 7924: <tr class="answer">
! 7925: <td align="left" valign="top"><b></b></td>
! 7926: <td align="left" valign="top">
! 7927: <p>There are many places where you can find
! 7928: documentation about pkgsrc:</p>
! 7929: <div class="itemizedlist"><ul type="disc">
! 7930: <li><p>The pkgsrc guide (this document) is a collection
! 7931: of chapters that explain large parts of pkgsrc, but some
! 7932: chapters tend to be outdated. Which ones they are is hard to
! 7933: say.</p></li>
! 7934: <li><p>On the mailing list archives (see <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>), you can find discussions
! 7935: about certain features, announcements of new parts of the pkgsrc
! 7936: infrastructure and sometimes even announcements that a certain
! 7937: feature has been marked as obsolete. The benefit here is that
! 7938: each message has a date appended to it.</p></li>
! 7939: <li><p>Many of the files in the
! 7940: <code class="filename">mk/</code> directory start with a comment that
! 7941: describes the purpose of the file and how it can be used by the
! 7942: pkgsrc user and package authors.</p></li>
! 7943: <li><p>The CVS log messages are a rich source of
! 7944: information, but they tend to be highly abbreviated, especially
! 7945: for actions that occur often. Some contain a detailed
! 7946: description of what has changed, but they are geared towards the
! 7947: other pkgsrc developers, not towards an average pkgsrc user.
! 7948: They also only document <span class="emphasis"><em>changes</em></span>, so if you
! 7949: don't know what has been before, these messages may not be worth
! 7950: too much to you.</p></li>
! 7951: <li><p>Some parts of pkgsrc are only “<span class="quote">implicitly
! 7952: documented</span>”, that is the documentation exists only in the
! 7953: mind of the developer who wrote the code. To get this
! 7954: information, use the the <span><strong class="command">cvs annotate</strong></span> command
! 7955: to see who has written it and ask on the
! 7956: <code class="literal">tech-pkg</code> mailing list, so that others can
! 7957: find your questions later (see above). To be sure that the
! 7958: developer in charge reads the mail, you may CC him or
! 7959: her.</p></li>
! 7960: </ul></div>
! 7961: </td>
! 7962: </tr>
1.75 rillig 7963: </tbody>
7964: </table>
7965: </div>
7966: </div>
7967: </div>
7968: <div class="part" lang="en">
7969: <div class="titlepage"><div><div><h1 class="title">
7970: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
7971: <div class="partintro" lang="en">
7972: <div></div>
7973: <p>This part of the guide deals with everything
7974: from the infrastructure that is behind the interfaces described
7975: in the developer's guide. A casual package maintainer should not
7976: need anything from this part.</p>
7977: <div class="toc">
7978: <p><b>Table of Contents</b></p>
7979: <dl>
1.77 rillig 7980: <dt><span class="chapter"><a href="#infr.design">21. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 7981: <dd><dl>
1.77 rillig 7982: <dt><span class="sect1"><a href="#infr.var">21.1. Variable evaluation</a></span></dt>
1.75 rillig 7983: <dd><dl>
1.77 rillig 7984: <dt><span class="sect2"><a href="#infr.var.load">21.1.1. At load time</a></span></dt>
7985: <dt><span class="sect2"><a href="#infr.var.run">21.1.2. At runtime</a></span></dt>
1.75 rillig 7986: </dl></dd>
1.78 rillig 7987: <dt><span class="sect1"><a href="#infr.varspec">21.2. How can variables be specified?</a></span></dt>
7988: <dt><span class="sect1"><a href="#infr.design.intf">21.3. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 7989: <dd><dl>
1.78 rillig 7990: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.3.1. Procedures with parameters</a></span></dt>
7991: <dt><span class="sect2"><a href="#infr.design.intf.action">21.3.2. Actions taken on behalf of parameters</a></span></dt>
1.75 rillig 7992: </dl></dd>
7993: </dl></dd>
1.77 rillig 7994: <dt><span class="chapter"><a href="#regression">22. Regression tests</a></span></dt>
1.75 rillig 7995: <dd><dl>
1.77 rillig 7996: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
7997: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
7998: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 7999: <dd><dl>
1.77 rillig 8000: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
8001: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 8002: </dl></dd>
8003: </dl></dd>
1.80 ! rillig 8004: <dt><span class="chapter"><a href="#porting">23. Porting pkgsrc</a></span></dt>
1.75 rillig 8005: <dd><dl>
1.80 ! rillig 8006: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
! 8007: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 8008: </dl></dd>
8009: </dl>
8010: </div>
8011: </div>
8012: <div class="chapter" lang="en">
8013: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8014: <a name="infr.design"></a>Chapter 21. Design of the pkgsrc infrastructure</h2></div></div></div>
1.75 rillig 8015: <div class="toc">
8016: <p><b>Table of Contents</b></p>
8017: <dl>
1.77 rillig 8018: <dt><span class="sect1"><a href="#infr.var">21.1. Variable evaluation</a></span></dt>
1.75 rillig 8019: <dd><dl>
1.77 rillig 8020: <dt><span class="sect2"><a href="#infr.var.load">21.1.1. At load time</a></span></dt>
8021: <dt><span class="sect2"><a href="#infr.var.run">21.1.2. At runtime</a></span></dt>
1.75 rillig 8022: </dl></dd>
1.78 rillig 8023: <dt><span class="sect1"><a href="#infr.varspec">21.2. How can variables be specified?</a></span></dt>
8024: <dt><span class="sect1"><a href="#infr.design.intf">21.3. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 8025: <dd><dl>
1.78 rillig 8026: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.3.1. Procedures with parameters</a></span></dt>
8027: <dt><span class="sect2"><a href="#infr.design.intf.action">21.3.2. Actions taken on behalf of parameters</a></span></dt>
1.75 rillig 8028: </dl></dd>
8029: </dl>
8030: </div>
8031: <p>The pkgsrc infrastructure consists of many small Makefile
8032: fragments. Each such fragment needs a properly specified
8033: interface. This chapter explains how such an interface looks
8034: like.</p>
8035: <div class="sect1" lang="en">
8036: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8037: <a name="infr.var"></a>21.1. Variable evaluation</h2></div></div></div>
1.75 rillig 8038: <div class="sect2" lang="en">
8039: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 8040: <a name="infr.var.load"></a>21.1.1. At load time</h3></div></div></div>
1.75 rillig 8041: <p>Variable evaluation takes place either at load time or at
8042: runtime, depending on the context in which they occur. The
8043: contexts where variables are evaluated at load time are:</p>
8044: <div class="itemizedlist"><ul type="disc">
8045: <li><p>The right hand side of the <code class="literal">:=</code>
8046: and <code class="literal">!=</code> operators,</p></li>
8047: <li><p>Make directives like <code class="literal">.if</code> or
8048: <code class="literal">.for</code>,</p></li>
8049: <li><p>Dependency lines.</p></li>
8050: </ul></div>
8051: <p>A special exception are references to the iteration
8052: variables of <code class="literal">.for</code> loops, which are expanded
8053: inline, no matter in which context they appear.</p>
8054: <p>As the values of variables may change during load time,
8055: care must be taken not to evaluate them by accident. Typical
8056: examples for variables that should not be evaluated at load time
8057: are <code class="varname">DEPENDS</code> and
8058: <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
8059: clear, here is an example:</p>
8060: <pre class="programlisting">
8061: CONFIGURE_ARGS= # none
8062: CFLAGS= -O
8063: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
1.1 grant 8064:
1.75 rillig 8065: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
1.1 grant 8066:
1.75 rillig 8067: CFLAGS+= -Wall
8068: </pre>
8069: <p>This code shows how the use of the <code class="literal">:=</code>
8070: operator can quickly lead to unexpected results. The first
8071: paragraph is fairly common code. The second paragraph evaluates
8072: the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
8073: <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
8074: <code class="literal">-Wall</code> is appended to the
8075: <code class="varname">CFLAGS</code>, but this addition will not appear in
8076: <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
8077: paragraphs from above typically occur in completely unrelated
8078: files.</p>
8079: </div>
8080: <div class="sect2" lang="en">
8081: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 8082: <a name="infr.var.run"></a>21.1.2. At runtime</h3></div></div></div>
1.75 rillig 8083: <p>After all the files have been loaded, the values of the
8084: variables cannot be changed anymore. Variables that are used in
8085: the shell commands are expanded at this point.</p>
8086: </div>
8087: </div>
8088: <div class="sect1" lang="en">
8089: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 8090: <a name="infr.varspec"></a>21.2. How can variables be specified?</h2></div></div></div>
8091: <p>There are many ways in which the definition and use of a
8092: variable can be restricted in order to detect bugs and
8093: violations of the (mostly unwritten) policies. See the
8094: <code class="literal">pkglint</code> developer's documentation for further
8095: details.</p>
8096: </div>
8097: <div class="sect1" lang="en">
8098: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8099: <a name="infr.design.intf"></a>21.3. Designing interfaces for Makefile fragments</h2></div></div></div>
1.76 rillig 8100: <p>Most of the <code class="filename">.mk</code> files fall into one
1.75 rillig 8101: of the following classes. Cases where a file falls into more
8102: than one class should be avoided as it often leads to subtle
8103: bugs.</p>
8104: <div class="sect2" lang="en">
8105: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 8106: <a name="infr.design.intf.proc"></a>21.3.1. Procedures with parameters</h3></div></div></div>
1.75 rillig 8107: <p>In a traditional imperative programming language some of
1.76 rillig 8108: the <code class="filename">.mk</code> files could be described as
1.78 rillig 8109: procedures. They take some input parameters and—after
8110: inclusion—provide a result in output parameters. Since all
1.76 rillig 8111: variables in <code class="filename">Makefile</code>s have global scope
1.75 rillig 8112: care must be taken not to use parameter names that have already
8113: another meaning. For example, <code class="varname">PKGNAME</code> is a
8114: bad choice for a parameter name.</p>
8115: <p>Procedures are completely evaluated at preprocessing time.
8116: That is, when calling a procedure all input parameters must be
8117: completely resolvable. For example,
8118: <code class="varname">CONFIGURE_ARGS</code> should never be an input
8119: parameter since it is very likely that further text will be
8120: added after calling the procedure, which would effectively apply
8121: the procedure to only a part of the variable. Also, references
8122: to other variables wit will be modified after calling the
8123: procedure.</p>
8124: <p>A procedure can declare its output parameters either as
8125: suitable for use in preprocessing directives or as only
8126: available at runtime. The latter alternative is for variables
8127: that contain references to other runtime variables.</p>
8128: <p>Procedures shall be written such that it is possible to
8129: call the procedure more than once. That is, the file must not
8130: contain multiple-inclusion guards.</p>
8131: <p>Examples for procedures are
1.76 rillig 8132: <code class="filename">mk/bsd.options.mk</code> and
8133: <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
1.75 rillig 8134: that the parameters are evaluated at load time, they should be
8135: assigned using the <code class="literal">:=</code> operator, which should
8136: be used only for this purpose.</p>
8137: </div>
8138: <div class="sect2" lang="en">
8139: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 8140: <a name="infr.design.intf.action"></a>21.3.2. Actions taken on behalf of parameters</h3></div></div></div>
1.75 rillig 8141: <p>Action files take some input parameters and may define
8142: runtime variables. They shall not define loadtime variables.
8143: There are action files that are included implicitly by the
8144: pkgsrc infrastructure, while other must be included
8145: explicitly.</p>
8146: <p>An example for action files is
1.76 rillig 8147: <code class="filename">mk/subst.mk</code>.</p>
1.75 rillig 8148: </div>
8149: </div>
8150: </div>
8151: <div class="chapter" lang="en">
8152: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8153: <a name="regression"></a>Chapter 22. Regression tests</h2></div></div></div>
1.75 rillig 8154: <div class="toc">
8155: <p><b>Table of Contents</b></p>
8156: <dl>
1.77 rillig 8157: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
8158: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
8159: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 8160: <dd><dl>
1.77 rillig 8161: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
8162: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 8163: </dl></dd>
8164: </dl>
8165: </div>
8166: <p>The pkgsrc infrastructure consists of a large codebase,
8167: and there are many corners where every little bit of a file is
8168: well thought out, making pkgsrc likely to fail as soon as
8169: anything is changed near those parts. To prevent most changes
8170: from breaking anything, a suite of regression tests should go
8171: along with every important part of the pkgsrc infrastructure.
8172: This chapter describes how regression tests work in pkgsrc and
8173: how you can add new tests.</p>
8174: <div class="sect1" lang="en">
8175: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8176: <a name="regression.descr"></a>22.1. The regression tests framework</h2></div></div></div>
1.75 rillig 8177: <p></p>
8178: </div>
8179: <div class="sect1" lang="en">
8180: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8181: <a name="regression.run"></a>22.2. Running the regression tests</h2></div></div></div>
1.76 rillig 8182: <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 8183: provides the <span><strong class="command">pkg_regress</strong></span> command. Then you
8184: can simply run that command, which will run all tests in the
1.76 rillig 8185: <code class="filename">regress</code> category.</p>
1.75 rillig 8186: </div>
8187: <div class="sect1" lang="en">
8188: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8189: <a name="regression.new"></a>22.3. Adding a new regression test</h2></div></div></div>
1.76 rillig 8190: <p>Every directory in the <code class="filename">regress</code>
8191: category that contains a file called <code class="filename">spec</code>
1.75 rillig 8192: is considered a regression test. This file is a shell program
8193: that is included by the <span><strong class="command">pkg_regress</strong></span> command.
8194: The following functions can be overridden to suit your
8195: needs.</p>
8196: <div class="sect2" lang="en">
8197: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 8198: <a name="regression.fun.override"></a>22.3.1. Overridable functions</h3></div></div></div>
1.75 rillig 8199: <p>These functions do not take any parameters. They are all
8200: called in “<span class="quote">set -e</span>” mode, so you should be careful
8201: to check the exitcodes of any commands you run in the
8202: test.</p>
8203: <div class="variablelist"><dl>
8204: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
8205: <dd><p>This function prepares the environment for the
8206: test. By default it does nothing.</p></dd>
8207: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
8208: <dd><p>This function runs the actual test. By default,
8209: it calls <code class="varname">TEST_MAKE</code> with the arguments
8210: <code class="varname">MAKEARGS_TEST</code> and writes its output including
8211: error messages into the file
8212: <code class="varname">TEST_OUTFILE</code>.</p></dd>
8213: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
8214: <dd><p>This function is run after the test and is
8215: typically used to compare the actual output from the one that is
8216: expected. It can make use of the various helper functions from
8217: the next section.</p></dd>
8218: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
8219: <dd><p>This function cleans everything up after the
8220: test has been run. By default it does nothing.</p></dd>
8221: </dl></div>
8222: </div>
8223: <div class="sect2" lang="en">
8224: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 8225: <a name="regression.fun.helper"></a>22.3.2. Helper functions</h3></div></div></div>
1.75 rillig 8226: <div class="variablelist"><dl>
8227: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
8228: <dd><p>This function compares the exitcode of the
8229: <span><strong class="command">do_test()</strong></span> function with its first parameter.
8230: If they differ, the test will fail.</p></dd>
8231: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
8232: <dd><p>This function checks for each of its parameters
8233: if the output from <span><strong class="command">do_test()</strong></span> matches the
8234: extended regular expression. If it does not, the test will
8235: fail.</p></dd>
8236: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
8237: <dd><p>This function checks for each of its parameters
8238: if the output from <span><strong class="command">do_test()</strong></span> does
8239: <span class="emphasis"><em>not</em></span> match the extended regular expression.
8240: If any of the regular expressions matches, the test will
8241: fail.</p></dd>
8242: </dl></div>
8243: </div>
8244: </div>
8245: </div>
8246: <div class="chapter" lang="en">
8247: <div class="titlepage"><div><div><h2 class="title">
1.80 ! rillig 8248: <a name="porting"></a>Chapter 23. Porting pkgsrc</h2></div></div></div>
1.75 rillig 8249: <div class="toc">
8250: <p><b>Table of Contents</b></p>
8251: <dl>
1.80 ! rillig 8252: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
! 8253: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 8254: </dl>
8255: </div>
8256: <p>The pkgsrc system has already been ported to many
8257: operating systems, hardware architectures and compilers. This
8258: chapter explains the necessary steps to make pkgsrc even more
8259: portable.</p>
8260: <div class="sect1" lang="en">
8261: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.80 ! rillig 8262: <a name="porting.opsys"></a>23.1. Porting pkgsrc to a new operating system</h2></div></div></div>
1.75 rillig 8263: <p>To port pkgsrc to a new operating system (called
8264: <code class="literal">MyOS</code> in this example), you need to touch the
8265: following files:</p>
8266: <div class="variablelist"><dl>
1.76 rillig 8267: <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 8268: <dd><p>This file contains some basic definitions, for
8269: example the name of the C
8270: compiler.</p></dd>
1.76 rillig 8271: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
1.75 rillig 8272: <dd><p>Insert code that defines the variables
8273: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
8274: <code class="varname">LOWER_OS_VERSION</code>,
8275: <code class="varname">LOWER_VENDOR</code>,
8276: <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
8277: <code class="varname">APPEND_ELF</code>, and the other variables that
8278: appear in this file.</p></dd>
1.76 rillig 8279: <dt><span class="term"><code class="filename">mk/platform/MyOS.mk</code></span></dt>
1.75 rillig 8280: <dd><p>This file contains the platform-specific
8281: definitions that are used by pkgsrc. Start by copying one of the
8282: other files and edit it to your
8283: needs.</p></dd>
1.76 rillig 8284: <dt><span class="term"><code class="filename">mk/platform/MyOS.pkg.dist</code></span></dt>
1.75 rillig 8285: <dd><p>This file contains a list of directories,
8286: together with their permission bits and ownership. These
8287: directories will be created automatically with every package
8288: that does not explicitly set <code class="varname">NO_MTREE</code>. There
8289: have been some discussions about whether this file is needed at
8290: all, but with no result.</p></dd>
1.76 rillig 8291: <dt><span class="term"><code class="filename">mk/platform/MyOS.x11.dist</code></span></dt>
1.75 rillig 8292: <dd><p>Just copy one of the pre-existing x11.dist files
8293: to your
1.76 rillig 8294: <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
8295: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
1.75 rillig 8296: <dd><p>On some operating systems, the tools that are
8297: provided with the base system are not good enough for pkgsrc.
8298: 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
8299: narrow limit on the line length they can process. Therefore
8300: pkgsrc brings its own tools, which can be enabled
8301: here.</p></dd>
1.76 rillig 8302: <dt><span class="term"><code class="filename">mk/tools/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
1.75 rillig 8303: <dd><p>This file defines the paths to all the tools
8304: that are needed by one or the other package in pkgsrc, as well
8305: as by pkgsrc itself. Find out where these tools are on your
8306: platform and add them.</p></dd>
8307: </dl></div>
8308: <p>Now, you should be able to build some basic packages, like
1.76 rillig 8309: <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 8310: </div>
8311: <div class="sect1" lang="en">
8312: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.80 ! rillig 8313: <a name="porting.compiler"></a>23.2. Adding support for a new compiler</h2></div></div></div>
1.75 rillig 8314: <p>TODO</p>
8315: </div>
8316: </div>
8317: </div>
8318: <div class="appendix" lang="en">
8319: <div class="titlepage"><div><div><h2 class="title">
8320: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
8321: <div class="toc">
8322: <p><b>Table of Contents</b></p>
8323: <dl>
8324: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
8325: <dd><dl>
8326: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
8327: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
8328: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
8329: <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>
8330: </dl></dd>
8331: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
8332: </dl>
8333: </div>
8334: <p>We checked to find a piece of software that wasn't in the packages
8335: collection, and picked GNU bison. Quite why someone would want to have
8336: <span><strong class="command">bison</strong></span> when Berkeley <span><strong class="command">yacc</strong></span> is already
8337: present in the tree is beyond us, but it's useful for the purposes of
8338: this exercise.</p>
8339: <div class="sect1" lang="en">
8340: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8341: <a name="example-files"></a>A.1. files</h2></div></div></div>
8342: <div class="sect2" lang="en">
8343: <div class="titlepage"><div><div><h3 class="title">
8344: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
8345: <pre class="programlisting">
1.51 rillig 8346: # $NetBSD$
8347: #
1.1 grant 8348:
1.51 rillig 8349: DISTNAME= bison-1.25
8350: CATEGORIES= devel
8351: MASTER_SITES= ${MASTER_SITE_GNU}
1.1 grant 8352:
1.51 rillig 8353: MAINTAINER= thorpej@NetBSD.org
8354: HOMEPAGE= http://www.gnu.org/software/bison/bison.html
8355: COMMENT= GNU yacc clone
1.1 grant 8356:
1.51 rillig 8357: GNU_CONFIGURE= yes
8358: INFO_FILES= bison.info
1.1 grant 8359:
1.51 rillig 8360: .include "../../mk/bsd.pkg.mk"
1.1 grant 8361: </pre>
1.75 rillig 8362: </div>
8363: <div class="sect2" lang="en">
8364: <div class="titlepage"><div><div><h3 class="title">
8365: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
8366: <pre class="programlisting">
1.51 rillig 8367: GNU version of yacc. Can make re-entrant parsers, and numerous other
1.75 rillig 8368: 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 8369: of the NetBSD source tree is beyond me.
1.1 grant 8370: </pre>
1.75 rillig 8371: </div>
8372: <div class="sect2" lang="en">
8373: <div class="titlepage"><div><div><h3 class="title">
8374: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
8375: <pre class="programlisting">
1.51 rillig 8376: @comment $NetBSD$
8377: bin/bison
8378: man/man1/bison.1.gz
8379: share/bison.simple
8380: share/bison.hairy
1.1 grant 8381: </pre>
1.75 rillig 8382: </div>
8383: <div class="sect2" lang="en">
8384: <div class="titlepage"><div><div><h3 class="title">
8385: <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>
8386: <p>The NetBSD package system comes with
1.76 rillig 8387: <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 8388: which helps to check the contents of these
8389: files. After installation it is quite easy to use, just change to the
8390: directory of the package you wish to examine and execute
8391: <span><strong class="command">pkglint</strong></span>:</p>
8392: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
8393: looks fine.</pre>
8394: <p>Depending on the supplied command line arguments (see pkglint(1)),
8395: more checks will be performed. Use e.g. <span><strong class="command">pkglint -Call
8396: -Wall</strong></span> for a very thorough check.</p>
8397: </div>
8398: </div>
8399: <div class="sect1" lang="en">
8400: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8401: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
8402: <p>Create the directory where the package lives,
8403: plus any auxiliary directories:</p>
8404: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
8405: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
8406: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
8407: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
1.76 rillig 8408: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.77 rillig 8409: <code class="filename">PLIST</code> (see <a href="#components" title="Chapter 9. Package components - files, directories and contents">Chapter 9, <i>Package components - files, directories and contents</i></a>)
1.75 rillig 8410: then continue with fetching the distfile:</p>
8411: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
1.1 grant 8412: >> bison-1.25.tar.gz doesn't seem to exist on this system.
8413: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
8414: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8415: ftp: Error retrieving file: 500 Internal error
8416:
8417: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
8418: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8419: ftp: Error retrieving file: 500 Internal error
8420:
8421: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
8422: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
1.75 rillig 8423: Successfully retrieved file.</pre>
8424: <p>Generate the checksum of the distfile into
1.76 rillig 8425: <code class="filename">distinfo</code>:</p>
1.75 rillig 8426: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makesum</code></strong></pre>
8427: <p>Now compile:</p>
8428: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 8429: >> Checksum OK for bison-1.25.tar.gz.
8430: ===> Extracting for bison-1.25
8431: ===> Patching for bison-1.25
8432: ===> Ignoring empty patch directory
8433: ===> Configuring for bison-1.25
8434: creating cache ./config.cache
8435: checking for gcc... cc
8436: checking whether we are using GNU C... yes
8437: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
8438: checking how to run the C preprocessor... cc -E
8439: checking for minix/config.h... no
8440: checking for POSIXized ISC... no
8441: checking whether cross-compiling... no
8442: checking for ANSI C header files... yes
8443: checking for string.h... yes
8444: checking for stdlib.h... yes
8445: checking for memory.h... yes
8446: checking for working const... yes
8447: checking for working alloca.h... no
8448: checking for alloca... yes
8449: checking for strerror... yes
8450: updating cache ./config.cache
8451: creating ./config.status
8452: creating Makefile
8453: ===> Building for bison-1.25
8454: 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
8455: 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
8456: 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
8457: 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
8458: 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 8459: 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 8460: 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
8461: 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
8462: 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
8463: 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
8464: 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
8465: 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
8466: 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
8467: 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
8468: 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
8469: 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
8470: 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
8471: 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
8472: 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
8473: 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
8474: 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
8475: 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
8476: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
8477: rm -f bison.s1
1.75 rillig 8478: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1</pre>
8479: <p>Everything seems OK, so install the files:</p>
8480: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 8481: >> Checksum OK for bison-1.25.tar.gz.
8482: ===> Installing for bison-1.25
8483: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
8484: rm -f /usr/pkg/bin/bison
8485: cd /usr/pkg/share; rm -f bison.simple bison.hairy
8486: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
8487: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
8488: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
8489: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
8490: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
8491: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
1.75 rillig 8492: ===> Registering installation for bison-1.25</pre>
8493: <p>You can now use bison, and also - if you decide so - remove it with
8494: <span><strong class="command">pkg_delete bison</strong></span>. Should you decide that you want a
8495: binary package, do this now:</p>
8496: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 8497: >> Checksum OK for bison-1.25.tar.gz.
8498: ===> Building package for bison-1.25
8499: Creating package bison-1.25.tgz
8500: Registering depends:.
1.75 rillig 8501: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
8502: <p>Now that you don't need the source and object files
8503: any more, clean up:</p>
8504: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
8505: ===> Cleaning for bison-1.25</pre>
8506: </div>
8507: </div>
8508: <div class="appendix" lang="en">
8509: <div class="titlepage"><div><div><h2 class="title">
8510: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
8511: <div class="toc">
8512: <p><b>Table of Contents</b></p>
8513: <dl>
8514: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
8515: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
8516: </dl>
8517: </div>
8518: <div class="sect1" lang="en">
8519: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8520: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
8521: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 8522: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8523: => figlet221.tar.gz doesn't seem to exist on this system.
8524: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
8525: => [172219 bytes]
8526: Connected to ftp.plig.net.
8527: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
8528: 331 Guest login ok, send your complete e-mail address as password.
8529: 230-You are user #5 of 500 simultaneous users allowed.
8530: 230-
1.68 rillig 8531: 230- ___ _ _ _
8532: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
1.1 grant 8533: 230- | _| _| . |_| . | | | . |_| . | _| . |
8534: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
8535: 230- |_| |_| |___| |___|
8536: 230-
8537: 230-** Welcome to ftp.plig.org **
8538: 230-
8539: 230-Please note that all transfers from this FTP site are logged. If you
8540: 230-do not like this, please disconnect now.
8541: 230-
8542: 230-This arhive is available via
8543: 230-
8544: 230-HTTP: http://ftp.plig.org/
8545: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
8546: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
8547: 230-
8548: 230-Please email comments, bug reports and requests for packages to be
1.68 rillig 8549: 230-mirrored to ftp-admin@plig.org.
1.1 grant 8550: 230-
8551: 230-
8552: 230 Logged in anonymously.
8553: Remote system type is UNIX.
8554: Using binary mode to transfer files.
8555: 200 Type okay.
8556: 250 "/pub" is new cwd.
8557: 250-"/pub/figlet" is new cwd.
8558: 250-
8559: 250-Welcome to the figlet archive at ftp.figlet.org
1.68 rillig 8560: 250-
1.75 rillig 8561: 250- ftp://ftp.figlet.org/pub/figlet/
1.1 grant 8562: 250-
8563: 250-The official FIGlet web page is:
1.75 rillig 8564: 250- http://www.figlet.org/
1.1 grant 8565: 250-
8566: 250-If you have questions, please mailto:info@figlet.org. If you want to
8567: 250-contribute a font or something else, you can email us.
1.68 rillig 8568: 250
1.1 grant 8569: 250 "/pub/figlet/program" is new cwd.
8570: 250 "/pub/figlet/program/unix" is new cwd.
8571: local: figlet221.tar.gz remote: figlet221.tar.gz
8572: 502 Unimplemented command.
8573: 227 Entering Passive Mode (195,40,6,41,246,104)
8574: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
8575: 38% |************** | 65800 64.16 KB/s 00:01 ETA
8576: 226 Transfer completed.
8577: 172219 bytes received in 00:02 (75.99 KB/s)
8578: 221 Goodbye.
8579: => Checksum OK for figlet221.tar.gz.
8580: ===> Extracting for figlet-2.2.1nb2
8581: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
8582: ===> Patching for figlet-2.2.1nb2
8583: ===> Applying pkgsrc patches for figlet-2.2.1nb2
8584: ===> Overriding tools for figlet-2.2.1nb2
8585: ===> Creating toolchain wrappers for figlet-2.2.1nb2
8586: ===> Configuring for figlet-2.2.1nb2
8587: ===> Building for figlet-2.2.1nb2
8588: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
8589: chmod a+x figlet
8590: gcc -O2 -o chkfont chkfont.c
8591: => Unwrapping files-to-be-installed.
1.14 xtraeme 8592: <code class="prompt">#</code>
1.75 rillig 8593: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 8594: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8595: ===> Installing for figlet-2.2.1nb2
8596: install -d -o root -g wheel -m 755 /usr/pkg/bin
8597: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
8598: mkdir -p /usr/pkg/share/figlet
8599: cp figlet /usr/pkg/bin
8600: cp chkfont /usr/pkg/bin
8601: chmod 555 figlist showfigfonts
8602: cp figlist /usr/pkg/bin
8603: cp showfigfonts /usr/pkg/bin
8604: cp fonts/*.flf /usr/pkg/share/figlet
8605: cp fonts/*.flc /usr/pkg/share/figlet
8606: cp figlet.6 /usr/pkg/man/man6
8607: ===> Registering installation for figlet-2.2.1nb2
1.75 rillig 8608: <code class="prompt">#</code></pre>
8609: </div>
8610: <div class="sect1" lang="en">
8611: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8612: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
8613: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 8614: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8615: ===> Packaging figlet-2.2.1nb2
8616: ===> Building binary package for figlet-2.2.1nb2
8617: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
8618: Using SrcDir value of /usr/pkg
1.68 rillig 8619: Registering depends:.
1.75 rillig 8620: <code class="prompt">#</code></pre>
8621: </div>
8622: </div>
8623: <div class="appendix" lang="en">
8624: <div class="titlepage"><div><div><h2 class="title">
1.76 rillig 8625: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
8626: <div class="toc">
8627: <p><b>Table of Contents</b></p>
8628: <dl>
8629: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
8630: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
8631: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
8632: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
8633: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
8634: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
8635: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
8636: source packages</a></span></dt>
8637: </dl>
8638: </div>
8639: <p>As in other big projects, the directory layout of pkgsrc
8640: is quite complex for newbies. This chapter explains where you
8641: find things on the FTP server. The base directory on
8642: <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>.
8643: This directory contains some subdirectories, which are explained
8644: below.</p>
8645: <div class="sect1" lang="en">
8646: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8647: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
8648: <p>For those who only want to manage binary packages on
8649: systems other than NetBSD, we provide the package management
8650: tools in a separate, small tar file.</p>
8651: </div>
8652: <div class="sect1" lang="en">
8653: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8654: <a name="ftp-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
8655: <p>The directory <code class="filename">distfiles</code> contains lots
8656: of archive files from all pkgsrc packages, which are mirrored
8657: here. The subdirectories are called after their package names
8658: and are used when the distributed files have names that don't
8659: explicitly contain a version number or are otherwise too generic
8660: (for example <code class="filename">release.tar.gz</code>).</p>
8661: </div>
8662: <div class="sect1" lang="en">
8663: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8664: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
8665: <p>This directory is currently not in use.</p>
8666: </div>
8667: <div class="sect1" lang="en">
8668: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8669: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
8670: <p>This directory contains things that individual pkgsrc
8671: developers find worth publishing.</p>
8672: </div>
8673: <div class="sect1" lang="en">
8674: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8675: <a name="ftp-packages"></a>C.5. <code class="filename">packages*</code>: Binary packages</h2></div></div></div>
8676: <p>These directories contain binary packages. Those
8677: directories that have a branch name
8678: (200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>)
8679: contain packages from that particular branch. The directory
8680: <code class="filename">packages</code> contains binary packages from
8681: pkgsrc-current. (However, this does not necessarily mean that
8682: the packages are still current anymore.)</p>
8683: <p>Below the <code class="filename">packages*</code> directories are
8684: directories that distinguish the packages by operating system
8685: and version, the next directory level specifies the hardware
8686: architecture.</p>
8687: <p>In each of the platform-specific directories, there is a
8688: whole binary packages collection. It has a directory called
8689: <code class="filename">All</code> which contains all binary packages.
8690: Besides that, there are various category directories that
8691: contain symbolic links to the real binary packages.</p>
8692: </div>
8693: <div class="sect1" lang="en">
8694: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8695: <a name="ftp-source"></a>C.6. <code class="filename">current</code>,
8696: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
8697: source packages</h2></div></div></div>
8698: <p>These directories contain the “<span class="quote">real</span>” pkgsrc,
8699: that is the files that define how to create binary packages from
8700: source archives.</p>
8701: <p>The directory <code class="filename">pkgsrc</code> contains a
8702: snapshot of the CVS repository, which is updated on a regularly
8703: basis. The file <code class="filename">pkgsrc.tar.gz</code> contains the
8704: same as the directory, ready to be downloaded as a whole.</p>
8705: <p>In the directories for the quarterly branches, there is an
8706: additional file called
8707: <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
8708: which contains the state of pkgsrc when it was branched.</p>
8709: </div>
1.75 rillig 8710: </div>
8711: <div class="appendix" lang="en">
8712: <div class="titlepage"><div><div><h2 class="title">
8713: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
8714: <div class="toc">
8715: <p><b>Table of Contents</b></p>
8716: <dl>
1.79 rillig 8717: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75 rillig 8718: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
8719: </dl>
8720: </div>
1.79 rillig 8721: <p>This section contains information on editing the pkgsrc
8722: guide itself.</p>
1.75 rillig 8723: <div class="sect1" lang="en">
8724: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.79 rillig 8725: <a name="targets"></a>D.1. Make targets</h2></div></div></div>
8726: <p>The pkgsrc guide's source code is stored in
8727: <code class="filename">pkgsrc/doc/guide/files</code>, and several files
8728: are created from it:</p>
8729: <div class="itemizedlist"><ul type="disc">
8730: <li><p><code class="filename">pkgsrc/doc/pkgsrc.txt</code></p></li>
8731: <li><p><code class="filename">pkgsrc/doc/pkgsrc.html</code></p></li>
8732: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/</a></p></li>
8733: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</a>:
8734: The PDF version of the pkgsrc guide.</p></li>
8735: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</a>:
8736: PostScript version of the pkgsrc guide.</p></li>
1.75 rillig 8737: </ul></div>
8738: </div>
8739: <div class="sect1" lang="en">
8740: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8741: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
1.79 rillig 8742: <p>The procedure to edit the pkgsrc guide is:</p>
8743: <div class="procedure"><ol type="1">
8744: <li><p>Make sure you have the packages needed to
8745: re-generate the pkgsrc guide (and other XML-based NetBSD
8746: documentation) installed. These are <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/netbsd-doc/README.html" target="_top"><code class="filename">meta-pkgs/netbsd-doc</code></a> for creating the
8747: ASCII and HTML versions, and <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/netbsd-doc-print/README.html" target="_top"><code class="filename">meta-pkgs/netbsd-doc-print</code></a> for the
8748: PostScript and PDF versions. You will need both packages
8749: installed, to make sure documentation is consistent across all
8750: formats.</p></li>
8751: <li><p>Run <span><strong class="command">cd doc/guide</strong></span> to get to the
8752: right directory. All further steps will take place
8753: here.</p></li>
8754: <li><p>Edit the XML file(s) in
8755: <code class="filename">files/</code>.</p></li>
8756: <li><p>Run <span><strong class="command">bmake</strong></span> to check the pkgsrc
8757: guide for valid XML and to build the final output files. If you
8758: get any errors at this stage, you can just edit the files, as
8759: there are only symbolic links in the working directory, pointing
8760: to the files in <code class="filename">files/</code>.</p></li>
8761: <li><p><span><strong class="command">(cd files && cvs
8762: commit)</strong></span></p></li>
8763: <li><p>Run <span><strong class="command">bmake clean && bmake</strong></span> to
8764: regenerate the output files with the proper RCS
8765: Ids.</p></li>
8766: <li><p>Run <span><strong class="command">(cd .. && cvs update pkgsrc.*)
8767: && bmake install-doc</strong></span> to put the generated
8768: files into <code class="filename">pkgsrc/doc</code>.</p></li>
8769: <li><p>Run <span><strong class="command">(cd .. && cvs commit -m
8770: "regenerated." pkgsrc.{html,txt})</strong></span> to commit the
8771: generated documentation.</p></li>
8772: <li><p>Run <span><strong class="command">(cd
8773: ../../../htdocs/Documentation/pkgsrc && cvs update)
8774: && bmake install-htdocs</strong></span> to generate all the
8775: files for the web server.</p></li>
8776: <li><p>Run <span><strong class="command">(cd
8777: ../../../htdocs/Documentation/pkgsrc && cvs commit -m
8778: "regenerated.")</strong></span> to update the files on the web server.
8779: If you have added a chapter, don't forget to run <span><strong class="command">cvs
8780: add *.html</strong></span> before you commit the files.</p></li>
8781: </ol></div>
1.75 rillig 8782: </div>
8783: </div>
8784: </div></body>
1.1 grant 8785: </html>
CVSweb <webmaster@jp.NetBSD.org>