Annotation of pkgsrc/doc/pkgsrc.html, revision 1.79
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.79 ! rillig 38: <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.20 2006/06/30 08:58:16 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>
156: </dl></dd>
157: </dl></dd>
158: <dt><span class="part"><a href="#developers-guide">II. The pkgsrc developer's guide</a></span></dt>
159: <dd><dl>
1.77 rillig 160: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
161: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75 rillig 162: <dd><dl>
1.77 rillig 163: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
164: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
165: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
166: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
167: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 168: <dd><dl>
169: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
170: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
171: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
172: </dl></dd>
1.77 rillig 173: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
174: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
175: </dl></dd>
176: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
177: <dd><dl>
178: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
179: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
180: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
181: <dd><dl>
182: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
183: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
184: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
185: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
186: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
187: </dl></dd>
188: </dl></dd>
189: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
190: <dd><dl>
191: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
192: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
193: <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>
194: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
195: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
196: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
197: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
198: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
199: </dl></dd>
200: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
201: <dd><dl>
202: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
203: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
204: <dd><dl>
205: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
206: <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>
207: </dl></dd>
208: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
209: <dd><dl>
210: <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>
211: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
212: </dl></dd>
213: </dl></dd>
214: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
215: <dd><dl>
216: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
217: <dd><dl>
218: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
219: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
220: </dl></dd>
221: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
222: <dd><dl>
223: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
224: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
225: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
226: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
227: </dl></dd>
228: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
229: <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>
230: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
231: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
232: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
233: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
234: <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>
235: </dl></dd>
236: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
237: <dd><dl>
238: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
239: <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>
240: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
241: </dl></dd>
242: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
243: <dd><dl>
244: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
245: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
246: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
247: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
248: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
249: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
250: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
251: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
252: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
253: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
254: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
255: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
256: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
257: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
258: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
259: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
260: </dl></dd>
261: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
262: <dd><dl>
263: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
264: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
265: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
266: </dl></dd>
267: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
268: <dd><dl>
269: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
270: <dd><dl>
1.78 rillig 271: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
272: <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>
273: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
274: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
275: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
276: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
277: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
278: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
279: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
280: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
281: <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 282: <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 283: </dl></dd>
284: <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>
285: <dd><dl>
286: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
287: <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>
288: </dl></dd>
289: <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>
290: <dd><dl>
291: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
292: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
293: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
294: </dl></dd>
295: <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>
296: <dd><dl>
1.78 rillig 297: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
298: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
299: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
300: </dl></dd>
301: <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>
302: <dd><dl>
303: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
304: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
305: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
306: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
307: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
308: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
309: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
310: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
311: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
312: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
313: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
314: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
315: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
316: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
317: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
318: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
319: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.77 rillig 320: </dl></dd>
1.78 rillig 321: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.77 rillig 322: </dl></dd>
323: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
324: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
325: <dd><dl>
326: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
327: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
328: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
329: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
330: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
331: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 332: </dl></dd>
1.77 rillig 333: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.75 rillig 334: </dl></dd>
335: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
336: <dd><dl>
1.77 rillig 337: <dt><span class="chapter"><a href="#infr.design">21. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 338: <dd><dl>
1.77 rillig 339: <dt><span class="sect1"><a href="#infr.var">21.1. Variable evaluation</a></span></dt>
1.75 rillig 340: <dd><dl>
1.77 rillig 341: <dt><span class="sect2"><a href="#infr.var.load">21.1.1. At load time</a></span></dt>
342: <dt><span class="sect2"><a href="#infr.var.run">21.1.2. At runtime</a></span></dt>
1.75 rillig 343: </dl></dd>
1.78 rillig 344: <dt><span class="sect1"><a href="#infr.varspec">21.2. How can variables be specified?</a></span></dt>
345: <dt><span class="sect1"><a href="#infr.design.intf">21.3. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 346: <dd><dl>
1.78 rillig 347: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.3.1. Procedures with parameters</a></span></dt>
348: <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 349: </dl></dd>
350: </dl></dd>
1.77 rillig 351: <dt><span class="chapter"><a href="#regression">22. Regression tests</a></span></dt>
1.75 rillig 352: <dd><dl>
1.77 rillig 353: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
354: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
355: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 356: <dd><dl>
1.77 rillig 357: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
358: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 359: </dl></dd>
360: </dl></dd>
1.79 ! rillig 361: <dt><span class="chapter"><a href="#infr.bulk">23. The implementation of the pkgsrc bulk builds</a></span></dt>
! 362: <dd><dl><dt><span class="sect1"><a href="#infr.bulk.what">23.1. Deciding which packages to build</a></span></dt></dl></dd>
! 363: <dt><span class="chapter"><a href="#porting">24. Porting pkgsrc</a></span></dt>
1.75 rillig 364: <dd><dl>
1.79 ! rillig 365: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
! 366: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 367: </dl></dd>
368: </dl></dd>
369: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
370: <dd><dl>
371: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
372: <dd><dl>
373: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
374: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
375: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
376: <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>
377: </dl></dd>
378: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
379: </dl></dd>
380: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
381: <dd><dl>
382: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
383: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
384: </dl></dd>
1.76 rillig 385: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
386: <dd><dl>
387: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
388: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
389: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
390: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
391: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
392: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
393: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
394: source packages</a></span></dt>
395: </dl></dd>
1.75 rillig 396: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
397: <dd><dl>
1.79 ! rillig 398: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75 rillig 399: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
400: </dl></dd>
401: </dl>
402: </div>
403: <div class="chapter" lang="en">
404: <div class="titlepage"><div><div><h2 class="title">
405: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
406: <div class="toc">
407: <p><b>Table of Contents</b></p>
408: <dl>
409: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
410: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
411: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.78 rillig 412: <dd><dl>
413: <dt><span class="sect2"><a href="#term.abbrev">1.3.1. Commonly used abbreviations</a></span></dt>
414: <dt><span class="sect2"><a href="#term.people">1.3.2. People involved in pkgsrc</a></span></dt>
415: </dl></dd>
1.75 rillig 416: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
417: </dl>
418: </div>
419: <div class="sect1" lang="en">
420: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
421: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
422: <p> There is a lot of software freely available for Unix-based
423: systems, which usually runs on NetBSD and other Unix-flavoured
424: systems, too, sometimes with some modifications. The NetBSD
425: Packages Collection (pkgsrc) incorporates any such changes
426: necessary to make that software run, and makes the installation
427: (and de-installation) of the software package easy by means of a
428: single command. </p>
429: <p>Once the software
430: has been built, it is manipulated with the <span><strong class="command">pkg_*</strong></span> tools
431: so that installation
432: and de-installation, printing of an inventory of all installed packages and
433: retrieval of one-line comments or more verbose descriptions are all
434: simple.</p>
435: <p>pkgsrc currently contains several thousand packages,
436: including:</p>
437: <div class="itemizedlist"><ul type="disc">
1.76 rillig 438: <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 439: web server</p></li>
1.76 rillig 440: <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 441: web browser</p></li>
1.76 rillig 442: <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 443: Desktop Environment</p></li>
1.76 rillig 444: <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 445: Desktop Environment</p></li>
446: </ul></div>
447: <p>...just to name a few.</p>
448: <p>pkgsrc has built-in support for handling varying dependencies,
449: such as pthreads and X11, and extended features such as IPv6 support on
450: a range of platforms.</p>
451: <p>pkgsrc was derived from FreeBSD's ports system, and
452: initially developed for NetBSD only. Since then, pkgsrc has
453: grown a lot, and now supports the following platforms:</p>
454: <div class="itemizedlist"><ul type="disc">
455: <li><p><a href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
456: (<a href="http://www.apple.com/macosx/" target="_top">Mac OS X</a>)</p></li>
457: <li><p><a href="http://www.DragonFlyBSD.org/" target="_top">DragonFly BSD</a></p></li>
458: <li><p><a href="http://www.FreeBSD.org/" target="_top">FreeBSD</a></p></li>
459: <li><p>Microsoft Windows, via <a href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a></p></li>
460: <li><p><a href="http://www.sgi.com/software/irix6.5/" target="_top">IRIX</a></p></li>
461: <li><p><a href="http://www.linux.org/" target="_top">Linux</a></p></li>
462: <li><p><a href="http://www.NetBSD.org/" target="_top">NetBSD</a> (of
463: course)</p></li>
464: <li><p><a href="http://h30097.www3.hp.com/" target="_top">Tru64</a>
465: (Digital UNIX, OSF1)</p></li>
466: <li><p><a href="http://www.openbsd.org/" target="_top">OpenBSD</a></p></li>
467: <li><p><a href="http://www.sun.com/solaris/" target="_top">Solaris</a></p></li>
468: </ul></div>
469: </div>
470: <div class="sect1" lang="en">
471: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
472: <a name="overview"></a>1.2. Overview</h2></div></div></div>
473: <p>This document is divided into three parts. The first,
474: <a href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
475: describes how one can use one of the packages in the Package
476: Collection, either by installing a precompiled binary package,
477: or by building one's own copy using the NetBSD package system.
478: 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
479: package so it can be easily built by other NetBSD users without
480: knowing about the package's building details. The third part,
481: <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
482: is intended for those who want to understand how pkgsrc is
483: implemented.</p>
484: <p>This document is available in various formats:
485: <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>
486: </div>
487: <div class="sect1" lang="en">
488: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
489: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
490: <p>There has been a lot of talk about “<span class="quote">ports</span>”,
491: “<span class="quote">packages</span>”, etc. so far. Here is a description of all the
492: terminology used within this document.</p>
493: <div class="variablelist"><dl>
494: <dt><span class="term">Package</span></dt>
495: <dd><p>A set of files and building instructions
496: that describe what's necessary
497: to build a certain piece of software using
498: pkgsrc. Packages are traditionally stored under
1.76 rillig 499: <code class="filename">/usr/pkgsrc</code>.</p></dd>
1.75 rillig 500: <dt><span class="term">The NetBSD package system</span></dt>
501: <dd><p>
502: This is the former name of “<span class="quote">pkgsrc</span>”. It is
503: part of the NetBSD operating system and can be bootstrapped to
504: run on non-NetBSD operating systems as well. It handles
505: building (compiling), installing, and removing of
506: packages.
507: </p></dd>
508: <dt><span class="term">Distfile</span></dt>
509: <dd><p>This term describes the file or files that are
510: provided by the author of the piece of software to
511: distribute his work. All the changes necessary to build on
512: NetBSD are reflected in the corresponding package. Usually
513: the distfile is in the form of a compressed tar-archive,
514: but other types are possible, too. Distfiles are usually
515: stored below
1.76 rillig 516: <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
1.75 rillig 517: <dt><span class="term">Port</span></dt>
518: <dd><p>This is the term used by FreeBSD and OpenBSD people
519: for what we call a package.
520: In NetBSD terminology, “<span class="quote">port</span>” refers to a different
521: architecture.</p></dd>
522: <dt><span class="term">Precompiled/binary package</span></dt>
523: <dd>
524: <p>A set of binaries built with pkgsrc from a distfile
1.76 rillig 525: and stuffed together in a single <code class="filename">.tgz</code>
1.75 rillig 526: file so it can be installed on machines of the same
527: machine architecture without the need to
528: recompile. Packages are usually generated in
1.76 rillig 529: <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.75 rillig 530: an archive on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
531: <p>Sometimes, this is referred to by the term “<span class="quote">package</span>” too,
532: especially in the context of precompiled packages.</p>
533: </dd>
534: <dt><span class="term">Program</span></dt>
535: <dd><p>The piece of software to be installed which will be constructed from
536: all the files in the distfile by the actions defined in the
537: corresponding package.</p></dd>
538: </dl></div>
539: <div class="sect2" lang="en">
540: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 541: <a name="term.abbrev"></a>1.3.1. Commonly used abbreviations</h3></div></div></div>
542: <div class="variablelist"><dl>
543: <dt><span class="term">ICE</span></dt>
544: <dd><p>Internal Compiler
545: Error</p></dd>
546: </dl></div>
547: </div>
548: <div class="sect2" lang="en">
549: <div class="titlepage"><div><div><h3 class="title">
550: <a name="term.people"></a>1.3.2. People involved in pkgsrc</h3></div></div></div>
1.75 rillig 551: <div class="variablelist"><dl>
552: <dt><span class="term">pkgsrc users</span></dt>
553: <dd>
554: <p>The
555: pkgsrc users are people who use the packages provided by pkgsrc.
556: Typically they are system administrators. The people using the
557: software that is inside the packages (maybe called “<span class="quote">end
558: users</span>”) are not covered by the pkgsrc guide.</p>
559: <p>There are two kinds of pkgsrc users: Some only want to
560: install pre-built binary packages. Others build the pkgsrc
561: packages from source, either for installing them directly or for
562: 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
563: documentation.</p>
564: </dd>
565: <dt><span class="term">package maintainers</span></dt>
566: <dd><p>A
567: 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>
568: <dt><span class="term">infrastructure developers</span></dt>
569: <dd><p>These people are involved in all those files
1.76 rillig 570: that live in the <code class="filename">mk/</code> directory and below.
1.75 rillig 571: 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,
572: too.</p></dd>
573: </dl></div>
574: </div>
575: </div>
576: <div class="sect1" lang="en">
577: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
578: <a name="typography"></a>1.4. Typography</h2></div></div></div>
579: <p>When giving examples for commands, shell prompts are used to
580: show if the command should/can be issued as root, or if
581: “<span class="quote">normal</span>” user privileges are sufficient. We use a
582: <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
583: shell prompt, assuming they use the C-shell or tcsh.</p>
584: </div>
585: </div>
586: <div class="part" lang="en">
587: <div class="titlepage"><div><div><h1 class="title">
588: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
589: <div class="toc">
590: <p><b>Table of Contents</b></p>
591: <dl>
592: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
593: <dd><dl>
594: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
595: <dd><dl>
596: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
597: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
598: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
599: </dl></dd>
600: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
601: <dd><dl>
602: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
603: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
604: </dl></dd>
605: </dl></dd>
606: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
607: <dd><dl>
608: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
609: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
610: <dd><dl>
611: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
612: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
613: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
614: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
615: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
616: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
617: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
618: </dl></dd>
619: </dl></dd>
620: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
621: <dd><dl>
622: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
623: <dd><dl>
624: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
625: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
626: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
627: </dl></dd>
628: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
629: <dd><dl>
630: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
631: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
632: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
633: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
634: </dl></dd>
635: </dl></dd>
636: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
637: <dd><dl>
638: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
639: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 640: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
641: <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>
642: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
643: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 644: </dl></dd>
645: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
646: <dd><dl>
647: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
648: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
649: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
650: <dd><dl>
651: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
652: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
653: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
654: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
655: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
656: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
657: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
658: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
659: </dl></dd>
660: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
661: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
662: </dl></dd>
663: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
664: <dd><dl>
665: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
666: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
667: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
668: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
669: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
670: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
671: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
672: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
673: <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>
674: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
675: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
676: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
677: <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>
678: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
679: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
680: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
681: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
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>
2559: </dl>
2560: </div>
2561: <p>This section contains hints, tips & tricks on special things in
2562: pkgsrc that we didn't find a better place for in the previous chapters, and
2563: it contains items for both pkgsrc users and developers.</p>
2564: <div class="sect1" lang="en">
2565: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2566: <a name="mailing-list-pointers"></a>7.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
2567: <p>The following mailing lists may be of interest to pkgsrc users:</p>
2568: <div class="itemizedlist"><ul type="disc">
1.78 rillig 2569: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-users" target="_top">pkgsrc-users</a>:
2570: This is a general purpose list for most issues regarding
2571: pkgsrc, regardless of platform, e.g. soliciting user help
2572: for pkgsrc configuration, unexpected build failures, using
2573: particular packages, upgrading pkgsrc installations,
2574: questions regarding the pkgsrc release branches, etc. General announcements or
2575: proposals for changes that impact the pkgsrc user community,
2576: e.g. major infrastructure changes, new features, package
2577: removals, etc., may also be posted.</p></li>
1.75 rillig 2578: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
2579: A list where the results of pkgsrc bulk builds are sent and
2580: discussed.</p></li>
2581: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
2582: This list is for those who are interested in getting a
2583: commit message for every change committed to pkgsrc. It is
2584: also available in digest form, meaning one daily message
2585: containing all commit messages for changes to the package
2586: source tree in that 24 hour period.</p></li>
2587: </ul></div>
2588: <p>To subscribe, do:</p>
2589: <pre class="programlisting">
2590: <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
2591: </pre>
2592: <p>Archives for all these mailing lists are available from
2593: <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
2594: </div>
2595: <div class="sect1" lang="en">
2596: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2597: <a name="pkgviews-docs"></a>7.2. Where's the pkgviews documentation?</h2></div></div></div>
2598: <p>Pkgviews is tightly integrated with buildlink. You can find a
2599: pkgviews User's guide in
1.76 rillig 2600: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
1.75 rillig 2601: </div>
2602: <div class="sect1" lang="en">
2603: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2604: <a name="faq-pkgtools"></a>7.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.76 rillig 2605: <p>The <code class="filename">pkgsrc/pkgtools</code> directory pkgtools contains
1.75 rillig 2606: a number of useful utilities for both users and developers of pkgsrc. This
2607: section attempts only to make the reader aware of the utilities and when
2608: they might be useful, and not to duplicate the documentation that comes
2609: with each package.</p>
2610: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
1.76 rillig 2611: <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 2612: Symlinks for use by buildlink.</p></li></ul></div>
2613: <p>OS tool augmentation (automatically installed when needed):</p>
2614: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2615: <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 2616: Calculates various kinds of checksums (including SHA1).</p></li>
1.76 rillig 2617: <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 2618: Compatibility library for pkgsrc tools.</p></li>
1.76 rillig 2619: <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 2620: non-BSD systems due to lack of native mtree.
2621: </p></li>
1.76 rillig 2622: <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 2623: Up-to-date replacement for
1.76 rillig 2624: <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
1.75 rillig 2625: systems where pkg_install is not present.</p></li>
2626: </ul></div>
2627: <p>Utilities used by pkgsrc (not automatically installed):</p>
2628: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2629: <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 2630: Create a binary package from an
2631: already-installed package. Used by <span><strong class="command">make replace</strong></span> to
2632: save the old package.</p></li>
1.76 rillig 2633: <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 2634: Adds extra functionality to pkgsrc, allowing it to fetch distfiles
2635: from multiple locations. It currently supports the following
2636: methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
1.76 rillig 2637: <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 2638: packages someplace else (enabled by default).</p></li>
1.76 rillig 2639: <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 2640: best compiler flags to optimise code for your current CPU and
2641: compiler.</p></li>
2642: </ul></div>
2643: <p>Utilities for keeping track of installed packages, being up to date,
2644: etc:</p>
2645: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2646: <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 2647: packages whose installed versions do not match the latest pkgsrc
2648: entries.</p></li>
1.76 rillig 2649: <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 2650: dependency graphs of packages, to aid in choosing a strategy for
2651: updating.</p></li>
1.76 rillig 2652: <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
2653: 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>
2654: <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 2655: pkglint(1) program checks a pkgsrc entry for errors, lintpkgsrc(1)
2656: does various checks on the complete pkgsrc system.</p></li>
1.76 rillig 2657: <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 2658: packages you have installed.</p></li>
2659: </ul></div>
2660: <p>Utilities for people maintaining or creating individual packages:</p>
2661: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2662: <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 2663: making and maintaining patches for a package (includes pkgdiff,
2664: pkgvi, mkpatches, etc.).</p></li>
1.76 rillig 2665: <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>,
2666: <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 2667: converting to pkgsrc.</p></li>
1.76 rillig 2668: <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 2669: pkgsrc to a Solaris package.</p></li>
2670: </ul></div>
2671: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
2672: utilities)</p>
2673: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2674: <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 2675: packages in a chrooted area.</p></li>
1.76 rillig 2676: <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 2677: kernel version for chrooted cross builds.</p></li>
2678: </ul></div>
2679: </div>
2680: <div class="sect1" lang="en">
2681: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2682: <a name="non-root-pkgsrc"></a>7.4. How to use pkgsrc as non-root</h2></div></div></div>
2683: <p>If you want to use pkgsrc as non-root user, you can set some
2684: variables to make pkgsrc work under these conditions. At the very least,
2685: you need to set <code class="varname">UNPRIVILEGED</code> to “<span class="quote">yes</span>”; this
2686: will turn on unprivileged mode and set multiple related variables to allow
2687: installation of packages as non-root.</p>
2688: <p>In case the defaults are not enough, you may want to tune some other
2689: variables used. For example, if the automatic user/group detection leads
2690: to incorrect values (or not the ones you would like to use), you can change
2691: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
2692: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
2693: <p>As regards bootstrapping, please note that the
2694: <span><strong class="command">bootstrap</strong></span> script will ease non-root configuration when
2695: given the “<span class="quote">--ignore-user-check</span>” flag, as it will choose and
1.76 rillig 2696: use multiple default directories under <code class="filename">~/pkg</code> as the
1.75 rillig 2697: installation targets. These directories can be overriden by the
2698: “<span class="quote">--prefix</span>” flag provided by the script, as well as some others
2699: that allow finer tuning of the tree layout.</p>
2700: </div>
2701: <div class="sect1" lang="en">
2702: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2703: <a name="resume-transfers"></a>7.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
2704: <p>By default, resuming transfers in pkgsrc is disabled, but you can
2705: enable this feature by adding the option
2706: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.76 rillig 2707: <code class="filename">/etc/mk.conf</code>. If, during a fetch step, an incomplete
1.75 rillig 2708: distfile is found, pkgsrc will try to resume it.</p>
2709: <p>You can also
2710: 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
2711: <code class="varname">FETCH_CMD</code> variable. Don't forget to set
2712: <code class="varname">FETCH_RESUME_ARGS</code> and
2713: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
2714: values.</p>
2715: <p>For example, if you want to use
1.76 rillig 2716: <code class="filename">wget</code> to resume downloads, you'll have to use something
1.75 rillig 2717: like:</p>
2718: <pre class="programlisting">
2719: FETCH_CMD= wget
2720: FETCH_BEFORE_ARGS= --passive-ftp
2721: FETCH_RESUME_ARGS= -c
2722: FETCH_OUTPUT_ARGS= -O
1.1 grant 2723: </pre>
1.75 rillig 2724: </div>
2725: <div class="sect1" lang="en">
2726: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2727: <a name="XFree86-from-pkgsrc"></a>7.6. How can I install/use XFree86 from pkgsrc?</h2></div></div></div>
2728: <p>If you want to use XFree86 from pkgsrc instead of your system's own
1.76 rillig 2729: X11 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>,
1.75 rillig 2730: ...), you will have to add the following line into
1.76 rillig 2731: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2732: <pre class="programlisting">
2733: X11_TYPE=XFree86
1.1 grant 2734: </pre>
1.75 rillig 2735: </div>
2736: <div class="sect1" lang="en">
2737: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2738: <a name="x.org-from-pkgsrc"></a>7.7. How can I install/use X.org from pkgsrc?</h2></div></div></div>
2739: <p>If you want to use X.org from pkgsrc instead of your system's own X11
1.76 rillig 2740: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
1.75 rillig 2741: you will have to add the following line into
1.76 rillig 2742: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2743: <pre class="programlisting">
2744: X11_TYPE=xorg
1.1 grant 2745: </pre>
1.75 rillig 2746: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
2747: <h3 class="title">Note</h3>
2748: <p>The DragonFly operating system defaults to using
2749: this X.org X11 implementation from pkgsrc.
2750: </p>
2751: </div>
2752: </div>
2753: <div class="sect1" lang="en">
2754: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2755: <a name="fetch-behind-firewall"></a>7.8. How to fetch files from behind a firewall</h2></div></div></div>
2756: <p>If you are sitting behind a firewall which does not allow direct
2757: connections to Internet hosts (i.e. non-NAT), you may specify the
2758: relevant proxy hosts. This is done using an environment variable in the
2759: form of a URL, e.g. in Amdahl, the machine
2760: “<span class="quote">orpheus.amdahl.com</span>” is one of the firewalls, and it uses
2761: port 80 as the proxy port number. So the proxy environment variables
2762: are:</p>
2763: <pre class="programlisting">
2764: ftp_proxy=ftp://orpheus.amdahl.com:80/
2765: http_proxy=http://orpheus.amdahl.com:80/
1.1 grant 2766: </pre>
1.75 rillig 2767: </div>
2768: <div class="sect1" lang="en">
2769: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2770: <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>
2771: <p>This depends on which utility is used to retrieve distfiles. From
1.76 rillig 2772: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
1.75 rillig 2773: the first available command from the following list:</p>
2774: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2775: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
2776: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
1.75 rillig 2777: </ul></div>
2778: <p>On a default NetBSD installation, this will be
1.76 rillig 2779: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
1.75 rillig 2780: connections first, and falls back to active connections if the server
2781: refuses to do passive. For the other tools, add the following to your
1.76 rillig 2782: <code class="filename">/etc/mk.conf</code> file:
1.75 rillig 2783: <code class="varname">PASSIVE_FETCH=1</code>.</p>
2784: <p>Having that option present will prevent
1.76 rillig 2785: <code class="filename">/usr/bin/ftp</code> from falling back to active
1.75 rillig 2786: transfers.</p>
2787: </div>
2788: <div class="sect1" lang="en">
2789: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2790: <a name="fetching-all-distfiles"></a>7.10. How to fetch all distfiles at once</h2></div></div></div>
2791: <p>You would like to download all the distfiles in a single batch from
2792: work or university, where you can't run a <span><strong class="command">make fetch</strong></span>.
2793: There is an archive of distfiles on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/" target="_top">ftp.NetBSD.org</a>,
2794: but downloading the entire directory may not be appropriate.</p>
2795: <p>The answer here is to do a <span><strong class="command">make fetch-list</strong></span> in
1.76 rillig 2796: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
1.75 rillig 2797: resulting list to your machine at work/school and use it there. If you
2798: 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
2799: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
2800: URL:</p>
2801: <p>At home:</p>
2802: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2803: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh</code></strong>
2804: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
2805: <p>At work:</p>
2806: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
1.76 rillig 2807: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
1.75 rillig 2808: home.</p>
2809: <p>If you have a machine running NetBSD, and you want to get
2810: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your machine
2811: architecture), you can do so by using the above-mentioned <span><strong class="command">make
2812: fetch-list</strong></span> approach, or fetch the distfiles directly by
2813: running:</p>
2814: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
2815: <p>If you even decide to ignore
2816: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
2817: by running:</p>
2818: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
2819: </div>
2820: <div class="sect1" lang="en">
2821: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2822: <a name="tmac.andoc-missing"></a>7.11. What does “<span class="quote">Don't know how to make
2823: /usr/share/tmac/tmac.andoc</span>” mean?</h2></div></div></div>
1.76 rillig 2824: <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 2825: package, you get the error from make that it doesn't know how to make
1.76 rillig 2826: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
1.75 rillig 2827: you don't have installed the “<span class="quote">text</span>” set (nroff, ...) from
2828: the NetBSD base distribution on your machine. It is recommended to do
2829: that to format man pages.</p>
1.76 rillig 2830: <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 2831: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.76 rillig 2832: environment or in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 2833: </div>
2834: <div class="sect1" lang="en">
2835: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2836: <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 2837: <p> You didn't install the compiler set, <code class="filename">comp.tgz</code>,
1.75 rillig 2838: when you installed your NetBSD machine. Please get and install it, by
1.76 rillig 2839: extracting it in <code class="filename">/</code>:</p>
1.75 rillig 2840: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
2841: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
1.76 rillig 2842: <p><code class="filename">comp.tgz</code> is part of every NetBSD release. Get
1.75 rillig 2843: the one that corresponds to your release (determine via <span><strong class="command">uname
2844: -r</strong></span>).</p>
2845: </div>
2846: <div class="sect1" lang="en">
2847: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2848: <a name="using-sudo-with-pkgsrc"></a>7.13. Using 'sudo' with pkgsrc</h2></div></div></div>
2849: <p>When installing packages as non-root user and using the just-in-time
2850: <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
2851: password for each required package installed. To avoid this, the sudo
2852: package can be used, which does password caching over a limited time. To
2853: use it, install sudo (either as binary package or from
1.76 rillig 2854: <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
2855: into your <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2856: <pre class="programlisting">
2857: .if exists(${LOCALBASE}/bin/sudo)
2858: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
2859: .endif
1.1 grant 2860: </pre>
1.75 rillig 2861: </div>
2862: <div class="sect1" lang="en">
2863: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2864: <a name="faq.conf"></a>7.14. How do I change the location of configuration files?</h2></div></div></div>
2865: <p>As the system administrator, you can choose where configuration files
2866: are installed. The default settings make all these files go into
1.76 rillig 2867: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
1.75 rillig 2868: be suboptimal depending on your expectations (e.g., a read-only,
2869: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
2870: configuration of the provided packages).</p>
2871: <p>In order to change the defaults, you can modify the
2872: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.76 rillig 2873: <code class="filename">/etc/mk.conf</code>) to point to your preferred configuration
2874: directory; some common examples include <code class="filename">/etc</code> or
2875: <code class="filename">/etc/pkg</code>.</p>
1.75 rillig 2876: <p>Furthermore, you can change this value on a per-package basis by
2877: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
2878: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
2879: package you would like to modify, that is, the contents of
2880: <code class="varname">PKGBASE</code>.</p>
2881: <p>Note that after changing these settings, you must rebuild and
2882: reinstall any affected packages.</p>
2883: </div>
2884: <div class="sect1" lang="en">
2885: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2886: <a name="audit-packages"></a>7.15. Automated security checks</h2></div></div></div>
2887: <p>Please be aware that there can often be bugs in third-party software,
2888: and some of these bugs can leave a machine vulnerable to exploitation by
2889: attackers. In an effort to lessen the exposure, the NetBSD packages team
2890: maintains a database of known-exploits to packages which have at one time
2891: been included in pkgsrc. The database can be downloaded automatically, and
2892: a security audit of all packages installed on a system can take place. To
1.76 rillig 2893: 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 2894: components:</p>
2895: <div class="orderedlist"><ol type="1">
2896: <li>
2897: <p><span><strong class="command">download-vulnerability-list</strong></span>, an easy way to
2898: download a list of the security vulnerabilities information. This list
2899: is kept up to date by the NetBSD security officer and the NetBSD
2900: packages team, and is distributed from the NetBSD ftp server:</p>
2901: <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>
2902: </li>
2903: <li><p><span><strong class="command">audit-packages</strong></span>, an easy way to audit the
2904: current machine, checking each vulnerability which is known. If a
2905: vulnerable package is installed, it will be shown by output to stdout,
2906: including a description of the type of vulnerability, and a URL
2907: containing more information.</p></li>
2908: </ol></div>
1.76 rillig 2909: <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 2910: package is strongly recommended! After
2911: “<span class="quote">audit-packages</span>” is installed, please read
2912: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
2913: audit-packages</code></strong>.</p>
2914: <p>If this package is installed, pkgsrc builds will use it to perform
2915: a security check before building any package. See
2916: <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.
2917: </p>
2918: </div>
2919: <div class="sect1" lang="en">
2920: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2921: <a name="ufaq-cflags"></a>7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
2922: <p>When you add your own preferences to the
2923: <code class="varname">CFLAGS</code> variable in your
1.76 rillig 2924: <code class="filename">mk.conf</code>, these flags are passed in
2925: environment variables to the <code class="filename">./configure</code>
1.75 rillig 2926: 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
2927: <code class="varname">CFLAGS</code> from the environment variable by
1.76 rillig 2928: overriding them in the <code class="filename">Makefile</code>s of their
1.75 rillig 2929: package.</p>
2930: <p>Currently there is no solution to this problem. If you
2931: really need the package to use your <code class="varname">CFLAGS</code>
2932: you should run <span><strong class="command">make patch</strong></span> in the package
1.76 rillig 2933: directory and then inspect any <code class="filename">Makefile</code> and
2934: <code class="filename">Makefile.in</code> for whether they define
1.75 rillig 2935: <code class="varname">CFLAGS</code> explicitly. Usually you can remove
2936: these lines. But be aware that some “<span class="quote">smart</span>”
2937: programmers write so bad code that it only works for the
2938: specific combination of <code class="varname">CFLAGS</code> they have
2939: chosen.</p>
2940: </div>
2941: </div>
2942: </div>
2943: <div class="part" lang="en">
2944: <div class="titlepage"><div><div><h1 class="title">
2945: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
1.77 rillig 2946: <div class="partintro" lang="en">
2947: <div></div>
2948: <p>This part of the book deals with creating and
2949: modifying packages. It starts with a “<span class="quote">HOWTO</span>”-like
2950: guide on creating a new package. The remaining chapters are more
2951: like a reference manual for pkgsrc.</p>
1.75 rillig 2952: <div class="toc">
2953: <p><b>Table of Contents</b></p>
2954: <dl>
1.77 rillig 2955: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
2956: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75 rillig 2957: <dd><dl>
1.77 rillig 2958: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
2959: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
2960: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
2961: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
2962: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 2963: <dd><dl>
2964: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
2965: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
2966: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
2967: </dl></dd>
1.77 rillig 2968: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
2969: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
2970: </dl></dd>
2971: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
2972: <dd><dl>
2973: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
2974: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
2975: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
2976: <dd><dl>
2977: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
2978: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
2979: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
2980: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
2981: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
2982: </dl></dd>
2983: </dl></dd>
2984: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
2985: <dd><dl>
2986: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
2987: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
2988: <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>
2989: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
2990: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
2991: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
2992: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
2993: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
2994: </dl></dd>
2995: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
2996: <dd><dl>
2997: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
2998: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
2999: <dd><dl>
3000: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
3001: <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>
3002: </dl></dd>
3003: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
3004: <dd><dl>
3005: <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>
3006: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
3007: </dl></dd>
3008: </dl></dd>
3009: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
3010: <dd><dl>
3011: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
3012: <dd><dl>
3013: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
3014: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
3015: </dl></dd>
3016: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
3017: <dd><dl>
3018: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
3019: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
3020: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
3021: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
3022: </dl></dd>
3023: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
3024: <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>
3025: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
3026: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
3027: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
3028: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
3029: <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>
3030: </dl></dd>
3031: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
3032: <dd><dl>
3033: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
3034: <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>
3035: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
3036: </dl></dd>
3037: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
3038: <dd><dl>
3039: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
3040: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
3041: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
3042: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
3043: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
3044: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
3045: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
3046: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
3047: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
3048: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
3049: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
3050: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3051: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
3052: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3053: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
3054: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
3055: </dl></dd>
3056: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
3057: <dd><dl>
3058: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
3059: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
3060: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
3061: </dl></dd>
3062: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
3063: <dd><dl>
3064: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
3065: <dd><dl>
1.78 rillig 3066: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
3067: <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>
3068: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
3069: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
3070: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
3071: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
3072: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
3073: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
3074: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
3075: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
3076: <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 3077: <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 3078: </dl></dd>
3079: <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>
3080: <dd><dl>
3081: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
3082: <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>
3083: </dl></dd>
3084: <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>
3085: <dd><dl>
3086: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
3087: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
3088: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
3089: </dl></dd>
3090: <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>
3091: <dd><dl>
1.78 rillig 3092: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
3093: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
3094: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
3095: </dl></dd>
3096: <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>
3097: <dd><dl>
3098: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
3099: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
3100: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
3101: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
3102: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
3103: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
3104: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
3105: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
3106: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
3107: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
3108: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
3109: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
3110: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
3111: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
3112: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
3113: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
3114: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.77 rillig 3115: </dl></dd>
1.78 rillig 3116: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.77 rillig 3117: </dl></dd>
3118: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
3119: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
3120: <dd><dl>
3121: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
3122: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
3123: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
3124: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
3125: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
3126: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 3127: </dl></dd>
1.77 rillig 3128: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.75 rillig 3129: </dl>
3130: </div>
1.77 rillig 3131: </div>
3132: <div class="chapter" lang="en">
3133: <div class="titlepage"><div><div><h2 class="title">
3134: <a name="creating"></a>Chapter 8. Creating a new pkgsrc package from scratch</h2></div></div></div>
3135: <p>When you find a package that is not yet in pkgsrc, you
3136: most likely have a URL from where you can download the source
3137: code. Starting with this URL, creating a package involves only a
3138: few steps.</p>
3139: <div class="procedure"><ol type="1">
3140: <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>
3141: <li><p>Then, choose one of the top-level directories as the
3142: category in which you want to place your package. You can also
3143: create a directory of your own (maybe called
3144: <code class="filename">local</code>). In that category directory, create
3145: another directory for your package and change into
3146: it.</p></li>
3147: <li><p>Run the program <span><strong class="command">url2pkg</strong></span>, which
3148: will ask you for a URL. Enter the URL of the distribution file
3149: (in most cases a <code class="filename">.tar.gz</code> file) and watch
3150: how the basic ingredients of your package are created
3151: automatically. The distribution file is extracted automatically
3152: to fill in some details in the <code class="filename">Makefile</code>
3153: that would otherwise have to be done manually.</p></li>
3154: <li>
3155: <p>Examine the extracted files to determine the
3156: dependencies of your package. Ideally, this is mentioned in some
3157: <code class="filename">README</code> file, but things may differ. For
3158: each of these dependencies, look where it exists in pkgsrc, and
3159: if there is a file called <code class="filename">buildlink3.mk</code> in
3160: that directory, add a line to your package
3161: <code class="filename">Makefile</code> which includes that file just
3162: before the last line. If the <code class="filename">buildlink3.mk</code>
3163: file does not exist, add a <code class="varname">DEPENDS</code> line to
3164: the Makefile, which specifies the version of the dependency and
3165: where it can be found in pkgsrc. This line should be placed in
3166: the third paragraph. If the dependency is only needed for
3167: building the package, but not when using it, use
3168: <code class="varname">BUILD_DEPENDS</code> instead of
3169: <code class="varname">DEPENDS</code>. Your package may then look like
3170: this:</p>
3171: <pre class="programlisting">
3172: [...]
3173:
3174: BUILD_DEPENDS+= lua>=5.0:../../lang/lua
3175: DEPENDS+= screen-[0-9]*:../../misc/screen
3176: DEPENDS+= screen>=4.0:../../misc/screen
3177:
3178: [...]
3179:
3180: .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
3181: .include "../../devel/glib2/buildlink3.mk"
3182: .include "../../mk/bsd.pkg.mk"
3183: </pre>
3184: </li>
3185: <li><p>Run <span><strong class="command">pkglint</strong></span> to see what things
3186: still need to be done to make your package a “<span class="quote">good</span>”
3187: one. If you don't know what pkglint's warnings want to tell you,
3188: try <span><strong class="command">pkglint --explain</strong></span> or <span><strong class="command">pkglint
3189: -e</strong></span>, which outputs additional
3190: explanations.</p></li>
3191: <li><p>Now, run <span><strong class="command">bmake</strong></span> to build the
3192: package. For the various things that can go wrong in this phase,
3193: consult <a href="#fixes" title="Chapter 17. Making your package work">Chapter 17, <i>Making your package work</i></a>.</p></li>
3194: <li><p>When the package builds fine, the next step is to
3195: install the package. Run <span><strong class="command">bmake install</strong></span> and
3196: hope that everything works.</p></li>
3197: <li><p>Up to now, the file <code class="filename">PLIST</code>,
3198: which contains a list of the files that are installed by the
3199: package, is nearly empty. Run <span><strong class="command">bmake print-PLIST
3200: >PLIST</strong></span> to generate a probably correct list. Check
3201: the file using your preferred text editor to see if the list of
3202: files looks plausible.</p></li>
3203: <li><p>Run <span><strong class="command">pkglint</strong></span> again to see if the
3204: generated <code class="filename">PLIST</code> contains garbage or
3205: not.</p></li>
3206: <li><p>When you ran <span><strong class="command">bmake install</strong></span>, the
3207: package has been registered in the database of installed files,
3208: but with an empty list of files. To fix this, run <span><strong class="command">bmake
3209: deinstall</strong></span> and <span><strong class="command">bmake install</strong></span> again.
3210: Now the package is registered with the list of files from
3211: <code class="filename">PLIST</code>.</p></li>
3212: <li><p>Run <span><strong class="command">bmake package</strong></span> to create a
3213: binary package from the set of installed files.</p></li>
3214: </ol></div>
3215: </div>
1.75 rillig 3216: <div class="chapter" lang="en">
3217: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3218: <a name="components"></a>Chapter 9. Package components - files, directories and contents</h2></div></div></div>
1.75 rillig 3219: <div class="toc">
3220: <p><b>Table of Contents</b></p>
3221: <dl>
1.77 rillig 3222: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
3223: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
3224: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
3225: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
3226: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 3227: <dd><dl>
3228: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
3229: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
3230: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
3231: </dl></dd>
1.77 rillig 3232: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
3233: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
1.75 rillig 3234: </dl>
3235: </div>
3236: <p> Whenever you're preparing a package, there are a number of
3237: files involved which are described in the following
3238: sections. </p>
3239: <div class="sect1" lang="en">
3240: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3241: <a name="components.Makefile"></a>9.1. <code class="filename">Makefile</code></h2></div></div></div>
1.75 rillig 3242: <p>Building, installation and creation of a binary package are all
1.76 rillig 3243: controlled by the package's <code class="filename">Makefile</code>.
3244: The <code class="filename">Makefile</code> describes various things about
1.75 rillig 3245: a package, for example from where to get it, how to configure,
3246: build, and install it.
3247: </p>
1.76 rillig 3248: <p>A package <code class="filename">Makefile</code> contains several
1.75 rillig 3249: sections that describe the package.</p>
3250: <p>In the first section there are the following variables, which
3251: should appear exactly in the order given here.
3252: </p>
3253: <div class="itemizedlist"><ul type="disc">
3254: <li><p><code class="varname">DISTNAME</code> is the basename of the
3255: distribution file to be downloaded from the package's
3256: website.</p></li>
3257: <li><p><code class="varname">PKGNAME</code> is the name of the
3258: package, as used by pkgsrc. You only need to provide it if it
3259: differs from <code class="varname">DISTNAME</code>. Usually it is the directory name together
3260: with the version number. It must match the regular expression
3261: <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
3262: starts with a letter or digit, and contains only letters, digits,
3263: dashes, underscores, dots and plus signs.</p></li>
3264: <li>
3265: <p><code class="varname">CATEGORIES</code> is a list of categories
3266: which the package fits in. You can choose any of the top-level
3267: directories of pkgsrc for it.</p>
3268: <p>Currently the following values are available for
3269: <code class="varname">CATEGORIES</code>. If more than
3270: one is used, they need to be separated by spaces:</p>
3271: <pre class="programlisting">
3272: archivers cross geography meta-pkgs security
3273: audio databases graphics misc shells
3274: benchmarks devel ham multimedia sysutils
3275: biology editors inputmethod net textproc
3276: cad emulators lang news time
3277: chat finance mail parallel wm
3278: comms fonts math pkgtools www
3279: converters games mbone print x11
1.1 grant 3280: </pre>
1.75 rillig 3281: </li>
3282: <li>
3283: <p><code class="varname">MASTER_SITES</code> is a list of URLs where
3284: the distribution files can be downloaded. Each URL must end with a
3285: slash.</p>
3286: <p>The <code class="varname">MASTER_SITES</code> may make use of
3287: the following predefined sites:</p>
3288: <pre class="programlisting">
3289: ${MASTER_SITE_APACHE}
3290: ${MASTER_SITE_BACKUP}
3291: ${MASTER_SITE_CYGWIN}
3292: ${MASTER_SITE_DEBIAN}
3293: ${MASTER_SITE_FREEBSD}
3294: ${MASTER_SITE_FREEBSD_LOCAL}
3295: ${MASTER_SITE_GNOME}
3296: ${MASTER_SITE_GNU}
3297: ${MASTER_SITE_GNUSTEP}
3298: ${MASTER_SITE_IFARCHIVE}
3299: ${MASTER_SITE_MOZILLA}
3300: ${MASTER_SITE_OPENOFFICE}
3301: ${MASTER_SITE_PERL_CPAN}
3302: ${MASTER_SITE_R_CRAN}
3303: ${MASTER_SITE_SOURCEFORGE}
3304: ${MASTER_SITE_SUNSITE}
3305: ${MASTER_SITE_SUSE}
3306: ${MASTER_SITE_TEX_CTAN}
3307: ${MASTER_SITE_XCONTRIB}
3308: ${MASTER_SITE_XEMACS}
1.74 rillig 3309: </pre>
1.75 rillig 3310: <p>If one of these predefined sites is chosen, you may
3311: want to specify a subdirectory of that
3312: site. Since these macros may expand to more than one
3313: actual site, you <span class="emphasis"><em>must</em></span> use the
3314: following construct to specify a subdirectory:</p>
3315: <pre class="programlisting">
3316: ${MASTER_SITE_GNU:=subdirectory/name/}
3317: ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1 grant 3318: </pre>
1.75 rillig 3319: <p>Note the trailing slash after the subdirectory name.</p>
3320: <p>If the package has multiple
3321: <code class="varname">DISTFILES</code> or multiple
3322: <code class="varname">PATCHFILES</code> from different
3323: sites, set <code class="varname">SITES.foo</code> to a list of URIs
3324: where file “<span class="quote">foo</span>” may be
3325: found. “<span class="quote">foo</span>” includes the suffix, e.g.:</p>
3326: <pre class="programlisting">
3327: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
3328: DISTFILES+= foo-file.tar.gz
3329: SITES.foo-file.tar.gz= \
3330: http://www.somewhere.com/somehow/ \
3331: http://www.somewhereelse.com/mirror/somehow/
1.1 grant 3332: </pre>
1.75 rillig 3333: </li>
3334: <li>
3335: <p><code class="varname">DISTFILES</code>: Name(s)
3336: of archive file(s) containing distribution. The default is
1.76 rillig 3337: <code class="filename">${DISTNAME}${EXTRACT_SUFX}</code>. Should only
1.75 rillig 3338: be set if you have more than one distfile.</p>
3339: <p>Note that the normal default setting of
3340: <code class="varname">DISTFILES</code> must be made explicit if you
3341: want to add to it (rather than replace it), as you usually
3342: would.</p>
3343: </li>
3344: <li><p><code class="varname">EXTRACT_SUFX</code>: Suffix of the
3345: distribution file, will be appended to
3346: <code class="varname">DISTNAME</code>. Defaults to
1.76 rillig 3347: <code class="filename">.tar.gz</code>.
1.75 rillig 3348: </p></li>
3349: </ul></div>
3350: <p>
3351: </p>
3352: <p>The second section contains information about separately
3353: downloaded patches, if any.
3354: </p>
3355: <div class="itemizedlist"><ul type="disc">
3356: <li><p><code class="varname">PATCHFILES:</code>
3357: Name(s) of additional files that contain distribution patches.
3358: There is no default. pkgsrc will look for them at
3359: <code class="varname">PATCH_SITES</code>.
3360: They will automatically be uncompressed before patching if
1.76 rillig 3361: the names end with <code class="filename">.gz</code> or
3362: <code class="filename">.Z</code>.</p></li>
1.75 rillig 3363: <li><p><code class="varname">PATCH_SITES</code>:
3364: Primary location(s) for distribution patch files (see
3365: <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
3366: </ul></div>
3367: <p>
3368: </p>
3369: <p>The third section contains the following variables.
3370: </p>
3371: <div class="itemizedlist"><ul type="disc">
3372: <li><p><code class="varname">MAINTAINER</code> is the email address
3373: of the person who feels responsible for this package, and who is
3374: most likely to look at problems or questions regarding this
3375: 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
3376: developers should contact the <code class="varname">MAINTAINER</code> before
3377: making major changes to the package. When packaging a new program,
3378: set <code class="varname">MAINTAINER</code> to yourself. If you really can't
3379: maintain the package for future updates, set it to
3380: <code class="email"><<a href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>></code>.</p></li>
3381: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
3382: find more information about the package.</p></li>
3383: <li><p><code class="varname">COMMENT</code> is a one-line
3384: description of the package (should not include the package
3385: name).</p></li>
3386: </ul></div>
3387: <p>
3388: </p>
3389: <p>Other variables that affect the build:
3390: </p>
3391: <div class="itemizedlist"><ul type="disc"><li>
3392: <p><code class="varname">WRKSRC</code>: The directory where the
3393: interesting distribution files of the package are found. The
1.76 rillig 3394: default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
1.75 rillig 3395: works for most packages.</p>
3396: <p>If a package doesn't create a subdirectory for itself
3397: (most GNU software does, for instance), but extracts itself in
3398: the current directory, you should set <code class="varname">WRKSRC=
3399: ${WRKDIR}</code>.</p>
3400: <p>If a package doesn't create a subdirectory with the name
3401: of <code class="varname">DISTNAME</code> but some different name, set
3402: <code class="varname">WRKSRC</code> to point to the proper name in
1.76 rillig 3403: <code class="filename">${WRKDIR}</code>, for example <code class="varname">WRKSRC=
3404: ${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 3405: <p>The name of the working directory created by pkgsrc is
3406: taken from the <code class="varname">WRKDIR_BASENAME</code> variable. By
1.76 rillig 3407: default, its value is <code class="filename">work</code>. If you want
1.75 rillig 3408: to use the same pkgsrc tree for building different kinds of
3409: binary packages, you can change the variable according to your
3410: needs. Two other variables handle common cases of setting
3411: <code class="varname">WRKDIR_BASENAME</code> individually. If
3412: <code class="varname">OBJHOSTNAME</code> is defined in
1.76 rillig 3413: <code class="filename">/etc/mk.conf</code>, the first component of the
1.75 rillig 3414: host's name is attached to the directory name. If
3415: <code class="varname">OBJMACHINE</code> is defined, the platform name is
1.76 rillig 3416: attached, which might look like <code class="filename">work.i386</code>
3417: or <code class="filename">work.sparc</code>.</p>
1.75 rillig 3418: </li></ul></div>
3419: <p>
3420: </p>
3421: <p>Please pay attention to the following gotchas:</p>
3422: <div class="itemizedlist"><ul type="disc">
3423: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are installed in
3424: compressed form by the package; see comment in
1.76 rillig 3425: <code class="filename">bsd.pkg.mk</code>.</p></li>
3426: <li><p>Replace <code class="filename">/usr/local</code> with
1.75 rillig 3427: “<span class="quote">${PREFIX}</span>” in all files (see patches, below).</p></li>
3428: <li><p>If the package installs any info files, see
1.78 rillig 3429: <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 3430: </ul></div>
3431: </div>
3432: <div class="sect1" lang="en">
3433: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3434: <a name="components.distinfo"></a>9.2. <code class="filename">distinfo</code></h2></div></div></div>
1.76 rillig 3435: <p>The <code class="filename">distinfo</code> file contains the message
1.75 rillig 3436: digest, or checksum, of each distfile needed for the package. This
3437: ensures that the distfiles retrieved from the Internet have not been
3438: corrupted during transfer or altered by a malign force to introduce
3439: a security hole. Due to recent rumor about weaknesses of digest
3440: algorithms, all distfiles are protected using both SHA1 and RMD160
3441: message digests, as well as the file size.</p>
1.76 rillig 3442: <p>The <code class="filename">distinfo</code> file also contains the
1.75 rillig 3443: checksums for all the patches found in the
1.77 rillig 3444: <code class="filename">patches</code> directory (see <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a>).</p>
1.76 rillig 3445: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.75 rillig 3446: <span><strong class="command">make makedistinfo</strong></span> or <span><strong class="command">make mdi</strong></span>
3447: command.</p>
3448: <p>Some packages have different sets of distfiles depending on
1.76 rillig 3449: 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
3450: <code class="filename">distinfo</code> file and care should be taken when
1.75 rillig 3451: upgrading such a package to ensure distfile information is not
3452: lost.</p>
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.patches"></a>9.3. patches/*</h2></div></div></div>
1.75 rillig 3457: <p>This directory contains files that are used by the
3458: <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
3459: modify the sources as distributed in the distribution file into a form
3460: that will compile and run perfectly on NetBSD. The files are applied
3461: successively in alphabetic order (as returned by a shell
3462: “<span class="quote">patches/patch-*</span>” glob expansion), so
1.76 rillig 3463: <code class="filename">patch-aa</code> is applied before
3464: <code class="filename">patch-ab</code>, etc.</p>
3465: <p>The <code class="filename">patch-*</code> files should be in
1.75 rillig 3466: <span><strong class="command">diff -bu</strong></span> format, and apply without a fuzz to avoid
3467: problems. (To force patches to apply
3468: with fuzz you can set <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>).
3469: Furthermore, do not put changes for more than one file into a single
3470: patch file, as this will make future modifications more difficult.</p>
3471: <p>Similar, a file should be patched at most once, not several times by
3472: several different patches. If a file needs several patches, they should
3473: be combined into one file.</p>
3474: <p>One important thing to mention is to pay attention that no RCS IDs
3475: get stored in the patch files, as these will cause problems when
3476: later checked into the NetBSD CVS tree. Use the
3477: <span><strong class="command">pkgdiff</strong></span> from the
1.76 rillig 3478: <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 3479: these problems.</p>
3480: <p>For even more automation, we recommend using <span><strong class="command">mkpatches</strong></span> from the same
3481: package to make a whole set of patches. You just have to backup files
1.76 rillig 3482: before you edit them to <code class="filename">filename.orig</code>, e.g. with
1.75 rillig 3483: <span><strong class="command">cp -p filename filename.orig</strong></span> or, easier, by using
3484: <span><strong class="command">pkgvi</strong></span> again from the same package. If you upgrade a package
3485: this way, you can easily compare the new set of patches with the
3486: previously existing one with <span><strong class="command">patchdiff</strong></span>.</p>
3487: <p>When you have finished a package, remember to generate the checksums
3488: for the patch files by using the <span><strong class="command">make makepatchsum</strong></span>
1.77 rillig 3489: command, see <a href="#components.distinfo" title="9.2. distinfo">Section 9.2, “<code class="filename">distinfo</code>”</a>.</p>
1.75 rillig 3490: <p>When adding a patch that corrects a problem in the distfile (rather
3491: than e.g. enforcing pkgsrc's view of where man pages should go), send
3492: the patch as a bug report to the maintainer. This benefits
3493: non-pkgsrc users of the package, and usually enables removing
3494: the patch in future version.</p>
3495: <p>Patch files that are distributed by the author or other
3496: maintainers can be listed in
3497: <code class="varname">$PATCHFILES</code>. </p>
3498: <p>If it is desired to store any patches that should not be committed into
3499: pkgsrc, they can be kept outside the pkgsrc tree in the
1.76 rillig 3500: <code class="filename">$LOCALPATCHES</code>
1.75 rillig 3501: directory. The directory tree there is expected to have the same
3502: “<span class="quote">category/package</span>” structure as pkgsrc, and patches are
3503: expected to be stored inside these dirs (also known as
1.76 rillig 3504: <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
1.75 rillig 3505: example, if you want to keep a private patch for
1.76 rillig 3506: <code class="filename">pkgsrc/graphics/png</code>, keep
3507: it in <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
1.75 rillig 3508: files in the named directory are expected to be patch files, and
3509: <span class="emphasis"><em>they are applied after pkgsrc patches are applied</em></span>.</p>
3510: </div>
3511: <div class="sect1" lang="en">
3512: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3513: <a name="other-mandatory-files"></a>9.4. Other mandatory files</h2></div></div></div>
1.75 rillig 3514: <div class="variablelist"><dl>
1.76 rillig 3515: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
1.75 rillig 3516: <dd><p>A multi-line description of the piece of software. This should include
3517: any credits where they are due. Please bear in mind that others do not
3518: share your sense of humour (or spelling idiosyncrasies), and that others
3519: will read everything that you write here.</p></dd>
1.76 rillig 3520: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
1.75 rillig 3521: <dd><p>
3522: This file governs the files that are installed on your system: all the
3523: binaries, manual pages, etc. There are other directives which may be
3524: entered in this file, to control the creation and deletion of
3525: directories, and the location of inserted files.
1.77 rillig 3526: See <a href="#plist" title="Chapter 11. PLIST issues">Chapter 11, <i>PLIST issues</i></a> for more information. </p></dd>
1.75 rillig 3527: </dl></div>
3528: </div>
3529: <div class="sect1" lang="en">
3530: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3531: <a name="components.optional"></a>9.5. Optional files</h2></div></div></div>
1.78 rillig 3532: <div class="sect2" lang="en">
3533: <div class="titlepage"><div><div><h3 class="title">
3534: <a name="components.optional.bin"></a>9.5.1. Files affecting the binary package</h3></div></div></div>
1.75 rillig 3535: <div class="variablelist"><dl>
1.76 rillig 3536: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.75 rillig 3537: <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>.
3538: First time after package
3539: extraction and before files are moved in place, the second time after
3540: the files to install are moved in place. This can be used to do any
3541: custom procedures not possible with @exec commands in
1.76 rillig 3542: <code class="filename">PLIST</code>. See
1.75 rillig 3543: <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 3544: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
1.75 rillig 3545: <dd><p>This script is executed before and after any files are removed. It is
3546: this script's responsibility to clean up any additional messy details
3547: around the package's installation, since all pkg_delete knows is how to
3548: delete the files created in the original distribution.
3549: 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>
3550: 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 3551: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
1.75 rillig 3552: <dd>
3553: <p>This file is displayed after installation of the package.
3554: Useful for things like legal notices on almost-free
3555: software and hints for updating config files after
3556: installing modules for apache, PHP etc.
3557: Please note that you can modify variables in it easily by using
3558: <code class="varname">MESSAGE_SUBST</code> in the package's
1.76 rillig 3559: <code class="filename">Makefile</code>:</p>
1.75 rillig 3560: <pre class="programlisting">
3561: MESSAGE_SUBST+= SOMEVAR="somevalue"
1.1 grant 3562: </pre>
1.75 rillig 3563: <p>replaces "${SOMEVAR}" with “<span class="quote">somevalue</span>” in
1.76 rillig 3564: <code class="filename">MESSAGE</code>.</p>
1.75 rillig 3565: </dd>
1.78 rillig 3566: <dt><span class="term"><code class="filename">ALTERNATIVES</code></span></dt>
3567: <dd><p>FIXME: There is no documentation on the
3568: alternatives framework.</p></dd>
3569: </dl></div>
3570: </div>
3571: <div class="sect2" lang="en">
3572: <div class="titlepage"><div><div><h3 class="title">
3573: <a name="components.optional.build"></a>9.5.2. Files affecting the build process</h3></div></div></div>
3574: <div class="variablelist"><dl>
3575: <dt><span class="term"><code class="filename">Makefile.common</code></span></dt>
3576: <dd><p>This file contains arbitrary things that could
3577: also go into a <code class="filename">Makefile</code>, but its purpose is
3578: to be used by more than one package. This file should only be
3579: used when the packages that will use the file are known in
3580: advance. For other purposes it is often better to write a
3581: <code class="filename">*.mk</code> file and give it a good name that
3582: describes what it does.</p></dd>
3583: <dt><span class="term"><code class="filename">buildlink3.mk</code></span></dt>
3584: <dd><p>This file contains the dependency information
3585: for the buildlink3 framework (see <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a>).</p></dd>
3586: <dt><span class="term"><code class="filename">hacks.mk</code></span></dt>
3587: <dd><p>This file contains workarounds for compiler bugs
3588: and similar things. It is included automatically by the pkgsrc
3589: infrastructure, so you don't need an extra
3590: <code class="literal">.include</code> line for
3591: it.</p></dd>
3592: <dt><span class="term"><code class="filename">options.mk</code></span></dt>
3593: <dd><p>This file contains the code for the
3594: package-specific options (see <a href="#options" title="Chapter 14. Options handling">Chapter 14, <i>Options handling</i></a>) that can be
3595: selected by the user. If a package has only one or two options,
3596: it is equally acceptable to put the code directly into the
3597: <code class="filename">Makefile</code>.</p></dd>
3598: </dl></div>
3599: </div>
3600: <div class="sect2" lang="en">
3601: <div class="titlepage"><div><div><h3 class="title">
3602: <a name="components.optional.none"></a>9.5.3. Files affecting nothing at all</h3></div></div></div>
3603: <div class="variablelist"><dl>
3604: <dt><span class="term"><code class="filename">README*</code></span></dt>
3605: <dd><p>These files do not take place in the creation of
3606: a package and thus are purely informative to the package
3607: developer.</p></dd>
3608: <dt><span class="term"><code class="filename">TODO</code></span></dt>
3609: <dd><p>This file contains things that need to be done
3610: to make the package even
3611: better.</p></dd>
1.75 rillig 3612: </dl></div>
3613: </div>
1.78 rillig 3614: </div>
1.75 rillig 3615: <div class="sect1" lang="en">
3616: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3617: <a name="work-dir"></a>9.6. <code class="filename">work*</code></h2></div></div></div>
1.75 rillig 3618: <p>When you type <span><strong class="command">make</strong></span>, the distribution files are
3619: unpacked into the directory denoted by
3620: <code class="varname">WRKDIR</code>. It can be removed by running
3621: <span><strong class="command">make clean</strong></span>. Besides the sources, this
3622: directory is also used to keep various timestamp files.
3623: The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
1.76 rillig 3624: The default is <code class="filename">${.CURDIR}/work</code>
3625: or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
1.75 rillig 3626: if <code class="varname">OBJMACHINE</code> is set.</p>
3627: </div>
3628: <div class="sect1" lang="en">
3629: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3630: <a name="files-dir"></a>9.7. <code class="filename">files/*</code></h2></div></div></div>
1.75 rillig 3631: <p>If you have any files that you wish to be placed in the package prior
3632: to configuration or building, you could place these files here and use
3633: a “<span class="quote">${CP}</span>” command in the
3634: “<span class="quote">pre-configure</span>” target to achieve
3635: this. Alternatively, you could simply diff the file against
1.76 rillig 3636: <code class="filename">/dev/null</code> and use the patch mechanism to manage
1.75 rillig 3637: the creation of this file.</p>
3638: </div>
3639: </div>
3640: <div class="chapter" lang="en">
3641: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3642: <a name="makefile"></a>Chapter 10. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.75 rillig 3643: <div class="toc">
3644: <p><b>Table of Contents</b></p>
3645: <dl>
1.77 rillig 3646: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
3647: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
3648: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
3649: <dd><dl>
3650: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
3651: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
3652: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
3653: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
3654: <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 3655: </dl></dd>
3656: </dl>
3657: </div>
1.76 rillig 3658: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
1.75 rillig 3659: each of which forms a well-defined part of the pkgsrc system. Using
3660: 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
3661: like pkgsrc requires some discipline to keep the code correct and
3662: understandable.</p>
1.76 rillig 3663: <p>The basic ingredients for <code class="filename">Makefile</code>
1.75 rillig 3664: programming are variables (which are actually macros) and shell
3665: commands. Among these shell commands may even be more complex ones
3666: 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
3667: as intended it is necessary to quote all variables correctly when they
3668: are used.</p>
3669: <p>This chapter describes some patterns, that appear quite often in
1.76 rillig 3670: <code class="filename">Makefile</code>s, including the pitfalls that come along
1.75 rillig 3671: with them.</p>
3672: <div class="sect1" lang="en">
3673: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3674: <a name="makefile.variables"></a>10.1. <code class="filename">Makefile</code> variables</h2></div></div></div>
1.76 rillig 3675: <p><code class="filename">Makefile</code> variables contain strings that
1.75 rillig 3676: can be processed using the five operators ``='', ``+='', ``?='',
3677: ``:='', 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
3678: page.</p>
3679: <p>When a variable's value is parsed from a
1.76 rillig 3680: <code class="filename">Makefile</code>, the hash character ``#'' and the
1.75 rillig 3681: backslash character ``\'' are handled specially. If a backslash is
3682: followed by a newline, any whitespace immediately in front of the
3683: backslash, the backslash, the newline, and any whitespace
3684: immediately behind the newline are replaced with a single space. A
3685: backslash character and an immediately following hash character are
3686: replaced with a single hash character. Otherwise, the backslash is
3687: passed as is. In a variable assignment, any hash character that is
3688: not preceded by a backslash starts a comment that continues upto the
3689: end of the logical line.</p>
3690: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
3691: the only way to create a variable consisting of a single backslash
3692: is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
3693: <p>So far for defining variables. The other thing you can do with
3694: variables is evaluating them. A variable is evaluated when it is
3695: part of the right side of the ``:='' or the ``!='' operator, or
3696: directly before executing a shell command which the variable is part
3697: 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
3698: is, variables are not evaluated until there's no other way. The
3699: ``modifiers'' mentioned in the man page also evaluate the
3700: variable.</p>
3701: <p>Some of the modifiers split the string into words and then
3702: operate on the words, others operate on the string as a whole. When
3703: a string is split into words, it is split as you would expect
3704: 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 3705: <p>No rule without exception—the <span><strong class="command">.for</strong></span>
1.75 rillig 3706: loop does not follow the shell quoting rules but splits at sequences
3707: of whitespace.</p>
3708: <p>There are several types of variables that should be handled
3709: differently. Strings and two types of lists.</p>
3710: <div class="itemizedlist"><ul type="disc">
3711: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
3712: characters. Nevertheless, you should restrict yourself to only
3713: using printable characters. Examples are
3714: <code class="varname">PREFIX</code> and
3715: <code class="varname">COMMENT</code>.</p></li>
3716: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
3717: are never exported to any shell command. Their elements are
3718: separated by whitespace. Therefore, the elements themselves cannot
3719: have embedded whitespace. Any other characters are allowed.
3720: Internal lists can be used in <span><strong class="command">.for</strong></span> loops.
3721: Examples are <code class="varname">DEPENDS</code> and
3722: <code class="varname">BUILD_DEPENDS</code>.</p></li>
3723: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
3724: may be exported to a shell command. Their elements can contain any
3725: characters, including whitespace. That's why they cannot be used
3726: in <span><strong class="command">.for</strong></span> loops. Examples are
3727: <code class="varname">DISTFILES</code> and
3728: <code class="varname">MASTER_SITES</code>.</p></li>
3729: </ul></div>
3730: <div class="sect2" lang="en">
3731: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3732: <a name="makefile.variables.names"></a>10.1.1. Naming conventions</h3></div></div></div>
1.75 rillig 3733: <div class="itemizedlist"><ul type="disc">
3734: <li><p>All variable names starting with an underscore
3735: are reserved for use by the pkgsrc infrastructure. They shall
3736: not be used by package
1.76 rillig 3737: <code class="filename">Makefile</code>s.</p></li>
1.75 rillig 3738: <li><p>In <span><strong class="command">.for</strong></span> loops you should use
3739: lowercase variable names for the iteration
3740: variables.</p></li>
3741: <li><p>All list variables should have a ``plural''
3742: name, e.g. <code class="varname">PKG_OPTIONS</code> or
3743: <code class="varname">DISTFILES</code>.</p></li>
3744: </ul></div>
3745: </div>
3746: </div>
3747: <div class="sect1" lang="en">
3748: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3749: <a name="makefile.code"></a>10.2. Code snippets</h2></div></div></div>
1.75 rillig 3750: <p>This section presents you with some code snippets you should
3751: use in your own code. If you don't find anything appropriate here,
3752: you should test your code and add it here.</p>
3753: <div class="sect2" lang="en">
3754: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3755: <a name="adding-to-list"></a>10.2.1. Adding things to a list</h3></div></div></div>
1.75 rillig 3756: <pre class="programlisting">
3757: STRING= foo * bar `date`
3758: INT_LIST= # empty
3759: ANOTHER_INT_LIST= apache-[0-9]*:../../www/apache
3760: EXT_LIST= # empty
3761: ANOTHER_EXT_LIST= a=b c=d
1.1 grant 3762:
1.75 rillig 3763: INT_LIST+= ${STRING} # 1
3764: INT_LIST+= ${ANOTHER_INT_LIST} # 2
3765: EXT_LIST+= ${STRING:Q} # 3
3766: EXT_LIST+= ${ANOTHER_EXT_LIST} # 4
1.1 grant 3767: </pre>
1.75 rillig 3768: <p>When you add a string to an external list (example 3), it
3769: must be quoted. In all other cases, you must not add a quoting
3770: level. You must not merge internal and external lists, unless you
3771: are sure that all entries are correctly interpreted in both
3772: lists.</p>
3773: </div>
3774: <div class="sect2" lang="en">
3775: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3776: <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 3777: <pre class="programlisting">
3778: EXT_LIST= # empty
3779: .for i in ${INT_LIST}
3780: EXT_LIST+= ${i:Q}""
3781: .endfor
1.1 grant 3782: </pre>
1.75 rillig 3783: <p>This code converts the internal list
3784: <code class="varname">INT_LIST</code> into the external list
3785: <code class="varname">EXT_LIST</code>. As the elements of an internal list
3786: are unquoted they must be quoted here. The reason for appending
3787: <code class="varname">""</code> is explained below.</p>
3788: </div>
3789: <div class="sect2" lang="en">
3790: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3791: <a name="passing-variable-to-shell"></a>10.2.3. Passing variables to a shell command</h3></div></div></div>
1.79 ! rillig 3792: <p>Sometimes you may want to print an arbitrary string. There
! 3793: are many ways to get it wrong and only few that can handle every
! 3794: nastiness.</p>
1.75 rillig 3795: <pre class="programlisting">
3796: STRING= foo bar < > * `date` $$HOME ' "
3797: EXT_LIST= string=${STRING:Q} x=second\ item
1.1 grant 3798:
1.75 rillig 3799: all:
3800: echo ${STRING} # 1
3801: echo "${STRING}" # 2
3802: echo "${STRING:Q}" # 3
3803: echo ${STRING:Q} # 4
3804: echo x${STRING:Q} | sed 1s,.,, # 5
1.79 ! rillig 3805: printf "%s\\n" ${STRING:Q}"" # 6
1.75 rillig 3806: env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
1.1 grant 3807: </pre>
1.75 rillig 3808: <p>Example 1 leads to a syntax error in the shell, as the
3809: characters are just copied.</p>
3810: <p>Example 2 leads to a syntax error too, and if you leave out
3811: the last " character from <code class="varname">${STRING}</code>,
3812: <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
3813: variable would be evaluated, too.</p>
3814: <p>Example 3 outputs each space character preceded by a
3815: backslash (or not), depending on the implementation of the
3816: <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>
3817: <p>Example 4 handles correctly every string that does not start
3818: with a dash. In that case, the result depends on the
3819: 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
3820: guarantee that your input does not start with a dash, this form is
3821: appropriate.</p>
3822: <p>Example 5 handles even the case of a leading dash
3823: correctly.</p>
1.79 ! rillig 3824: <p>Example 6 also works with every string and is the
! 3825: light-weight solution, since it does not involve a pipe, which has
! 3826: its own problems.</p>
1.75 rillig 3827: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
3828: because the quoting has already been done when adding elements to
3829: the list.</p>
3830: <p>As internal lists shall not be passed to the shell, there is
3831: no example for it.</p>
3832: </div>
3833: <div class="sect2" lang="en">
3834: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3835: <a name="quoting-guideline"></a>10.2.4. Quoting guideline</h3></div></div></div>
1.75 rillig 3836: <p>There are many possible sources of wrongly quoted variables.
3837: This section lists some of the commonly known ones.</p>
3838: <div class="itemizedlist"><ul type="disc">
3839: <li>
3840: <p>Whenever you use the value of a list, think
3841: about what happens to leading or trailing whitespace. If the
3842: list is a well-formed shell expression, you can apply the
3843: <code class="varname">:M*</code> modifier to strip leading and trailing
3844: whitespace from each word. The <code class="varname">:M</code> operator
3845: first splits its argument according to the rules of the shell,
3846: and then creates a new list consisting of all words that match
3847: the shell glob expression <code class="varname">*</code>, that is: all.
3848: One class of situations where this is needed is when adding a
3849: variable like <code class="varname">CPPFLAGS</code> to
3850: <code class="varname">CONFIGURE_ARGS</code>. If the configure script
3851: invokes other configure scripts, it strips the leading and
3852: trailing whitespace from the variable and then passes it to the
3853: other configure scripts. But these configure scripts expect the
3854: (child) <code class="varname">CPPFLAGS</code> variable to be the same as
3855: the parent <code class="varname">CPPFLAGS</code>. That's why we better
3856: pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
3857: here is how we do it:</p>
3858: <pre class="programlisting">
3859: CPPFLAGS= # empty
3860: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX:Q}\"
3861: CPPFLAGS+= ${MY_CPPFLAGS}
1.1 grant 3862:
1.75 rillig 3863: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
1.1 grant 3864:
1.75 rillig 3865: all:
3866: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
3867: echo x${CONFIGURE_ARGS}x # properly trimmed
1.1 grant 3868: </pre>
1.75 rillig 3869: </li>
3870: <li><p>The example above contains one bug: The
3871: <code class="varname">${PREFIX}</code> is a properly quoted shell
3872: expression, but there is the C compiler after it, which also
3873: expects a properly quoted string (this time in C syntax). The
3874: version above is therefore only correct if
3875: <code class="varname">${PREFIX}</code> does not have embedded backslashes
3876: or double quotes. If you want to allow these, you have to add
3877: another layer of quoting to each variable that is used as a C
3878: string literal. You cannot use the <code class="varname">:Q</code>
3879: operator for it, as this operator only works for the
3880: shell.</p></li>
3881: <li>
3882: <p>Whenever a variable can be empty, the
3883: <code class="varname">:Q</code> operator can have surprising results. Here
3884: are two completely different cases which can be solved with the
3885: same trick.</p>
3886: <pre class="programlisting">
3887: EMPTY= # empty
3888: empty_test:
3889: for i in a ${EMPTY:Q} c; do \
3890: echo "$$i"; \
3891: done
1.1 grant 3892:
1.75 rillig 3893: for_test:
3894: .for i in a:\ a:\test.txt
3895: echo ${i:Q}
3896: echo "foo"
3897: .endfor
1.1 grant 3898: </pre>
1.75 rillig 3899: <p>The first example will only print two of the three lines
3900: we might have expected. This is because
3901: <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
3902: the shell cannot see. The workaround is to write
3903: <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
3904: as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
3905: -f ${FNAME:Q}</code> (both of these are wrong).</p>
3906: <p>The second example will only print three lines instead of
3907: four. The first line looks like <code class="varname">a:\ echo foo</code>.
3908: This is because the backslash of the value
3909: <code class="varname">a:\</code> is interpreted as a line-continuation by
3910: <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
3911: <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
3912: <code class="varname">${i:Q}""</code>.</p>
3913: </li>
3914: </ul></div>
3915: </div>
3916: <div class="sect2" lang="en">
3917: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3918: <a name="bsd-make-bug-workaround"></a>10.2.5. Workaround for a bug in BSD Make</h3></div></div></div>
1.75 rillig 3919: <p>The pkgsrc bmake program does not handle the following
3920: assignment correctly. In case <code class="varname">_othervar_</code>
3921: contains a ``-'' character, one of the closing braces is included
3922: in <code class="varname">${VAR}</code> after this code executes.</p>
3923: <pre class="programlisting">
3924: VAR:= ${VAR:N${_othervar_:C/-//}}
1.1 grant 3925: </pre>
1.75 rillig 3926: <p>For a more complex code snippet and a workaround, see the
1.76 rillig 3927: 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 3928: <code class="varname">bug1</code>.</p>
3929: </div>
3930: </div>
3931: </div>
3932: <div class="chapter" lang="en">
3933: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3934: <a name="plist"></a>Chapter 11. PLIST issues</h2></div></div></div>
1.75 rillig 3935: <div class="toc">
3936: <p><b>Table of Contents</b></p>
3937: <dl>
1.77 rillig 3938: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
3939: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
3940: <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>
3941: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
3942: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
3943: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
3944: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
3945: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
1.75 rillig 3946: </dl>
3947: </div>
1.76 rillig 3948: <p> The <code class="filename">PLIST</code> file contains a package's
1.75 rillig 3949: “<span class="quote">packing list</span>”, i.e. a list of files that belong to
1.76 rillig 3950: the package (relative to the <code class="filename">${PREFIX}</code>
1.75 rillig 3951: directory it's been installed in) plus some additional statements
3952: - 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.
3953: This chapter addresses some issues that need attention when
1.76 rillig 3954: dealing with the <code class="filename">PLIST</code> file (or files, see
1.75 rillig 3955: below!).</p>
3956: <div class="sect1" lang="en">
3957: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3958: <a name="rcs-id"></a>11.1. RCS ID</h2></div></div></div>
1.75 rillig 3959: <p>
3960: Be sure to add a RCS ID line as the first thing in any
1.76 rillig 3961: <code class="filename">PLIST</code> file you write:
1.75 rillig 3962: </p>
3963: <pre class="programlisting">
3964: @comment $NetBSD$
1.55 rillig 3965: </pre>
1.75 rillig 3966: </div>
3967: <div class="sect1" lang="en">
3968: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3969: <a name="automatic-plist-generation"></a>11.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.75 rillig 3970: <p>You can use the <span><strong class="command">make print-PLIST</strong></span> command
3971: to output a PLIST that matches any new files since the package
1.77 rillig 3972: 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 3973: more information on this target.</p>
3974: </div>
3975: <div class="sect1" lang="en">
3976: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3977: <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 3978: <p> If you have used any of the *-dirs packages, as explained in
1.77 rillig 3979: <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 3980: <span><strong class="command">make print-PLIST</strong></span> outputs a set of
3981: <code class="varname">@comment</code>s instead of real
3982: <code class="varname">@dirrm</code> lines. You can also do this for
3983: specific directories and files, so that the results of that
3984: command are very close to reality. This helps <span class="emphasis"><em>a
3985: lot</em></span> during the update of packages. </p>
3986: <p> The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
3987: of AWK patterns and actions that are used to filter the output of
3988: print-PLIST. You can <span class="emphasis"><em>append</em></span> any chunk of AWK
3989: scripting you like to it, but be careful with quoting. </p>
3990: <p> For example, to get all files inside the
1.76 rillig 3991: <code class="filename">libdata/foo</code> directory removed from the
1.75 rillig 3992: resulting PLIST:</p>
3993: <pre class="programlisting">
3994: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
1.55 rillig 3995: </pre>
1.75 rillig 3996: <p> And to get all the <code class="varname">@dirrm</code> lines referring
3997: to a specific (shared) directory converted to
3998: <code class="varname">@comment</code>s: </p>
3999: <pre class="programlisting">
4000: PRINT_PLIST_AWK+= /^@dirrm share\/specific/ { print "@comment " $$0; next; }
1.51 rillig 4001: </pre>
1.75 rillig 4002: </div>
4003: <div class="sect1" lang="en">
4004: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4005: <a name="plist.misc"></a>11.4. Variable substitution in PLIST</h2></div></div></div>
1.75 rillig 4006: <p>
4007: A number of variables are substituted automatically in PLISTs
4008: when a package is installed on a system. This includes the
4009: following variables: </p>
4010: <div class="variablelist"><dl>
4011: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
4012: <dd>
4013: <p>Some packages like emacs and perl embed information
4014: about which architecture they were built on into the
4015: pathnames where they install their files. To handle this
4016: case, PLIST will be preprocessed before actually used, and
4017: the symbol
4018: “<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>” will be
4019: replaced by what <span><strong class="command">uname -p</strong></span> gives. The
4020: same is done if the string
4021: <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
4022: PLIST somewhere - use this on packages that have GNU
4023: autoconf-created configure scripts.</p>
4024: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
4025: <h3 class="title">Legacy note</h3>
4026: <p>There used to be a symbol
4027: “<span class="quote"><code class="varname">$ARCH</code></span>” that
4028: was replaced by the output of <span><strong class="command">uname
4029: -m</strong></span>, but that's no longer supported and has
4030: been removed.</p>
4031: </div>
4032: </dd>
4033: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
4034: <dd>
4035: <p>Some packages want to embed the OS name and version
4036: into some paths. To do this, use these variables in the
1.76 rillig 4037: <code class="filename">PLIST</code>:
1.75 rillig 4038: </p>
4039: <div class="itemizedlist"><ul type="disc">
4040: <li><p><code class="varname">${OPSYS}</code> - output of “<span class="quote"><span><strong class="command">uname -s</strong></span></span>”</p></li>
4041: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. “<span class="quote">solaris</span>”)</p></li>
4042: <li><p><code class="varname">${OS_VERSION}</code> - “<span class="quote"><span><strong class="command">uname -r</strong></span></span>”</p></li>
4043: </ul></div>
4044: </dd>
4045: </dl></div>
4046: <p> For a complete list of values which are replaced by
1.76 rillig 4047: default, please look in <code class="filename">bsd.pkg.mk</code> (and
1.75 rillig 4048: search for <span class="emphasis"><em>PLIST_SUBST</em></span>). </p>
4049: <p> If you want to change other variables not listed above, you
4050: can add variables and their expansions to this variable in the
1.77 rillig 4051: 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 4052: <pre class="programlisting">
4053: PLIST_SUBST+= SOMEVAR="somevalue"
1.1 grant 4054: </pre>
1.75 rillig 4055: <p>This replaces all occurrences of “<span class="quote">${SOMEVAR}</span>”
4056: in the PLIST with “<span class="quote">somevalue</span>”. </p>
4057: </div>
4058: <div class="sect1" lang="en">
4059: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4060: <a name="manpage-compression"></a>11.5. Man page compression</h2></div></div></div>
1.75 rillig 4061: <p>Man pages should be installed in compressed form if
1.76 rillig 4062: <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
1.75 rillig 4063: and uncompressed otherwise. To handle this in the
1.76 rillig 4064: <code class="filename">PLIST</code> file, the suffix “<span class="quote">.gz</span>” is
1.75 rillig 4065: appended/removed automatically for man pages according to
4066: <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
4067: or not, see above for details. This modification of the
1.76 rillig 4068: <code class="filename">PLIST</code> file is done on a copy of it, not
4069: <code class="filename">PLIST</code> itself.</p>
1.75 rillig 4070: </div>
4071: <div class="sect1" lang="en">
4072: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4073: <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 4074: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
1.75 rillig 4075: in generating the binary package, set the variable
4076: <code class="varname">PLIST_SRC</code> to the names of that file(s).
4077: 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
4078: important.</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="platform-specific-plist"></a>11.7. Platform-specific and differing PLISTs</h2></div></div></div>
1.75 rillig 4083: <p>Some packages decide to install a different set of files based on
4084: the operating system being used. These differences can be
4085: automatically handled by using the following files:</p>
4086: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4087: <li><p><code class="filename">PLIST.common</code></p></li>
4088: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
4089: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
4090: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
4091: <li><p><code class="filename">PLIST.common_end</code></p></li>
1.75 rillig 4092: </ul></div>
4093: </div>
4094: <div class="sect1" lang="en">
4095: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4096: <a name="faq.common-dirs"></a>11.8. Sharing directories between packages</h2></div></div></div>
1.75 rillig 4097: <p> A “<span class="quote">shared directory</span>” is a directory where
4098: multiple (and unrelated) packages install files. These
4099: directories are problematic because you have to add special tricks
4100: in the PLIST to conditionally remove them, or have some
4101: centralized package handle them. </p>
4102: <p> Within pkgsrc, you'll find both approaches. If a directory
4103: is shared by a few unrelated packages, it's often not worth to add
4104: an extra package to remove it. Therefore, one simply does:
4105: </p>
4106: <pre class="programlisting">
4107: @unexec ${RMDIR} %D/path/to/shared/directory 2>/dev/null || ${TRUE}
1.1 grant 4108: </pre>
1.75 rillig 4109: <p> in the PLISTs of all affected packages, instead of the
4110: regular "@dirrm" line. </p>
4111: <p> However, if the directory is shared across many packages, two
4112: different solutions are available: </p>
4113: <div class="orderedlist"><ol type="1">
4114: <li><p> If the packages have a common dependency, the directory
4115: can be removed in that. For example, see
1.76 rillig 4116: <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 4117: removes the shared directory
1.76 rillig 4118: <code class="filename">share/omf</code>. </p></li>
1.75 rillig 4119: <li><p> If the packages using the directory are not related at
4120: all (they have no common dependencies), a *-dirs package is
4121: used. </p></li>
4122: </ol></div>
4123: <p> From now on, we'll discuss the second solution. To get an
4124: idea of the *-dirs packages available, issue: </p>
4125: <pre class="programlisting">
4126: <code class="prompt">%</code> cd .../pkgsrc
4127: <code class="prompt">%</code> ls -d */*-dirs
1.1 grant 4128: </pre>
1.75 rillig 4129: <p> Their use from other packages is very simple. The
4130: <code class="varname">USE_DIRS</code> variable takes a list of package names
4131: (without the “<span class="quote">-dirs</span>” part) together with the required
4132: version number (always pick the latest one when writing new
4133: packages). </p>
4134: <p> For example, if a package installs files under
1.76 rillig 4135: <code class="filename">share/applications</code>, it should have the
1.75 rillig 4136: following line in it:
4137: </p>
4138: <pre class="programlisting">
4139: USE_DIRS+= xdg-1.1
1.1 grant 4140: </pre>
1.75 rillig 4141: <p> After regenerating the PLIST using <span><strong class="command">make
4142: print-PLIST</strong></span>, you should get the right (commented out)
4143: lines. </p>
4144: <p> Note that even if your package is using
1.76 rillig 4145: <code class="filename">$X11BASE</code>, it must not depend on the
1.75 rillig 4146: *-x11-dirs packages. Just specify the name without that part and
1.76 rillig 4147: pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
1.75 rillig 4148: care of it. </p>
4149: </div>
4150: </div>
4151: <div class="chapter" lang="en">
4152: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4153: <a name="buildlink"></a>Chapter 12. Buildlink methodology</h2></div></div></div>
1.75 rillig 4154: <div class="toc">
4155: <p><b>Table of Contents</b></p>
4156: <dl>
1.77 rillig 4157: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
4158: <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 4159: <dd><dl>
1.77 rillig 4160: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
4161: <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 4162: </dl></dd>
1.77 rillig 4163: <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 4164: <dd><dl>
1.77 rillig 4165: <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>
4166: <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 4167: </dl></dd>
4168: </dl>
4169: </div>
4170: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
4171: are seen by a package's configure and build processes. This is implemented
4172: in a two step process:</p>
4173: <div class="orderedlist"><ol type="1">
4174: <li><p>Symlink headers and libraries for dependencies into
4175: <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
4176: of <code class="varname">WRKDIR</code>.</p></li>
4177: <li><p>Create wrapper scripts that are used in place of the normal compiler
4178: tools that translate <code class="option">-I${LOCALBASE}/include</code> and
4179: <code class="option">-L${LOCALBASE}/lib</code> into references to
4180: <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
4181: native compiler on some operating systems look like GCC, so that
4182: packages that expect GCC won't require modifications to build with
4183: those native compilers.</p></li>
4184: </ol></div>
4185: <p>This normalizes the environment in which a package is built so that the
4186: package may be built consistently despite what other software may be
4187: installed. Please note that the normal system header and library paths,
1.76 rillig 4188: e.g. <code class="filename">/usr/include</code>,
4189: <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
1.75 rillig 4190: designed to insulate the package build from non-system-supplied
4191: software. </p>
4192: <div class="sect1" lang="en">
4193: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4194: <a name="converting-to-buildlink3"></a>12.1. Converting packages to use buildlink3</h2></div></div></div>
1.75 rillig 4195: <p>The process of converting packages to use the buildlink3
4196: framework (“<span class="quote">bl3ifying</span>”) is fairly straightforward.
4197: The things to keep in mind are:</p>
4198: <div class="orderedlist"><ol type="1">
4199: <li><p> Ensure that the build always calls the wrapper scripts
4200: instead of the actual toolchain. Some packages are tricky,
4201: and the only way to know for sure is the check
1.76 rillig 4202: <code class="filename">${WRKDIR}/.work.log</code> to see if the
1.75 rillig 4203: wrappers are being invoked. </p></li>
4204: <li><p> Don't override <code class="varname">PREFIX</code> from within
4205: the package Makefile, e.g. Java VMs, standalone shells,
4206: etc., because the code to symlink files into
1.76 rillig 4207: <code class="filename">${BUILDLINK_DIR}</code> looks for files
1.75 rillig 4208: relative to “<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>”.
4209: </p></li>
4210: <li><p> Remember that <span class="emphasis"><em>only</em></span> the
1.76 rillig 4211: <code class="filename">buildlink3.mk</code> files that you list in a
1.75 rillig 4212: package's Makefile are added as dependencies for that package.
4213: </p></li>
4214: </ol></div>
4215: <p> If a dependency on a particular package is required for its libraries and
4216: headers, then we replace: </p>
4217: <pre class="programlisting">
4218: DEPENDS+= foo>=1.1.0:../../category/foo
1.1 grant 4219: </pre>
1.75 rillig 4220: <p>with</p>
4221: <pre class="programlisting">
4222: .include "../../category/foo/buildlink3.mk"
1.1 grant 4223: </pre>
1.75 rillig 4224: <p>The buildlink3.mk files usually define the required dependencies.
4225: If you need a newer version of the dependency when using buildlink3.mk
4226: files, then you can define it in your Makefile; for example:
4227: </p>
4228: <pre class="programlisting">
4229: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
4230: .include "../../category/foo/buildlink3.mk"
1.1 grant 4231: </pre>
1.76 rillig 4232: <p>There are several <code class="filename">buildlink3.mk</code>
4233: files in <code class="filename">pkgsrc/mk</code>
1.75 rillig 4234: that handle special package issues:</p>
4235: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4236: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
1.75 rillig 4237: the native or a pkgsrc Berkeley DB implementation based on
4238: the values of <code class="varname">BDB_ACCEPTED</code> and
4239: <code class="varname">BDB_DEFAULT</code>.</p></li>
1.76 rillig 4240: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
1.75 rillig 4241: comes with neither Curses nor NCurses, this will take care
1.76 rillig 4242: 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>
4243: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
1.75 rillig 4244: of <code class="varname">KRB5_ACCEPTED</code> to choose between
4245: adding a dependency on Heimdal or MIT-krb5 for packages that
4246: require a Kerberos 5 implementation.</p></li>
1.76 rillig 4247: <li><p><code class="filename">motif.buildlink3.mk</code> checks
1.75 rillig 4248: for a system-provided
1.76 rillig 4249: 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
4250: <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>
4251: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
1.75 rillig 4252: variables that may be used by packages that use the
4253: Open Sound System (OSS) API.</p></li>
1.76 rillig 4254: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
1.75 rillig 4255: either Postgres 7.3 or 7.4, whichever is found installed. See
4256: the file for more information. </p></li>
1.76 rillig 4257: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
1.75 rillig 4258: <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
1.76 rillig 4259: 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>
4260: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
1.75 rillig 4261: <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
4262: library.</p></li>
4263: </ul></div>
1.76 rillig 4264: <p>The comments in those <code class="filename">buildlink3.mk</code>
1.75 rillig 4265: files provide a more complete
4266: description of how to use them properly.</p>
4267: </div>
4268: <div class="sect1" lang="en">
4269: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4270: <a name="creating-buildlink3.mk"></a>12.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
1.76 rillig 4271: <p> A package's <code class="filename">buildlink3.mk</code> file is
1.75 rillig 4272: included by Makefiles to indicate the need to compile and link
4273: against header files and libraries provided by the package. A
1.76 rillig 4274: <code class="filename">buildlink3.mk</code> file should always provide
1.75 rillig 4275: enough information to add the correct type of dependency
4276: relationship and include any other
1.76 rillig 4277: <code class="filename">buildlink3.mk</code> files that it needs to find
1.75 rillig 4278: headers and libraries that it needs in turn.</p>
1.76 rillig 4279: <p> To generate an initial <code class="filename">buildlink3.mk</code>
4280: 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 4281: package is highly recommended. For most packages, the following
4282: command will generate a good starting point for
1.76 rillig 4283: <code class="filename">buildlink3.mk</code> files:</p>
1.75 rillig 4284: <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>
4285: <code class="prompt">%</code> createbuildlink >buildlink3.mk</code></strong></pre>
4286: <div class="sect2" lang="en">
4287: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4288: <a name="anatomy-of-bl3"></a>12.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
1.75 rillig 4289: <p>The following real-life example
1.76 rillig 4290: <code class="filename">buildlink3.mk</code> is taken
4291: from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
1.75 rillig 4292: <pre class="programlisting">
4293: # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
1.1 grant 4294:
1.75 rillig 4295: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
4296: TIFF_BUILDLINK3_MK:= ${TIFF_BUILDLINK3_MK}+
1.1 grant 4297:
1.75 rillig 4298: .if !empty(BUILDLINK_DEPTH:M+)
4299: BUILDLINK_DEPENDS+= tiff
4300: .endif
1.1 grant 4301:
1.75 rillig 4302: BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Ntiff}
4303: BUILDLINK_PACKAGES+= tiff
1.1 grant 4304:
1.75 rillig 4305: .if !empty(TIFF_BUILDLINK3_MK:M+)
4306: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
4307: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
4308: .endif # TIFF_BUILDLINK3_MK
1.1 grant 4309:
1.75 rillig 4310: .include "../../devel/zlib/buildlink3.mk"
4311: .include "../../graphics/jpeg/buildlink3.mk"
1.1 grant 4312:
1.75 rillig 4313: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
1.1 grant 4314: </pre>
1.75 rillig 4315: <p> The header and footer manipulate
4316: <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
1.76 rillig 4317: <code class="filename">buildlink3.mk</code> files and is used to track
1.75 rillig 4318: at what depth we are including
1.76 rillig 4319: <code class="filename">buildlink3.mk</code> files.</p>
1.75 rillig 4320: <p> The first section controls if the dependency on
4321: <em class="replaceable"><code>pkg</code></em> is added.
4322: <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
4323: packages for which dependencies are added by
4324: buildlink3.</p>
4325: <p> The second section advises pkgsrc that the
1.76 rillig 4326: <code class="filename">buildlink3.mk</code> file for
1.75 rillig 4327: <em class="replaceable"><code>pkg</code></em> has been included at some point.
4328: <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
1.76 rillig 4329: packages for which <code class="filename">buildlink3.mk</code> files
1.75 rillig 4330: have been included. It must <span class="emphasis"><em>always</em></span> be
1.76 rillig 4331: appended to within a <code class="filename">buildlink3.mk</code>
1.75 rillig 4332: file. </p>
4333: <p> The third section is protected from multiple inclusion
4334: and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
4335: added. Several important variables are set in the section:
4336: </p>
4337: <div class="itemizedlist"><ul type="disc">
4338: <li><p> <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4339: is the actual dependency recorded in the installed
4340: package; this should always be set using
4341: <span><strong class="command">+=</strong></span> to ensure that
4342: we're appending to any pre-existing list of values. This
4343: variable should be set to the first version of the
4344: package that had an API change.
4345: </p></li>
4346: <li><p> <code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
4347: is the location of the <em class="replaceable"><code>pkg</code></em>
4348: pkgsrc directory.</p></li>
4349: <li><p>
4350: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
4351: (not shown above) controls whether we use
4352: <code class="varname">BUILD_DEPENDS</code> or
4353: <code class="varname">DEPENDS</code> to add the dependency on
4354: <em class="replaceable"><code>pkg</code></em>.
4355: The build dependency is selected by setting
4356: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
4357: to “<span class="quote">build</span>”. By default, the
4358: full dependency is used.
4359: </p></li>
4360: <li><p>
4361: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
4362: and
4363: <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
4364: (not shown above) are lists of subdirectories of
1.76 rillig 4365: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4366: to add to the header and library search paths. These
4367: default to “<span class="quote">include</span>” and “<span class="quote">lib</span>”
4368: respectively. </p></li>
4369: <li><p>
4370: <code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
4371: (not shown above) is the list of preprocessor flags to add
4372: to <code class="varname">CPPFLAGS</code>, which are passed on to the
4373: configure and build phases. The “<span class="quote">-I</span>” option
4374: should be avoided and instead be handled using
4375: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
4376: above.</p></li>
4377: </ul></div>
4378: <p> The following variables are all optionally defined within
4379: this second section (protected against multiple inclusion) and
4380: control which package files are symlinked into
1.76 rillig 4381: <code class="filename">${BUILDLINK_DIR}</code> and how their names are
1.75 rillig 4382: transformed during the symlinking: </p>
4383: <div class="itemizedlist"><ul type="disc">
4384: <li><p>
4385: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
4386: (not shown above) is a shell glob pattern relative to
1.76 rillig 4387: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4388: to be symlinked into
1.76 rillig 4389: <code class="filename">${BUILDLINK_DIR}</code>,
4390: e.g. <code class="filename">include/*.h</code>. </p></li>
1.75 rillig 4391: <li><p>
4392: <code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
4393: (not shown above) is a shell pipeline that
4394: outputs to stdout a list of files relative to
1.76 rillig 4395: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
1.75 rillig 4396: The resulting files are to be symlinked
1.76 rillig 4397: into <code class="filename">${BUILDLINK_DIR}</code>. By default,
4398: this takes the <code class="filename">+CONTENTS</code> of a
1.75 rillig 4399: <em class="replaceable"><code>pkg</code></em> and filters it through
4400: <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.
4401: </p></li>
4402: <li><p>
4403: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
4404: (not shown above) is a filter command that filters
1.76 rillig 4405: <code class="filename">+CONTENTS</code> input into a list of files
1.75 rillig 4406: relative to
1.76 rillig 4407: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4408: on stdout. By default for overwrite packages,
4409: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.76 rillig 4410: outputs the contents of the <code class="filename">include</code>
4411: and <code class="filename">lib</code> directories in the package
4412: <code class="filename">+CONTENTS</code>, and for pkgviews packages,
1.75 rillig 4413: it outputs any libtool archives in
1.76 rillig 4414: <code class="filename">lib</code> directories.
1.75 rillig 4415: </p></li>
4416: <li><p>
4417: <code class="varname">BUILDLINK_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
4418: (not shown above) is a list of sed arguments used to
4419: transform the name of the source filename into a
4420: destination filename, e.g. <span><strong class="command">-e
4421: "s|/curses.h|/ncurses.h|g"</strong></span>.
4422: </p></li>
4423: </ul></div>
4424: <p> The last section includes any
1.76 rillig 4425: <code class="filename">buildlink3.mk</code> needed for
1.75 rillig 4426: <em class="replaceable"><code>pkg</code></em>'s library dependencies.
1.76 rillig 4427: Including these <code class="filename">buildlink3.mk</code> files
1.75 rillig 4428: means that the headers and libraries for these
4429: dependencies are also symlinked into
1.76 rillig 4430: <code class="filename">${BUILDLINK_DIR}</code>
1.75 rillig 4431: whenever the <em class="replaceable"><code>pkg</code></em>
1.76 rillig 4432: <code class="filename">buildlink3.mk</code>
1.75 rillig 4433: file is included.
4434: </p>
4435: </div>
4436: <div class="sect2" lang="en">
4437: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4438: <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 4439: <p>
4440: The situation that requires increasing the dependency listed in
4441: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4442: after a package update is when the API or interface to the
4443: header files change.</p>
4444: <p> In this case,
4445: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4446: should be adjusted to require at least the new package
4447: version. In some cases, the packages that depend on this new
4448: version may need their <code class="varname">PKGREVISION</code>s
1.76 rillig 4449: increased and, if they have <code class="filename">buildlink3.mk</code>
1.75 rillig 4450: files, their
4451: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4452: adjusted, too. This is needed so pkgsrc will require the
4453: correct package dependency and not settle for an older one
4454: when building the source.</p>
4455: <p>
4456: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4457: should be increased when the binary interface or sonames
4458: (major number of the library version) of any installed
4459: shared libraries change. This is needed so that binary
4460: packages made using it will require the correct package
4461: dependency and not settle for an older one which will not
4462: contain the necessary shared libraries. </p>
4463: <p>
1.78 rillig 4464: See <a href="#dependencies" title="17.1.6. Handling dependencies">Section 17.1.6, “Handling dependencies”</a> for
1.75 rillig 4465: more information about dependencies on other packages,
4466: including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
4467: <code class="varname">ABI_DEPENDS</code> definitions. </p>
4468: <p> Please take careful consideration before adjusting
4469: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4470: or
4471: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4472: as we don't want to cause unneeded package deletions and
4473: rebuilds. In many cases, new versions of packages work just
4474: fine with older dependencies.</p>
4475: <p>
4476: Also it is not needed to set
4477: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4478: when it is identical to
4479: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>. </p>
4480: </div>
4481: </div>
4482: <div class="sect1" lang="en">
4483: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4484: <a name="writing-builtin.mk"></a>12.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.75 rillig 4485: <p>
4486: Some packages in pkgsrc install headers and libraries that
4487: coincide with headers and libraries present in the base system.
1.76 rillig 4488: Aside from a <code class="filename">buildlink3.mk</code> file, these
4489: packages should also include a <code class="filename">builtin.mk</code>
1.75 rillig 4490: file that includes the necessary checks to decide whether using
4491: the built-in software or the pkgsrc software is
4492: appropriate. </p>
4493: <p> The only requirements of a builtin.mk file for
4494: <em class="replaceable"><code>pkg</code></em> are:
4495: </p>
4496: <div class="orderedlist"><ol type="1">
4497: <li><p> It should set
4498: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4499: to either “<span class="quote">yes</span>” or “<span class="quote">no</span>”
4500: after it is included.
4501: </p></li>
4502: <li><p> It should <span class="emphasis"><em>not</em></span> override any
4503: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4504: which is already set before the
1.76 rillig 4505: <code class="filename">builtin.mk</code> file is included.
1.75 rillig 4506: </p></li>
4507: <li><p> It should be written to allow multiple inclusion. This
4508: is <span class="emphasis"><em>very</em></span> important and takes careful
1.76 rillig 4509: attention to <code class="filename">Makefile</code> coding.
1.75 rillig 4510: </p></li>
4511: </ol></div>
4512: <div class="sect2" lang="en">
4513: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4514: <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 4515: <p>The following is the recommended template for builtin.mk
4516: files: </p>
4517: <pre class="programlisting">
4518: .if !defined(IS_BUILTIN.foo)
4519: #
4520: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
4521: # genuinely exists in the system or not.
4522: #
4523: IS_BUILTIN.foo?= no
1.1 grant 4524:
1.75 rillig 4525: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
4526: # version can be determined.
4527: #
4528: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
4529: BUILTIN_PKG.foo?= foo-1.0
4530: . endif
4531: .endif # IS_BUILTIN.foo
1.1 grant 4532:
1.75 rillig 4533: .if !defined(USE_BUILTIN.foo)
4534: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
4535: . if defined(BUILTIN_PKG.foo)
4536: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
4537: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
4538: USE_BUILTIN.foo!= \
4539: if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then \
4540: ${ECHO} "yes"; \
4541: else \
4542: ${ECHO} "no"; \
4543: fi
4544: . endif
4545: . endfor
4546: . endif
4547: .endif # USE_BUILTIN.foo
1.1 grant 4548:
1.75 rillig 4549: CHECK_BUILTIN.foo?= no
4550: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
4551: #
4552: # Here we place code that depends on whether USE_BUILTIN.foo is set to
4553: # "yes" or "no".
4554: #
4555: .endif # CHECK_BUILTIN.foo
1.1 grant 4556: </pre>
1.75 rillig 4557: <p> The first section sets
4558: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4559: depending on if <em class="replaceable"><code>pkg</code></em> really exists
4560: in the base system. This should not be a base system software
4561: with similar functionality to <em class="replaceable"><code>pkg</code></em>;
4562: it should only be “<span class="quote">yes</span>” if the actual package is
4563: included as part of the base system. This variable is only
1.76 rillig 4564: used internally within the <code class="filename">builtin.mk</code>
1.75 rillig 4565: file. </p>
4566: <p> The second section sets
4567: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
4568: to the version of <em class="replaceable"><code>pkg</code></em> in the base
4569: system if it exists (if
4570: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4571: is “<span class="quote">yes</span>”). This variable is only used internally
1.76 rillig 4572: within the <code class="filename">builtin.mk</code> file. </p>
1.75 rillig 4573: <p> The third section sets
4574: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4575: and is <span class="emphasis"><em>required</em></span> in all
1.76 rillig 4576: <code class="filename">builtin.mk</code> files. The code in this
1.75 rillig 4577: section must make the determination whether the built-in
4578: software is adequate to satisfy the dependencies listed in
4579: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
4580: This is typically done by comparing
4581: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
4582: against each of the dependencies in
4583: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
4584: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4585: <span class="emphasis"><em>must</em></span> be set to the correct value by the
1.76 rillig 4586: end of the <code class="filename">builtin.mk</code> file. Note that
1.75 rillig 4587: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4588: may be “<span class="quote">yes</span>” even if
4589: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4590: is “<span class="quote">no</span>” because we may make the determination
4591: that the built-in version of the software is similar enough to
4592: be used as a replacement. </p>
4593: <p> The last section is guarded by
4594: <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
4595: and includes code that uses the value of
4596: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4597: set in the previous section. This typically includes, e.g.,
4598: adding additional dependency restrictions and listing
4599: additional files to symlink into
1.76 rillig 4600: <code class="filename">${BUILDLINK_DIR}</code> (via
1.75 rillig 4601: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).
4602: </p>
4603: </div>
4604: <div class="sect2" lang="en">
4605: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4606: <a name="native-or-pkgsrc-preference"></a>12.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
1.75 rillig 4607: <p>
4608: When building packages, it's possible to choose whether to set
4609: a global preference for using either the built-in (native)
4610: version or the pkgsrc version of software to satisfy a
4611: dependency. This is controlled by setting
4612: <code class="varname">PREFER_PKGSRC</code> and
4613: <code class="varname">PREFER_NATIVE</code>. These variables take values
4614: of either “<span class="quote">yes</span>”, “<span class="quote">no</span>”, or a list of
4615: packages. <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
4616: use the pkgsrc versions of software, while
4617: <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
4618: built-in versions. Preferences are determined by the most
4619: specific instance of the package in either
4620: <code class="varname">PREFER_PKGSRC</code> or
4621: <code class="varname">PREFER_NATIVE</code>. If a package is specified
4622: in neither or in both variables, then
4623: <code class="varname">PREFER_PKGSRC</code> has precedence over
4624: <code class="varname">PREFER_NATIVE</code>. For example, to require
4625: using pkgsrc versions of software for all but the most basic
4626: bits on a NetBSD system, you can set: </p>
4627: <pre class="programlisting">
4628: PREFER_PKGSRC= yes
4629: PREFER_NATIVE= getopt skey tcp_wrappers
1.1 grant 4630: </pre>
1.75 rillig 4631: <p> A package <span class="emphasis"><em>must</em></span> have a
1.76 rillig 4632: <code class="filename">builtin.mk</code>
1.75 rillig 4633: file to be listed in <code class="varname">PREFER_NATIVE</code>,
4634: otherwise it is simply ignored in that list.
4635: </p>
4636: </div>
4637: </div>
4638: </div>
4639: <div class="chapter" lang="en">
4640: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4641: <a name="pkginstall"></a>Chapter 13. The pkginstall framework</h2></div></div></div>
1.75 rillig 4642: <div class="toc">
4643: <p><b>Table of Contents</b></p>
4644: <dl>
1.77 rillig 4645: <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 4646: <dd><dl>
1.77 rillig 4647: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
4648: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
1.75 rillig 4649: </dl></dd>
1.77 rillig 4650: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
1.75 rillig 4651: <dd><dl>
1.77 rillig 4652: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
4653: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
4654: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
4655: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
4656: </dl></dd>
4657: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
4658: <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>
4659: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
4660: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
4661: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
4662: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
4663: <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 4664: </dl>
4665: </div>
4666: <p>This chapter describes the framework known as
4667: <code class="literal">pkginstall</code>, whose key features are:</p>
4668: <div class="itemizedlist"><ul type="disc">
4669: <li><p>Generic installation and manipulation of directories and files
4670: outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
4671: <li><p>Automatic handling of configuration files during installation,
4672: provided that packages are correctly designed.</p></li>
4673: <li><p>Generation and installation of system startup scripts.</p></li>
4674: <li><p>Registration of system users and groups.</p></li>
4675: <li><p>Registration of system shells.</p></li>
4676: <li><p>Automatic updating of fonts databases.</p></li>
4677: </ul></div>
4678: <p>The following sections inspect each of the above points in detail.</p>
4679: <p>You may be thinking that many of the things described here could be
4680: easily done with simple code in the package's post-installation target
4681: (<code class="literal">post-install</code>). <span class="emphasis"><em>This is incorrect</em></span>,
4682: as the code in them is only executed when building from source. Machines
4683: using binary packages could not benefit from it at all (as the code itself
4684: could be unavailable). Therefore, the only way to achieve any of the items
4685: described above is by means of the installation scripts, which are
4686: automatically generated by pkginstall.</p>
4687: <div class="sect1" lang="en">
4688: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4689: <a name="files-and-dirs-outside-prefix"></a>13.1. Files and directories outside the installation prefix</h2></div></div></div>
1.76 rillig 4690: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
1.75 rillig 4691: of files and directories that belong to a package. The names used in it
1.76 rillig 4692: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
1.75 rillig 4693: which means that it cannot register files outside this directory (absolute
4694: path names are not allowed). Despite this restriction, some packages need
4695: to install files outside this location; e.g., under
1.76 rillig 4696: <code class="filename">${VARBASE}</code> or
4697: <code class="filename">${PKG_SYSCONFDIR}</code>.</p>
1.75 rillig 4698: <p>The only way to achieve this is to create such files during
4699: installation time by using the installation scripts. These scripts can run
4700: arbitrary commands, so they have the potential to create and manage files
4701: anywhere in the file system. Here is where pkginstall comes into play: it
4702: provides generic scripts to abstract the manipulation of such files and
4703: directories based on variables set in the package's
1.76 rillig 4704: <code class="filename">Makefile</code>. The rest of this section describes these
1.75 rillig 4705: variables.</p>
4706: <div class="sect2" lang="en">
4707: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4708: <a name="dirs-outside-prefix"></a>13.1.1. Directory manipulation</h3></div></div></div>
1.75 rillig 4709: <p>The following variables can be set to request the creation of
4710: directories anywhere in the file system:</p>
4711: <div class="itemizedlist"><ul type="disc">
4712: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
4713: contain a list of directories that should be created and should attempt
4714: to be destroyed by the installation scripts. The difference between
4715: the two is that the latter prompts the administrator to remove any
4716: directories that may be left after deinstallation (because they were
4717: not empty), while the former does not.</p></li>
4718: <li>
4719: <p><code class="varname">MAKE_DIRS_PERMS</code> and
4720: <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
4721: which directories should be created and should attempt to be destroyed
4722: by the installation scripts. Each tuple holds the following values,
4723: separated by spaces: the directory name, its owner, its group and its
4724: numerical mode. For example:</p>
4725: <pre class="programlisting">
4726: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 4727: </pre>
1.75 rillig 4728: <p>The difference between the two is exactly the same as their
4729: non-<code class="varname">PERMS</code> counterparts.</p>
4730: </li>
4731: </ul></div>
4732: </div>
4733: <div class="sect2" lang="en">
4734: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4735: <a name="files-outside-prefix"></a>13.1.2. File manipulation</h3></div></div></div>
1.75 rillig 4736: <p>Creating non-empty files outside the installation prefix is tricky
1.76 rillig 4737: because the <code class="filename">PLIST</code> forces all files to be inside it.
1.75 rillig 4738: To overcome this problem, the only solution is to extract the file in the
4739: known place (i.e., inside the installation prefix) and copy it to the
4740: appropriate location during installation (done by the installation scripts
4741: generated by pkginstall). We will call the former the <span class="emphasis"><em>master
4742: file</em></span> in the following paragraphs, which describe the variables
4743: that can be used to automatically and consistently handle files outside the
4744: installation prefix:</p>
4745: <div class="itemizedlist"><ul type="disc">
4746: <li>
4747: <p><code class="varname">CONF_FILES</code> and
4748: <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
4749: During installation time, the master file is copied to the target one
4750: if and only if the latter does not exist. Upon deinstallation, the
4751: target file is removed provided that it was not modified by the
4752: installation.</p>
4753: <p>The difference between the two is that the latter prompts the
4754: administrator to remove any files that may be left after
4755: deinstallation (because they were not empty), while the former does
4756: not.</p>
4757: </li>
4758: <li>
4759: <p><code class="varname">CONF_FILES_PERMS</code> and
4760: <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
4761: files as well as their target locations. For each of them, it also
4762: specifies their owner, their group and their numeric permissions, in
4763: this order. For example:</p>
4764: <pre class="programlisting">
4765: SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 4766: </pre>
1.75 rillig 4767: <p>The difference between the two is exactly the same as their
4768: non-<code class="varname">PERMS</code> counterparts.</p>
4769: </li>
4770: </ul></div>
4771: </div>
4772: </div>
4773: <div class="sect1" lang="en">
4774: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4775: <a name="conf-files"></a>13.2. Configuration files</h2></div></div></div>
1.75 rillig 4776: <p>Configuration files are special in the sense that they are installed
4777: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
4778: need special treatment during installation (most of which is automated by
4779: pkginstall). The main concept you must bear in mind is that files marked
4780: as configuration files are automatically copied to the right place (somewhere
4781: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
4782: and only if</em></span> they didn't exist before. Similarly, they will not
4783: be removed if they have local modifications. This ensures that
4784: administrators never lose any custom changes they may have made.</p>
4785: <div class="sect2" lang="en">
4786: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4787: <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 4788: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
4789: specifies where configuration files shall be installed. Its contents are
4790: set based upon the following variables:</p>
4791: <div class="itemizedlist"><ul type="disc">
4792: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
1.76 rillig 4793: directory. Defaults to <code class="filename">${PREFIX}/etc</code> although it may
1.75 rillig 4794: be overridden by the user to point to his preferred location (e.g.,
1.76 rillig 4795: <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
1.75 rillig 4796: Packages must not use it directly.</p></li>
4797: <li>
4798: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
4799: <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
4800: for the package being built shall be installed. The definition of this
4801: variable only makes sense in the package's
1.76 rillig 4802: <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
1.75 rillig 4803: <p>As an example, consider the Apache package,
1.76 rillig 4804: <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 4805: configuration files under the
1.76 rillig 4806: <code class="filename">httpd/</code> subdirectory of
1.75 rillig 4807: <code class="varname">PKG_SYSCONFBASE</code>. This should be set in the package
4808: Makefile.</p>
4809: </li>
4810: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
4811: variable that holds this package's configuration directory (if
4812: different from <code class="varname">PKG_SYSCONFBASE</code>). It defaults to
4813: <code class="varname">PKGBASE</code>'s value, and is always prefixed with
4814: <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
4815: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
4816: directory where the configuration files for the package identified by
4817: <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
4818: </ul></div>
4819: <p>Based on the above variables, pkginstall determines the value of
4820: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
4821: variable that can be used within a package to refer to its configuration
4822: directory. The algorithm used to set its value is basically the
4823: following:</p>
4824: <div class="orderedlist"><ol type="1">
4825: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
4826: its value is used.</p></li>
4827: <li><p>If the previous variable is not defined but
4828: <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
1.76 rillig 4829: <code class="filename">Makefile</code>, the resulting value is
4830: <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
1.75 rillig 4831: <li><p>Otherwise, it is set to
1.76 rillig 4832: <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
1.75 rillig 4833: </ol></div>
1.76 rillig 4834: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
1.77 rillig 4835: 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 4836: </div>
4837: <div class="sect2" lang="en">
4838: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4839: <a name="conf-files-configure"></a>13.2.2. Telling the software where configuration files are</h3></div></div></div>
1.75 rillig 4840: <p>Given that pkgsrc (and users!) expect configuration files to be in a
4841: known place, you need to teach each package where it shall install its
4842: files. In some cases you will have to patch the package Makefiles to
4843: achieve it. If you are lucky, though, it may be as easy as passing an
4844: extra flag to the configuration script; this is the case of GNU Autoconf-
4845: generated files:</p>
4846: <pre class="programlisting">
4847: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1 grant 4848: </pre>
1.75 rillig 4849: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
4850: for</em></span> its configuration files, not where they will be originally
4851: installed (although the difference is never explicit,
4852: unfortunately).</p>
4853: </div>
4854: <div class="sect2" lang="en">
4855: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4856: <a name="conf-files-patching"></a>13.2.3. Patching installations</h3></div></div></div>
1.75 rillig 4857: <p>As said before, pkginstall automatically handles configuration files.
4858: This means that <span class="strong"><strong>the packages themselves must not
1.76 rillig 4859: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
1.75 rillig 4860: directly</strong></span>. Bad news is that many software installation scripts
4861: will, out of the box, mess with the contents of that directory. So what is
4862: the correct procedure to fix this issue?</p>
4863: <p>You must teach the package (usually by manually patching it) to
4864: install any configuration files under the examples hierarchy,
1.76 rillig 4865: <code class="filename">share/examples/${PKGBASE}/</code>. This way, the
4866: <code class="filename">PLIST</code> registers them and the administrator always
1.75 rillig 4867: has the original copies available.</p>
4868: <p>Once the required configuration files are in place (i.e., under the
4869: examples hierarchy), the pkginstall framework can use them as master copies
4870: during the package installation to update what is in
1.76 rillig 4871: <code class="filename">${PKG_SYSCONFDIR}</code>. To achieve this, the variables
1.75 rillig 4872: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
1.77 rillig 4873: 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 4874: about their syntax and their purpose. Here is an example, taken from the
1.76 rillig 4875: <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 4876: <pre class="programlisting">
4877: EGDIR= ${PREFIX}/share/doc/mutt/samples
4878: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1 grant 4879: </pre>
1.75 rillig 4880: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
4881: package and has no meaning outside it.</p>
4882: </div>
4883: <div class="sect2" lang="en">
4884: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4885: <a name="conf-files-disable"></a>13.2.4. Disabling handling of configuration files</h3></div></div></div>
1.75 rillig 4886: <p>The automatic copying of config files can be toggled by setting the
4887: environment variable <code class="varname">PKG_CONFIG</code> prior to package
4888: installation.</p>
4889: </div>
4890: </div>
4891: <div class="sect1" lang="en">
4892: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4893: <a name="rcd-scripts"></a>13.3. System startup scripts</h2></div></div></div>
1.75 rillig 4894: <p>System startup scripts are special files because they must be
4895: installed in a place known by the underlying OS, usually outside the
1.77 rillig 4896: 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 4897: can be used. However, pkginstall provides a special mechanism to handle
4898: these files.</p>
4899: <p>In order to provide system startup scripts, the package has
4900: to:</p>
4901: <div class="orderedlist"><ol type="1">
1.76 rillig 4902: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
1.75 rillig 4903: the <code class="literal">.sh</code> suffix appended. Considering the
1.76 rillig 4904: <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
4905: <code class="filename">cupsd.sh</code> in its files directory.</p></li>
1.75 rillig 4906: <li>
4907: <p>Tell pkginstall to handle it, appending the name of the script,
4908: without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
4909: Continuing the previous example:</p>
4910: <pre class="programlisting">
4911: RCD_SCRIPTS+= cupsd
1.1 grant 4912: </pre>
1.75 rillig 4913: </li>
4914: </ol></div>
4915: <p>Once this is done, pkginstall will do the following steps for each
4916: script in an automated fashion:</p>
4917: <div class="orderedlist"><ol type="1">
4918: <li><p>Process the file found in the files directory applying all the
1.76 rillig 4919: substitutions described in the <code class="filename">FILES_SUBST</code>
1.75 rillig 4920: variable.</p></li>
4921: <li><p>Copy the script from the files directory to the examples
1.76 rillig 4922: hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>. Note
1.75 rillig 4923: that this master file must be explicitly registered in the
1.76 rillig 4924: <code class="filename">PLIST</code>.</p></li>
1.75 rillig 4925: <li><p>Add code to the installation scripts to copy the startup script
4926: from the examples hierarchy into the system-wide startup scripts
4927: directory.</p></li>
4928: </ol></div>
4929: <div class="sect2" lang="en">
4930: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4931: <a name="rcd-scripts-disable"></a>13.3.1. Disabling handling of system startup scripts</h3></div></div></div>
1.75 rillig 4932: <p>The automatic copying of config files can be toggled by setting the
4933: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
4934: installation. Note that the scripts will be always copied inside the
1.76 rillig 4935: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
1.75 rillig 4936: matter what the value of this variable is.</p>
4937: </div>
4938: </div>
4939: <div class="sect1" lang="en">
4940: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4941: <a name="users-and-groups"></a>13.4. System users and groups</h2></div></div></div>
1.75 rillig 4942: <p>If a package needs to create special users and/or groups during
4943: installation, it can do so by using the pkginstall framework.</p>
4944: <p>Users can be created by adding entries to the
4945: <code class="varname">PKG_USERS</code> variable. Each entry has the following
4946: syntax:</p>
4947: <pre class="programlisting">
4948: user:group
1.1 grant 4949: </pre>
1.75 rillig 4950: <p>Further specification of user details may be done by setting per-user
4951: variables.
4952: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the numeric
4953: UID for the user.
4954: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the user's
4955: description or comment.
4956: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the user's
1.76 rillig 4957: home directory, and defaults to <code class="filename">/nonexistent</code> if not
1.75 rillig 4958: specified.
4959: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the user's
1.76 rillig 4960: shell, and defaults to <code class="filename">/sbinno/login</code> if not specified.
1.75 rillig 4961: </p>
4962: <p>Similarly, groups can be created by adding entries to the
4963: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
4964: <pre class="programlisting">
4965: group
1.1 grant 4966: </pre>
1.75 rillig 4967: <p>The numeric GID of the group may be set by defining
4968: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
4969: <p>If a package needs to create the users and groups at an earlier
4970: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
4971: either <code class="literal">configure</code> or <code class="literal">build</code> to
4972: indicate the phase before which the users and groups are created. In
4973: this case, the numeric UIDs and GIDs of the created users and groups
4974: are automatically hardcoded into the final installation scripts.</p>
4975: </div>
4976: <div class="sect1" lang="en">
4977: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4978: <a name="shells"></a>13.5. System shells</h2></div></div></div>
1.75 rillig 4979: <p>Packages that install system shells should register them in the shell
1.76 rillig 4980: database, <code class="filename">/etc/shells</code>, to make things easier to the
1.75 rillig 4981: administrator. This must be done from the installation scripts to keep
4982: binary packages working on any system. pkginstall provides an easy way to
4983: accomplish this task.</p>
4984: <p>When a package provides a shell interpreter, it has to set the
4985: <code class="varname">PKG_SHELL</code> variable to its absolute file name. This will
4986: add some hooks to the installation scripts to handle it. Consider the
1.76 rillig 4987: 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 4988: <pre class="programlisting">
4989: PKG_SHELL= ${PREFIX}/bin/zsh
1.1 grant 4990: </pre>
1.75 rillig 4991: <div class="sect2" lang="en">
4992: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4993: <a name="shells-disable"></a>13.5.1. Disabling shell registration</h3></div></div></div>
1.75 rillig 4994: <p>The automatic registration of shell interpreters can be disabled by
1.76 rillig 4995: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
1.75 rillig 4996: environment variable to <code class="literal">NO</code>.</p>
4997: </div>
4998: </div>
4999: <div class="sect1" lang="en">
5000: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5001: <a name="fonts"></a>13.6. Fonts</h2></div></div></div>
1.75 rillig 5002: <p>Packages that install X11 fonts should update the database files
5003: that index the fonts within each fonts directory. This can easily be
5004: accomplished within the pkginstall framework.</p>
5005: <p>When a package installs X11 fonts, it must list the directories in
5006: which fonts are installed in the
5007: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
5008: where <em class="replaceable"><code>type</code></em> can be one of “<span class="quote">ttf</span>”,
5009: “<span class="quote">type1</span>” or “<span class="quote">x11</span>”. This will add hooks to the
5010: installation scripts to run the appropriate commands to update the fonts
5011: database files within each of those directories. For convenience, if the
5012: directory path is relative, it is taken to be relative to the package's
1.76 rillig 5013: 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 5014: <pre class="programlisting">
5015: FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
1.1 grant 5016: </pre>
1.75 rillig 5017: <div class="sect2" lang="en">
5018: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5019: <a name="fonts-disable"></a>13.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
1.75 rillig 5020: <p>The automatic update of fonts databases can be disabled by
1.76 rillig 5021: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
1.75 rillig 5022: environment variable to <code class="literal">NO</code>.</p>
5023: </div>
5024: </div>
5025: </div>
5026: <div class="chapter" lang="en">
5027: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5028: <a name="options"></a>Chapter 14. Options handling</h2></div></div></div>
1.75 rillig 5029: <div class="toc">
5030: <p><b>Table of Contents</b></p>
5031: <dl>
1.77 rillig 5032: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
5033: <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>
5034: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
1.75 rillig 5035: </dl>
5036: </div>
5037: <p>Many packages have the ability to be built to support different
1.76 rillig 5038: sets of features. <code class="filename">bsd.options.mk</code> is a framework
1.75 rillig 5039: in pkgsrc that provides generic handling of those options that
5040: determine different ways in which the packages can be built. It's
5041: possible for the user to specify exactly which sets of options will be
5042: built into a package or to allow a set of global default options
5043: apply.</p>
5044: <div class="sect1" lang="en">
5045: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5046: <a name="global-default-options"></a>14.1. Global default options</h2></div></div></div>
1.75 rillig 5047: <p>Global default options are listed in
5048: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
5049: that should be built into every package if that option is supported.
1.76 rillig 5050: This variable should be set in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 5051: </div>
5052: <div class="sect1" lang="en">
5053: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5054: <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 5055: <p>The following example shows how
1.76 rillig 5056: <code class="filename">bsd.options.mk</code> should be used
1.75 rillig 5057: by the hypothetical ``wibble'' package, either in the package
1.76 rillig 5058: <code class="filename">Makefile</code>, or in a file,
5059: e.g. <code class="filename">options.mk</code>, that is included by the
5060: main package <code class="filename">Makefile</code>.</p>
1.75 rillig 5061: <pre class="programlisting">
5062: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
5063: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
5064: PKG_OPTIONS_OPTIONAL_GROUPS= database
5065: PKG_OPTIONS_GROUP.database= mysql pgsql
5066: PKG_SUGGESTED_OPTIONS= wibble-foo
5067: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
5068: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
1.1 grant 5069:
1.75 rillig 5070: .include "../../mk/bsd.prefs.mk"
1.69 rillig 5071:
1.75 rillig 5072: # this package was previously named wibble2
5073: .if defined(PKG_OPTIONS.wibble2)
5074: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
5075: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
1.78 rillig 5076: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
1.75 rillig 5077: .endif
1.69 rillig 5078:
1.75 rillig 5079: .include "../../mk/bsd.options.mk"
1.69 rillig 5080:
1.75 rillig 5081: # Package-specific option-handling
1.69 rillig 5082:
1.75 rillig 5083: ###
5084: ### FOO support
5085: ###
5086: .if !empty(PKG_OPTIONS:Mwibble-foo)
5087: CONFIGURE_ARGS+= --enable-foo
5088: .endif
1.69 rillig 5089:
1.75 rillig 5090: ###
5091: ### LDAP support
5092: ###
5093: .if !empty(PKG_OPTIONS:Mldap)
1.77 rillig 5094: . include "../../databases/openldap-client/buildlink3.mk"
5095: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
1.75 rillig 5096: .endif
1.69 rillig 5097:
1.75 rillig 5098: ###
5099: ### database support
5100: ###
5101: .if !empty(PKG_OPTIONS:Mmysql)
5102: . include "../../mk/mysql.buildlink3.mk"
5103: .endif
5104: .if !empty(PKG_OPTIONS:Mpgsql)
5105: . include "../../mk/pgsql.buildlink3.mk"
5106: .endif
5107: </pre>
5108: <p>The first section contains the information about which build
5109: options are supported by the package, and any default options settings
5110: if needed.</p>
5111: <div class="orderedlist"><ol type="1">
5112: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
5113: <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
5114: options. It should be set to
1.78 rillig 5115: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
5116: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is not defined
5117: at the point where the options are processed.</p></li>
1.75 rillig 5118: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
5119: build options supported by the package.</p></li>
5120: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
5121: list of names of groups of mutually exclusive options. The options in
5122: each group are listed in
5123: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
5124: The most specific setting of any option from the group takes
5125: precedence over all other options in the group. Options from the
5126: groups will be automatically added to
5127: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
5128: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
5129: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
5130: packages will fail if no option from the group is
5131: selected.</p></li>
5132: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
5133: of names of sets of options. At least one option from each set must
5134: be selected. The options in each set are listed in
5135: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
5136: Options from the sets will be automatically added to
5137: <code class="varname">PKG_SUPPORTED_OPTIONS</code>. Building the package will
5138: fail if no option from the set is selected.</p></li>
5139: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
5140: build options which are enabled by default.</p></li>
5141: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
5142: of
5143: “<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>”
1.76 rillig 5144: pairs that map legacy <code class="filename">/etc/mk.conf</code> variables to
1.75 rillig 5145: their option counterparts. Pairs should be added with
5146: “<span class="quote">+=</span>” to keep the listing of global legacy variables. A
5147: warning will be issued if the user uses a legacy
5148: variable.</p></li>
5149: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
5150: of
5151: “<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>”
5152: pairs that map options that have been renamed to their new
5153: counterparts. Pairs should be added with “<span class="quote">+=</span>” to keep
5154: the listing of global legacy options. A warning will be issued if
5155: the user uses a legacy option.</p></li>
5156: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
5157: options implied by deprecated variables used. This can be used for
5158: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
5159: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
5160: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
5161: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
5162: a list of warnings about deprecated variables or options used, and
5163: what to use instead.</p></li>
5164: </ol></div>
5165: <p>A package should never modify
5166: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
5167: <code class="varname">PKG_OPTIONS_VAR</code>. These are strictly user-settable.
5168: To suggest a default set of options, use
5169: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
5170: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
1.76 rillig 5171: including <code class="filename">bsd.options.mk</code>. If none of
1.75 rillig 5172: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
5173: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
5174: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
5175: happen with platform-specific options if none of them is supported on
5176: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
5177: empty list and the package is otherwise treated as not using the
5178: options framework.</p>
1.76 rillig 5179: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
1.75 rillig 5180: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
5181: build options, properly filtered to remove unsupported and duplicate
5182: options.</p>
5183: <p>The remaining sections contain the logic that is specific to
5184: each option. The correct way to check for an option is to check
5185: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
5186: <pre class="programlisting">
5187: .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
5188: </pre>
5189: </div>
5190: <div class="sect1" lang="en">
5191: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5192: <a name="option-names"></a>14.3. Option Names</h2></div></div></div>
1.75 rillig 5193: <p>Options that enable similar features in different packages (like
5194: optional support for a library) should use a common name in all
5195: packages that support it (like the name of the library). If another
5196: package already has an option with the same meaning, use the same
5197: name.</p>
5198: <p>Options that enable features specific to one package, where it's
5199: unlikely that another (unrelated) package has the same (or a similar)
5200: optional feature, should use a name prefixed with
5201: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
5202: <p>If a group of related packages share an optional feature
5203: specific to that group, prefix it with the name of the
5204: “<span class="quote">main</span>” package
5205: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
5206: <p>For new options, add a line to
1.76 rillig 5207: <code class="filename">mk/defaults/options.description</code>. Lines have two
1.75 rillig 5208: fields, separated by tab. The first field is the option name, the
5209: second its description. The description should be a whole sentence
5210: (starting with an uppercase letter and ending with a period) that
5211: describes what enabling the option does. E. g. “<span class="quote">Enable ispell
5212: support.</span>” The file is sorted by option names.</p>
5213: </div>
5214: </div>
5215: <div class="chapter" lang="en">
5216: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5217: <a name="build"></a>Chapter 15. The build process</h2></div></div></div>
1.75 rillig 5218: <div class="toc">
5219: <p><b>Table of Contents</b></p>
5220: <dl>
1.77 rillig 5221: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
5222: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
5223: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
5224: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
5225: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
5226: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
5227: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
5228: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
5229: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
5230: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
5231: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
5232: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
5233: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
5234: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
5235: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
5236: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
1.75 rillig 5237: </dl>
5238: </div>
5239: <div class="sect1" lang="en">
5240: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5241: <a name="build.intro"></a>15.1. Introduction</h2></div></div></div>
1.75 rillig 5242: <p>This chapter gives a detailed description on how a package is
5243: built. Building a package is separated into different
5244: <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
5245: <code class="varname">build</code>, <code class="varname">install</code>), all of which are
5246: described in the following sections. Each phase is splitted into
5247: so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
5248: containing phase, prefixed by one of <code class="varname">pre-</code>,
5249: <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
5250: <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
5251: of the actual work is done in the <code class="varname">do-*</code> stages.</p>
5252: <p>The basic steps for building a program are always the same. First
5253: the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
5254: the local system and then extracted. After any pkgsrc-specific patches
5255: to compile properly are applied, the software can be configured, then
5256: built (usually by compiling), and finally the generated binaries, etc.
5257: can be put into place on the system.</p>
5258: </div>
5259: <div class="sect1" lang="en">
5260: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5261: <a name="build.prefix"></a>15.2. Program location</h2></div></div></div>
1.75 rillig 5262: <p>Before outlining the process performed by the NetBSD package system in
5263: the next section, here's a brief discussion on where programs are
5264: installed, and which variables influence this.</p>
5265: <p>The automatic variable <code class="varname">PREFIX</code> indicates
5266: where all files of the final program shall be installed. It is
5267: usually set to <code class="varname">LOCALBASE</code>
1.76 rillig 5268: (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
1.75 rillig 5269: for pkgs in the “<span class="quote">cross</span>” category. The value of
5270: <code class="varname">PREFIX</code> needs to be put
5271: into the various places in the program's source where paths to
1.77 rillig 5272: 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 5273: <p>When choosing which of these variables to use,
5274: follow the following rules:</p>
5275: <div class="itemizedlist"><ul type="disc">
5276: <li><p><code class="varname">PREFIX</code> always points to the location where the current
5277: pkg will be installed. When referring to a pkg's own installation path,
5278: use “<span class="quote">${PREFIX}</span>”.</p></li>
5279: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs are installed.
5280: If you need to construct a -I or -L argument to the compiler to find
5281: includes and libraries installed by another non-X11 pkg, use
1.78 rillig 5282: “<span class="quote">${LOCALBASE}</span>”. The name
5283: <code class="varname">LOCALBASE</code> stems from FreeBSD, which
5284: installed all packages in <code class="filename">/usr/local</code>. As
5285: pkgsrc leaves <code class="filename">/usr/local</code> for the system
5286: administrator, this variable is a misnomer.</p></li>
1.75 rillig 5287: <li><p><code class="varname">X11BASE</code> is where the actual X11 distribution (from
5288: xsrc, etc.) is installed. When looking for
5289: <span class="emphasis"><em>standard</em></span> X11 includes (not
5290: those installed by a pkg), use “<span class="quote">${X11BASE}</span>”.</p></li>
5291: <li>
5292: <p>X11-based packages are special in that they may be installed in
5293: either <code class="varname">X11BASE</code> or <code class="varname">LOCALBASE</code>.</p>
5294: <p>Usually, X11 packages should be installed under
5295: <code class="varname">LOCALBASE</code> whenever possible. Note that you will
1.76 rillig 5296: need to include <code class="filename">../../mk/x11.buildlink3.mk</code>
1.75 rillig 5297: in them to request the
5298: presence of X11 and to get the right compilation flags.</p>
5299: <p>Even though, there are some packages that cannot be installed
5300: under <code class="varname">LOCALBASE</code>: those that come with app-defaults
5301: files. These packages are special and they must be placed under
5302: <code class="varname">X11BASE</code>. To accomplish this, set either
5303: <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
5304: your package.</p>
5305: <p>Some notes: If you need
5306: to find includes or libraries installed by a pkg that has
5307: <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
1.76 rillig 5308: its pkg <code class="filename">Makefile</code>, you need to look in
5309: <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
5310: <code class="filename">${LOCALBASE}</code>. To force installation of
1.75 rillig 5311: all X11 packages in <code class="varname">LOCALBASE</code>, the
1.76 rillig 5312: <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 5313: is enabled by default.</p>
5314: </li>
5315: <li><p><code class="varname">X11PREFIX</code> should be used to refer to the installed
5316: location of an X11 package. <code class="varname">X11PREFIX</code> will be set to
5317: <code class="varname">X11BASE</code> if xpkgwedge is not installed,
5318: and to <code class="varname">LOCALBASE</code> if xpkgwedge is installed.</p></li>
5319: <li>
5320: <p>If xpkgwedge is installed, it is possible to have some packages installed
5321: in <code class="varname">X11BASE</code> and some in <code class="varname">LOCALBASE</code>.
5322: To determine the prefix of an installed package, the
5323: <code class="varname">EVAL_PREFIX</code> definition can be used. It takes pairs in the
5324: 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
5325: <code class="varname">DIRNAME</code> will be set to the prefix of the installed
5326: package <package>, or “<span class="quote">${X11PREFIX}</span>” if the package is
5327: not installed.</p>
5328: <p>This is best illustrated by example.</p>
5329: <p>The following lines are taken from
1.76 rillig 5330: <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
1.75 rillig 5331: <pre class="programlisting">
5332: EVAL_PREFIX+= GTKDIR=gtk+
5333: CONFIGURE_ARGS+= --with-guile-prefix=${LOCALBASE:Q}
5334: CONFIGURE_ARGS+= --with-gtk-prefix=${GTKDIR:Q}
5335: CONFIGURE_ARGS+= --enable-multibyte
5336: </pre>
5337: <p>Specific defaults can be defined for the packages evaluated using
5338: <code class="varname">EVAL_PREFIX</code>, by using a definition of the form:</p>
5339: <pre class="programlisting">
5340: GTKDIR_DEFAULT= ${LOCALBASE}
5341: </pre>
5342: <p>where <code class="varname">GTKDIR</code> corresponds
5343: to the first definition in
5344: the <code class="varname">EVAL_PREFIX</code> pair.</p>
5345: </li>
1.76 rillig 5346: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.75 rillig 5347: 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 5348: manual pages go into <code class="filename">${PREFIX}/man</code>, not
5349: <code class="filename">${PREFIX}/share/man</code>.</p></li>
1.75 rillig 5350: </ul></div>
5351: </div>
5352: <div class="sect1" lang="en">
5353: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5354: <a name="build.builddirs"></a>15.3. Directories used during the build process</h2></div></div></div>
1.75 rillig 5355: <p>When building a package, a number of directories is used to store
5356: source files, temporary files, pkgsrc-internal files, and so on. These
5357: directories are explained here.</p>
5358: <p>Some of the directory variables contain relative pathnames. There
5359: are two common base directories for these relative directories:
5360: <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
5361: pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
5362: inside the package itself.</p>
5363: <div class="variablelist"><dl>
5364: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
5365: <dd><p>This is an absolute pathname that points to the pkgsrc
5366: root directory. Generally, you don't need
5367: it.</p></dd>
5368: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
5369: <dd><p>This is a pathname relative to
5370: <code class="varname">PKGSRCDIR</code> that points to the current
5371: package.</p></dd>
5372: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
5373: <dd><p>This is an absolute pathname pointing to the directory
5374: where all work takes place. The distfiles are extraced to this
5375: directory. It also contains temporary directories and log files used by
5376: the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
5377: the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
5378: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
5379: <dd><p>This is an absolute pathname pointing to the directory
5380: where the distfiles are extracted. It is usually a direct subdirectory
5381: of <code class="varname">WRKDIR</code>, and often it's the only directory entry
5382: that isn't hidden. This variable may be changed by a package
1.76 rillig 5383: <code class="filename">Makefile</code>.</p></dd>
1.75 rillig 5384: </dl></div>
5385: </div>
5386: <div class="sect1" lang="en">
5387: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5388: <a name="build.running"></a>15.4. Running a phase</h2></div></div></div>
1.75 rillig 5389: <p>You can run a particular phase by typing <span><strong class="command">make
5390: phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
5391: phase. This will automatically run all phases that are required for this
5392: phase. The default phase is <code class="varname">build</code>, that is, when you
5393: run <span><strong class="command">make</strong></span> without parameters in a package directory,
5394: the package will be built, but not installed.</p>
5395: </div>
5396: <div class="sect1" lang="en">
5397: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5398: <a name="build.fetch"></a>15.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.75 rillig 5399: <p>This will check if the file(s) given in the variables
5400: <code class="varname">DISTFILES</code> and <code class="varname">PATCHFILES</code> (as
5401: defined in the package's Makefile) are present on the
1.76 rillig 5402: local system in <code class="filename">/usr/pkgsrc/distfiles</code>. If they
1.75 rillig 5403: are not present, an attempt will be made to fetch them using commands
5404: of the form:</p>
5405: <pre class="programlisting">
5406: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
5407: </pre>
5408: <p>where ${site} varies through several possibilities in turn: first,
5409: <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the sites
5410: specified in either <code class="varname">SITES.file</code> if defined, else
5411: <code class="varname">MASTER_SITES</code> or <code class="varname">PATCH_SITES</code>, as
5412: applies, then finally the value of
5413: <code class="varname">MASTER_SITE_BACKUP</code>. The order of all except the
5414: first can be optionally sorted by the user, via setting either
5415: <code class="varname">MASTER_SORT_AWK</code> or
5416: <code class="varname">MASTER_SORT_REGEX</code>.</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.checksum"></a>15.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
1.75 rillig 5421: <p>After the distfile(s) are fetched, their checksum is generated and
5422: compared with the checksums stored in the distinfo file. If the
5423: checksums don't match, the build is aborted. This is to ensure the same
5424: distfile is used for building, and that the distfile wasn't changed,
5425: e.g. by some malign force, deliberately changed distfiles on the master
5426: distribution site or network lossage.</p>
5427: </div>
5428: <div class="sect1" lang="en">
5429: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5430: <a name="build.extract"></a>15.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
1.75 rillig 5431: <p>When the distfiles are present on the local system, they
5432: need to be extracted, as they usually come in the form of some
5433: compressed archive format.</p>
5434: <p>By default, all <code class="varname">DISTFILES</code> are
5435: extracted. If you only need some of them, you can set the
5436: <code class="varname">EXTRACT_ONLY</code> variable to the list of those
5437: files.</p>
5438: <p>Extracting the files is usually done by a little program,
1.76 rillig 5439: <code class="filename">mk/scripts/extract</code>, which already knows how
1.75 rillig 5440: to extract various archive formats, so most likely you will not
5441: need to change anything here. But if you need, the following
5442: variables may help you:</p>
5443: <div class="variablelist"><dl>
5444: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
5445: <dd><p>Use these variables to override the default
5446: options for an extract command, which are defined in
1.76 rillig 5447: <code class="filename">mk/scripts/extract</code>.</p></dd>
1.75 rillig 5448: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
5449: <dd><p>This variable can be set to
5450: <code class="literal">pax</code>, <code class="literal">tar</code> or an absolute
5451: pathname pointing to the command with which tar archives should
5452: be extracted.</p></dd>
5453: </dl></div>
1.76 rillig 5454: <p>If the <code class="filename">extract</code> program doesn't serve
1.75 rillig 5455: your needs, you can also override the
5456: <code class="varname">EXTRACT_CMD</code> variable, which holds the command
5457: used for extracting the files. This command is executed in the
1.76 rillig 5458: <code class="filename">${WRKSRC}</code> directory. During execution of
1.75 rillig 5459: this command, the shell variable <code class="varname">extract_file</code>
5460: holds the absolute pathname of the file that is going to be
5461: extracted.</p>
5462: <p>And if that still does not suffice, you can override the
5463: <code class="varname">do-extract</code> target in the package
5464: Makefile.</p>
5465: </div>
5466: <div class="sect1" lang="en">
5467: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5468: <a name="build.patch"></a>15.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
1.75 rillig 5469: <p>After extraction, all the patches named by the
5470: <code class="varname">PATCHFILES</code>, those present in the patches
5471: subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
1.76 rillig 5472: <code class="filename">/usr/local/patches/graphics/png</code>) are applied.
5473: Patchfiles ending in <code class="filename">.Z</code> or
5474: <code class="filename">.gz</code> are uncompressed before they are applied,
5475: files ending in <code class="filename">.orig</code> or
5476: <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 5477: can be handed in <code class="varname">PATCH_DIST_ARGS</code>.
1.77 rillig 5478: See <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a> for more details.</p>
1.75 rillig 5479: <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
5480: patches apply with some lines of fuzz. Please fix (regen) the patches
5481: so that they apply cleanly. The rationale behind this is that
5482: patches that don't apply cleanly may end up being applied in the wrong
5483: place, and cause severe harm there.</p>
5484: </div>
5485: <div class="sect1" lang="en">
5486: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5487: <a name="build.tools"></a>15.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
1.75 rillig 5488: <p>This is covered in
1.77 rillig 5489: <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 5490: </p>
5491: </div>
5492: <div class="sect1" lang="en">
5493: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5494: <a name="build.wrapper"></a>15.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
1.75 rillig 5495: <p>This phase creates wrapper programs for the compilers and
5496: linkers. The following variables can be used to tweak the
5497: wrappers.</p>
5498: <div class="variablelist"><dl>
5499: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
5500: <dd><p>The command used to print progress
5501: messages. Does nothing by default. Set to
5502: <code class="literal">${ECHO}</code> to see the progress
5503: messages.</p></dd>
5504: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
5505: <dd><p>This variable can be set to
5506: <code class="literal">yes</code> (default) or
5507: <code class="literal">no</code>, depending on whether you want
5508: additional information in the wrapper log
5509: file.</p></dd>
5510: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
5511: <dd><p>This variable can be set to
5512: <code class="literal">yes</code> or <code class="literal">no</code>,
5513: depending on whether the wrapper should use its cache,
5514: which will improve the speed. The default value is
5515: <code class="literal">yes</code>, but is forced to
5516: <code class="literal">no</code> if the platform does not support
5517: it.</p></dd>
5518: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
5519: <dd><p>A list of reordering commands. A
5520: reordering command has the form
5521: <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
5522: It ensures that that
5523: <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code>
5524: occurs before
5525: <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
5526: </p></dd>
5527: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
5528: <dd><p>A list of transformation commands. [TODO:
5529: investigate further]</p></dd>
5530: </dl></div>
5531: </div>
5532: <div class="sect1" lang="en">
5533: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5534: <a name="build.configure"></a>15.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.75 rillig 5535: <p>Most pieces of software need information on the header files,
5536: system calls, and library routines which are available on the platform
5537: they run on. The process of determining this information is known as
5538: configuration, and is usually automated. In most cases, a script is
5539: supplied with the distfiles, and its invocation results in generation of
5540: header files, Makefiles, etc.</p>
5541: <p>If the package contains a configure script, this can be invoked by
5542: setting <code class="varname">HAS_CONFIGURE</code> to “<span class="quote">yes</span>”. If the
5543: configure script is a GNU autoconf script, you should set
5544: <code class="varname">GNU_CONFIGURE</code> to “<span class="quote">yes</span>” instead. What
5545: happens in the <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
5546: <pre class="programlisting">
5547: .for d in ${CONFIGURE_DIRS}
5548: cd ${WRKSRC} && cd ${d} && env ${CONFIGURE_ENV} \
5549: ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
5550: .endfor
5551: </pre>
5552: <p><code class="varname">CONFIGURE_DIRS</code> (default: “<span class="quote">.</span>”) is a
5553: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
5554: these directories, the configure script is run with the environment
5555: <code class="varname">CONFIGURE_ENV</code> and arguments
5556: <code class="varname">CONFIGURE_ARGS</code>. The variables
5557: <code class="varname">CONFIGURE_ENV</code>, <code class="varname">CONFIGURE_SCRIPT</code>
5558: (default: “<span class="quote">./configure</span>”) and
5559: <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
5560: package.</p>
1.76 rillig 5561: <p>If the program uses an <code class="filename">Imakefile</code> for
1.75 rillig 5562: configuration, the appropriate steps can be invoked by setting
5563: <code class="varname">USE_IMAKE</code> to “<span class="quote">yes</span>”. (If you only want
5564: the package installed in <code class="varname">${X11PREFIX}</code> but xmkmf not
5565: being run, set <code class="varname">USE_X11BASE</code> instead.)</p>
5566: </div>
5567: <div class="sect1" lang="en">
5568: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5569: <a name="build.build"></a>15.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.75 rillig 5570: <p>For building a package, a rough equivalent of the following code
5571: is executed.</p>
5572: <pre class="programlisting">
5573: .for d in ${BUILD_DIRS}
5574: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
5575: ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
5576: -f ${MAKEFILE} ${BUILD_TARGET}
5577: .endfor
5578: </pre>
5579: <p><code class="varname">BUILD_DIRS</code> (default: “<span class="quote">.</span>”) is a
5580: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
5581: these directories, <code class="varname">MAKE_PROGRAM</code> is run with the
5582: environment <code class="varname">MAKE_ENV</code> and arguments
5583: <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
5584: <code class="varname">MAKE_ENV</code>, <code class="varname">BUILD_MAKE_FLAGS</code>,
5585: <code class="varname">MAKEFILE</code> and <code class="varname">BUILD_TARGET</code> may all
5586: be changed by the package.</p>
5587: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
5588: “<span class="quote">gmake</span>” if <code class="varname">USE_TOOLS</code> contains
5589: “<span class="quote">gmake</span>”, “<span class="quote">make</span>” otherwise. The default value
5590: of <code class="varname">MAKEFILE</code> is “<span class="quote">Makefile</span>”, and
5591: <code class="varname">BUILD_TARGET</code> defaults to “<span class="quote">all</span>”.</p>
5592: </div>
5593: <div class="sect1" lang="en">
5594: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5595: <a name="build.test"></a>15.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
1.75 rillig 5596: <p>[TODO]</p>
5597: </div>
5598: <div class="sect1" lang="en">
5599: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5600: <a name="build.install"></a>15.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75 rillig 5601: <p>Once the build stage has completed, the final step is to
5602: install the software in public directories, so users can access
5603: the programs and files.</p>
5604: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
5605: equivalent of the following code is executed. Additionally,
5606: before and after this code, much magic is performed to do
5607: consistency checks, registering the package, and so on.</p>
5608: <pre class="programlisting">
5609: .for d in ${INSTALL_DIRS}
5610: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
5611: ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
5612: -f ${MAKEFILE} ${BUILD_TARGET}
5613: .endfor
5614: </pre>
5615: <p>The variable's meanings are analogous to the ones in the
5616: <span class="emphasis"><em>build</em></span> phase.
5617: <code class="varname">INSTALL_DIRS</code> defaults to
5618: <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
5619: is “<span class="quote">install</span>” by default, plus
5620: “<span class="quote">install.man</span>” if <code class="varname">USE_IMAKE</code> is
5621: defined.</p>
5622: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
5623: variables are useful. They are all variations of the
5624: <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
5625: permissions preset. <code class="varname">INSTALL</code> is the plain
5626: install command. The specialized variants, together with their
5627: intended use, are:</p>
5628: <div class="variablelist"><dl>
5629: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
5630: <dd><p>directories that contain binaries</p></dd>
5631: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
5632: <dd><p>directories that contain scripts</p></dd>
5633: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
5634: <dd><p>directories that contain shared and static libraries</p></dd>
5635: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
5636: <dd><p>directories that contain data files</p></dd>
5637: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
5638: <dd><p>directories that contain man pages</p></dd>
5639: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
5640: <dd><p>binaries that can be stripped from debugging symbols</p></dd>
5641: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
5642: <dd><p>binaries that cannot be stripped</p></dd>
5643: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
5644: <dd><p>game binaries</p></dd>
5645: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
5646: <dd><p>shared and static libraries</p></dd>
5647: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
5648: <dd><p>data files</p></dd>
5649: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
5650: <dd><p>data files for games</p></dd>
5651: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
5652: <dd><p>man pages</p></dd>
5653: </dl></div>
5654: <p>Some other variables are:</p>
5655: <div class="variablelist"><dl>
5656: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
5657: <dd><p>A list of directories relative to
5658: <code class="varname">PREFIX</code> that are created by pkgsrc at
1.78 rillig 5659: the beginning of the <span class="emphasis"><em>install</em></span> phase.
5660: If this variable is set,
1.75 rillig 5661: <code class="varname">NO_MTREE</code>=“<span class="quote">yes</span>” is
5662: assumed, which means that the package claims to create
5663: all needed directories itself before installing files to
5664: it. Therefore this variable should only be set in
1.76 rillig 5665: <code class="filename">Makefile</code>s that are under control of
1.78 rillig 5666: the package's author. The directories are created with
5667: the correct ownership, depending on their
5668: name.</p></dd>
1.75 rillig 5669: </dl></div>
5670: </div>
5671: <div class="sect1" lang="en">
5672: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5673: <a name="build.package"></a>15.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
1.75 rillig 5674: <p>[TODO]</p>
5675: </div>
5676: <div class="sect1" lang="en">
5677: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5678: <a name="build.helpful-targets"></a>15.16. Other helpful targets</h2></div></div></div>
1.75 rillig 5679: <div class="variablelist"><dl>
5680: <dt><span class="term">pre/post-*</span></dt>
5681: <dd><p>For any of the main targets described in the previous section, two
5682: auxiliary targets exist with “<span class="quote">pre-</span>” and
5683: “<span class="quote">post-</span>” used as a prefix
5684: for the main target's name. These targets are invoked before and
5685: after the main target is called, allowing extra configuration or
5686: installation steps be performed from a package's Makefile, for
5687: example, which a program's configure script
5688: or install target omitted.</p></dd>
5689: <dt><span class="term">do-*</span></dt>
5690: <dd><p>Should one of the main targets do the wrong thing, and should there
5691: be no variable to fix this, you can redefine it with the do-*
5692: target. (Note that redefining the target itself instead of the
5693: do-* target is a bad idea, as the pre-* and post-* targets won't be
5694: called anymore, etc.) You will not usually need to do this.</p></dd>
5695: <dt><span class="term">reinstall</span></dt>
5696: <dd><p>If you did a <span><strong class="command">make install</strong></span> and you noticed some file
5697: was not installed properly, you can repeat the installation with this
5698: target, which will ignore the “<span class="quote">already installed</span>” flag.</p></dd>
5699: <dt><span class="term">deinstall</span></dt>
5700: <dd>
5701: <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,
5702: effectively de-installing the package. The following variables can
5703: be used to tune the behaviour:</p>
5704: <div class="variablelist"><dl>
5705: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
5706: <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>
5707: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
5708: <dd><p>Remove all packages that require (depend on) the given package.
5709: This can be used to remove any packages that may have been pulled in
5710: by a given package, e.g. if <span><strong class="command">make deinstall
5711: DEINSTALLDEPENDS=1</strong></span> is done in
1.76 rillig 5712: <code class="filename">pkgsrc/x11/kde</code>, this is likely to remove whole
1.75 rillig 5713: 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>
5714: </dl></div>
5715: </dd>
5716: <dt><span class="term">update</span></dt>
5717: <dd>
5718: <p>This target causes the current package to be updated to the latest
5719: version. The package and all depending packages first get de-installed,
5720: then current versions of the corresponding packages get compiled and
5721: installed. This is similar to manually noting which packages are
5722: currently installed, then performing a series of <span><strong class="command">make
5723: deinstall</strong></span> and <span><strong class="command">make install</strong></span> (or whatever
5724: <code class="varname">UPDATE_TARGET</code> is set to) for these packages.</p>
5725: <p>You can use the “<span class="quote">update</span>” target to resume package
5726: updating in case a previous <span><strong class="command">make update</strong></span> was interrupted
5727: for some reason. However, in this case, make sure you don't call
5728: <span><strong class="command">make clean</strong></span> or otherwise remove the list of dependent
5729: packages in <code class="varname">WRKDIR</code>. Otherwise, you lose the
5730: ability to automatically update the current package along with the
5731: dependent packages you have installed.</p>
5732: <p>Resuming an interrupted <span><strong class="command">make update</strong></span> will only work as
5733: long as the package tree remains unchanged. If the source code for
5734: one of the packages to be updated has been changed, resuming
5735: <span><strong class="command">make update</strong></span> will most certainly fail!</p>
5736: <p>The following variables can be used either on the command line or in
1.76 rillig 5737: <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75 rillig 5738: <span><strong class="command">make update</strong></span>:</p>
5739: <div class="variablelist"><dl>
5740: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
5741: <dd><p>Install target to recursively use for the updated package and the
5742: dependent packages. Defaults to <code class="varname">DEPENDS_TARGET</code> if set,
5743: “<span class="quote">install</span>” otherwise for <span><strong class="command">make update</strong></span>.
5744: e.g. <span><strong class="command">make update UPDATE_TARGET=package</strong></span></p></dd>
5745: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
5746: <dd><p>Don't clean up after updating. Useful if you want to leave the
5747: work sources of the updated packages around for inspection or
5748: other purposes. Be sure you eventually clean up the source
5749: tree (see the “<span class="quote">clean-update</span>” target below) or you may
5750: run into troubles with old source code still lying around on your
5751: next <span><strong class="command">make</strong></span> or <span><strong class="command">make update</strong></span>.</p></dd>
5752: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
5753: <dd><p>Deinstall each package before installing (making
5754: <code class="varname">DEPENDS_TARGET</code>). This may be necessary if the
5755: “<span class="quote">clean-update</span>” target (see below) was called after
5756: interrupting a running <span><strong class="command">make update</strong></span>.</p></dd>
5757: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
5758: <dd><p>Allows you to disable recursion and hardcode the target for
5759: packages. The default is “<span class="quote">update</span>” for the update target,
5760: facilitating a recursive update of prerequisite packages.
5761: Only set <code class="varname">DEPENDS_TARGET</code> if you want to disable
5762: recursive updates. Use <code class="varname">UPDATE_TARGET</code> instead to just
5763: set a specific target for each package to be installed during
5764: <span><strong class="command">make update</strong></span> (see above).</p></dd>
5765: </dl></div>
5766: </dd>
5767: <dt><span class="term">clean-update</span></dt>
5768: <dd>
5769: <p>Clean the source tree for all packages that would get updated if
5770: <span><strong class="command">make update</strong></span> was called from the current directory.
5771: This target should not be used if the current package (or any of its
5772: depending packages) have already been de-installed (e.g., after calling
5773: <span><strong class="command">make update</strong></span>) or you may lose some packages you intended
5774: to update. As a rule of thumb: only use this target
5775: <span class="emphasis"><em>before</em></span> the first time you run
5776: <span><strong class="command">make update</strong></span> and only if you have a dirty package tree
5777: (e.g., if you used <code class="varname">NOCLEAN</code>).</p>
5778: <p>If you are unsure about whether your tree is clean, you can either
5779: perform a <span><strong class="command">make clean</strong></span> at the top of the tree, or use
5780: the following sequence of commands from the directory of the package
5781: you want to update (<span class="emphasis"><em>before</em></span> running
5782: <span><strong class="command">make update</strong></span> for the first time, otherwise you lose
5783: all the packages you wanted to update!):</p>
5784: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
5785: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
5786: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong></pre>
5787: <p>The following variables can be used either on the command line or in
1.76 rillig 5788: <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75 rillig 5789: <span><strong class="command">make clean-update</strong></span>:</p>
5790: <div class="variablelist"><dl>
5791: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
5792: <dd><p>After <span><strong class="command">make clean</strong></span>, do not reconstruct the list of
5793: directories to update for this package. Only use this if <span><strong class="command">make
5794: update</strong></span> successfully installed all packages you wanted to
5795: update. Normally, this is done automatically on <span><strong class="command">make
5796: update</strong></span>, but may have been suppressed by the
5797: <code class="varname">NOCLEAN</code> variable (see above).</p></dd>
5798: </dl></div>
5799: </dd>
5800: <dt><span class="term">info</span></dt>
5801: <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
5802: package. You can use this to check which version of a package is
5803: installed.</p></dd>
5804: <dt><span class="term">readme</span></dt>
1.76 rillig 5805: <dd><p>This target generates a <code class="filename">README.html</code> file, which
1.75 rillig 5806: can be viewed using a browser such as
1.76 rillig 5807: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/mozilla/README.html" target="_top"><code class="filename">www/mozilla</code></a> or
5808: <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 5809: The generated files contain references to any
5810: packages which are in the <code class="varname">PACKAGES</code> directory on
5811: the local host. The generated files can be made to refer to URLs based on
5812: <code class="varname">FTP_PKG_URL_HOST</code> and
5813: <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I wanted to generate
1.76 rillig 5814: <code class="filename">README.html</code> files which pointed to binary packages
1.75 rillig 5815: on the local machine, in the directory
1.76 rillig 5816: <code class="filename">/usr/packages</code>, set
1.75 rillig 5817: <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
5818: <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
5819: <code class="varname">${PACKAGES}</code> directory and its subdirectories will be
5820: searched for all the binary packages.</p></dd>
5821: <dt><span class="term">readme-all</span></dt>
1.76 rillig 5822: <dd><p>Use this target to create a file <code class="filename">README-all.html</code>
1.75 rillig 5823: which contains a list of all packages currently available in the NetBSD
5824: Packages Collection, together with the category they belong to and a
5825: short description. This file is compiled from the
1.76 rillig 5826: <code class="filename">pkgsrc/*/README.html</code> files, so be sure to run
1.75 rillig 5827: this <span class="emphasis"><em>after</em></span> a <span><strong class="command">make readme</strong></span>.</p></dd>
5828: <dt><span class="term">cdrom-readme</span></dt>
5829: <dd><p>This is very much the same as the “<span class="quote">readme</span>” target (see
5830: above), but is to be used when generating a pkgsrc tree to be written
5831: to a CD-ROM. This target also produces
1.76 rillig 5832: <code class="filename">README.html</code> files, and can be made to refer
1.75 rillig 5833: to URLs based on <code class="varname">CDROM_PKG_URL_HOST</code> and
5834: <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
5835: <dt><span class="term">show-distfiles</span></dt>
5836: <dd><p>This target shows which distfiles and patchfiles are needed to build
5837: the package. (<code class="varname">DISTFILES</code> and
1.76 rillig 5838: <code class="varname">PATCHFILES</code>, but not <code class="filename">patches/*</code>)</p></dd>
1.75 rillig 5839: <dt><span class="term">show-downlevel</span></dt>
5840: <dd><p>This target shows nothing if the package is not installed. If a version
5841: of this package is installed, but is not the version provided in this
5842: version of pkgsrc, then a warning message is displayed. This target can
5843: be used to show which of your installed packages are downlevel, and so
5844: the old versions can be deleted, and the current ones added.</p></dd>
5845: <dt><span class="term">show-pkgsrc-dir</span></dt>
5846: <dd><p>This target shows the directory in the pkgsrc hierarchy from which the
5847: package can be built and installed. This may not be the same directory
5848: as the one from which the package was installed. This target is intended
5849: to be used by people who may wish to upgrade many packages on a single
5850: host, and can be invoked from the top-level pkgsrc Makefile by using the
5851: “<span class="quote">show-host-specific-pkgs</span>” target.</p></dd>
5852: <dt><span class="term">show-installed-depends</span></dt>
5853: <dd><p>This target shows which installed packages match the current package's
5854: <code class="varname">DEPENDS</code>. Useful if out of date dependencies are
5855: causing build problems.</p></dd>
5856: <dt><span class="term">check-shlibs</span></dt>
5857: <dd><p>After a package is installed, check all its binaries and (on ELF
5858: platforms) shared libraries to see if they find the shared libs they need.
5859: Run by default if <code class="varname">PKG_DEVELOPER</code> is set in
1.76 rillig 5860: <code class="filename">/etc/mk.conf</code>.</p></dd>
1.75 rillig 5861: <dt><span class="term">print-PLIST</span></dt>
5862: <dd>
5863: <p>After a “<span class="quote">make install</span>” from a new or
5864: upgraded pkg, this prints out an attempt to generate a new
1.76 rillig 5865: <code class="filename">PLIST</code> from a <span><strong class="command">find -newer
1.75 rillig 5866: work/.extract_done</strong></span>. An attempt is made to care
5867: for shared libs etc., but it is
5868: <span class="emphasis"><em>strongly</em></span> recommended to review the
5869: result before putting it into
1.76 rillig 5870: <code class="filename">PLIST</code>. On upgrades, it's useful to
1.75 rillig 5871: diff the output of this command against an already
1.76 rillig 5872: existing <code class="filename">PLIST</code> file.</p>
1.75 rillig 5873: <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
5874: methods that don't update file access times, be sure to
5875: add these files manually to your
1.76 rillig 5876: <code class="filename">PLIST</code>, as the “<span class="quote">find
1.75 rillig 5877: -newer</span>” command used by this target won't catch
5878: them!</p>
1.77 rillig 5879: <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 5880: information on this target.</p>
5881: </dd>
5882: <dt><span class="term">bulk-package</span></dt>
5883: <dd>
5884: <p>Used to do bulk builds. If an appropriate binary package already exists,
5885: no action is taken. If not, this target will compile, install and
5886: package it (and its depends, if <code class="varname">PKG_DEPENDS</code> is
5887: set properly. See <a href="#binary.configuration" title="6.3.1. Configuration">Section 6.3.1, “Configuration”</a>).
5888: After creating the binary
5889: package, the sources, the just-installed package and its required
5890: packages are removed, preserving free disk space.</p>
5891: <p><span class="emphasis"><em>Beware that this target may deinstall all
5892: packages installed on a system!</em></span></p>
5893: </dd>
5894: <dt><span class="term">bulk-install</span></dt>
5895: <dd>
5896: <p>Used during bulk-installs to install required packages. If an
5897: up-to-date binary package is available, it will be installed via
5898: <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,
5899: but the installed binary won't be removed. </p>
5900: <p> A binary package is considered “<span class="quote">up-to-date</span>” to be
5901: 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>
5902: <div class="itemizedlist"><ul type="disc">
1.76 rillig 5903: <li><p>None of the package's files (<code class="filename">Makefile</code>,
1.75 rillig 5904: ...) were modified since it was built.</p></li>
5905: <li><p>None of the package's required (binary) packages were
5906: modified since it was built.</p></li>
5907: </ul></div>
5908: <p><span class="emphasis"><em>Beware that this target may deinstall all
5909: packages installed on a system!</em></span></p>
5910: </dd>
5911: </dl></div>
5912: </div>
5913: </div>
5914: <div class="chapter" lang="en">
5915: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5916: <a name="tools"></a>Chapter 16. Tools needed for building or running</h2></div></div></div>
1.75 rillig 5917: <div class="toc">
5918: <p><b>Table of Contents</b></p>
5919: <dl>
1.77 rillig 5920: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
5921: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
5922: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
1.75 rillig 5923: </dl>
5924: </div>
5925: <p>
5926: The <code class="varname">USE_TOOLS</code> definition is used both internally
5927: by pkgsrc and also for individual packages to define what commands
5928: are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
5929: or for later run-time of an installed packaged (such as
5930: <code class="varname">DEPENDS</code>).
5931: If the native system provides an adequate tool, then in many cases, a pkgsrc
5932: package will not be used.
5933: </p>
5934: <p>
5935: When building a package, the replacement tools are
5936: made available in a directory (as symlinks or wrapper scripts)
5937: that is early in the executable search path. Just like the buildlink
5938: system, this helps with consistent builds.
5939: </p>
5940: <p>
5941: A tool may be needed to help build a specific package. For example,
5942: perl, GNU make (gmake) or yacc may be needed.
5943: </p>
5944: <p>
5945: Also a tool may be needed, for example, because the native system's supplied
5946: tool may be inefficient for building a package with pkgsrc.
5947: For example, a package may need GNU awk, bison (instead of
5948: yacc) or a better sed.
5949: </p>
5950: <p>
5951: The tools used by a package can be listed by running
5952: <span><strong class="command">make show-tools</strong></span>.
5953: </p>
5954: <div class="sect1" lang="en">
5955: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5956: <a name="pkgsrc-tools"></a>16.1. Tools for pkgsrc builds</h2></div></div></div>
1.75 rillig 5957: <p>
5958: The default set of tools used by pkgsrc is defined in
1.76 rillig 5959: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.75 rillig 5960: such as: <span><strong class="command">cat</strong></span>, <span><strong class="command">awk</strong></span>,
5961: <span><strong class="command">chmod</strong></span>, <span><strong class="command">test</strong></span>, and so on.
5962: These can be seen by running:
5963: <span><strong class="command">make show-var VARNAME=USE_TOOLS</strong></span>.
5964: </p>
5965: <p>
5966: If a package needs a specific program to build
5967: then the <code class="varname">USE_TOOLS</code> variable can be used
5968: to define the tools needed.
5969: </p>
5970: </div>
5971: <div class="sect1" lang="en">
5972: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5973: <a name="package-tools"></a>16.2. Tools needed by packages</h2></div></div></div>
1.75 rillig 5974: <p>
5975: In the following examples, the :pkgsrc means to use the pkgsrc version
5976: and not the native version for a build dependency.
5977: And the :run means that it is used for a
5978: run-time dependencies also (and becomes a DEPENDS).
5979: The default is a build dependency which can be set with
5980: :build. (So in this example, it is the same as gmake:build
5981: and pkg-config:build.)
5982: </p>
5983: <pre class="programlisting">
5984: USE_TOOLS+= mktemp:pkgsrc
5985: USE_TOOLS+= gmake perl:run pkg-config
5986: </pre>
5987: <p>
5988: When using the tools framework, a
5989: <code class="varname">TOOLS_PATH.foo</code> variable is defined
5990: which contains the full path to the appropriate tool. For example,
5991: <code class="varname">TOOLS_PATH.bash</code> could be “<span class="quote">/bin/bash</span>”
5992: on Linux systems.
5993: </p>
5994: <p>
5995: If you always need a pkgsrc version of the
5996: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
5997:
5998: </p>
5999: </div>
6000: <div class="sect1" lang="en">
6001: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6002: <a name="platform-tools"></a>16.3. Tools provided by platforms</h2></div></div></div>
1.75 rillig 6003: <p>
6004: When improving or porting pkgsrc to a new platform, have a look
6005: at (or create) the corresponding platform specific make file fragment under
1.76 rillig 6006: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
1.75 rillig 6007: the name of the common tools. For example:</p>
6008: <pre class="programlisting">
6009: .if exists(/usr/bin/bzcat)
6010: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
6011: .elif exists(/usr/bin/bzip2)
6012: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
6013: .endif
1.69 rillig 6014:
1.75 rillig 6015: TOOLS_PLATFORM.true?= true # shell builtin
6016: </pre>
6017: </div>
6018: </div>
6019: <div class="chapter" lang="en">
6020: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 6021: <a name="fixes"></a>Chapter 17. Making your package work</h2></div></div></div>
1.75 rillig 6022: <div class="toc">
6023: <p><b>Table of Contents</b></p>
6024: <dl>
1.77 rillig 6025: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
1.75 rillig 6026: <dd><dl>
1.78 rillig 6027: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
6028: <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>
6029: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
6030: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
6031: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
6032: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
6033: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
6034: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
6035: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
6036: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
6037: <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 6038: <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 6039: </dl></dd>
6040: <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>
6041: <dd><dl>
6042: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
6043: <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>
6044: </dl></dd>
6045: <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>
6046: <dd><dl>
6047: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
6048: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
6049: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
6050: </dl></dd>
6051: <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>
6052: <dd><dl>
1.78 rillig 6053: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
6054: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
6055: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
6056: </dl></dd>
6057: <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>
6058: <dd><dl>
6059: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
6060: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
6061: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
6062: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
6063: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
6064: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
6065: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
6066: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
6067: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
6068: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
6069: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
6070: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
6071: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
6072: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
6073: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
6074: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
6075: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.75 rillig 6076: </dl></dd>
1.78 rillig 6077: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.75 rillig 6078: </dl>
6079: </div>
6080: <div class="sect1" lang="en">
6081: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6082: <a name="general-operation"></a>17.1. General operation</h2></div></div></div>
1.75 rillig 6083: <div class="sect2" lang="en">
6084: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6085: <a name="portability-of-packages"></a>17.1.1. Portability of packages</h3></div></div></div>
6086: <p>One appealing feature of pkgsrc is that it runs on many
6087: different platforms. As a result, it is important to ensure,
6088: where possible, that packages in pkgsrc are portable. This
6089: chapter mentions some particular details you should pay
6090: attention to while working on pkgsrc.</p>
6091: </div>
6092: <div class="sect2" lang="en">
6093: <div class="titlepage"><div><div><h3 class="title">
6094: <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>
6095: <p>The pkgsrc user can configure pkgsrc by overriding several
6096: variables in the file pointed to by <code class="varname">MAKECONF</code>,
6097: which is <code class="filename">/etc/mk.conf</code> by default. When you
6098: want to use those variables in the preprocessor directives of
6099: <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
6100: <code class="literal">.for</code>), you need to include the file
6101: <code class="filename">../../mk/bsd.prefs.mk</code> before, which in turn
6102: loads the user preferences.</p>
6103: <p>But note that some variables may not be completely defined
6104: after <code class="filename">../../mk/bsd.prefs.mk</code> has been
6105: included, as they may contain references to variables that are
6106: not yet defined. In shell commands this is no problem, since
6107: variables are actually macros, which are only expanded when they
6108: are used. But in the preprocessor directives mentioned above and
6109: in dependency lines (of the form <code class="literal">target:
6110: dependencies</code>) the variables are expanded at load
6111: time.</p>
6112: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
6113: <h3 class="title">Note</h3>
6114: <p>Currently there is no exhaustive list of all
6115: variables that tells you whether they can be used at load time
6116: or only at run time, but it is in preparation.</p>
6117: </div>
6118: </div>
6119: <div class="sect2" lang="en">
6120: <div class="titlepage"><div><div><h3 class="title">
6121: <a name="user-interaction"></a>17.1.3. User interaction</h3></div></div></div>
6122: <p>Occasionally, packages require interaction from the user, and this can be
6123: in a number of ways:</p>
6124: <div class="itemizedlist"><ul type="disc">
1.79 ! rillig 6125: <li><p>When fetching the distfiles, some packages require user
! 6126: interaction such as entering username/password or accepting a
! 6127: license on a web page.</p></li>
1.78 rillig 6128: <li><p>When extracting the distfiles, some packages may ask for passwords.</p></li>
6129: <li><p>help to configure the package before it is built</p></li>
6130: <li><p>help during the build process</p></li>
6131: <li><p>help during the installation of a package</p></li>
6132: </ul></div>
6133: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is provided to notify
6134: the pkgsrc mechanism of an interactive stage which will be needed, and
6135: this should be set in the package's <code class="filename">Makefile</code>, e.g.:</p>
1.75 rillig 6136: <pre class="programlisting">
1.78 rillig 6137: INTERACTIVE_STAGE= build
1.75 rillig 6138: </pre>
1.78 rillig 6139: <p>Multiple interactive stages can be specified:</p>
1.75 rillig 6140: <pre class="programlisting">
1.78 rillig 6141: INTERACTIVE_STAGE= configure install
1.75 rillig 6142: </pre>
6143: </div>
6144: <div class="sect2" lang="en">
6145: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6146: <a name="handling-licenses"></a>17.1.4. Handling licenses</h3></div></div></div>
6147: <p>A package may be covered by a license which the user has
6148: or has not agreed to accept. For these cases, pkgsrc contains
6149: a mechanism to note that a package is covered by a particular
6150: license, and the package cannot be built unless the user has
6151: accepted the license. (Installation of binary packages are
6152: not currently subject to this mechanism.) Packages with
6153: licenses that are either Open Source according to the Open
6154: Source Initiative or Free according to the Free Software
6155: Foundation will not be marked with a license tag. Packages
6156: with licenses that have not been determined to meet either
6157: definition will be marked with a license tag referring to the
6158: license. This will prevent building unless pkgsrc is informed
6159: that the license is acceptable, and enables displaying the
6160: license.</p>
6161: <p>The license tag mechanism is intended to address
6162: copyright-related issues surrounding building, installing and
6163: using a package, and not to address redistribution issues (see
6164: <code class="varname">RESTRICTED</code> and
6165: <code class="varname">NO_SRC_ON_FTP</code>, etc.). However, the above
6166: definition of licenses for which tags are not needed implies
6167: that packages with redistribution restrictions should have
6168: tags.</p>
6169: <p>
6170: Denoting that a package is covered by a particular license is
6171: done by placing the license in
6172: <code class="filename">pkgsrc/licenses</code> and setting the
6173: <code class="varname">LICENSE</code> variable to a string identifying
6174: the license, e.g. in
6175: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>: </p>
6176: <pre class="programlisting">
6177: LICENSE= xv-license
6178: </pre>
6179: <p>
6180: When trying to build, the user will get a notice that the
6181: package is covered by a license which has not been
6182: accepted:</p>
6183: <pre class="programlisting">
6184: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
6185: ===> xv-3.10anb9 has an unacceptable license: xv-license.
6186: ===> To view the license, enter "/usr/bin/make show-license".
6187: ===> To indicate acceptance, add this line to your /etc/mk.conf:
6188: ===> ACCEPTABLE_LICENSES+=xv-license
6189: *** Error code 1
6190: </pre>
6191: <p>The license can be viewed with <span><strong class="command">make
6192: show-license</strong></span>, and if it is considered appropriate,
6193: the line printed above can be added to
6194: <code class="filename">/etc/mk.conf</code> to indicate acceptance of
6195: the particular license:</p>
6196: <pre class="programlisting">
6197: ACCEPTABLE_LICENSES+=xv-license
6198: </pre>
6199: <p>When adding a package with a new license, the license
6200: text should be added to <code class="filename">pkgsrc/licenses</code>
6201: for displaying. A list of known licenses can be seen in this
6202: directory as well as by looking at the list of (commented
6203: out) <code class="varname">ACCEPTABLE_LICENSES</code> variable
6204: settings in
6205: <code class="filename">pkgsrc/mk/defaults/mk.conf</code>.</p>
6206: <p>The use of <code class="varname">LICENSE=shareware</code>,
6207: <code class="varname">LICENSE=no-commercial-use</code>, and similar
6208: language is deprecated because it does not crisply refer to
6209: a particular license text. Another problem with such usage
6210: is that it does not enable a user to denote acceptance of
6211: the license for a single package without accepting the same
6212: license text for another package. In particular, this can
6213: be inappropriate when e.g. one accepts a particular license to
6214: indicate to pkgsrc that a fee has been paid.</p>
1.75 rillig 6215: </div>
6216: <div class="sect2" lang="en">
6217: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6218: <a name="restricted-packages"></a>17.1.5. Restricted packages</h3></div></div></div>
1.75 rillig 6219: <p>Some licenses restrict how software may be re-distributed.
6220: In order to satisfy these restrictions, the package system
6221: defines five make variables that can be set to note these
6222: restrictions:</p>
6223: <div class="itemizedlist"><ul type="disc">
6224: <li>
6225: <p><code class="varname">RESTRICTED</code></p>
6226: <p>This variable should be set whenever a restriction
6227: exists (regardless of its kind). Set this variable to a
6228: string containing the reason for the restriction.</p>
6229: </li>
6230: <li>
6231: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
6232: <p>Binaries may not be placed on CD-ROM. Set this
6233: variable to <code class="varname">${RESTRICTED}</code> whenever a
6234: binary package may not be included on a CD-ROM.</p>
6235: </li>
6236: <li>
6237: <p><code class="varname">NO_BIN_ON_FTP</code></p>
6238: <p>Binaries may not be placed on an FTP server. Set
6239: this variable to <code class="varname">${RESTRICTED}</code>
6240: whenever a binary package may not not be made available
6241: on the Internet.</p>
6242: </li>
6243: <li>
6244: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
6245: <p>Distfiles may not be placed on CD-ROM. Set this
6246: variable to <code class="varname">${RESTRICTED}</code> if
6247: re-distribution of the source code or other distfile(s) is
6248: not allowed on CD-ROMs.</p>
6249: </li>
6250: <li>
6251: <p><code class="varname">NO_SRC_ON_FTP</code></p>
6252: <p>Distfiles may not be placed on FTP. Set this variable
6253: to <code class="varname">${RESTRICTED}</code> if re-distribution of
6254: the source code or other distfile(s) via the Internet is not
6255: allowed.</p>
6256: </li>
6257: </ul></div>
6258: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
6259: <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
6260: generic make variables to denote restrictions is deprecated,
6261: because they unconditionally prevent users from generating
6262: binary packages!</p>
6263: </div>
6264: <div class="sect2" lang="en">
6265: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6266: <a name="dependencies"></a>17.1.6. Handling dependencies</h3></div></div></div>
1.75 rillig 6267: <p>Your package may depend on some other package being present
6268: - and there are various ways of expressing this
6269: dependency. pkgsrc supports the <code class="varname">BUILD_DEPENDS</code>
6270: and <code class="varname">DEPENDS</code> definitions, the
6271: <code class="varname">USE_TOOLS</code> definition, as well as
1.76 rillig 6272: dependencies via <code class="filename">buildlink3.mk</code>, which is
1.75 rillig 6273: the preferred way to handle dependencies, and which uses the
1.77 rillig 6274: variables named above. See <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a> for more
1.75 rillig 6275: information.</p>
6276: <p>The basic difference between the two variables is as
6277: follows: The <code class="varname">DEPENDS</code> definition registers
6278: that pre-requisite in the binary package so it will be pulled in
6279: when the binary package is later installed, whilst the
6280: <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
6281: dependency that is only needed for building the package.
6282: </p>
6283: <p>This means that if you only need a package present whilst
6284: you are building, it should be noted as a
6285: <code class="varname">BUILD_DEPENDS</code>.</p>
6286: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
6287: <code class="varname">DEPENDS</code> definition is:</p>
6288: <pre class="programlisting">
6289: <pre-req-package-name>:../../<category>/<pre-req-package>
6290: </pre>
6291: <p>Please note that the “<span class="quote">pre-req-package-name</span>”
6292: may include any of the wildcard version numbers recognized by
6293: <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>
6294: <div class="orderedlist"><ol type="1">
6295: <li>
6296: <p>If your package needs another package's binaries or
6297: libraries to build or run, and if that package has a
1.76 rillig 6298: <code class="filename">buildlink3.mk</code> file available, use it:
1.75 rillig 6299: </p>
6300: <pre class="programlisting">
6301: .include "../../graphics/jpeg/buildlink3.mk"
6302: </pre>
6303: </li>
6304: <li>
6305: <p>If your package needs to use another package to build
1.76 rillig 6306: itself and there is no <code class="filename">buildlink3.mk</code>
1.75 rillig 6307: file available, use the <code class="varname">BUILD_DEPENDS</code>
6308: definition:</p>
6309: <pre class="programlisting">
6310: BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
6311: </pre>
6312: </li>
6313: <li>
6314: <p>If your package needs a library with which to link and
1.76 rillig 6315: again there is no <code class="filename">buildlink3.mk</code> file
1.75 rillig 6316: available, this is specified using the
6317: <code class="varname">DEPENDS</code> definition. For example:</p>
6318: <pre class="programlisting">
6319: DEPENDS+= xpm-3.4j:../../graphics/xpm
6320: </pre>
6321: <p>You can also use wildcards in package dependences:</p>
6322: <pre class="programlisting">
6323: DEPENDS+= xpm-[0-9]*:../../graphics/xpm
6324: </pre>
6325: <p>Note that such wildcard dependencies are retained when
6326: creating binary packages. The dependency is checked when
6327: installing the binary package and any package which matches
6328: the pattern will be used. Wildcard dependencies should be
6329: used with care.</p>
6330: <p>The “<span class="quote">-[0-9]*</span>” should be used instead of
6331: “<span class="quote">-*</span>” to avoid potentially ambiguous matches
6332: such as “<span class="quote">tk-postgresql</span>” matching a
6333: “<span class="quote">tk-*</span>” <code class="varname">DEPENDS</code>.</p>
6334: <p>Wildcards can also be used to specify that a package
6335: will only build against a certain minimum version of a
6336: pre-requisite:</p>
6337: <pre class="programlisting">
6338: DEPENDS+= tiff>=3.5.4:../../graphics/tiff
6339: </pre>
6340: <p>This means that the package will build against version
6341: 3.5.4 of the tiff library or newer. Such a dependency may
6342: be warranted if, for example, the API of the library has
6343: changed with version 3.5.4 and a package would not compile
6344: against an earlier version of tiff.</p>
6345: <p>Please note that such dependencies should only be
6346: updated if a package requires a newer pre-requisite, but
6347: not to denote recommendations such as
6348: ABI changes that do not prevent a package from building
6349: correctly. Such recommendations can be expressed using
6350: <code class="varname">ABI_DEPENDS</code>:</p>
6351: <pre class="programlisting">
6352: ABI_DEPENDS+= tiff>=3.6.1:../../graphics/tiff
6353: </pre>
6354: <p>In addition to the above <code class="varname">DEPENDS</code>
6355: line, this denotes that while a package will build against
6356: tiff>=3.5.4, at least version 3.6.1 is recommended.
6357: <code class="varname">ABI_DEPENDS</code> entries will be turned into
6358: dependencies unless explicitly ignored (in which case a
6359: warning will be printed).</p>
6360: <p>To ignore these ABI dependency recommendations and just
6361: use the required <code class="varname">DEPENDS</code>, set
6362: <code class="varname">USE_ABI_DEPENDS=NO</code>. This may make
6363: it easier and faster to update packages built using pkgsrc,
6364: since older compatible dependencies can continue to be
6365: used. This is useful for people who watch their rebuilds
6366: very carefully; it is not very good as a general-purpose
6367: hammer. If you use it, you need to be mindful of possible
6368: ABI changes, including those from the underlying OS.
6369: </p>
6370: <p>Packages that are built with recommendations ignored
6371: may not be uploaded to ftp.NetBSD.org by developers and
6372: should not be used across different systems that may have
6373: different versions of binary packages installed.</p>
6374: <p>For security fixes, please update the package
1.78 rillig 6375: 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 6376: information.</p>
6377: </li>
6378: <li>
6379: <p>If your package needs some executable to be able to run
6380: correctly and if there's no
1.76 rillig 6381: <code class="filename">buildlink3.mk</code> file, this is specified
1.75 rillig 6382: using the <code class="varname">DEPENDS</code> variable. The
1.76 rillig 6383: <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 6384: be able to execute the latex binary from the teTeX package
6385: when it runs, and that is specified:</p>
6386: <pre class="programlisting">
6387: DEPENDS+= teTeX-[0-9]*:../../print/teTeX
6388: </pre>
6389: <p>The comment about wildcard dependencies from previous
6390: paragraph applies here, too.</p>
6391: </li>
6392: </ol></div>
6393: <p>If your package needs files from another package to build,
6394: add the relevant distribution files to
6395: <code class="varname">DISTFILES</code>, so they will be extracted
1.76 rillig 6396: 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 6397: (It relies on the jpeg sources being present in source form
6398: during the build.)</p>
6399: <p>Please also note the <code class="varname">BUILD_USES_MSGFMT</code>
6400: and <code class="varname">BUILD_USES_GETTEXT_M4</code> definitions, which
6401: are provided as convenience definitions. The former works out
6402: 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 6403: 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 6404: The latter adds a build dependency on either an installed
6405: version of an older gettext package, or if it isn't, installs the
1.76 rillig 6406: <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 6407: </div>
6408: <div class="sect2" lang="en">
6409: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6410: <a name="conflicts"></a>17.1.7. Handling conflicts with other packages</h3></div></div></div>
1.75 rillig 6411: <p>Your package may conflict with other packages a user might
6412: already have installed on his system, e.g. if your package
6413: installs the same set of files like another package in our
6414: pkgsrc tree.</p>
6415: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
6416: space-separated list of packages (including version string) your
6417: package conflicts with.</p>
1.76 rillig 6418: <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>
6419: 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 6420: install the same shared library, thus you set in
1.76 rillig 6421: <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
1.75 rillig 6422: <pre class="programlisting">
6423: CONFLICTS= Xaw-Xpm-[0-9]*
6424: </pre>
1.76 rillig 6425: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:
1.75 rillig 6426: </p>
6427: <pre class="programlisting">
6428: CONFLICTS= Xaw3d-[0-9]*
6429: </pre>
6430: <p>Packages will automatically conflict with other packages
6431: with the name prefix and a different version
6432: string. “<span class="quote">Xaw3d-1.5</span>” e.g. will automatically
6433: conflict with the older version “<span class="quote">Xaw3d-1.3</span>”.
6434: </p>
6435: </div>
6436: <div class="sect2" lang="en">
6437: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6438: <a name="not-building-packages"></a>17.1.8. Packages that cannot or should not be built</h3></div></div></div>
1.75 rillig 6439: <p>There are several reasons why a package might be
6440: instructed to not build under certain circumstances. If the
6441: package builds and runs on most platforms, the exceptions
6442: should be noted with <code class="varname">NOT_FOR_PLATFORM</code>. If
6443: the package builds and runs on a small handful of platforms,
6444: set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
6445: Both <code class="varname">ONLY_FOR_PLATFORM</code> and
6446: <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
6447: (OS-version-platform) that can use glob-style
6448: wildcards.</p>
6449: <p>If the package should be skipped (for example, because it
6450: provides functionality already provided by the system), set
6451: <code class="varname">PKG_SKIP_REASON</code> to a descriptive message.
6452: If the package should fail because some preconditions are not
6453: met, set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
6454: message.</p>
6455: </div>
6456: <div class="sect2" lang="en">
6457: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6458: <a name="undeletable-packages"></a>17.1.9. Packages which should not be deleted, once installed</h3></div></div></div>
1.75 rillig 6459: <p>To ensure that a package may not be deleted, once it has been
6460: installed, the <code class="varname">PKG_PRESERVE</code> definition should
6461: be set in the package Makefile. This will be carried into any
6462: binary package that is made from this pkgsrc entry. A
6463: “<span class="quote">preserved</span>” package will
6464: 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
6465: “<span class="quote">-f</span>” option is used.</p>
6466: </div>
6467: <div class="sect2" lang="en">
6468: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6469: <a name="security-handling"></a>17.1.10. Handling packages with security problems</h3></div></div></div>
1.75 rillig 6470: <p>When a vulnerability is found, this should be noted in
1.76 rillig 6471: <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
1.75 rillig 6472: and after committing that file, use <span><strong class="command">make upload</strong></span>
6473: in the same directory to update the file on ftp.NetBSD.org.</p>
6474: <p>After fixing the vulnerability by a patch, its
6475: <code class="varname">PKGREVISION</code> should be increased (this
6476: is of course not necessary if the problem is fixed by using
6477: a newer release of the software).</p>
6478: <p>Also, if the fix should be applied to the stable pkgsrc
6479: branch, be sure to submit a pullup request!</p>
6480: <p>Binary packages already on ftp.NetBSD.org will be handled
6481: semi-automatically by a weekly cron job.</p>
6482: </div>
6483: <div class="sect2" lang="en">
6484: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6485: <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 6486: <p>When making fixes to an existing package it can be useful
6487: to change the version number in <code class="varname">PKGNAME</code>. To
6488: avoid conflicting with future versions by the original author, a
6489: “<span class="quote">nb1</span>”, “<span class="quote">nb2</span>”, ... suffix can be used
6490: on package versions by setting <code class="varname">PKGREVISION=1</code>
6491: (2, ...). The “<span class="quote">nb</span>” is treated like a
6492: “<span class="quote">.</span>” by the pkg tools. e.g.</p>
6493: <pre class="programlisting">
6494: DISTNAME= foo-17.42
6495: PKGREVISION= 9
6496: </pre>
6497: <p>will result in a <code class="varname">PKGNAME</code> of
6498: “<span class="quote">foo-17.42nb9</span>”.</p>
6499: <p>When a new release of the package is released, the
6500: <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
6501: minor release of the above package, things should be like:</p>
6502: <pre class="programlisting">
6503: DISTNAME= foo-17.43
6504: </pre>
1.78 rillig 6505: <p>PKGREVISION should be incremented for any non-trivial change in the
6506: resulting binary package. Without a PKGREVISION bump, someone with
6507: the previous version installed has no way of knowing that their
6508: package is out of date. Thus, changes without increasing PKGREVISION
6509: are essentially labeled "this is so trivial that no reasonable person
6510: would want to upgrade", and this is the rough test for when increasing
6511: PKGREVISION is appropriate. Examples of changes that do not merit
6512: increasing PKGREVISION are:</p>
6513: <pre class="programlisting">
6514: Changing HOMEPAGE, MAINTAINER, or comments in Makefile.
6515: Changing build variables if the resulting binary package is the same.
6516: Changing DESCR.
6517: Adding PKG_OPTIONS if the default options don't change.
6518: </pre>
6519: <p>Examples of changes that do merit an increase to PKGREVISION
6520: include:</p>
6521: <pre class="programlisting">
6522: Security fixes
6523: Changes or additions to a patch file
6524: Changes to the PLIST
1.75 rillig 6525: </pre>
1.78 rillig 6526: <p>PKGREVISION must also be incremented when dependencies have ABI
6527: changes.</p>
1.75 rillig 6528: </div>
1.79 ! rillig 6529: <div class="sect2" lang="en">
! 6530: <div class="titlepage"><div><div><h3 class="title">
! 6531: <a name="fixes.subst"></a>17.1.12. Substituting variable text in the package files (the SUBST framework)</h3></div></div></div>
! 6532: <p>When you want to replace the same text in multiple files
! 6533: or when the replacement text varies, patches alone cannot help.
! 6534: This is where the SUBST framework comes in. It provides an
! 6535: easy-to-use interface for replacing text in files.
! 6536: Example:</p>
! 6537: <pre class="programlisting">
! 6538: SUBST_CLASSES+= fix-paths
! 6539: SUBST_STAGE.fix-paths= pre-configure
! 6540: SUBST_MESSAGE.fix-paths= Fixing absolute paths.
! 6541: SUBST_FILES.fix-paths= src/*.c
! 6542: SUBST_FILES.fix-paths+= scripts/*.sh
! 6543: SUBST_SED.fix-paths= -e 's,"/usr/local,"${PREFIX},g'
! 6544: SUBST_SED.fix-paths+= -e 's,"/var/log,"${VARBASE}/log,g'
! 6545: </pre>
! 6546: <p><code class="varname">SUBST_CLASSES</code> is a list of identifiers
! 6547: that are used to identify the different SUBST blocks that are
! 6548: defined. The SUBST framework is heavily used by pkgsrc, so it is
! 6549: important to always use the <code class="literal">+=</code> operator with
! 6550: this variable. Otherwise some substitutions may be
! 6551: skipped.</p>
! 6552: <p>The remaining variables of each SUBST block are
! 6553: parameterized with the identifier from the first line
! 6554: (<code class="literal">fix-paths</code> in this case.) They can be seen as
! 6555: parameters to a function call.</p>
! 6556: <p><code class="varname">SUBST_STAGE.*</code> specifies the stage at
! 6557: which the replacement will take place. All combinations of
! 6558: <code class="literal">pre-</code>, <code class="literal">do-</code> and
! 6559: <code class="literal">post-</code> together with a phase name are
! 6560: possible, though only few are actually used. Most commonly used
! 6561: are <code class="literal">post-patch</code> and
! 6562: <code class="literal">pre-configure</code>. Of these two,
! 6563: <code class="literal">pre-configure</code> should be preferred because
! 6564: then it is possible to run <span><strong class="command">bmake patch</strong></span> and
! 6565: have the state after applying the patches but before making any
! 6566: other changes. This is especially useful when you are debugging
! 6567: a package in order to create new patches for it. Similarly,
! 6568: <code class="literal">post-build</code> is preferred over
! 6569: <code class="literal">pre-install</code>, because the install phase should
! 6570: generally be kept as simple as possible. When you use
! 6571: <code class="literal">post-build</code>, you have the same files in the
! 6572: working directory that will be installed later, so you can check
! 6573: if the substitution has succeeded.</p>
! 6574: <p><code class="varname">SUBST_MESSAGE.*</code> is an optional text
! 6575: that is printed just before the substitution is done.</p>
! 6576: <p><code class="varname">SUBST_FILES.*</code> is the list of shell
! 6577: globbing patterns that specifies the files in which the
! 6578: substitution will take place. The patterns are interpreted
! 6579: relatively to the <code class="varname">WRKSRC</code> directory.</p>
! 6580: <p><code class="varname">SUBST_SED.*</code> is a list of arguments to
! 6581: <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
! 6582: command should be prefixed with <code class="literal">-e</code>, so that
! 6583: all SUBST blocks look uniform.</p>
! 6584: <p>There are some more variables, but they are so seldomly
! 6585: used that they are only documented in the
! 6586: <code class="filename">mk/subst.mk</code>.</p>
! 6587: </div>
1.75 rillig 6588: </div>
6589: <div class="sect1" lang="en">
6590: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6591: <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 6592: <div class="sect2" lang="en">
6593: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6594: <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 6595: <p>If you need to download from a dynamic URL you can set
6596: <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span><strong class="command">make
1.76 rillig 6597: fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
1.75 rillig 6598: with the name of each file to download as an argument, expecting
6599: it to output the URL of the directory from which to download
1.76 rillig 6600: 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 6601: example of this usage.</p>
1.75 rillig 6602: <p>If the download can't be automated, because the user must
6603: submit personal information to apply for a password, or must pay
6604: for the source, or whatever, you can set
6605: <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
6606: displayed to the user before aborting the build. Example:</p>
6607: <pre class="programlisting">
6608: FETCH_MESSAGE= "Please download the files"
6609: FETCH_MESSAGE+= " "${DISTFILES:Q}
6610: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
6611: </pre>
6612: </div>
6613: <div class="sect2" lang="en">
6614: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6615: <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 6616: <p>Sometimes authors of a software package make some
6617: modifications after the software was released, and they put up a
6618: new distfile without changing the package's version number. If a
6619: package is already in pkgsrc at that time, the checksum will
6620: no longer match. The contents of the new distfile should be
6621: compared against the old one before changing anything, to make
6622: sure the distfile was really updated on purpose, and that
6623: no trojan horse or so crept in.
6624: Then, the correct way to work around this is to
6625: set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
6626: usually based on <code class="varname">PKGNAME_NOREV</code>. In case this
6627: happens more often, <code class="varname">PKGNAME</code> can be used (thus
1.76 rillig 6628: including the <code class="filename">nbX</code> suffix) or a date stamp
1.75 rillig 6629: can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
1.76 rillig 6630: Do not forget regenerating the <code class="filename">distinfo</code> file
1.75 rillig 6631: after that, since it contains the <code class="varname">DIST_SUBDIR</code>
6632: path in the filenames.
6633: Furthermore, a mail to the package's authors seems appropriate
6634: telling them that changing distfiles after releases without
6635: changing the file names is not good practice.</p>
6636: </div>
6637: </div>
6638: <div class="sect1" lang="en">
6639: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6640: <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 6641: <div class="sect2" lang="en">
6642: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6643: <a name="fixes.libtool"></a>17.3.1. Shared libraries - libtool</h3></div></div></div>
1.75 rillig 6644: <p>pkgsrc supports many different machines, with different
6645: object formats like a.out and ELF, and varying abilities to do
6646: shared library and dynamic loading at all. To accompany this,
6647: varying commands and options have to be passed to the
6648: compiler, linker, etc. to get the Right Thing, which can be
6649: pretty annoying especially if you don't have all the machines
6650: at your hand to test things. The
1.76 rillig 6651: <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 6652: can help here, as it just “<span class="quote">knows</span>” how to build
6653: both static and dynamic libraries from a set of source files,
6654: thus being platform-independent.</p>
6655: <p>Here's how to use libtool in a pkg in seven simple
6656: steps:</p>
6657: <div class="orderedlist"><ol type="1">
6658: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
6659: Makefile.</p></li>
6660: <li><p>For library objects, use “<span class="quote">${LIBTOOL} --mode=compile
6661: ${CC}</span>” in place of “<span class="quote">${CC}</span>”. You could even
6662: add it to the definition of <code class="varname">CC</code>, if only
6663: libraries are being built in a given Makefile. This one command
6664: will build both PIC and non-PIC library objects, so you need not
6665: have separate shared and non-shared library rules.</p></li>
6666: <li>
6667: <p>For the linking of the library, remove any
6668: “<span class="quote">ar</span>”, “<span class="quote">ranlib</span>”, and “<span class="quote">ld
6669: -Bshareable</span>” commands, and instead use:</p>
6670: <pre class="programlisting">
6671: ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
6672: -rpath ${PREFIX}/lib -version-info major:minor
6673: </pre>
6674: <p>Note that the library is changed to have a
1.76 rillig 6675: <code class="filename">.la</code> extension, and the objects are
6676: changed to have a <code class="filename">.lo</code>
1.75 rillig 6677: extension. Change <code class="varname">OBJS</code> as
6678: necessary. This automatically creates all of the
1.76 rillig 6679: <code class="filename">.a</code>,
6680: <code class="filename">.so.major.minor</code>, and ELF symlinks (if
1.75 rillig 6681: necessary) in the build directory. Be sure to include
6682: “<span class="quote">-version-info</span>”, especially when major and
6683: minor are zero, as libtool will otherwise strip off the
6684: shared library version.</p>
6685: <p>From the libtool manual:</p>
6686: <pre class="programlisting">
6687: So, libtool library versions are described by three integers:
1.69 rillig 6688:
1.75 rillig 6689: CURRENT
6690: The most recent interface number that this library implements.
1.69 rillig 6691:
1.75 rillig 6692: REVISION
6693: The implementation number of the CURRENT interface.
1.69 rillig 6694:
1.75 rillig 6695: AGE
6696: The difference between the newest and oldest interfaces that
6697: this library implements. In other words, the library implements
6698: all the interface numbers in the range from number `CURRENT -
6699: AGE' to `CURRENT'.
1.1 grant 6700:
1.75 rillig 6701: If two libraries have identical CURRENT and AGE numbers, then the
6702: dynamic linker chooses the library with the greater REVISION number.
6703: </pre>
6704: <p>The “<span class="quote">-release</span>” option will produce
6705: different results for a.out and ELF (excluding symlinks)
6706: in only one case. An ELF library of the form
6707: “<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
6708: will have a symlink of
6709: “<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
6710: on an a.out platform. This is handled
6711: automatically.</p>
6712: <p>The “<span class="quote">-rpath argument</span>” is the install
6713: directory of the library being built.</p>
1.76 rillig 6714: <p>In the <code class="filename">PLIST</code>, include only the
6715: <code class="filename">.la</code> file, the other files will be
1.75 rillig 6716: added automatically.</p>
6717: </li>
6718: <li>
1.76 rillig 6719: <p>When linking shared object (<code class="filename">.so</code>)
1.75 rillig 6720: 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
6721: shared libraries, use “<span class="quote">-module
6722: -avoid-version</span>” to prevent them getting version
6723: tacked on.</p>
1.76 rillig 6724: <p>The <code class="filename">PLIST</code> file gets the
6725: <code class="filename">foo.so</code> entry.</p>
1.75 rillig 6726: </li>
6727: <li>
6728: <p>When linking programs that depend on these libraries
6729: <span class="emphasis"><em>before</em></span> they are installed, preface
6730: 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}
6731: --mode=link</span>”, and it will find the correct
6732: libraries (static or shared), but please be aware that
6733: libtool will not allow you to specify a relative path in
6734: -L (such as “<span class="quote">-L../somelib</span>”), because it
6735: expects you to change that argument to be the
1.76 rillig 6736: <code class="filename">.la</code> file. e.g.</p>
1.75 rillig 6737: <pre class="programlisting">
6738: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
6739: </pre>
6740: <p>should be changed to:</p>
6741: <pre class="programlisting">
6742: ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
6743: </pre>
6744: <p>and it will do the right thing with the libraries.</p>
6745: </li>
6746: <li>
6747: <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>
6748: 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}
6749: --mode=install</span>”, and change the library name to
1.76 rillig 6750: <code class="filename">.la</code>. e.g.</p>
1.75 rillig 6751: <pre class="programlisting">
6752: ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
6753: </pre>
1.76 rillig 6754: <p>This will install the static <code class="filename">.a</code>,
1.75 rillig 6755: shared library, any needed symlinks, and run
6756: <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>
6757: </li>
1.76 rillig 6758: <li><p>In your <code class="filename">PLIST</code>, include only
6759: the <code class="filename">.la</code>
1.75 rillig 6760: file (this is a change from previous behaviour).</p></li>
6761: </ol></div>
6762: </div>
6763: <div class="sect2" lang="en">
6764: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6765: <a name="using-libtool"></a>17.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
1.75 rillig 6766: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
6767: package Makefile. This will override the package's own libtool
6768: in most cases. For older libtool using packages, libtool is
6769: made by ltconfig script during the do-configure step; you can
6770: check the libtool script location by doing <span><strong class="command">make
6771: configure; find work*/ -name libtool</strong></span>.</p>
6772: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
6773: scripts, relative to <code class="varname">WRKSRC</code>, to override. By
6774: default, it is set to “<span class="quote">libtool */libtool
6775: */*/libtool</span>”. If this does not match the location of the
6776: package's libtool script(s), set it as appropriate.</p>
1.76 rillig 6777: <p>If you do not need <code class="filename">*.a</code> static
1.75 rillig 6778: libraries built and installed, then use
6779: <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
6780: <p>If your package makes use of the platform-independent library
6781: for loading dynamic shared objects, that comes with libtool
6782: (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
6783: <p>Some packages use libtool incorrectly so that the package may not work or
6784: build in some circumstances. Some of the more common errors are:</p>
6785: <div class="itemizedlist"><ul type="disc">
6786: <li>
6787: <p>The inclusion of a shared object (-module) as a dependent library in an
6788: executable or library. This in itself isn't a problem if one of two things
6789: has been done:</p>
6790: <div class="orderedlist"><ol type="1">
6791: <li><p>The shared object is named correctly, i.e.
1.76 rillig 6792: <code class="filename">libfoo.la</code>, not
6793: <code class="filename">foo.la</code></p></li>
1.75 rillig 6794: <li><p>The -dlopen option is used when linking an executable.</p></li>
6795: </ol></div>
6796: </li>
6797: <li><p>The use of libltdl without the correct calls to initialisation routines.
6798: The function lt_dlinit() should be called and the macro
6799: <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
6800: executables.</p></li>
6801: </ul></div>
6802: </div>
6803: <div class="sect2" lang="en">
6804: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6805: <a name="autoconf-automake"></a>17.3.3. GNU Autoconf/Automake</h3></div></div></div>
1.75 rillig 6806: <p>If a package needs GNU autoconf or automake to be executed
6807: to regenerate the configure script and Makefile.in makefile
6808: templates, then they should be executed in a pre-configure
6809: target.</p>
6810: <p>For packages that need only autoconf:</p>
6811: <pre class="programlisting">
6812: AUTOCONF_REQD= 2.50 # if default version is not good enough
6813: USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
6814: ...
1.1 grant 6815:
1.75 rillig 6816: pre-configure:
6817: cd ${WRKSRC}; autoconf
1.1 grant 6818:
1.75 rillig 6819: ...
6820: </pre>
6821: <p>and for packages that need automake and autoconf:</p>
6822: <pre class="programlisting">
6823: AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
6824: USE_TOOLS+= automake # use "automake14" for automake-1.4
6825: ...
1.1 grant 6826:
1.75 rillig 6827: pre-configure:
6828: cd ${WRKSRC}; \
6829: aclocal; autoheader; \
6830: automake -a --foreign -i; autoconf
1.1 grant 6831:
1.75 rillig 6832: ...
6833: </pre>
6834: <p>Packages which use GNU Automake will almost certainly
6835: require GNU Make.</p>
6836: <p>There are times when the configure process makes
6837: additional changes to the generated files, which then causes
6838: the build process to try to re-execute the automake sequence.
6839: This is prevented by touching various files in the configure
6840: stage. If this causes problems with your package you can set
6841: <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
6842: Makefile.</p>
6843: </div>
6844: </div>
6845: <div class="sect1" lang="en">
6846: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6847: <a name="fixes.build"></a>17.4. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
6848: <p>The most common failures when building a package are that
6849: some platforms do not provide certain header files, functions or
6850: libraries, or they provide the functions in a library that the
6851: original package author didn't know. To work around this, you
6852: can rewrite the source code in most cases so that it does not
6853: use the missing functions or provides a replacement function.</p>
6854: <div class="sect2" lang="en">
6855: <div class="titlepage"><div><div><h3 class="title">
6856: <a name="fixes.build.cpp"></a>17.4.1. Compiling C and C++ code conditionally</h3></div></div></div>
6857: <p>If a package already comes with a GNU configure script, the
6858: preferred way to fix the build failure is to change the
6859: configure script, not the code. In the other cases, you can
6860: utilize the C preprocessor, which defines certain macros
6861: depending on the operating system and hardware architecture it
6862: compiles for. These macros can be queried using for example
6863: <code class="varname">#if defined(__i386)</code>. Almost every operating
6864: system, hardware architecture and compiler has its own macro.
6865: For example, if the macros <code class="varname">__GNUC__</code>,
6866: <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
6867: are all defined, you know that you are using NetBSD on an i386
6868: compatible CPU, and your compiler is GCC.</p>
6869: <p>The list of the following macros for hardware and
6870: operating system depends on the compiler that is used. For
6871: example, if you want to conditionally compile code on Solaris,
6872: don't use <code class="varname">__sun__</code>, as the SunPro compiler
6873: does not define it. Use <code class="varname">__sun</code> instead.</p>
1.75 rillig 6874: <div class="sect3" lang="en">
6875: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 6876: <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 6877: <p>To distinguish between 4.4 BSD-derived systems and the
6878: rest of the world, you should use the following code.</p>
6879: <pre class="programlisting">
6880: #include <sys/param.h>
6881: #if (defined(BSD) && BSD >= 199306)
6882: /* BSD-specific code goes here */
6883: #else
6884: /* non-BSD-specific code goes here */
6885: #endif
6886: </pre>
1.77 rillig 6887: <p>If this distinction is not fine enough, you can also test
6888: for the following macros.</p>
1.75 rillig 6889: <pre class="programlisting">
6890: FreeBSD __FreeBSD__
6891: DragonFly __DragonFly__
6892: Interix __INTERIX
6893: Linux linux, __linux, __linux__
6894: NetBSD __NetBSD__
6895: OpenBSD __OpenBSD__
6896: Solaris sun, __sun
6897: </pre>
6898: </div>
6899: <div class="sect3" lang="en">
6900: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 6901: <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 6902: <pre class="programlisting">
6903: i386 i386, __i386, __i386__
6904: MIPS __mips
6905: SPARC sparc, __sparc
6906: </pre>
6907: </div>
6908: <div class="sect3" lang="en">
6909: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 6910: <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 6911: <pre class="programlisting">
6912: GCC __GNUC__ (major version), __GNUC_MINOR__
6913: SunPro __SUNPRO_C (0x570 for version 5.7)
6914: </pre>
6915: </div>
6916: </div>
1.78 rillig 6917: <div class="sect2" lang="en">
6918: <div class="titlepage"><div><div><h3 class="title">
6919: <a name="compiler-bugs"></a>17.4.2. How to handle compiler bugs</h3></div></div></div>
6920: <p>Some source files trigger bugs in the compiler, based on
6921: combinations of compiler version and architecture and almost
6922: always relation to optimisation being enabled. Common symptoms
6923: are gcc internal errors or never finishing compiling a
6924: file.</p>
6925: <p>Typically, a workaround involves testing the
6926: <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
6927: optimisation for that combination of file,
6928: <code class="varname">MACHINE_ARCH</code> and compiler, and documenting it
6929: in <code class="filename">pkgsrc/doc/HACKS</code>. See that file for a
6930: number of examples.</p>
6931: </div>
6932: <div class="sect2" lang="en">
6933: <div class="titlepage"><div><div><h3 class="title">
6934: <a name="undefined-reference"></a>17.4.3. Undefined reference to “<span class="quote">...</span>”</h3></div></div></div>
6935: <p>This compiler error often means that a package did not
6936: link to a shared library it needs. The following functions are
6937: known to cause this error message over and over.</p>
6938: <div class="informaltable">
6939: <a name="undefined-reference-functions"></a><table border="1">
6940: <colgroup>
6941: <col>
6942: <col>
6943: <col>
6944: </colgroup>
6945: <thead><tr>
6946: <th>Function</th>
6947: <th>Library</th>
6948: <th>Affected platforms</th>
6949: </tr></thead>
6950: <tbody>
6951: <tr>
6952: <td>accept, bind, connect</td>
6953: <td>-lsocket</td>
6954: <td>Solaris</td>
6955: </tr>
6956: <tr>
6957: <td>crypt</td>
6958: <td>-lcrypt</td>
6959: <td>DragonFly, NetBSD</td>
6960: </tr>
6961: <tr>
6962: <td>dlopen, dlsym</td>
6963: <td>-ldl</td>
6964: <td>Linux</td>
6965: </tr>
6966: <tr>
6967: <td>gethost*</td>
6968: <td>-lnsl</td>
6969: <td>Solaris</td>
6970: </tr>
6971: <tr>
6972: <td>inet_aton</td>
6973: <td>-lresolv</td>
6974: <td>Solaris</td>
6975: </tr>
6976: <tr>
6977: <td>nanosleep, sem_*, timer_*</td>
6978: <td>-lrt</td>
6979: <td>Solaris</td>
6980: </tr>
6981: <tr>
6982: <td>openpty</td>
6983: <td>-lutil</td>
6984: <td>Linux</td>
6985: </tr>
6986: </tbody>
6987: </table>
6988: </div>
6989: <p>To fix these linker errors, it is often sufficient to say
6990: <code class="literal">LIBS.<em class="replaceable"><code>OperatingSystem</code></em>+=
6991: -l<em class="replaceable"><code>foo</code></em></code> to the package
6992: <code class="filename">Makefile</code> and then say <span><strong class="command">bmake clean;
6993: bmake</strong></span>.</p>
6994: </div>
1.75 rillig 6995: </div>
6996: <div class="sect1" lang="en">
6997: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 6998: <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 6999: <div class="sect2" lang="en">
7000: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7001: <a name="install-scripts"></a>17.5.1. Creating needed directories</h3></div></div></div>
7002: <p>The BSD-compatible <span><strong class="command">install</strong></span> supplied
7003: with some operating systems cannot create more than one
7004: directory at a time. As such, you should call
7005: <code class="literal">${INSTALL_*_DIR}</code> like this:</p>
1.75 rillig 7006: <pre class="programlisting">
1.78 rillig 7007: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
7008: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
1.75 rillig 7009: </pre>
1.78 rillig 7010: <p>You can also just append “<span class="quote"><code class="literal">dir1
7011: dir2</code></span>” to the
7012: <code class="varname">INSTALLATION_DIRS</code> variable, which will
7013: automatically do the right thing.</p>
1.75 rillig 7014: </div>
7015: <div class="sect2" lang="en">
7016: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7017: <a name="where-to-install-documentation"></a>17.5.2. Where to install documentation</h3></div></div></div>
7018: <p>Documentation should be installed into
7019: <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
7020: <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the latter
7021: includes the version number of the package).</p>
1.75 rillig 7022: </div>
7023: <div class="sect2" lang="en">
7024: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7025: <a name="installing-score-files"></a>17.5.3. Installing score files</h3></div></div></div>
1.75 rillig 7026: <p>Certain packages, most of them in the games category, install
7027: a score file that allows all users on the system to record their
7028: highscores. In order for this to work, the binaries need to be
7029: installed setgid and the score files owned by the appropriate
7030: group and/or owner (traditionally the "games" user/group). The
7031: following variables, documented in more detail in
1.76 rillig 7032: <code class="filename">mk/defaults/mk.conf</code>, control this
1.75 rillig 7033: behaviour: <code class="varname">SETGIDGAME</code>,
7034: <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
7035: <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
7036: <p>Note that per default, setgid installation of games is
7037: disabled; setting <code class="varname">SETGIDGAME=YES</code> will set all
7038: the other variables accordingly.</p>
7039: <p>A package should therefor never hard code file ownership or
7040: access permissions but rely on <code class="varname">INSTALL_GAME</code> and
7041: <code class="varname">INSTALL_GAME_DATA</code> to set these
7042: correctly.</p>
7043: </div>
7044: <div class="sect2" lang="en">
7045: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7046: <a name="perl-scripts"></a>17.5.4. Packages containing perl scripts</h3></div></div></div>
1.75 rillig 7047: <p>
7048: If your package contains interpreted perl scripts, set
7049: <code class="varname">REPLACE_PERL</code> to ensure that the proper
7050: interpreter path is set. <code class="varname">REPLACE_PERL</code> should
7051: contain a list of scripts, relative to
7052: <code class="varname">WRKSRC</code>, that you want adjusted.</p>
7053: </div>
7054: <div class="sect2" lang="en">
7055: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7056: <a name="hardcoded-paths"></a>17.5.5. Packages with hardcoded paths to other interpreters</h3></div></div></div>
1.75 rillig 7057: <p>
7058: Your package may also contain scripts with hardcoded paths to
7059: other interpreters besides (or as well as) perl. To correct the
7060: full pathname to the script interpreter, you need to set the
1.76 rillig 7061: following definitions in your <code class="filename">Makefile</code> (we
1.75 rillig 7062: shall use <span><strong class="command">tclsh</strong></span> in this example):</p>
7063: <pre class="programlisting">
7064: REPLACE_INTERPRETER+= tcl
7065: REPLACE.tcl.old= .*/bin/tclsh
7066: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
7067: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
7068: # relative to ${WRKSRC}, just as in REPLACE_PERL
7069: </pre>
7070: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7071: <h3 class="title">Note</h3>
7072: <p>Before March 2006, these variables were called
7073: <code class="varname">_REPLACE.*</code> and
7074: <code class="varname">_REPLACE_FILES.*</code>.</p>
7075: </div>
7076: </div>
7077: <div class="sect2" lang="en">
7078: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7079: <a name="perl-modules"></a>17.5.6. Packages installing perl modules</h3></div></div></div>
1.75 rillig 7080: <p>Makefiles of packages providing perl5 modules should include
7081: the Makefile fragment
1.76 rillig 7082: <code class="filename">../../lang/perl5/module.mk</code>. It provides a
1.75 rillig 7083: <span><strong class="command">do-configure</strong></span> target for the standard perl
7084: configuration for such modules as well as various hooks to tune
7085: this configuration. See comments in this file for
7086: details.</p>
7087: <p>Perl5 modules will install into different places depending
7088: on the version of perl used during the build process. To
7089: address this, pkgsrc will append lines to the
1.76 rillig 7090: <code class="filename">PLIST</code> corresponding to the files listed in
7091: the installed <code class="filename">.packlist</code> file generated by
1.75 rillig 7092: most perl5 modules. This is invoked by defining
7093: <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
7094: paths to packlist files, e.g.:</p>
7095: <pre class="programlisting">
7096: PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
7097: </pre>
7098: <p>The variables <code class="varname">PERL5_SITELIB</code>,
7099: <code class="varname">PERL5_SITEARCH</code>, and
7100: <code class="varname">PERL5_ARCHLIB</code> represent the three locations
7101: in which perl5 modules may be installed, and may be used by
7102: perl5 packages that don't have a packlist. These three
7103: variables are also substituted for in the
1.76 rillig 7104: <code class="filename">PLIST</code>.</p>
1.75 rillig 7105: </div>
7106: <div class="sect2" lang="en">
7107: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7108: <a name="faq.info-files"></a>17.5.7. Packages installing info files</h3></div></div></div>
1.75 rillig 7109: <p>Some packages install info files or use the
7110: “<span class="quote">makeinfo</span>” or “<span class="quote">install-info</span>”
7111: commands. <code class="varname">INFO_FILES</code> should be defined in
1.76 rillig 7112: the package Makefile so that <code class="filename">INSTALL</code> and
7113: <code class="filename">DEINSTALL</code> scripts will be generated to
1.75 rillig 7114: handle registration of the info files in the Info directory
7115: file. The “<span class="quote">install-info</span>” command used for the info
7116: files registration is either provided by the system, or by a
7117: special purpose package automatically added as dependency if
7118: needed.</p>
7119: <p><code class="varname">PKGINFODIR</code> is the directory under
1.76 rillig 7120: <code class="filename">${PREFIX}</code> where info files are primarily
1.75 rillig 7121: located. <code class="varname">PKGINFODIR</code> defaults to
7122: “<span class="quote">info</span>” and can be overridden by the user.</p>
7123: <p>The info files for the package should be listed in the
1.76 rillig 7124: package <code class="filename">PLIST</code>; however any split info files
1.75 rillig 7125: need not be listed.</p>
7126: <p>A package which needs the “<span class="quote">makeinfo</span>” command
7127: at build time must add “<span class="quote">makeinfo</span>” to
7128: <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
7129: version of the “<span class="quote">makeinfo</span>” command is needed it
7130: should be noted with the <code class="varname">TEXINFO_REQD</code>
1.76 rillig 7131: variable in the package <code class="filename">Makefile</code>. By
1.75 rillig 7132: default, a minimum version of 3.12 is required. If the system
7133: does not provide a <span><strong class="command">makeinfo</strong></span> command or if it
7134: does not match the required minimum, a build dependency on the
1.76 rillig 7135: <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 7136: be added automatically.</p>
7137: <p>The build and installation process of the software provided
7138: by the package should not use the
7139: <span><strong class="command">install-info</strong></span> command as the registration of
7140: info files is the task of the package
1.76 rillig 7141: <code class="filename">INSTALL</code> script, and it must use the
1.75 rillig 7142: appropriate <span><strong class="command">makeinfo</strong></span> command.</p>
7143: <p>To achieve this goal, the pkgsrc infrastructure creates
7144: overriding scripts for the <span><strong class="command">install-info</strong></span> and
7145: <span><strong class="command">makeinfo</strong></span> commands in a directory listed early
7146: in <code class="varname">PATH</code>.</p>
7147: <p>The script overriding <span><strong class="command">install-info</strong></span> has
7148: no effect except the logging of a message. The script overriding
7149: <span><strong class="command">makeinfo</strong></span> logs a message and according to the
7150: value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
7151: <span><strong class="command">makeinfo</strong></span> command or exit on error.</p>
7152: </div>
7153: <div class="sect2" lang="en">
7154: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7155: <a name="manpages"></a>17.5.8. Packages installing man pages</h3></div></div></div>
1.75 rillig 7156: <p>Many packages install manual pages. The man pages
7157: are installed under <code class="varname">${PREFIX}/${PKGMANDIR}</code>
1.76 rillig 7158: which is <code class="filename">/usr/pkg/man</code> by default.
1.75 rillig 7159: <code class="varname">PKGMANDIR</code> defaults to “<span class="quote">man</span>”.
7160: For example, you can set <code class="varname">PKGMANDIR</code> to
7161: “<span class="quote">share/man</span>” to have man pages install under
1.76 rillig 7162: <code class="filename">/usr/pkg/share/man/</code> by default.
1.75 rillig 7163: </p>
7164: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7165: <h3 class="title">Note</h3>
7166: <p>The support for a custom <code class="varname">PKGMANDIR</code>
7167: is not complete.
7168: </p>
7169: </div>
1.76 rillig 7170: <p>The <code class="filename">PLIST</code> files can just
7171: use <code class="filename">man/</code> as the top level directory
1.75 rillig 7172: for the man page file entries
7173: and the pkgsrc framework will convert as needed.
7174: </p>
7175: <p> Packages that are
7176: configured with <code class="varname">GNU_CONFIGURE</code> set as
7177: “<span class="quote">yes</span>”, by default will use the
1.76 rillig 7178: <code class="filename">./configure</code>
1.75 rillig 7179: --mandir switch to set where the man pages should be installed.
7180: The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
7181: to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.
7182: </p>
7183: <p>
7184: Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
7185: use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
7186: to “<span class="quote">no</span>”.
1.76 rillig 7187: Or if the <code class="filename">./configure</code> script uses
1.75 rillig 7188: a non-standard use of --mandir, you can set
7189: <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.
7190: </p>
1.77 rillig 7191: <p>See <a href="#manpage-compression" title="11.5. Man page compression">Section 11.5, “Man page compression”</a> for
1.75 rillig 7192: information on installation of compressed manual pages.
7193: </p>
7194: </div>
7195: <div class="sect2" lang="en">
7196: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7197: <a name="gconf2-data-files"></a>17.5.9. Packages installing GConf2 data files</h3></div></div></div>
1.75 rillig 7198: <p>
1.76 rillig 7199: If a package installs <code class="filename">.schemas</code> or
7200: <code class="filename">.entries</code> files, used by GConf2,
1.75 rillig 7201: you need to take some extra steps to make sure they get registered
7202: in the database:
7203: </p>
7204: <div class="orderedlist"><ol type="1">
1.76 rillig 7205: <li><p>Include <code class="filename">../../devel/GConf2/schemas.mk</code>
7206: instead of its <code class="filename">buildlink3.mk</code> file. This
1.75 rillig 7207: takes care of rebuilding the GConf2 database at installation and
7208: deinstallation time, and tells the package where to install
7209: GConf2 data files using some standard configure arguments. It
7210: also disallows any access to the database directly from the
7211: package.</p></li>
7212: <li><p>Ensure that the package installs its
1.76 rillig 7213: <code class="filename">.schemas</code> files under
7214: <code class="filename">${PREFIX}/share/gconf/schemas</code>. If they get
7215: installed under <code class="filename">${PREFIX}/etc</code>, you will
1.75 rillig 7216: need to manually patch the package.</p></li>
7217: <li><p>Check the PLIST and remove any entries under the etc/gconf
7218: directory, as they will be handled automatically. See
7219: <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>
7220: <li><p>Define the <code class="varname">GCONF2_SCHEMAS</code> variable in
1.76 rillig 7221: your <code class="filename">Makefile</code> with a list of all
7222: <code class="filename">.schemas</code> files installed by the package, if
1.75 rillig 7223: any. Names must not contain any directories in them.</p></li>
7224: <li><p>Define the <code class="varname">GCONF2_ENTRIES</code> variable in
1.76 rillig 7225: your <code class="filename">Makefile</code> with a
7226: list of all <code class="filename">.entries</code> files installed by the
1.75 rillig 7227: package, if any. Names must not contain any directories in
7228: them.</p></li>
7229: </ol></div>
7230: </div>
7231: <div class="sect2" lang="en">
7232: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7233: <a name="scrollkeeper-data-files"></a>17.5.10. Packages installing scrollkeeper data files</h3></div></div></div>
1.75 rillig 7234: <p>
1.76 rillig 7235: If a package installs <code class="filename">.omf</code> files, used by
1.75 rillig 7236: scrollkeeper, you need to take some extra steps to make sure they
7237: get registered in the database:
7238: </p>
7239: <div class="orderedlist"><ol type="1">
7240: <li><p>Include
1.76 rillig 7241: <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
7242: instead of its <code class="filename">buildlink3.mk</code> file. This
1.75 rillig 7243: takes care of rebuilding the scrollkeeper database at
7244: installation and deinstallation time, and disallows any access
7245: to it directly from the package.
7246: </p></li>
7247: <li><p>Check the PLIST and remove any entries under the
1.76 rillig 7248: <code class="filename">libdata/scrollkeeper</code> directory, as they
1.75 rillig 7249: will be handled automatically.</p></li>
1.76 rillig 7250: <li><p>Remove the <code class="filename">share/omf</code> directory from
1.75 rillig 7251: the PLIST. It will be handled by scrollkeeper.</p></li>
7252: </ol></div>
7253: </div>
7254: <div class="sect2" lang="en">
7255: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7256: <a name="x11-fonts"></a>17.5.11. Packages installing X11 fonts</h3></div></div></div>
1.75 rillig 7257: <p>If a package installs font files, you will need to rebuild
7258: the fonts database in the directory where they get installed at
7259: installation and deinstallation time. This can be automatically
7260: done by using the pkginstall framework.</p>
7261: <p>You can list the directories where fonts are installed in the
7262: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
7263: variables, where <em class="replaceable"><code>type</code></em> can be one of
7264: “<span class="quote">ttf</span>”, “<span class="quote">type1</span>” or “<span class="quote">x11</span>”.
7265: Also make sure that the database file
1.76 rillig 7266: <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
1.75 rillig 7267: <p>Note that you should not create new directories for fonts;
7268: instead use the standard ones to avoid that the user needs to
7269: manually configure his X server to find them.</p>
7270: </div>
7271: <div class="sect2" lang="en">
7272: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7273: <a name="gtk2-modules"></a>17.5.12. Packages installing GTK2 modules</h3></div></div></div>
1.75 rillig 7274: <p>If a package installs GTK2 immodules or loaders, you need to
7275: take some extra steps to get them registered in the GTK2 database
7276: properly:</p>
7277: <div class="orderedlist"><ol type="1">
7278: <li><p>Include
1.76 rillig 7279: <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
7280: <code class="filename">buildlink3.mk</code> file. This takes care of
1.75 rillig 7281: rebuilding the database at installation and deinstallation time.
7282: </p></li>
7283: <li><p>
7284: Set <code class="varname">GTK2_IMMODULES=YES</code> if
7285: your package installs GTK2 immodules.</p></li>
7286: <li><p>
7287: Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
7288: GTK2 loaders.</p></li>
7289: <li>
7290: <p>
7291: Patch the package to not touch any of the GTK2 databases directly.
7292: These are:
7293:
7294: </p>
7295: <div class="itemizedlist"><ul type="disc">
1.76 rillig 7296: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
7297: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
1.75 rillig 7298: </ul></div>
7299: <p>
7300: </p>
7301: </li>
7302: <li><p>
7303: Check the PLIST and remove any entries under the
1.76 rillig 7304: <code class="filename">libdata/gtk-2.0</code> directory, as they will be
1.75 rillig 7305: handled automatically.</p></li>
7306: </ol></div>
7307: </div>
7308: <div class="sect2" lang="en">
7309: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7310: <a name="sgml-xml-data"></a>17.5.13. Packages installing SGML or XML data</h3></div></div></div>
1.75 rillig 7311: <p>If a package installs SGML or XML data files that need to be
7312: registered in system-wide catalogs (like DTDs, sub-catalogs,
7313: etc.), you need to take some extra steps:
7314: </p>
7315: <div class="orderedlist"><ol type="1">
7316: <li><p>Include
1.76 rillig 7317: <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
7318: your <code class="filename">Makefile</code>, which takes care of
1.75 rillig 7319: registering those files in system-wide catalogs at
7320: installation and deinstallation time.</p></li>
7321: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
7322: any SGML catalogs installed by the package.</p></li>
7323: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
7324: any XML catalogs installed by the package.</p></li>
7325: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
7326: to be added to the SGML catalog. These come in groups of
7327: three strings; see xmlcatmgr(1) for more information
7328: (specifically, arguments recognized by the 'add' action).
7329: Note that you will normally not use this variable.</p></li>
7330: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
7331: to be added to the XML catalog. These come in groups of three
7332: strings; see xmlcatmgr(1) for more information (specifically,
7333: arguments recognized by the 'add' action). Note that you will
7334: normally not use this variable.
7335: </p></li>
7336: </ol></div>
7337: </div>
7338: <div class="sect2" lang="en">
7339: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7340: <a name="mime-database"></a>17.5.14. Packages installing extensions to the MIME database</h3></div></div></div>
1.75 rillig 7341: <p>If a package provides extensions to the MIME database by
1.76 rillig 7342: installing <code class="filename">.xml</code> files inside
7343: <code class="filename">${PREFIX}/share/mime/packages</code>, you
1.75 rillig 7344: need to take some extra steps to ensure that the database is kept
7345: consistent with respect to these new files:
7346: </p>
7347: <div class="orderedlist"><ol type="1">
7348: <li><p>Include
1.76 rillig 7349: <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
7350: (avoid using the <code class="filename">buildlink3.mk</code> file from
1.75 rillig 7351: this same directory, which is reserved for inclusion from
1.76 rillig 7352: other <code class="filename">buildlink3.mk</code> files). It takes
1.75 rillig 7353: care of rebuilding the MIME database at installation and
7354: deinstallation time, and disallows any access to it directly
7355: from the package.</p></li>
7356: <li><p>Check the PLIST and remove any entries under the
1.76 rillig 7357: <code class="filename">share/mime</code> directory,
1.75 rillig 7358: <span class="emphasis"><em>except</em></span> for files saved under
1.76 rillig 7359: <code class="filename">share/mime/packages</code>. The former are
1.75 rillig 7360: handled automatically by
7361: the update-mime-database program, but the latter are
7362: package-dependent and must be removed by the package that
7363: installed them in the first place.</p></li>
1.76 rillig 7364: <li><p>Remove any <code class="filename">share/mime/*</code> directories
1.75 rillig 7365: from the PLIST. They will be handled by the shared-mime-info
7366: package.</p></li>
7367: </ol></div>
7368: </div>
7369: <div class="sect2" lang="en">
7370: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7371: <a name="intltool"></a>17.5.15. Packages using intltool</h3></div></div></div>
1.75 rillig 7372: <p>If a package uses intltool during its build, include the
1.76 rillig 7373: <code class="filename">../../textproc/intltool/buildlink3.mk</code> file,
1.75 rillig 7374: which forces it to use the intltool package provided by pkgsrc,
7375: instead of the one bundled with the distribution file.
7376: </p>
7377: <p>This tracks intltool's build-time dependencies and uses the
7378: latest available version; this way, the package benefits of any
7379: bug fixes that may have appeared since it was released.
7380: </p>
7381: </div>
7382: <div class="sect2" lang="en">
7383: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7384: <a name="startup-scripts"></a>17.5.16. Packages installing startup scripts</h3></div></div></div>
1.75 rillig 7385: <p>If a package contains a rc.d script, it won't be copied into
7386: the startup directory by default, but you can enable it, by adding
7387: the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
1.76 rillig 7388: <code class="filename">/etc/mk.conf</code>. This option will copy the scripts
7389: into <code class="filename">/etc/rc.d</code> when a package is installed, and
1.75 rillig 7390: it will automatically remove the scripts when the package is
7391: deinstalled.</p>
7392: </div>
7393: <div class="sect2" lang="en">
7394: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7395: <a name="tex-packages"></a>17.5.17. Packages installing TeX modules</h3></div></div></div>
1.75 rillig 7396: <p>If a package installs TeX packages into the texmf tree,
1.76 rillig 7397: the <code class="filename">ls-R</code> database of the tree needs to be
1.75 rillig 7398: updated.</p>
7399: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7400: <h3 class="title">Note</h3>
7401: <p>Except the main TeX packages such as teTeX-texmf,
7402: packages should install files
7403: into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
7404: not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
7405: </div>
7406: <div class="orderedlist"><ol type="1">
7407: <li><p>Include
1.76 rillig 7408: <code class="filename">../../print/teTeX/module.mk</code> instead
7409: of <code class="filename">../../mk/tex.buildlink3.mk</code>. This
7410: takes care of rebuilding the <code class="filename">ls-R</code>
1.75 rillig 7411: database at installation and deinstallation time.</p></li>
7412: <li>
7413: <p>If your package installs files into a texmf
7414: tree other than the one
7415: at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
7416: set <code class="varname">TEXMFDIRS</code> to the list of all texmf
7417: trees that need database update.</p>
7418: <p>If your package also installs font map files that need
7419: to be registered using <span><strong class="command">updmap</strong></span>,
7420: set <code class="varname">TEX_FONTMAPS</code> to the list of all
7421: such font map files. Then <span><strong class="command">updmap</strong></span> will
7422: be run automatically at installation/deinstallation to
7423: enable/disable font map files for TeX output
7424: drivers.</p>
7425: </li>
1.76 rillig 7426: <li><p>Make sure that none of <code class="filename">ls-R</code>
7427: databases are included in <code class="filename">PLIST</code>, as
1.75 rillig 7428: they will be removed only by the teTeX-bin package.</p></li>
7429: </ol></div>
7430: </div>
7431: </div>
7432: <div class="sect1" lang="en">
7433: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 7434: <a name="feedback-to-author"></a>17.6. Feedback to the author</h2></div></div></div>
1.75 rillig 7435: <p>If you have found any bugs in the package you make available,
7436: if you had to do special steps to make it run under NetBSD or
7437: if you enhanced the software in various other ways, be sure
7438: to report these changes back to the original author of the
7439: program! With that kind of support, the next release of the
7440: program can incorporate these fixes, and people not using the
7441: NetBSD packages system can win from your efforts.</p>
7442: <p>Support the idea of free software!</p>
7443: </div>
7444: </div>
7445: <div class="chapter" lang="en">
7446: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7447: <a name="debug"></a>Chapter 18. Debugging</h2></div></div></div>
1.75 rillig 7448: <p>To check out all the gotchas when building a package, here are the steps
7449: that I do in order to get a package working. Please note this is basically
7450: the same as what was explained in the previous sections, only with some
7451: debugging aids.</p>
7452: <div class="itemizedlist"><ul type="disc">
7453: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=1</code>
1.76 rillig 7454: in <code class="filename">/etc/mk.conf</code></p></li>
1.75 rillig 7455: <li>
1.76 rillig 7456: <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 7457: create a directory for a new package, change into it, then run
7458: <span><strong class="command">url2pkg</strong></span>:</p>
7459: <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>
7460: <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>
7461: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
7462: </li>
1.76 rillig 7463: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
7464: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.75 rillig 7465: <li><p>Run <span><strong class="command">make configure</strong></span>
7466: </p></li>
7467: <li><p>Add any dependencies glimpsed from documentation and the
7468: configure step to the package's
1.76 rillig 7469: <code class="filename">Makefile</code>.</p></li>
1.75 rillig 7470: <li>
7471: <p>Make the package compile, doing multiple rounds of</p>
7472: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
7473: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
7474: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
7475: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
7476: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
7477: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
7478: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
7479: <p>Doing as non-root user will ensure that no files are modified that
7480: shouldn't be, especially during the build
7481: phase. <span><strong class="command">mkpatches</strong></span>,
7482: <span><strong class="command">patchdiff</strong></span> and <span><strong class="command">pkgvi</strong></span> are
1.76 rillig 7483: 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 7484: package. </p>
7485: </li>
1.76 rillig 7486: <li><p>Look at the <code class="filename">Makefile</code>, fix if necessary;
1.77 rillig 7487: see <a href="#components.Makefile" title="9.1. Makefile">Section 9.1, “<code class="filename">Makefile</code>”</a>.</p></li>
1.75 rillig 7488: <li>
1.76 rillig 7489: <p>Generate a <code class="filename">PLIST</code>:</p>
1.75 rillig 7490: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
7491: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST >PLIST</code></strong>
7492: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
7493: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
7494: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
1.76 rillig 7495: <p>You usually need to be <code class="username">root</code> to do this.
1.75 rillig 7496: Look if there are any files left:</p>
7497: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
7498: <p>If this reveals any files that are missing in
1.76 rillig 7499: <code class="filename">PLIST</code>, add them.</p>
1.75 rillig 7500: </li>
7501: <li>
1.76 rillig 7502: <p>Now that the <code class="filename">PLIST</code> is OK,
1.75 rillig 7503: install the package again and make a binary package:</p>
7504: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
7505: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
7506: </li>
7507: <li>
7508: <p>Delete the installed package:</p>
7509: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete blub</code></strong></pre>
7510: </li>
7511: <li>
7512: <p>Repeat the above <span><strong class="command">make print-PLIST</strong></span> command,
7513: which shouldn't find anything now:</p>
7514: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
7515: </li>
7516: <li>
7517: <p>Reinstall the binary package:</p>
7518: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkgadd .../blub.tgz</code></strong></pre>
7519: </li>
7520: <li><p>Play with it. Make sure everything works.</p></li>
7521: <li>
7522: <p>Run <span><strong class="command">pkglint</strong></span> from
1.76 rillig 7523: <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 7524: and fix the problems it reports:</p>
7525: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
7526: </li>
7527: <li><p>Submit (or commit, if you have cvs access);
1.77 rillig 7528: see <a href="#submit" title="Chapter 19. Submitting and Committing">Chapter 19, <i>Submitting and Committing</i></a>.</p></li>
1.75 rillig 7529: </ul></div>
7530: </div>
7531: <div class="chapter" lang="en">
7532: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7533: <a name="submit"></a>Chapter 19. Submitting and Committing</h2></div></div></div>
1.75 rillig 7534: <div class="toc">
7535: <p><b>Table of Contents</b></p>
7536: <dl>
1.77 rillig 7537: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
7538: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
7539: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
7540: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
7541: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
7542: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 7543: </dl>
7544: </div>
7545: <div class="sect1" lang="en">
7546: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7547: <a name="submitting-binary-packages"></a>19.1. Submitting binary packages</h2></div></div></div>
1.75 rillig 7548: <p>Our policy is that we accept binaries only from pkgsrc
7549: developers to guarantee that the packages don't contain any
7550: trojan horses etc. This is not to annoy anyone but rather to
7551: protect our users! You're still free to put up your home-made
7552: binary packages and tell the world where to get them. NetBSD
7553: developers doing bulk builds and wanting to upload them please
7554: 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>
7555: </div>
7556: <div class="sect1" lang="en">
7557: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7558: <a name="submitting-your-package"></a>19.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
1.75 rillig 7559: <p>First, check that your package is complete, compiles and
1.77 rillig 7560: runs well; see <a href="#debug" title="Chapter 18. Debugging">Chapter 18, <i>Debugging</i></a> and the rest of this
1.75 rillig 7561: 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>
7562: archive, preferably with all files in a single directory.
7563: Finally, <span><strong class="command">send-pr</strong></span> with category
7564: “<span class="quote">pkg</span>”, a synopsis which includes the package name
7565: and version number, a short description of your package
7566: (contents of the COMMENT variable or DESCR file are OK) and
7567: attach the archive to your PR.</p>
7568: <p>If you want to submit several packages, please send a
7569: separate PR for each one, it's easier for us to track things
7570: that way.</p>
7571: <p>Alternatively, you can also import new packages into
7572: pkgsrc-wip (“<span class="quote">pkgsrc work-in-progress</span>”); see the
7573: homepage at <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
7574: for details.</p>
7575: </div>
7576: <div class="sect1" lang="en">
7577: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7578: <a name="general-notes-for-changes"></a>19.3. General notes when adding, updating, or removing packages</h2></div></div></div>
1.75 rillig 7579: <p>Please note all package additions, updates, moves, and
1.76 rillig 7580: removals in <code class="filename">pkgsrc/doc/CHANGES</code>. It's very
1.75 rillig 7581: important to keep this file up to date and conforming to the
7582: existing format, because it will be used by scripts to
7583: automatically update pages on <a href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
7584: sites. Additionally, check the
1.76 rillig 7585: <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
1.75 rillig 7586: for the package you updated or removed, in case it was mentioned
7587: there.</p>
7588: <p>When the <code class="varname">PKGREVISION</code> of a package is
7589: bumped, the change should appear in
1.76 rillig 7590: <code class="filename">pkgsrc/doc/CHANGES</code> if it is security
1.75 rillig 7591: related or otherwise relevant. Mass bumps that result from a
7592: dependency being updated should not be mentioned. In all other
7593: cases it's the developer's decision.</p>
7594: <p>There is a make target that helps in creating proper
1.76 rillig 7595: <code class="filename">CHANGES</code> entries: <span><strong class="command">make
1.75 rillig 7596: changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
7597: and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
1.76 rillig 7598: usage is to first make sure that your <code class="filename">CHANGES</code>
1.75 rillig 7599: file is up-to-date (to avoid having to resolve conflicts later-on)
7600: and then to <span><strong class="command">cd</strong></span> to the package directory. For
7601: package updates, <span><strong class="command">make changes-entry</strong></span> is enough.
7602: For new packages, or package moves or removals, set the
7603: <code class="varname">CTYPE</code> variable on the command line to "Added",
7604: "Moved", or "Removed". You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.76 rillig 7605: in <code class="filename">/etc/mk.conf</code> if your local login name is
1.75 rillig 7606: not the same as your NetBSD login name. Don't forget to commit
1.76 rillig 7607: the changes to <code class="filename">pkgsrc/doc/CHANGES</code>!</p>
1.75 rillig 7608: </div>
7609: <div class="sect1" lang="en">
7610: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7611: <a name="committing-importing"></a>19.4. Committing: Importing a package into CVS</h2></div></div></div>
1.75 rillig 7612: <p>
7613: This section is only of interest for pkgsrc developers with write
7614: access to the pkgsrc repository. Please remember that cvs
7615: imports files relative to the current working directory, and that
7616: the pathname that you
7617: give the <span><strong class="command">cvs import</strong></span> command is so that it knows where
7618: to place the files in the repository. Newly created packages should be
7619: imported with a vendor tag of “<span class="quote">TNF</span>” and a release tag of
7620: “<span class="quote">pkgsrc-base</span>”, e.g:
7621: </p>
7622: <pre class="programlisting">
7623: <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
7624: <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
7625: </pre>
7626: <p>
7627: Remember to move the directory from which you imported out of
7628: the way, or cvs will complain the next time you “<span class="quote">cvs
7629: update</span>” your source tree. Also don't forget to add the new
1.76 rillig 7630: package to the category's <code class="filename">Makefile</code>.
1.75 rillig 7631: </p>
7632: <p>
7633: The commit message of the initial import should include part of the
1.76 rillig 7634: <code class="filename">DESCR</code> file, so people reading the mailing lists know
1.75 rillig 7635: what the package is/does.
7636: </p>
7637: <p>
7638: For new packages, “<span class="quote">cvs import</span>” is preferred to “<span class="quote">cvs
7639: add</span>” because the former gets everything with a single command,
7640: and provides a consistent tag.
7641: </p>
7642: </div>
7643: <div class="sect1" lang="en">
7644: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7645: <a name="updating-package"></a>19.5. Updating a package to a newer version</h2></div></div></div>
1.75 rillig 7646: <p>
7647: Please always put a concise, appropriate and relevant summary of the
7648: changes between old and new versions into the commit log when updating
7649: a package. There are various reasons for this:
7650: </p>
7651: <div class="itemizedlist"><ul type="disc">
7652: <li><p>
7653: A URL is volatile, and can change over time. It may go away completely
7654: or its information may be overwritten by newer information.
7655: </p></li>
7656: <li><p>
7657: Having the change information between old and new versions in our CVS
7658: repository is very useful for people who use either cvs or anoncvs.
7659: </p></li>
7660: <li><p>
7661: Having the change information between old and new versions in our CVS
7662: repository is very useful for people who read the pkgsrc-changes mailing
7663: list, so that they can make tactical decisions about when to upgrade
7664: the package.
7665: </p></li>
7666: </ul></div>
7667: <p>
7668: Please also recognize that, just because a new version of a package
7669: has been released, it should not automatically be upgraded in the CVS
7670: repository. We prefer to be conservative in the packages that are
7671: included in pkgsrc - development or beta packages are not really the
7672: best thing for most places in which pkgsrc is used. Please use your
7673: judgement about what should go into pkgsrc, and bear in mind that
7674: stability is to be preferred above new and possibly untested features.
7675: </p>
7676: </div>
7677: <div class="sect1" lang="en">
7678: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7679: <a name="moving-package"></a>19.6. Moving a package in pkgsrc</h2></div></div></div>
1.75 rillig 7680: <div class="orderedlist"><ol type="1">
7681: <li><p>Make a copy of the directory somewhere else.</p></li>
7682: <li>
7683: <p>Remove all CVS dirs.</p>
7684: <p>
7685: Alternatively to the first two steps you can also do:
7686: </p>
7687: <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>
7688: <p>
7689: and use that for further work.
7690: </p>
7691: </li>
7692: <li><p>Fix <code class="varname">CATEGORIES</code> and any
7693: <code class="varname">DEPENDS</code> paths that just did “<span class="quote">../package</span>”
7694: instead of “<span class="quote">../../category/package</span>”.</p></li>
7695: <li><p><span><strong class="command">cvs import</strong></span> the modified package in the new
7696: place.</p></li>
7697: <li>
7698: <p>Check if any package depends on it:
7699: </p>
7700: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
7701: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
7702: <p>
7703: </p>
7704: </li>
7705: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
7706: <li><p><span><strong class="command">cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.76 rillig 7707: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
7708: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
1.75 rillig 7709: <li>
7710: <p>Commit the changed and removed files:</p>
7711: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong></pre>
7712: <p>
7713: (and any packages from step 5, of course).
7714: </p>
7715: </li>
7716: </ol></div>
7717: </div>
7718: </div>
7719: <div class="chapter" lang="en">
7720: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7721: <a name="devfaq"></a>Chapter 20. Frequently Asked Questions</h2></div></div></div>
1.75 rillig 7722: <p>This section contains the answers to questions that may
7723: arise when you are writing a package. If you don't find your
7724: question answered here, first have a look in the other chapters,
7725: and if you still don't have the answer, ask on the
7726: <code class="literal">pkgsrc-users</code> mailing list.</p>
7727: <div class="qandaset">
7728: <dl>
1.79 ! rillig 7729: <dt>20.1. <a href="#id2655027">What is the difference between
1.75 rillig 7730: MAKEFLAGS, .MAKEFLAGS and
7731: MAKE_FLAGS?</a>
7732: </dt>
1.79 ! rillig 7733: <dt>20.2. <a href="#id2655063">What is the difference between
1.75 rillig 7734: MAKE, GMAKE and
7735: MAKE_PROGRAM?</a>
7736: </dt>
1.79 ! rillig 7737: <dt>20.3. <a href="#id2655101">What is the difference between
1.75 rillig 7738: CC, PKG_CC and
7739: PKGSRC_COMPILER?</a>
7740: </dt>
1.79 ! rillig 7741: <dt>20.4. <a href="#id2655139">What is the difference between
1.75 rillig 7742: BUILDLINK_LDFLAGS,
7743: BUILDLINK_LDADD and
7744: BUILDLINK_LIBS?</a>
7745: </dt>
1.79 ! rillig 7746: <dt>20.5. <a href="#id2655157">Why does make show-var
1.75 rillig 7747: VARNAME=BUILDLINK_PREFIX.foo
7748: say it's empty?</a>
7749: </dt>
1.79 ! rillig 7750: <dt>20.6. <a href="#id2655185">What does
1.78 rillig 7751: ${MASTER_SITE_SOURCEFORGE:=package/} mean? I
7752: don't understand the := inside
7753: it.</a>
7754: </dt>
1.79 ! rillig 7755: <dt>20.7. <a href="#id2655259">Which mailing lists are there for package
1.78 rillig 7756: developers?</a>
7757: </dt>
1.75 rillig 7758: </dl>
7759: <table border="0" summary="Q and A Set">
7760: <col align="left" width="1%">
7761: <tbody>
7762: <tr class="question">
7763: <td align="left" valign="top">
1.79 ! rillig 7764: <a name="id2655027"></a><a name="id2655028"></a><b>20.1.</b>
1.75 rillig 7765: </td>
7766: <td align="left" valign="top"><p>What is the difference between
7767: <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
7768: <code class="varname">MAKE_FLAGS</code>?</p></td>
7769: </tr>
7770: <tr class="answer">
7771: <td align="left" valign="top"><b></b></td>
7772: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
7773: 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
7774: <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
7775: the <code class="varname">MAKE_PROGRAM</code> when building the
7776: package. [FIXME: What is .MAKEFLAGS for?]</p></td>
7777: </tr>
7778: <tr class="question">
7779: <td align="left" valign="top">
1.79 ! rillig 7780: <a name="id2655063"></a><a name="id2655064"></a><b>20.2.</b>
1.75 rillig 7781: </td>
7782: <td align="left" valign="top"><p>What is the difference between
7783: <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
7784: <code class="varname">MAKE_PROGRAM</code>?</p></td>
7785: </tr>
7786: <tr class="answer">
7787: <td align="left" valign="top"><b></b></td>
7788: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
7789: <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
7790: infrastructure. <code class="varname">GMAKE</code> is the path to GNU
7791: Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
7792: use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
7793: Make program that is used for building the
7794: package.</p></td>
7795: </tr>
7796: <tr class="question">
7797: <td align="left" valign="top">
1.79 ! rillig 7798: <a name="id2655101"></a><a name="id2655102"></a><b>20.3.</b>
1.75 rillig 7799: </td>
7800: <td align="left" valign="top"><p>What is the difference between
7801: <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
7802: <code class="varname">PKGSRC_COMPILER</code>?</p></td>
7803: </tr>
7804: <tr class="answer">
7805: <td align="left" valign="top"><b></b></td>
7806: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
7807: compiler, which can be configured by the pkgsrc user.
7808: <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
7809: <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
7810: path to a compiler, but the type of compiler that should be
1.76 rillig 7811: used. See <code class="filename">mk/compiler.mk</code> for more
1.75 rillig 7812: information about the latter variable.</p></td>
7813: </tr>
7814: <tr class="question">
7815: <td align="left" valign="top">
1.79 ! rillig 7816: <a name="id2655139"></a><a name="id2655140"></a><b>20.4.</b>
1.75 rillig 7817: </td>
7818: <td align="left" valign="top"><p>What is the difference between
7819: <code class="varname">BUILDLINK_LDFLAGS</code>,
7820: <code class="varname">BUILDLINK_LDADD</code> and
7821: <code class="varname">BUILDLINK_LIBS</code>?</p></td>
7822: </tr>
7823: <tr class="answer">
7824: <td align="left" valign="top"><b></b></td>
7825: <td align="left" valign="top"><p>[FIXME]</p></td>
7826: </tr>
7827: <tr class="question">
7828: <td align="left" valign="top">
1.79 ! rillig 7829: <a name="id2655157"></a><a name="id2655158"></a><b>20.5.</b>
1.75 rillig 7830: </td>
7831: <td align="left" valign="top"><p>Why does <span><strong class="command">make show-var
7832: VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
7833: say it's empty?</p></td>
7834: </tr>
7835: <tr class="answer">
7836: <td align="left" valign="top"><b></b></td>
7837: <td align="left" valign="top"><p>For optimization reasons, some variables are only
7838: available in the “<span class="quote">wrapper</span>” phase and later. To
7839: “<span class="quote">simulate</span>” the wrapper phase, append
7840: <span><strong class="command">PKG_PHASE=wrapper</strong></span> to the above
7841: command.</p></td>
7842: </tr>
1.78 rillig 7843: <tr class="question">
7844: <td align="left" valign="top">
1.79 ! rillig 7845: <a name="id2655185"></a><a name="id2655186"></a><b>20.6.</b>
1.78 rillig 7846: </td>
7847: <td align="left" valign="top"><p>What does
7848: <code class="literal">${MASTER_SITE_SOURCEFORGE:=package/}</code> mean? I
7849: don't understand the <code class="literal">:=</code> inside
7850: it.</p></td>
7851: </tr>
7852: <tr class="answer">
7853: <td align="left" valign="top"><b></b></td>
7854: <td align="left" valign="top"><p>The <code class="literal">:=</code> is not really an
7855: assignment operator, like you might expect at first sight.
7856: Instead, it is a degenerate form of
7857: <code class="literal">${LIST:<em class="replaceable"><code>old_string</code></em>=<em class="replaceable"><code>new_string</code></em>}</code>,
7858: 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
7859: may have seen as in <code class="literal">${SRCS:.c=.o}</code>. In the
7860: case of <code class="varname">MASTER_SITE_*</code>,
7861: <em class="replaceable"><code>old_string</code></em> is the empty string and
7862: <em class="replaceable"><code>new_string</code></em> is
7863: <code class="literal">package/</code>. That's where the
7864: <code class="literal">:</code> and the <code class="literal">=</code> fall
7865: together.</p></td>
7866: </tr>
7867: <tr class="question">
7868: <td align="left" valign="top">
1.79 ! rillig 7869: <a name="id2655259"></a><a name="id2655260"></a><b>20.7.</b>
1.78 rillig 7870: </td>
7871: <td align="left" valign="top"><p>Which mailing lists are there for package
7872: developers?</p></td>
7873: </tr>
7874: <tr class="answer">
7875: <td align="left" valign="top"><b></b></td>
7876: <td align="left" valign="top"><div class="variablelist"><dl>
7877: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">tech-pkg</a></span></dt>
7878: <dd><p>This is a list for technical discussions related
7879: to pkgsrc development, e.g. soliciting feedback for changes to
7880: pkgsrc infrastructure, proposed new features, questions related
7881: to porting pkgsrc to a new platform, advice for maintaining a
7882: package, patches that affect many packages, help requests moved
7883: from pkgsrc-users when an infrastructure bug is found,
7884: etc.</p></dd>
7885: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a></span></dt>
7886: <dd><p>All bug reports in category "pkg" sent with
7887: <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
7888: directly; use one of the other mailing
7889: lists.</p></dd>
7890: </dl></div></td>
7891: </tr>
1.75 rillig 7892: </tbody>
7893: </table>
7894: </div>
7895: </div>
7896: </div>
7897: <div class="part" lang="en">
7898: <div class="titlepage"><div><div><h1 class="title">
7899: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
7900: <div class="partintro" lang="en">
7901: <div></div>
7902: <p>This part of the guide deals with everything
7903: from the infrastructure that is behind the interfaces described
7904: in the developer's guide. A casual package maintainer should not
7905: need anything from this part.</p>
7906: <div class="toc">
7907: <p><b>Table of Contents</b></p>
7908: <dl>
1.77 rillig 7909: <dt><span class="chapter"><a href="#infr.design">21. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 7910: <dd><dl>
1.77 rillig 7911: <dt><span class="sect1"><a href="#infr.var">21.1. Variable evaluation</a></span></dt>
1.75 rillig 7912: <dd><dl>
1.77 rillig 7913: <dt><span class="sect2"><a href="#infr.var.load">21.1.1. At load time</a></span></dt>
7914: <dt><span class="sect2"><a href="#infr.var.run">21.1.2. At runtime</a></span></dt>
1.75 rillig 7915: </dl></dd>
1.78 rillig 7916: <dt><span class="sect1"><a href="#infr.varspec">21.2. How can variables be specified?</a></span></dt>
7917: <dt><span class="sect1"><a href="#infr.design.intf">21.3. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 7918: <dd><dl>
1.78 rillig 7919: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.3.1. Procedures with parameters</a></span></dt>
7920: <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 7921: </dl></dd>
7922: </dl></dd>
1.77 rillig 7923: <dt><span class="chapter"><a href="#regression">22. Regression tests</a></span></dt>
1.75 rillig 7924: <dd><dl>
1.77 rillig 7925: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
7926: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
7927: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 7928: <dd><dl>
1.77 rillig 7929: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
7930: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 7931: </dl></dd>
7932: </dl></dd>
1.79 ! rillig 7933: <dt><span class="chapter"><a href="#infr.bulk">23. The implementation of the pkgsrc bulk builds</a></span></dt>
! 7934: <dd><dl><dt><span class="sect1"><a href="#infr.bulk.what">23.1. Deciding which packages to build</a></span></dt></dl></dd>
! 7935: <dt><span class="chapter"><a href="#porting">24. Porting pkgsrc</a></span></dt>
1.75 rillig 7936: <dd><dl>
1.79 ! rillig 7937: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
! 7938: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 7939: </dl></dd>
7940: </dl>
7941: </div>
7942: </div>
7943: <div class="chapter" lang="en">
7944: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7945: <a name="infr.design"></a>Chapter 21. Design of the pkgsrc infrastructure</h2></div></div></div>
1.75 rillig 7946: <div class="toc">
7947: <p><b>Table of Contents</b></p>
7948: <dl>
1.77 rillig 7949: <dt><span class="sect1"><a href="#infr.var">21.1. Variable evaluation</a></span></dt>
1.75 rillig 7950: <dd><dl>
1.77 rillig 7951: <dt><span class="sect2"><a href="#infr.var.load">21.1.1. At load time</a></span></dt>
7952: <dt><span class="sect2"><a href="#infr.var.run">21.1.2. At runtime</a></span></dt>
1.75 rillig 7953: </dl></dd>
1.78 rillig 7954: <dt><span class="sect1"><a href="#infr.varspec">21.2. How can variables be specified?</a></span></dt>
7955: <dt><span class="sect1"><a href="#infr.design.intf">21.3. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 7956: <dd><dl>
1.78 rillig 7957: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.3.1. Procedures with parameters</a></span></dt>
7958: <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 7959: </dl></dd>
7960: </dl>
7961: </div>
7962: <p>The pkgsrc infrastructure consists of many small Makefile
7963: fragments. Each such fragment needs a properly specified
7964: interface. This chapter explains how such an interface looks
7965: like.</p>
7966: <div class="sect1" lang="en">
7967: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7968: <a name="infr.var"></a>21.1. Variable evaluation</h2></div></div></div>
1.75 rillig 7969: <div class="sect2" lang="en">
7970: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7971: <a name="infr.var.load"></a>21.1.1. At load time</h3></div></div></div>
1.75 rillig 7972: <p>Variable evaluation takes place either at load time or at
7973: runtime, depending on the context in which they occur. The
7974: contexts where variables are evaluated at load time are:</p>
7975: <div class="itemizedlist"><ul type="disc">
7976: <li><p>The right hand side of the <code class="literal">:=</code>
7977: and <code class="literal">!=</code> operators,</p></li>
7978: <li><p>Make directives like <code class="literal">.if</code> or
7979: <code class="literal">.for</code>,</p></li>
7980: <li><p>Dependency lines.</p></li>
7981: </ul></div>
7982: <p>A special exception are references to the iteration
7983: variables of <code class="literal">.for</code> loops, which are expanded
7984: inline, no matter in which context they appear.</p>
7985: <p>As the values of variables may change during load time,
7986: care must be taken not to evaluate them by accident. Typical
7987: examples for variables that should not be evaluated at load time
7988: are <code class="varname">DEPENDS</code> and
7989: <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
7990: clear, here is an example:</p>
7991: <pre class="programlisting">
7992: CONFIGURE_ARGS= # none
7993: CFLAGS= -O
7994: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
1.1 grant 7995:
1.75 rillig 7996: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
1.1 grant 7997:
1.75 rillig 7998: CFLAGS+= -Wall
7999: </pre>
8000: <p>This code shows how the use of the <code class="literal">:=</code>
8001: operator can quickly lead to unexpected results. The first
8002: paragraph is fairly common code. The second paragraph evaluates
8003: the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
8004: <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
8005: <code class="literal">-Wall</code> is appended to the
8006: <code class="varname">CFLAGS</code>, but this addition will not appear in
8007: <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
8008: paragraphs from above typically occur in completely unrelated
8009: files.</p>
8010: </div>
8011: <div class="sect2" lang="en">
8012: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 8013: <a name="infr.var.run"></a>21.1.2. At runtime</h3></div></div></div>
1.75 rillig 8014: <p>After all the files have been loaded, the values of the
8015: variables cannot be changed anymore. Variables that are used in
8016: the shell commands are expanded at this point.</p>
8017: </div>
8018: </div>
8019: <div class="sect1" lang="en">
8020: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 8021: <a name="infr.varspec"></a>21.2. How can variables be specified?</h2></div></div></div>
8022: <p>There are many ways in which the definition and use of a
8023: variable can be restricted in order to detect bugs and
8024: violations of the (mostly unwritten) policies. See the
8025: <code class="literal">pkglint</code> developer's documentation for further
8026: details.</p>
8027: </div>
8028: <div class="sect1" lang="en">
8029: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8030: <a name="infr.design.intf"></a>21.3. Designing interfaces for Makefile fragments</h2></div></div></div>
1.76 rillig 8031: <p>Most of the <code class="filename">.mk</code> files fall into one
1.75 rillig 8032: of the following classes. Cases where a file falls into more
8033: than one class should be avoided as it often leads to subtle
8034: bugs.</p>
8035: <div class="sect2" lang="en">
8036: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 8037: <a name="infr.design.intf.proc"></a>21.3.1. Procedures with parameters</h3></div></div></div>
1.75 rillig 8038: <p>In a traditional imperative programming language some of
1.76 rillig 8039: the <code class="filename">.mk</code> files could be described as
1.78 rillig 8040: procedures. They take some input parameters and—after
8041: inclusion—provide a result in output parameters. Since all
1.76 rillig 8042: variables in <code class="filename">Makefile</code>s have global scope
1.75 rillig 8043: care must be taken not to use parameter names that have already
8044: another meaning. For example, <code class="varname">PKGNAME</code> is a
8045: bad choice for a parameter name.</p>
8046: <p>Procedures are completely evaluated at preprocessing time.
8047: That is, when calling a procedure all input parameters must be
8048: completely resolvable. For example,
8049: <code class="varname">CONFIGURE_ARGS</code> should never be an input
8050: parameter since it is very likely that further text will be
8051: added after calling the procedure, which would effectively apply
8052: the procedure to only a part of the variable. Also, references
8053: to other variables wit will be modified after calling the
8054: procedure.</p>
8055: <p>A procedure can declare its output parameters either as
8056: suitable for use in preprocessing directives or as only
8057: available at runtime. The latter alternative is for variables
8058: that contain references to other runtime variables.</p>
8059: <p>Procedures shall be written such that it is possible to
8060: call the procedure more than once. That is, the file must not
8061: contain multiple-inclusion guards.</p>
8062: <p>Examples for procedures are
1.76 rillig 8063: <code class="filename">mk/bsd.options.mk</code> and
8064: <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
1.75 rillig 8065: that the parameters are evaluated at load time, they should be
8066: assigned using the <code class="literal">:=</code> operator, which should
8067: be used only for this purpose.</p>
8068: </div>
8069: <div class="sect2" lang="en">
8070: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 8071: <a name="infr.design.intf.action"></a>21.3.2. Actions taken on behalf of parameters</h3></div></div></div>
1.75 rillig 8072: <p>Action files take some input parameters and may define
8073: runtime variables. They shall not define loadtime variables.
8074: There are action files that are included implicitly by the
8075: pkgsrc infrastructure, while other must be included
8076: explicitly.</p>
8077: <p>An example for action files is
1.76 rillig 8078: <code class="filename">mk/subst.mk</code>.</p>
1.75 rillig 8079: </div>
8080: </div>
8081: </div>
8082: <div class="chapter" lang="en">
8083: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8084: <a name="regression"></a>Chapter 22. Regression tests</h2></div></div></div>
1.75 rillig 8085: <div class="toc">
8086: <p><b>Table of Contents</b></p>
8087: <dl>
1.77 rillig 8088: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
8089: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
8090: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 8091: <dd><dl>
1.77 rillig 8092: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
8093: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 8094: </dl></dd>
8095: </dl>
8096: </div>
8097: <p>The pkgsrc infrastructure consists of a large codebase,
8098: and there are many corners where every little bit of a file is
8099: well thought out, making pkgsrc likely to fail as soon as
8100: anything is changed near those parts. To prevent most changes
8101: from breaking anything, a suite of regression tests should go
8102: along with every important part of the pkgsrc infrastructure.
8103: This chapter describes how regression tests work in pkgsrc and
8104: how you can add new tests.</p>
8105: <div class="sect1" lang="en">
8106: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8107: <a name="regression.descr"></a>22.1. The regression tests framework</h2></div></div></div>
1.75 rillig 8108: <p></p>
8109: </div>
8110: <div class="sect1" lang="en">
8111: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8112: <a name="regression.run"></a>22.2. Running the regression tests</h2></div></div></div>
1.76 rillig 8113: <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 8114: provides the <span><strong class="command">pkg_regress</strong></span> command. Then you
8115: can simply run that command, which will run all tests in the
1.76 rillig 8116: <code class="filename">regress</code> category.</p>
1.75 rillig 8117: </div>
8118: <div class="sect1" lang="en">
8119: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8120: <a name="regression.new"></a>22.3. Adding a new regression test</h2></div></div></div>
1.76 rillig 8121: <p>Every directory in the <code class="filename">regress</code>
8122: category that contains a file called <code class="filename">spec</code>
1.75 rillig 8123: is considered a regression test. This file is a shell program
8124: that is included by the <span><strong class="command">pkg_regress</strong></span> command.
8125: The following functions can be overridden to suit your
8126: needs.</p>
8127: <div class="sect2" lang="en">
8128: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 8129: <a name="regression.fun.override"></a>22.3.1. Overridable functions</h3></div></div></div>
1.75 rillig 8130: <p>These functions do not take any parameters. They are all
8131: called in “<span class="quote">set -e</span>” mode, so you should be careful
8132: to check the exitcodes of any commands you run in the
8133: test.</p>
8134: <div class="variablelist"><dl>
8135: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
8136: <dd><p>This function prepares the environment for the
8137: test. By default it does nothing.</p></dd>
8138: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
8139: <dd><p>This function runs the actual test. By default,
8140: it calls <code class="varname">TEST_MAKE</code> with the arguments
8141: <code class="varname">MAKEARGS_TEST</code> and writes its output including
8142: error messages into the file
8143: <code class="varname">TEST_OUTFILE</code>.</p></dd>
8144: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
8145: <dd><p>This function is run after the test and is
8146: typically used to compare the actual output from the one that is
8147: expected. It can make use of the various helper functions from
8148: the next section.</p></dd>
8149: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
8150: <dd><p>This function cleans everything up after the
8151: test has been run. By default it does nothing.</p></dd>
8152: </dl></div>
8153: </div>
8154: <div class="sect2" lang="en">
8155: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 8156: <a name="regression.fun.helper"></a>22.3.2. Helper functions</h3></div></div></div>
1.75 rillig 8157: <div class="variablelist"><dl>
8158: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
8159: <dd><p>This function compares the exitcode of the
8160: <span><strong class="command">do_test()</strong></span> function with its first parameter.
8161: If they differ, the test will fail.</p></dd>
8162: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
8163: <dd><p>This function checks for each of its parameters
8164: if the output from <span><strong class="command">do_test()</strong></span> matches the
8165: extended regular expression. If it does not, the test will
8166: fail.</p></dd>
8167: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
8168: <dd><p>This function checks for each of its parameters
8169: if the output from <span><strong class="command">do_test()</strong></span> does
8170: <span class="emphasis"><em>not</em></span> match the extended regular expression.
8171: If any of the regular expressions matches, the test will
8172: fail.</p></dd>
8173: </dl></div>
8174: </div>
8175: </div>
8176: </div>
8177: <div class="chapter" lang="en">
8178: <div class="titlepage"><div><div><h2 class="title">
1.79 ! rillig 8179: <a name="infr.bulk"></a>Chapter 23. The implementation of the pkgsrc bulk builds</h2></div></div></div>
! 8180: <div class="toc">
! 8181: <p><b>Table of Contents</b></p>
! 8182: <dl><dt><span class="sect1"><a href="#infr.bulk.what">23.1. Deciding which packages to build</a></span></dt></dl>
! 8183: </div>
! 8184: <div class="sect1" lang="en">
! 8185: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 8186: <a name="infr.bulk.what"></a>23.1. Deciding which packages to build</h2></div></div></div>
! 8187: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
! 8188: <h3 class="title">Note</h3>
! 8189: <p>This is not yet implemented.</p>
! 8190: </div>
! 8191: <p>Some of the pkgsrc packages are not usable in a certain
! 8192: build configuration, either because of platform limitations
! 8193: (processor, operating system) or because the build is done by an
! 8194: unprivileged user. This section lists all the conditions that
! 8195: influence whether a package is excluded from a bulk
! 8196: build.</p>
! 8197: <div class="itemizedlist"><ul type="disc">
! 8198: <li><p><code class="varname">ONLY_FOR_PLATFORM</code> or
! 8199: <code class="varname">NOT_FOR_PLATFORM</code> may be defined in the
! 8200: package <code class="filename">Makefile</code>.</p></li>
! 8201: <li><p><code class="varname">ONLY_FOR_COMPILER</code> or
! 8202: <code class="varname">NOT_FOR_COMPILER</code> may be defined in the
! 8203: package <code class="filename">Makefile</code>.</p></li>
! 8204: <li><p><code class="varname">NOT_FOR_UNPRIVILEGED</code> (does
! 8205: not exist yet) may be defined in the package
! 8206: <code class="filename">Makefile</code> (only affects bulk builds in
! 8207: unprivileged mode).</p></li>
! 8208: <li><p><code class="varname">LICENSE</code> may be defined in the
! 8209: package <code class="filename">Makefile</code>. This may be overridden by
! 8210: defining <code class="varname">ACCEPTABLE_LICENSES</code> in
! 8211: <code class="filename">mk.conf</code>.</p></li>
! 8212: <li><p>The package vulnerability database may list the
! 8213: package as vulnerable. This may be overridden by defining
! 8214: <code class="varname">ALLOW_VULNERABLE_PACKAGES</code> in
! 8215: <code class="filename">mk.conf</code>.</p></li>
! 8216: <li><p>Packages that define
! 8217: <code class="varname">INTERACTIVE_STAGE</code> cannot be built by the bulk
! 8218: builds, which are by definition
! 8219: non-interactive.</p></li>
! 8220: </ul></div>
! 8221: </div>
! 8222: </div>
! 8223: <div class="chapter" lang="en">
! 8224: <div class="titlepage"><div><div><h2 class="title">
! 8225: <a name="porting"></a>Chapter 24. Porting pkgsrc</h2></div></div></div>
1.75 rillig 8226: <div class="toc">
8227: <p><b>Table of Contents</b></p>
8228: <dl>
1.79 ! rillig 8229: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
! 8230: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 8231: </dl>
8232: </div>
8233: <p>The pkgsrc system has already been ported to many
8234: operating systems, hardware architectures and compilers. This
8235: chapter explains the necessary steps to make pkgsrc even more
8236: portable.</p>
8237: <div class="sect1" lang="en">
8238: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.79 ! rillig 8239: <a name="porting.opsys"></a>24.1. Porting pkgsrc to a new operating system</h2></div></div></div>
1.75 rillig 8240: <p>To port pkgsrc to a new operating system (called
8241: <code class="literal">MyOS</code> in this example), you need to touch the
8242: following files:</p>
8243: <div class="variablelist"><dl>
1.76 rillig 8244: <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 8245: <dd><p>This file contains some basic definitions, for
8246: example the name of the C
8247: compiler.</p></dd>
1.76 rillig 8248: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
1.75 rillig 8249: <dd><p>Insert code that defines the variables
8250: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
8251: <code class="varname">LOWER_OS_VERSION</code>,
8252: <code class="varname">LOWER_VENDOR</code>,
8253: <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
8254: <code class="varname">APPEND_ELF</code>, and the other variables that
8255: appear in this file.</p></dd>
1.76 rillig 8256: <dt><span class="term"><code class="filename">mk/platform/MyOS.mk</code></span></dt>
1.75 rillig 8257: <dd><p>This file contains the platform-specific
8258: definitions that are used by pkgsrc. Start by copying one of the
8259: other files and edit it to your
8260: needs.</p></dd>
1.76 rillig 8261: <dt><span class="term"><code class="filename">mk/platform/MyOS.pkg.dist</code></span></dt>
1.75 rillig 8262: <dd><p>This file contains a list of directories,
8263: together with their permission bits and ownership. These
8264: directories will be created automatically with every package
8265: that does not explicitly set <code class="varname">NO_MTREE</code>. There
8266: have been some discussions about whether this file is needed at
8267: all, but with no result.</p></dd>
1.76 rillig 8268: <dt><span class="term"><code class="filename">mk/platform/MyOS.x11.dist</code></span></dt>
1.75 rillig 8269: <dd><p>Just copy one of the pre-existing x11.dist files
8270: to your
1.76 rillig 8271: <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
8272: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
1.75 rillig 8273: <dd><p>On some operating systems, the tools that are
8274: provided with the base system are not good enough for pkgsrc.
8275: 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
8276: narrow limit on the line length they can process. Therefore
8277: pkgsrc brings its own tools, which can be enabled
8278: here.</p></dd>
1.76 rillig 8279: <dt><span class="term"><code class="filename">mk/tools/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
1.75 rillig 8280: <dd><p>This file defines the paths to all the tools
8281: that are needed by one or the other package in pkgsrc, as well
8282: as by pkgsrc itself. Find out where these tools are on your
8283: platform and add them.</p></dd>
8284: </dl></div>
8285: <p>Now, you should be able to build some basic packages, like
1.76 rillig 8286: <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 8287: </div>
8288: <div class="sect1" lang="en">
8289: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.79 ! rillig 8290: <a name="porting.compiler"></a>24.2. Adding support for a new compiler</h2></div></div></div>
1.75 rillig 8291: <p>TODO</p>
8292: </div>
8293: </div>
8294: </div>
8295: <div class="appendix" lang="en">
8296: <div class="titlepage"><div><div><h2 class="title">
8297: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
8298: <div class="toc">
8299: <p><b>Table of Contents</b></p>
8300: <dl>
8301: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
8302: <dd><dl>
8303: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
8304: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
8305: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
8306: <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>
8307: </dl></dd>
8308: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
8309: </dl>
8310: </div>
8311: <p>We checked to find a piece of software that wasn't in the packages
8312: collection, and picked GNU bison. Quite why someone would want to have
8313: <span><strong class="command">bison</strong></span> when Berkeley <span><strong class="command">yacc</strong></span> is already
8314: present in the tree is beyond us, but it's useful for the purposes of
8315: this exercise.</p>
8316: <div class="sect1" lang="en">
8317: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8318: <a name="example-files"></a>A.1. files</h2></div></div></div>
8319: <div class="sect2" lang="en">
8320: <div class="titlepage"><div><div><h3 class="title">
8321: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
8322: <pre class="programlisting">
1.51 rillig 8323: # $NetBSD$
8324: #
1.1 grant 8325:
1.51 rillig 8326: DISTNAME= bison-1.25
8327: CATEGORIES= devel
8328: MASTER_SITES= ${MASTER_SITE_GNU}
1.1 grant 8329:
1.51 rillig 8330: MAINTAINER= thorpej@NetBSD.org
8331: HOMEPAGE= http://www.gnu.org/software/bison/bison.html
8332: COMMENT= GNU yacc clone
1.1 grant 8333:
1.51 rillig 8334: GNU_CONFIGURE= yes
8335: INFO_FILES= bison.info
1.1 grant 8336:
1.51 rillig 8337: .include "../../mk/bsd.pkg.mk"
1.1 grant 8338: </pre>
1.75 rillig 8339: </div>
8340: <div class="sect2" lang="en">
8341: <div class="titlepage"><div><div><h3 class="title">
8342: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
8343: <pre class="programlisting">
1.51 rillig 8344: GNU version of yacc. Can make re-entrant parsers, and numerous other
1.75 rillig 8345: 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 8346: of the NetBSD source tree is beyond me.
1.1 grant 8347: </pre>
1.75 rillig 8348: </div>
8349: <div class="sect2" lang="en">
8350: <div class="titlepage"><div><div><h3 class="title">
8351: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
8352: <pre class="programlisting">
1.51 rillig 8353: @comment $NetBSD$
8354: bin/bison
8355: man/man1/bison.1.gz
8356: share/bison.simple
8357: share/bison.hairy
1.1 grant 8358: </pre>
1.75 rillig 8359: </div>
8360: <div class="sect2" lang="en">
8361: <div class="titlepage"><div><div><h3 class="title">
8362: <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>
8363: <p>The NetBSD package system comes with
1.76 rillig 8364: <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 8365: which helps to check the contents of these
8366: files. After installation it is quite easy to use, just change to the
8367: directory of the package you wish to examine and execute
8368: <span><strong class="command">pkglint</strong></span>:</p>
8369: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
8370: looks fine.</pre>
8371: <p>Depending on the supplied command line arguments (see pkglint(1)),
8372: more checks will be performed. Use e.g. <span><strong class="command">pkglint -Call
8373: -Wall</strong></span> for a very thorough check.</p>
8374: </div>
8375: </div>
8376: <div class="sect1" lang="en">
8377: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8378: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
8379: <p>Create the directory where the package lives,
8380: plus any auxiliary directories:</p>
8381: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
8382: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
8383: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
8384: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
1.76 rillig 8385: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.77 rillig 8386: <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 8387: then continue with fetching the distfile:</p>
8388: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
1.1 grant 8389: >> bison-1.25.tar.gz doesn't seem to exist on this system.
8390: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
8391: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8392: ftp: Error retrieving file: 500 Internal error
8393:
8394: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
8395: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8396: ftp: Error retrieving file: 500 Internal error
8397:
8398: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
8399: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
1.75 rillig 8400: Successfully retrieved file.</pre>
8401: <p>Generate the checksum of the distfile into
1.76 rillig 8402: <code class="filename">distinfo</code>:</p>
1.75 rillig 8403: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makesum</code></strong></pre>
8404: <p>Now compile:</p>
8405: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 8406: >> Checksum OK for bison-1.25.tar.gz.
8407: ===> Extracting for bison-1.25
8408: ===> Patching for bison-1.25
8409: ===> Ignoring empty patch directory
8410: ===> Configuring for bison-1.25
8411: creating cache ./config.cache
8412: checking for gcc... cc
8413: checking whether we are using GNU C... yes
8414: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
8415: checking how to run the C preprocessor... cc -E
8416: checking for minix/config.h... no
8417: checking for POSIXized ISC... no
8418: checking whether cross-compiling... no
8419: checking for ANSI C header files... yes
8420: checking for string.h... yes
8421: checking for stdlib.h... yes
8422: checking for memory.h... yes
8423: checking for working const... yes
8424: checking for working alloca.h... no
8425: checking for alloca... yes
8426: checking for strerror... yes
8427: updating cache ./config.cache
8428: creating ./config.status
8429: creating Makefile
8430: ===> Building for bison-1.25
8431: 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
8432: 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
8433: 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
8434: 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
8435: 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 8436: 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 8437: 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
8438: 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
8439: 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
8440: 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
8441: 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
8442: 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
8443: 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
8444: 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
8445: 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
8446: 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
8447: 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
8448: 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
8449: 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
8450: 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
8451: 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
8452: 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
8453: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
8454: rm -f bison.s1
1.75 rillig 8455: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1</pre>
8456: <p>Everything seems OK, so install the files:</p>
8457: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 8458: >> Checksum OK for bison-1.25.tar.gz.
8459: ===> Installing for bison-1.25
8460: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
8461: rm -f /usr/pkg/bin/bison
8462: cd /usr/pkg/share; rm -f bison.simple bison.hairy
8463: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
8464: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
8465: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
8466: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
8467: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
8468: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
1.75 rillig 8469: ===> Registering installation for bison-1.25</pre>
8470: <p>You can now use bison, and also - if you decide so - remove it with
8471: <span><strong class="command">pkg_delete bison</strong></span>. Should you decide that you want a
8472: binary package, do this now:</p>
8473: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 8474: >> Checksum OK for bison-1.25.tar.gz.
8475: ===> Building package for bison-1.25
8476: Creating package bison-1.25.tgz
8477: Registering depends:.
1.75 rillig 8478: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
8479: <p>Now that you don't need the source and object files
8480: any more, clean up:</p>
8481: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
8482: ===> Cleaning for bison-1.25</pre>
8483: </div>
8484: </div>
8485: <div class="appendix" lang="en">
8486: <div class="titlepage"><div><div><h2 class="title">
8487: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
8488: <div class="toc">
8489: <p><b>Table of Contents</b></p>
8490: <dl>
8491: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
8492: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
8493: </dl>
8494: </div>
8495: <div class="sect1" lang="en">
8496: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8497: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
8498: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 8499: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8500: => figlet221.tar.gz doesn't seem to exist on this system.
8501: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
8502: => [172219 bytes]
8503: Connected to ftp.plig.net.
8504: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
8505: 331 Guest login ok, send your complete e-mail address as password.
8506: 230-You are user #5 of 500 simultaneous users allowed.
8507: 230-
1.68 rillig 8508: 230- ___ _ _ _
8509: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
1.1 grant 8510: 230- | _| _| . |_| . | | | . |_| . | _| . |
8511: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
8512: 230- |_| |_| |___| |___|
8513: 230-
8514: 230-** Welcome to ftp.plig.org **
8515: 230-
8516: 230-Please note that all transfers from this FTP site are logged. If you
8517: 230-do not like this, please disconnect now.
8518: 230-
8519: 230-This arhive is available via
8520: 230-
8521: 230-HTTP: http://ftp.plig.org/
8522: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
8523: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
8524: 230-
8525: 230-Please email comments, bug reports and requests for packages to be
1.68 rillig 8526: 230-mirrored to ftp-admin@plig.org.
1.1 grant 8527: 230-
8528: 230-
8529: 230 Logged in anonymously.
8530: Remote system type is UNIX.
8531: Using binary mode to transfer files.
8532: 200 Type okay.
8533: 250 "/pub" is new cwd.
8534: 250-"/pub/figlet" is new cwd.
8535: 250-
8536: 250-Welcome to the figlet archive at ftp.figlet.org
1.68 rillig 8537: 250-
1.75 rillig 8538: 250- ftp://ftp.figlet.org/pub/figlet/
1.1 grant 8539: 250-
8540: 250-The official FIGlet web page is:
1.75 rillig 8541: 250- http://www.figlet.org/
1.1 grant 8542: 250-
8543: 250-If you have questions, please mailto:info@figlet.org. If you want to
8544: 250-contribute a font or something else, you can email us.
1.68 rillig 8545: 250
1.1 grant 8546: 250 "/pub/figlet/program" is new cwd.
8547: 250 "/pub/figlet/program/unix" is new cwd.
8548: local: figlet221.tar.gz remote: figlet221.tar.gz
8549: 502 Unimplemented command.
8550: 227 Entering Passive Mode (195,40,6,41,246,104)
8551: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
8552: 38% |************** | 65800 64.16 KB/s 00:01 ETA
8553: 226 Transfer completed.
8554: 172219 bytes received in 00:02 (75.99 KB/s)
8555: 221 Goodbye.
8556: => Checksum OK for figlet221.tar.gz.
8557: ===> Extracting for figlet-2.2.1nb2
8558: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
8559: ===> Patching for figlet-2.2.1nb2
8560: ===> Applying pkgsrc patches for figlet-2.2.1nb2
8561: ===> Overriding tools for figlet-2.2.1nb2
8562: ===> Creating toolchain wrappers for figlet-2.2.1nb2
8563: ===> Configuring for figlet-2.2.1nb2
8564: ===> Building for figlet-2.2.1nb2
8565: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
8566: chmod a+x figlet
8567: gcc -O2 -o chkfont chkfont.c
8568: => Unwrapping files-to-be-installed.
1.14 xtraeme 8569: <code class="prompt">#</code>
1.75 rillig 8570: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 8571: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8572: ===> Installing for figlet-2.2.1nb2
8573: install -d -o root -g wheel -m 755 /usr/pkg/bin
8574: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
8575: mkdir -p /usr/pkg/share/figlet
8576: cp figlet /usr/pkg/bin
8577: cp chkfont /usr/pkg/bin
8578: chmod 555 figlist showfigfonts
8579: cp figlist /usr/pkg/bin
8580: cp showfigfonts /usr/pkg/bin
8581: cp fonts/*.flf /usr/pkg/share/figlet
8582: cp fonts/*.flc /usr/pkg/share/figlet
8583: cp figlet.6 /usr/pkg/man/man6
8584: ===> Registering installation for figlet-2.2.1nb2
1.75 rillig 8585: <code class="prompt">#</code></pre>
8586: </div>
8587: <div class="sect1" lang="en">
8588: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8589: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
8590: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 8591: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8592: ===> Packaging figlet-2.2.1nb2
8593: ===> Building binary package for figlet-2.2.1nb2
8594: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
8595: Using SrcDir value of /usr/pkg
1.68 rillig 8596: Registering depends:.
1.75 rillig 8597: <code class="prompt">#</code></pre>
8598: </div>
8599: </div>
8600: <div class="appendix" lang="en">
8601: <div class="titlepage"><div><div><h2 class="title">
1.76 rillig 8602: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
8603: <div class="toc">
8604: <p><b>Table of Contents</b></p>
8605: <dl>
8606: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
8607: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
8608: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
8609: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
8610: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
8611: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
8612: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
8613: source packages</a></span></dt>
8614: </dl>
8615: </div>
8616: <p>As in other big projects, the directory layout of pkgsrc
8617: is quite complex for newbies. This chapter explains where you
8618: find things on the FTP server. The base directory on
8619: <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>.
8620: This directory contains some subdirectories, which are explained
8621: below.</p>
8622: <div class="sect1" lang="en">
8623: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8624: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
8625: <p>For those who only want to manage binary packages on
8626: systems other than NetBSD, we provide the package management
8627: tools in a separate, small tar file.</p>
8628: </div>
8629: <div class="sect1" lang="en">
8630: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8631: <a name="ftp-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
8632: <p>The directory <code class="filename">distfiles</code> contains lots
8633: of archive files from all pkgsrc packages, which are mirrored
8634: here. The subdirectories are called after their package names
8635: and are used when the distributed files have names that don't
8636: explicitly contain a version number or are otherwise too generic
8637: (for example <code class="filename">release.tar.gz</code>).</p>
8638: </div>
8639: <div class="sect1" lang="en">
8640: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8641: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
8642: <p>This directory is currently not in use.</p>
8643: </div>
8644: <div class="sect1" lang="en">
8645: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8646: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
8647: <p>This directory contains things that individual pkgsrc
8648: developers find worth publishing.</p>
8649: </div>
8650: <div class="sect1" lang="en">
8651: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8652: <a name="ftp-packages"></a>C.5. <code class="filename">packages*</code>: Binary packages</h2></div></div></div>
8653: <p>These directories contain binary packages. Those
8654: directories that have a branch name
8655: (200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>)
8656: contain packages from that particular branch. The directory
8657: <code class="filename">packages</code> contains binary packages from
8658: pkgsrc-current. (However, this does not necessarily mean that
8659: the packages are still current anymore.)</p>
8660: <p>Below the <code class="filename">packages*</code> directories are
8661: directories that distinguish the packages by operating system
8662: and version, the next directory level specifies the hardware
8663: architecture.</p>
8664: <p>In each of the platform-specific directories, there is a
8665: whole binary packages collection. It has a directory called
8666: <code class="filename">All</code> which contains all binary packages.
8667: Besides that, there are various category directories that
8668: contain symbolic links to the real binary packages.</p>
8669: </div>
8670: <div class="sect1" lang="en">
8671: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8672: <a name="ftp-source"></a>C.6. <code class="filename">current</code>,
8673: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
8674: source packages</h2></div></div></div>
8675: <p>These directories contain the “<span class="quote">real</span>” pkgsrc,
8676: that is the files that define how to create binary packages from
8677: source archives.</p>
8678: <p>The directory <code class="filename">pkgsrc</code> contains a
8679: snapshot of the CVS repository, which is updated on a regularly
8680: basis. The file <code class="filename">pkgsrc.tar.gz</code> contains the
8681: same as the directory, ready to be downloaded as a whole.</p>
8682: <p>In the directories for the quarterly branches, there is an
8683: additional file called
8684: <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
8685: which contains the state of pkgsrc when it was branched.</p>
8686: </div>
1.75 rillig 8687: </div>
8688: <div class="appendix" lang="en">
8689: <div class="titlepage"><div><div><h2 class="title">
8690: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
8691: <div class="toc">
8692: <p><b>Table of Contents</b></p>
8693: <dl>
1.79 ! rillig 8694: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75 rillig 8695: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
8696: </dl>
8697: </div>
1.79 ! rillig 8698: <p>This section contains information on editing the pkgsrc
! 8699: guide itself.</p>
1.75 rillig 8700: <div class="sect1" lang="en">
8701: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.79 ! rillig 8702: <a name="targets"></a>D.1. Make targets</h2></div></div></div>
! 8703: <p>The pkgsrc guide's source code is stored in
! 8704: <code class="filename">pkgsrc/doc/guide/files</code>, and several files
! 8705: are created from it:</p>
! 8706: <div class="itemizedlist"><ul type="disc">
! 8707: <li><p><code class="filename">pkgsrc/doc/pkgsrc.txt</code></p></li>
! 8708: <li><p><code class="filename">pkgsrc/doc/pkgsrc.html</code></p></li>
! 8709: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/</a></p></li>
! 8710: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</a>:
! 8711: The PDF version of the pkgsrc guide.</p></li>
! 8712: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</a>:
! 8713: PostScript version of the pkgsrc guide.</p></li>
1.75 rillig 8714: </ul></div>
8715: </div>
8716: <div class="sect1" lang="en">
8717: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8718: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
1.79 ! rillig 8719: <p>The procedure to edit the pkgsrc guide is:</p>
! 8720: <div class="procedure"><ol type="1">
! 8721: <li><p>Make sure you have the packages needed to
! 8722: re-generate the pkgsrc guide (and other XML-based NetBSD
! 8723: 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
! 8724: 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
! 8725: PostScript and PDF versions. You will need both packages
! 8726: installed, to make sure documentation is consistent across all
! 8727: formats.</p></li>
! 8728: <li><p>Run <span><strong class="command">cd doc/guide</strong></span> to get to the
! 8729: right directory. All further steps will take place
! 8730: here.</p></li>
! 8731: <li><p>Edit the XML file(s) in
! 8732: <code class="filename">files/</code>.</p></li>
! 8733: <li><p>Run <span><strong class="command">bmake</strong></span> to check the pkgsrc
! 8734: guide for valid XML and to build the final output files. If you
! 8735: get any errors at this stage, you can just edit the files, as
! 8736: there are only symbolic links in the working directory, pointing
! 8737: to the files in <code class="filename">files/</code>.</p></li>
! 8738: <li><p><span><strong class="command">(cd files && cvs
! 8739: commit)</strong></span></p></li>
! 8740: <li><p>Run <span><strong class="command">bmake clean && bmake</strong></span> to
! 8741: regenerate the output files with the proper RCS
! 8742: Ids.</p></li>
! 8743: <li><p>Run <span><strong class="command">(cd .. && cvs update pkgsrc.*)
! 8744: && bmake install-doc</strong></span> to put the generated
! 8745: files into <code class="filename">pkgsrc/doc</code>.</p></li>
! 8746: <li><p>Run <span><strong class="command">(cd .. && cvs commit -m
! 8747: "regenerated." pkgsrc.{html,txt})</strong></span> to commit the
! 8748: generated documentation.</p></li>
! 8749: <li><p>Run <span><strong class="command">(cd
! 8750: ../../../htdocs/Documentation/pkgsrc && cvs update)
! 8751: && bmake install-htdocs</strong></span> to generate all the
! 8752: files for the web server.</p></li>
! 8753: <li><p>Run <span><strong class="command">(cd
! 8754: ../../../htdocs/Documentation/pkgsrc && cvs commit -m
! 8755: "regenerated.")</strong></span> to update the files on the web server.
! 8756: If you have added a chapter, don't forget to run <span><strong class="command">cvs
! 8757: add *.html</strong></span> before you commit the files.</p></li>
! 8758: </ol></div>
1.75 rillig 8759: </div>
8760: </div>
8761: </div></body>
1.1 grant 8762: </html>
CVSweb <webmaster@jp.NetBSD.org>