Annotation of pkgsrc/doc/pkgsrc.html, revision 1.81
1.75 rillig 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2: <html>
1.1 grant 3: <head>
1.75 rillig 4: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
5: <title>The pkgsrc guide</title>
6: <link rel="stylesheet" href="/NetBSD.css" type="text/css">
7: <meta name="generator" content="DocBook XSL Stylesheets VX.X.X">
8: <meta name="description" content="pkgsrc is a centralized package management system for
9: Unix-like operating systems. This guide provides information for
10: users and developers of pkgsrc. It covers installation of binary
11: and source packages, creation of binary and source packages and
12: a high-level overview about the infrastructure.">
13: </head>
14: <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" lang="en">
15: <div class="titlepage">
16: <div>
17: <div><h1 class="title">
18: <a name="the-pkgsrc-guide"></a>The pkgsrc guide</h1></div>
19: <div><h2 class="subtitle">Documentation on the NetBSD packages system</h2></div>
20: <div><div class="authorgroup">
21: <div class="author">
22: <h3 class="author">
23: <span class="firstname">Alistair</span> <span class="surname">Crooks</span>
24: </h3>
25: <div class="affiliation"><div class="address"><p><code class="email"><<a href="mailto:agc@NetBSD.org">agc@NetBSD.org</a>></code></p></div></div>
26: </div>
27: <div class="author">
28: <h3 class="author">
29: <span class="firstname">Hubert</span> <span class="surname">Feyrer</span>
30: </h3>
31: <div class="affiliation"><div class="address"><p><code class="email"><<a href="mailto:hubertf@NetBSD.org">hubertf@NetBSD.org</a>></code></p></div></div>
32: </div>
33: <h3 class="corpauthor">
34: The pkgsrc Developers
35: </h3>
36: </div></div>
37: <div><p class="copyright">Copyright © 1994-2006 The NetBSD Foundation, Inc</p></div>
1.80 rillig 38: <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.21 2006/07/03 23:51:01 rillig Exp $</p></div>
1.76 rillig 39: <div><div class="abstract">
1.75 rillig 40: <p class="title"><b>Abstract</b></p>
41: <p>pkgsrc is a centralized package management system for
42: Unix-like operating systems. This guide provides information for
43: users and developers of pkgsrc. It covers installation of binary
44: and source packages, creation of binary and source packages and
45: a high-level overview about the infrastructure.</p>
46: </div></div>
47: </div>
48: <hr>
49: </div>
50: <div class="toc">
51: <p><b>Table of Contents</b></p>
52: <dl>
53: <dt><span class="chapter"><a href="#introduction">1. What is pkgsrc?</a></span></dt>
54: <dd><dl>
55: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
56: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
57: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.78 rillig 58: <dd><dl>
59: <dt><span class="sect2"><a href="#term.abbrev">1.3.1. Commonly used abbreviations</a></span></dt>
60: <dt><span class="sect2"><a href="#term.people">1.3.2. People involved in pkgsrc</a></span></dt>
61: </dl></dd>
1.75 rillig 62: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
63: </dl></dd>
64: <dt><span class="part"><a href="#users-guide">I. The pkgsrc user's guide</a></span></dt>
65: <dd><dl>
66: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
67: <dd><dl>
68: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
69: <dd><dl>
70: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
71: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
72: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
73: </dl></dd>
74: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
75: <dd><dl>
76: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
77: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
78: </dl></dd>
79: </dl></dd>
80: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
81: <dd><dl>
82: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
83: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
84: <dd><dl>
85: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
86: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
87: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
88: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
89: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
90: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
91: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
92: </dl></dd>
93: </dl></dd>
94: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
95: <dd><dl>
96: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
97: <dd><dl>
98: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
99: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
100: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
101: </dl></dd>
102: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
103: <dd><dl>
104: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
105: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
106: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
107: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
108: </dl></dd>
109: </dl></dd>
110: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
111: <dd><dl>
112: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
113: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 114: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
115: <dd><dl><dt><span class="sect2"><a href="#conf.cflags">5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt></dl></dd>
116: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
117: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 118: </dl></dd>
119: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
120: <dd><dl>
121: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
122: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
123: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
124: <dd><dl>
125: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
126: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
127: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
128: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
129: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
130: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
131: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
132: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
133: </dl></dd>
134: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
135: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
136: </dl></dd>
137: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
138: <dd><dl>
139: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
140: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
141: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
142: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
143: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
144: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
145: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
146: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
147: <dt><span class="sect1"><a href="#passive-ftp">7.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
148: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
149: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
150: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
151: <dt><span class="sect1"><a href="#bsd.own.mk-missing">7.12. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</a></span></dt>
152: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
153: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
154: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
155: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
1.80 rillig 156: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.75 rillig 157: </dl></dd>
158: </dl></dd>
159: <dt><span class="part"><a href="#developers-guide">II. The pkgsrc developer's guide</a></span></dt>
160: <dd><dl>
1.77 rillig 161: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
162: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75 rillig 163: <dd><dl>
1.77 rillig 164: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
165: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
166: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
167: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
168: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 169: <dd><dl>
170: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
171: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
172: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
173: </dl></dd>
1.77 rillig 174: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
175: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
176: </dl></dd>
177: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
178: <dd><dl>
179: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
180: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
181: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
182: <dd><dl>
183: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
184: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
185: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
186: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
187: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
188: </dl></dd>
189: </dl></dd>
190: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
191: <dd><dl>
192: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
193: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
194: <dt><span class="sect1"><a href="#print-PLIST">11.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
195: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
196: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
197: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
198: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
199: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
200: </dl></dd>
201: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
202: <dd><dl>
203: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
204: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
205: <dd><dl>
206: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
207: <dt><span class="sect2"><a href="#updating-buildlink-depends">12.2.2. Updating <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code> in <code class="filename">buildlink3.mk</code> files</a></span></dt>
208: </dl></dd>
209: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
210: <dd><dl>
211: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">12.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
212: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
213: </dl></dd>
214: </dl></dd>
215: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
216: <dd><dl>
217: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
218: <dd><dl>
219: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
220: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
221: </dl></dd>
222: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
223: <dd><dl>
224: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
225: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
226: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
227: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
228: </dl></dd>
229: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
230: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">13.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
231: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
232: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
233: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
234: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
235: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">13.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
236: </dl></dd>
237: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
238: <dd><dl>
239: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
240: <dt><span class="sect1"><a href="#converting-to-options">14.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
241: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
242: </dl></dd>
243: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
244: <dd><dl>
245: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
246: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
247: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
248: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
249: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
1.81 ! rillig 250: <dd><dl>
! 251: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
! 252: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
! 253: </dl></dd>
1.77 rillig 254: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
255: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
256: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
257: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
258: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
259: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
260: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
261: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
262: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
263: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
264: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
265: </dl></dd>
266: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
267: <dd><dl>
268: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
269: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
270: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
271: </dl></dd>
272: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
273: <dd><dl>
274: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
275: <dd><dl>
1.78 rillig 276: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
277: <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>
278: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
279: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
280: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
281: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
282: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
283: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
284: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
285: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
286: <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 287: <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 288: </dl></dd>
289: <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>
290: <dd><dl>
291: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
292: <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>
293: </dl></dd>
294: <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>
295: <dd><dl>
296: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
297: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
298: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
299: </dl></dd>
300: <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>
301: <dd><dl>
1.78 rillig 302: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
303: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
304: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
305: </dl></dd>
306: <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>
307: <dd><dl>
308: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
309: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
310: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
311: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
312: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
313: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
314: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
315: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
316: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
317: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
318: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
319: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
320: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
321: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
322: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
323: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
324: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.77 rillig 325: </dl></dd>
1.78 rillig 326: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.77 rillig 327: </dl></dd>
328: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
329: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
330: <dd><dl>
331: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
332: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
333: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
334: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
335: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
336: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 337: </dl></dd>
1.77 rillig 338: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.75 rillig 339: </dl></dd>
340: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
341: <dd><dl>
1.77 rillig 342: <dt><span class="chapter"><a href="#infr.design">21. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 343: <dd><dl>
1.81 ! rillig 344: <dt><span class="sect1"><a href="#infr.vardef">21.1. The meaning of variable definitions</a></span></dt>
! 345: <dt><span class="sect1"><a href="#infr.vardef.problems">21.2. Avoiding problems before they arise</a></span></dt>
! 346: <dt><span class="sect1"><a href="#infr.var">21.3. Variable evaluation</a></span></dt>
! 347: <dd><dl>
! 348: <dt><span class="sect2"><a href="#infr.var.load">21.3.1. At load time</a></span></dt>
! 349: <dt><span class="sect2"><a href="#infr.var.run">21.3.2. At runtime</a></span></dt>
! 350: </dl></dd>
! 351: <dt><span class="sect1"><a href="#infr.varspec">21.4. How can variables be specified?</a></span></dt>
! 352: <dt><span class="sect1"><a href="#infr.design.intf">21.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 353: <dd><dl>
1.81 ! rillig 354: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.5.1. Procedures with parameters</a></span></dt>
! 355: <dt><span class="sect2"><a href="#infr.design.intf.action">21.5.2. Actions taken on behalf of parameters</a></span></dt>
1.75 rillig 356: </dl></dd>
1.81 ! rillig 357: <dt><span class="sect1"><a href="#infr.order">21.6. The order in which files are loaded</a></span></dt>
1.75 rillig 358: <dd><dl>
1.81 ! rillig 359: <dt><span class="sect2"><a href="#infr.order.prefs">21.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
! 360: <dt><span class="sect2"><a href="#infr.order.pkg">21.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75 rillig 361: </dl></dd>
362: </dl></dd>
1.77 rillig 363: <dt><span class="chapter"><a href="#regression">22. Regression tests</a></span></dt>
1.75 rillig 364: <dd><dl>
1.77 rillig 365: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
366: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
367: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 368: <dd><dl>
1.77 rillig 369: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
370: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 371: </dl></dd>
372: </dl></dd>
1.80 rillig 373: <dt><span class="chapter"><a href="#porting">23. Porting pkgsrc</a></span></dt>
1.75 rillig 374: <dd><dl>
1.80 rillig 375: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
376: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 377: </dl></dd>
378: </dl></dd>
379: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
380: <dd><dl>
381: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
382: <dd><dl>
383: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
384: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
385: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
386: <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>
387: </dl></dd>
388: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
389: </dl></dd>
390: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
391: <dd><dl>
392: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
393: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
394: </dl></dd>
1.76 rillig 395: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
396: <dd><dl>
397: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
398: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
399: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
400: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
401: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
402: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
403: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
404: source packages</a></span></dt>
405: </dl></dd>
1.75 rillig 406: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
407: <dd><dl>
1.79 rillig 408: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75 rillig 409: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
410: </dl></dd>
411: </dl>
412: </div>
413: <div class="chapter" lang="en">
414: <div class="titlepage"><div><div><h2 class="title">
415: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
416: <div class="toc">
417: <p><b>Table of Contents</b></p>
418: <dl>
419: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
420: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
421: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.78 rillig 422: <dd><dl>
423: <dt><span class="sect2"><a href="#term.abbrev">1.3.1. Commonly used abbreviations</a></span></dt>
424: <dt><span class="sect2"><a href="#term.people">1.3.2. People involved in pkgsrc</a></span></dt>
425: </dl></dd>
1.75 rillig 426: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
427: </dl>
428: </div>
429: <div class="sect1" lang="en">
430: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
431: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
432: <p> There is a lot of software freely available for Unix-based
433: systems, which usually runs on NetBSD and other Unix-flavoured
434: systems, too, sometimes with some modifications. The NetBSD
435: Packages Collection (pkgsrc) incorporates any such changes
436: necessary to make that software run, and makes the installation
437: (and de-installation) of the software package easy by means of a
438: single command. </p>
439: <p>Once the software
440: has been built, it is manipulated with the <span><strong class="command">pkg_*</strong></span> tools
441: so that installation
442: and de-installation, printing of an inventory of all installed packages and
443: retrieval of one-line comments or more verbose descriptions are all
444: simple.</p>
445: <p>pkgsrc currently contains several thousand packages,
446: including:</p>
447: <div class="itemizedlist"><ul type="disc">
1.76 rillig 448: <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 449: web server</p></li>
1.76 rillig 450: <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 451: web browser</p></li>
1.76 rillig 452: <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 453: Desktop Environment</p></li>
1.76 rillig 454: <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 455: Desktop Environment</p></li>
456: </ul></div>
457: <p>...just to name a few.</p>
458: <p>pkgsrc has built-in support for handling varying dependencies,
459: such as pthreads and X11, and extended features such as IPv6 support on
460: a range of platforms.</p>
461: <p>pkgsrc was derived from FreeBSD's ports system, and
462: initially developed for NetBSD only. Since then, pkgsrc has
463: grown a lot, and now supports the following platforms:</p>
464: <div class="itemizedlist"><ul type="disc">
465: <li><p><a href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
466: (<a href="http://www.apple.com/macosx/" target="_top">Mac OS X</a>)</p></li>
467: <li><p><a href="http://www.DragonFlyBSD.org/" target="_top">DragonFly BSD</a></p></li>
468: <li><p><a href="http://www.FreeBSD.org/" target="_top">FreeBSD</a></p></li>
469: <li><p>Microsoft Windows, via <a href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a></p></li>
470: <li><p><a href="http://www.sgi.com/software/irix6.5/" target="_top">IRIX</a></p></li>
471: <li><p><a href="http://www.linux.org/" target="_top">Linux</a></p></li>
472: <li><p><a href="http://www.NetBSD.org/" target="_top">NetBSD</a> (of
473: course)</p></li>
474: <li><p><a href="http://h30097.www3.hp.com/" target="_top">Tru64</a>
475: (Digital UNIX, OSF1)</p></li>
476: <li><p><a href="http://www.openbsd.org/" target="_top">OpenBSD</a></p></li>
477: <li><p><a href="http://www.sun.com/solaris/" target="_top">Solaris</a></p></li>
478: </ul></div>
479: </div>
480: <div class="sect1" lang="en">
481: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
482: <a name="overview"></a>1.2. Overview</h2></div></div></div>
483: <p>This document is divided into three parts. The first,
484: <a href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
485: describes how one can use one of the packages in the Package
486: Collection, either by installing a precompiled binary package,
487: or by building one's own copy using the NetBSD package system.
488: 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
489: package so it can be easily built by other NetBSD users without
490: knowing about the package's building details. The third part,
491: <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
492: is intended for those who want to understand how pkgsrc is
493: implemented.</p>
494: <p>This document is available in various formats:
495: <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>
496: </div>
497: <div class="sect1" lang="en">
498: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
499: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
500: <p>There has been a lot of talk about “<span class="quote">ports</span>”,
501: “<span class="quote">packages</span>”, etc. so far. Here is a description of all the
502: terminology used within this document.</p>
503: <div class="variablelist"><dl>
504: <dt><span class="term">Package</span></dt>
505: <dd><p>A set of files and building instructions
506: that describe what's necessary
507: to build a certain piece of software using
508: pkgsrc. Packages are traditionally stored under
1.76 rillig 509: <code class="filename">/usr/pkgsrc</code>.</p></dd>
1.75 rillig 510: <dt><span class="term">The NetBSD package system</span></dt>
511: <dd><p>
512: This is the former name of “<span class="quote">pkgsrc</span>”. It is
513: part of the NetBSD operating system and can be bootstrapped to
514: run on non-NetBSD operating systems as well. It handles
515: building (compiling), installing, and removing of
516: packages.
517: </p></dd>
518: <dt><span class="term">Distfile</span></dt>
519: <dd><p>This term describes the file or files that are
520: provided by the author of the piece of software to
521: distribute his work. All the changes necessary to build on
522: NetBSD are reflected in the corresponding package. Usually
523: the distfile is in the form of a compressed tar-archive,
524: but other types are possible, too. Distfiles are usually
525: stored below
1.76 rillig 526: <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
1.75 rillig 527: <dt><span class="term">Port</span></dt>
528: <dd><p>This is the term used by FreeBSD and OpenBSD people
529: for what we call a package.
530: In NetBSD terminology, “<span class="quote">port</span>” refers to a different
531: architecture.</p></dd>
532: <dt><span class="term">Precompiled/binary package</span></dt>
533: <dd>
534: <p>A set of binaries built with pkgsrc from a distfile
1.76 rillig 535: and stuffed together in a single <code class="filename">.tgz</code>
1.75 rillig 536: file so it can be installed on machines of the same
537: machine architecture without the need to
538: recompile. Packages are usually generated in
1.76 rillig 539: <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.75 rillig 540: an archive on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
541: <p>Sometimes, this is referred to by the term “<span class="quote">package</span>” too,
542: especially in the context of precompiled packages.</p>
543: </dd>
544: <dt><span class="term">Program</span></dt>
545: <dd><p>The piece of software to be installed which will be constructed from
546: all the files in the distfile by the actions defined in the
547: corresponding package.</p></dd>
548: </dl></div>
549: <div class="sect2" lang="en">
550: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 551: <a name="term.abbrev"></a>1.3.1. Commonly used abbreviations</h3></div></div></div>
552: <div class="variablelist"><dl>
553: <dt><span class="term">ICE</span></dt>
554: <dd><p>Internal Compiler
555: Error</p></dd>
556: </dl></div>
557: </div>
558: <div class="sect2" lang="en">
559: <div class="titlepage"><div><div><h3 class="title">
560: <a name="term.people"></a>1.3.2. People involved in pkgsrc</h3></div></div></div>
1.75 rillig 561: <div class="variablelist"><dl>
562: <dt><span class="term">pkgsrc users</span></dt>
563: <dd>
564: <p>The
565: pkgsrc users are people who use the packages provided by pkgsrc.
566: Typically they are system administrators. The people using the
567: software that is inside the packages (maybe called “<span class="quote">end
568: users</span>”) are not covered by the pkgsrc guide.</p>
569: <p>There are two kinds of pkgsrc users: Some only want to
570: install pre-built binary packages. Others build the pkgsrc
571: packages from source, either for installing them directly or for
572: 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
573: documentation.</p>
574: </dd>
575: <dt><span class="term">package maintainers</span></dt>
576: <dd><p>A
577: 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>
578: <dt><span class="term">infrastructure developers</span></dt>
579: <dd><p>These people are involved in all those files
1.76 rillig 580: that live in the <code class="filename">mk/</code> directory and below.
1.75 rillig 581: 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,
582: too.</p></dd>
583: </dl></div>
584: </div>
585: </div>
586: <div class="sect1" lang="en">
587: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
588: <a name="typography"></a>1.4. Typography</h2></div></div></div>
589: <p>When giving examples for commands, shell prompts are used to
590: show if the command should/can be issued as root, or if
591: “<span class="quote">normal</span>” user privileges are sufficient. We use a
592: <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
593: shell prompt, assuming they use the C-shell or tcsh.</p>
594: </div>
595: </div>
596: <div class="part" lang="en">
597: <div class="titlepage"><div><div><h1 class="title">
598: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
599: <div class="toc">
600: <p><b>Table of Contents</b></p>
601: <dl>
602: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
603: <dd><dl>
604: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
605: <dd><dl>
606: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
607: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
608: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
609: </dl></dd>
610: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
611: <dd><dl>
612: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
613: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
614: </dl></dd>
615: </dl></dd>
616: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
617: <dd><dl>
618: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
619: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
620: <dd><dl>
621: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
622: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
623: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
624: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
625: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
626: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
627: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
628: </dl></dd>
629: </dl></dd>
630: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
631: <dd><dl>
632: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
633: <dd><dl>
634: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
635: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
636: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
637: </dl></dd>
638: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
639: <dd><dl>
640: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
641: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
642: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
643: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
644: </dl></dd>
645: </dl></dd>
646: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
647: <dd><dl>
648: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
649: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 650: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
651: <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>
652: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
653: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 654: </dl></dd>
655: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
656: <dd><dl>
657: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
658: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
659: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
660: <dd><dl>
661: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
662: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
663: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
664: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
665: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
666: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
667: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
668: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
669: </dl></dd>
670: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
671: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
672: </dl></dd>
673: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
674: <dd><dl>
675: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
676: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
677: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
678: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
679: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
680: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
681: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
682: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
683: <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>
684: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
685: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
686: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
687: <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>
688: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
689: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
690: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
691: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
1.80 rillig 692: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.75 rillig 693: </dl></dd>
694: </dl>
695: </div>
696: <div class="chapter" lang="en">
697: <div class="titlepage"><div><div><h2 class="title">
698: <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
699: <div class="toc">
700: <p><b>Table of Contents</b></p>
701: <dl>
702: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
703: <dd><dl>
704: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
705: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
706: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
707: </dl></dd>
708: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
709: <dd><dl>
710: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
711: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
712: </dl></dd>
713: </dl>
714: </div>
715: <p>The most common location where pkgsrc is installed is
1.76 rillig 716: <code class="filename">/usr/pkgsrc</code> for the “<span class="quote">package
717: sources</span>” and <code class="filename">/usr/pkg</code> for the
1.75 rillig 718: installed binary packages. You are though free to install the
719: sources and binary packages wherever you want in your
720: filesystem, provided that both paths do not contain white-space
721: or other characters that are interpreted specially by the shell
722: and some other programs. A safe bet is to use only letters,
723: digits, underscores and dashes in the names.</p>
724: <div class="sect1" lang="en">
725: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
726: <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
727: <p>Before you download any pkgsrc files, you should decide
728: whether you want the <span class="emphasis"><em>current</em></span> branch or the
729: <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
730: quarterly basis from the current branch and only gets modified
731: for security updates. The names of the stable branches are built
732: from the year and the quarter, for example
733: <code class="literal">2006Q1</code>.</p>
734: <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
735: want to download pkgsrc. You can get it as a tar file, via SUP,
736: or via CVS. All three ways are described here.</p>
737: <div class="sect2" lang="en">
738: <div class="titlepage"><div><div><h3 class="title">
739: <a name="getting-via-tar"></a>2.1.1. As tar file</h3></div></div></div>
740: <p>The primary download location for all pkgsrc files is
741: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>. There are a
742: number of subdirectories for different purposes, which are
1.76 rillig 743: 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 744: <p>The tar file for the current branch is in the directory
1.76 rillig 745: <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 746: It is autogenerated daily.</p>
747: <p>The tar file for the stable branch 2006Q1 is in the
1.76 rillig 748: 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 749: <p>After downloading the tar file, change to the directory
750: where you want to have pkgsrc. This is usually
1.76 rillig 751: <code class="filename">/usr</code>. Then, run <span><strong class="command">tar xfz
1.75 rillig 752: pkgsrc.tar.gz</strong></span> to extract the files.</p>
753: </div>
754: <div class="sect2" lang="en">
755: <div class="titlepage"><div><div><h3 class="title">
756: <a name="getting-via-sup"></a>2.1.2. Via SUP</h3></div></div></div>
757: <p>As an alternative to the tar file, you can get pkgsrc via
758: the Software Update Protocol, SUP. To do so, make sure your
759: supfile has a line
1.1 grant 760:
1.75 rillig 761: </p>
762: <pre class="programlisting">
1.51 rillig 763: release=pkgsrc
1.1 grant 764: </pre>
1.75 rillig 765: <p>
1.1 grant 766:
1.75 rillig 767: in it, see the examples in
1.76 rillig 768: <code class="filename">/usr/share/examples/supfiles</code>, and that the
769: <code class="filename">/usr/pkgsrc</code> directory exists. Then, simply
1.75 rillig 770: run <span><strong class="command">sup -v
771: <em class="replaceable"><code>/path/to/your/supfile</code></em></strong></span>.</p>
772: </div>
773: <div class="sect2" lang="en">
774: <div class="titlepage"><div><div><h3 class="title">
775: <a name="getting-via-cvs"></a>2.1.3. Via CVS</h3></div></div></div>
776: <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>
777: installed. To do an initial (full) checkout of pkgsrc, you first
778: have to set some environment variables. For the C-Shell,
779: type:</p>
780: <pre class="screen">
781: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
782: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVS_RSH ssh</code></strong>
783: </pre>
784: <p>Or, the same for the bourne shell:</p>
785: <pre class="screen">
786: <code class="prompt">$</code> <strong class="userinput"><code>CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"</code></strong>
787: <code class="prompt">$</code> <strong class="userinput"><code>CVS_RSH="ssh"</code></strong>
788: <code class="prompt">$</code> <strong class="userinput"><code>export CVSROOT CVS_RSH</code></strong>
789: </pre>
790: <p>Then, you change to the directory where you want to have
791: your copy of pkgsrc. In most cases this is
1.76 rillig 792: <code class="filename">/usr</code>. In that directory you run the
1.75 rillig 793: checkout command, which is <span><strong class="command">cvs -q checkout -P
794: pkgsrc</strong></span> for the current branch and <span><strong class="command">cvs -q
795: checkout -rpkgsrc-2006Q1 -P pkgsrc</strong></span> for the stable
796: branch. This command will create a directory called
1.76 rillig 797: <code class="filename">pkgsrc</code> with all the pkgsrc files in
1.75 rillig 798: it.</p>
799: </div>
800: </div>
801: <div class="sect1" lang="en">
802: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
803: <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
804: <p>The preferred way to keep pkgsrc up-to-date is via CVS
805: (which also works if you have first installed it via a tar
806: file). It saves bandwidth and hard disk activity, compared to
807: downloading the tar file again.</p>
808: <div class="sect2" lang="en">
809: <div class="titlepage"><div><div><h3 class="title">
810: <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
811: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
812: <h3 class="title">Warning</h3>
1.77 rillig 813: <p>When updating from a tar file, you first need to
814: completely remove the old pkgsrc directory. Otherwise those
815: files that have been removed from pkgsrc in the mean time will
816: not be removed on your local disk, resulting in inconsistencies.
817: When removing the old files, any changes that you have done to
818: the pkgsrc files will be lost after updating. Therefore updating
819: via CVS is strongly recommended.</p>
1.75 rillig 820: </div>
821: <p>To update pkgsrc from a tar file, download the tar file as
822: explained above. Then, make sure that you have not made any
823: changes to the files in the pkgsrc directory. Remove the pkgsrc
824: directory and extract the new tar file. Done.</p>
825: </div>
826: <div class="sect2" lang="en">
827: <div class="titlepage"><div><div><h3 class="title">
828: <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
829: <p>To update pkgsrc via CVS, make sure the environment
830: variable <code class="varname">CVS_RSH</code> is set as above. Then,
831: change to the pkgsrc directory and run <span><strong class="command">cvs -q update
1.77 rillig 832: -dP</strong></span>.</p>
1.75 rillig 833: <div class="sect3" lang="en">
834: <div class="titlepage"><div><div><h4 class="title">
835: <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
836: <p>When updating pkgsrc, the CVS program keeps track of the
837: branch you selected. But if you, for whatever reason, want to
838: switch from the stable branch to the current one, you can do it
839: by adding the option “<span class="quote">-A</span>” after the
840: “<span class="quote">update</span>” keyword. To switch from the current branch
841: back to the stable branch, add the
842: “<span class="quote">-rpkgsrc-2006Q1</span>” option.</p>
843: </div>
844: <div class="sect3" lang="en">
845: <div class="titlepage"><div><div><h4 class="title">
846: <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
847: <p>When you update pkgsrc, the CVS program will only touch
848: those files that are registered in the CVS repository. That
849: means that any packages that you created on your own will stay
850: unmodified. If you change files that are managed by CVS, later
851: updates will try to merge your changes with those that have been
852: done by others. See the CVS manual, chapter
853: “<span class="quote">update</span>” for details.</p>
854: </div>
855: </div>
856: </div>
857: </div>
858: <div class="chapter" lang="en">
859: <div class="titlepage"><div><div><h2 class="title">
860: <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
861: <div class="toc">
862: <p><b>Table of Contents</b></p>
863: <dl>
864: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
865: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
866: <dd><dl>
867: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
868: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
869: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
870: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
871: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
872: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
873: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
874: </dl></dd>
875: </dl>
876: </div>
877: <div class="sect1" lang="en">
878: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
879: <a name="bootstrapping-pkgsrc"></a>3.1. Bootstrapping pkgsrc</h2></div></div></div>
880: <p>For operating systems other than NetBSD, we provide a bootstrap kit to
881: build the required tools to use pkgsrc on your platform. Besides
882: support for native NetBSD, pkgsrc and the bootstrap kit have support for
883: the following operating systems:</p>
884: <div class="itemizedlist"><ul type="disc">
885: <li><p>Darwin (Mac OS X)</p></li>
886: <li><p>DragonFly BSD</p></li>
887: <li><p>FreeBSD</p></li>
888: <li><p>Interix (Windows 2000, XP, 2003)</p></li>
889: <li><p>IRIX</p></li>
890: <li><p>Linux</p></li>
891: <li><p>OpenBSD</p></li>
892: <li><p>Solaris</p></li>
893: <li><p>Tru64 (Digital UNIX/OSF1)</p></li>
894: </ul></div>
895: <p>Support for other platforms is under development.</p>
896: <p>Installing the bootstrap kit should be as simple as:</p>
897: <pre class="screen">
898: <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
899: <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
900: <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong></pre>
901: <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
902: pkgsrc before bootstrapping. The given
903: <span><strong class="command">bootstrap</strong></span> command will use the defaults of
1.76 rillig 904: <code class="filename">/usr/pkg</code> for the
1.75 rillig 905: <span class="emphasis"><em>prefix</em></span> where programs will be installed in,
1.76 rillig 906: and <code class="filename">/var/db/pkg</code> for the package database
1.75 rillig 907: directory where pkgsrc will do its internal bookkeeping.
908: However, these can also be set using command-line
909: arguments.</p>
910: <p>Binary packages for the pkgsrc tools and an initial set of packages is
911: available for supported platforms. An up-to-date list of these can be
912: found on <a href="http://www.pkgsrc.org/" target="_top">www.pkgsrc.org</a>.
913: Note that this only works for privileged builds that install
1.76 rillig 914: into <code class="filename">/usr/pkg</code>.</p>
1.75 rillig 915: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
916: <h3 class="title">Note</h3>
917: <p>The bootstrap installs a <span><strong class="command">bmake</strong></span> tool.
918: Use this <span><strong class="command">bmake</strong></span> when building via pkgsrc.
919: For examples in this guide, use <span><strong class="command">bmake</strong></span>
920: instead of “<span class="quote">make</span>”.</p>
921: </div>
922: </div>
923: <div class="sect1" lang="en">
924: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
925: <a name="platform-specific-notes"></a>3.2. Platform-specific notes</h2></div></div></div>
926: <p>Here are some platform-specific notes you should be aware of.</p>
927: <div class="sect2" lang="en">
928: <div class="titlepage"><div><div><h3 class="title">
929: <a name="darwin"></a>3.2.1. Darwin (Mac OS X)</h3></div></div></div>
930: <p>Darwin 5.x and 6.x are supported. There are two methods of using
931: pkgsrc on Mac OS X, by using a <a href="#platform.osx-image" title="3.2.1.1. Using a disk image">disk
932: image</a>, or a <a href="#platform.osx-ufs" title="3.2.1.2. Using a UFS partition">UFS
933: partition</a>.</p>
934: <p>Before you start, you will need to download and install the Mac OS X Developer
935: Tools from Apple's Developer Connection. See <a href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
936: for details. Also, make sure you install X11 for Mac OS X and the X11 SDK
937: from <a href="http://www.apple.com/macosx/x11/download/" target="_top">http://www.apple.com/macosx/x11/download/</a>
938: if you intend to build packages that use the X11 Window System.</p>
939: <p>If you already have a UFS partition, or have a spare partition
940: that you can format as UFS, it is recommended to use that instead of
941: the disk image. It'll be somewhat faster and will mount automatically
942: at boot time, where you must manually mount a disk image.</p>
943: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
944: <h3 class="title">Note</h3>
945: <p>You cannot use a HFS+ file system for pkgsrc, because pkgsrc currently
946: requires the file system to be case-sensitive, and HFS+ is not.</p>
947: </div>
948: <div class="sect3" lang="en">
949: <div class="titlepage"><div><div><h4 class="title">
950: <a name="platform.osx-image"></a>3.2.1.1. Using a disk image</h4></div></div></div>
951: <p>Create the disk image:</p>
952: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
953: <code class="prompt">#</code> <strong class="userinput"><code>./ufsdiskimage create ~/Documents/NetBSD 512</code></strong> # megabytes - season to taste
954: <code class="prompt">#</code> <strong class="userinput"><code>./ufsdiskimage mount ~/Documents/NetBSD</code></strong>
955: <code class="prompt">#</code> <strong class="userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong></pre>
956: <p>That's it!</p>
957: </div>
958: <div class="sect3" lang="en">
959: <div class="titlepage"><div><div><h4 class="title">
960: <a name="platform.osx-ufs"></a>3.2.1.2. Using a UFS partition</h4></div></div></div>
1.76 rillig 961: <p>By default, <code class="filename">/usr</code> will be on your root file
1.75 rillig 962: system, normally HFS+. It is possible to use the default
1.76 rillig 963: <span class="emphasis"><em>prefix</em></span> of <code class="filename">/usr/pkg</code>
964: by symlinking <code class="filename">/usr/pkg</code> to a directory on a UFS
1.75 rillig 965: file system. Obviously, another symlink is required if you want to
966: place the package database directory outside the
967: <span class="emphasis"><em>prefix</em></span>. e.g.</p>
968: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb</code></strong></pre>
969: <p>If you created your partitions at the time of installing Mac OS X
970: and formatted the target partition as UFS, it should automatically
1.76 rillig 971: mount on <code class="filename">/Volumes/<volume name></code> when the
1.75 rillig 972: machine boots. If you are (re)formatting a partition as UFS, you need
973: to ensure that the partition map correctly reflects
974: “<span class="quote">Apple_UFS</span>” and not “<span class="quote">Apple_HFS</span>”.</p>
975: <p>The problem is that none of the disk tools will let you touch a
976: disk that is booted from. You can unmount the partition, but even if
977: you newfs it, the partition type will be incorrect and the
978: automounter won't mount it. It can be mounted manually, but it won't
979: appear in Finder.</p>
980: <p>You'll need to boot off of the OS X Installation (User) CD. When
981: the Installation program starts, go up to the menu and select Disk
982: Utility. Now, you will be able to select the partition you want
983: to be UFS, and Format it Apple UFS. Quit the Disk Utility, quit the
984: installer which will reboot your machine. The new UFS file system
985: will appear in Finder.</p>
986: <p>Be aware that the permissions on the new file system will be writable
987: by root only.</p>
988: <p>This note is as of 10.2 (Jaguar) and applies to earlier versions.
989: Hopefully Apple will fix Disk Utility in 10.3 (Panther).</p>
990: </div>
991: </div>
992: <div class="sect2" lang="en">
993: <div class="titlepage"><div><div><h3 class="title">
994: <a name="freebsd"></a>3.2.2. FreeBSD</h3></div></div></div>
995: <p>
996: FreeBSD 4.7 and 5.0 have been tested and are supported, other versions
997: may work.</p>
998: <p>Care should be taken so that the tools that this kit installs do not conflict
999: with the FreeBSD userland tools. There are several steps:</p>
1000: <div class="orderedlist"><ol type="1">
1001: <li><p>FreeBSD stores its ports pkg database in
1.76 rillig 1002: <code class="filename">/var/db/pkg</code>. It is therefore
1.75 rillig 1003: recommended that you choose a different location (e.g.
1.76 rillig 1004: <code class="filename">/usr/pkgdb</code>) by
1.75 rillig 1005: using the --pkgdbdir option to the bootstrap script.</p></li>
1006: <li>
1007: <p>If you do not intend to use the FreeBSD ports tools, it's probably a
1008: good idea to move them out of the way to avoid confusion, e.g.</p>
1009: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1010: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1011: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1012: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1013: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
1014: </li>
1.76 rillig 1015: <li><p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1016: <code class="filename">/etc/mk.conf.example</code> file
1.75 rillig 1017: when you use the bootstrap script.</p></li>
1018: </ol></div>
1019: </div>
1020: <div class="sect2" lang="en">
1021: <div class="titlepage"><div><div><h3 class="title">
1022: <a name="interix"></a>3.2.3. Interix</h3></div></div></div>
1023: <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
1024: providing a Unix-like environment with a tighter kernel integration than
1025: available with Cygwin. It is part of the Windows Services for Unix
1026: package, available for free for any licensed copy of Windows 2000, XP
1027: (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>
1028: <p>Services for Unix 3.5, current as of this writing, has been tested. 3.0
1029: or 3.1 may work, but are not officially supported. (The main difference
1030: in 3.0/3.1 is lack of pthreads.)</p>
1031: <div class="sect3" lang="en">
1032: <div class="titlepage"><div><div><h4 class="title">
1033: <a name="platform.interix-sfu-install"></a>3.2.3.1. When installing Interix/SFU</h4></div></div></div>
1034: <p>At an absolute minimum, the following packages must be installed from
1035: the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
1036: <div class="itemizedlist"><ul type="disc">
1037: <li><p>Utilities -> Base Utilities</p></li>
1038: <li><p>Interix GNU Components -> (all)</p></li>
1039: <li><p>Remote Connectivity</p></li>
1040: <li><p>Interix SDK</p></li>
1041: </ul></div>
1042: <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
1043: "UNIX Perl". That is Perl 5.6 without shared module support, installed to
1044: /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
1045: pkgsrc (or from a binary package).</p>
1046: <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
1047: not need to be installed, but Remote Connectivity itself should be
1048: installed in order to have a working inetd.</p>
1049: <p>During installation you may be asked whether to enable setuid
1050: behavior for Interix programs, and whether to make pathnames default to
1051: case-sensitive. Setuid should be enabled, and case-sensitivity MUST be
1052: enabled. (Without case-sensitivity, a large number of packages including
1053: perl will not build.)</p>
1054: <p>NOTE: Newer Windows service packs change the way binary execution
1055: works (via the Data Execution Prevention feature). In order to use
1056: pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
1057: POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
1058: must be installed. Hotfixes are available from Microsoft through a
1059: support contract; however, a NetBSD developer has made most Interix
1060: 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>
1061: </div>
1062: <div class="sect3" lang="en">
1063: <div class="titlepage"><div><div><h4 class="title">
1064: <a name="platform.interix-sfu-postinstall"></a>3.2.3.2. What to do if Interix/SFU is already installed</h4></div></div></div>
1065: <p>If SFU is already installed and you wish to alter these settings to work
1066: with pkgsrc, note the following things.</p>
1067: <div class="itemizedlist"><ul type="disc">
1068: <li><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
1069: Windows Services for UNIX, then click Change. In the installer, choose
1070: Add or Remove, then uncheck Utilities->UNIX Perl.</p></li>
1071: <li>
1072: <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
1073: change the following registry key:</p>
1074: <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
1075: <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
1076: </li>
1077: <li>
1078: <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
1079: following registry key:</p>
1080: <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
1081: <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
1082: </li>
1083: </ul></div>
1084: </div>
1085: <div class="sect3" lang="en">
1086: <div class="titlepage"><div><div><h4 class="title">
1087: <a name="platform.interix-notes"></a>3.2.3.3. Important notes for using pkgsrc</h4></div></div></div>
1088: <p>The package manager (either the pkgsrc "su" user, or the user
1089: running "pkg_add") must be a member of the local Administrators
1090: group. Such a user must also be used to run the bootstrap. This is
1091: slightly relaxed from the normal pkgsrc requirement of "root".</p>
1092: <p>The package manager should use a umask of 002. "make install" will
1093: automatically complain if this is not the case. This ensures that
1094: directories written in /var/db/pkg are Administrators-group writeable.</p>
1095: <p>The popular Interix binary packages from http://www.interopsystems.com/
1096: use an older version of pkgsrc's pkg_* tools. Ideally, these should
1097: NOT be used in conjunction with pkgsrc. If you choose to use them at
1098: the same time as the pkgsrc packages, ensure that you use the proper
1099: pkg_* tools for each type of binary package.</p>
1100: <p>The TERM setting used for DOS-type console windows (including those
1101: invoked by the csh and ksh startup shortcuts) is "interix". Most systems
1102: don't have a termcap/terminfo entry for it, but the following .termcap
1103: entry provides adequate emulation in most cases:</p>
1104: <pre class="programlisting">
1105: interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
1106: </pre>
1107: </div>
1108: <div class="sect3" lang="en">
1109: <div class="titlepage"><div><div><h4 class="title">
1110: <a name="platform.interix-limits"></a>3.2.3.4. Limitations of the Interix platform</h4></div></div></div>
1111: <p>Though Interix suffices as a familiar and flexible substitute
1112: for a full Unix-like platform, it has some drawbacks that should
1113: be noted for those desiring to make the most of Interix.</p>
1114: <div class="itemizedlist"><ul type="disc">
1115: <li>
1116: <p><span class="strong"><strong>X11:</strong></span></p>
1117: <p>Interix comes with the standard set of X11R6 client libraries,
1118: and can run X11 based applications, but it does
1119: <span class="emphasis"><em>not</em></span> come with an X server. Some options are
1120: <a href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
1121: <a href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
1122: (available in a trimmed version for Interix from Interop Systems as the
1123: <a href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
1124: and the free X11 server included with
1125: <a href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
1126: <p>Also, StarNet Communications has graciously provided a free
1127: version of their X-Win32 product that accepts connections only
1128: from localhost:
1129: <a href="http://www.starnet.com/xwin32LX/get_xwin32LX.htm" target="_top">X-Win32 LX</a>,
1130: recommended by the maintainer of Interix pkgsrc support.</p>
1131: </li>
1132: <li>
1133: <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
1134: <p>Because Interix runs in a completely different NT subsystem from
1135: Win32 applications, it does not currently support various X11
1136: protocol extensions for acceleration (such as MIT-SHM or DGA).
1137: Most interactive applications to a local X server will run
1138: reasonably fast, but full motion video and other graphics
1139: intensive applications may require a faster-than-expected CPU.</p>
1140: </li>
1141: <li>
1142: <p><span class="strong"><strong>Audio:</strong></span></p>
1143: <p>Interix has no native support for audio output. For audio
1144: support, pkgsrc uses the <span><strong class="command">esound</strong></span> client/server
1145: audio system on Interix. Unlike on most platforms, the
1.76 rillig 1146: <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 1147: <span class="emphasis"><em>not</em></span> contain the <span><strong class="command">esd</strong></span>
1148: server component. To output audio via an Interix host, the
1.76 rillig 1149: <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 1150: must also be installed.</p>
1151: </li>
1152: <li>
1153: <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
1154: <p>Direct device access is not currently supported in Interix, so it
1155: is not currently possible to access CD/DVD drives, USB devices,
1156: or SCSI devices through non-filesystem means. Among other things,
1157: this makes it impossible to use Interix directly for CD/DVD
1158: burning.</p>
1159: </li>
1160: <li>
1161: <p><span class="strong"><strong>Tape drives:</strong></span></p>
1162: <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
1163: drives are also not directly accessible in Interix. However,
1164: support is in work to make tape drive access possible by using
1165: Cygwin as a bridge (similarly to audio bridged via Cygwin's
1166: esound server).</p>
1167: </li>
1168: </ul></div>
1169: </div>
1170: <div class="sect3" lang="en">
1171: <div class="titlepage"><div><div><h4 class="title">
1172: <a name="platform.interix-knownissues"></a>3.2.3.5. Known issues for pkgsrc on Interix</h4></div></div></div>
1173: <p>It is not necessary, in general, to have a "root" user on the
1174: Windows system; any member of the local Administrators group will
1175: suffice. However, some packages currently assume that the user
1176: named "root" is the privileged user. To accommodate these, you
1177: may create such a user; make sure it is in the local group
1178: Administrators (or your language equivalent).</p>
1179: <p>"pkg_add" creates directories of mode 0755, not 0775, in
1180: $PKG_DBDIR. For the time being, install packages as the local
1181: Administrator (or your language equivalent), or run the following
1182: command after installing a package to work around the issue:</p>
1183: <pre class="screen">
1184: <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong></pre>
1185: </div>
1186: </div>
1187: <div class="sect2" lang="en">
1188: <div class="titlepage"><div><div><h3 class="title">
1189: <a name="irix"></a>3.2.4. IRIX</h3></div></div></div>
1190: <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
1191: compiler (cc/c89). Please set the <code class="varname">CC</code> environment variable
1192: according to your preference. If you do not have a license for the MIPSpro
1193: compiler suite, you can download a gcc tardist file from <a href="http://freeware.sgi.com/" target="_top">http://freeware.sgi.com/</a>.</p>
1194: <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
1195: 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>,
1196: etc.</p>
1197: <p>At this point in time, pkgsrc only supports one ABI at a time. That is, you can not
1198: switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI. If
1199: you start out using "abi=n32", that's what all your packages will be built
1200: with.</p>
1201: <p>Therefore, please make sure that you have no conflicting
1202: <code class="varname">CFLAGS</code> in your environment or the
1.76 rillig 1203: <code class="filename">/etc/mk.conf</code>. Particularly, make sure that you do not
1.75 rillig 1204: try to link n32 object files with lib64 or vice versa. Check your
1.76 rillig 1205: <code class="filename">/etc/compiler.defaults</code>!</p>
1.75 rillig 1206: <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
1207: please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
1208: as it appears that IRIX linker occasionally runs into issues when trying to
1209: link over a network-mounted file system.</p>
1210: <p>The bootstrapping process should set all the right options for programs such
1211: as imake(1), but you may want to set some options depending on your local
1.76 rillig 1212: setup. Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
1.75 rillig 1213: course, your compiler's man pages for details.</p>
1214: <p>If you are using SGI's MIPSPro compiler, please set
1.1 grant 1215:
1.75 rillig 1216: </p>
1217: <pre class="programlisting">
1218: PKGSRC_COMPILER= mipspro
1219: </pre>
1220: <p>
1.1 grant 1221:
1.76 rillig 1222: in <code class="filename">/etc/mk.conf</code>. Otherwise, pkgsrc will assume you
1.75 rillig 1223: are using gcc and may end up passing invalid flags to the compiler. Note that
1.76 rillig 1224: bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
1.75 rillig 1225: default.</p>
1226: <p>If you have both the MIPSPro compiler chain installed as well as gcc,
1227: but want to make sure that MIPRPro is used, please set your <code class="varname">PATH</code>
1228: to <span class="emphasis"><em>not</em></span> include the location of gcc (often
1.76 rillig 1229: <code class="filename">/usr/freeware/bin</code>), and (important) pass the
1.75 rillig 1230: '--preserve-path' flag.</p>
1231: </div>
1232: <div class="sect2" lang="en">
1233: <div class="titlepage"><div><div><h3 class="title">
1234: <a name="linux"></a>3.2.5. Linux</h3></div></div></div>
1235: <p>
1236: Some versions of Linux (for example Debian GNU/Linux) need either
1237: libtermcap or libcurses (libncurses). Installing the distributions
1238: libncurses-dev package (or equivalent) should fix the problem.</p>
1239: <p>
1240: pkgsrc supports both gcc (GNU Compiler Collection) and icc (Intel C++
1241: Compiler). gcc is the default. icc 8.0 and 8.1 on i386 have been tested.
1242: </p>
1243: <p>To bootstrap using icc, assuming the default icc installation
1244: directory:</p>
1245: <pre class="programlisting">
1246: env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
1247: ac_cv___attribute__=yes ./bootstrap
1248: </pre>
1249: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1250: <h3 class="title">Note</h3>
1251: <p>icc 8.1 needs the `-i-static' argument instead of -static-libcxa.</p>
1252: </div>
1253: <p>icc supports __attribute__, but the GNU configure test uses a nested
1254: function, which icc does not support. #undef'ing __attribute__ has the
1255: unfortunate side-effect of breaking many of the Linux header files, which
1256: cannot be compiled properly without __attribute__. The test must be
1257: overridden so that __attribute__ is assumed supported by the
1258: compiler.</p>
1259: <p>After bootstrapping, you should set <code class="varname">PKGSRC_COMPILER</code>
1.76 rillig 1260: in <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1261: <pre class="programlisting">
1262: PKGSRC_COMPILER= icc
1263: </pre>
1264: <p>The default installation directory for icc is
1.76 rillig 1265: <code class="filename">/opt/intel_cc_80</code>, which
1.75 rillig 1266: is also the pkgsrc default. If you have installed it into a different
1267: directory, set <code class="varname">ICCBASE</code> in
1.76 rillig 1268: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1269: <pre class="programlisting">
1270: ICCBASE= /opt/icc
1271: </pre>
1272: <p>pkgsrc uses the static linking method of the runtime libraries
1273: provided by icc, so binaries can be run on other systems which do not
1274: have the shared libraries installed.</p>
1275: <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>
1276: command run when linking a C++ shared library and records it, throwing
1277: away the -Bstatic and -Bdynamic options interspersed between the libraries.
1278: This means that libtool-linked C++ shared libraries will have a
1279: runtime dependency on the icc libraries until this is fixed in libtool.
1280: </p>
1281: </div>
1282: <div class="sect2" lang="en">
1283: <div class="titlepage"><div><div><h3 class="title">
1284: <a name="openbsd"></a>3.2.6. OpenBSD</h3></div></div></div>
1285: <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
1286: <p>Care should be taken so that the tools that this kit installs do not conflict
1287: with the OpenBSD userland tools. There are several steps:</p>
1288: <div class="orderedlist"><ol type="1">
1289: <li><p>OpenBSD stores its ports pkg database in
1.76 rillig 1290: <code class="filename">/var/db/pkg</code>. It is therefore
1.75 rillig 1291: recommended that you choose a different location (e.g.
1.76 rillig 1292: <code class="filename">/usr/pkgdb</code>) by
1.75 rillig 1293: using the --pkgdbdir option to the bootstrap script.</p></li>
1294: <li>
1295: <p>If you do not intend to use the OpenBSD ports tools, it's probably a
1296: good idea to move them out of the way to avoid confusion, e.g.</p>
1297: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1298: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1299: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1300: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1301: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
1302: </li>
1303: <li>
1.76 rillig 1304: <p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1305: <code class="filename">/etc/mk.conf.example</code> file
1.75 rillig 1306: when you use the bootstrap script. OpenBSD's make program uses
1.76 rillig 1307: <code class="filename">/etc/mk.conf</code>
1.75 rillig 1308: as well. You can work around this by enclosing all the pkgsrc-specific parts
1309: of the file with:</p>
1310: <pre class="programlisting">
1311: .ifdef BSD_PKG_MK
1312: # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
1313: .else
1314: # OpenBSD stuff
1.1 grant 1315: .endif
1316: </pre>
1.75 rillig 1317: </li>
1318: </ol></div>
1319: </div>
1320: <div class="sect2" lang="en">
1321: <div class="titlepage"><div><div><h3 class="title">
1322: <a name="solaris"></a>3.2.7. Solaris</h3></div></div></div>
1323: <p>Solaris 2.6 through 9 are supported on both x86 and sparc.
1324: You will need a working C compiler. Both gcc 2.95.3 and
1325: Sun WorkShop 5 have been tested.</p>
1326: <p>The following packages are required on Solaris 8 for the bootstrap
1327: process and to build packages.</p>
1328: <div class="itemizedlist"><ul type="disc">
1329: <li><p>SUNWsprot</p></li>
1330: <li><p>SUNWarc</p></li>
1331: <li><p>SUNWbtool</p></li>
1332: <li><p>SUNWtoo</p></li>
1333: <li><p>SUNWlibm</p></li>
1334: </ul></div>
1.78 rillig 1335: <p>Please note that the use of GNU binutils on Solaris is
1336: <span class="emphasis"><em>not</em></span> supported, as of June 2006.</p>
1.75 rillig 1337: <p>Whichever compiler you use, please ensure the compiler tools and
1338: your $prefix are in your <code class="varname">PATH</code>. This includes
1.76 rillig 1339: <code class="filename">/usr/ccs/{bin,lib}</code>
1340: and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1.75 rillig 1341: <div class="sect3" lang="en">
1342: <div class="titlepage"><div><div><h4 class="title">
1343: <a name="solaris-gcc-note"></a>3.2.7.1. If you are using gcc</h4></div></div></div>
1344: <p>It makes life much simpler if you only use the same gcc consistently
1345: for building all packages.</p>
1346: <p>It is recommended that an external gcc be used only for bootstrapping,
1347: then either build gcc from
1.76 rillig 1348: <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 1349: package, then remove gcc used during bootstrapping.</p>
1350: <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>
1351: </div>
1352: <div class="sect3" lang="en">
1353: <div class="titlepage"><div><div><h4 class="title">
1354: <a name="solaris-sun-workshop-note"></a>3.2.7.2. If you are using Sun WorkShop</h4></div></div></div>
1355: <p>You will need at least the following packages installed (from WorkShop
1356: 5.0)</p>
1357: <div class="itemizedlist"><ul type="disc">
1358: <li><p>SPROcc
1359: - Sun WorkShop Compiler C 5.0</p></li>
1360: <li><p>SPROcpl
1361: - Sun WorkShop Compiler C++ 5.0</p></li>
1362: <li><p>SPROild
1363: - Sun WorkShop Incremental Linker</p></li>
1364: <li><p>SPROlang
1365: - Sun WorkShop Compilers common components</p></li>
1366: </ul></div>
1367: <p>You should set <code class="varname">CC</code>, <code class="varname">CXX</code> and
1.76 rillig 1368: optionally, <code class="varname">CPP</code> in <code class="filename">/etc/mk.conf</code>,
1.75 rillig 1369: e.g.:</p>
1370: <pre class="programlisting">
1371: CC= cc
1372: CXX= CC
1373: CPP= /usr/ccs/lib/cpp
1.1 grant 1374: </pre>
1.75 rillig 1375: </div>
1376: <div class="sect3" lang="en">
1377: <div class="titlepage"><div><div><h4 class="title">
1378: <a name="solaris-sunpro-64"></a>3.2.7.3. Buildling 64-bit binaries with SunPro</h4></div></div></div>
1379: <p>Building 64-bit binaries is a little trickier. First, you
1380: need to bootstrap pkgsrc in 64-bit mode. One problem here is
1381: that while building one of the programs in the bootstrap kit
1.76 rillig 1382: (<code class="filename">bmake</code>), the <code class="varname">CFLAGS</code>
1.75 rillig 1383: variable is not honored, even if it is set in the environment.
1384: To work around this bug, you can create a simple shell script
1.76 rillig 1385: called <code class="filename">cc64</code> and put it somewhere in the
1.75 rillig 1386: <code class="varname">PATH</code>:</p>
1387: <pre class="programlisting">
1388: #! /bin/sh
1389: exec /opt/SUNWspro/bin/cc -xtarget=ultra -xarch=v9 ${1+"$@"}
1.1 grant 1390: </pre>
1.75 rillig 1391: <p>Then, pass the definition for <code class="varname">CC</code> in the
1392: environment of the <span><strong class="command">bootstrap</strong></span> command:</p>
1393: <pre class="programlisting">
1394: <code class="prompt">$</code> <strong class="userinput"><code>cd bootstrap</code></strong>
1395: <code class="prompt">$</code> <strong class="userinput"><code>CC=cc64 ./bootstrap</code></strong>
1396: </pre>
1397: <p>After bootstrapping, there are two alternative ways,
1398: depending on whether you want to find bugs in packages or get
1399: your system ready quickly. If you just want a running system,
1.76 rillig 1400: add the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1401: file:</p>
1402: <pre class="programlisting">
1403: CC= cc64
1404: CXX= CC64
1405: PKGSRC_COMPILER= sunpro
1.1 grant 1406: </pre>
1.75 rillig 1407: <p>This way, all calls to the compiler will be intercepted by
1408: the above wrapper and therefore get the necessary ABI options
1409: automatically. (Don't forget to create the shell script
1.76 rillig 1410: <code class="filename">CC64</code>, too.)</p>
1.75 rillig 1411: <p>To find packages that ignore the user-specified
1412: <code class="varname">CFLAGS</code> and <code class="varname">CXXFLAGS</code>, add
1.76 rillig 1413: the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1414: file:</p>
1415: <pre class="programlisting">
1416: CC= cc
1417: CXX= CC
1418: PKGSRC_COMPILER= sunpro
1419: CFLAGS= -xtarget=ultra -xarch=v9
1420: CXXFLAGS= -xtarget=ultra -xarch=v9
1421: LDFLAGS= -xtarget=ultra -xarch=v9
1.1 grant 1422: </pre>
1.75 rillig 1423: <p>Packages that don't use the flags provided in the
1424: configuration file will try to build 32-bit binaries and fail
1425: during linking. Detecting this is useful to prevent bugs on
1426: other platforms where the error would not show up but pass
1427: silently.</p>
1428: </div>
1429: <div class="sect3" lang="en">
1430: <div class="titlepage"><div><div><h4 class="title">
1431: <a name="plat.sunos.problems"></a>3.2.7.4. Common problems</h4></div></div></div>
1432: <p>Sometimes, when using <span><strong class="command">libtool</strong></span>,
1.76 rillig 1433: <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
1.75 rillig 1434: The workaround is to use another shell for the configure
1.76 rillig 1435: 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
1436: to your <code class="filename">mk.conf</code>:</p>
1.75 rillig 1437: <pre class="programlisting">
1438: CONFIG_SHELL= ${LOCALBASE}/bin/bash
1439: WRAPPER_SHELL= ${LOCALBASE}/bin/bash
1.1 grant 1440: </pre>
1.76 rillig 1441: <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 1442: </div>
1443: </div>
1444: </div>
1445: </div>
1446: <div class="chapter" lang="en">
1447: <div class="titlepage"><div><div><h2 class="title">
1448: <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
1449: <div class="toc">
1450: <p><b>Table of Contents</b></p>
1451: <dl>
1452: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
1453: <dd><dl>
1454: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
1455: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1456: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
1457: </dl></dd>
1458: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
1459: <dd><dl>
1460: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
1461: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
1462: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
1463: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
1464: </dl></dd>
1465: </dl>
1466: </div>
1467: <p>Basically, there are two ways of using pkgsrc. The first
1468: is to only install the package tools and to use binary packages
1469: that someone else has prepared. This is the “<span class="quote">pkg</span>”
1470: in pkgsrc. The second way is to install the “<span class="quote">src</span>”
1471: of pkgsrc, too. Then you are able to build your own packages,
1472: and you can still use binary packages from someone else.</p>
1473: <div class="sect1" lang="en">
1474: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1475: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
1476: <p>To use binary packages, you need some tools to manage
1477: them. On NetBSD, these tools are already installed. On all other
1478: operating systems, you need to install them first. For the
1479: following platforms, prebuilt versions of the package tools
1480: are available and can simply be downloaded and unpacked in the
1.76 rillig 1481: <code class="filename">/</code> directory:</p>
1.75 rillig 1482: <div class="informaltable">
1483: <a name="binary-bootstrap-kits"></a><table border="1">
1484: <colgroup>
1485: <col>
1486: <col>
1487: </colgroup>
1488: <thead><tr>
1489: <th>Platform</th>
1490: <th>URL</th>
1491: </tr></thead>
1492: <tbody>
1493: <tr>
1494: <td>Solaris 9</td>
1.76 rillig 1495: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1496: </tr>
1497: <tr>
1498: <td>Solaris 10</td>
1.76 rillig 1499: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1500: </tr>
1501: </tbody>
1502: </table>
1503: </div>
1504: <p>These prebuilt package tools use
1.76 rillig 1505: <code class="filename">/usr/pkg</code> for the base directory, and
1506: <code class="filename">/var/db/pkg</code> for the database of installed
1.75 rillig 1507: packages. If you cannot use these directories for whatever
1508: reasons (maybe because you're not root), you have to build the
1509: package tools yourself, which is explained in <a href="#bootstrapping-pkgsrc" title="3.1. Bootstrapping pkgsrc">Section 3.1, “Bootstrapping pkgsrc”</a>.</p>
1510: <div class="sect2" lang="en">
1511: <div class="titlepage"><div><div><h3 class="title">
1512: <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
1513: <p>To install binary packages, you first need to know from
1514: where to get them. You can get them on CD-ROMs, DVDs, or via FTP
1515: or HTTP.</p>
1.81 ! rillig 1516: <p>The binary packages can be found at the following
! 1517: locations.</p>
1.75 rillig 1518: <div class="informaltable">
1519: <a name="binary-packages"></a><table border="1">
1520: <colgroup>
1521: <col>
1522: <col>
1523: </colgroup>
1524: <thead><tr>
1525: <th>Platform</th>
1526: <th>URL</th>
1527: </tr></thead>
1528: <tbody>
1529: <tr>
1.81 ! rillig 1530: <td>NetBSD</td>
! 1531: <td><code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/</code></td>
! 1532: </tr>
! 1533: <tr>
1.75 rillig 1534: <td>Solaris 9</td>
1.76 rillig 1535: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/</code></td>
1.75 rillig 1536: </tr>
1537: <tr>
1538: <td>Solaris 10</td>
1.76 rillig 1539: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/</code></td>
1.75 rillig 1540: </tr>
1541: </tbody>
1542: </table>
1543: </div>
1.81 ! rillig 1544: <p>Most of these directories contain binary packages for
! 1545: multiple platforms. Select the appropriate subdirectories,
1.75 rillig 1546: according to your machine architecture and operating system,
1.76 rillig 1547: until you find a directory called <code class="filename">All</code>. This
1.75 rillig 1548: directory contains all the binary packages. Further, there are
1549: subdirectories for categories that contain symbolic links that
1550: point to the actual binary package in
1.76 rillig 1551: <code class="filename">../All</code>. This directory layout is used for
1.75 rillig 1552: all package repositories, no matter if they are accessed via
1553: HTTP, FTP, NFS, CD-ROM, or the local filesystem.</p>
1554: </div>
1555: <div class="sect2" lang="en">
1556: <div class="titlepage"><div><div><h3 class="title">
1557: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
1558: <p> If you have the files on a CD-ROM or downloaded them to
1559: your hard disk, you can install them with the following command
1560: (be sure to <span><strong class="command">su</strong></span> to root first):</p>
1561: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add /path/to/package.tgz</code></strong></pre>
1562: <p> If you have FTP access and you don't want to download the
1563: packages via FTP prior to installation, you can do this
1564: automatically by giving <span><strong class="command">pkg_add</strong></span> an FTP URL:
1565: </p>
1566: <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>
1567: <p>Note that any prerequisite packages needed to run the
1568: package in question will be installed, too, assuming they are
1569: present where you install from. </p>
1570: <p>To save some typing, you can set the
1571: <code class="varname">PKG_PATH</code> environment variable to a semicolon-separated
1572: list of paths (including remote URLs); trailing slashes are not allowed.
1573: </p>
1.76 rillig 1574: <p>Additionally to the <code class="filename">All</code> directory
1575: there exists a <code class="filename">vulnerable</code> directory to
1.75 rillig 1576: which binary packages with known vulnerabilities are
1577: moved, since removing them could cause missing dependencies. To
1.76 rillig 1578: use these packages, add the <code class="filename">vulnerable</code>
1.75 rillig 1579: directory to your <code class="varname">PKG_PATH</code>. However, you should run
1.76 rillig 1580: <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 1581: especially after installing new packages, and verify that the
1582: vulnerabilities are acceptable for your configuration. An example
1583: <code class="varname">PKG_PATH</code> would be:
1.76 rillig 1584: <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 1585: Please note that semicolon (';') is a shell meta-character, so
1586: you'll probably have to quote it.</p>
1587: <p>After you've installed packages, be sure to have
1.76 rillig 1588: <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
1.75 rillig 1589: <code class="varname">PATH</code> so you can actually start the just
1590: installed program. </p>
1591: </div>
1592: <div class="sect2" lang="en">
1593: <div class="titlepage"><div><div><h3 class="title">
1594: <a name="a-word-of-warning"></a>4.1.3. A word of warning</h3></div></div></div>
1595: <p>Please pay very careful attention to the warnings
1596: 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
1597: inherent dangers of installing binary packages which you did
1598: not create yourself, and the security holes that can be
1599: introduced onto your system by indiscriminate adding of such
1600: files.</p>
1601: <p>The same warning of course applies to every package you
1602: install from source when you haven't completely read and
1603: understood the source code of the package, the compiler that
1604: is used to build the package and all the other tools that are
1605: involved.</p>
1606: </div>
1607: </div>
1608: <div class="sect1" lang="en">
1609: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1610: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
1611: <p> This assumes that the package is already in pkgsrc. If it
1612: 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
1613: how to create your own packages.</p>
1614: <div class="sect2" lang="en">
1615: <div class="titlepage"><div><div><h3 class="title">
1616: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
1617: <p> To build packages from source on a NetBSD system the
1618: “<span class="quote">comp</span>” and the “<span class="quote">text</span>” distribution
1619: sets must be installed. If you want to build X11-related
1620: packages the “<span class="quote">xbase</span>” and “<span class="quote">xcomp</span>”
1621: distribution sets are required, too.</p>
1622: </div>
1623: <div class="sect2" lang="en">
1624: <div class="titlepage"><div><div><h3 class="title">
1625: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
1626: <p>The first step for building a package is downloading the
1627: distfiles (i.e. the unmodified source). If they have not yet been
1628: downloaded, pkgsrc will fetch them automatically.</p>
1629: <p>You can overwrite some of the major distribution sites to fit to sites
1630: that are close to your own. Have a look at
1.76 rillig 1631: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find some examples
1.78 rillig 1632: — in particular, look for the <code class="varname">MASTER_SORT</code>,
1.75 rillig 1633: <code class="varname">MASTER_SORT_REGEX</code> and
1634: <code class="varname">INET_COUNTRY</code> definitions. This may save some of your
1635: bandwidth and time.</p>
1636: <p>You can change these settings either in your shell's environment, or,
1637: if you want to keep the settings, by editing the
1.76 rillig 1638: <code class="filename">/etc/mk.conf</code> file,
1.75 rillig 1639: and adding the definitions there.</p>
1640: <p>If you don't have a permanent Internet connection and you want to know
1641: which files to download, <span><strong class="command">make fetch-list</strong></span> will tell you
1642: what you'll need. Put these distfiles into
1.76 rillig 1643: <code class="filename">/usr/pkgsrc/distfiles</code>.</p>
1.75 rillig 1644: </div>
1645: <div class="sect2" lang="en">
1646: <div class="titlepage"><div><div><h3 class="title">
1647: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
1648: <p>Assuming that the distfile has been fetched (see previous section), become
1649: root and change into the relevant directory and run
1650: <span><strong class="command">make</strong></span>.</p>
1651: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1652: <h3 class="title">Note</h3>
1653: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
1654: use the pkgsrc <span><strong class="command">bmake</strong></span> command instead of
1655: “<span class="quote">make</span>” in the examples in this guide.</p>
1656: </div>
1657: <p>For example, type </p>
1658: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
1659: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong></pre>
1660: <p>at the shell prompt to build the various components of the
1661: package, and</p>
1662: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong></pre>
1663: <p>to install the various components into the correct places
1664: on your system. Installing the package on your system requires
1665: you to be root. However, pkgsrc has a
1666: <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
1667: to only become root for the actual installation step</p>
1668: <p>Taking the figlet utility as an example, we can install it on our
1669: system by building as shown in <a href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
1670: <p>The program is installed under the default root of the packages tree -
1.76 rillig 1671: <code class="filename">/usr/pkg</code>. Should this not conform to your tastes,
1.75 rillig 1672: set the <code class="varname">LOCALBASE</code>
1673: variable in your environment, and it will use that value as the root of
1.76 rillig 1674: your packages tree. So, to use <code class="filename">/usr/local</code>, set
1.75 rillig 1675: <code class="varname">LOCALBASE=/usr/local</code> in your environment. Please note
1676: that you should use a directory which is
1677: dedicated to packages and not shared with other programs (i.e., do not try
1678: and use <code class="varname">LOCALBASE=/usr</code>). Also, you should not try to
1.76 rillig 1679: add any of your own files or directories (such as <code class="filename">src/</code>,
1680: <code class="filename">obj/</code>, or <code class="filename">pkgsrc/</code>) below the
1.75 rillig 1681: <code class="varname">LOCALBASE</code> tree. This is to prevent possible conflicts
1682: between programs and other files installed by the package system and
1683: whatever else may have been installed there.</p>
1.76 rillig 1684: <p>Some packages look in <code class="filename">/etc/mk.conf</code> to alter some
1.75 rillig 1685: configuration options at build time. Have a look at
1.76 rillig 1686: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to
1.75 rillig 1687: get an overview of what will be set there by default. Environment
1688: variables such as <code class="varname">LOCALBASE</code>
1.76 rillig 1689: can be set in <code class="filename">/etc/mk.conf</code> to
1.75 rillig 1690: save having to remember to set them each time you want to use pkgsrc.</p>
1691: <p>Occasionally, people want to “<span class="quote">look under the covers</span>” to see
1692: what is going on when a package is building or being installed. This may be
1693: for debugging purposes, or out of simple curiosity. A number of utility
1694: values have been added to help with this.</p>
1695: <div class="orderedlist"><ol type="1">
1696: <li>
1697: <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>,
1698: then a huge amount of information will be displayed. For example,</p>
1699: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
1700: <p>will show all the commands that are invoked, up to and including the
1701: “<span class="quote">patch</span>” stage.</p>
1702: </li>
1703: <li>
1704: <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
1705: the <code class="varname">VARNAME</code> definition should be used, in conjunction
1706: 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
1707: <code class="varname">LOCALBASE</code>:</p>
1708: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
1709: /usr/pkg
1710: <code class="prompt">%</code>
1711: </pre>
1712: </li>
1713: </ol></div>
1714: <p>If you want to install a binary package that you've either
1715: created yourself (see next section), that you put into pkgsrc/packages manually or
1716: that is located on a remote FTP server, you can use the "bin-install"
1717: target. This target will install a binary package - if available - via
1718: <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>.
1719: The list of remote
1720: FTP sites searched is kept in the variable
1721: <code class="varname">BINPKG_SITES</code>, which defaults to
1722: 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
1723: into <code class="varname">BIN_INSTALL_FLAGS</code>.
1.76 rillig 1724: See <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more details.</p>
1.75 rillig 1725: <p>A final word of warning: If you set up a system that has a non-standard
1726: setting for <code class="varname">LOCALBASE</code>, be sure to set that
1727: before any packages are installed, as you can not use several directories
1728: for the same purpose. Doing so will result in pkgsrc not being able to
1729: properly detect your installed packages, and fail miserably. Note also that
1730: precompiled binary packages are usually built with the default
1731: <code class="varname">LOCALBASE</code> of
1.76 rillig 1732: <code class="filename">/usr/pkg</code>, and that you should <span class="emphasis"><em>not</em></span>
1.75 rillig 1733: install any if you use a non-standard <code class="varname">LOCALBASE</code>.</p>
1734: </div>
1735: <div class="sect2" lang="en">
1736: <div class="titlepage"><div><div><h3 class="title">
1737: <a name="selecting-the-compiler"></a>4.2.4. Selecting the compiler</h3></div></div></div>
1738: <p>By default, pkgsrc will use GCC to build packages. This may be
1739: overridden by setting the following variables in /etc/mk.conf:
1740: </p>
1741: <div class="variablelist"><dl>
1742: <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
1743: <dd>
1744: <p> This is a list of values specifying the chain of
1745: compilers to invoke when building packages. Valid values
1746: are: </p>
1747: <div class="itemizedlist"><ul type="disc">
1748: <li><p><code class="varname">distcc</code>:
1749: distributed C/C++ (chainable)</p></li>
1750: <li><p><code class="varname">ccache</code>:
1751: compiler cache (chainable)</p></li>
1752: <li><p><code class="varname">gcc</code>:
1753: GNU C/C++ Compiler</p></li>
1754: <li><p><code class="varname">mipspro</code>:
1755: Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
1756: <li><p><code class="varname">mipspro</code>:
1757: Silicon Graphics, Inc. MIPSpro (o32)</p></li>
1758: <li><p><code class="varname">sunpro</code>:
1759: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
1760: </ul></div>
1761: <p> The default is
1762: “<span class="quote"><code class="varname">gcc</code></span>”. You can use
1763: <code class="varname">ccache</code> and/or
1764: <code class="varname">distcc</code> with an appropriate
1765: <code class="varname">PKGSRC_COMPILER</code> setting,
1766: e.g. “<span class="quote"><code class="varname">ccache gcc</code></span>”. This
1767: variable should always be
1768: terminated with a value for a real compiler. </p>
1769: </dd>
1770: <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
1771: <dd><p> This specifies the minimum version of GCC to use
1772: when building packages. If the system GCC doesn't
1773: satisfy this requirement, then pkgsrc will build and
1774: install one of the GCC packages to use instead. </p></dd>
1775: </dl></div>
1776: </div>
1777: </div>
1778: </div>
1779: <div class="chapter" lang="en">
1780: <div class="titlepage"><div><div><h2 class="title">
1781: <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
1782: <div class="toc">
1783: <p><b>Table of Contents</b></p>
1784: <dl>
1785: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
1786: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 1787: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
1788: <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>
1789: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
1790: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 1791: </dl>
1792: </div>
1793: <div class="sect1" lang="en">
1794: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1795: <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
1796: <p>In this section, you can find some variables that apply to all
1797: pkgsrc packages. The preferred method of setting these variables
1.76 rillig 1798: is by setting them in <code class="filename">/etc/mk.conf</code>.
1.75 rillig 1799: </p>
1800: <div class="itemizedlist"><ul type="disc">
1801: <li><p><code class="varname">LOCALBASE</code>: Where
1802: packages will be installed. The default is
1.76 rillig 1803: <code class="filename">/usr/pkg</code>. Do not mix binary packages
1.75 rillig 1804: with different <code class="varname">LOCALBASE</code>s!</p></li>
1805: <li><p><code class="varname">CROSSBASE</code>: Where
1806: “<span class="quote">cross</span>” category packages will be
1807: installed. The default is
1.76 rillig 1808: <code class="filename">${LOCALBASE}/cross</code>.</p></li>
1.75 rillig 1809: <li><p><code class="varname">X11BASE</code>: Where
1810: X11 is installed on the system. The default is
1.76 rillig 1811: <code class="filename">/usr/X11R6</code>.</p></li>
1.75 rillig 1812: <li><p><code class="varname">DISTDIR</code>: Where to store the
1813: downloaded copies of the original source distributions used
1814: for building pkgsrc packages. The default is
1.76 rillig 1815: <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
1.75 rillig 1816: <li><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
1817: If set, override the packages'
1818: <code class="varname">MASTER_SITES</code> with this value.</p></li>
1819: <li><p><code class="varname">MASTER_SITE_BACKUP</code>:
1820: Backup location(s) for distribution files and patch files
1821: if not found locally or in
1.76 rillig 1822: <code class="filename">${MASTER_SITES}</code> or
1823: <code class="filename">${PATCH_SITES}</code> respectively.
1.75 rillig 1824: The defaults are
1.76 rillig 1825: <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
1.75 rillig 1826: and
1.76 rillig 1827: <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
1.75 rillig 1828: <li><p><code class="varname">BINPKG_SITES</code>:
1829: List of sites carrying binary pkgs.</p></li>
1830: </ul></div>
1831: <p>
1832: </p>
1833: </div>
1834: <div class="sect1" lang="en">
1835: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1836: <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
1837: <p>XXX
1838: </p>
1839: <div class="itemizedlist"><ul type="disc">
1840: <li><p><code class="varname">PACKAGES</code>: The top level
1841: directory for the binary packages. The default is
1.76 rillig 1842: <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
1.75 rillig 1843: <li><p><code class="varname">WRKOBJDIR</code>:
1844: The top level directory where, if defined, the separate
1845: working directories will get created, and symbolically
1.76 rillig 1846: linked to from <code class="filename">${WRKDIR}</code> (see below).
1.75 rillig 1847: This is useful for building packages on several
1.76 rillig 1848: architectures, then <code class="filename">${PKGSRCDIR}</code>
1849: can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
1.75 rillig 1850: is local to every architecture. (It should be noted that
1851: <code class="varname">PKGSRCDIR</code> should not be set by the user
1.78 rillig 1852: — it is an internal definition which refers to the
1.75 rillig 1853: root of the pkgsrc tree. It is possible to have many
1854: pkgsrc tree instances.)</p></li>
1855: <li><p><code class="varname">LOCALPATCHES</code>:
1856: Directory for local patches that aren't part of pkgsrc.
1.77 rillig 1857: See <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a> for more
1.75 rillig 1858: information. <em class="replaceable"><code>rel</code></em> and
1859: <em class="replaceable"><code>arch</code></em> are replaced with OS
1860: release (“<span class="quote">2.0</span>”, etc.) and architecture
1861: (“<span class="quote">mipsel</span>”, etc.).</p></li>
1862: <li><p><code class="varname">PKGMAKECONF</code>: Location of
1.76 rillig 1863: the <code class="filename">mk.conf</code> file used by a package's
1.75 rillig 1864: BSD-style Makefile. If this is not set,
1865: <code class="varname">MAKECONF</code> is set to
1.76 rillig 1866: <code class="filename">/dev/null</code> to avoid picking up
1867: settings used by builds in <code class="filename">/usr/src</code>.</p></li>
1.75 rillig 1868: </ul></div>
1869: <p>
1870: </p>
1871: </div>
1872: <div class="sect1" lang="en">
1873: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 1874: <a name="conf.compiler"></a>5.3. Selecting and configuring the compiler</h2></div></div></div>
1875: <div class="sect2" lang="en">
1876: <div class="titlepage"><div><div><h3 class="title">
1877: <a name="conf.cflags"></a>5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</h3></div></div></div>
1878: <p>If you wish to set the <code class="varname">CFLAGS</code> variable,
1879: please make sure to use the <code class="literal">+=</code> operator
1880: instead of the <code class="literal">=</code> operator:</p>
1881: <pre class="programlisting">
1882: CFLAGS+= -your -flags
1883: </pre>
1884: <p>Using <code class="varname">CFLAGS=</code> (i.e. without the
1885: “<span class="quote">+</span>”) may lead to problems with packages that need
1886: to add their own flags. Also, you may want to take a look at
1887: 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
1888: you're interested in optimization for the current CPU.</p>
1889: </div>
1890: </div>
1891: <div class="sect1" lang="en">
1892: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1893: <a name="developer-advanced-settings"></a>5.4. Developer/advanced settings</h2></div></div></div>
1.75 rillig 1894: <p>XXX
1895: </p>
1896: <div class="itemizedlist"><ul type="disc">
1897: <li>
1898: <p><code class="varname">PKG_DEVELOPER</code>:
1899: Run some sanity checks that package developers want:
1900: </p>
1901: <div class="itemizedlist"><ul type="circle">
1902: <li><p>make sure patches apply with zero fuzz</p></li>
1903: <li><p>run check-shlibs to see that all binaries will
1904: find their shared libs.</p></li>
1905: </ul></div>
1906: <p>
1907: </p>
1908: </li>
1909: <li><p><code class="varname">PKG_DEBUG_LEVEL</code>:
1910: The level of debugging output which is displayed whilst
1911: making and installing the package.
1912: The default value for this is 0, which will not display
1913: the commands as they are executed (normal, default, quiet
1914: operation); the value 1 will display all shell commands
1915: before their invocation, and the value 2 will display both
1916: the shell commands before their invocation, and their
1917: actual execution progress with <span><strong class="command">set -x</strong></span>
1918: will be displayed.</p></li>
1919: </ul></div>
1920: <p>
1921: </p>
1922: </div>
1923: <div class="sect1" lang="en">
1924: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 1925: <a name="selecting-build-options"></a>5.5. Selecting Build Options</h2></div></div></div>
1.75 rillig 1926: <p>Some packages have build time options, usually to select between
1927: different dependencies, enable optional support for big dependencies
1928: or enable experimental features.</p>
1929: <p>To see which options, if any, a package supports, and which
1930: options are mutually exclusive, run <span><strong class="command">make show-options</strong></span>,
1931: for example:</p>
1932: <pre class="programlisting">
1933: The following options are supported by this package:
1934: ssl Enable SSL support.
1935: Exactly one of the following gecko options is required:
1936: firefox Use firefox as gecko rendering engine.
1937: mozilla Use mozilla as gecko rendering engine.
1938: At most one of the following database options may be selected:
1939: mysql Enable support for MySQL database.
1940: pgsql Enable support for PostgreSQL database.
1.1 grant 1941:
1.75 rillig 1942: These options are enabled by default: firefox
1943: These options are currently enabled: mozilla ssl
1.1 grant 1944: </pre>
1.75 rillig 1945: <p>The following variables can be defined in
1.76 rillig 1946: <code class="filename">/etc/mk.conf</code> to select which options to enable
1.75 rillig 1947: for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which can be
1948: used to select or disable options for all packages that support them,
1949: and <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
1950: which can be used to select or disable options specifically for
1951: package <em class="replaceable"><code>pkgbase</code></em>. Options listed in these
1952: variables are selected, options preceded by “<span class="quote">-</span>” are
1953: disabled. A few examples:</p>
1954: <pre class="screen">
1955: <code class="prompt">$</code> <span><strong class="command">grep "PKG.*OPTION" /etc/mk.conf</strong></span>
1956: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
1957: PKG_OPTIONS.kdebase= debug -sasl
1958: PKG_OPTIONS.apache= suexec </pre>
1959: <p>The following settings are consulted in the order given, and the
1960: last setting that selects or disables an option is used:</p>
1961: <div class="orderedlist"><ol type="1">
1962: <li><p>the default options as suggested by the package
1963: maintainer</p></li>
1964: <li><p>the options implied by the settings of legacy
1965: variables (see below)</p></li>
1966: <li><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
1967: <li><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
1968: </ol></div>
1969: <p>For groups of mutually exclusive options, the last option
1970: selected is used, all others are automatically disabled. If an option
1971: of the group is explicitly disabled, the previously selected option,
1972: if any, is used. It is an error if no option from a required group of
1973: options is selected, and building the package will fail.</p>
1974: <p>Before the options framework was introduced, build options were
1975: selected by setting a variable (often named
1976: <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
1.76 rillig 1977: <code class="filename">/etc/mk.conf</code> for each option. To ease transition
1.75 rillig 1978: to the options framework for the user, these legacy variables are
1979: converted to the appropriate options setting
1980: (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
1981: automatically. A warning is issued to prompt the user to
1.76 rillig 1982: update <code class="filename">/etc/mk.conf</code> to use the options framework
1.75 rillig 1983: directly. Support for the legacy variables will be removed
1984: eventually.</p>
1985: </div>
1986: </div>
1987: <div class="chapter" lang="en">
1988: <div class="titlepage"><div><div><h2 class="title">
1989: <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
1990: <div class="toc">
1991: <p><b>Table of Contents</b></p>
1992: <dl>
1993: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
1994: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
1995: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
1996: <dd><dl>
1997: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
1998: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
1999: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
2000: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
2001: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
2002: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
2003: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
2004: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
2005: </dl></dd>
2006: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
2007: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
2008: </dl>
2009: </div>
2010: <div class="sect1" lang="en">
2011: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2012: <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
2013: <p>
2014: Once you have built and installed a package, you can create a
2015: <span class="emphasis"><em>binary package</em></span> which can be installed on
2016: 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
2017: the same package on a group of hosts and wasting CPU time. It
2018: also provides a simple means for others to install your package,
2019: should you distribute it.
2020: </p>
2021: <p>
2022: To create a binary package, change into the appropriate
2023: directory in pkgsrc, and run <span><strong class="command">make
2024: package</strong></span>:
2025: </p>
2026: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
2027: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
2028: <p>
2029: This will build and install your package (if not already done),
2030: and then build a binary package from what was installed. You can
2031: then use the <span><strong class="command">pkg_*</strong></span> tools to manipulate
2032: it. Binary packages are created by default in
1.76 rillig 2033: <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
1.75 rillig 2034: gzipped tar file. See <a href="#logs.package" title="B.2. Packaging figlet">Section B.2, “Packaging figlet”</a> for a
1.76 rillig 2035: 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 2036: <p>
1.77 rillig 2037: 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 2038: such a binary package.</p>
2039: </div>
2040: <div class="sect1" lang="en">
2041: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2042: <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
1.77 rillig 2043: <p>See <a href="#build.helpful-targets" title="15.16. Other helpful targets">Section 15.16, “Other helpful targets”</a>.</p>
1.75 rillig 2044: </div>
2045: <div class="sect1" lang="en">
2046: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2047: <a name="bulkbuild"></a>6.3. Doing a bulk build of all packages</h2></div></div></div>
2048: <p>If you want to get a full set of precompiled binary
2049: packages, this section describes how to get them. Beware that
2050: the bulk build will remove all currently installed packages from
2051: your system!</p>
2052: <p>Having an FTP server configured either on the
2053: machine doing the bulk builds or on a nearby NFS server can help
2054: to make the packages available to other machines that can then
2055: 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
2056: more information. If you use a remote NFS server's storage, be
2057: sure to not actually compile on NFS storage, as this slows
2058: things down a lot.</p>
2059: <div class="sect2" lang="en">
2060: <div class="titlepage"><div><div><h3 class="title">
2061: <a name="binary.configuration"></a>6.3.1. Configuration</h3></div></div></div>
2062: <div class="sect3" lang="en">
2063: <div class="titlepage"><div><div><h4 class="title">
1.76 rillig 2064: <a name="binary.bulk.build.conf"></a>6.3.1.1. <code class="filename">build.conf</code></h4></div></div></div>
2065: <p>The <code class="filename">build.conf</code> file is the main
1.75 rillig 2066: configuration file for bulk builds. You can configure how your
2067: copy of pkgsrc is kept up to date, how the distfiles are
2068: downloaded, how the packages are built and how the report is
2069: generated. You can find an annotated example file in
1.76 rillig 2070: <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
2071: it, copy <code class="filename">build.conf-example</code> to
2072: <code class="filename">build.conf</code> and edit it, following the
1.75 rillig 2073: comments in that file.</p>
2074: </div>
2075: <div class="sect3" lang="en">
2076: <div class="titlepage"><div><div><h4 class="title">
2077: <a name="binary.mk.conf"></a>6.3.1.2. /etc/mk.conf</h4></div></div></div>
2078: <p>You may want to set variables in
1.76 rillig 2079: <code class="filename">/etc/mk.conf</code>.
2080: Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
1.75 rillig 2081: details of the default settings. You will want to ensure that
2082: <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
2083: As used in this example, <code class="varname">_ACCEPTABLE=yes</code>
2084: accepts <span class="emphasis"><em>all</em></span> licenses.</p>
2085: <pre class="programlisting">
2086: PACKAGES?= ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
2087: WRKOBJDIR?= /usr/tmp/pkgsrc # build here instead of in pkgsrc
2088: BSDSRCDIR= /usr/src
2089: BSDXSRCDIR= /usr/xsrc # for x11/xservers
2090: OBJHOSTNAME?= yes # use work.`hostname`
2091: FAILOVER_FETCH= yes # insist on the correct checksum
2092: PKG_DEVELOPER?= yes
2093: _ACCEPTABLE= yes
1.1 grant 2094: </pre>
1.75 rillig 2095: <p>Some options that are especially useful for bulk builds
2096: can be found at the top lines of the file
1.76 rillig 2097: <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
1.75 rillig 2098: options of these are briefly described here.</p>
2099: <div class="itemizedlist"><ul type="disc">
2100: <li><p>If you are on a slow machine, you may want to
2101: set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
2102: “<span class="quote">no</span>”.</p></li>
2103: <li><p>If you are doing bulk builds from a read-only
2104: copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
2105: to the directory where all log files are created. Otherwise the
2106: log files are created in the pkgsrc directory.</p></li>
2107: <li><p>Another important variable is
2108: <code class="varname">BULK_PREREQ</code>, which is a list of packages that
2109: should be always available while building other
2110: packages.</p></li>
2111: </ul></div>
2112: <p>Some other options are scattered in the pkgsrc
2113: infrastructure:</p>
2114: <div class="itemizedlist"><ul type="disc">
2115: <li><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
2116: should be set to <code class="literal">yes</code>. The purpose of the bulk
2117: builds is creating binary packages, no matter if they are
2118: vulnerable or not. When uploading the packages to a public
2119: server, the vulnerable packages will be put into a directory of
2120: their own. Leaving this variable unset would prevent the bulk
2121: build system from even trying to build them, so possible
2122: building errors would not show up.</p></li>
2123: <li><p><code class="varname">CHECK_FILES</code>
1.76 rillig 2124: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75 rillig 2125: “<span class="quote">yes</span>” to check that the installed set of files
1.76 rillig 2126: matches the <code class="filename">PLIST</code>.</p></li>
1.75 rillig 2127: <li><p><code class="varname">CHECK_INTERPRETER</code>
1.76 rillig 2128: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75 rillig 2129: “<span class="quote">yes</span>” to check that the installed
2130: “<span class="quote">#!</span>”-scripts will find their
2131: interpreter.</p></li>
2132: </ul></div>
2133: </div>
2134: <div class="sect3" lang="en">
2135: <div class="titlepage"><div><div><h4 class="title">
1.76 rillig 2136: <a name="pre-build.local"></a>6.3.1.3. <code class="filename">pre-build.local</code></h4></div></div></div>
1.75 rillig 2137: <p>It is possible to configure the bulk build to perform
2138: certain site-specific tasks at the end of the pre-build
2139: stage. If the file
1.76 rillig 2140: <code class="filename">pre-build.local</code> exists in
2141: <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
1.75 rillig 2142: (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
2143: stage. An example use of
1.76 rillig 2144: <code class="filename">pre-build.local</code> is to have the line:</p>
1.75 rillig 2145: <pre class="screen">echo "I do not have enough disk space to build this pig." \
2146: > misc/openoffice/$BROKENF</pre>
2147: <p>to prevent the system from trying to build a particular package
2148: which requires nearly 3 GB of disk space.</p>
2149: </div>
2150: </div>
2151: <div class="sect2" lang="en">
2152: <div class="titlepage"><div><div><h3 class="title">
2153: <a name="other-environmental-considerations"></a>6.3.2. Other environmental considerations</h3></div></div></div>
1.76 rillig 2154: <p>As <code class="filename">/usr/pkg</code> will be completely
1.75 rillig 2155: deleted at the start of bulk builds, make sure your login
2156: shell is placed somewhere else. Either drop it into
1.76 rillig 2157: <code class="filename">/usr/local/bin</code> (and adjust your login
1.75 rillig 2158: shell in the passwd file), or (re-)install it via
1.76 rillig 2159: <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 2160: you can login after a reboot (remember that your current
2161: process won't die if the package is removed, you just can't
2162: start any new instances of the shell any more). Also, if you
2163: use NetBSD earlier than 1.5, or you still want to use the pkgsrc
2164: version of ssh for some reason, be sure to install ssh before
1.76 rillig 2165: starting it from <code class="filename">rc.local</code>:</p>
1.75 rillig 2166: <pre class="programlisting">
2167: ( cd /usr/pkgsrc/security/ssh ; make bulk-install )
2168: if [ -f /usr/pkg/etc/rc.d/sshd ]; then
2169: /usr/pkg/etc/rc.d/sshd
2170: fi
1.1 grant 2171: </pre>
1.75 rillig 2172: <p>Not doing so will result in you being not able to log in
2173: via ssh after the bulk build is finished or if the machine
2174: gets rebooted or crashes. You have been warned! :)</p>
2175: </div>
2176: <div class="sect2" lang="en">
2177: <div class="titlepage"><div><div><h3 class="title">
2178: <a name="operation"></a>6.3.3. Operation</h3></div></div></div>
2179: <p>Make sure you don't need any of the packages still
2180: installed.
2181: </p>
2182: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
2183: <h3 class="title">Warning</h3>
2184: <p>During the bulk build, <span class="emphasis"><em>all packages will be
2185: removed!</em></span></p>
2186: </div>
2187: <p>Be sure to remove all other things that might
2188: interfere with builds, like some libs installed in
1.76 rillig 2189: <code class="filename">/usr/local</code>, etc. then become root and type:</p>
1.75 rillig 2190: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2191: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong></pre>
2192: <p>If for some reason your last build didn't complete (power
2193: failure, system panic, ...), you can continue it by
2194: running:</p>
2195: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
2196: <p>
2197: At the end of the bulk build, you will get a summary via mail,
2198: and find build logs in the directory specified by
1.76 rillig 2199: <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
1.75 rillig 2200: file.
2201: </p>
2202: </div>
2203: <div class="sect2" lang="en">
2204: <div class="titlepage"><div><div><h3 class="title">
2205: <a name="what-it-does"></a>6.3.4. What it does</h3></div></div></div>
2206: <p>The bulk builds consist of three steps:</p>
2207: <div class="variablelist"><dl>
2208: <dt><span class="term">1. pre-build</span></dt>
2209: <dd><p>
2210: The script updates your pkgsrc tree via (anon)cvs, then
2211: cleans out any broken distfiles, and removes all
2212: packages installed.</p></dd>
2213: <dt><span class="term">2. the bulk build</span></dt>
2214: <dd><p>
2215: This is basically “<span class="quote">make bulk-package</span>” with
2216: an optimised order in which packages will be
2217: built. Packages that don't require other packages will
2218: be built first, and packages with many dependencies will
2219: be built later.
2220: </p></dd>
2221: <dt><span class="term">3. post-build</span></dt>
2222: <dd><p>
2223: Generates a report that's placed in the directory
1.76 rillig 2224: specified in the <code class="filename">build.conf</code> file
2225: named <code class="filename">broken.html</code>, a short version
1.75 rillig 2226: of that report will also be mailed to the build's
2227: admin.</p></dd>
2228: </dl></div>
2229: <p>
2230: During the build, a list of broken packages will be compiled
1.76 rillig 2231: in <code class="filename">/usr/pkgsrc/.broken</code> (or
2232: <code class="filename">.../.broken.${MACHINE}</code> if
1.75 rillig 2233: <code class="varname">OBJMACHINE</code> is set), individual build logs
2234: of broken builds can be found in the package's
2235: directory. These files are used by the bulk-targets to mark
2236: broken builds to not waste time trying to rebuild them, and
2237: they can be used to debug these broken package builds
2238: later.
2239: </p>
2240: </div>
2241: <div class="sect2" lang="en">
2242: <div class="titlepage"><div><div><h3 class="title">
2243: <a name="disk-space-requirements"></a>6.3.5. Disk space requirements</h3></div></div></div>
2244: <p>Currently, roughly the following requirements are valid for
2245: NetBSD 2.0/i386:</p>
2246: <div class="itemizedlist"><ul type="disc">
2247: <li><p>
2248: 10 GB - distfiles (NFS ok)
2249: </p></li>
2250: <li><p>
2251: 8 GB - full set of all binaries (NFS ok)
2252: </p></li>
2253: <li><p>
2254: 5 GB - temp space for compiling (local disk recommended)
2255: </p></li>
2256: </ul></div>
2257: <p>
2258: Note that all pkgs will be de-installed as soon as they are
2259: turned into a binary package, and that sources are removed,
2260: so there is no excessively huge demand to disk
2261: space. Afterwards, if the package is needed again, it will
2262: 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
2263: there are no cycles wasted by recompiling.
2264: </p>
2265: </div>
2266: <div class="sect2" lang="en">
2267: <div class="titlepage"><div><div><h3 class="title">
2268: <a name="setting-up-a-sandbox"></a>6.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
2269: <p>
2270: If you don't want all the packages nuked from a machine
2271: (rendering it useless for anything but pkg compiling), there
2272: is the possibility of doing the package bulk build inside a
2273: chroot environment.
2274: </p>
2275: <p>
2276: The first step is to set up a chroot sandbox,
1.76 rillig 2277: e.g. <code class="filename">/usr/sandbox</code>. This can be done by
1.75 rillig 2278: using null mounts, or manually.
2279: </p>
2280: <p>
2281: There is a shell script called
1.76 rillig 2282: <code class="filename">pkgsrc/mk/bulk/mksandbox</code> which will set
1.75 rillig 2283: up the sandbox environment using null mounts. It will also
1.76 rillig 2284: create a script called <code class="filename">sandbox</code> in the
1.75 rillig 2285: root of the sandbox environment, which will allow the null
2286: mounts to be activated using the <span><strong class="command">sandbox
2287: mount</strong></span> command and deactivated using the
2288: <span><strong class="command">sandbox umount</strong></span> command.
2289: </p>
2290: <p>
2291: To set up a sandbox environment by hand, after extracting all
2292: the sets from a NetBSD installation or doing a <span><strong class="command">make
2293: distribution DESTDIR=/usr/sandbox</strong></span> in
1.76 rillig 2294: <code class="filename">/usr/src/etc</code>, be sure the following items
1.75 rillig 2295: are present and properly configured:
2296: </p>
2297: <div class="procedure"><ol type="1">
2298: <li>
2299: <p>Kernel</p>
2300: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
2301: </li>
2302: <li>
1.76 rillig 2303: <p><code class="filename">/dev/*</code></p>
1.75 rillig 2304: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
2305: </li>
2306: <li>
1.76 rillig 2307: <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 2308: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
2309: </li>
2310: <li>
2311: <p>Working(!) mail config (hostname, sendmail.cf):</p>
2312: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
2313: </li>
2314: <li>
1.76 rillig 2315: <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 2316: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
2317: </li>
2318: <li>
1.76 rillig 2319: <p><code class="filename">/usr/src</code> (system sources,
1.78 rillig 2320: 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 2321: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
2322: <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
2323: </li>
2324: <li>
1.76 rillig 2325: <p>Create <code class="filename">/var/db/pkg</code> (not part of default install):</p>
1.75 rillig 2326: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong></pre>
2327: </li>
2328: <li>
1.76 rillig 2329: <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
1.75 rillig 2330: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
2331: </li>
2332: <li>
2333: <p>Checkout pkgsrc via cvs into
1.76 rillig 2334: <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
1.75 rillig 2335: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
2336: <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong></pre>
2337: <p>Do not mount/link this to the copy of your pkgsrc tree
2338: you do development in, as this will likely cause problems!
2339: </p>
2340: </li>
2341: <li><p>Make
1.76 rillig 2342: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
2343: <code class="filename">.../distfiles</code> point somewhere
1.75 rillig 2344: appropriate. NFS- and/or nullfs-mounts may come in handy!
2345: </p></li>
1.76 rillig 2346: <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>
2347: <li><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
1.75 rillig 2348: </ol></div>
2349: <p>When the chroot sandbox is set up, you can start
2350: the build with the following steps:</p>
2351: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2352: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong></pre>
2353: <p>
2354: This will just jump inside the sandbox and start building. At
2355: the end of the build, mail will be sent with the results of
2356: the build. Created binary pkgs will be in
1.76 rillig 2357: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
1.75 rillig 2358: (wherever that points/mounts to/from).</p>
2359: </div>
2360: <div class="sect2" lang="en">
2361: <div class="titlepage"><div><div><h3 class="title">
2362: <a name="building-a-partial-set"></a>6.3.7. Building a partial set of packages</h3></div></div></div>
2363: <p> In addition to building a complete set of all packages in
1.76 rillig 2364: pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
1.75 rillig 2365: may be used to build a subset of the packages contained in
2366: pkgsrc. By setting <code class="varname">SPECIFIC_PKGS</code>
1.76 rillig 2367: in <code class="filename">/etc/mk.conf</code>, the variables</p>
1.75 rillig 2368: <div class="itemizedlist"><ul type="disc">
2369: <li><p>SITE_SPECIFIC_PKGS</p></li>
2370: <li><p>HOST_SPECIFIC_PKGS</p></li>
2371: <li><p>GROUP_SPECIFIC_PKGS</p></li>
2372: <li><p>USER_SPECIFIC_PKGS</p></li>
2373: </ul></div>
2374: <p> will define the set of packages which should be built.
2375: The bulk build code will also include any packages which are
2376: needed as dependencies for the explicitly listed packages.
2377: </p>
2378: <p> One use of this is to do a bulk build with
2379: <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
2380: periodically to have a complete set of the binary packages
2381: needed for your site available without the overhead of
2382: building extra packages that are not needed. </p>
2383: </div>
2384: <div class="sect2" lang="en">
2385: <div class="titlepage"><div><div><h3 class="title">
2386: <a name="bulk-upload"></a>6.3.8. Uploading results of a bulk build</h3></div></div></div>
2387: <p>
2388: This section describes how pkgsrc developers can upload binary
2389: pkgs built by bulk builds to ftp.NetBSD.org.
2390: </p>
2391: <p>
2392: If you would like to automatically create checksum files for the
2393: binary packages you intend to upload, remember to set
2394: <code class="varname">MKSUMS=yes</code> in your
1.76 rillig 2395: <code class="filename">mk/bulk/build.conf</code>.
1.75 rillig 2396: </p>
2397: <p>
2398: If you would like to PGP sign the checksum files (highly
2399: recommended!), remember to set
2400: <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
1.76 rillig 2401: <code class="filename">mk/bulk/build.conf</code>. This will prompt you for
1.75 rillig 2402: your GPG password to sign the files before uploading everything.
2403: </p>
2404: <p>
2405: Then, make sure that you have <code class="varname">RSYNC_DST</code>
1.76 rillig 2406: set properly in your <code class="filename">mk/bulk/build.conf</code>
1.75 rillig 2407: file, i.e. adjust it to something like one of the following:
2408: </p>
2409: <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
2410: <p>Please use appropriate values for "pkgsrc-200xQy",
2411: "NetBSD-a.b.c" and "arch" here. If your login on ftp.NetBSD.org
2412: is different from your local login, write your login directly
2413: into the variable, e.g. my local account is "feyrer", but for my
2414: login "hubertf", I use:</p>
2415: <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
2416: <p>
1.76 rillig 2417: A separate <code class="filename">upload</code> directory is used
1.75 rillig 2418: here to allow "closing" the directory during upload. To do
2419: so, run the following command on ftp.NetBSD.org next:
2420: </p>
2421: <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>
2422: <p>
1.76 rillig 2423: Please note that <code class="filename">/pub/NetBSD/packages</code> is
1.75 rillig 2424: only appropriate for packages for the NetBSD operating
2425: system. Binary packages for other operating systems should go
1.76 rillig 2426: into <code class="filename">/pub/pkgsrc</code>.
1.75 rillig 2427: </p>
2428: <p>
2429: Before uploading the binary pkgs, ssh authentication needs to
2430: be set up. This example shows how to set up temporary keys
2431: for the root account <span class="emphasis"><em>inside the sandbox</em></span>
2432: (assuming that no keys should be present there usually):
2433: </p>
2434: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
2435: chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
2436: chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t dsa</code></strong>
2437: chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong> </pre>
2438: <p>
1.76 rillig 2439: Now take the output of <code class="filename">id-dsa.pub</code> and
2440: append it to your <code class="filename">~/.ssh/authorized_keys</code>
1.75 rillig 2441: file on ftp.NetBSD.org. You can remove the key after the
2442: upload is done!
2443: </p>
2444: <p>
2445: Next, test if your ssh connection really works:
2446: </p>
2447: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
2448: <p>
2449: Use "-l yourNetBSDlogin" here as appropriate!
2450: </p>
2451: <p>
2452: Now after all this works, you can exit the sandbox and start
2453: the upload:
2454: </p>
2455: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
2456: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2457: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong> </pre>
2458: <p>
2459: 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
2460: <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
2461: upload. The upload script will take care of not uploading
2462: restricted packages and putting vulnerable packages into the
1.76 rillig 2463: <code class="filename">vulnerable</code> subdirectory.
1.75 rillig 2464: </p>
2465: <p>
2466: After the upload has ended, first thing is to revoke ssh access:
2467: </p>
2468: <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
2469: Gdd:x! </pre>
2470: <p>
2471: Use whatever is needed to remove the key you've entered
2472: before! Last, move the uploaded packages out of the
1.76 rillig 2473: <code class="filename">upload</code> directory to have them accessible
1.75 rillig 2474: to everyone:
2475: </p>
2476: <pre class="screen">nbftp% <strong class="userinput"><code>cd /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch</code></strong>
2477: nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
2478: nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
2479: nbftp% <strong class="userinput"><code>chmod 755 .</code></strong> </pre>
2480: </div>
2481: </div>
2482: <div class="sect1" lang="en">
2483: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2484: <a name="creating-cdroms"></a>6.4. Creating a multiple CD-ROM packages collection</h2></div></div></div>
2485: <p>
2486: After your pkgsrc bulk-build has completed, you may wish to
2487: create a CD-ROM set of the resulting binary packages to assist
2488: in installing packages on other machines. The
1.76 rillig 2489: <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 2490: a simple tool for creating the ISO 9660 images.
2491: <span><strong class="command">cdpack</strong></span> arranges the packages on the CD-ROMs in a
2492: way that keeps all the dependencies for a given package on the same
2493: CD as that package.
2494: </p>
2495: <div class="sect2" lang="en">
2496: <div class="titlepage"><div><div><h3 class="title">
2497: <a name="cdpack-example"></a>6.4.1. Example of cdpack</h3></div></div></div>
2498: <p>
2499: Complete documentation for cdpack is found in the cdpack(1)
2500: man page. The following short example assumes that the binary
2501: packages are left in
1.76 rillig 2502: <code class="filename">/usr/pkgsrc/packages/All</code> and that
2503: sufficient disk space exists in <code class="filename">/u2</code> to
1.75 rillig 2504: hold the ISO 9660 images.</p>
2505: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
2506: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
2507: <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong></pre>
2508: <p>
2509: If you wish to include a common set of files
1.76 rillig 2510: (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
1.75 rillig 2511: etc.) on each CD in the collection, then you need to create a
2512: directory which contains these files. e.g.
2513: </p>
2514: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
2515: <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" > /tmp/common/README</code></strong>
2516: <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" > /tmp/common/COPYING</code></strong>
2517: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
2518: <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" > /tmp/common/bin/myscript</code></strong>
2519: <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" >> /tmp/common/bin/myscript</code></strong>
2520: <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong></pre>
2521: <p>Now create the images:</p>
2522: <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 2523: <p>Each image will contain <code class="filename">README</code>,
2524: <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
1.75 rillig 2525: in their root directories.</p>
2526: </div>
2527: </div>
2528: </div>
2529: <div class="chapter" lang="en">
2530: <div class="titlepage"><div><div><h2 class="title">
2531: <a name="faq"></a>Chapter 7. Frequently Asked Questions</h2></div></div></div>
2532: <div class="toc">
2533: <p><b>Table of Contents</b></p>
2534: <dl>
2535: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
2536: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
2537: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
2538: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
2539: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
2540: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
2541: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
2542: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
2543: <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>
2544: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
2545: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
2546: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
2547: <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>
2548: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
2549: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
2550: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
2551: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
1.80 rillig 2552: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.75 rillig 2553: </dl>
2554: </div>
2555: <p>This section contains hints, tips & tricks on special things in
2556: pkgsrc that we didn't find a better place for in the previous chapters, and
2557: it contains items for both pkgsrc users and developers.</p>
2558: <div class="sect1" lang="en">
2559: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2560: <a name="mailing-list-pointers"></a>7.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
2561: <p>The following mailing lists may be of interest to pkgsrc users:</p>
2562: <div class="itemizedlist"><ul type="disc">
1.78 rillig 2563: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-users" target="_top">pkgsrc-users</a>:
2564: This is a general purpose list for most issues regarding
2565: pkgsrc, regardless of platform, e.g. soliciting user help
2566: for pkgsrc configuration, unexpected build failures, using
2567: particular packages, upgrading pkgsrc installations,
2568: questions regarding the pkgsrc release branches, etc. General announcements or
2569: proposals for changes that impact the pkgsrc user community,
2570: e.g. major infrastructure changes, new features, package
2571: removals, etc., may also be posted.</p></li>
1.75 rillig 2572: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
2573: A list where the results of pkgsrc bulk builds are sent and
2574: discussed.</p></li>
2575: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
2576: This list is for those who are interested in getting a
2577: commit message for every change committed to pkgsrc. It is
2578: also available in digest form, meaning one daily message
2579: containing all commit messages for changes to the package
2580: source tree in that 24 hour period.</p></li>
2581: </ul></div>
2582: <p>To subscribe, do:</p>
2583: <pre class="programlisting">
2584: <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
2585: </pre>
2586: <p>Archives for all these mailing lists are available from
2587: <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
2588: </div>
2589: <div class="sect1" lang="en">
2590: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2591: <a name="pkgviews-docs"></a>7.2. Where's the pkgviews documentation?</h2></div></div></div>
2592: <p>Pkgviews is tightly integrated with buildlink. You can find a
2593: pkgviews User's guide in
1.76 rillig 2594: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
1.75 rillig 2595: </div>
2596: <div class="sect1" lang="en">
2597: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2598: <a name="faq-pkgtools"></a>7.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.80 rillig 2599: <p>The directory <code class="filename">pkgsrc/pkgtools</code> contains
1.75 rillig 2600: a number of useful utilities for both users and developers of pkgsrc. This
2601: section attempts only to make the reader aware of the utilities and when
2602: they might be useful, and not to duplicate the documentation that comes
2603: with each package.</p>
2604: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
1.76 rillig 2605: <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 2606: Symlinks for use by buildlink.</p></li></ul></div>
2607: <p>OS tool augmentation (automatically installed when needed):</p>
2608: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2609: <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 2610: Calculates various kinds of checksums (including SHA1).</p></li>
1.76 rillig 2611: <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 2612: Compatibility library for pkgsrc tools.</p></li>
1.76 rillig 2613: <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 2614: non-BSD systems due to lack of native mtree.
2615: </p></li>
1.76 rillig 2616: <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 2617: Up-to-date replacement for
1.76 rillig 2618: <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
1.75 rillig 2619: systems where pkg_install is not present.</p></li>
2620: </ul></div>
2621: <p>Utilities used by pkgsrc (not automatically installed):</p>
2622: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2623: <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 2624: Create a binary package from an
2625: already-installed package. Used by <span><strong class="command">make replace</strong></span> to
2626: save the old package.</p></li>
1.76 rillig 2627: <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 2628: Adds extra functionality to pkgsrc, allowing it to fetch distfiles
2629: from multiple locations. It currently supports the following
2630: methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
1.76 rillig 2631: <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 2632: packages someplace else (enabled by default).</p></li>
1.76 rillig 2633: <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 2634: best compiler flags to optimise code for your current CPU and
2635: compiler.</p></li>
2636: </ul></div>
2637: <p>Utilities for keeping track of installed packages, being up to date,
2638: etc:</p>
2639: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2640: <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 2641: packages whose installed versions do not match the latest pkgsrc
2642: entries.</p></li>
1.76 rillig 2643: <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 2644: dependency graphs of packages, to aid in choosing a strategy for
2645: updating.</p></li>
1.76 rillig 2646: <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
2647: 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>
2648: <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 2649: pkglint(1) program checks a pkgsrc entry for errors, lintpkgsrc(1)
2650: does various checks on the complete pkgsrc system.</p></li>
1.76 rillig 2651: <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 2652: packages you have installed.</p></li>
2653: </ul></div>
2654: <p>Utilities for people maintaining or creating individual packages:</p>
2655: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2656: <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 2657: making and maintaining patches for a package (includes pkgdiff,
2658: pkgvi, mkpatches, etc.).</p></li>
1.76 rillig 2659: <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>,
2660: <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 2661: converting to pkgsrc.</p></li>
1.76 rillig 2662: <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 2663: pkgsrc to a Solaris package.</p></li>
2664: </ul></div>
2665: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
2666: utilities)</p>
2667: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2668: <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 2669: packages in a chrooted area.</p></li>
1.76 rillig 2670: <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 2671: kernel version for chrooted cross builds.</p></li>
2672: </ul></div>
2673: </div>
2674: <div class="sect1" lang="en">
2675: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2676: <a name="non-root-pkgsrc"></a>7.4. How to use pkgsrc as non-root</h2></div></div></div>
2677: <p>If you want to use pkgsrc as non-root user, you can set some
2678: variables to make pkgsrc work under these conditions. At the very least,
2679: you need to set <code class="varname">UNPRIVILEGED</code> to “<span class="quote">yes</span>”; this
2680: will turn on unprivileged mode and set multiple related variables to allow
2681: installation of packages as non-root.</p>
2682: <p>In case the defaults are not enough, you may want to tune some other
2683: variables used. For example, if the automatic user/group detection leads
2684: to incorrect values (or not the ones you would like to use), you can change
2685: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
2686: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
2687: <p>As regards bootstrapping, please note that the
2688: <span><strong class="command">bootstrap</strong></span> script will ease non-root configuration when
2689: given the “<span class="quote">--ignore-user-check</span>” flag, as it will choose and
1.76 rillig 2690: use multiple default directories under <code class="filename">~/pkg</code> as the
1.75 rillig 2691: installation targets. These directories can be overriden by the
2692: “<span class="quote">--prefix</span>” flag provided by the script, as well as some others
2693: that allow finer tuning of the tree layout.</p>
2694: </div>
2695: <div class="sect1" lang="en">
2696: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2697: <a name="resume-transfers"></a>7.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
2698: <p>By default, resuming transfers in pkgsrc is disabled, but you can
2699: enable this feature by adding the option
2700: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.76 rillig 2701: <code class="filename">/etc/mk.conf</code>. If, during a fetch step, an incomplete
1.75 rillig 2702: distfile is found, pkgsrc will try to resume it.</p>
2703: <p>You can also
2704: 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
2705: <code class="varname">FETCH_CMD</code> variable. Don't forget to set
2706: <code class="varname">FETCH_RESUME_ARGS</code> and
2707: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
2708: values.</p>
2709: <p>For example, if you want to use
1.76 rillig 2710: <code class="filename">wget</code> to resume downloads, you'll have to use something
1.75 rillig 2711: like:</p>
2712: <pre class="programlisting">
2713: FETCH_CMD= wget
2714: FETCH_BEFORE_ARGS= --passive-ftp
2715: FETCH_RESUME_ARGS= -c
2716: FETCH_OUTPUT_ARGS= -O
1.1 grant 2717: </pre>
1.75 rillig 2718: </div>
2719: <div class="sect1" lang="en">
2720: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2721: <a name="XFree86-from-pkgsrc"></a>7.6. How can I install/use XFree86 from pkgsrc?</h2></div></div></div>
2722: <p>If you want to use XFree86 from pkgsrc instead of your system's own
1.76 rillig 2723: X11 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>,
1.75 rillig 2724: ...), you will have to add the following line into
1.76 rillig 2725: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2726: <pre class="programlisting">
2727: X11_TYPE=XFree86
1.1 grant 2728: </pre>
1.75 rillig 2729: </div>
2730: <div class="sect1" lang="en">
2731: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2732: <a name="x.org-from-pkgsrc"></a>7.7. How can I install/use X.org from pkgsrc?</h2></div></div></div>
2733: <p>If you want to use X.org from pkgsrc instead of your system's own X11
1.76 rillig 2734: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
1.75 rillig 2735: you will have to add the following line into
1.76 rillig 2736: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2737: <pre class="programlisting">
2738: X11_TYPE=xorg
1.1 grant 2739: </pre>
1.75 rillig 2740: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
2741: <h3 class="title">Note</h3>
2742: <p>The DragonFly operating system defaults to using
2743: this X.org X11 implementation from pkgsrc.
2744: </p>
2745: </div>
2746: </div>
2747: <div class="sect1" lang="en">
2748: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2749: <a name="fetch-behind-firewall"></a>7.8. How to fetch files from behind a firewall</h2></div></div></div>
2750: <p>If you are sitting behind a firewall which does not allow direct
2751: connections to Internet hosts (i.e. non-NAT), you may specify the
2752: relevant proxy hosts. This is done using an environment variable in the
2753: form of a URL, e.g. in Amdahl, the machine
2754: “<span class="quote">orpheus.amdahl.com</span>” is one of the firewalls, and it uses
2755: port 80 as the proxy port number. So the proxy environment variables
2756: are:</p>
2757: <pre class="programlisting">
2758: ftp_proxy=ftp://orpheus.amdahl.com:80/
2759: http_proxy=http://orpheus.amdahl.com:80/
1.1 grant 2760: </pre>
1.75 rillig 2761: </div>
2762: <div class="sect1" lang="en">
2763: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2764: <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>
2765: <p>This depends on which utility is used to retrieve distfiles. From
1.76 rillig 2766: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
1.75 rillig 2767: the first available command from the following list:</p>
2768: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2769: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
2770: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
1.75 rillig 2771: </ul></div>
2772: <p>On a default NetBSD installation, this will be
1.76 rillig 2773: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
1.75 rillig 2774: connections first, and falls back to active connections if the server
2775: refuses to do passive. For the other tools, add the following to your
1.76 rillig 2776: <code class="filename">/etc/mk.conf</code> file:
1.75 rillig 2777: <code class="varname">PASSIVE_FETCH=1</code>.</p>
2778: <p>Having that option present will prevent
1.76 rillig 2779: <code class="filename">/usr/bin/ftp</code> from falling back to active
1.75 rillig 2780: transfers.</p>
2781: </div>
2782: <div class="sect1" lang="en">
2783: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2784: <a name="fetching-all-distfiles"></a>7.10. How to fetch all distfiles at once</h2></div></div></div>
2785: <p>You would like to download all the distfiles in a single batch from
2786: work or university, where you can't run a <span><strong class="command">make fetch</strong></span>.
2787: There is an archive of distfiles on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/" target="_top">ftp.NetBSD.org</a>,
2788: but downloading the entire directory may not be appropriate.</p>
2789: <p>The answer here is to do a <span><strong class="command">make fetch-list</strong></span> in
1.76 rillig 2790: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
1.75 rillig 2791: resulting list to your machine at work/school and use it there. If you
2792: 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
2793: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
2794: URL:</p>
2795: <p>At home:</p>
2796: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2797: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh</code></strong>
2798: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
2799: <p>At work:</p>
2800: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
1.76 rillig 2801: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
1.75 rillig 2802: home.</p>
2803: <p>If you have a machine running NetBSD, and you want to get
2804: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your machine
2805: architecture), you can do so by using the above-mentioned <span><strong class="command">make
2806: fetch-list</strong></span> approach, or fetch the distfiles directly by
2807: running:</p>
2808: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
2809: <p>If you even decide to ignore
2810: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
2811: by running:</p>
2812: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
2813: </div>
2814: <div class="sect1" lang="en">
2815: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2816: <a name="tmac.andoc-missing"></a>7.11. What does “<span class="quote">Don't know how to make
2817: /usr/share/tmac/tmac.andoc</span>” mean?</h2></div></div></div>
1.76 rillig 2818: <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 2819: package, you get the error from make that it doesn't know how to make
1.76 rillig 2820: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
1.75 rillig 2821: you don't have installed the “<span class="quote">text</span>” set (nroff, ...) from
2822: the NetBSD base distribution on your machine. It is recommended to do
2823: that to format man pages.</p>
1.76 rillig 2824: <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 2825: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.76 rillig 2826: environment or in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 2827: </div>
2828: <div class="sect1" lang="en">
2829: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2830: <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 2831: <p> You didn't install the compiler set, <code class="filename">comp.tgz</code>,
1.75 rillig 2832: when you installed your NetBSD machine. Please get and install it, by
1.76 rillig 2833: extracting it in <code class="filename">/</code>:</p>
1.75 rillig 2834: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
2835: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
1.76 rillig 2836: <p><code class="filename">comp.tgz</code> is part of every NetBSD release. Get
1.75 rillig 2837: the one that corresponds to your release (determine via <span><strong class="command">uname
2838: -r</strong></span>).</p>
2839: </div>
2840: <div class="sect1" lang="en">
2841: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2842: <a name="using-sudo-with-pkgsrc"></a>7.13. Using 'sudo' with pkgsrc</h2></div></div></div>
2843: <p>When installing packages as non-root user and using the just-in-time
2844: <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
2845: password for each required package installed. To avoid this, the sudo
2846: package can be used, which does password caching over a limited time. To
2847: use it, install sudo (either as binary package or from
1.76 rillig 2848: <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
2849: into your <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2850: <pre class="programlisting">
2851: .if exists(${LOCALBASE}/bin/sudo)
2852: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
2853: .endif
1.1 grant 2854: </pre>
1.75 rillig 2855: </div>
2856: <div class="sect1" lang="en">
2857: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2858: <a name="faq.conf"></a>7.14. How do I change the location of configuration files?</h2></div></div></div>
2859: <p>As the system administrator, you can choose where configuration files
2860: are installed. The default settings make all these files go into
1.76 rillig 2861: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
1.75 rillig 2862: be suboptimal depending on your expectations (e.g., a read-only,
2863: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
2864: configuration of the provided packages).</p>
2865: <p>In order to change the defaults, you can modify the
2866: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.76 rillig 2867: <code class="filename">/etc/mk.conf</code>) to point to your preferred configuration
2868: directory; some common examples include <code class="filename">/etc</code> or
2869: <code class="filename">/etc/pkg</code>.</p>
1.75 rillig 2870: <p>Furthermore, you can change this value on a per-package basis by
2871: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
2872: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
2873: package you would like to modify, that is, the contents of
2874: <code class="varname">PKGBASE</code>.</p>
2875: <p>Note that after changing these settings, you must rebuild and
2876: reinstall any affected packages.</p>
2877: </div>
2878: <div class="sect1" lang="en">
2879: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2880: <a name="audit-packages"></a>7.15. Automated security checks</h2></div></div></div>
2881: <p>Please be aware that there can often be bugs in third-party software,
2882: and some of these bugs can leave a machine vulnerable to exploitation by
2883: attackers. In an effort to lessen the exposure, the NetBSD packages team
2884: maintains a database of known-exploits to packages which have at one time
2885: been included in pkgsrc. The database can be downloaded automatically, and
2886: a security audit of all packages installed on a system can take place. To
1.76 rillig 2887: 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 2888: components:</p>
2889: <div class="orderedlist"><ol type="1">
2890: <li>
2891: <p><span><strong class="command">download-vulnerability-list</strong></span>, an easy way to
2892: download a list of the security vulnerabilities information. This list
2893: is kept up to date by the NetBSD security officer and the NetBSD
2894: packages team, and is distributed from the NetBSD ftp server:</p>
2895: <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>
2896: </li>
2897: <li><p><span><strong class="command">audit-packages</strong></span>, an easy way to audit the
2898: current machine, checking each vulnerability which is known. If a
2899: vulnerable package is installed, it will be shown by output to stdout,
2900: including a description of the type of vulnerability, and a URL
2901: containing more information.</p></li>
2902: </ol></div>
1.76 rillig 2903: <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 2904: package is strongly recommended! After
2905: “<span class="quote">audit-packages</span>” is installed, please read
2906: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
2907: audit-packages</code></strong>.</p>
2908: <p>If this package is installed, pkgsrc builds will use it to perform
2909: a security check before building any package. See
2910: <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.
2911: </p>
2912: </div>
2913: <div class="sect1" lang="en">
2914: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2915: <a name="ufaq-cflags"></a>7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
2916: <p>When you add your own preferences to the
2917: <code class="varname">CFLAGS</code> variable in your
1.76 rillig 2918: <code class="filename">mk.conf</code>, these flags are passed in
2919: environment variables to the <code class="filename">./configure</code>
1.75 rillig 2920: 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
2921: <code class="varname">CFLAGS</code> from the environment variable by
1.76 rillig 2922: overriding them in the <code class="filename">Makefile</code>s of their
1.75 rillig 2923: package.</p>
2924: <p>Currently there is no solution to this problem. If you
2925: really need the package to use your <code class="varname">CFLAGS</code>
2926: you should run <span><strong class="command">make patch</strong></span> in the package
1.76 rillig 2927: directory and then inspect any <code class="filename">Makefile</code> and
2928: <code class="filename">Makefile.in</code> for whether they define
1.75 rillig 2929: <code class="varname">CFLAGS</code> explicitly. Usually you can remove
2930: these lines. But be aware that some “<span class="quote">smart</span>”
2931: programmers write so bad code that it only works for the
2932: specific combination of <code class="varname">CFLAGS</code> they have
2933: chosen.</p>
2934: </div>
1.80 rillig 2935: <div class="sect1" lang="en">
2936: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2937: <a name="ufaq-fail"></a>7.17. A package does not build. What shall I do?</h2></div></div></div>
2938: <div class="procedure"><ol type="1">
2939: <li><p>Make sure that your copy of pkgsrc is consistent. A
2940: case that occurs often is that people only update pkgsrc in
2941: parts, because of performance reasons. Since pkgsrc is one large
2942: system, not a collection of many small systems, there are
2943: sometimes changes that only work when the whole pkgsrc tree is
2944: updated.</p></li>
2945: <li><p>Make sure that you don't have any CVS conflicts.
2946: Search for “<span class="quote"><<<<<<</span>” or
2947: “<span class="quote">>>>>>></span>” in all your pkgsrc
2948: files.</p></li>
2949: <li><p>Make sure that you don't have old copies of the packages
2950: extracted. Run <span><strong class="command">make clean clean-depends</strong></span> to
2951: verify this.</p></li>
2952: <li><p>If the problem still exists, write a mail to the
2953: <code class="literal">pkgsrc-users</code> mailing list.</p></li>
2954: </ol></div>
2955: </div>
1.75 rillig 2956: </div>
2957: </div>
2958: <div class="part" lang="en">
2959: <div class="titlepage"><div><div><h1 class="title">
2960: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
1.77 rillig 2961: <div class="partintro" lang="en">
2962: <div></div>
2963: <p>This part of the book deals with creating and
2964: modifying packages. It starts with a “<span class="quote">HOWTO</span>”-like
2965: guide on creating a new package. The remaining chapters are more
2966: like a reference manual for pkgsrc.</p>
1.75 rillig 2967: <div class="toc">
2968: <p><b>Table of Contents</b></p>
2969: <dl>
1.77 rillig 2970: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
2971: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75 rillig 2972: <dd><dl>
1.77 rillig 2973: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
2974: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
2975: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
2976: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
2977: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 2978: <dd><dl>
2979: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
2980: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
2981: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
2982: </dl></dd>
1.77 rillig 2983: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
2984: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
2985: </dl></dd>
2986: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
2987: <dd><dl>
2988: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
2989: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
2990: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
2991: <dd><dl>
2992: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
2993: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
2994: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
2995: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
2996: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
2997: </dl></dd>
2998: </dl></dd>
2999: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
3000: <dd><dl>
3001: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
3002: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
3003: <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>
3004: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
3005: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
3006: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
3007: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
3008: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
3009: </dl></dd>
3010: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
3011: <dd><dl>
3012: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
3013: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
3014: <dd><dl>
3015: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
3016: <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>
3017: </dl></dd>
3018: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
3019: <dd><dl>
3020: <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>
3021: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
3022: </dl></dd>
3023: </dl></dd>
3024: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
3025: <dd><dl>
3026: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
3027: <dd><dl>
3028: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
3029: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
3030: </dl></dd>
3031: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
3032: <dd><dl>
3033: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
3034: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
3035: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
3036: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
3037: </dl></dd>
3038: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
3039: <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>
3040: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
3041: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
3042: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
3043: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
3044: <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>
3045: </dl></dd>
3046: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
3047: <dd><dl>
3048: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
3049: <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>
3050: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
3051: </dl></dd>
3052: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
3053: <dd><dl>
3054: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
3055: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
3056: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
3057: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
3058: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
1.81 ! rillig 3059: <dd><dl>
! 3060: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
! 3061: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
! 3062: </dl></dd>
1.77 rillig 3063: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
3064: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
3065: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
3066: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
3067: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
3068: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
3069: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3070: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
3071: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3072: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
3073: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
3074: </dl></dd>
3075: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
3076: <dd><dl>
3077: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
3078: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
3079: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
3080: </dl></dd>
3081: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
3082: <dd><dl>
3083: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
3084: <dd><dl>
1.78 rillig 3085: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
3086: <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>
3087: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
3088: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
3089: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
3090: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
3091: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
3092: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
3093: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
3094: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
3095: <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 3096: <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 3097: </dl></dd>
3098: <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>
3099: <dd><dl>
3100: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
3101: <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>
3102: </dl></dd>
3103: <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>
3104: <dd><dl>
3105: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
3106: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
3107: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
3108: </dl></dd>
3109: <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>
3110: <dd><dl>
1.78 rillig 3111: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
3112: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
3113: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
3114: </dl></dd>
3115: <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>
3116: <dd><dl>
3117: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
3118: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
3119: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
3120: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
3121: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
3122: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
3123: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
3124: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
3125: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
3126: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
3127: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
3128: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
3129: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
3130: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
3131: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
3132: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
3133: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.77 rillig 3134: </dl></dd>
1.78 rillig 3135: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.77 rillig 3136: </dl></dd>
3137: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
3138: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
3139: <dd><dl>
3140: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
3141: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
3142: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
3143: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
3144: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
3145: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 3146: </dl></dd>
1.77 rillig 3147: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.75 rillig 3148: </dl>
3149: </div>
1.77 rillig 3150: </div>
3151: <div class="chapter" lang="en">
3152: <div class="titlepage"><div><div><h2 class="title">
3153: <a name="creating"></a>Chapter 8. Creating a new pkgsrc package from scratch</h2></div></div></div>
3154: <p>When you find a package that is not yet in pkgsrc, you
3155: most likely have a URL from where you can download the source
3156: code. Starting with this URL, creating a package involves only a
3157: few steps.</p>
3158: <div class="procedure"><ol type="1">
3159: <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>
3160: <li><p>Then, choose one of the top-level directories as the
3161: category in which you want to place your package. You can also
3162: create a directory of your own (maybe called
3163: <code class="filename">local</code>). In that category directory, create
3164: another directory for your package and change into
3165: it.</p></li>
3166: <li><p>Run the program <span><strong class="command">url2pkg</strong></span>, which
3167: will ask you for a URL. Enter the URL of the distribution file
3168: (in most cases a <code class="filename">.tar.gz</code> file) and watch
3169: how the basic ingredients of your package are created
3170: automatically. The distribution file is extracted automatically
3171: to fill in some details in the <code class="filename">Makefile</code>
3172: that would otherwise have to be done manually.</p></li>
3173: <li>
3174: <p>Examine the extracted files to determine the
3175: dependencies of your package. Ideally, this is mentioned in some
3176: <code class="filename">README</code> file, but things may differ. For
3177: each of these dependencies, look where it exists in pkgsrc, and
3178: if there is a file called <code class="filename">buildlink3.mk</code> in
3179: that directory, add a line to your package
3180: <code class="filename">Makefile</code> which includes that file just
3181: before the last line. If the <code class="filename">buildlink3.mk</code>
3182: file does not exist, add a <code class="varname">DEPENDS</code> line to
3183: the Makefile, which specifies the version of the dependency and
3184: where it can be found in pkgsrc. This line should be placed in
3185: the third paragraph. If the dependency is only needed for
3186: building the package, but not when using it, use
3187: <code class="varname">BUILD_DEPENDS</code> instead of
3188: <code class="varname">DEPENDS</code>. Your package may then look like
3189: this:</p>
3190: <pre class="programlisting">
3191: [...]
3192:
3193: BUILD_DEPENDS+= lua>=5.0:../../lang/lua
3194: DEPENDS+= screen-[0-9]*:../../misc/screen
3195: DEPENDS+= screen>=4.0:../../misc/screen
3196:
3197: [...]
3198:
3199: .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
3200: .include "../../devel/glib2/buildlink3.mk"
3201: .include "../../mk/bsd.pkg.mk"
3202: </pre>
3203: </li>
3204: <li><p>Run <span><strong class="command">pkglint</strong></span> to see what things
3205: still need to be done to make your package a “<span class="quote">good</span>”
3206: one. If you don't know what pkglint's warnings want to tell you,
3207: try <span><strong class="command">pkglint --explain</strong></span> or <span><strong class="command">pkglint
3208: -e</strong></span>, which outputs additional
3209: explanations.</p></li>
3210: <li><p>Now, run <span><strong class="command">bmake</strong></span> to build the
3211: package. For the various things that can go wrong in this phase,
3212: consult <a href="#fixes" title="Chapter 17. Making your package work">Chapter 17, <i>Making your package work</i></a>.</p></li>
3213: <li><p>When the package builds fine, the next step is to
3214: install the package. Run <span><strong class="command">bmake install</strong></span> and
3215: hope that everything works.</p></li>
3216: <li><p>Up to now, the file <code class="filename">PLIST</code>,
3217: which contains a list of the files that are installed by the
3218: package, is nearly empty. Run <span><strong class="command">bmake print-PLIST
3219: >PLIST</strong></span> to generate a probably correct list. Check
3220: the file using your preferred text editor to see if the list of
3221: files looks plausible.</p></li>
3222: <li><p>Run <span><strong class="command">pkglint</strong></span> again to see if the
3223: generated <code class="filename">PLIST</code> contains garbage or
3224: not.</p></li>
3225: <li><p>When you ran <span><strong class="command">bmake install</strong></span>, the
3226: package has been registered in the database of installed files,
3227: but with an empty list of files. To fix this, run <span><strong class="command">bmake
3228: deinstall</strong></span> and <span><strong class="command">bmake install</strong></span> again.
3229: Now the package is registered with the list of files from
3230: <code class="filename">PLIST</code>.</p></li>
3231: <li><p>Run <span><strong class="command">bmake package</strong></span> to create a
3232: binary package from the set of installed files.</p></li>
3233: </ol></div>
3234: </div>
1.75 rillig 3235: <div class="chapter" lang="en">
3236: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3237: <a name="components"></a>Chapter 9. Package components - files, directories and contents</h2></div></div></div>
1.75 rillig 3238: <div class="toc">
3239: <p><b>Table of Contents</b></p>
3240: <dl>
1.77 rillig 3241: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
3242: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
3243: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
3244: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
3245: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 3246: <dd><dl>
3247: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
3248: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
3249: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
3250: </dl></dd>
1.77 rillig 3251: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
3252: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
1.75 rillig 3253: </dl>
3254: </div>
3255: <p> Whenever you're preparing a package, there are a number of
3256: files involved which are described in the following
3257: sections. </p>
3258: <div class="sect1" lang="en">
3259: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3260: <a name="components.Makefile"></a>9.1. <code class="filename">Makefile</code></h2></div></div></div>
1.75 rillig 3261: <p>Building, installation and creation of a binary package are all
1.76 rillig 3262: controlled by the package's <code class="filename">Makefile</code>.
3263: The <code class="filename">Makefile</code> describes various things about
1.75 rillig 3264: a package, for example from where to get it, how to configure,
3265: build, and install it.
3266: </p>
1.76 rillig 3267: <p>A package <code class="filename">Makefile</code> contains several
1.75 rillig 3268: sections that describe the package.</p>
3269: <p>In the first section there are the following variables, which
1.81 ! rillig 3270: should appear exactly in the order given here. The ordering and
! 3271: grouping of variables is mostly historical and has no further
! 3272: meaning.</p>
1.75 rillig 3273: <div class="itemizedlist"><ul type="disc">
3274: <li><p><code class="varname">DISTNAME</code> is the basename of the
3275: distribution file to be downloaded from the package's
3276: website.</p></li>
3277: <li><p><code class="varname">PKGNAME</code> is the name of the
3278: package, as used by pkgsrc. You only need to provide it if it
3279: differs from <code class="varname">DISTNAME</code>. Usually it is the directory name together
3280: with the version number. It must match the regular expression
3281: <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
3282: starts with a letter or digit, and contains only letters, digits,
3283: dashes, underscores, dots and plus signs.</p></li>
3284: <li>
3285: <p><code class="varname">CATEGORIES</code> is a list of categories
3286: which the package fits in. You can choose any of the top-level
3287: directories of pkgsrc for it.</p>
3288: <p>Currently the following values are available for
3289: <code class="varname">CATEGORIES</code>. If more than
3290: one is used, they need to be separated by spaces:</p>
3291: <pre class="programlisting">
3292: archivers cross geography meta-pkgs security
3293: audio databases graphics misc shells
3294: benchmarks devel ham multimedia sysutils
3295: biology editors inputmethod net textproc
3296: cad emulators lang news time
3297: chat finance mail parallel wm
3298: comms fonts math pkgtools www
3299: converters games mbone print x11
1.1 grant 3300: </pre>
1.75 rillig 3301: </li>
1.81 ! rillig 3302: <li><p><code class="varname">MASTER_SITES</code>,
! 3303: <code class="varname">DYNAMIC_MASTER_SITES</code>,
! 3304: <code class="varname">DIST_SUBDIR</code>, <code class="varname">EXTRACT_SUFX</code>
! 3305: and <code class="varname">DISTFILES</code> are discussed in detail in
! 3306: <a href="#build.fetch" title="15.5. The fetch phase">Section 15.5, “The <span class="emphasis"><em>fetch</em></span> phase”</a>.</p></li>
1.75 rillig 3307: </ul></div>
3308: <p>The second section contains information about separately
3309: downloaded patches, if any.
3310: </p>
3311: <div class="itemizedlist"><ul type="disc">
3312: <li><p><code class="varname">PATCHFILES:</code>
3313: Name(s) of additional files that contain distribution patches.
3314: There is no default. pkgsrc will look for them at
3315: <code class="varname">PATCH_SITES</code>.
3316: They will automatically be uncompressed before patching if
1.76 rillig 3317: the names end with <code class="filename">.gz</code> or
3318: <code class="filename">.Z</code>.</p></li>
1.75 rillig 3319: <li><p><code class="varname">PATCH_SITES</code>:
3320: Primary location(s) for distribution patch files (see
3321: <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
3322: </ul></div>
3323: <p>
3324: </p>
3325: <p>The third section contains the following variables.
3326: </p>
3327: <div class="itemizedlist"><ul type="disc">
3328: <li><p><code class="varname">MAINTAINER</code> is the email address
3329: of the person who feels responsible for this package, and who is
3330: most likely to look at problems or questions regarding this
3331: 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
3332: developers should contact the <code class="varname">MAINTAINER</code> before
3333: making major changes to the package. When packaging a new program,
3334: set <code class="varname">MAINTAINER</code> to yourself. If you really can't
3335: maintain the package for future updates, set it to
3336: <code class="email"><<a href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>></code>.</p></li>
3337: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
3338: find more information about the package.</p></li>
3339: <li><p><code class="varname">COMMENT</code> is a one-line
3340: description of the package (should not include the package
3341: name).</p></li>
3342: </ul></div>
3343: <p>
3344: </p>
3345: <p>Other variables that affect the build:
3346: </p>
3347: <div class="itemizedlist"><ul type="disc"><li>
3348: <p><code class="varname">WRKSRC</code>: The directory where the
3349: interesting distribution files of the package are found. The
1.76 rillig 3350: default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
1.75 rillig 3351: works for most packages.</p>
3352: <p>If a package doesn't create a subdirectory for itself
3353: (most GNU software does, for instance), but extracts itself in
3354: the current directory, you should set <code class="varname">WRKSRC=
3355: ${WRKDIR}</code>.</p>
3356: <p>If a package doesn't create a subdirectory with the name
3357: of <code class="varname">DISTNAME</code> but some different name, set
3358: <code class="varname">WRKSRC</code> to point to the proper name in
1.76 rillig 3359: <code class="filename">${WRKDIR}</code>, for example <code class="varname">WRKSRC=
3360: ${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 3361: <p>The name of the working directory created by pkgsrc is
3362: taken from the <code class="varname">WRKDIR_BASENAME</code> variable. By
1.76 rillig 3363: default, its value is <code class="filename">work</code>. If you want
1.75 rillig 3364: to use the same pkgsrc tree for building different kinds of
3365: binary packages, you can change the variable according to your
3366: needs. Two other variables handle common cases of setting
3367: <code class="varname">WRKDIR_BASENAME</code> individually. If
3368: <code class="varname">OBJHOSTNAME</code> is defined in
1.76 rillig 3369: <code class="filename">/etc/mk.conf</code>, the first component of the
1.75 rillig 3370: host's name is attached to the directory name. If
3371: <code class="varname">OBJMACHINE</code> is defined, the platform name is
1.76 rillig 3372: attached, which might look like <code class="filename">work.i386</code>
3373: or <code class="filename">work.sparc</code>.</p>
1.75 rillig 3374: </li></ul></div>
3375: <p>
3376: </p>
3377: <p>Please pay attention to the following gotchas:</p>
3378: <div class="itemizedlist"><ul type="disc">
3379: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are installed in
3380: compressed form by the package; see comment in
1.76 rillig 3381: <code class="filename">bsd.pkg.mk</code>.</p></li>
3382: <li><p>Replace <code class="filename">/usr/local</code> with
1.75 rillig 3383: “<span class="quote">${PREFIX}</span>” in all files (see patches, below).</p></li>
3384: <li><p>If the package installs any info files, see
1.78 rillig 3385: <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 3386: </ul></div>
3387: </div>
3388: <div class="sect1" lang="en">
3389: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3390: <a name="components.distinfo"></a>9.2. <code class="filename">distinfo</code></h2></div></div></div>
1.76 rillig 3391: <p>The <code class="filename">distinfo</code> file contains the message
1.75 rillig 3392: digest, or checksum, of each distfile needed for the package. This
3393: ensures that the distfiles retrieved from the Internet have not been
3394: corrupted during transfer or altered by a malign force to introduce
3395: a security hole. Due to recent rumor about weaknesses of digest
3396: algorithms, all distfiles are protected using both SHA1 and RMD160
3397: message digests, as well as the file size.</p>
1.76 rillig 3398: <p>The <code class="filename">distinfo</code> file also contains the
1.75 rillig 3399: checksums for all the patches found in the
1.77 rillig 3400: <code class="filename">patches</code> directory (see <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a>).</p>
1.76 rillig 3401: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.75 rillig 3402: <span><strong class="command">make makedistinfo</strong></span> or <span><strong class="command">make mdi</strong></span>
3403: command.</p>
3404: <p>Some packages have different sets of distfiles depending on
1.76 rillig 3405: 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
3406: <code class="filename">distinfo</code> file and care should be taken when
1.75 rillig 3407: upgrading such a package to ensure distfile information is not
3408: lost.</p>
3409: </div>
3410: <div class="sect1" lang="en">
3411: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3412: <a name="components.patches"></a>9.3. patches/*</h2></div></div></div>
1.75 rillig 3413: <p>This directory contains files that are used by the
3414: <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
3415: modify the sources as distributed in the distribution file into a form
3416: that will compile and run perfectly on NetBSD. The files are applied
3417: successively in alphabetic order (as returned by a shell
3418: “<span class="quote">patches/patch-*</span>” glob expansion), so
1.76 rillig 3419: <code class="filename">patch-aa</code> is applied before
3420: <code class="filename">patch-ab</code>, etc.</p>
3421: <p>The <code class="filename">patch-*</code> files should be in
1.75 rillig 3422: <span><strong class="command">diff -bu</strong></span> format, and apply without a fuzz to avoid
3423: problems. (To force patches to apply
3424: with fuzz you can set <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>).
3425: Furthermore, do not put changes for more than one file into a single
3426: patch file, as this will make future modifications more difficult.</p>
3427: <p>Similar, a file should be patched at most once, not several times by
3428: several different patches. If a file needs several patches, they should
3429: be combined into one file.</p>
3430: <p>One important thing to mention is to pay attention that no RCS IDs
3431: get stored in the patch files, as these will cause problems when
3432: later checked into the NetBSD CVS tree. Use the
3433: <span><strong class="command">pkgdiff</strong></span> from the
1.76 rillig 3434: <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 3435: these problems.</p>
3436: <p>For even more automation, we recommend using <span><strong class="command">mkpatches</strong></span> from the same
3437: package to make a whole set of patches. You just have to backup files
1.76 rillig 3438: before you edit them to <code class="filename">filename.orig</code>, e.g. with
1.75 rillig 3439: <span><strong class="command">cp -p filename filename.orig</strong></span> or, easier, by using
3440: <span><strong class="command">pkgvi</strong></span> again from the same package. If you upgrade a package
3441: this way, you can easily compare the new set of patches with the
3442: previously existing one with <span><strong class="command">patchdiff</strong></span>.</p>
3443: <p>When you have finished a package, remember to generate the checksums
3444: for the patch files by using the <span><strong class="command">make makepatchsum</strong></span>
1.77 rillig 3445: command, see <a href="#components.distinfo" title="9.2. distinfo">Section 9.2, “<code class="filename">distinfo</code>”</a>.</p>
1.75 rillig 3446: <p>When adding a patch that corrects a problem in the distfile (rather
3447: than e.g. enforcing pkgsrc's view of where man pages should go), send
3448: the patch as a bug report to the maintainer. This benefits
3449: non-pkgsrc users of the package, and usually enables removing
3450: the patch in future version.</p>
3451: <p>Patch files that are distributed by the author or other
3452: maintainers can be listed in
3453: <code class="varname">$PATCHFILES</code>. </p>
3454: <p>If it is desired to store any patches that should not be committed into
3455: pkgsrc, they can be kept outside the pkgsrc tree in the
1.76 rillig 3456: <code class="filename">$LOCALPATCHES</code>
1.75 rillig 3457: directory. The directory tree there is expected to have the same
3458: “<span class="quote">category/package</span>” structure as pkgsrc, and patches are
3459: expected to be stored inside these dirs (also known as
1.76 rillig 3460: <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
1.75 rillig 3461: example, if you want to keep a private patch for
1.76 rillig 3462: <code class="filename">pkgsrc/graphics/png</code>, keep
3463: it in <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
1.75 rillig 3464: files in the named directory are expected to be patch files, and
3465: <span class="emphasis"><em>they are applied after pkgsrc patches are applied</em></span>.</p>
3466: </div>
3467: <div class="sect1" lang="en">
3468: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3469: <a name="other-mandatory-files"></a>9.4. Other mandatory files</h2></div></div></div>
1.75 rillig 3470: <div class="variablelist"><dl>
1.76 rillig 3471: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
1.75 rillig 3472: <dd><p>A multi-line description of the piece of software. This should include
3473: any credits where they are due. Please bear in mind that others do not
3474: share your sense of humour (or spelling idiosyncrasies), and that others
3475: will read everything that you write here.</p></dd>
1.76 rillig 3476: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
1.75 rillig 3477: <dd><p>
3478: This file governs the files that are installed on your system: all the
3479: binaries, manual pages, etc. There are other directives which may be
3480: entered in this file, to control the creation and deletion of
3481: directories, and the location of inserted files.
1.77 rillig 3482: See <a href="#plist" title="Chapter 11. PLIST issues">Chapter 11, <i>PLIST issues</i></a> for more information. </p></dd>
1.75 rillig 3483: </dl></div>
3484: </div>
3485: <div class="sect1" lang="en">
3486: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3487: <a name="components.optional"></a>9.5. Optional files</h2></div></div></div>
1.78 rillig 3488: <div class="sect2" lang="en">
3489: <div class="titlepage"><div><div><h3 class="title">
3490: <a name="components.optional.bin"></a>9.5.1. Files affecting the binary package</h3></div></div></div>
1.75 rillig 3491: <div class="variablelist"><dl>
1.76 rillig 3492: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.75 rillig 3493: <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>.
3494: First time after package
3495: extraction and before files are moved in place, the second time after
3496: the files to install are moved in place. This can be used to do any
3497: custom procedures not possible with @exec commands in
1.76 rillig 3498: <code class="filename">PLIST</code>. See
1.75 rillig 3499: <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 3500: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
1.75 rillig 3501: <dd><p>This script is executed before and after any files are removed. It is
3502: this script's responsibility to clean up any additional messy details
3503: around the package's installation, since all pkg_delete knows is how to
3504: delete the files created in the original distribution.
3505: 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>
3506: 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 3507: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
1.75 rillig 3508: <dd>
3509: <p>This file is displayed after installation of the package.
3510: Useful for things like legal notices on almost-free
3511: software and hints for updating config files after
3512: installing modules for apache, PHP etc.
3513: Please note that you can modify variables in it easily by using
3514: <code class="varname">MESSAGE_SUBST</code> in the package's
1.76 rillig 3515: <code class="filename">Makefile</code>:</p>
1.75 rillig 3516: <pre class="programlisting">
3517: MESSAGE_SUBST+= SOMEVAR="somevalue"
1.1 grant 3518: </pre>
1.75 rillig 3519: <p>replaces "${SOMEVAR}" with “<span class="quote">somevalue</span>” in
1.76 rillig 3520: <code class="filename">MESSAGE</code>.</p>
1.75 rillig 3521: </dd>
1.78 rillig 3522: <dt><span class="term"><code class="filename">ALTERNATIVES</code></span></dt>
3523: <dd><p>FIXME: There is no documentation on the
3524: alternatives framework.</p></dd>
3525: </dl></div>
3526: </div>
3527: <div class="sect2" lang="en">
3528: <div class="titlepage"><div><div><h3 class="title">
3529: <a name="components.optional.build"></a>9.5.2. Files affecting the build process</h3></div></div></div>
3530: <div class="variablelist"><dl>
3531: <dt><span class="term"><code class="filename">Makefile.common</code></span></dt>
3532: <dd><p>This file contains arbitrary things that could
3533: also go into a <code class="filename">Makefile</code>, but its purpose is
3534: to be used by more than one package. This file should only be
3535: used when the packages that will use the file are known in
3536: advance. For other purposes it is often better to write a
3537: <code class="filename">*.mk</code> file and give it a good name that
3538: describes what it does.</p></dd>
3539: <dt><span class="term"><code class="filename">buildlink3.mk</code></span></dt>
3540: <dd><p>This file contains the dependency information
3541: for the buildlink3 framework (see <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a>).</p></dd>
3542: <dt><span class="term"><code class="filename">hacks.mk</code></span></dt>
3543: <dd><p>This file contains workarounds for compiler bugs
3544: and similar things. It is included automatically by the pkgsrc
3545: infrastructure, so you don't need an extra
3546: <code class="literal">.include</code> line for
3547: it.</p></dd>
3548: <dt><span class="term"><code class="filename">options.mk</code></span></dt>
3549: <dd><p>This file contains the code for the
3550: package-specific options (see <a href="#options" title="Chapter 14. Options handling">Chapter 14, <i>Options handling</i></a>) that can be
3551: selected by the user. If a package has only one or two options,
3552: it is equally acceptable to put the code directly into the
3553: <code class="filename">Makefile</code>.</p></dd>
3554: </dl></div>
3555: </div>
3556: <div class="sect2" lang="en">
3557: <div class="titlepage"><div><div><h3 class="title">
3558: <a name="components.optional.none"></a>9.5.3. Files affecting nothing at all</h3></div></div></div>
3559: <div class="variablelist"><dl>
3560: <dt><span class="term"><code class="filename">README*</code></span></dt>
3561: <dd><p>These files do not take place in the creation of
3562: a package and thus are purely informative to the package
3563: developer.</p></dd>
3564: <dt><span class="term"><code class="filename">TODO</code></span></dt>
3565: <dd><p>This file contains things that need to be done
3566: to make the package even
3567: better.</p></dd>
1.75 rillig 3568: </dl></div>
3569: </div>
1.78 rillig 3570: </div>
1.75 rillig 3571: <div class="sect1" lang="en">
3572: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3573: <a name="work-dir"></a>9.6. <code class="filename">work*</code></h2></div></div></div>
1.75 rillig 3574: <p>When you type <span><strong class="command">make</strong></span>, the distribution files are
3575: unpacked into the directory denoted by
3576: <code class="varname">WRKDIR</code>. It can be removed by running
3577: <span><strong class="command">make clean</strong></span>. Besides the sources, this
3578: directory is also used to keep various timestamp files.
3579: The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
1.76 rillig 3580: The default is <code class="filename">${.CURDIR}/work</code>
3581: or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
1.75 rillig 3582: if <code class="varname">OBJMACHINE</code> is set.</p>
3583: </div>
3584: <div class="sect1" lang="en">
3585: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3586: <a name="files-dir"></a>9.7. <code class="filename">files/*</code></h2></div></div></div>
1.75 rillig 3587: <p>If you have any files that you wish to be placed in the package prior
3588: to configuration or building, you could place these files here and use
3589: a “<span class="quote">${CP}</span>” command in the
3590: “<span class="quote">pre-configure</span>” target to achieve
3591: this. Alternatively, you could simply diff the file against
1.76 rillig 3592: <code class="filename">/dev/null</code> and use the patch mechanism to manage
1.75 rillig 3593: the creation of this file.</p>
3594: </div>
3595: </div>
3596: <div class="chapter" lang="en">
3597: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3598: <a name="makefile"></a>Chapter 10. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.75 rillig 3599: <div class="toc">
3600: <p><b>Table of Contents</b></p>
3601: <dl>
1.77 rillig 3602: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
3603: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
3604: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
3605: <dd><dl>
3606: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
3607: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
3608: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
3609: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
3610: <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 3611: </dl></dd>
3612: </dl>
3613: </div>
1.76 rillig 3614: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
1.75 rillig 3615: each of which forms a well-defined part of the pkgsrc system. Using
3616: 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
3617: like pkgsrc requires some discipline to keep the code correct and
3618: understandable.</p>
1.76 rillig 3619: <p>The basic ingredients for <code class="filename">Makefile</code>
1.75 rillig 3620: programming are variables (which are actually macros) and shell
3621: commands. Among these shell commands may even be more complex ones
3622: 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
3623: as intended it is necessary to quote all variables correctly when they
3624: are used.</p>
3625: <p>This chapter describes some patterns, that appear quite often in
1.76 rillig 3626: <code class="filename">Makefile</code>s, including the pitfalls that come along
1.75 rillig 3627: with them.</p>
3628: <div class="sect1" lang="en">
3629: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3630: <a name="makefile.variables"></a>10.1. <code class="filename">Makefile</code> variables</h2></div></div></div>
1.76 rillig 3631: <p><code class="filename">Makefile</code> variables contain strings that
1.75 rillig 3632: can be processed using the five operators ``='', ``+='', ``?='',
3633: ``:='', 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
3634: page.</p>
3635: <p>When a variable's value is parsed from a
1.76 rillig 3636: <code class="filename">Makefile</code>, the hash character ``#'' and the
1.75 rillig 3637: backslash character ``\'' are handled specially. If a backslash is
3638: followed by a newline, any whitespace immediately in front of the
3639: backslash, the backslash, the newline, and any whitespace
3640: immediately behind the newline are replaced with a single space. A
3641: backslash character and an immediately following hash character are
3642: replaced with a single hash character. Otherwise, the backslash is
3643: passed as is. In a variable assignment, any hash character that is
3644: not preceded by a backslash starts a comment that continues upto the
3645: end of the logical line.</p>
3646: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
3647: the only way to create a variable consisting of a single backslash
3648: is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
3649: <p>So far for defining variables. The other thing you can do with
3650: variables is evaluating them. A variable is evaluated when it is
3651: part of the right side of the ``:='' or the ``!='' operator, or
3652: directly before executing a shell command which the variable is part
3653: 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
3654: is, variables are not evaluated until there's no other way. The
3655: ``modifiers'' mentioned in the man page also evaluate the
3656: variable.</p>
3657: <p>Some of the modifiers split the string into words and then
3658: operate on the words, others operate on the string as a whole. When
3659: a string is split into words, it is split as you would expect
3660: 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 3661: <p>No rule without exception—the <span><strong class="command">.for</strong></span>
1.75 rillig 3662: loop does not follow the shell quoting rules but splits at sequences
3663: of whitespace.</p>
3664: <p>There are several types of variables that should be handled
3665: differently. Strings and two types of lists.</p>
3666: <div class="itemizedlist"><ul type="disc">
3667: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
3668: characters. Nevertheless, you should restrict yourself to only
3669: using printable characters. Examples are
3670: <code class="varname">PREFIX</code> and
3671: <code class="varname">COMMENT</code>.</p></li>
3672: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
3673: are never exported to any shell command. Their elements are
3674: separated by whitespace. Therefore, the elements themselves cannot
3675: have embedded whitespace. Any other characters are allowed.
3676: Internal lists can be used in <span><strong class="command">.for</strong></span> loops.
3677: Examples are <code class="varname">DEPENDS</code> and
3678: <code class="varname">BUILD_DEPENDS</code>.</p></li>
3679: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
3680: may be exported to a shell command. Their elements can contain any
3681: characters, including whitespace. That's why they cannot be used
3682: in <span><strong class="command">.for</strong></span> loops. Examples are
3683: <code class="varname">DISTFILES</code> and
3684: <code class="varname">MASTER_SITES</code>.</p></li>
3685: </ul></div>
3686: <div class="sect2" lang="en">
3687: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3688: <a name="makefile.variables.names"></a>10.1.1. Naming conventions</h3></div></div></div>
1.75 rillig 3689: <div class="itemizedlist"><ul type="disc">
3690: <li><p>All variable names starting with an underscore
3691: are reserved for use by the pkgsrc infrastructure. They shall
3692: not be used by package
1.76 rillig 3693: <code class="filename">Makefile</code>s.</p></li>
1.75 rillig 3694: <li><p>In <span><strong class="command">.for</strong></span> loops you should use
3695: lowercase variable names for the iteration
3696: variables.</p></li>
3697: <li><p>All list variables should have a ``plural''
3698: name, e.g. <code class="varname">PKG_OPTIONS</code> or
3699: <code class="varname">DISTFILES</code>.</p></li>
3700: </ul></div>
3701: </div>
3702: </div>
3703: <div class="sect1" lang="en">
3704: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3705: <a name="makefile.code"></a>10.2. Code snippets</h2></div></div></div>
1.75 rillig 3706: <p>This section presents you with some code snippets you should
3707: use in your own code. If you don't find anything appropriate here,
3708: you should test your code and add it here.</p>
3709: <div class="sect2" lang="en">
3710: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3711: <a name="adding-to-list"></a>10.2.1. Adding things to a list</h3></div></div></div>
1.75 rillig 3712: <pre class="programlisting">
3713: STRING= foo * bar `date`
3714: INT_LIST= # empty
3715: ANOTHER_INT_LIST= apache-[0-9]*:../../www/apache
3716: EXT_LIST= # empty
3717: ANOTHER_EXT_LIST= a=b c=d
1.1 grant 3718:
1.75 rillig 3719: INT_LIST+= ${STRING} # 1
3720: INT_LIST+= ${ANOTHER_INT_LIST} # 2
3721: EXT_LIST+= ${STRING:Q} # 3
3722: EXT_LIST+= ${ANOTHER_EXT_LIST} # 4
1.1 grant 3723: </pre>
1.75 rillig 3724: <p>When you add a string to an external list (example 3), it
3725: must be quoted. In all other cases, you must not add a quoting
3726: level. You must not merge internal and external lists, unless you
3727: are sure that all entries are correctly interpreted in both
3728: lists.</p>
3729: </div>
3730: <div class="sect2" lang="en">
3731: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3732: <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 3733: <pre class="programlisting">
3734: EXT_LIST= # empty
3735: .for i in ${INT_LIST}
3736: EXT_LIST+= ${i:Q}""
3737: .endfor
1.1 grant 3738: </pre>
1.75 rillig 3739: <p>This code converts the internal list
3740: <code class="varname">INT_LIST</code> into the external list
3741: <code class="varname">EXT_LIST</code>. As the elements of an internal list
3742: are unquoted they must be quoted here. The reason for appending
3743: <code class="varname">""</code> is explained below.</p>
3744: </div>
3745: <div class="sect2" lang="en">
3746: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3747: <a name="passing-variable-to-shell"></a>10.2.3. Passing variables to a shell command</h3></div></div></div>
1.79 rillig 3748: <p>Sometimes you may want to print an arbitrary string. There
3749: are many ways to get it wrong and only few that can handle every
3750: nastiness.</p>
1.75 rillig 3751: <pre class="programlisting">
3752: STRING= foo bar < > * `date` $$HOME ' "
3753: EXT_LIST= string=${STRING:Q} x=second\ item
1.1 grant 3754:
1.75 rillig 3755: all:
3756: echo ${STRING} # 1
3757: echo "${STRING}" # 2
3758: echo "${STRING:Q}" # 3
3759: echo ${STRING:Q} # 4
3760: echo x${STRING:Q} | sed 1s,.,, # 5
1.79 rillig 3761: printf "%s\\n" ${STRING:Q}"" # 6
1.75 rillig 3762: env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
1.1 grant 3763: </pre>
1.75 rillig 3764: <p>Example 1 leads to a syntax error in the shell, as the
3765: characters are just copied.</p>
3766: <p>Example 2 leads to a syntax error too, and if you leave out
3767: the last " character from <code class="varname">${STRING}</code>,
3768: <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
3769: variable would be evaluated, too.</p>
3770: <p>Example 3 outputs each space character preceded by a
3771: backslash (or not), depending on the implementation of the
3772: <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>
3773: <p>Example 4 handles correctly every string that does not start
3774: with a dash. In that case, the result depends on the
3775: 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
3776: guarantee that your input does not start with a dash, this form is
3777: appropriate.</p>
3778: <p>Example 5 handles even the case of a leading dash
3779: correctly.</p>
1.79 rillig 3780: <p>Example 6 also works with every string and is the
3781: light-weight solution, since it does not involve a pipe, which has
3782: its own problems.</p>
1.75 rillig 3783: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
3784: because the quoting has already been done when adding elements to
3785: the list.</p>
3786: <p>As internal lists shall not be passed to the shell, there is
3787: no example for it.</p>
3788: </div>
3789: <div class="sect2" lang="en">
3790: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3791: <a name="quoting-guideline"></a>10.2.4. Quoting guideline</h3></div></div></div>
1.75 rillig 3792: <p>There are many possible sources of wrongly quoted variables.
3793: This section lists some of the commonly known ones.</p>
3794: <div class="itemizedlist"><ul type="disc">
3795: <li>
3796: <p>Whenever you use the value of a list, think
3797: about what happens to leading or trailing whitespace. If the
3798: list is a well-formed shell expression, you can apply the
3799: <code class="varname">:M*</code> modifier to strip leading and trailing
3800: whitespace from each word. The <code class="varname">:M</code> operator
3801: first splits its argument according to the rules of the shell,
3802: and then creates a new list consisting of all words that match
3803: the shell glob expression <code class="varname">*</code>, that is: all.
3804: One class of situations where this is needed is when adding a
3805: variable like <code class="varname">CPPFLAGS</code> to
3806: <code class="varname">CONFIGURE_ARGS</code>. If the configure script
3807: invokes other configure scripts, it strips the leading and
3808: trailing whitespace from the variable and then passes it to the
3809: other configure scripts. But these configure scripts expect the
3810: (child) <code class="varname">CPPFLAGS</code> variable to be the same as
3811: the parent <code class="varname">CPPFLAGS</code>. That's why we better
3812: pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
3813: here is how we do it:</p>
3814: <pre class="programlisting">
3815: CPPFLAGS= # empty
3816: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX:Q}\"
3817: CPPFLAGS+= ${MY_CPPFLAGS}
1.1 grant 3818:
1.75 rillig 3819: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
1.1 grant 3820:
1.75 rillig 3821: all:
3822: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
3823: echo x${CONFIGURE_ARGS}x # properly trimmed
1.1 grant 3824: </pre>
1.75 rillig 3825: </li>
3826: <li><p>The example above contains one bug: The
3827: <code class="varname">${PREFIX}</code> is a properly quoted shell
3828: expression, but there is the C compiler after it, which also
3829: expects a properly quoted string (this time in C syntax). The
3830: version above is therefore only correct if
3831: <code class="varname">${PREFIX}</code> does not have embedded backslashes
3832: or double quotes. If you want to allow these, you have to add
3833: another layer of quoting to each variable that is used as a C
3834: string literal. You cannot use the <code class="varname">:Q</code>
3835: operator for it, as this operator only works for the
3836: shell.</p></li>
3837: <li>
3838: <p>Whenever a variable can be empty, the
3839: <code class="varname">:Q</code> operator can have surprising results. Here
3840: are two completely different cases which can be solved with the
3841: same trick.</p>
3842: <pre class="programlisting">
3843: EMPTY= # empty
3844: empty_test:
3845: for i in a ${EMPTY:Q} c; do \
3846: echo "$$i"; \
3847: done
1.1 grant 3848:
1.75 rillig 3849: for_test:
3850: .for i in a:\ a:\test.txt
3851: echo ${i:Q}
3852: echo "foo"
3853: .endfor
1.1 grant 3854: </pre>
1.75 rillig 3855: <p>The first example will only print two of the three lines
3856: we might have expected. This is because
3857: <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
3858: the shell cannot see. The workaround is to write
3859: <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
3860: as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
3861: -f ${FNAME:Q}</code> (both of these are wrong).</p>
3862: <p>The second example will only print three lines instead of
3863: four. The first line looks like <code class="varname">a:\ echo foo</code>.
3864: This is because the backslash of the value
3865: <code class="varname">a:\</code> is interpreted as a line-continuation by
3866: <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
3867: <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
3868: <code class="varname">${i:Q}""</code>.</p>
3869: </li>
3870: </ul></div>
3871: </div>
3872: <div class="sect2" lang="en">
3873: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3874: <a name="bsd-make-bug-workaround"></a>10.2.5. Workaround for a bug in BSD Make</h3></div></div></div>
1.75 rillig 3875: <p>The pkgsrc bmake program does not handle the following
3876: assignment correctly. In case <code class="varname">_othervar_</code>
3877: contains a ``-'' character, one of the closing braces is included
3878: in <code class="varname">${VAR}</code> after this code executes.</p>
3879: <pre class="programlisting">
3880: VAR:= ${VAR:N${_othervar_:C/-//}}
1.1 grant 3881: </pre>
1.75 rillig 3882: <p>For a more complex code snippet and a workaround, see the
1.76 rillig 3883: 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 3884: <code class="varname">bug1</code>.</p>
3885: </div>
3886: </div>
3887: </div>
3888: <div class="chapter" lang="en">
3889: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3890: <a name="plist"></a>Chapter 11. PLIST issues</h2></div></div></div>
1.75 rillig 3891: <div class="toc">
3892: <p><b>Table of Contents</b></p>
3893: <dl>
1.77 rillig 3894: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
3895: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
3896: <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>
3897: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
3898: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
3899: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
3900: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
3901: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
1.75 rillig 3902: </dl>
3903: </div>
1.76 rillig 3904: <p> The <code class="filename">PLIST</code> file contains a package's
1.75 rillig 3905: “<span class="quote">packing list</span>”, i.e. a list of files that belong to
1.76 rillig 3906: the package (relative to the <code class="filename">${PREFIX}</code>
1.75 rillig 3907: directory it's been installed in) plus some additional statements
3908: - 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.
3909: This chapter addresses some issues that need attention when
1.76 rillig 3910: dealing with the <code class="filename">PLIST</code> file (or files, see
1.75 rillig 3911: below!).</p>
3912: <div class="sect1" lang="en">
3913: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3914: <a name="rcs-id"></a>11.1. RCS ID</h2></div></div></div>
1.75 rillig 3915: <p>
3916: Be sure to add a RCS ID line as the first thing in any
1.76 rillig 3917: <code class="filename">PLIST</code> file you write:
1.75 rillig 3918: </p>
3919: <pre class="programlisting">
3920: @comment $NetBSD$
1.55 rillig 3921: </pre>
1.75 rillig 3922: </div>
3923: <div class="sect1" lang="en">
3924: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3925: <a name="automatic-plist-generation"></a>11.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.75 rillig 3926: <p>You can use the <span><strong class="command">make print-PLIST</strong></span> command
3927: to output a PLIST that matches any new files since the package
1.77 rillig 3928: 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 3929: more information on this target.</p>
3930: </div>
3931: <div class="sect1" lang="en">
3932: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3933: <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 3934: <p> If you have used any of the *-dirs packages, as explained in
1.77 rillig 3935: <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 3936: <span><strong class="command">make print-PLIST</strong></span> outputs a set of
3937: <code class="varname">@comment</code>s instead of real
3938: <code class="varname">@dirrm</code> lines. You can also do this for
3939: specific directories and files, so that the results of that
3940: command are very close to reality. This helps <span class="emphasis"><em>a
3941: lot</em></span> during the update of packages. </p>
3942: <p> The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
3943: of AWK patterns and actions that are used to filter the output of
3944: print-PLIST. You can <span class="emphasis"><em>append</em></span> any chunk of AWK
3945: scripting you like to it, but be careful with quoting. </p>
3946: <p> For example, to get all files inside the
1.76 rillig 3947: <code class="filename">libdata/foo</code> directory removed from the
1.75 rillig 3948: resulting PLIST:</p>
3949: <pre class="programlisting">
3950: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
1.55 rillig 3951: </pre>
1.75 rillig 3952: <p> And to get all the <code class="varname">@dirrm</code> lines referring
3953: to a specific (shared) directory converted to
3954: <code class="varname">@comment</code>s: </p>
3955: <pre class="programlisting">
3956: PRINT_PLIST_AWK+= /^@dirrm share\/specific/ { print "@comment " $$0; next; }
1.51 rillig 3957: </pre>
1.75 rillig 3958: </div>
3959: <div class="sect1" lang="en">
3960: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3961: <a name="plist.misc"></a>11.4. Variable substitution in PLIST</h2></div></div></div>
1.75 rillig 3962: <p>
3963: A number of variables are substituted automatically in PLISTs
3964: when a package is installed on a system. This includes the
3965: following variables: </p>
3966: <div class="variablelist"><dl>
3967: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
3968: <dd>
3969: <p>Some packages like emacs and perl embed information
3970: about which architecture they were built on into the
3971: pathnames where they install their files. To handle this
3972: case, PLIST will be preprocessed before actually used, and
3973: the symbol
3974: “<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>” will be
3975: replaced by what <span><strong class="command">uname -p</strong></span> gives. The
3976: same is done if the string
3977: <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
3978: PLIST somewhere - use this on packages that have GNU
3979: autoconf-created configure scripts.</p>
3980: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
3981: <h3 class="title">Legacy note</h3>
3982: <p>There used to be a symbol
3983: “<span class="quote"><code class="varname">$ARCH</code></span>” that
3984: was replaced by the output of <span><strong class="command">uname
3985: -m</strong></span>, but that's no longer supported and has
3986: been removed.</p>
3987: </div>
3988: </dd>
3989: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
3990: <dd>
3991: <p>Some packages want to embed the OS name and version
3992: into some paths. To do this, use these variables in the
1.76 rillig 3993: <code class="filename">PLIST</code>:
1.75 rillig 3994: </p>
3995: <div class="itemizedlist"><ul type="disc">
3996: <li><p><code class="varname">${OPSYS}</code> - output of “<span class="quote"><span><strong class="command">uname -s</strong></span></span>”</p></li>
3997: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. “<span class="quote">solaris</span>”)</p></li>
3998: <li><p><code class="varname">${OS_VERSION}</code> - “<span class="quote"><span><strong class="command">uname -r</strong></span></span>”</p></li>
3999: </ul></div>
4000: </dd>
4001: </dl></div>
4002: <p> For a complete list of values which are replaced by
1.76 rillig 4003: default, please look in <code class="filename">bsd.pkg.mk</code> (and
1.75 rillig 4004: search for <span class="emphasis"><em>PLIST_SUBST</em></span>). </p>
4005: <p> If you want to change other variables not listed above, you
4006: can add variables and their expansions to this variable in the
1.77 rillig 4007: 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 4008: <pre class="programlisting">
4009: PLIST_SUBST+= SOMEVAR="somevalue"
1.1 grant 4010: </pre>
1.75 rillig 4011: <p>This replaces all occurrences of “<span class="quote">${SOMEVAR}</span>”
4012: in the PLIST with “<span class="quote">somevalue</span>”. </p>
4013: </div>
4014: <div class="sect1" lang="en">
4015: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4016: <a name="manpage-compression"></a>11.5. Man page compression</h2></div></div></div>
1.75 rillig 4017: <p>Man pages should be installed in compressed form if
1.76 rillig 4018: <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
1.75 rillig 4019: and uncompressed otherwise. To handle this in the
1.76 rillig 4020: <code class="filename">PLIST</code> file, the suffix “<span class="quote">.gz</span>” is
1.75 rillig 4021: appended/removed automatically for man pages according to
4022: <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
4023: or not, see above for details. This modification of the
1.76 rillig 4024: <code class="filename">PLIST</code> file is done on a copy of it, not
4025: <code class="filename">PLIST</code> itself.</p>
1.75 rillig 4026: </div>
4027: <div class="sect1" lang="en">
4028: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4029: <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 4030: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
1.75 rillig 4031: in generating the binary package, set the variable
4032: <code class="varname">PLIST_SRC</code> to the names of that file(s).
4033: 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
4034: important.</p>
4035: </div>
4036: <div class="sect1" lang="en">
4037: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4038: <a name="platform-specific-plist"></a>11.7. Platform-specific and differing PLISTs</h2></div></div></div>
1.75 rillig 4039: <p>Some packages decide to install a different set of files based on
4040: the operating system being used. These differences can be
4041: automatically handled by using the following files:</p>
4042: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4043: <li><p><code class="filename">PLIST.common</code></p></li>
4044: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
4045: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
4046: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
4047: <li><p><code class="filename">PLIST.common_end</code></p></li>
1.75 rillig 4048: </ul></div>
4049: </div>
4050: <div class="sect1" lang="en">
4051: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4052: <a name="faq.common-dirs"></a>11.8. Sharing directories between packages</h2></div></div></div>
1.75 rillig 4053: <p> A “<span class="quote">shared directory</span>” is a directory where
4054: multiple (and unrelated) packages install files. These
4055: directories are problematic because you have to add special tricks
4056: in the PLIST to conditionally remove them, or have some
4057: centralized package handle them. </p>
4058: <p> Within pkgsrc, you'll find both approaches. If a directory
4059: is shared by a few unrelated packages, it's often not worth to add
4060: an extra package to remove it. Therefore, one simply does:
4061: </p>
4062: <pre class="programlisting">
4063: @unexec ${RMDIR} %D/path/to/shared/directory 2>/dev/null || ${TRUE}
1.1 grant 4064: </pre>
1.75 rillig 4065: <p> in the PLISTs of all affected packages, instead of the
4066: regular "@dirrm" line. </p>
4067: <p> However, if the directory is shared across many packages, two
4068: different solutions are available: </p>
4069: <div class="orderedlist"><ol type="1">
4070: <li><p> If the packages have a common dependency, the directory
4071: can be removed in that. For example, see
1.76 rillig 4072: <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 4073: removes the shared directory
1.76 rillig 4074: <code class="filename">share/omf</code>. </p></li>
1.75 rillig 4075: <li><p> If the packages using the directory are not related at
4076: all (they have no common dependencies), a *-dirs package is
4077: used. </p></li>
4078: </ol></div>
4079: <p> From now on, we'll discuss the second solution. To get an
4080: idea of the *-dirs packages available, issue: </p>
4081: <pre class="programlisting">
4082: <code class="prompt">%</code> cd .../pkgsrc
4083: <code class="prompt">%</code> ls -d */*-dirs
1.1 grant 4084: </pre>
1.75 rillig 4085: <p> Their use from other packages is very simple. The
4086: <code class="varname">USE_DIRS</code> variable takes a list of package names
4087: (without the “<span class="quote">-dirs</span>” part) together with the required
4088: version number (always pick the latest one when writing new
4089: packages). </p>
4090: <p> For example, if a package installs files under
1.76 rillig 4091: <code class="filename">share/applications</code>, it should have the
1.75 rillig 4092: following line in it:
4093: </p>
4094: <pre class="programlisting">
4095: USE_DIRS+= xdg-1.1
1.1 grant 4096: </pre>
1.75 rillig 4097: <p> After regenerating the PLIST using <span><strong class="command">make
4098: print-PLIST</strong></span>, you should get the right (commented out)
4099: lines. </p>
4100: <p> Note that even if your package is using
1.76 rillig 4101: <code class="filename">$X11BASE</code>, it must not depend on the
1.75 rillig 4102: *-x11-dirs packages. Just specify the name without that part and
1.76 rillig 4103: pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
1.75 rillig 4104: care of it. </p>
4105: </div>
4106: </div>
4107: <div class="chapter" lang="en">
4108: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4109: <a name="buildlink"></a>Chapter 12. Buildlink methodology</h2></div></div></div>
1.75 rillig 4110: <div class="toc">
4111: <p><b>Table of Contents</b></p>
4112: <dl>
1.77 rillig 4113: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
4114: <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 4115: <dd><dl>
1.77 rillig 4116: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
4117: <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 4118: </dl></dd>
1.77 rillig 4119: <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 4120: <dd><dl>
1.77 rillig 4121: <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>
4122: <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 4123: </dl></dd>
4124: </dl>
4125: </div>
4126: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
4127: are seen by a package's configure and build processes. This is implemented
4128: in a two step process:</p>
4129: <div class="orderedlist"><ol type="1">
4130: <li><p>Symlink headers and libraries for dependencies into
4131: <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
4132: of <code class="varname">WRKDIR</code>.</p></li>
4133: <li><p>Create wrapper scripts that are used in place of the normal compiler
4134: tools that translate <code class="option">-I${LOCALBASE}/include</code> and
4135: <code class="option">-L${LOCALBASE}/lib</code> into references to
4136: <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
4137: native compiler on some operating systems look like GCC, so that
4138: packages that expect GCC won't require modifications to build with
4139: those native compilers.</p></li>
4140: </ol></div>
4141: <p>This normalizes the environment in which a package is built so that the
4142: package may be built consistently despite what other software may be
4143: installed. Please note that the normal system header and library paths,
1.76 rillig 4144: e.g. <code class="filename">/usr/include</code>,
4145: <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
1.75 rillig 4146: designed to insulate the package build from non-system-supplied
4147: software. </p>
4148: <div class="sect1" lang="en">
4149: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4150: <a name="converting-to-buildlink3"></a>12.1. Converting packages to use buildlink3</h2></div></div></div>
1.75 rillig 4151: <p>The process of converting packages to use the buildlink3
4152: framework (“<span class="quote">bl3ifying</span>”) is fairly straightforward.
4153: The things to keep in mind are:</p>
4154: <div class="orderedlist"><ol type="1">
4155: <li><p> Ensure that the build always calls the wrapper scripts
4156: instead of the actual toolchain. Some packages are tricky,
4157: and the only way to know for sure is the check
1.76 rillig 4158: <code class="filename">${WRKDIR}/.work.log</code> to see if the
1.75 rillig 4159: wrappers are being invoked. </p></li>
4160: <li><p> Don't override <code class="varname">PREFIX</code> from within
4161: the package Makefile, e.g. Java VMs, standalone shells,
4162: etc., because the code to symlink files into
1.76 rillig 4163: <code class="filename">${BUILDLINK_DIR}</code> looks for files
1.75 rillig 4164: relative to “<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>”.
4165: </p></li>
4166: <li><p> Remember that <span class="emphasis"><em>only</em></span> the
1.76 rillig 4167: <code class="filename">buildlink3.mk</code> files that you list in a
1.75 rillig 4168: package's Makefile are added as dependencies for that package.
4169: </p></li>
4170: </ol></div>
4171: <p> If a dependency on a particular package is required for its libraries and
4172: headers, then we replace: </p>
4173: <pre class="programlisting">
4174: DEPENDS+= foo>=1.1.0:../../category/foo
1.1 grant 4175: </pre>
1.75 rillig 4176: <p>with</p>
4177: <pre class="programlisting">
4178: .include "../../category/foo/buildlink3.mk"
1.1 grant 4179: </pre>
1.75 rillig 4180: <p>The buildlink3.mk files usually define the required dependencies.
4181: If you need a newer version of the dependency when using buildlink3.mk
4182: files, then you can define it in your Makefile; for example:
4183: </p>
4184: <pre class="programlisting">
4185: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
4186: .include "../../category/foo/buildlink3.mk"
1.1 grant 4187: </pre>
1.76 rillig 4188: <p>There are several <code class="filename">buildlink3.mk</code>
4189: files in <code class="filename">pkgsrc/mk</code>
1.75 rillig 4190: that handle special package issues:</p>
4191: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4192: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
1.75 rillig 4193: the native or a pkgsrc Berkeley DB implementation based on
4194: the values of <code class="varname">BDB_ACCEPTED</code> and
4195: <code class="varname">BDB_DEFAULT</code>.</p></li>
1.76 rillig 4196: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
1.75 rillig 4197: comes with neither Curses nor NCurses, this will take care
1.76 rillig 4198: 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>
4199: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
1.75 rillig 4200: of <code class="varname">KRB5_ACCEPTED</code> to choose between
4201: adding a dependency on Heimdal or MIT-krb5 for packages that
4202: require a Kerberos 5 implementation.</p></li>
1.76 rillig 4203: <li><p><code class="filename">motif.buildlink3.mk</code> checks
1.75 rillig 4204: for a system-provided
1.76 rillig 4205: 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
4206: <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>
4207: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
1.75 rillig 4208: variables that may be used by packages that use the
4209: Open Sound System (OSS) API.</p></li>
1.76 rillig 4210: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
1.75 rillig 4211: either Postgres 7.3 or 7.4, whichever is found installed. See
4212: the file for more information. </p></li>
1.76 rillig 4213: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
1.75 rillig 4214: <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
1.76 rillig 4215: 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>
4216: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
1.75 rillig 4217: <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
4218: library.</p></li>
4219: </ul></div>
1.76 rillig 4220: <p>The comments in those <code class="filename">buildlink3.mk</code>
1.75 rillig 4221: files provide a more complete
4222: description of how to use them properly.</p>
4223: </div>
4224: <div class="sect1" lang="en">
4225: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4226: <a name="creating-buildlink3.mk"></a>12.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
1.76 rillig 4227: <p> A package's <code class="filename">buildlink3.mk</code> file is
1.75 rillig 4228: included by Makefiles to indicate the need to compile and link
4229: against header files and libraries provided by the package. A
1.76 rillig 4230: <code class="filename">buildlink3.mk</code> file should always provide
1.75 rillig 4231: enough information to add the correct type of dependency
4232: relationship and include any other
1.76 rillig 4233: <code class="filename">buildlink3.mk</code> files that it needs to find
1.75 rillig 4234: headers and libraries that it needs in turn.</p>
1.76 rillig 4235: <p> To generate an initial <code class="filename">buildlink3.mk</code>
4236: 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 4237: package is highly recommended. For most packages, the following
4238: command will generate a good starting point for
1.76 rillig 4239: <code class="filename">buildlink3.mk</code> files:</p>
1.75 rillig 4240: <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>
4241: <code class="prompt">%</code> createbuildlink >buildlink3.mk</code></strong></pre>
4242: <div class="sect2" lang="en">
4243: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4244: <a name="anatomy-of-bl3"></a>12.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
1.75 rillig 4245: <p>The following real-life example
1.76 rillig 4246: <code class="filename">buildlink3.mk</code> is taken
4247: from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
1.75 rillig 4248: <pre class="programlisting">
4249: # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
1.1 grant 4250:
1.75 rillig 4251: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
4252: TIFF_BUILDLINK3_MK:= ${TIFF_BUILDLINK3_MK}+
1.1 grant 4253:
1.75 rillig 4254: .if !empty(BUILDLINK_DEPTH:M+)
4255: BUILDLINK_DEPENDS+= tiff
4256: .endif
1.1 grant 4257:
1.75 rillig 4258: BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Ntiff}
4259: BUILDLINK_PACKAGES+= tiff
1.1 grant 4260:
1.75 rillig 4261: .if !empty(TIFF_BUILDLINK3_MK:M+)
4262: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
4263: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
4264: .endif # TIFF_BUILDLINK3_MK
1.1 grant 4265:
1.75 rillig 4266: .include "../../devel/zlib/buildlink3.mk"
4267: .include "../../graphics/jpeg/buildlink3.mk"
1.1 grant 4268:
1.75 rillig 4269: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
1.1 grant 4270: </pre>
1.75 rillig 4271: <p> The header and footer manipulate
4272: <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
1.76 rillig 4273: <code class="filename">buildlink3.mk</code> files and is used to track
1.75 rillig 4274: at what depth we are including
1.76 rillig 4275: <code class="filename">buildlink3.mk</code> files.</p>
1.75 rillig 4276: <p> The first section controls if the dependency on
4277: <em class="replaceable"><code>pkg</code></em> is added.
4278: <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
4279: packages for which dependencies are added by
4280: buildlink3.</p>
4281: <p> The second section advises pkgsrc that the
1.76 rillig 4282: <code class="filename">buildlink3.mk</code> file for
1.75 rillig 4283: <em class="replaceable"><code>pkg</code></em> has been included at some point.
4284: <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
1.76 rillig 4285: packages for which <code class="filename">buildlink3.mk</code> files
1.75 rillig 4286: have been included. It must <span class="emphasis"><em>always</em></span> be
1.76 rillig 4287: appended to within a <code class="filename">buildlink3.mk</code>
1.75 rillig 4288: file. </p>
4289: <p> The third section is protected from multiple inclusion
4290: and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
4291: added. Several important variables are set in the section:
4292: </p>
4293: <div class="itemizedlist"><ul type="disc">
4294: <li><p> <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4295: is the actual dependency recorded in the installed
4296: package; this should always be set using
4297: <span><strong class="command">+=</strong></span> to ensure that
4298: we're appending to any pre-existing list of values. This
4299: variable should be set to the first version of the
4300: package that had an API change.
4301: </p></li>
4302: <li><p> <code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
4303: is the location of the <em class="replaceable"><code>pkg</code></em>
4304: pkgsrc directory.</p></li>
4305: <li><p>
4306: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
4307: (not shown above) controls whether we use
4308: <code class="varname">BUILD_DEPENDS</code> or
4309: <code class="varname">DEPENDS</code> to add the dependency on
4310: <em class="replaceable"><code>pkg</code></em>.
4311: The build dependency is selected by setting
4312: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
4313: to “<span class="quote">build</span>”. By default, the
4314: full dependency is used.
4315: </p></li>
4316: <li><p>
4317: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
4318: and
4319: <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
4320: (not shown above) are lists of subdirectories of
1.76 rillig 4321: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4322: to add to the header and library search paths. These
4323: default to “<span class="quote">include</span>” and “<span class="quote">lib</span>”
4324: respectively. </p></li>
4325: <li><p>
4326: <code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
4327: (not shown above) is the list of preprocessor flags to add
4328: to <code class="varname">CPPFLAGS</code>, which are passed on to the
4329: configure and build phases. The “<span class="quote">-I</span>” option
4330: should be avoided and instead be handled using
4331: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
4332: above.</p></li>
4333: </ul></div>
4334: <p> The following variables are all optionally defined within
4335: this second section (protected against multiple inclusion) and
4336: control which package files are symlinked into
1.76 rillig 4337: <code class="filename">${BUILDLINK_DIR}</code> and how their names are
1.75 rillig 4338: transformed during the symlinking: </p>
4339: <div class="itemizedlist"><ul type="disc">
4340: <li><p>
4341: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
4342: (not shown above) is a shell glob pattern relative to
1.76 rillig 4343: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4344: to be symlinked into
1.76 rillig 4345: <code class="filename">${BUILDLINK_DIR}</code>,
4346: e.g. <code class="filename">include/*.h</code>. </p></li>
1.75 rillig 4347: <li><p>
4348: <code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
4349: (not shown above) is a shell pipeline that
4350: outputs to stdout a list of files relative to
1.76 rillig 4351: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
1.75 rillig 4352: The resulting files are to be symlinked
1.76 rillig 4353: into <code class="filename">${BUILDLINK_DIR}</code>. By default,
4354: this takes the <code class="filename">+CONTENTS</code> of a
1.75 rillig 4355: <em class="replaceable"><code>pkg</code></em> and filters it through
4356: <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.
4357: </p></li>
4358: <li><p>
4359: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
4360: (not shown above) is a filter command that filters
1.76 rillig 4361: <code class="filename">+CONTENTS</code> input into a list of files
1.75 rillig 4362: relative to
1.76 rillig 4363: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4364: on stdout. By default for overwrite packages,
4365: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.76 rillig 4366: outputs the contents of the <code class="filename">include</code>
4367: and <code class="filename">lib</code> directories in the package
4368: <code class="filename">+CONTENTS</code>, and for pkgviews packages,
1.75 rillig 4369: it outputs any libtool archives in
1.76 rillig 4370: <code class="filename">lib</code> directories.
1.75 rillig 4371: </p></li>
4372: <li><p>
4373: <code class="varname">BUILDLINK_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
4374: (not shown above) is a list of sed arguments used to
4375: transform the name of the source filename into a
4376: destination filename, e.g. <span><strong class="command">-e
4377: "s|/curses.h|/ncurses.h|g"</strong></span>.
4378: </p></li>
4379: </ul></div>
4380: <p> The last section includes any
1.76 rillig 4381: <code class="filename">buildlink3.mk</code> needed for
1.75 rillig 4382: <em class="replaceable"><code>pkg</code></em>'s library dependencies.
1.76 rillig 4383: Including these <code class="filename">buildlink3.mk</code> files
1.75 rillig 4384: means that the headers and libraries for these
4385: dependencies are also symlinked into
1.76 rillig 4386: <code class="filename">${BUILDLINK_DIR}</code>
1.75 rillig 4387: whenever the <em class="replaceable"><code>pkg</code></em>
1.76 rillig 4388: <code class="filename">buildlink3.mk</code>
1.75 rillig 4389: file is included.
4390: </p>
4391: </div>
4392: <div class="sect2" lang="en">
4393: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4394: <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 4395: <p>
4396: The situation that requires increasing the dependency listed in
4397: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4398: after a package update is when the API or interface to the
4399: header files change.</p>
4400: <p> In this case,
4401: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4402: should be adjusted to require at least the new package
4403: version. In some cases, the packages that depend on this new
4404: version may need their <code class="varname">PKGREVISION</code>s
1.76 rillig 4405: increased and, if they have <code class="filename">buildlink3.mk</code>
1.75 rillig 4406: files, their
4407: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4408: adjusted, too. This is needed so pkgsrc will require the
4409: correct package dependency and not settle for an older one
4410: when building the source.</p>
4411: <p>
4412: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4413: should be increased when the binary interface or sonames
4414: (major number of the library version) of any installed
4415: shared libraries change. This is needed so that binary
4416: packages made using it will require the correct package
4417: dependency and not settle for an older one which will not
4418: contain the necessary shared libraries. </p>
4419: <p>
1.78 rillig 4420: See <a href="#dependencies" title="17.1.6. Handling dependencies">Section 17.1.6, “Handling dependencies”</a> for
1.75 rillig 4421: more information about dependencies on other packages,
4422: including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
4423: <code class="varname">ABI_DEPENDS</code> definitions. </p>
4424: <p> Please take careful consideration before adjusting
4425: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4426: or
4427: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4428: as we don't want to cause unneeded package deletions and
4429: rebuilds. In many cases, new versions of packages work just
4430: fine with older dependencies.</p>
4431: <p>
4432: Also it is not needed to set
4433: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4434: when it is identical to
4435: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>. </p>
4436: </div>
4437: </div>
4438: <div class="sect1" lang="en">
4439: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4440: <a name="writing-builtin.mk"></a>12.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.75 rillig 4441: <p>
4442: Some packages in pkgsrc install headers and libraries that
4443: coincide with headers and libraries present in the base system.
1.76 rillig 4444: Aside from a <code class="filename">buildlink3.mk</code> file, these
4445: packages should also include a <code class="filename">builtin.mk</code>
1.75 rillig 4446: file that includes the necessary checks to decide whether using
4447: the built-in software or the pkgsrc software is
4448: appropriate. </p>
4449: <p> The only requirements of a builtin.mk file for
4450: <em class="replaceable"><code>pkg</code></em> are:
4451: </p>
4452: <div class="orderedlist"><ol type="1">
4453: <li><p> It should set
4454: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4455: to either “<span class="quote">yes</span>” or “<span class="quote">no</span>”
4456: after it is included.
4457: </p></li>
4458: <li><p> It should <span class="emphasis"><em>not</em></span> override any
4459: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4460: which is already set before the
1.76 rillig 4461: <code class="filename">builtin.mk</code> file is included.
1.75 rillig 4462: </p></li>
4463: <li><p> It should be written to allow multiple inclusion. This
4464: is <span class="emphasis"><em>very</em></span> important and takes careful
1.76 rillig 4465: attention to <code class="filename">Makefile</code> coding.
1.75 rillig 4466: </p></li>
4467: </ol></div>
4468: <div class="sect2" lang="en">
4469: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4470: <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 4471: <p>The following is the recommended template for builtin.mk
4472: files: </p>
4473: <pre class="programlisting">
4474: .if !defined(IS_BUILTIN.foo)
4475: #
4476: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
4477: # genuinely exists in the system or not.
4478: #
4479: IS_BUILTIN.foo?= no
1.1 grant 4480:
1.75 rillig 4481: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
4482: # version can be determined.
4483: #
4484: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
4485: BUILTIN_PKG.foo?= foo-1.0
4486: . endif
4487: .endif # IS_BUILTIN.foo
1.1 grant 4488:
1.75 rillig 4489: .if !defined(USE_BUILTIN.foo)
4490: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
4491: . if defined(BUILTIN_PKG.foo)
4492: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
4493: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
4494: USE_BUILTIN.foo!= \
4495: if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then \
4496: ${ECHO} "yes"; \
4497: else \
4498: ${ECHO} "no"; \
4499: fi
4500: . endif
4501: . endfor
4502: . endif
4503: .endif # USE_BUILTIN.foo
1.1 grant 4504:
1.75 rillig 4505: CHECK_BUILTIN.foo?= no
4506: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
4507: #
4508: # Here we place code that depends on whether USE_BUILTIN.foo is set to
4509: # "yes" or "no".
4510: #
4511: .endif # CHECK_BUILTIN.foo
1.1 grant 4512: </pre>
1.75 rillig 4513: <p> The first section sets
4514: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4515: depending on if <em class="replaceable"><code>pkg</code></em> really exists
4516: in the base system. This should not be a base system software
4517: with similar functionality to <em class="replaceable"><code>pkg</code></em>;
4518: it should only be “<span class="quote">yes</span>” if the actual package is
4519: included as part of the base system. This variable is only
1.76 rillig 4520: used internally within the <code class="filename">builtin.mk</code>
1.75 rillig 4521: file. </p>
4522: <p> The second section sets
4523: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
4524: to the version of <em class="replaceable"><code>pkg</code></em> in the base
4525: system if it exists (if
4526: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4527: is “<span class="quote">yes</span>”). This variable is only used internally
1.76 rillig 4528: within the <code class="filename">builtin.mk</code> file. </p>
1.75 rillig 4529: <p> The third section sets
4530: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4531: and is <span class="emphasis"><em>required</em></span> in all
1.76 rillig 4532: <code class="filename">builtin.mk</code> files. The code in this
1.75 rillig 4533: section must make the determination whether the built-in
4534: software is adequate to satisfy the dependencies listed in
4535: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
4536: This is typically done by comparing
4537: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
4538: against each of the dependencies in
4539: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
4540: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4541: <span class="emphasis"><em>must</em></span> be set to the correct value by the
1.76 rillig 4542: end of the <code class="filename">builtin.mk</code> file. Note that
1.75 rillig 4543: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4544: may be “<span class="quote">yes</span>” even if
4545: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4546: is “<span class="quote">no</span>” because we may make the determination
4547: that the built-in version of the software is similar enough to
4548: be used as a replacement. </p>
4549: <p> The last section is guarded by
4550: <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
4551: and includes code that uses the value of
4552: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4553: set in the previous section. This typically includes, e.g.,
4554: adding additional dependency restrictions and listing
4555: additional files to symlink into
1.76 rillig 4556: <code class="filename">${BUILDLINK_DIR}</code> (via
1.75 rillig 4557: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).
4558: </p>
4559: </div>
4560: <div class="sect2" lang="en">
4561: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4562: <a name="native-or-pkgsrc-preference"></a>12.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
1.75 rillig 4563: <p>
4564: When building packages, it's possible to choose whether to set
4565: a global preference for using either the built-in (native)
4566: version or the pkgsrc version of software to satisfy a
4567: dependency. This is controlled by setting
4568: <code class="varname">PREFER_PKGSRC</code> and
4569: <code class="varname">PREFER_NATIVE</code>. These variables take values
4570: of either “<span class="quote">yes</span>”, “<span class="quote">no</span>”, or a list of
4571: packages. <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
4572: use the pkgsrc versions of software, while
4573: <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
4574: built-in versions. Preferences are determined by the most
4575: specific instance of the package in either
4576: <code class="varname">PREFER_PKGSRC</code> or
4577: <code class="varname">PREFER_NATIVE</code>. If a package is specified
4578: in neither or in both variables, then
4579: <code class="varname">PREFER_PKGSRC</code> has precedence over
4580: <code class="varname">PREFER_NATIVE</code>. For example, to require
4581: using pkgsrc versions of software for all but the most basic
4582: bits on a NetBSD system, you can set: </p>
4583: <pre class="programlisting">
4584: PREFER_PKGSRC= yes
4585: PREFER_NATIVE= getopt skey tcp_wrappers
1.1 grant 4586: </pre>
1.75 rillig 4587: <p> A package <span class="emphasis"><em>must</em></span> have a
1.76 rillig 4588: <code class="filename">builtin.mk</code>
1.75 rillig 4589: file to be listed in <code class="varname">PREFER_NATIVE</code>,
4590: otherwise it is simply ignored in that list.
4591: </p>
4592: </div>
4593: </div>
4594: </div>
4595: <div class="chapter" lang="en">
4596: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4597: <a name="pkginstall"></a>Chapter 13. The pkginstall framework</h2></div></div></div>
1.75 rillig 4598: <div class="toc">
4599: <p><b>Table of Contents</b></p>
4600: <dl>
1.77 rillig 4601: <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 4602: <dd><dl>
1.77 rillig 4603: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
4604: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
1.75 rillig 4605: </dl></dd>
1.77 rillig 4606: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
1.75 rillig 4607: <dd><dl>
1.77 rillig 4608: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
4609: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
4610: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
4611: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
4612: </dl></dd>
4613: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
4614: <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>
4615: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
4616: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
4617: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
4618: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
4619: <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 4620: </dl>
4621: </div>
4622: <p>This chapter describes the framework known as
4623: <code class="literal">pkginstall</code>, whose key features are:</p>
4624: <div class="itemizedlist"><ul type="disc">
4625: <li><p>Generic installation and manipulation of directories and files
4626: outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
4627: <li><p>Automatic handling of configuration files during installation,
4628: provided that packages are correctly designed.</p></li>
4629: <li><p>Generation and installation of system startup scripts.</p></li>
4630: <li><p>Registration of system users and groups.</p></li>
4631: <li><p>Registration of system shells.</p></li>
4632: <li><p>Automatic updating of fonts databases.</p></li>
4633: </ul></div>
4634: <p>The following sections inspect each of the above points in detail.</p>
4635: <p>You may be thinking that many of the things described here could be
4636: easily done with simple code in the package's post-installation target
4637: (<code class="literal">post-install</code>). <span class="emphasis"><em>This is incorrect</em></span>,
4638: as the code in them is only executed when building from source. Machines
4639: using binary packages could not benefit from it at all (as the code itself
4640: could be unavailable). Therefore, the only way to achieve any of the items
4641: described above is by means of the installation scripts, which are
4642: automatically generated by pkginstall.</p>
4643: <div class="sect1" lang="en">
4644: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4645: <a name="files-and-dirs-outside-prefix"></a>13.1. Files and directories outside the installation prefix</h2></div></div></div>
1.76 rillig 4646: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
1.75 rillig 4647: of files and directories that belong to a package. The names used in it
1.76 rillig 4648: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
1.75 rillig 4649: which means that it cannot register files outside this directory (absolute
4650: path names are not allowed). Despite this restriction, some packages need
4651: to install files outside this location; e.g., under
1.76 rillig 4652: <code class="filename">${VARBASE}</code> or
4653: <code class="filename">${PKG_SYSCONFDIR}</code>.</p>
1.75 rillig 4654: <p>The only way to achieve this is to create such files during
4655: installation time by using the installation scripts. These scripts can run
4656: arbitrary commands, so they have the potential to create and manage files
4657: anywhere in the file system. Here is where pkginstall comes into play: it
4658: provides generic scripts to abstract the manipulation of such files and
4659: directories based on variables set in the package's
1.76 rillig 4660: <code class="filename">Makefile</code>. The rest of this section describes these
1.75 rillig 4661: variables.</p>
4662: <div class="sect2" lang="en">
4663: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4664: <a name="dirs-outside-prefix"></a>13.1.1. Directory manipulation</h3></div></div></div>
1.75 rillig 4665: <p>The following variables can be set to request the creation of
4666: directories anywhere in the file system:</p>
4667: <div class="itemizedlist"><ul type="disc">
4668: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
4669: contain a list of directories that should be created and should attempt
4670: to be destroyed by the installation scripts. The difference between
4671: the two is that the latter prompts the administrator to remove any
4672: directories that may be left after deinstallation (because they were
4673: not empty), while the former does not.</p></li>
4674: <li>
4675: <p><code class="varname">MAKE_DIRS_PERMS</code> and
4676: <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
4677: which directories should be created and should attempt to be destroyed
4678: by the installation scripts. Each tuple holds the following values,
4679: separated by spaces: the directory name, its owner, its group and its
4680: numerical mode. For example:</p>
4681: <pre class="programlisting">
4682: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 4683: </pre>
1.75 rillig 4684: <p>The difference between the two is exactly the same as their
4685: non-<code class="varname">PERMS</code> counterparts.</p>
4686: </li>
4687: </ul></div>
4688: </div>
4689: <div class="sect2" lang="en">
4690: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4691: <a name="files-outside-prefix"></a>13.1.2. File manipulation</h3></div></div></div>
1.75 rillig 4692: <p>Creating non-empty files outside the installation prefix is tricky
1.76 rillig 4693: because the <code class="filename">PLIST</code> forces all files to be inside it.
1.75 rillig 4694: To overcome this problem, the only solution is to extract the file in the
4695: known place (i.e., inside the installation prefix) and copy it to the
4696: appropriate location during installation (done by the installation scripts
4697: generated by pkginstall). We will call the former the <span class="emphasis"><em>master
4698: file</em></span> in the following paragraphs, which describe the variables
4699: that can be used to automatically and consistently handle files outside the
4700: installation prefix:</p>
4701: <div class="itemizedlist"><ul type="disc">
4702: <li>
4703: <p><code class="varname">CONF_FILES</code> and
4704: <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
4705: During installation time, the master file is copied to the target one
4706: if and only if the latter does not exist. Upon deinstallation, the
4707: target file is removed provided that it was not modified by the
4708: installation.</p>
4709: <p>The difference between the two is that the latter prompts the
4710: administrator to remove any files that may be left after
4711: deinstallation (because they were not empty), while the former does
4712: not.</p>
4713: </li>
4714: <li>
4715: <p><code class="varname">CONF_FILES_PERMS</code> and
4716: <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
4717: files as well as their target locations. For each of them, it also
4718: specifies their owner, their group and their numeric permissions, in
4719: this order. For example:</p>
4720: <pre class="programlisting">
4721: SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 4722: </pre>
1.75 rillig 4723: <p>The difference between the two is exactly the same as their
4724: non-<code class="varname">PERMS</code> counterparts.</p>
4725: </li>
4726: </ul></div>
4727: </div>
4728: </div>
4729: <div class="sect1" lang="en">
4730: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4731: <a name="conf-files"></a>13.2. Configuration files</h2></div></div></div>
1.75 rillig 4732: <p>Configuration files are special in the sense that they are installed
4733: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
4734: need special treatment during installation (most of which is automated by
4735: pkginstall). The main concept you must bear in mind is that files marked
4736: as configuration files are automatically copied to the right place (somewhere
4737: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
4738: and only if</em></span> they didn't exist before. Similarly, they will not
4739: be removed if they have local modifications. This ensures that
4740: administrators never lose any custom changes they may have made.</p>
4741: <div class="sect2" lang="en">
4742: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4743: <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 4744: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
4745: specifies where configuration files shall be installed. Its contents are
4746: set based upon the following variables:</p>
4747: <div class="itemizedlist"><ul type="disc">
4748: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
1.76 rillig 4749: directory. Defaults to <code class="filename">${PREFIX}/etc</code> although it may
1.75 rillig 4750: be overridden by the user to point to his preferred location (e.g.,
1.76 rillig 4751: <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
1.75 rillig 4752: Packages must not use it directly.</p></li>
4753: <li>
4754: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
4755: <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
4756: for the package being built shall be installed. The definition of this
4757: variable only makes sense in the package's
1.76 rillig 4758: <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
1.75 rillig 4759: <p>As an example, consider the Apache package,
1.76 rillig 4760: <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 4761: configuration files under the
1.76 rillig 4762: <code class="filename">httpd/</code> subdirectory of
1.75 rillig 4763: <code class="varname">PKG_SYSCONFBASE</code>. This should be set in the package
4764: Makefile.</p>
4765: </li>
4766: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
4767: variable that holds this package's configuration directory (if
4768: different from <code class="varname">PKG_SYSCONFBASE</code>). It defaults to
4769: <code class="varname">PKGBASE</code>'s value, and is always prefixed with
4770: <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
4771: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
4772: directory where the configuration files for the package identified by
4773: <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
4774: </ul></div>
4775: <p>Based on the above variables, pkginstall determines the value of
4776: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
4777: variable that can be used within a package to refer to its configuration
4778: directory. The algorithm used to set its value is basically the
4779: following:</p>
4780: <div class="orderedlist"><ol type="1">
4781: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
4782: its value is used.</p></li>
4783: <li><p>If the previous variable is not defined but
4784: <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
1.76 rillig 4785: <code class="filename">Makefile</code>, the resulting value is
4786: <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
1.75 rillig 4787: <li><p>Otherwise, it is set to
1.76 rillig 4788: <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
1.75 rillig 4789: </ol></div>
1.76 rillig 4790: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
1.77 rillig 4791: 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 4792: </div>
4793: <div class="sect2" lang="en">
4794: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4795: <a name="conf-files-configure"></a>13.2.2. Telling the software where configuration files are</h3></div></div></div>
1.75 rillig 4796: <p>Given that pkgsrc (and users!) expect configuration files to be in a
4797: known place, you need to teach each package where it shall install its
4798: files. In some cases you will have to patch the package Makefiles to
4799: achieve it. If you are lucky, though, it may be as easy as passing an
4800: extra flag to the configuration script; this is the case of GNU Autoconf-
4801: generated files:</p>
4802: <pre class="programlisting">
4803: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1 grant 4804: </pre>
1.75 rillig 4805: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
4806: for</em></span> its configuration files, not where they will be originally
4807: installed (although the difference is never explicit,
4808: unfortunately).</p>
4809: </div>
4810: <div class="sect2" lang="en">
4811: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4812: <a name="conf-files-patching"></a>13.2.3. Patching installations</h3></div></div></div>
1.75 rillig 4813: <p>As said before, pkginstall automatically handles configuration files.
4814: This means that <span class="strong"><strong>the packages themselves must not
1.76 rillig 4815: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
1.75 rillig 4816: directly</strong></span>. Bad news is that many software installation scripts
4817: will, out of the box, mess with the contents of that directory. So what is
4818: the correct procedure to fix this issue?</p>
4819: <p>You must teach the package (usually by manually patching it) to
4820: install any configuration files under the examples hierarchy,
1.76 rillig 4821: <code class="filename">share/examples/${PKGBASE}/</code>. This way, the
4822: <code class="filename">PLIST</code> registers them and the administrator always
1.75 rillig 4823: has the original copies available.</p>
4824: <p>Once the required configuration files are in place (i.e., under the
4825: examples hierarchy), the pkginstall framework can use them as master copies
4826: during the package installation to update what is in
1.76 rillig 4827: <code class="filename">${PKG_SYSCONFDIR}</code>. To achieve this, the variables
1.75 rillig 4828: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
1.77 rillig 4829: 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 4830: about their syntax and their purpose. Here is an example, taken from the
1.76 rillig 4831: <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 4832: <pre class="programlisting">
4833: EGDIR= ${PREFIX}/share/doc/mutt/samples
4834: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1 grant 4835: </pre>
1.75 rillig 4836: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
4837: package and has no meaning outside it.</p>
4838: </div>
4839: <div class="sect2" lang="en">
4840: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4841: <a name="conf-files-disable"></a>13.2.4. Disabling handling of configuration files</h3></div></div></div>
1.75 rillig 4842: <p>The automatic copying of config files can be toggled by setting the
4843: environment variable <code class="varname">PKG_CONFIG</code> prior to package
4844: installation.</p>
4845: </div>
4846: </div>
4847: <div class="sect1" lang="en">
4848: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4849: <a name="rcd-scripts"></a>13.3. System startup scripts</h2></div></div></div>
1.75 rillig 4850: <p>System startup scripts are special files because they must be
4851: installed in a place known by the underlying OS, usually outside the
1.77 rillig 4852: 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 4853: can be used. However, pkginstall provides a special mechanism to handle
4854: these files.</p>
4855: <p>In order to provide system startup scripts, the package has
4856: to:</p>
4857: <div class="orderedlist"><ol type="1">
1.76 rillig 4858: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
1.75 rillig 4859: the <code class="literal">.sh</code> suffix appended. Considering the
1.76 rillig 4860: <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
4861: <code class="filename">cupsd.sh</code> in its files directory.</p></li>
1.75 rillig 4862: <li>
4863: <p>Tell pkginstall to handle it, appending the name of the script,
4864: without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
4865: Continuing the previous example:</p>
4866: <pre class="programlisting">
4867: RCD_SCRIPTS+= cupsd
1.1 grant 4868: </pre>
1.75 rillig 4869: </li>
4870: </ol></div>
4871: <p>Once this is done, pkginstall will do the following steps for each
4872: script in an automated fashion:</p>
4873: <div class="orderedlist"><ol type="1">
4874: <li><p>Process the file found in the files directory applying all the
1.76 rillig 4875: substitutions described in the <code class="filename">FILES_SUBST</code>
1.75 rillig 4876: variable.</p></li>
4877: <li><p>Copy the script from the files directory to the examples
1.76 rillig 4878: hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>. Note
1.75 rillig 4879: that this master file must be explicitly registered in the
1.76 rillig 4880: <code class="filename">PLIST</code>.</p></li>
1.75 rillig 4881: <li><p>Add code to the installation scripts to copy the startup script
4882: from the examples hierarchy into the system-wide startup scripts
4883: directory.</p></li>
4884: </ol></div>
4885: <div class="sect2" lang="en">
4886: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4887: <a name="rcd-scripts-disable"></a>13.3.1. Disabling handling of system startup scripts</h3></div></div></div>
1.75 rillig 4888: <p>The automatic copying of config files can be toggled by setting the
4889: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
4890: installation. Note that the scripts will be always copied inside the
1.76 rillig 4891: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
1.75 rillig 4892: matter what the value of this variable is.</p>
4893: </div>
4894: </div>
4895: <div class="sect1" lang="en">
4896: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4897: <a name="users-and-groups"></a>13.4. System users and groups</h2></div></div></div>
1.75 rillig 4898: <p>If a package needs to create special users and/or groups during
4899: installation, it can do so by using the pkginstall framework.</p>
4900: <p>Users can be created by adding entries to the
4901: <code class="varname">PKG_USERS</code> variable. Each entry has the following
4902: syntax:</p>
4903: <pre class="programlisting">
4904: user:group
1.1 grant 4905: </pre>
1.75 rillig 4906: <p>Further specification of user details may be done by setting per-user
4907: variables.
4908: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the numeric
4909: UID for the user.
4910: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the user's
4911: description or comment.
4912: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the user's
1.76 rillig 4913: home directory, and defaults to <code class="filename">/nonexistent</code> if not
1.75 rillig 4914: specified.
4915: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the user's
1.76 rillig 4916: shell, and defaults to <code class="filename">/sbinno/login</code> if not specified.
1.75 rillig 4917: </p>
4918: <p>Similarly, groups can be created by adding entries to the
4919: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
4920: <pre class="programlisting">
4921: group
1.1 grant 4922: </pre>
1.75 rillig 4923: <p>The numeric GID of the group may be set by defining
4924: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
4925: <p>If a package needs to create the users and groups at an earlier
4926: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
4927: either <code class="literal">configure</code> or <code class="literal">build</code> to
4928: indicate the phase before which the users and groups are created. In
4929: this case, the numeric UIDs and GIDs of the created users and groups
4930: are automatically hardcoded into the final installation scripts.</p>
4931: </div>
4932: <div class="sect1" lang="en">
4933: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4934: <a name="shells"></a>13.5. System shells</h2></div></div></div>
1.75 rillig 4935: <p>Packages that install system shells should register them in the shell
1.76 rillig 4936: database, <code class="filename">/etc/shells</code>, to make things easier to the
1.75 rillig 4937: administrator. This must be done from the installation scripts to keep
4938: binary packages working on any system. pkginstall provides an easy way to
4939: accomplish this task.</p>
4940: <p>When a package provides a shell interpreter, it has to set the
4941: <code class="varname">PKG_SHELL</code> variable to its absolute file name. This will
4942: add some hooks to the installation scripts to handle it. Consider the
1.76 rillig 4943: 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 4944: <pre class="programlisting">
4945: PKG_SHELL= ${PREFIX}/bin/zsh
1.1 grant 4946: </pre>
1.75 rillig 4947: <div class="sect2" lang="en">
4948: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4949: <a name="shells-disable"></a>13.5.1. Disabling shell registration</h3></div></div></div>
1.75 rillig 4950: <p>The automatic registration of shell interpreters can be disabled by
1.76 rillig 4951: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
1.75 rillig 4952: environment variable to <code class="literal">NO</code>.</p>
4953: </div>
4954: </div>
4955: <div class="sect1" lang="en">
4956: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4957: <a name="fonts"></a>13.6. Fonts</h2></div></div></div>
1.75 rillig 4958: <p>Packages that install X11 fonts should update the database files
4959: that index the fonts within each fonts directory. This can easily be
4960: accomplished within the pkginstall framework.</p>
4961: <p>When a package installs X11 fonts, it must list the directories in
4962: which fonts are installed in the
4963: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
4964: where <em class="replaceable"><code>type</code></em> can be one of “<span class="quote">ttf</span>”,
4965: “<span class="quote">type1</span>” or “<span class="quote">x11</span>”. This will add hooks to the
4966: installation scripts to run the appropriate commands to update the fonts
4967: database files within each of those directories. For convenience, if the
4968: directory path is relative, it is taken to be relative to the package's
1.76 rillig 4969: 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 4970: <pre class="programlisting">
4971: FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
1.1 grant 4972: </pre>
1.75 rillig 4973: <div class="sect2" lang="en">
4974: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4975: <a name="fonts-disable"></a>13.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
1.75 rillig 4976: <p>The automatic update of fonts databases can be disabled by
1.76 rillig 4977: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
1.75 rillig 4978: environment variable to <code class="literal">NO</code>.</p>
4979: </div>
4980: </div>
4981: </div>
4982: <div class="chapter" lang="en">
4983: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4984: <a name="options"></a>Chapter 14. Options handling</h2></div></div></div>
1.75 rillig 4985: <div class="toc">
4986: <p><b>Table of Contents</b></p>
4987: <dl>
1.77 rillig 4988: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
4989: <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>
4990: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
1.75 rillig 4991: </dl>
4992: </div>
4993: <p>Many packages have the ability to be built to support different
1.76 rillig 4994: sets of features. <code class="filename">bsd.options.mk</code> is a framework
1.75 rillig 4995: in pkgsrc that provides generic handling of those options that
4996: determine different ways in which the packages can be built. It's
4997: possible for the user to specify exactly which sets of options will be
4998: built into a package or to allow a set of global default options
4999: apply.</p>
5000: <div class="sect1" lang="en">
5001: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5002: <a name="global-default-options"></a>14.1. Global default options</h2></div></div></div>
1.75 rillig 5003: <p>Global default options are listed in
5004: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
5005: that should be built into every package if that option is supported.
1.76 rillig 5006: This variable should be set in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 5007: </div>
5008: <div class="sect1" lang="en">
5009: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5010: <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 5011: <p>The following example shows how
1.76 rillig 5012: <code class="filename">bsd.options.mk</code> should be used
1.75 rillig 5013: by the hypothetical ``wibble'' package, either in the package
1.76 rillig 5014: <code class="filename">Makefile</code>, or in a file,
5015: e.g. <code class="filename">options.mk</code>, that is included by the
5016: main package <code class="filename">Makefile</code>.</p>
1.75 rillig 5017: <pre class="programlisting">
5018: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
5019: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
5020: PKG_OPTIONS_OPTIONAL_GROUPS= database
5021: PKG_OPTIONS_GROUP.database= mysql pgsql
5022: PKG_SUGGESTED_OPTIONS= wibble-foo
5023: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
5024: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
1.1 grant 5025:
1.75 rillig 5026: .include "../../mk/bsd.prefs.mk"
1.69 rillig 5027:
1.75 rillig 5028: # this package was previously named wibble2
5029: .if defined(PKG_OPTIONS.wibble2)
5030: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
5031: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
1.78 rillig 5032: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
1.75 rillig 5033: .endif
1.69 rillig 5034:
1.75 rillig 5035: .include "../../mk/bsd.options.mk"
1.69 rillig 5036:
1.75 rillig 5037: # Package-specific option-handling
1.69 rillig 5038:
1.75 rillig 5039: ###
5040: ### FOO support
5041: ###
5042: .if !empty(PKG_OPTIONS:Mwibble-foo)
5043: CONFIGURE_ARGS+= --enable-foo
5044: .endif
1.69 rillig 5045:
1.75 rillig 5046: ###
5047: ### LDAP support
5048: ###
5049: .if !empty(PKG_OPTIONS:Mldap)
1.77 rillig 5050: . include "../../databases/openldap-client/buildlink3.mk"
5051: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
1.75 rillig 5052: .endif
1.69 rillig 5053:
1.75 rillig 5054: ###
5055: ### database support
5056: ###
5057: .if !empty(PKG_OPTIONS:Mmysql)
5058: . include "../../mk/mysql.buildlink3.mk"
5059: .endif
5060: .if !empty(PKG_OPTIONS:Mpgsql)
5061: . include "../../mk/pgsql.buildlink3.mk"
5062: .endif
5063: </pre>
5064: <p>The first section contains the information about which build
5065: options are supported by the package, and any default options settings
5066: if needed.</p>
5067: <div class="orderedlist"><ol type="1">
5068: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
5069: <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
5070: options. It should be set to
1.78 rillig 5071: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
5072: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is not defined
5073: at the point where the options are processed.</p></li>
1.75 rillig 5074: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
5075: build options supported by the package.</p></li>
5076: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
5077: list of names of groups of mutually exclusive options. The options in
5078: each group are listed in
5079: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
5080: The most specific setting of any option from the group takes
5081: precedence over all other options in the group. Options from the
5082: groups will be automatically added to
5083: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
5084: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
5085: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
5086: packages will fail if no option from the group is
5087: selected.</p></li>
5088: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
5089: of names of sets of options. At least one option from each set must
5090: be selected. The options in each set are listed in
5091: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
5092: Options from the sets will be automatically added to
5093: <code class="varname">PKG_SUPPORTED_OPTIONS</code>. Building the package will
5094: fail if no option from the set is selected.</p></li>
5095: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
5096: build options which are enabled by default.</p></li>
5097: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
5098: of
5099: “<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>”
1.76 rillig 5100: pairs that map legacy <code class="filename">/etc/mk.conf</code> variables to
1.75 rillig 5101: their option counterparts. Pairs should be added with
5102: “<span class="quote">+=</span>” to keep the listing of global legacy variables. A
5103: warning will be issued if the user uses a legacy
5104: variable.</p></li>
5105: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
5106: of
5107: “<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>”
5108: pairs that map options that have been renamed to their new
5109: counterparts. Pairs should be added with “<span class="quote">+=</span>” to keep
5110: the listing of global legacy options. A warning will be issued if
5111: the user uses a legacy option.</p></li>
5112: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
5113: options implied by deprecated variables used. This can be used for
5114: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
5115: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
5116: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
5117: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
5118: a list of warnings about deprecated variables or options used, and
5119: what to use instead.</p></li>
5120: </ol></div>
5121: <p>A package should never modify
5122: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
5123: <code class="varname">PKG_OPTIONS_VAR</code>. These are strictly user-settable.
5124: To suggest a default set of options, use
5125: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
5126: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
1.76 rillig 5127: including <code class="filename">bsd.options.mk</code>. If none of
1.75 rillig 5128: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
5129: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
5130: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
5131: happen with platform-specific options if none of them is supported on
5132: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
5133: empty list and the package is otherwise treated as not using the
5134: options framework.</p>
1.76 rillig 5135: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
1.75 rillig 5136: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
5137: build options, properly filtered to remove unsupported and duplicate
5138: options.</p>
5139: <p>The remaining sections contain the logic that is specific to
5140: each option. The correct way to check for an option is to check
5141: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
5142: <pre class="programlisting">
5143: .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
5144: </pre>
5145: </div>
5146: <div class="sect1" lang="en">
5147: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5148: <a name="option-names"></a>14.3. Option Names</h2></div></div></div>
1.75 rillig 5149: <p>Options that enable similar features in different packages (like
5150: optional support for a library) should use a common name in all
5151: packages that support it (like the name of the library). If another
5152: package already has an option with the same meaning, use the same
5153: name.</p>
5154: <p>Options that enable features specific to one package, where it's
5155: unlikely that another (unrelated) package has the same (or a similar)
5156: optional feature, should use a name prefixed with
5157: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
5158: <p>If a group of related packages share an optional feature
5159: specific to that group, prefix it with the name of the
5160: “<span class="quote">main</span>” package
5161: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
5162: <p>For new options, add a line to
1.76 rillig 5163: <code class="filename">mk/defaults/options.description</code>. Lines have two
1.75 rillig 5164: fields, separated by tab. The first field is the option name, the
5165: second its description. The description should be a whole sentence
5166: (starting with an uppercase letter and ending with a period) that
5167: describes what enabling the option does. E. g. “<span class="quote">Enable ispell
5168: support.</span>” The file is sorted by option names.</p>
5169: </div>
5170: </div>
5171: <div class="chapter" lang="en">
5172: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5173: <a name="build"></a>Chapter 15. The build process</h2></div></div></div>
1.75 rillig 5174: <div class="toc">
5175: <p><b>Table of Contents</b></p>
5176: <dl>
1.77 rillig 5177: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
5178: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
5179: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
5180: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
5181: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
1.81 ! rillig 5182: <dd><dl>
! 5183: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
! 5184: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
! 5185: </dl></dd>
1.77 rillig 5186: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
5187: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
5188: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
5189: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
5190: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
5191: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
5192: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
5193: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
5194: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
5195: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
5196: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
1.75 rillig 5197: </dl>
5198: </div>
5199: <div class="sect1" lang="en">
5200: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5201: <a name="build.intro"></a>15.1. Introduction</h2></div></div></div>
1.75 rillig 5202: <p>This chapter gives a detailed description on how a package is
5203: built. Building a package is separated into different
5204: <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
5205: <code class="varname">build</code>, <code class="varname">install</code>), all of which are
5206: described in the following sections. Each phase is splitted into
5207: so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
5208: containing phase, prefixed by one of <code class="varname">pre-</code>,
5209: <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
5210: <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
5211: of the actual work is done in the <code class="varname">do-*</code> stages.</p>
5212: <p>The basic steps for building a program are always the same. First
5213: the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
5214: the local system and then extracted. After any pkgsrc-specific patches
5215: to compile properly are applied, the software can be configured, then
5216: built (usually by compiling), and finally the generated binaries, etc.
5217: can be put into place on the system.</p>
5218: </div>
5219: <div class="sect1" lang="en">
5220: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5221: <a name="build.prefix"></a>15.2. Program location</h2></div></div></div>
1.75 rillig 5222: <p>Before outlining the process performed by the NetBSD package system in
5223: the next section, here's a brief discussion on where programs are
5224: installed, and which variables influence this.</p>
5225: <p>The automatic variable <code class="varname">PREFIX</code> indicates
5226: where all files of the final program shall be installed. It is
5227: usually set to <code class="varname">LOCALBASE</code>
1.76 rillig 5228: (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
1.75 rillig 5229: for pkgs in the “<span class="quote">cross</span>” category. The value of
5230: <code class="varname">PREFIX</code> needs to be put
5231: into the various places in the program's source where paths to
1.77 rillig 5232: 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 5233: <p>When choosing which of these variables to use,
5234: follow the following rules:</p>
5235: <div class="itemizedlist"><ul type="disc">
5236: <li><p><code class="varname">PREFIX</code> always points to the location where the current
5237: pkg will be installed. When referring to a pkg's own installation path,
5238: use “<span class="quote">${PREFIX}</span>”.</p></li>
5239: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs are installed.
5240: If you need to construct a -I or -L argument to the compiler to find
5241: includes and libraries installed by another non-X11 pkg, use
1.78 rillig 5242: “<span class="quote">${LOCALBASE}</span>”. The name
5243: <code class="varname">LOCALBASE</code> stems from FreeBSD, which
5244: installed all packages in <code class="filename">/usr/local</code>. As
5245: pkgsrc leaves <code class="filename">/usr/local</code> for the system
5246: administrator, this variable is a misnomer.</p></li>
1.75 rillig 5247: <li><p><code class="varname">X11BASE</code> is where the actual X11 distribution (from
5248: xsrc, etc.) is installed. When looking for
5249: <span class="emphasis"><em>standard</em></span> X11 includes (not
5250: those installed by a pkg), use “<span class="quote">${X11BASE}</span>”.</p></li>
5251: <li>
5252: <p>X11-based packages are special in that they may be installed in
5253: either <code class="varname">X11BASE</code> or <code class="varname">LOCALBASE</code>.</p>
5254: <p>Usually, X11 packages should be installed under
5255: <code class="varname">LOCALBASE</code> whenever possible. Note that you will
1.76 rillig 5256: need to include <code class="filename">../../mk/x11.buildlink3.mk</code>
1.75 rillig 5257: in them to request the
5258: presence of X11 and to get the right compilation flags.</p>
5259: <p>Even though, there are some packages that cannot be installed
5260: under <code class="varname">LOCALBASE</code>: those that come with app-defaults
5261: files. These packages are special and they must be placed under
5262: <code class="varname">X11BASE</code>. To accomplish this, set either
5263: <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
5264: your package.</p>
5265: <p>Some notes: If you need
5266: to find includes or libraries installed by a pkg that has
5267: <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
1.76 rillig 5268: its pkg <code class="filename">Makefile</code>, you need to look in
5269: <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
5270: <code class="filename">${LOCALBASE}</code>. To force installation of
1.75 rillig 5271: all X11 packages in <code class="varname">LOCALBASE</code>, the
1.76 rillig 5272: <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 5273: is enabled by default.</p>
5274: </li>
5275: <li><p><code class="varname">X11PREFIX</code> should be used to refer to the installed
5276: location of an X11 package. <code class="varname">X11PREFIX</code> will be set to
5277: <code class="varname">X11BASE</code> if xpkgwedge is not installed,
5278: and to <code class="varname">LOCALBASE</code> if xpkgwedge is installed.</p></li>
5279: <li>
5280: <p>If xpkgwedge is installed, it is possible to have some packages installed
5281: in <code class="varname">X11BASE</code> and some in <code class="varname">LOCALBASE</code>.
5282: To determine the prefix of an installed package, the
5283: <code class="varname">EVAL_PREFIX</code> definition can be used. It takes pairs in the
5284: 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
5285: <code class="varname">DIRNAME</code> will be set to the prefix of the installed
5286: package <package>, or “<span class="quote">${X11PREFIX}</span>” if the package is
5287: not installed.</p>
5288: <p>This is best illustrated by example.</p>
5289: <p>The following lines are taken from
1.76 rillig 5290: <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
1.75 rillig 5291: <pre class="programlisting">
5292: EVAL_PREFIX+= GTKDIR=gtk+
5293: CONFIGURE_ARGS+= --with-guile-prefix=${LOCALBASE:Q}
5294: CONFIGURE_ARGS+= --with-gtk-prefix=${GTKDIR:Q}
5295: CONFIGURE_ARGS+= --enable-multibyte
5296: </pre>
5297: <p>Specific defaults can be defined for the packages evaluated using
5298: <code class="varname">EVAL_PREFIX</code>, by using a definition of the form:</p>
5299: <pre class="programlisting">
5300: GTKDIR_DEFAULT= ${LOCALBASE}
5301: </pre>
5302: <p>where <code class="varname">GTKDIR</code> corresponds
5303: to the first definition in
5304: the <code class="varname">EVAL_PREFIX</code> pair.</p>
5305: </li>
1.76 rillig 5306: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.75 rillig 5307: 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 5308: manual pages go into <code class="filename">${PREFIX}/man</code>, not
5309: <code class="filename">${PREFIX}/share/man</code>.</p></li>
1.75 rillig 5310: </ul></div>
5311: </div>
5312: <div class="sect1" lang="en">
5313: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5314: <a name="build.builddirs"></a>15.3. Directories used during the build process</h2></div></div></div>
1.75 rillig 5315: <p>When building a package, a number of directories is used to store
5316: source files, temporary files, pkgsrc-internal files, and so on. These
5317: directories are explained here.</p>
5318: <p>Some of the directory variables contain relative pathnames. There
5319: are two common base directories for these relative directories:
5320: <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
5321: pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
5322: inside the package itself.</p>
5323: <div class="variablelist"><dl>
5324: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
5325: <dd><p>This is an absolute pathname that points to the pkgsrc
5326: root directory. Generally, you don't need
5327: it.</p></dd>
5328: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
5329: <dd><p>This is a pathname relative to
5330: <code class="varname">PKGSRCDIR</code> that points to the current
5331: package.</p></dd>
5332: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
5333: <dd><p>This is an absolute pathname pointing to the directory
5334: where all work takes place. The distfiles are extraced to this
5335: directory. It also contains temporary directories and log files used by
5336: the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
5337: the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
5338: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
5339: <dd><p>This is an absolute pathname pointing to the directory
5340: where the distfiles are extracted. It is usually a direct subdirectory
5341: of <code class="varname">WRKDIR</code>, and often it's the only directory entry
5342: that isn't hidden. This variable may be changed by a package
1.76 rillig 5343: <code class="filename">Makefile</code>.</p></dd>
1.75 rillig 5344: </dl></div>
5345: </div>
5346: <div class="sect1" lang="en">
5347: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5348: <a name="build.running"></a>15.4. Running a phase</h2></div></div></div>
1.75 rillig 5349: <p>You can run a particular phase by typing <span><strong class="command">make
5350: phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
5351: phase. This will automatically run all phases that are required for this
5352: phase. The default phase is <code class="varname">build</code>, that is, when you
5353: run <span><strong class="command">make</strong></span> without parameters in a package directory,
5354: the package will be built, but not installed.</p>
5355: </div>
5356: <div class="sect1" lang="en">
5357: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5358: <a name="build.fetch"></a>15.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.81 ! rillig 5359: <p>The first step in building a package is to fetch the
! 5360: distribution files (distfiles) from the sites that are providing
! 5361: them. This is the task of the <span class="emphasis"><em>fetch</em></span>
! 5362: phase.</p>
! 5363: <div class="sect2" lang="en">
! 5364: <div class="titlepage"><div><div><h3 class="title">
! 5365: <a name="build.fetch.what"></a>15.5.1. What to fetch and where to get it from</h3></div></div></div>
! 5366: <p>In simple cases, <code class="varname">MASTER_SITES</code> defines
! 5367: all URLs from where the distfile, whose name is derived from the
! 5368: <code class="varname">DISTNAME</code> variable, is fetched. The more
! 5369: complicated cases are described below.</p>
! 5370: <p>The variable <code class="varname">DISTFILES</code> specifies the
! 5371: list of distfiles that have to be fetched. Its value defaults to
! 5372: <code class="literal">${DISTNAME}${EXTRACT_SUFX}</code>, so that most
! 5373: packages don't need to define it at all.
! 5374: <code class="varname">EXTRACT_SUFX</code> is <code class="literal">.tar.gz</code> by
! 5375: default, but can be changed freely. Note that if your package
! 5376: requires additional distfiles to the default one, you cannot
! 5377: just append the additional filenames using the
! 5378: <code class="literal">+=</code> operator, but you have write for
! 5379: example:</p>
! 5380: <pre class="programlisting">
! 5381: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
! 5382: </pre>
! 5383: <p>Each of the distfiles is fetched from a list of sites,
! 5384: usually <code class="varname">MASTER_SITES</code>. If the package has
! 5385: multiple <code class="varname">DISTFILES</code> or multiple
! 5386: <code class="varname">PATCHFILES</code> from different sites, you can set
! 5387: <code class="varname">SITES.<em class="replaceable"><code>distfile</code></em></code> to
! 5388: the list of URLs where the file
! 5389: <code class="filename"><em class="replaceable"><code>distfile</code></em></code>
! 5390: (including the suffix) can be found.</p>
! 5391: <pre class="programlisting">
! 5392: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
! 5393: DISTFILES+= foo-file.tar.gz
! 5394: SITES.foo-file.tar.gz= \
! 5395: http://www.somewhere.com/somehow/ \
! 5396: http://www.somewhereelse.com/mirror/somehow/
! 5397: </pre>
! 5398: <p>When actually fetching the distfiles, each item from
! 5399: <code class="varname">MASTER_SITES</code> or <code class="varname">SITES.*</code>
! 5400: gets the name of each distfile appended to it, without an
! 5401: intermediate slash. Therefore, all site values have to end with
! 5402: a slash or other separator character. This allows for example to
! 5403: set <code class="varname">MASTER_SITES</code> to a URL of a CGI script
! 5404: that gets the name of the distfile as a parameter. In this case,
! 5405: the definition would look like:</p>
! 5406: <pre class="programlisting">
! 5407: MASTER_SITES= http://www.example.com/download.cgi?file=
! 5408: </pre>
! 5409: <p>There are some predefined values for
! 5410: <code class="varname">MASTER_SITES</code>, which can be used in packages.
! 5411: The names of the variables should speak for themselves.</p>
! 5412: <pre class="programlisting">
! 5413: ${MASTER_SITE_APACHE}
! 5414: ${MASTER_SITE_BACKUP}
! 5415: ${MASTER_SITE_CYGWIN}
! 5416: ${MASTER_SITE_DEBIAN}
! 5417: ${MASTER_SITE_FREEBSD}
! 5418: ${MASTER_SITE_FREEBSD_LOCAL}
! 5419: ${MASTER_SITE_GNOME}
! 5420: ${MASTER_SITE_GNU}
! 5421: ${MASTER_SITE_GNUSTEP}
! 5422: ${MASTER_SITE_IFARCHIVE}
! 5423: ${MASTER_SITE_KDE}
! 5424: ${MASTER_SITE_MOZILLA}
! 5425: ${MASTER_SITE_MYSQL}
! 5426: ${MASTER_SITE_OPENOFFICE}
! 5427: ${MASTER_SITE_PERL_CPAN}
! 5428: ${MASTER_SITE_PGSQL}
! 5429: ${MASTER_SITE_R_CRAN}
! 5430: ${MASTER_SITE_SOURCEFORGE}
! 5431: ${MASTER_SITE_SOURCEFORGE_JP}
! 5432: ${MASTER_SITE_SUNSITE}
! 5433: ${MASTER_SITE_SUSE}
! 5434: ${MASTER_SITE_TEX_CTAN}
! 5435: ${MASTER_SITE_XCONTRIB}
! 5436: ${MASTER_SITE_XEMACS}
! 5437: </pre>
! 5438: <p>If you choose one of these predefined sites, you may want
! 5439: to specify a subdirectory of that site. Since these macros may
! 5440: expand to more than one actual site, you
! 5441: <span class="emphasis"><em>must</em></span> use the following construct to specify
! 5442: a subdirectory:</p>
! 5443: <pre class="programlisting">
! 5444: MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
! 5445: MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
! 5446: </pre>
! 5447: <p>Note the trailing slash after the subdirectory
! 5448: name.</p>
! 5449: </div>
! 5450: <div class="sect2" lang="en">
! 5451: <div class="titlepage"><div><div><h3 class="title">
! 5452: <a name="build.fetch.how"></a>15.5.2. How are the files fetched?</h3></div></div></div>
! 5453: <p>The <span class="emphasis"><em>fetch</em></span> phase makes sure that all
! 5454: the distfiles exist in a local directory
! 5455: (<code class="varname">DISTDIR</code>), which can be set by the pkgsrc
! 5456: user). If the files do not exist, they are fetched using
! 5457: commands of the form
! 5458:
! 5459: </p>
1.75 rillig 5460: <pre class="programlisting">
5461: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
5462: </pre>
1.81 ! rillig 5463: <p>
! 5464:
! 5465: where <code class="literal">${site}</code> varies through several
! 5466: possibilities in turn: first,
! 5467: <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the sites
! 5468: specified in either <code class="varname">SITES.file</code> if defined,
! 5469: else <code class="varname">MASTER_SITES</code> or
! 5470: <code class="varname">PATCH_SITES</code>, as applies, then finally the
! 5471: value of <code class="varname">MASTER_SITE_BACKUP</code>. The order of all
! 5472: except the first can be optionally sorted by the user, via
! 5473: setting either <code class="varname">MASTER_SORT_AWK</code> or
! 5474: <code class="varname">MASTER_SORT_REGEX</code>.</p>
! 5475: </div>
1.75 rillig 5476: </div>
5477: <div class="sect1" lang="en">
5478: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5479: <a name="build.checksum"></a>15.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
1.75 rillig 5480: <p>After the distfile(s) are fetched, their checksum is generated and
5481: compared with the checksums stored in the distinfo file. If the
5482: checksums don't match, the build is aborted. This is to ensure the same
5483: distfile is used for building, and that the distfile wasn't changed,
5484: e.g. by some malign force, deliberately changed distfiles on the master
5485: distribution site or network lossage.</p>
5486: </div>
5487: <div class="sect1" lang="en">
5488: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5489: <a name="build.extract"></a>15.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
1.75 rillig 5490: <p>When the distfiles are present on the local system, they
5491: need to be extracted, as they usually come in the form of some
5492: compressed archive format.</p>
5493: <p>By default, all <code class="varname">DISTFILES</code> are
5494: extracted. If you only need some of them, you can set the
5495: <code class="varname">EXTRACT_ONLY</code> variable to the list of those
5496: files.</p>
5497: <p>Extracting the files is usually done by a little program,
1.76 rillig 5498: <code class="filename">mk/scripts/extract</code>, which already knows how
1.75 rillig 5499: to extract various archive formats, so most likely you will not
5500: need to change anything here. But if you need, the following
5501: variables may help you:</p>
5502: <div class="variablelist"><dl>
5503: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
5504: <dd><p>Use these variables to override the default
5505: options for an extract command, which are defined in
1.76 rillig 5506: <code class="filename">mk/scripts/extract</code>.</p></dd>
1.75 rillig 5507: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
5508: <dd><p>This variable can be set to
5509: <code class="literal">pax</code>, <code class="literal">tar</code> or an absolute
5510: pathname pointing to the command with which tar archives should
5511: be extracted.</p></dd>
5512: </dl></div>
1.76 rillig 5513: <p>If the <code class="filename">extract</code> program doesn't serve
1.75 rillig 5514: your needs, you can also override the
5515: <code class="varname">EXTRACT_CMD</code> variable, which holds the command
5516: used for extracting the files. This command is executed in the
1.76 rillig 5517: <code class="filename">${WRKSRC}</code> directory. During execution of
1.75 rillig 5518: this command, the shell variable <code class="varname">extract_file</code>
5519: holds the absolute pathname of the file that is going to be
5520: extracted.</p>
5521: <p>And if that still does not suffice, you can override the
5522: <code class="varname">do-extract</code> target in the package
5523: Makefile.</p>
5524: </div>
5525: <div class="sect1" lang="en">
5526: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5527: <a name="build.patch"></a>15.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
1.75 rillig 5528: <p>After extraction, all the patches named by the
5529: <code class="varname">PATCHFILES</code>, those present in the patches
5530: subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
1.76 rillig 5531: <code class="filename">/usr/local/patches/graphics/png</code>) are applied.
5532: Patchfiles ending in <code class="filename">.Z</code> or
5533: <code class="filename">.gz</code> are uncompressed before they are applied,
5534: files ending in <code class="filename">.orig</code> or
5535: <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 5536: can be handed in <code class="varname">PATCH_DIST_ARGS</code>.
1.77 rillig 5537: See <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a> for more details.</p>
1.75 rillig 5538: <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
5539: patches apply with some lines of fuzz. Please fix (regen) the patches
5540: so that they apply cleanly. The rationale behind this is that
5541: patches that don't apply cleanly may end up being applied in the wrong
5542: place, and cause severe harm there.</p>
5543: </div>
5544: <div class="sect1" lang="en">
5545: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5546: <a name="build.tools"></a>15.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
1.75 rillig 5547: <p>This is covered in
1.77 rillig 5548: <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 5549: </p>
5550: </div>
5551: <div class="sect1" lang="en">
5552: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5553: <a name="build.wrapper"></a>15.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
1.75 rillig 5554: <p>This phase creates wrapper programs for the compilers and
5555: linkers. The following variables can be used to tweak the
5556: wrappers.</p>
5557: <div class="variablelist"><dl>
5558: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
5559: <dd><p>The command used to print progress
5560: messages. Does nothing by default. Set to
5561: <code class="literal">${ECHO}</code> to see the progress
5562: messages.</p></dd>
5563: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
5564: <dd><p>This variable can be set to
5565: <code class="literal">yes</code> (default) or
5566: <code class="literal">no</code>, depending on whether you want
5567: additional information in the wrapper log
5568: file.</p></dd>
5569: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
5570: <dd><p>This variable can be set to
5571: <code class="literal">yes</code> or <code class="literal">no</code>,
5572: depending on whether the wrapper should use its cache,
5573: which will improve the speed. The default value is
5574: <code class="literal">yes</code>, but is forced to
5575: <code class="literal">no</code> if the platform does not support
5576: it.</p></dd>
5577: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
5578: <dd><p>A list of reordering commands. A
5579: reordering command has the form
5580: <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
5581: It ensures that that
5582: <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code>
5583: occurs before
5584: <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
5585: </p></dd>
5586: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
5587: <dd><p>A list of transformation commands. [TODO:
5588: investigate further]</p></dd>
5589: </dl></div>
5590: </div>
5591: <div class="sect1" lang="en">
5592: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5593: <a name="build.configure"></a>15.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.75 rillig 5594: <p>Most pieces of software need information on the header files,
5595: system calls, and library routines which are available on the platform
5596: they run on. The process of determining this information is known as
5597: configuration, and is usually automated. In most cases, a script is
5598: supplied with the distfiles, and its invocation results in generation of
5599: header files, Makefiles, etc.</p>
5600: <p>If the package contains a configure script, this can be invoked by
5601: setting <code class="varname">HAS_CONFIGURE</code> to “<span class="quote">yes</span>”. If the
5602: configure script is a GNU autoconf script, you should set
5603: <code class="varname">GNU_CONFIGURE</code> to “<span class="quote">yes</span>” instead. What
5604: happens in the <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
5605: <pre class="programlisting">
5606: .for d in ${CONFIGURE_DIRS}
5607: cd ${WRKSRC} && cd ${d} && env ${CONFIGURE_ENV} \
5608: ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
5609: .endfor
5610: </pre>
5611: <p><code class="varname">CONFIGURE_DIRS</code> (default: “<span class="quote">.</span>”) is a
5612: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
5613: these directories, the configure script is run with the environment
5614: <code class="varname">CONFIGURE_ENV</code> and arguments
5615: <code class="varname">CONFIGURE_ARGS</code>. The variables
5616: <code class="varname">CONFIGURE_ENV</code>, <code class="varname">CONFIGURE_SCRIPT</code>
5617: (default: “<span class="quote">./configure</span>”) and
5618: <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
5619: package.</p>
1.76 rillig 5620: <p>If the program uses an <code class="filename">Imakefile</code> for
1.75 rillig 5621: configuration, the appropriate steps can be invoked by setting
5622: <code class="varname">USE_IMAKE</code> to “<span class="quote">yes</span>”. (If you only want
5623: the package installed in <code class="varname">${X11PREFIX}</code> but xmkmf not
5624: being run, set <code class="varname">USE_X11BASE</code> instead.)</p>
5625: </div>
5626: <div class="sect1" lang="en">
5627: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5628: <a name="build.build"></a>15.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.75 rillig 5629: <p>For building a package, a rough equivalent of the following code
5630: is executed.</p>
5631: <pre class="programlisting">
5632: .for d in ${BUILD_DIRS}
5633: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
5634: ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
5635: -f ${MAKEFILE} ${BUILD_TARGET}
5636: .endfor
5637: </pre>
5638: <p><code class="varname">BUILD_DIRS</code> (default: “<span class="quote">.</span>”) is a
5639: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
5640: these directories, <code class="varname">MAKE_PROGRAM</code> is run with the
5641: environment <code class="varname">MAKE_ENV</code> and arguments
5642: <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
5643: <code class="varname">MAKE_ENV</code>, <code class="varname">BUILD_MAKE_FLAGS</code>,
5644: <code class="varname">MAKEFILE</code> and <code class="varname">BUILD_TARGET</code> may all
5645: be changed by the package.</p>
5646: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
5647: “<span class="quote">gmake</span>” if <code class="varname">USE_TOOLS</code> contains
5648: “<span class="quote">gmake</span>”, “<span class="quote">make</span>” otherwise. The default value
5649: of <code class="varname">MAKEFILE</code> is “<span class="quote">Makefile</span>”, and
5650: <code class="varname">BUILD_TARGET</code> defaults to “<span class="quote">all</span>”.</p>
5651: </div>
5652: <div class="sect1" lang="en">
5653: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5654: <a name="build.test"></a>15.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
1.75 rillig 5655: <p>[TODO]</p>
5656: </div>
5657: <div class="sect1" lang="en">
5658: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5659: <a name="build.install"></a>15.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75 rillig 5660: <p>Once the build stage has completed, the final step is to
5661: install the software in public directories, so users can access
5662: the programs and files.</p>
5663: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
5664: equivalent of the following code is executed. Additionally,
5665: before and after this code, much magic is performed to do
5666: consistency checks, registering the package, and so on.</p>
5667: <pre class="programlisting">
5668: .for d in ${INSTALL_DIRS}
5669: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
5670: ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
5671: -f ${MAKEFILE} ${BUILD_TARGET}
5672: .endfor
5673: </pre>
5674: <p>The variable's meanings are analogous to the ones in the
5675: <span class="emphasis"><em>build</em></span> phase.
5676: <code class="varname">INSTALL_DIRS</code> defaults to
5677: <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
5678: is “<span class="quote">install</span>” by default, plus
5679: “<span class="quote">install.man</span>” if <code class="varname">USE_IMAKE</code> is
5680: defined.</p>
5681: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
5682: variables are useful. They are all variations of the
5683: <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
5684: permissions preset. <code class="varname">INSTALL</code> is the plain
5685: install command. The specialized variants, together with their
5686: intended use, are:</p>
5687: <div class="variablelist"><dl>
5688: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
5689: <dd><p>directories that contain binaries</p></dd>
5690: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
5691: <dd><p>directories that contain scripts</p></dd>
5692: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
5693: <dd><p>directories that contain shared and static libraries</p></dd>
5694: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
5695: <dd><p>directories that contain data files</p></dd>
5696: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
5697: <dd><p>directories that contain man pages</p></dd>
5698: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
5699: <dd><p>binaries that can be stripped from debugging symbols</p></dd>
5700: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
5701: <dd><p>binaries that cannot be stripped</p></dd>
5702: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
5703: <dd><p>game binaries</p></dd>
5704: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
5705: <dd><p>shared and static libraries</p></dd>
5706: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
5707: <dd><p>data files</p></dd>
5708: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
5709: <dd><p>data files for games</p></dd>
5710: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
5711: <dd><p>man pages</p></dd>
5712: </dl></div>
5713: <p>Some other variables are:</p>
5714: <div class="variablelist"><dl>
5715: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
5716: <dd><p>A list of directories relative to
5717: <code class="varname">PREFIX</code> that are created by pkgsrc at
1.78 rillig 5718: the beginning of the <span class="emphasis"><em>install</em></span> phase.
5719: If this variable is set,
1.75 rillig 5720: <code class="varname">NO_MTREE</code>=“<span class="quote">yes</span>” is
5721: assumed, which means that the package claims to create
5722: all needed directories itself before installing files to
5723: it. Therefore this variable should only be set in
1.76 rillig 5724: <code class="filename">Makefile</code>s that are under control of
1.78 rillig 5725: the package's author. The directories are created with
5726: the correct ownership, depending on their
5727: name.</p></dd>
1.75 rillig 5728: </dl></div>
5729: </div>
5730: <div class="sect1" lang="en">
5731: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5732: <a name="build.package"></a>15.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
1.75 rillig 5733: <p>[TODO]</p>
5734: </div>
5735: <div class="sect1" lang="en">
5736: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5737: <a name="build.helpful-targets"></a>15.16. Other helpful targets</h2></div></div></div>
1.75 rillig 5738: <div class="variablelist"><dl>
5739: <dt><span class="term">pre/post-*</span></dt>
5740: <dd><p>For any of the main targets described in the previous section, two
5741: auxiliary targets exist with “<span class="quote">pre-</span>” and
5742: “<span class="quote">post-</span>” used as a prefix
5743: for the main target's name. These targets are invoked before and
5744: after the main target is called, allowing extra configuration or
5745: installation steps be performed from a package's Makefile, for
5746: example, which a program's configure script
5747: or install target omitted.</p></dd>
5748: <dt><span class="term">do-*</span></dt>
5749: <dd><p>Should one of the main targets do the wrong thing, and should there
5750: be no variable to fix this, you can redefine it with the do-*
5751: target. (Note that redefining the target itself instead of the
5752: do-* target is a bad idea, as the pre-* and post-* targets won't be
5753: called anymore, etc.) You will not usually need to do this.</p></dd>
5754: <dt><span class="term">reinstall</span></dt>
5755: <dd><p>If you did a <span><strong class="command">make install</strong></span> and you noticed some file
5756: was not installed properly, you can repeat the installation with this
5757: target, which will ignore the “<span class="quote">already installed</span>” flag.</p></dd>
5758: <dt><span class="term">deinstall</span></dt>
5759: <dd>
5760: <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,
5761: effectively de-installing the package. The following variables can
5762: be used to tune the behaviour:</p>
5763: <div class="variablelist"><dl>
5764: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
5765: <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>
5766: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
5767: <dd><p>Remove all packages that require (depend on) the given package.
5768: This can be used to remove any packages that may have been pulled in
5769: by a given package, e.g. if <span><strong class="command">make deinstall
5770: DEINSTALLDEPENDS=1</strong></span> is done in
1.76 rillig 5771: <code class="filename">pkgsrc/x11/kde</code>, this is likely to remove whole
1.75 rillig 5772: 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>
5773: </dl></div>
5774: </dd>
5775: <dt><span class="term">update</span></dt>
5776: <dd>
5777: <p>This target causes the current package to be updated to the latest
5778: version. The package and all depending packages first get de-installed,
5779: then current versions of the corresponding packages get compiled and
5780: installed. This is similar to manually noting which packages are
5781: currently installed, then performing a series of <span><strong class="command">make
5782: deinstall</strong></span> and <span><strong class="command">make install</strong></span> (or whatever
5783: <code class="varname">UPDATE_TARGET</code> is set to) for these packages.</p>
5784: <p>You can use the “<span class="quote">update</span>” target to resume package
5785: updating in case a previous <span><strong class="command">make update</strong></span> was interrupted
5786: for some reason. However, in this case, make sure you don't call
5787: <span><strong class="command">make clean</strong></span> or otherwise remove the list of dependent
5788: packages in <code class="varname">WRKDIR</code>. Otherwise, you lose the
5789: ability to automatically update the current package along with the
5790: dependent packages you have installed.</p>
5791: <p>Resuming an interrupted <span><strong class="command">make update</strong></span> will only work as
5792: long as the package tree remains unchanged. If the source code for
5793: one of the packages to be updated has been changed, resuming
5794: <span><strong class="command">make update</strong></span> will most certainly fail!</p>
5795: <p>The following variables can be used either on the command line or in
1.76 rillig 5796: <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75 rillig 5797: <span><strong class="command">make update</strong></span>:</p>
5798: <div class="variablelist"><dl>
5799: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
5800: <dd><p>Install target to recursively use for the updated package and the
5801: dependent packages. Defaults to <code class="varname">DEPENDS_TARGET</code> if set,
5802: “<span class="quote">install</span>” otherwise for <span><strong class="command">make update</strong></span>.
5803: e.g. <span><strong class="command">make update UPDATE_TARGET=package</strong></span></p></dd>
5804: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
5805: <dd><p>Don't clean up after updating. Useful if you want to leave the
5806: work sources of the updated packages around for inspection or
5807: other purposes. Be sure you eventually clean up the source
5808: tree (see the “<span class="quote">clean-update</span>” target below) or you may
5809: run into troubles with old source code still lying around on your
5810: next <span><strong class="command">make</strong></span> or <span><strong class="command">make update</strong></span>.</p></dd>
5811: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
5812: <dd><p>Deinstall each package before installing (making
5813: <code class="varname">DEPENDS_TARGET</code>). This may be necessary if the
5814: “<span class="quote">clean-update</span>” target (see below) was called after
5815: interrupting a running <span><strong class="command">make update</strong></span>.</p></dd>
5816: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
5817: <dd><p>Allows you to disable recursion and hardcode the target for
5818: packages. The default is “<span class="quote">update</span>” for the update target,
5819: facilitating a recursive update of prerequisite packages.
5820: Only set <code class="varname">DEPENDS_TARGET</code> if you want to disable
5821: recursive updates. Use <code class="varname">UPDATE_TARGET</code> instead to just
5822: set a specific target for each package to be installed during
5823: <span><strong class="command">make update</strong></span> (see above).</p></dd>
5824: </dl></div>
5825: </dd>
5826: <dt><span class="term">clean-update</span></dt>
5827: <dd>
5828: <p>Clean the source tree for all packages that would get updated if
5829: <span><strong class="command">make update</strong></span> was called from the current directory.
5830: This target should not be used if the current package (or any of its
5831: depending packages) have already been de-installed (e.g., after calling
5832: <span><strong class="command">make update</strong></span>) or you may lose some packages you intended
5833: to update. As a rule of thumb: only use this target
5834: <span class="emphasis"><em>before</em></span> the first time you run
5835: <span><strong class="command">make update</strong></span> and only if you have a dirty package tree
5836: (e.g., if you used <code class="varname">NOCLEAN</code>).</p>
5837: <p>If you are unsure about whether your tree is clean, you can either
5838: perform a <span><strong class="command">make clean</strong></span> at the top of the tree, or use
5839: the following sequence of commands from the directory of the package
5840: you want to update (<span class="emphasis"><em>before</em></span> running
5841: <span><strong class="command">make update</strong></span> for the first time, otherwise you lose
5842: all the packages you wanted to update!):</p>
5843: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
5844: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
5845: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong></pre>
5846: <p>The following variables can be used either on the command line or in
1.76 rillig 5847: <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75 rillig 5848: <span><strong class="command">make clean-update</strong></span>:</p>
5849: <div class="variablelist"><dl>
5850: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
5851: <dd><p>After <span><strong class="command">make clean</strong></span>, do not reconstruct the list of
5852: directories to update for this package. Only use this if <span><strong class="command">make
5853: update</strong></span> successfully installed all packages you wanted to
5854: update. Normally, this is done automatically on <span><strong class="command">make
5855: update</strong></span>, but may have been suppressed by the
5856: <code class="varname">NOCLEAN</code> variable (see above).</p></dd>
5857: </dl></div>
5858: </dd>
5859: <dt><span class="term">info</span></dt>
5860: <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
5861: package. You can use this to check which version of a package is
5862: installed.</p></dd>
5863: <dt><span class="term">readme</span></dt>
1.76 rillig 5864: <dd><p>This target generates a <code class="filename">README.html</code> file, which
1.75 rillig 5865: can be viewed using a browser such as
1.76 rillig 5866: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/mozilla/README.html" target="_top"><code class="filename">www/mozilla</code></a> or
5867: <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 5868: The generated files contain references to any
5869: packages which are in the <code class="varname">PACKAGES</code> directory on
5870: the local host. The generated files can be made to refer to URLs based on
5871: <code class="varname">FTP_PKG_URL_HOST</code> and
5872: <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I wanted to generate
1.76 rillig 5873: <code class="filename">README.html</code> files which pointed to binary packages
1.75 rillig 5874: on the local machine, in the directory
1.76 rillig 5875: <code class="filename">/usr/packages</code>, set
1.75 rillig 5876: <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
5877: <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
5878: <code class="varname">${PACKAGES}</code> directory and its subdirectories will be
5879: searched for all the binary packages.</p></dd>
5880: <dt><span class="term">readme-all</span></dt>
1.76 rillig 5881: <dd><p>Use this target to create a file <code class="filename">README-all.html</code>
1.75 rillig 5882: which contains a list of all packages currently available in the NetBSD
5883: Packages Collection, together with the category they belong to and a
5884: short description. This file is compiled from the
1.76 rillig 5885: <code class="filename">pkgsrc/*/README.html</code> files, so be sure to run
1.75 rillig 5886: this <span class="emphasis"><em>after</em></span> a <span><strong class="command">make readme</strong></span>.</p></dd>
5887: <dt><span class="term">cdrom-readme</span></dt>
5888: <dd><p>This is very much the same as the “<span class="quote">readme</span>” target (see
5889: above), but is to be used when generating a pkgsrc tree to be written
5890: to a CD-ROM. This target also produces
1.76 rillig 5891: <code class="filename">README.html</code> files, and can be made to refer
1.75 rillig 5892: to URLs based on <code class="varname">CDROM_PKG_URL_HOST</code> and
5893: <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
5894: <dt><span class="term">show-distfiles</span></dt>
5895: <dd><p>This target shows which distfiles and patchfiles are needed to build
5896: the package. (<code class="varname">DISTFILES</code> and
1.76 rillig 5897: <code class="varname">PATCHFILES</code>, but not <code class="filename">patches/*</code>)</p></dd>
1.75 rillig 5898: <dt><span class="term">show-downlevel</span></dt>
5899: <dd><p>This target shows nothing if the package is not installed. If a version
5900: of this package is installed, but is not the version provided in this
5901: version of pkgsrc, then a warning message is displayed. This target can
5902: be used to show which of your installed packages are downlevel, and so
5903: the old versions can be deleted, and the current ones added.</p></dd>
5904: <dt><span class="term">show-pkgsrc-dir</span></dt>
5905: <dd><p>This target shows the directory in the pkgsrc hierarchy from which the
5906: package can be built and installed. This may not be the same directory
5907: as the one from which the package was installed. This target is intended
5908: to be used by people who may wish to upgrade many packages on a single
5909: host, and can be invoked from the top-level pkgsrc Makefile by using the
5910: “<span class="quote">show-host-specific-pkgs</span>” target.</p></dd>
5911: <dt><span class="term">show-installed-depends</span></dt>
5912: <dd><p>This target shows which installed packages match the current package's
5913: <code class="varname">DEPENDS</code>. Useful if out of date dependencies are
5914: causing build problems.</p></dd>
5915: <dt><span class="term">check-shlibs</span></dt>
5916: <dd><p>After a package is installed, check all its binaries and (on ELF
5917: platforms) shared libraries to see if they find the shared libs they need.
5918: Run by default if <code class="varname">PKG_DEVELOPER</code> is set in
1.76 rillig 5919: <code class="filename">/etc/mk.conf</code>.</p></dd>
1.75 rillig 5920: <dt><span class="term">print-PLIST</span></dt>
5921: <dd>
5922: <p>After a “<span class="quote">make install</span>” from a new or
5923: upgraded pkg, this prints out an attempt to generate a new
1.76 rillig 5924: <code class="filename">PLIST</code> from a <span><strong class="command">find -newer
1.75 rillig 5925: work/.extract_done</strong></span>. An attempt is made to care
5926: for shared libs etc., but it is
5927: <span class="emphasis"><em>strongly</em></span> recommended to review the
5928: result before putting it into
1.76 rillig 5929: <code class="filename">PLIST</code>. On upgrades, it's useful to
1.75 rillig 5930: diff the output of this command against an already
1.76 rillig 5931: existing <code class="filename">PLIST</code> file.</p>
1.75 rillig 5932: <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
5933: methods that don't update file access times, be sure to
5934: add these files manually to your
1.76 rillig 5935: <code class="filename">PLIST</code>, as the “<span class="quote">find
1.75 rillig 5936: -newer</span>” command used by this target won't catch
5937: them!</p>
1.77 rillig 5938: <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 5939: information on this target.</p>
5940: </dd>
5941: <dt><span class="term">bulk-package</span></dt>
5942: <dd>
5943: <p>Used to do bulk builds. If an appropriate binary package already exists,
5944: no action is taken. If not, this target will compile, install and
5945: package it (and its depends, if <code class="varname">PKG_DEPENDS</code> is
5946: set properly. See <a href="#binary.configuration" title="6.3.1. Configuration">Section 6.3.1, “Configuration”</a>).
5947: After creating the binary
5948: package, the sources, the just-installed package and its required
5949: packages are removed, preserving free disk space.</p>
5950: <p><span class="emphasis"><em>Beware that this target may deinstall all
5951: packages installed on a system!</em></span></p>
5952: </dd>
5953: <dt><span class="term">bulk-install</span></dt>
5954: <dd>
5955: <p>Used during bulk-installs to install required packages. If an
5956: up-to-date binary package is available, it will be installed via
5957: <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,
5958: but the installed binary won't be removed. </p>
5959: <p> A binary package is considered “<span class="quote">up-to-date</span>” to be
5960: 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>
5961: <div class="itemizedlist"><ul type="disc">
1.76 rillig 5962: <li><p>None of the package's files (<code class="filename">Makefile</code>,
1.75 rillig 5963: ...) were modified since it was built.</p></li>
5964: <li><p>None of the package's required (binary) packages were
5965: modified since it was built.</p></li>
5966: </ul></div>
5967: <p><span class="emphasis"><em>Beware that this target may deinstall all
5968: packages installed on a system!</em></span></p>
5969: </dd>
5970: </dl></div>
5971: </div>
5972: </div>
5973: <div class="chapter" lang="en">
5974: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5975: <a name="tools"></a>Chapter 16. Tools needed for building or running</h2></div></div></div>
1.75 rillig 5976: <div class="toc">
5977: <p><b>Table of Contents</b></p>
5978: <dl>
1.77 rillig 5979: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
5980: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
5981: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
1.75 rillig 5982: </dl>
5983: </div>
5984: <p>
5985: The <code class="varname">USE_TOOLS</code> definition is used both internally
5986: by pkgsrc and also for individual packages to define what commands
5987: are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
5988: or for later run-time of an installed packaged (such as
5989: <code class="varname">DEPENDS</code>).
5990: If the native system provides an adequate tool, then in many cases, a pkgsrc
5991: package will not be used.
5992: </p>
5993: <p>
5994: When building a package, the replacement tools are
5995: made available in a directory (as symlinks or wrapper scripts)
5996: that is early in the executable search path. Just like the buildlink
5997: system, this helps with consistent builds.
5998: </p>
5999: <p>
6000: A tool may be needed to help build a specific package. For example,
6001: perl, GNU make (gmake) or yacc may be needed.
6002: </p>
6003: <p>
6004: Also a tool may be needed, for example, because the native system's supplied
6005: tool may be inefficient for building a package with pkgsrc.
6006: For example, a package may need GNU awk, bison (instead of
6007: yacc) or a better sed.
6008: </p>
6009: <p>
6010: The tools used by a package can be listed by running
6011: <span><strong class="command">make show-tools</strong></span>.
6012: </p>
6013: <div class="sect1" lang="en">
6014: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6015: <a name="pkgsrc-tools"></a>16.1. Tools for pkgsrc builds</h2></div></div></div>
1.75 rillig 6016: <p>
6017: The default set of tools used by pkgsrc is defined in
1.76 rillig 6018: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.75 rillig 6019: such as: <span><strong class="command">cat</strong></span>, <span><strong class="command">awk</strong></span>,
6020: <span><strong class="command">chmod</strong></span>, <span><strong class="command">test</strong></span>, and so on.
6021: These can be seen by running:
6022: <span><strong class="command">make show-var VARNAME=USE_TOOLS</strong></span>.
6023: </p>
6024: <p>
6025: If a package needs a specific program to build
6026: then the <code class="varname">USE_TOOLS</code> variable can be used
6027: to define the tools needed.
6028: </p>
6029: </div>
6030: <div class="sect1" lang="en">
6031: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6032: <a name="package-tools"></a>16.2. Tools needed by packages</h2></div></div></div>
1.75 rillig 6033: <p>
6034: In the following examples, the :pkgsrc means to use the pkgsrc version
6035: and not the native version for a build dependency.
6036: And the :run means that it is used for a
6037: run-time dependencies also (and becomes a DEPENDS).
6038: The default is a build dependency which can be set with
6039: :build. (So in this example, it is the same as gmake:build
6040: and pkg-config:build.)
6041: </p>
6042: <pre class="programlisting">
6043: USE_TOOLS+= mktemp:pkgsrc
6044: USE_TOOLS+= gmake perl:run pkg-config
6045: </pre>
6046: <p>
6047: When using the tools framework, a
6048: <code class="varname">TOOLS_PATH.foo</code> variable is defined
6049: which contains the full path to the appropriate tool. For example,
6050: <code class="varname">TOOLS_PATH.bash</code> could be “<span class="quote">/bin/bash</span>”
6051: on Linux systems.
6052: </p>
6053: <p>
6054: If you always need a pkgsrc version of the
6055: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
6056:
6057: </p>
6058: </div>
6059: <div class="sect1" lang="en">
6060: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6061: <a name="platform-tools"></a>16.3. Tools provided by platforms</h2></div></div></div>
1.75 rillig 6062: <p>
6063: When improving or porting pkgsrc to a new platform, have a look
6064: at (or create) the corresponding platform specific make file fragment under
1.76 rillig 6065: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
1.75 rillig 6066: the name of the common tools. For example:</p>
6067: <pre class="programlisting">
6068: .if exists(/usr/bin/bzcat)
6069: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
6070: .elif exists(/usr/bin/bzip2)
6071: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
6072: .endif
1.69 rillig 6073:
1.75 rillig 6074: TOOLS_PLATFORM.true?= true # shell builtin
6075: </pre>
6076: </div>
6077: </div>
6078: <div class="chapter" lang="en">
6079: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 6080: <a name="fixes"></a>Chapter 17. Making your package work</h2></div></div></div>
1.75 rillig 6081: <div class="toc">
6082: <p><b>Table of Contents</b></p>
6083: <dl>
1.77 rillig 6084: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
1.75 rillig 6085: <dd><dl>
1.78 rillig 6086: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
6087: <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>
6088: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
6089: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
6090: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
6091: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
6092: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
6093: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
6094: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
6095: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
6096: <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 6097: <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 6098: </dl></dd>
6099: <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>
6100: <dd><dl>
6101: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
6102: <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>
6103: </dl></dd>
6104: <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>
6105: <dd><dl>
6106: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
6107: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
6108: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
6109: </dl></dd>
6110: <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>
6111: <dd><dl>
1.78 rillig 6112: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
6113: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
6114: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
6115: </dl></dd>
6116: <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>
6117: <dd><dl>
6118: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
6119: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
6120: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
6121: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
6122: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
6123: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
6124: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
6125: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
6126: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
6127: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
6128: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
6129: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
6130: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
6131: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
6132: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
6133: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
6134: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.75 rillig 6135: </dl></dd>
1.78 rillig 6136: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.75 rillig 6137: </dl>
6138: </div>
6139: <div class="sect1" lang="en">
6140: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6141: <a name="general-operation"></a>17.1. General operation</h2></div></div></div>
1.75 rillig 6142: <div class="sect2" lang="en">
6143: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6144: <a name="portability-of-packages"></a>17.1.1. Portability of packages</h3></div></div></div>
6145: <p>One appealing feature of pkgsrc is that it runs on many
6146: different platforms. As a result, it is important to ensure,
6147: where possible, that packages in pkgsrc are portable. This
6148: chapter mentions some particular details you should pay
6149: attention to while working on pkgsrc.</p>
6150: </div>
6151: <div class="sect2" lang="en">
6152: <div class="titlepage"><div><div><h3 class="title">
6153: <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>
6154: <p>The pkgsrc user can configure pkgsrc by overriding several
6155: variables in the file pointed to by <code class="varname">MAKECONF</code>,
6156: which is <code class="filename">/etc/mk.conf</code> by default. When you
6157: want to use those variables in the preprocessor directives of
6158: <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
6159: <code class="literal">.for</code>), you need to include the file
6160: <code class="filename">../../mk/bsd.prefs.mk</code> before, which in turn
6161: loads the user preferences.</p>
6162: <p>But note that some variables may not be completely defined
6163: after <code class="filename">../../mk/bsd.prefs.mk</code> has been
6164: included, as they may contain references to variables that are
6165: not yet defined. In shell commands this is no problem, since
6166: variables are actually macros, which are only expanded when they
6167: are used. But in the preprocessor directives mentioned above and
6168: in dependency lines (of the form <code class="literal">target:
6169: dependencies</code>) the variables are expanded at load
6170: time.</p>
6171: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
6172: <h3 class="title">Note</h3>
6173: <p>Currently there is no exhaustive list of all
6174: variables that tells you whether they can be used at load time
6175: or only at run time, but it is in preparation.</p>
6176: </div>
6177: </div>
6178: <div class="sect2" lang="en">
6179: <div class="titlepage"><div><div><h3 class="title">
6180: <a name="user-interaction"></a>17.1.3. User interaction</h3></div></div></div>
6181: <p>Occasionally, packages require interaction from the user, and this can be
6182: in a number of ways:</p>
6183: <div class="itemizedlist"><ul type="disc">
1.79 rillig 6184: <li><p>When fetching the distfiles, some packages require user
6185: interaction such as entering username/password or accepting a
6186: license on a web page.</p></li>
1.78 rillig 6187: <li><p>When extracting the distfiles, some packages may ask for passwords.</p></li>
6188: <li><p>help to configure the package before it is built</p></li>
6189: <li><p>help during the build process</p></li>
6190: <li><p>help during the installation of a package</p></li>
6191: </ul></div>
6192: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is provided to notify
6193: the pkgsrc mechanism of an interactive stage which will be needed, and
6194: this should be set in the package's <code class="filename">Makefile</code>, e.g.:</p>
1.75 rillig 6195: <pre class="programlisting">
1.78 rillig 6196: INTERACTIVE_STAGE= build
1.75 rillig 6197: </pre>
1.78 rillig 6198: <p>Multiple interactive stages can be specified:</p>
1.75 rillig 6199: <pre class="programlisting">
1.78 rillig 6200: INTERACTIVE_STAGE= configure install
1.75 rillig 6201: </pre>
6202: </div>
6203: <div class="sect2" lang="en">
6204: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6205: <a name="handling-licenses"></a>17.1.4. Handling licenses</h3></div></div></div>
6206: <p>A package may be covered by a license which the user has
6207: or has not agreed to accept. For these cases, pkgsrc contains
6208: a mechanism to note that a package is covered by a particular
6209: license, and the package cannot be built unless the user has
6210: accepted the license. (Installation of binary packages are
6211: not currently subject to this mechanism.) Packages with
6212: licenses that are either Open Source according to the Open
6213: Source Initiative or Free according to the Free Software
6214: Foundation will not be marked with a license tag. Packages
6215: with licenses that have not been determined to meet either
6216: definition will be marked with a license tag referring to the
6217: license. This will prevent building unless pkgsrc is informed
6218: that the license is acceptable, and enables displaying the
6219: license.</p>
6220: <p>The license tag mechanism is intended to address
6221: copyright-related issues surrounding building, installing and
6222: using a package, and not to address redistribution issues (see
6223: <code class="varname">RESTRICTED</code> and
6224: <code class="varname">NO_SRC_ON_FTP</code>, etc.). However, the above
6225: definition of licenses for which tags are not needed implies
6226: that packages with redistribution restrictions should have
6227: tags.</p>
6228: <p>
6229: Denoting that a package is covered by a particular license is
6230: done by placing the license in
6231: <code class="filename">pkgsrc/licenses</code> and setting the
6232: <code class="varname">LICENSE</code> variable to a string identifying
6233: the license, e.g. in
6234: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>: </p>
6235: <pre class="programlisting">
6236: LICENSE= xv-license
6237: </pre>
6238: <p>
6239: When trying to build, the user will get a notice that the
6240: package is covered by a license which has not been
6241: accepted:</p>
6242: <pre class="programlisting">
6243: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
6244: ===> xv-3.10anb9 has an unacceptable license: xv-license.
6245: ===> To view the license, enter "/usr/bin/make show-license".
6246: ===> To indicate acceptance, add this line to your /etc/mk.conf:
6247: ===> ACCEPTABLE_LICENSES+=xv-license
6248: *** Error code 1
6249: </pre>
6250: <p>The license can be viewed with <span><strong class="command">make
6251: show-license</strong></span>, and if it is considered appropriate,
6252: the line printed above can be added to
6253: <code class="filename">/etc/mk.conf</code> to indicate acceptance of
6254: the particular license:</p>
6255: <pre class="programlisting">
6256: ACCEPTABLE_LICENSES+=xv-license
6257: </pre>
6258: <p>When adding a package with a new license, the license
6259: text should be added to <code class="filename">pkgsrc/licenses</code>
6260: for displaying. A list of known licenses can be seen in this
6261: directory as well as by looking at the list of (commented
6262: out) <code class="varname">ACCEPTABLE_LICENSES</code> variable
6263: settings in
6264: <code class="filename">pkgsrc/mk/defaults/mk.conf</code>.</p>
6265: <p>The use of <code class="varname">LICENSE=shareware</code>,
6266: <code class="varname">LICENSE=no-commercial-use</code>, and similar
6267: language is deprecated because it does not crisply refer to
6268: a particular license text. Another problem with such usage
6269: is that it does not enable a user to denote acceptance of
6270: the license for a single package without accepting the same
6271: license text for another package. In particular, this can
6272: be inappropriate when e.g. one accepts a particular license to
6273: indicate to pkgsrc that a fee has been paid.</p>
1.75 rillig 6274: </div>
6275: <div class="sect2" lang="en">
6276: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6277: <a name="restricted-packages"></a>17.1.5. Restricted packages</h3></div></div></div>
1.75 rillig 6278: <p>Some licenses restrict how software may be re-distributed.
6279: In order to satisfy these restrictions, the package system
6280: defines five make variables that can be set to note these
6281: restrictions:</p>
6282: <div class="itemizedlist"><ul type="disc">
6283: <li>
6284: <p><code class="varname">RESTRICTED</code></p>
6285: <p>This variable should be set whenever a restriction
6286: exists (regardless of its kind). Set this variable to a
6287: string containing the reason for the restriction.</p>
6288: </li>
6289: <li>
6290: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
6291: <p>Binaries may not be placed on CD-ROM. Set this
6292: variable to <code class="varname">${RESTRICTED}</code> whenever a
6293: binary package may not be included on a CD-ROM.</p>
6294: </li>
6295: <li>
6296: <p><code class="varname">NO_BIN_ON_FTP</code></p>
6297: <p>Binaries may not be placed on an FTP server. Set
6298: this variable to <code class="varname">${RESTRICTED}</code>
6299: whenever a binary package may not not be made available
6300: on the Internet.</p>
6301: </li>
6302: <li>
6303: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
6304: <p>Distfiles may not be placed on CD-ROM. Set this
6305: variable to <code class="varname">${RESTRICTED}</code> if
6306: re-distribution of the source code or other distfile(s) is
6307: not allowed on CD-ROMs.</p>
6308: </li>
6309: <li>
6310: <p><code class="varname">NO_SRC_ON_FTP</code></p>
6311: <p>Distfiles may not be placed on FTP. Set this variable
6312: to <code class="varname">${RESTRICTED}</code> if re-distribution of
6313: the source code or other distfile(s) via the Internet is not
6314: allowed.</p>
6315: </li>
6316: </ul></div>
6317: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
6318: <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
6319: generic make variables to denote restrictions is deprecated,
6320: because they unconditionally prevent users from generating
6321: binary packages!</p>
6322: </div>
6323: <div class="sect2" lang="en">
6324: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6325: <a name="dependencies"></a>17.1.6. Handling dependencies</h3></div></div></div>
1.75 rillig 6326: <p>Your package may depend on some other package being present
6327: - and there are various ways of expressing this
6328: dependency. pkgsrc supports the <code class="varname">BUILD_DEPENDS</code>
6329: and <code class="varname">DEPENDS</code> definitions, the
6330: <code class="varname">USE_TOOLS</code> definition, as well as
1.76 rillig 6331: dependencies via <code class="filename">buildlink3.mk</code>, which is
1.75 rillig 6332: the preferred way to handle dependencies, and which uses the
1.77 rillig 6333: variables named above. See <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a> for more
1.75 rillig 6334: information.</p>
6335: <p>The basic difference between the two variables is as
6336: follows: The <code class="varname">DEPENDS</code> definition registers
6337: that pre-requisite in the binary package so it will be pulled in
6338: when the binary package is later installed, whilst the
6339: <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
6340: dependency that is only needed for building the package.
6341: </p>
6342: <p>This means that if you only need a package present whilst
6343: you are building, it should be noted as a
6344: <code class="varname">BUILD_DEPENDS</code>.</p>
6345: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
6346: <code class="varname">DEPENDS</code> definition is:</p>
6347: <pre class="programlisting">
6348: <pre-req-package-name>:../../<category>/<pre-req-package>
6349: </pre>
6350: <p>Please note that the “<span class="quote">pre-req-package-name</span>”
6351: may include any of the wildcard version numbers recognized by
6352: <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>
6353: <div class="orderedlist"><ol type="1">
6354: <li>
6355: <p>If your package needs another package's binaries or
6356: libraries to build or run, and if that package has a
1.76 rillig 6357: <code class="filename">buildlink3.mk</code> file available, use it:
1.75 rillig 6358: </p>
6359: <pre class="programlisting">
6360: .include "../../graphics/jpeg/buildlink3.mk"
6361: </pre>
6362: </li>
6363: <li>
6364: <p>If your package needs to use another package to build
1.76 rillig 6365: itself and there is no <code class="filename">buildlink3.mk</code>
1.75 rillig 6366: file available, use the <code class="varname">BUILD_DEPENDS</code>
6367: definition:</p>
6368: <pre class="programlisting">
6369: BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
6370: </pre>
6371: </li>
6372: <li>
6373: <p>If your package needs a library with which to link and
1.76 rillig 6374: again there is no <code class="filename">buildlink3.mk</code> file
1.75 rillig 6375: available, this is specified using the
6376: <code class="varname">DEPENDS</code> definition. For example:</p>
6377: <pre class="programlisting">
6378: DEPENDS+= xpm-3.4j:../../graphics/xpm
6379: </pre>
6380: <p>You can also use wildcards in package dependences:</p>
6381: <pre class="programlisting">
6382: DEPENDS+= xpm-[0-9]*:../../graphics/xpm
6383: </pre>
6384: <p>Note that such wildcard dependencies are retained when
6385: creating binary packages. The dependency is checked when
6386: installing the binary package and any package which matches
6387: the pattern will be used. Wildcard dependencies should be
6388: used with care.</p>
6389: <p>The “<span class="quote">-[0-9]*</span>” should be used instead of
6390: “<span class="quote">-*</span>” to avoid potentially ambiguous matches
6391: such as “<span class="quote">tk-postgresql</span>” matching a
6392: “<span class="quote">tk-*</span>” <code class="varname">DEPENDS</code>.</p>
6393: <p>Wildcards can also be used to specify that a package
6394: will only build against a certain minimum version of a
6395: pre-requisite:</p>
6396: <pre class="programlisting">
6397: DEPENDS+= tiff>=3.5.4:../../graphics/tiff
6398: </pre>
6399: <p>This means that the package will build against version
6400: 3.5.4 of the tiff library or newer. Such a dependency may
6401: be warranted if, for example, the API of the library has
6402: changed with version 3.5.4 and a package would not compile
6403: against an earlier version of tiff.</p>
6404: <p>Please note that such dependencies should only be
6405: updated if a package requires a newer pre-requisite, but
6406: not to denote recommendations such as
6407: ABI changes that do not prevent a package from building
6408: correctly. Such recommendations can be expressed using
6409: <code class="varname">ABI_DEPENDS</code>:</p>
6410: <pre class="programlisting">
6411: ABI_DEPENDS+= tiff>=3.6.1:../../graphics/tiff
6412: </pre>
6413: <p>In addition to the above <code class="varname">DEPENDS</code>
6414: line, this denotes that while a package will build against
6415: tiff>=3.5.4, at least version 3.6.1 is recommended.
6416: <code class="varname">ABI_DEPENDS</code> entries will be turned into
6417: dependencies unless explicitly ignored (in which case a
6418: warning will be printed).</p>
6419: <p>To ignore these ABI dependency recommendations and just
6420: use the required <code class="varname">DEPENDS</code>, set
6421: <code class="varname">USE_ABI_DEPENDS=NO</code>. This may make
6422: it easier and faster to update packages built using pkgsrc,
6423: since older compatible dependencies can continue to be
6424: used. This is useful for people who watch their rebuilds
6425: very carefully; it is not very good as a general-purpose
6426: hammer. If you use it, you need to be mindful of possible
6427: ABI changes, including those from the underlying OS.
6428: </p>
6429: <p>Packages that are built with recommendations ignored
6430: may not be uploaded to ftp.NetBSD.org by developers and
6431: should not be used across different systems that may have
6432: different versions of binary packages installed.</p>
6433: <p>For security fixes, please update the package
1.78 rillig 6434: 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 6435: information.</p>
6436: </li>
6437: <li>
6438: <p>If your package needs some executable to be able to run
6439: correctly and if there's no
1.76 rillig 6440: <code class="filename">buildlink3.mk</code> file, this is specified
1.75 rillig 6441: using the <code class="varname">DEPENDS</code> variable. The
1.76 rillig 6442: <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 6443: be able to execute the latex binary from the teTeX package
6444: when it runs, and that is specified:</p>
6445: <pre class="programlisting">
6446: DEPENDS+= teTeX-[0-9]*:../../print/teTeX
6447: </pre>
6448: <p>The comment about wildcard dependencies from previous
6449: paragraph applies here, too.</p>
6450: </li>
6451: </ol></div>
6452: <p>If your package needs files from another package to build,
6453: add the relevant distribution files to
6454: <code class="varname">DISTFILES</code>, so they will be extracted
1.76 rillig 6455: 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 6456: (It relies on the jpeg sources being present in source form
6457: during the build.)</p>
6458: <p>Please also note the <code class="varname">BUILD_USES_MSGFMT</code>
6459: and <code class="varname">BUILD_USES_GETTEXT_M4</code> definitions, which
6460: are provided as convenience definitions. The former works out
6461: 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 6462: 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 6463: The latter adds a build dependency on either an installed
6464: version of an older gettext package, or if it isn't, installs the
1.76 rillig 6465: <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 6466: </div>
6467: <div class="sect2" lang="en">
6468: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6469: <a name="conflicts"></a>17.1.7. Handling conflicts with other packages</h3></div></div></div>
1.75 rillig 6470: <p>Your package may conflict with other packages a user might
6471: already have installed on his system, e.g. if your package
6472: installs the same set of files like another package in our
6473: pkgsrc tree.</p>
6474: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
6475: space-separated list of packages (including version string) your
6476: package conflicts with.</p>
1.76 rillig 6477: <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>
6478: 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 6479: install the same shared library, thus you set in
1.76 rillig 6480: <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
1.75 rillig 6481: <pre class="programlisting">
6482: CONFLICTS= Xaw-Xpm-[0-9]*
6483: </pre>
1.76 rillig 6484: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:
1.75 rillig 6485: </p>
6486: <pre class="programlisting">
6487: CONFLICTS= Xaw3d-[0-9]*
6488: </pre>
6489: <p>Packages will automatically conflict with other packages
6490: with the name prefix and a different version
6491: string. “<span class="quote">Xaw3d-1.5</span>” e.g. will automatically
6492: conflict with the older version “<span class="quote">Xaw3d-1.3</span>”.
6493: </p>
6494: </div>
6495: <div class="sect2" lang="en">
6496: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6497: <a name="not-building-packages"></a>17.1.8. Packages that cannot or should not be built</h3></div></div></div>
1.75 rillig 6498: <p>There are several reasons why a package might be
6499: instructed to not build under certain circumstances. If the
6500: package builds and runs on most platforms, the exceptions
6501: should be noted with <code class="varname">NOT_FOR_PLATFORM</code>. If
6502: the package builds and runs on a small handful of platforms,
6503: set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
6504: Both <code class="varname">ONLY_FOR_PLATFORM</code> and
6505: <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
6506: (OS-version-platform) that can use glob-style
6507: wildcards.</p>
6508: <p>If the package should be skipped (for example, because it
6509: provides functionality already provided by the system), set
6510: <code class="varname">PKG_SKIP_REASON</code> to a descriptive message.
6511: If the package should fail because some preconditions are not
6512: met, set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
6513: message.</p>
6514: </div>
6515: <div class="sect2" lang="en">
6516: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6517: <a name="undeletable-packages"></a>17.1.9. Packages which should not be deleted, once installed</h3></div></div></div>
1.75 rillig 6518: <p>To ensure that a package may not be deleted, once it has been
6519: installed, the <code class="varname">PKG_PRESERVE</code> definition should
6520: be set in the package Makefile. This will be carried into any
6521: binary package that is made from this pkgsrc entry. A
6522: “<span class="quote">preserved</span>” package will
6523: 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
6524: “<span class="quote">-f</span>” option is used.</p>
6525: </div>
6526: <div class="sect2" lang="en">
6527: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6528: <a name="security-handling"></a>17.1.10. Handling packages with security problems</h3></div></div></div>
1.75 rillig 6529: <p>When a vulnerability is found, this should be noted in
1.76 rillig 6530: <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
1.75 rillig 6531: and after committing that file, use <span><strong class="command">make upload</strong></span>
6532: in the same directory to update the file on ftp.NetBSD.org.</p>
6533: <p>After fixing the vulnerability by a patch, its
6534: <code class="varname">PKGREVISION</code> should be increased (this
6535: is of course not necessary if the problem is fixed by using
6536: a newer release of the software).</p>
6537: <p>Also, if the fix should be applied to the stable pkgsrc
6538: branch, be sure to submit a pullup request!</p>
6539: <p>Binary packages already on ftp.NetBSD.org will be handled
6540: semi-automatically by a weekly cron job.</p>
6541: </div>
6542: <div class="sect2" lang="en">
6543: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6544: <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 6545: <p>When making fixes to an existing package it can be useful
6546: to change the version number in <code class="varname">PKGNAME</code>. To
6547: avoid conflicting with future versions by the original author, a
6548: “<span class="quote">nb1</span>”, “<span class="quote">nb2</span>”, ... suffix can be used
6549: on package versions by setting <code class="varname">PKGREVISION=1</code>
6550: (2, ...). The “<span class="quote">nb</span>” is treated like a
6551: “<span class="quote">.</span>” by the pkg tools. e.g.</p>
6552: <pre class="programlisting">
6553: DISTNAME= foo-17.42
6554: PKGREVISION= 9
6555: </pre>
6556: <p>will result in a <code class="varname">PKGNAME</code> of
6557: “<span class="quote">foo-17.42nb9</span>”.</p>
6558: <p>When a new release of the package is released, the
6559: <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
6560: minor release of the above package, things should be like:</p>
6561: <pre class="programlisting">
6562: DISTNAME= foo-17.43
6563: </pre>
1.78 rillig 6564: <p>PKGREVISION should be incremented for any non-trivial change in the
6565: resulting binary package. Without a PKGREVISION bump, someone with
6566: the previous version installed has no way of knowing that their
6567: package is out of date. Thus, changes without increasing PKGREVISION
6568: are essentially labeled "this is so trivial that no reasonable person
6569: would want to upgrade", and this is the rough test for when increasing
6570: PKGREVISION is appropriate. Examples of changes that do not merit
6571: increasing PKGREVISION are:</p>
6572: <pre class="programlisting">
6573: Changing HOMEPAGE, MAINTAINER, or comments in Makefile.
6574: Changing build variables if the resulting binary package is the same.
6575: Changing DESCR.
6576: Adding PKG_OPTIONS if the default options don't change.
6577: </pre>
6578: <p>Examples of changes that do merit an increase to PKGREVISION
6579: include:</p>
6580: <pre class="programlisting">
6581: Security fixes
6582: Changes or additions to a patch file
6583: Changes to the PLIST
1.75 rillig 6584: </pre>
1.78 rillig 6585: <p>PKGREVISION must also be incremented when dependencies have ABI
6586: changes.</p>
1.75 rillig 6587: </div>
1.79 rillig 6588: <div class="sect2" lang="en">
6589: <div class="titlepage"><div><div><h3 class="title">
6590: <a name="fixes.subst"></a>17.1.12. Substituting variable text in the package files (the SUBST framework)</h3></div></div></div>
6591: <p>When you want to replace the same text in multiple files
6592: or when the replacement text varies, patches alone cannot help.
6593: This is where the SUBST framework comes in. It provides an
6594: easy-to-use interface for replacing text in files.
6595: Example:</p>
6596: <pre class="programlisting">
6597: SUBST_CLASSES+= fix-paths
6598: SUBST_STAGE.fix-paths= pre-configure
6599: SUBST_MESSAGE.fix-paths= Fixing absolute paths.
6600: SUBST_FILES.fix-paths= src/*.c
6601: SUBST_FILES.fix-paths+= scripts/*.sh
6602: SUBST_SED.fix-paths= -e 's,"/usr/local,"${PREFIX},g'
6603: SUBST_SED.fix-paths+= -e 's,"/var/log,"${VARBASE}/log,g'
6604: </pre>
6605: <p><code class="varname">SUBST_CLASSES</code> is a list of identifiers
6606: that are used to identify the different SUBST blocks that are
6607: defined. The SUBST framework is heavily used by pkgsrc, so it is
6608: important to always use the <code class="literal">+=</code> operator with
6609: this variable. Otherwise some substitutions may be
6610: skipped.</p>
6611: <p>The remaining variables of each SUBST block are
6612: parameterized with the identifier from the first line
6613: (<code class="literal">fix-paths</code> in this case.) They can be seen as
6614: parameters to a function call.</p>
6615: <p><code class="varname">SUBST_STAGE.*</code> specifies the stage at
6616: which the replacement will take place. All combinations of
6617: <code class="literal">pre-</code>, <code class="literal">do-</code> and
6618: <code class="literal">post-</code> together with a phase name are
6619: possible, though only few are actually used. Most commonly used
6620: are <code class="literal">post-patch</code> and
6621: <code class="literal">pre-configure</code>. Of these two,
6622: <code class="literal">pre-configure</code> should be preferred because
6623: then it is possible to run <span><strong class="command">bmake patch</strong></span> and
6624: have the state after applying the patches but before making any
6625: other changes. This is especially useful when you are debugging
6626: a package in order to create new patches for it. Similarly,
6627: <code class="literal">post-build</code> is preferred over
6628: <code class="literal">pre-install</code>, because the install phase should
6629: generally be kept as simple as possible. When you use
6630: <code class="literal">post-build</code>, you have the same files in the
6631: working directory that will be installed later, so you can check
6632: if the substitution has succeeded.</p>
6633: <p><code class="varname">SUBST_MESSAGE.*</code> is an optional text
6634: that is printed just before the substitution is done.</p>
6635: <p><code class="varname">SUBST_FILES.*</code> is the list of shell
6636: globbing patterns that specifies the files in which the
6637: substitution will take place. The patterns are interpreted
6638: relatively to the <code class="varname">WRKSRC</code> directory.</p>
6639: <p><code class="varname">SUBST_SED.*</code> is a list of arguments to
6640: <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
6641: command should be prefixed with <code class="literal">-e</code>, so that
6642: all SUBST blocks look uniform.</p>
6643: <p>There are some more variables, but they are so seldomly
6644: used that they are only documented in the
1.80 rillig 6645: <code class="filename">mk/subst.mk</code> file.</p>
1.79 rillig 6646: </div>
1.75 rillig 6647: </div>
6648: <div class="sect1" lang="en">
6649: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6650: <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 6651: <div class="sect2" lang="en">
6652: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6653: <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 6654: <p>If you need to download from a dynamic URL you can set
6655: <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span><strong class="command">make
1.76 rillig 6656: fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
1.75 rillig 6657: with the name of each file to download as an argument, expecting
6658: it to output the URL of the directory from which to download
1.76 rillig 6659: 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 6660: example of this usage.</p>
1.75 rillig 6661: <p>If the download can't be automated, because the user must
6662: submit personal information to apply for a password, or must pay
6663: for the source, or whatever, you can set
6664: <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
6665: displayed to the user before aborting the build. Example:</p>
6666: <pre class="programlisting">
6667: FETCH_MESSAGE= "Please download the files"
6668: FETCH_MESSAGE+= " "${DISTFILES:Q}
6669: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
6670: </pre>
6671: </div>
6672: <div class="sect2" lang="en">
6673: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6674: <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 6675: <p>Sometimes authors of a software package make some
6676: modifications after the software was released, and they put up a
6677: new distfile without changing the package's version number. If a
6678: package is already in pkgsrc at that time, the checksum will
6679: no longer match. The contents of the new distfile should be
6680: compared against the old one before changing anything, to make
6681: sure the distfile was really updated on purpose, and that
6682: no trojan horse or so crept in.
6683: Then, the correct way to work around this is to
6684: set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
6685: usually based on <code class="varname">PKGNAME_NOREV</code>. In case this
6686: happens more often, <code class="varname">PKGNAME</code> can be used (thus
1.76 rillig 6687: including the <code class="filename">nbX</code> suffix) or a date stamp
1.75 rillig 6688: can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
1.76 rillig 6689: Do not forget regenerating the <code class="filename">distinfo</code> file
1.75 rillig 6690: after that, since it contains the <code class="varname">DIST_SUBDIR</code>
6691: path in the filenames.
6692: Furthermore, a mail to the package's authors seems appropriate
6693: telling them that changing distfiles after releases without
6694: changing the file names is not good practice.</p>
6695: </div>
6696: </div>
6697: <div class="sect1" lang="en">
6698: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6699: <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 6700: <div class="sect2" lang="en">
6701: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6702: <a name="fixes.libtool"></a>17.3.1. Shared libraries - libtool</h3></div></div></div>
1.75 rillig 6703: <p>pkgsrc supports many different machines, with different
6704: object formats like a.out and ELF, and varying abilities to do
6705: shared library and dynamic loading at all. To accompany this,
6706: varying commands and options have to be passed to the
6707: compiler, linker, etc. to get the Right Thing, which can be
6708: pretty annoying especially if you don't have all the machines
6709: at your hand to test things. The
1.76 rillig 6710: <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 6711: can help here, as it just “<span class="quote">knows</span>” how to build
6712: both static and dynamic libraries from a set of source files,
6713: thus being platform-independent.</p>
6714: <p>Here's how to use libtool in a pkg in seven simple
6715: steps:</p>
6716: <div class="orderedlist"><ol type="1">
6717: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
6718: Makefile.</p></li>
6719: <li><p>For library objects, use “<span class="quote">${LIBTOOL} --mode=compile
6720: ${CC}</span>” in place of “<span class="quote">${CC}</span>”. You could even
6721: add it to the definition of <code class="varname">CC</code>, if only
6722: libraries are being built in a given Makefile. This one command
6723: will build both PIC and non-PIC library objects, so you need not
6724: have separate shared and non-shared library rules.</p></li>
6725: <li>
6726: <p>For the linking of the library, remove any
6727: “<span class="quote">ar</span>”, “<span class="quote">ranlib</span>”, and “<span class="quote">ld
6728: -Bshareable</span>” commands, and instead use:</p>
6729: <pre class="programlisting">
6730: ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
6731: -rpath ${PREFIX}/lib -version-info major:minor
6732: </pre>
6733: <p>Note that the library is changed to have a
1.76 rillig 6734: <code class="filename">.la</code> extension, and the objects are
6735: changed to have a <code class="filename">.lo</code>
1.75 rillig 6736: extension. Change <code class="varname">OBJS</code> as
6737: necessary. This automatically creates all of the
1.76 rillig 6738: <code class="filename">.a</code>,
6739: <code class="filename">.so.major.minor</code>, and ELF symlinks (if
1.75 rillig 6740: necessary) in the build directory. Be sure to include
6741: “<span class="quote">-version-info</span>”, especially when major and
6742: minor are zero, as libtool will otherwise strip off the
6743: shared library version.</p>
6744: <p>From the libtool manual:</p>
6745: <pre class="programlisting">
6746: So, libtool library versions are described by three integers:
1.69 rillig 6747:
1.75 rillig 6748: CURRENT
6749: The most recent interface number that this library implements.
1.69 rillig 6750:
1.75 rillig 6751: REVISION
6752: The implementation number of the CURRENT interface.
1.69 rillig 6753:
1.75 rillig 6754: AGE
6755: The difference between the newest and oldest interfaces that
6756: this library implements. In other words, the library implements
6757: all the interface numbers in the range from number `CURRENT -
6758: AGE' to `CURRENT'.
1.1 grant 6759:
1.75 rillig 6760: If two libraries have identical CURRENT and AGE numbers, then the
6761: dynamic linker chooses the library with the greater REVISION number.
6762: </pre>
6763: <p>The “<span class="quote">-release</span>” option will produce
6764: different results for a.out and ELF (excluding symlinks)
6765: in only one case. An ELF library of the form
6766: “<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
6767: will have a symlink of
6768: “<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
6769: on an a.out platform. This is handled
6770: automatically.</p>
6771: <p>The “<span class="quote">-rpath argument</span>” is the install
6772: directory of the library being built.</p>
1.76 rillig 6773: <p>In the <code class="filename">PLIST</code>, include only the
6774: <code class="filename">.la</code> file, the other files will be
1.75 rillig 6775: added automatically.</p>
6776: </li>
6777: <li>
1.76 rillig 6778: <p>When linking shared object (<code class="filename">.so</code>)
1.75 rillig 6779: 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
6780: shared libraries, use “<span class="quote">-module
6781: -avoid-version</span>” to prevent them getting version
6782: tacked on.</p>
1.76 rillig 6783: <p>The <code class="filename">PLIST</code> file gets the
6784: <code class="filename">foo.so</code> entry.</p>
1.75 rillig 6785: </li>
6786: <li>
6787: <p>When linking programs that depend on these libraries
6788: <span class="emphasis"><em>before</em></span> they are installed, preface
6789: 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}
6790: --mode=link</span>”, and it will find the correct
6791: libraries (static or shared), but please be aware that
6792: libtool will not allow you to specify a relative path in
6793: -L (such as “<span class="quote">-L../somelib</span>”), because it
6794: expects you to change that argument to be the
1.76 rillig 6795: <code class="filename">.la</code> file. e.g.</p>
1.75 rillig 6796: <pre class="programlisting">
6797: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
6798: </pre>
6799: <p>should be changed to:</p>
6800: <pre class="programlisting">
6801: ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
6802: </pre>
6803: <p>and it will do the right thing with the libraries.</p>
6804: </li>
6805: <li>
6806: <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>
6807: 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}
6808: --mode=install</span>”, and change the library name to
1.76 rillig 6809: <code class="filename">.la</code>. e.g.</p>
1.75 rillig 6810: <pre class="programlisting">
6811: ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
6812: </pre>
1.76 rillig 6813: <p>This will install the static <code class="filename">.a</code>,
1.75 rillig 6814: shared library, any needed symlinks, and run
6815: <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>
6816: </li>
1.76 rillig 6817: <li><p>In your <code class="filename">PLIST</code>, include only
6818: the <code class="filename">.la</code>
1.75 rillig 6819: file (this is a change from previous behaviour).</p></li>
6820: </ol></div>
6821: </div>
6822: <div class="sect2" lang="en">
6823: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6824: <a name="using-libtool"></a>17.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
1.75 rillig 6825: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
6826: package Makefile. This will override the package's own libtool
6827: in most cases. For older libtool using packages, libtool is
6828: made by ltconfig script during the do-configure step; you can
6829: check the libtool script location by doing <span><strong class="command">make
6830: configure; find work*/ -name libtool</strong></span>.</p>
6831: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
6832: scripts, relative to <code class="varname">WRKSRC</code>, to override. By
6833: default, it is set to “<span class="quote">libtool */libtool
6834: */*/libtool</span>”. If this does not match the location of the
6835: package's libtool script(s), set it as appropriate.</p>
1.76 rillig 6836: <p>If you do not need <code class="filename">*.a</code> static
1.75 rillig 6837: libraries built and installed, then use
6838: <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
6839: <p>If your package makes use of the platform-independent library
6840: for loading dynamic shared objects, that comes with libtool
6841: (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
6842: <p>Some packages use libtool incorrectly so that the package may not work or
6843: build in some circumstances. Some of the more common errors are:</p>
6844: <div class="itemizedlist"><ul type="disc">
6845: <li>
6846: <p>The inclusion of a shared object (-module) as a dependent library in an
6847: executable or library. This in itself isn't a problem if one of two things
6848: has been done:</p>
6849: <div class="orderedlist"><ol type="1">
6850: <li><p>The shared object is named correctly, i.e.
1.76 rillig 6851: <code class="filename">libfoo.la</code>, not
6852: <code class="filename">foo.la</code></p></li>
1.75 rillig 6853: <li><p>The -dlopen option is used when linking an executable.</p></li>
6854: </ol></div>
6855: </li>
6856: <li><p>The use of libltdl without the correct calls to initialisation routines.
6857: The function lt_dlinit() should be called and the macro
6858: <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
6859: executables.</p></li>
6860: </ul></div>
6861: </div>
6862: <div class="sect2" lang="en">
6863: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6864: <a name="autoconf-automake"></a>17.3.3. GNU Autoconf/Automake</h3></div></div></div>
1.75 rillig 6865: <p>If a package needs GNU autoconf or automake to be executed
6866: to regenerate the configure script and Makefile.in makefile
6867: templates, then they should be executed in a pre-configure
6868: target.</p>
6869: <p>For packages that need only autoconf:</p>
6870: <pre class="programlisting">
6871: AUTOCONF_REQD= 2.50 # if default version is not good enough
6872: USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
6873: ...
1.1 grant 6874:
1.75 rillig 6875: pre-configure:
6876: cd ${WRKSRC}; autoconf
1.1 grant 6877:
1.75 rillig 6878: ...
6879: </pre>
6880: <p>and for packages that need automake and autoconf:</p>
6881: <pre class="programlisting">
6882: AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
6883: USE_TOOLS+= automake # use "automake14" for automake-1.4
6884: ...
1.1 grant 6885:
1.75 rillig 6886: pre-configure:
6887: cd ${WRKSRC}; \
6888: aclocal; autoheader; \
6889: automake -a --foreign -i; autoconf
1.1 grant 6890:
1.75 rillig 6891: ...
6892: </pre>
6893: <p>Packages which use GNU Automake will almost certainly
6894: require GNU Make.</p>
6895: <p>There are times when the configure process makes
6896: additional changes to the generated files, which then causes
6897: the build process to try to re-execute the automake sequence.
6898: This is prevented by touching various files in the configure
6899: stage. If this causes problems with your package you can set
6900: <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
6901: Makefile.</p>
6902: </div>
6903: </div>
6904: <div class="sect1" lang="en">
6905: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6906: <a name="fixes.build"></a>17.4. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
6907: <p>The most common failures when building a package are that
6908: some platforms do not provide certain header files, functions or
6909: libraries, or they provide the functions in a library that the
6910: original package author didn't know. To work around this, you
6911: can rewrite the source code in most cases so that it does not
6912: use the missing functions or provides a replacement function.</p>
6913: <div class="sect2" lang="en">
6914: <div class="titlepage"><div><div><h3 class="title">
6915: <a name="fixes.build.cpp"></a>17.4.1. Compiling C and C++ code conditionally</h3></div></div></div>
6916: <p>If a package already comes with a GNU configure script, the
6917: preferred way to fix the build failure is to change the
6918: configure script, not the code. In the other cases, you can
6919: utilize the C preprocessor, which defines certain macros
6920: depending on the operating system and hardware architecture it
6921: compiles for. These macros can be queried using for example
6922: <code class="varname">#if defined(__i386)</code>. Almost every operating
6923: system, hardware architecture and compiler has its own macro.
6924: For example, if the macros <code class="varname">__GNUC__</code>,
6925: <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
6926: are all defined, you know that you are using NetBSD on an i386
6927: compatible CPU, and your compiler is GCC.</p>
6928: <p>The list of the following macros for hardware and
6929: operating system depends on the compiler that is used. For
6930: example, if you want to conditionally compile code on Solaris,
6931: don't use <code class="varname">__sun__</code>, as the SunPro compiler
6932: does not define it. Use <code class="varname">__sun</code> instead.</p>
1.75 rillig 6933: <div class="sect3" lang="en">
6934: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 6935: <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 6936: <p>To distinguish between 4.4 BSD-derived systems and the
6937: rest of the world, you should use the following code.</p>
6938: <pre class="programlisting">
6939: #include <sys/param.h>
6940: #if (defined(BSD) && BSD >= 199306)
6941: /* BSD-specific code goes here */
6942: #else
6943: /* non-BSD-specific code goes here */
6944: #endif
6945: </pre>
1.77 rillig 6946: <p>If this distinction is not fine enough, you can also test
6947: for the following macros.</p>
1.75 rillig 6948: <pre class="programlisting">
6949: FreeBSD __FreeBSD__
6950: DragonFly __DragonFly__
6951: Interix __INTERIX
6952: Linux linux, __linux, __linux__
6953: NetBSD __NetBSD__
6954: OpenBSD __OpenBSD__
6955: Solaris sun, __sun
6956: </pre>
6957: </div>
6958: <div class="sect3" lang="en">
6959: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 6960: <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 6961: <pre class="programlisting">
6962: i386 i386, __i386, __i386__
6963: MIPS __mips
6964: SPARC sparc, __sparc
6965: </pre>
6966: </div>
6967: <div class="sect3" lang="en">
6968: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 6969: <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 6970: <pre class="programlisting">
6971: GCC __GNUC__ (major version), __GNUC_MINOR__
6972: SunPro __SUNPRO_C (0x570 for version 5.7)
1.81 ! rillig 6973: SunPro C++ __SUNPRO_CC (0x580 for version 5.8)
1.75 rillig 6974: </pre>
6975: </div>
6976: </div>
1.78 rillig 6977: <div class="sect2" lang="en">
6978: <div class="titlepage"><div><div><h3 class="title">
6979: <a name="compiler-bugs"></a>17.4.2. How to handle compiler bugs</h3></div></div></div>
6980: <p>Some source files trigger bugs in the compiler, based on
6981: combinations of compiler version and architecture and almost
6982: always relation to optimisation being enabled. Common symptoms
6983: are gcc internal errors or never finishing compiling a
6984: file.</p>
6985: <p>Typically, a workaround involves testing the
6986: <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
6987: optimisation for that combination of file,
6988: <code class="varname">MACHINE_ARCH</code> and compiler, and documenting it
6989: in <code class="filename">pkgsrc/doc/HACKS</code>. See that file for a
6990: number of examples.</p>
6991: </div>
6992: <div class="sect2" lang="en">
6993: <div class="titlepage"><div><div><h3 class="title">
6994: <a name="undefined-reference"></a>17.4.3. Undefined reference to “<span class="quote">...</span>”</h3></div></div></div>
6995: <p>This compiler error often means that a package did not
6996: link to a shared library it needs. The following functions are
6997: known to cause this error message over and over.</p>
6998: <div class="informaltable">
6999: <a name="undefined-reference-functions"></a><table border="1">
7000: <colgroup>
7001: <col>
7002: <col>
7003: <col>
7004: </colgroup>
7005: <thead><tr>
7006: <th>Function</th>
7007: <th>Library</th>
7008: <th>Affected platforms</th>
7009: </tr></thead>
7010: <tbody>
7011: <tr>
7012: <td>accept, bind, connect</td>
7013: <td>-lsocket</td>
7014: <td>Solaris</td>
7015: </tr>
7016: <tr>
7017: <td>crypt</td>
7018: <td>-lcrypt</td>
7019: <td>DragonFly, NetBSD</td>
7020: </tr>
7021: <tr>
7022: <td>dlopen, dlsym</td>
7023: <td>-ldl</td>
7024: <td>Linux</td>
7025: </tr>
7026: <tr>
7027: <td>gethost*</td>
7028: <td>-lnsl</td>
7029: <td>Solaris</td>
7030: </tr>
7031: <tr>
7032: <td>inet_aton</td>
7033: <td>-lresolv</td>
7034: <td>Solaris</td>
7035: </tr>
7036: <tr>
7037: <td>nanosleep, sem_*, timer_*</td>
7038: <td>-lrt</td>
7039: <td>Solaris</td>
7040: </tr>
7041: <tr>
7042: <td>openpty</td>
7043: <td>-lutil</td>
7044: <td>Linux</td>
7045: </tr>
7046: </tbody>
7047: </table>
7048: </div>
7049: <p>To fix these linker errors, it is often sufficient to say
7050: <code class="literal">LIBS.<em class="replaceable"><code>OperatingSystem</code></em>+=
7051: -l<em class="replaceable"><code>foo</code></em></code> to the package
7052: <code class="filename">Makefile</code> and then say <span><strong class="command">bmake clean;
7053: bmake</strong></span>.</p>
7054: </div>
1.75 rillig 7055: </div>
7056: <div class="sect1" lang="en">
7057: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 7058: <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 7059: <div class="sect2" lang="en">
7060: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7061: <a name="install-scripts"></a>17.5.1. Creating needed directories</h3></div></div></div>
7062: <p>The BSD-compatible <span><strong class="command">install</strong></span> supplied
7063: with some operating systems cannot create more than one
7064: directory at a time. As such, you should call
7065: <code class="literal">${INSTALL_*_DIR}</code> like this:</p>
1.75 rillig 7066: <pre class="programlisting">
1.78 rillig 7067: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
7068: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
1.75 rillig 7069: </pre>
1.78 rillig 7070: <p>You can also just append “<span class="quote"><code class="literal">dir1
7071: dir2</code></span>” to the
7072: <code class="varname">INSTALLATION_DIRS</code> variable, which will
7073: automatically do the right thing.</p>
1.75 rillig 7074: </div>
7075: <div class="sect2" lang="en">
7076: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7077: <a name="where-to-install-documentation"></a>17.5.2. Where to install documentation</h3></div></div></div>
7078: <p>Documentation should be installed into
7079: <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
7080: <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the latter
7081: includes the version number of the package).</p>
1.75 rillig 7082: </div>
7083: <div class="sect2" lang="en">
7084: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7085: <a name="installing-score-files"></a>17.5.3. Installing score files</h3></div></div></div>
1.75 rillig 7086: <p>Certain packages, most of them in the games category, install
7087: a score file that allows all users on the system to record their
7088: highscores. In order for this to work, the binaries need to be
7089: installed setgid and the score files owned by the appropriate
7090: group and/or owner (traditionally the "games" user/group). The
7091: following variables, documented in more detail in
1.76 rillig 7092: <code class="filename">mk/defaults/mk.conf</code>, control this
1.75 rillig 7093: behaviour: <code class="varname">SETGIDGAME</code>,
7094: <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
7095: <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
7096: <p>Note that per default, setgid installation of games is
7097: disabled; setting <code class="varname">SETGIDGAME=YES</code> will set all
7098: the other variables accordingly.</p>
7099: <p>A package should therefor never hard code file ownership or
7100: access permissions but rely on <code class="varname">INSTALL_GAME</code> and
7101: <code class="varname">INSTALL_GAME_DATA</code> to set these
7102: correctly.</p>
7103: </div>
7104: <div class="sect2" lang="en">
7105: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7106: <a name="perl-scripts"></a>17.5.4. Packages containing perl scripts</h3></div></div></div>
1.75 rillig 7107: <p>
7108: If your package contains interpreted perl scripts, set
7109: <code class="varname">REPLACE_PERL</code> to ensure that the proper
7110: interpreter path is set. <code class="varname">REPLACE_PERL</code> should
7111: contain a list of scripts, relative to
7112: <code class="varname">WRKSRC</code>, that you want adjusted.</p>
7113: </div>
7114: <div class="sect2" lang="en">
7115: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7116: <a name="hardcoded-paths"></a>17.5.5. Packages with hardcoded paths to other interpreters</h3></div></div></div>
1.75 rillig 7117: <p>
7118: Your package may also contain scripts with hardcoded paths to
7119: other interpreters besides (or as well as) perl. To correct the
7120: full pathname to the script interpreter, you need to set the
1.76 rillig 7121: following definitions in your <code class="filename">Makefile</code> (we
1.75 rillig 7122: shall use <span><strong class="command">tclsh</strong></span> in this example):</p>
7123: <pre class="programlisting">
7124: REPLACE_INTERPRETER+= tcl
7125: REPLACE.tcl.old= .*/bin/tclsh
7126: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
7127: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
7128: # relative to ${WRKSRC}, just as in REPLACE_PERL
7129: </pre>
7130: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7131: <h3 class="title">Note</h3>
7132: <p>Before March 2006, these variables were called
7133: <code class="varname">_REPLACE.*</code> and
7134: <code class="varname">_REPLACE_FILES.*</code>.</p>
7135: </div>
7136: </div>
7137: <div class="sect2" lang="en">
7138: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7139: <a name="perl-modules"></a>17.5.6. Packages installing perl modules</h3></div></div></div>
1.75 rillig 7140: <p>Makefiles of packages providing perl5 modules should include
7141: the Makefile fragment
1.76 rillig 7142: <code class="filename">../../lang/perl5/module.mk</code>. It provides a
1.75 rillig 7143: <span><strong class="command">do-configure</strong></span> target for the standard perl
7144: configuration for such modules as well as various hooks to tune
7145: this configuration. See comments in this file for
7146: details.</p>
7147: <p>Perl5 modules will install into different places depending
7148: on the version of perl used during the build process. To
7149: address this, pkgsrc will append lines to the
1.76 rillig 7150: <code class="filename">PLIST</code> corresponding to the files listed in
7151: the installed <code class="filename">.packlist</code> file generated by
1.75 rillig 7152: most perl5 modules. This is invoked by defining
7153: <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
7154: paths to packlist files, e.g.:</p>
7155: <pre class="programlisting">
7156: PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
7157: </pre>
7158: <p>The variables <code class="varname">PERL5_SITELIB</code>,
7159: <code class="varname">PERL5_SITEARCH</code>, and
7160: <code class="varname">PERL5_ARCHLIB</code> represent the three locations
7161: in which perl5 modules may be installed, and may be used by
7162: perl5 packages that don't have a packlist. These three
7163: variables are also substituted for in the
1.76 rillig 7164: <code class="filename">PLIST</code>.</p>
1.75 rillig 7165: </div>
7166: <div class="sect2" lang="en">
7167: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7168: <a name="faq.info-files"></a>17.5.7. Packages installing info files</h3></div></div></div>
1.75 rillig 7169: <p>Some packages install info files or use the
7170: “<span class="quote">makeinfo</span>” or “<span class="quote">install-info</span>”
7171: commands. <code class="varname">INFO_FILES</code> should be defined in
1.76 rillig 7172: the package Makefile so that <code class="filename">INSTALL</code> and
7173: <code class="filename">DEINSTALL</code> scripts will be generated to
1.75 rillig 7174: handle registration of the info files in the Info directory
7175: file. The “<span class="quote">install-info</span>” command used for the info
7176: files registration is either provided by the system, or by a
7177: special purpose package automatically added as dependency if
7178: needed.</p>
7179: <p><code class="varname">PKGINFODIR</code> is the directory under
1.76 rillig 7180: <code class="filename">${PREFIX}</code> where info files are primarily
1.75 rillig 7181: located. <code class="varname">PKGINFODIR</code> defaults to
7182: “<span class="quote">info</span>” and can be overridden by the user.</p>
7183: <p>The info files for the package should be listed in the
1.76 rillig 7184: package <code class="filename">PLIST</code>; however any split info files
1.75 rillig 7185: need not be listed.</p>
7186: <p>A package which needs the “<span class="quote">makeinfo</span>” command
7187: at build time must add “<span class="quote">makeinfo</span>” to
7188: <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
7189: version of the “<span class="quote">makeinfo</span>” command is needed it
7190: should be noted with the <code class="varname">TEXINFO_REQD</code>
1.76 rillig 7191: variable in the package <code class="filename">Makefile</code>. By
1.75 rillig 7192: default, a minimum version of 3.12 is required. If the system
7193: does not provide a <span><strong class="command">makeinfo</strong></span> command or if it
7194: does not match the required minimum, a build dependency on the
1.76 rillig 7195: <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 7196: be added automatically.</p>
7197: <p>The build and installation process of the software provided
7198: by the package should not use the
7199: <span><strong class="command">install-info</strong></span> command as the registration of
7200: info files is the task of the package
1.76 rillig 7201: <code class="filename">INSTALL</code> script, and it must use the
1.75 rillig 7202: appropriate <span><strong class="command">makeinfo</strong></span> command.</p>
7203: <p>To achieve this goal, the pkgsrc infrastructure creates
7204: overriding scripts for the <span><strong class="command">install-info</strong></span> and
7205: <span><strong class="command">makeinfo</strong></span> commands in a directory listed early
7206: in <code class="varname">PATH</code>.</p>
7207: <p>The script overriding <span><strong class="command">install-info</strong></span> has
7208: no effect except the logging of a message. The script overriding
7209: <span><strong class="command">makeinfo</strong></span> logs a message and according to the
7210: value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
7211: <span><strong class="command">makeinfo</strong></span> command or exit on error.</p>
7212: </div>
7213: <div class="sect2" lang="en">
7214: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7215: <a name="manpages"></a>17.5.8. Packages installing man pages</h3></div></div></div>
1.81 ! rillig 7216: <p>All packages that install manual pages should install them
! 7217: into the same directory, so that there is one common place to
! 7218: look for them. In pkgsrc, this place is
! 7219: <code class="literal">${PREFIX}/${PKGMANDIR}</code>, and this expression
! 7220: should be used in packages. The default for
! 7221: <code class="varname">PKGMANDIR</code> is
! 7222: “<span class="quote"><code class="filename">man</code></span>”. Another often-used
! 7223: value is “<span class="quote"><code class="filename">share/man</code></span>”.</p>
1.75 rillig 7224: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7225: <h3 class="title">Note</h3>
1.81 ! rillig 7226: <p>The support for a custom
! 7227: <code class="varname">PKGMANDIR</code> is far from complete.</p>
1.75 rillig 7228: </div>
1.81 ! rillig 7229: <p>The <code class="filename">PLIST</code> files can just use
! 7230: <code class="filename">man/</code> as the top level directory for the man
! 7231: page file entries, and the pkgsrc framework will convert as
! 7232: needed. In all other places, the correct
! 7233: <code class="varname">PKGMANDIR</code> must be used.</p>
1.75 rillig 7234: <p> Packages that are
7235: configured with <code class="varname">GNU_CONFIGURE</code> set as
7236: “<span class="quote">yes</span>”, by default will use the
1.76 rillig 7237: <code class="filename">./configure</code>
1.75 rillig 7238: --mandir switch to set where the man pages should be installed.
7239: The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
7240: to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.
7241: </p>
7242: <p>
7243: Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
7244: use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
7245: to “<span class="quote">no</span>”.
1.76 rillig 7246: Or if the <code class="filename">./configure</code> script uses
1.75 rillig 7247: a non-standard use of --mandir, you can set
7248: <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.
7249: </p>
1.77 rillig 7250: <p>See <a href="#manpage-compression" title="11.5. Man page compression">Section 11.5, “Man page compression”</a> for
1.75 rillig 7251: information on installation of compressed manual pages.
7252: </p>
7253: </div>
7254: <div class="sect2" lang="en">
7255: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7256: <a name="gconf2-data-files"></a>17.5.9. Packages installing GConf2 data files</h3></div></div></div>
1.75 rillig 7257: <p>
1.76 rillig 7258: If a package installs <code class="filename">.schemas</code> or
7259: <code class="filename">.entries</code> files, used by GConf2,
1.75 rillig 7260: you need to take some extra steps to make sure they get registered
7261: in the database:
7262: </p>
7263: <div class="orderedlist"><ol type="1">
1.76 rillig 7264: <li><p>Include <code class="filename">../../devel/GConf2/schemas.mk</code>
7265: instead of its <code class="filename">buildlink3.mk</code> file. This
1.75 rillig 7266: takes care of rebuilding the GConf2 database at installation and
7267: deinstallation time, and tells the package where to install
7268: GConf2 data files using some standard configure arguments. It
7269: also disallows any access to the database directly from the
7270: package.</p></li>
7271: <li><p>Ensure that the package installs its
1.76 rillig 7272: <code class="filename">.schemas</code> files under
7273: <code class="filename">${PREFIX}/share/gconf/schemas</code>. If they get
7274: installed under <code class="filename">${PREFIX}/etc</code>, you will
1.75 rillig 7275: need to manually patch the package.</p></li>
7276: <li><p>Check the PLIST and remove any entries under the etc/gconf
7277: directory, as they will be handled automatically. See
7278: <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>
7279: <li><p>Define the <code class="varname">GCONF2_SCHEMAS</code> variable in
1.76 rillig 7280: your <code class="filename">Makefile</code> with a list of all
7281: <code class="filename">.schemas</code> files installed by the package, if
1.75 rillig 7282: any. Names must not contain any directories in them.</p></li>
7283: <li><p>Define the <code class="varname">GCONF2_ENTRIES</code> variable in
1.76 rillig 7284: your <code class="filename">Makefile</code> with a
7285: list of all <code class="filename">.entries</code> files installed by the
1.75 rillig 7286: package, if any. Names must not contain any directories in
7287: them.</p></li>
7288: </ol></div>
7289: </div>
7290: <div class="sect2" lang="en">
7291: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7292: <a name="scrollkeeper-data-files"></a>17.5.10. Packages installing scrollkeeper data files</h3></div></div></div>
1.75 rillig 7293: <p>
1.76 rillig 7294: If a package installs <code class="filename">.omf</code> files, used by
1.75 rillig 7295: scrollkeeper, you need to take some extra steps to make sure they
7296: get registered in the database:
7297: </p>
7298: <div class="orderedlist"><ol type="1">
7299: <li><p>Include
1.76 rillig 7300: <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
7301: instead of its <code class="filename">buildlink3.mk</code> file. This
1.75 rillig 7302: takes care of rebuilding the scrollkeeper database at
7303: installation and deinstallation time, and disallows any access
7304: to it directly from the package.
7305: </p></li>
7306: <li><p>Check the PLIST and remove any entries under the
1.76 rillig 7307: <code class="filename">libdata/scrollkeeper</code> directory, as they
1.75 rillig 7308: will be handled automatically.</p></li>
1.76 rillig 7309: <li><p>Remove the <code class="filename">share/omf</code> directory from
1.75 rillig 7310: the PLIST. It will be handled by scrollkeeper.</p></li>
7311: </ol></div>
7312: </div>
7313: <div class="sect2" lang="en">
7314: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7315: <a name="x11-fonts"></a>17.5.11. Packages installing X11 fonts</h3></div></div></div>
1.75 rillig 7316: <p>If a package installs font files, you will need to rebuild
7317: the fonts database in the directory where they get installed at
7318: installation and deinstallation time. This can be automatically
7319: done by using the pkginstall framework.</p>
7320: <p>You can list the directories where fonts are installed in the
7321: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
7322: variables, where <em class="replaceable"><code>type</code></em> can be one of
7323: “<span class="quote">ttf</span>”, “<span class="quote">type1</span>” or “<span class="quote">x11</span>”.
7324: Also make sure that the database file
1.76 rillig 7325: <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
1.75 rillig 7326: <p>Note that you should not create new directories for fonts;
7327: instead use the standard ones to avoid that the user needs to
7328: manually configure his X server to find them.</p>
7329: </div>
7330: <div class="sect2" lang="en">
7331: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7332: <a name="gtk2-modules"></a>17.5.12. Packages installing GTK2 modules</h3></div></div></div>
1.75 rillig 7333: <p>If a package installs GTK2 immodules or loaders, you need to
7334: take some extra steps to get them registered in the GTK2 database
7335: properly:</p>
7336: <div class="orderedlist"><ol type="1">
7337: <li><p>Include
1.76 rillig 7338: <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
7339: <code class="filename">buildlink3.mk</code> file. This takes care of
1.75 rillig 7340: rebuilding the database at installation and deinstallation time.
7341: </p></li>
7342: <li><p>
7343: Set <code class="varname">GTK2_IMMODULES=YES</code> if
7344: your package installs GTK2 immodules.</p></li>
7345: <li><p>
7346: Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
7347: GTK2 loaders.</p></li>
7348: <li>
7349: <p>
7350: Patch the package to not touch any of the GTK2 databases directly.
7351: These are:
7352:
7353: </p>
7354: <div class="itemizedlist"><ul type="disc">
1.76 rillig 7355: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
7356: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
1.75 rillig 7357: </ul></div>
7358: <p>
7359: </p>
7360: </li>
7361: <li><p>
7362: Check the PLIST and remove any entries under the
1.76 rillig 7363: <code class="filename">libdata/gtk-2.0</code> directory, as they will be
1.75 rillig 7364: handled automatically.</p></li>
7365: </ol></div>
7366: </div>
7367: <div class="sect2" lang="en">
7368: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7369: <a name="sgml-xml-data"></a>17.5.13. Packages installing SGML or XML data</h3></div></div></div>
1.75 rillig 7370: <p>If a package installs SGML or XML data files that need to be
7371: registered in system-wide catalogs (like DTDs, sub-catalogs,
7372: etc.), you need to take some extra steps:
7373: </p>
7374: <div class="orderedlist"><ol type="1">
7375: <li><p>Include
1.76 rillig 7376: <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
7377: your <code class="filename">Makefile</code>, which takes care of
1.75 rillig 7378: registering those files in system-wide catalogs at
7379: installation and deinstallation time.</p></li>
7380: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
7381: any SGML catalogs installed by the package.</p></li>
7382: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
7383: any XML catalogs installed by the package.</p></li>
7384: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
7385: to be added to the SGML catalog. These come in groups of
7386: three strings; see xmlcatmgr(1) for more information
7387: (specifically, arguments recognized by the 'add' action).
7388: Note that you will normally not use this variable.</p></li>
7389: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
7390: to be added to the XML catalog. These come in groups of three
7391: strings; see xmlcatmgr(1) for more information (specifically,
7392: arguments recognized by the 'add' action). Note that you will
7393: normally not use this variable.
7394: </p></li>
7395: </ol></div>
7396: </div>
7397: <div class="sect2" lang="en">
7398: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7399: <a name="mime-database"></a>17.5.14. Packages installing extensions to the MIME database</h3></div></div></div>
1.75 rillig 7400: <p>If a package provides extensions to the MIME database by
1.76 rillig 7401: installing <code class="filename">.xml</code> files inside
7402: <code class="filename">${PREFIX}/share/mime/packages</code>, you
1.75 rillig 7403: need to take some extra steps to ensure that the database is kept
7404: consistent with respect to these new files:
7405: </p>
7406: <div class="orderedlist"><ol type="1">
7407: <li><p>Include
1.76 rillig 7408: <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
7409: (avoid using the <code class="filename">buildlink3.mk</code> file from
1.75 rillig 7410: this same directory, which is reserved for inclusion from
1.76 rillig 7411: other <code class="filename">buildlink3.mk</code> files). It takes
1.75 rillig 7412: care of rebuilding the MIME database at installation and
7413: deinstallation time, and disallows any access to it directly
7414: from the package.</p></li>
7415: <li><p>Check the PLIST and remove any entries under the
1.76 rillig 7416: <code class="filename">share/mime</code> directory,
1.75 rillig 7417: <span class="emphasis"><em>except</em></span> for files saved under
1.76 rillig 7418: <code class="filename">share/mime/packages</code>. The former are
1.75 rillig 7419: handled automatically by
7420: the update-mime-database program, but the latter are
7421: package-dependent and must be removed by the package that
7422: installed them in the first place.</p></li>
1.76 rillig 7423: <li><p>Remove any <code class="filename">share/mime/*</code> directories
1.75 rillig 7424: from the PLIST. They will be handled by the shared-mime-info
7425: package.</p></li>
7426: </ol></div>
7427: </div>
7428: <div class="sect2" lang="en">
7429: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7430: <a name="intltool"></a>17.5.15. Packages using intltool</h3></div></div></div>
1.75 rillig 7431: <p>If a package uses intltool during its build, include the
1.76 rillig 7432: <code class="filename">../../textproc/intltool/buildlink3.mk</code> file,
1.75 rillig 7433: which forces it to use the intltool package provided by pkgsrc,
7434: instead of the one bundled with the distribution file.
7435: </p>
7436: <p>This tracks intltool's build-time dependencies and uses the
7437: latest available version; this way, the package benefits of any
7438: bug fixes that may have appeared since it was released.
7439: </p>
7440: </div>
7441: <div class="sect2" lang="en">
7442: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7443: <a name="startup-scripts"></a>17.5.16. Packages installing startup scripts</h3></div></div></div>
1.75 rillig 7444: <p>If a package contains a rc.d script, it won't be copied into
7445: the startup directory by default, but you can enable it, by adding
7446: the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
1.76 rillig 7447: <code class="filename">/etc/mk.conf</code>. This option will copy the scripts
7448: into <code class="filename">/etc/rc.d</code> when a package is installed, and
1.75 rillig 7449: it will automatically remove the scripts when the package is
7450: deinstalled.</p>
7451: </div>
7452: <div class="sect2" lang="en">
7453: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7454: <a name="tex-packages"></a>17.5.17. Packages installing TeX modules</h3></div></div></div>
1.75 rillig 7455: <p>If a package installs TeX packages into the texmf tree,
1.76 rillig 7456: the <code class="filename">ls-R</code> database of the tree needs to be
1.75 rillig 7457: updated.</p>
7458: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7459: <h3 class="title">Note</h3>
7460: <p>Except the main TeX packages such as teTeX-texmf,
7461: packages should install files
7462: into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
7463: not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
7464: </div>
7465: <div class="orderedlist"><ol type="1">
7466: <li><p>Include
1.76 rillig 7467: <code class="filename">../../print/teTeX/module.mk</code> instead
7468: of <code class="filename">../../mk/tex.buildlink3.mk</code>. This
7469: takes care of rebuilding the <code class="filename">ls-R</code>
1.75 rillig 7470: database at installation and deinstallation time.</p></li>
7471: <li>
7472: <p>If your package installs files into a texmf
7473: tree other than the one
7474: at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
7475: set <code class="varname">TEXMFDIRS</code> to the list of all texmf
7476: trees that need database update.</p>
7477: <p>If your package also installs font map files that need
7478: to be registered using <span><strong class="command">updmap</strong></span>,
7479: set <code class="varname">TEX_FONTMAPS</code> to the list of all
7480: such font map files. Then <span><strong class="command">updmap</strong></span> will
7481: be run automatically at installation/deinstallation to
7482: enable/disable font map files for TeX output
7483: drivers.</p>
7484: </li>
1.76 rillig 7485: <li><p>Make sure that none of <code class="filename">ls-R</code>
7486: databases are included in <code class="filename">PLIST</code>, as
1.75 rillig 7487: they will be removed only by the teTeX-bin package.</p></li>
7488: </ol></div>
7489: </div>
7490: </div>
7491: <div class="sect1" lang="en">
7492: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 7493: <a name="feedback-to-author"></a>17.6. Feedback to the author</h2></div></div></div>
1.75 rillig 7494: <p>If you have found any bugs in the package you make available,
7495: if you had to do special steps to make it run under NetBSD or
7496: if you enhanced the software in various other ways, be sure
7497: to report these changes back to the original author of the
7498: program! With that kind of support, the next release of the
7499: program can incorporate these fixes, and people not using the
7500: NetBSD packages system can win from your efforts.</p>
7501: <p>Support the idea of free software!</p>
7502: </div>
7503: </div>
7504: <div class="chapter" lang="en">
7505: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7506: <a name="debug"></a>Chapter 18. Debugging</h2></div></div></div>
1.75 rillig 7507: <p>To check out all the gotchas when building a package, here are the steps
7508: that I do in order to get a package working. Please note this is basically
7509: the same as what was explained in the previous sections, only with some
7510: debugging aids.</p>
7511: <div class="itemizedlist"><ul type="disc">
7512: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=1</code>
1.76 rillig 7513: in <code class="filename">/etc/mk.conf</code></p></li>
1.75 rillig 7514: <li>
1.76 rillig 7515: <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 7516: create a directory for a new package, change into it, then run
7517: <span><strong class="command">url2pkg</strong></span>:</p>
7518: <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>
7519: <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>
7520: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
7521: </li>
1.76 rillig 7522: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
7523: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.75 rillig 7524: <li><p>Run <span><strong class="command">make configure</strong></span>
7525: </p></li>
7526: <li><p>Add any dependencies glimpsed from documentation and the
7527: configure step to the package's
1.76 rillig 7528: <code class="filename">Makefile</code>.</p></li>
1.75 rillig 7529: <li>
7530: <p>Make the package compile, doing multiple rounds of</p>
7531: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
7532: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
7533: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
7534: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
7535: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
7536: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
7537: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
7538: <p>Doing as non-root user will ensure that no files are modified that
7539: shouldn't be, especially during the build
7540: phase. <span><strong class="command">mkpatches</strong></span>,
7541: <span><strong class="command">patchdiff</strong></span> and <span><strong class="command">pkgvi</strong></span> are
1.76 rillig 7542: 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 7543: package. </p>
7544: </li>
1.76 rillig 7545: <li><p>Look at the <code class="filename">Makefile</code>, fix if necessary;
1.77 rillig 7546: see <a href="#components.Makefile" title="9.1. Makefile">Section 9.1, “<code class="filename">Makefile</code>”</a>.</p></li>
1.75 rillig 7547: <li>
1.76 rillig 7548: <p>Generate a <code class="filename">PLIST</code>:</p>
1.75 rillig 7549: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
7550: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST >PLIST</code></strong>
7551: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
7552: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
7553: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
1.76 rillig 7554: <p>You usually need to be <code class="username">root</code> to do this.
1.75 rillig 7555: Look if there are any files left:</p>
7556: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
7557: <p>If this reveals any files that are missing in
1.76 rillig 7558: <code class="filename">PLIST</code>, add them.</p>
1.75 rillig 7559: </li>
7560: <li>
1.76 rillig 7561: <p>Now that the <code class="filename">PLIST</code> is OK,
1.75 rillig 7562: install the package again and make a binary package:</p>
7563: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
7564: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
7565: </li>
7566: <li>
7567: <p>Delete the installed package:</p>
7568: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete blub</code></strong></pre>
7569: </li>
7570: <li>
7571: <p>Repeat the above <span><strong class="command">make print-PLIST</strong></span> command,
7572: which shouldn't find anything now:</p>
7573: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
7574: </li>
7575: <li>
7576: <p>Reinstall the binary package:</p>
7577: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkgadd .../blub.tgz</code></strong></pre>
7578: </li>
7579: <li><p>Play with it. Make sure everything works.</p></li>
7580: <li>
7581: <p>Run <span><strong class="command">pkglint</strong></span> from
1.76 rillig 7582: <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 7583: and fix the problems it reports:</p>
7584: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
7585: </li>
7586: <li><p>Submit (or commit, if you have cvs access);
1.77 rillig 7587: see <a href="#submit" title="Chapter 19. Submitting and Committing">Chapter 19, <i>Submitting and Committing</i></a>.</p></li>
1.75 rillig 7588: </ul></div>
7589: </div>
7590: <div class="chapter" lang="en">
7591: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7592: <a name="submit"></a>Chapter 19. Submitting and Committing</h2></div></div></div>
1.75 rillig 7593: <div class="toc">
7594: <p><b>Table of Contents</b></p>
7595: <dl>
1.77 rillig 7596: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
7597: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
7598: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
7599: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
7600: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
7601: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 7602: </dl>
7603: </div>
7604: <div class="sect1" lang="en">
7605: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7606: <a name="submitting-binary-packages"></a>19.1. Submitting binary packages</h2></div></div></div>
1.75 rillig 7607: <p>Our policy is that we accept binaries only from pkgsrc
7608: developers to guarantee that the packages don't contain any
7609: trojan horses etc. This is not to annoy anyone but rather to
7610: protect our users! You're still free to put up your home-made
7611: binary packages and tell the world where to get them. NetBSD
7612: developers doing bulk builds and wanting to upload them please
7613: 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>
7614: </div>
7615: <div class="sect1" lang="en">
7616: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7617: <a name="submitting-your-package"></a>19.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
1.75 rillig 7618: <p>First, check that your package is complete, compiles and
1.77 rillig 7619: runs well; see <a href="#debug" title="Chapter 18. Debugging">Chapter 18, <i>Debugging</i></a> and the rest of this
1.75 rillig 7620: 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>
7621: archive, preferably with all files in a single directory.
7622: Finally, <span><strong class="command">send-pr</strong></span> with category
7623: “<span class="quote">pkg</span>”, a synopsis which includes the package name
7624: and version number, a short description of your package
7625: (contents of the COMMENT variable or DESCR file are OK) and
7626: attach the archive to your PR.</p>
7627: <p>If you want to submit several packages, please send a
7628: separate PR for each one, it's easier for us to track things
7629: that way.</p>
7630: <p>Alternatively, you can also import new packages into
7631: pkgsrc-wip (“<span class="quote">pkgsrc work-in-progress</span>”); see the
7632: homepage at <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
7633: for details.</p>
7634: </div>
7635: <div class="sect1" lang="en">
7636: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7637: <a name="general-notes-for-changes"></a>19.3. General notes when adding, updating, or removing packages</h2></div></div></div>
1.75 rillig 7638: <p>Please note all package additions, updates, moves, and
1.76 rillig 7639: removals in <code class="filename">pkgsrc/doc/CHANGES</code>. It's very
1.75 rillig 7640: important to keep this file up to date and conforming to the
7641: existing format, because it will be used by scripts to
7642: automatically update pages on <a href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
7643: sites. Additionally, check the
1.76 rillig 7644: <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
1.75 rillig 7645: for the package you updated or removed, in case it was mentioned
7646: there.</p>
7647: <p>When the <code class="varname">PKGREVISION</code> of a package is
7648: bumped, the change should appear in
1.76 rillig 7649: <code class="filename">pkgsrc/doc/CHANGES</code> if it is security
1.75 rillig 7650: related or otherwise relevant. Mass bumps that result from a
7651: dependency being updated should not be mentioned. In all other
7652: cases it's the developer's decision.</p>
7653: <p>There is a make target that helps in creating proper
1.76 rillig 7654: <code class="filename">CHANGES</code> entries: <span><strong class="command">make
1.75 rillig 7655: changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
7656: and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
1.76 rillig 7657: usage is to first make sure that your <code class="filename">CHANGES</code>
1.75 rillig 7658: file is up-to-date (to avoid having to resolve conflicts later-on)
7659: and then to <span><strong class="command">cd</strong></span> to the package directory. For
7660: package updates, <span><strong class="command">make changes-entry</strong></span> is enough.
7661: For new packages, or package moves or removals, set the
7662: <code class="varname">CTYPE</code> variable on the command line to "Added",
7663: "Moved", or "Removed". You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.76 rillig 7664: in <code class="filename">/etc/mk.conf</code> if your local login name is
1.75 rillig 7665: not the same as your NetBSD login name. Don't forget to commit
1.76 rillig 7666: the changes to <code class="filename">pkgsrc/doc/CHANGES</code>!</p>
1.75 rillig 7667: </div>
7668: <div class="sect1" lang="en">
7669: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7670: <a name="committing-importing"></a>19.4. Committing: Importing a package into CVS</h2></div></div></div>
1.75 rillig 7671: <p>
7672: This section is only of interest for pkgsrc developers with write
7673: access to the pkgsrc repository. Please remember that cvs
7674: imports files relative to the current working directory, and that
7675: the pathname that you
7676: give the <span><strong class="command">cvs import</strong></span> command is so that it knows where
7677: to place the files in the repository. Newly created packages should be
7678: imported with a vendor tag of “<span class="quote">TNF</span>” and a release tag of
7679: “<span class="quote">pkgsrc-base</span>”, e.g:
7680: </p>
7681: <pre class="programlisting">
7682: <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
7683: <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
7684: </pre>
7685: <p>
7686: Remember to move the directory from which you imported out of
7687: the way, or cvs will complain the next time you “<span class="quote">cvs
7688: update</span>” your source tree. Also don't forget to add the new
1.76 rillig 7689: package to the category's <code class="filename">Makefile</code>.
1.75 rillig 7690: </p>
7691: <p>
7692: The commit message of the initial import should include part of the
1.76 rillig 7693: <code class="filename">DESCR</code> file, so people reading the mailing lists know
1.75 rillig 7694: what the package is/does.
7695: </p>
7696: <p>
7697: For new packages, “<span class="quote">cvs import</span>” is preferred to “<span class="quote">cvs
7698: add</span>” because the former gets everything with a single command,
7699: and provides a consistent tag.
7700: </p>
7701: </div>
7702: <div class="sect1" lang="en">
7703: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7704: <a name="updating-package"></a>19.5. Updating a package to a newer version</h2></div></div></div>
1.75 rillig 7705: <p>
7706: Please always put a concise, appropriate and relevant summary of the
7707: changes between old and new versions into the commit log when updating
7708: a package. There are various reasons for this:
7709: </p>
7710: <div class="itemizedlist"><ul type="disc">
7711: <li><p>
7712: A URL is volatile, and can change over time. It may go away completely
7713: or its information may be overwritten by newer information.
7714: </p></li>
7715: <li><p>
7716: Having the change information between old and new versions in our CVS
7717: repository is very useful for people who use either cvs or anoncvs.
7718: </p></li>
7719: <li><p>
7720: Having the change information between old and new versions in our CVS
7721: repository is very useful for people who read the pkgsrc-changes mailing
7722: list, so that they can make tactical decisions about when to upgrade
7723: the package.
7724: </p></li>
7725: </ul></div>
7726: <p>
7727: Please also recognize that, just because a new version of a package
7728: has been released, it should not automatically be upgraded in the CVS
7729: repository. We prefer to be conservative in the packages that are
7730: included in pkgsrc - development or beta packages are not really the
7731: best thing for most places in which pkgsrc is used. Please use your
7732: judgement about what should go into pkgsrc, and bear in mind that
7733: stability is to be preferred above new and possibly untested features.
7734: </p>
7735: </div>
7736: <div class="sect1" lang="en">
7737: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7738: <a name="moving-package"></a>19.6. Moving a package in pkgsrc</h2></div></div></div>
1.75 rillig 7739: <div class="orderedlist"><ol type="1">
7740: <li><p>Make a copy of the directory somewhere else.</p></li>
7741: <li>
7742: <p>Remove all CVS dirs.</p>
7743: <p>
7744: Alternatively to the first two steps you can also do:
7745: </p>
7746: <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>
7747: <p>
7748: and use that for further work.
7749: </p>
7750: </li>
7751: <li><p>Fix <code class="varname">CATEGORIES</code> and any
7752: <code class="varname">DEPENDS</code> paths that just did “<span class="quote">../package</span>”
7753: instead of “<span class="quote">../../category/package</span>”.</p></li>
7754: <li><p><span><strong class="command">cvs import</strong></span> the modified package in the new
7755: place.</p></li>
7756: <li>
7757: <p>Check if any package depends on it:
7758: </p>
7759: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
7760: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
7761: <p>
7762: </p>
7763: </li>
7764: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
7765: <li><p><span><strong class="command">cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.76 rillig 7766: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
7767: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
1.75 rillig 7768: <li>
7769: <p>Commit the changed and removed files:</p>
7770: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong></pre>
7771: <p>
7772: (and any packages from step 5, of course).
7773: </p>
7774: </li>
7775: </ol></div>
7776: </div>
7777: </div>
7778: <div class="chapter" lang="en">
7779: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7780: <a name="devfaq"></a>Chapter 20. Frequently Asked Questions</h2></div></div></div>
1.75 rillig 7781: <p>This section contains the answers to questions that may
7782: arise when you are writing a package. If you don't find your
7783: question answered here, first have a look in the other chapters,
7784: and if you still don't have the answer, ask on the
7785: <code class="literal">pkgsrc-users</code> mailing list.</p>
7786: <div class="qandaset">
7787: <dl>
1.81 ! rillig 7788: <dt>20.1. <a href="#id2655066">What is the difference between
1.75 rillig 7789: MAKEFLAGS, .MAKEFLAGS and
7790: MAKE_FLAGS?</a>
7791: </dt>
1.81 ! rillig 7792: <dt>20.2. <a href="#id2655171">What is the difference between
1.75 rillig 7793: MAKE, GMAKE and
7794: MAKE_PROGRAM?</a>
7795: </dt>
1.81 ! rillig 7796: <dt>20.3. <a href="#id2655209">What is the difference between
1.75 rillig 7797: CC, PKG_CC and
7798: PKGSRC_COMPILER?</a>
7799: </dt>
1.81 ! rillig 7800: <dt>20.4. <a href="#id2655246">What is the difference between
1.75 rillig 7801: BUILDLINK_LDFLAGS,
7802: BUILDLINK_LDADD and
7803: BUILDLINK_LIBS?</a>
7804: </dt>
1.81 ! rillig 7805: <dt>20.5. <a href="#id2655265">Why does make show-var
1.75 rillig 7806: VARNAME=BUILDLINK_PREFIX.foo
7807: say it's empty?</a>
7808: </dt>
1.81 ! rillig 7809: <dt>20.6. <a href="#id2655292">What does
1.78 rillig 7810: ${MASTER_SITE_SOURCEFORGE:=package/} mean? I
7811: don't understand the := inside
7812: it.</a>
7813: </dt>
1.81 ! rillig 7814: <dt>20.7. <a href="#id2655367">Which mailing lists are there for package
1.78 rillig 7815: developers?</a>
7816: </dt>
1.81 ! rillig 7817: <dt>20.8. <a href="#id2655403">Where is the pkgsrc
1.80 rillig 7818: documentation?</a>
7819: </dt>
1.75 rillig 7820: </dl>
7821: <table border="0" summary="Q and A Set">
7822: <col align="left" width="1%">
7823: <tbody>
7824: <tr class="question">
7825: <td align="left" valign="top">
1.81 ! rillig 7826: <a name="id2655066"></a><a name="id2655067"></a><b>20.1.</b>
1.75 rillig 7827: </td>
7828: <td align="left" valign="top"><p>What is the difference between
7829: <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
7830: <code class="varname">MAKE_FLAGS</code>?</p></td>
7831: </tr>
7832: <tr class="answer">
7833: <td align="left" valign="top"><b></b></td>
7834: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
7835: 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
7836: <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
7837: the <code class="varname">MAKE_PROGRAM</code> when building the
7838: package. [FIXME: What is .MAKEFLAGS for?]</p></td>
7839: </tr>
7840: <tr class="question">
7841: <td align="left" valign="top">
1.81 ! rillig 7842: <a name="id2655171"></a><a name="id2655172"></a><b>20.2.</b>
1.75 rillig 7843: </td>
7844: <td align="left" valign="top"><p>What is the difference between
7845: <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
7846: <code class="varname">MAKE_PROGRAM</code>?</p></td>
7847: </tr>
7848: <tr class="answer">
7849: <td align="left" valign="top"><b></b></td>
7850: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
7851: <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
7852: infrastructure. <code class="varname">GMAKE</code> is the path to GNU
7853: Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
7854: use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
7855: Make program that is used for building the
7856: package.</p></td>
7857: </tr>
7858: <tr class="question">
7859: <td align="left" valign="top">
1.81 ! rillig 7860: <a name="id2655209"></a><a name="id2655210"></a><b>20.3.</b>
1.75 rillig 7861: </td>
7862: <td align="left" valign="top"><p>What is the difference between
7863: <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
7864: <code class="varname">PKGSRC_COMPILER</code>?</p></td>
7865: </tr>
7866: <tr class="answer">
7867: <td align="left" valign="top"><b></b></td>
7868: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
7869: compiler, which can be configured by the pkgsrc user.
7870: <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
7871: <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
7872: path to a compiler, but the type of compiler that should be
1.76 rillig 7873: used. See <code class="filename">mk/compiler.mk</code> for more
1.75 rillig 7874: information about the latter variable.</p></td>
7875: </tr>
7876: <tr class="question">
7877: <td align="left" valign="top">
1.81 ! rillig 7878: <a name="id2655246"></a><a name="id2655248"></a><b>20.4.</b>
1.75 rillig 7879: </td>
7880: <td align="left" valign="top"><p>What is the difference between
7881: <code class="varname">BUILDLINK_LDFLAGS</code>,
7882: <code class="varname">BUILDLINK_LDADD</code> and
7883: <code class="varname">BUILDLINK_LIBS</code>?</p></td>
7884: </tr>
7885: <tr class="answer">
7886: <td align="left" valign="top"><b></b></td>
7887: <td align="left" valign="top"><p>[FIXME]</p></td>
7888: </tr>
7889: <tr class="question">
7890: <td align="left" valign="top">
1.81 ! rillig 7891: <a name="id2655265"></a><a name="id2655266"></a><b>20.5.</b>
1.75 rillig 7892: </td>
7893: <td align="left" valign="top"><p>Why does <span><strong class="command">make show-var
7894: VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
7895: say it's empty?</p></td>
7896: </tr>
7897: <tr class="answer">
7898: <td align="left" valign="top"><b></b></td>
7899: <td align="left" valign="top"><p>For optimization reasons, some variables are only
7900: available in the “<span class="quote">wrapper</span>” phase and later. To
7901: “<span class="quote">simulate</span>” the wrapper phase, append
7902: <span><strong class="command">PKG_PHASE=wrapper</strong></span> to the above
7903: command.</p></td>
7904: </tr>
1.78 rillig 7905: <tr class="question">
7906: <td align="left" valign="top">
1.81 ! rillig 7907: <a name="id2655292"></a><a name="id2655293"></a><b>20.6.</b>
1.78 rillig 7908: </td>
7909: <td align="left" valign="top"><p>What does
7910: <code class="literal">${MASTER_SITE_SOURCEFORGE:=package/}</code> mean? I
7911: don't understand the <code class="literal">:=</code> inside
7912: it.</p></td>
7913: </tr>
7914: <tr class="answer">
7915: <td align="left" valign="top"><b></b></td>
7916: <td align="left" valign="top"><p>The <code class="literal">:=</code> is not really an
7917: assignment operator, like you might expect at first sight.
7918: Instead, it is a degenerate form of
7919: <code class="literal">${LIST:<em class="replaceable"><code>old_string</code></em>=<em class="replaceable"><code>new_string</code></em>}</code>,
7920: 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
7921: may have seen as in <code class="literal">${SRCS:.c=.o}</code>. In the
7922: case of <code class="varname">MASTER_SITE_*</code>,
7923: <em class="replaceable"><code>old_string</code></em> is the empty string and
7924: <em class="replaceable"><code>new_string</code></em> is
7925: <code class="literal">package/</code>. That's where the
7926: <code class="literal">:</code> and the <code class="literal">=</code> fall
7927: together.</p></td>
7928: </tr>
7929: <tr class="question">
7930: <td align="left" valign="top">
1.81 ! rillig 7931: <a name="id2655367"></a><a name="id2655368"></a><b>20.7.</b>
1.78 rillig 7932: </td>
7933: <td align="left" valign="top"><p>Which mailing lists are there for package
7934: developers?</p></td>
7935: </tr>
7936: <tr class="answer">
7937: <td align="left" valign="top"><b></b></td>
7938: <td align="left" valign="top"><div class="variablelist"><dl>
7939: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">tech-pkg</a></span></dt>
7940: <dd><p>This is a list for technical discussions related
7941: to pkgsrc development, e.g. soliciting feedback for changes to
7942: pkgsrc infrastructure, proposed new features, questions related
7943: to porting pkgsrc to a new platform, advice for maintaining a
7944: package, patches that affect many packages, help requests moved
7945: from pkgsrc-users when an infrastructure bug is found,
7946: etc.</p></dd>
7947: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a></span></dt>
7948: <dd><p>All bug reports in category "pkg" sent with
7949: <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
7950: directly; use one of the other mailing
7951: lists.</p></dd>
7952: </dl></div></td>
7953: </tr>
1.80 rillig 7954: <tr class="question">
7955: <td align="left" valign="top">
1.81 ! rillig 7956: <a name="id2655403"></a><a name="id2655404"></a><b>20.8.</b>
1.80 rillig 7957: </td>
7958: <td align="left" valign="top"><p>Where is the pkgsrc
7959: documentation?</p></td>
7960: </tr>
7961: <tr class="answer">
7962: <td align="left" valign="top"><b></b></td>
7963: <td align="left" valign="top">
7964: <p>There are many places where you can find
7965: documentation about pkgsrc:</p>
7966: <div class="itemizedlist"><ul type="disc">
7967: <li><p>The pkgsrc guide (this document) is a collection
7968: of chapters that explain large parts of pkgsrc, but some
7969: chapters tend to be outdated. Which ones they are is hard to
7970: say.</p></li>
7971: <li><p>On the mailing list archives (see <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>), you can find discussions
7972: about certain features, announcements of new parts of the pkgsrc
7973: infrastructure and sometimes even announcements that a certain
7974: feature has been marked as obsolete. The benefit here is that
7975: each message has a date appended to it.</p></li>
7976: <li><p>Many of the files in the
7977: <code class="filename">mk/</code> directory start with a comment that
7978: describes the purpose of the file and how it can be used by the
7979: pkgsrc user and package authors.</p></li>
7980: <li><p>The CVS log messages are a rich source of
7981: information, but they tend to be highly abbreviated, especially
7982: for actions that occur often. Some contain a detailed
7983: description of what has changed, but they are geared towards the
7984: other pkgsrc developers, not towards an average pkgsrc user.
7985: They also only document <span class="emphasis"><em>changes</em></span>, so if you
7986: don't know what has been before, these messages may not be worth
7987: too much to you.</p></li>
7988: <li><p>Some parts of pkgsrc are only “<span class="quote">implicitly
7989: documented</span>”, that is the documentation exists only in the
7990: mind of the developer who wrote the code. To get this
7991: information, use the the <span><strong class="command">cvs annotate</strong></span> command
7992: to see who has written it and ask on the
7993: <code class="literal">tech-pkg</code> mailing list, so that others can
7994: find your questions later (see above). To be sure that the
7995: developer in charge reads the mail, you may CC him or
7996: her.</p></li>
7997: </ul></div>
7998: </td>
7999: </tr>
1.75 rillig 8000: </tbody>
8001: </table>
8002: </div>
8003: </div>
8004: </div>
8005: <div class="part" lang="en">
8006: <div class="titlepage"><div><div><h1 class="title">
8007: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
8008: <div class="partintro" lang="en">
8009: <div></div>
8010: <p>This part of the guide deals with everything
8011: from the infrastructure that is behind the interfaces described
8012: in the developer's guide. A casual package maintainer should not
8013: need anything from this part.</p>
8014: <div class="toc">
8015: <p><b>Table of Contents</b></p>
8016: <dl>
1.77 rillig 8017: <dt><span class="chapter"><a href="#infr.design">21. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 8018: <dd><dl>
1.81 ! rillig 8019: <dt><span class="sect1"><a href="#infr.vardef">21.1. The meaning of variable definitions</a></span></dt>
! 8020: <dt><span class="sect1"><a href="#infr.vardef.problems">21.2. Avoiding problems before they arise</a></span></dt>
! 8021: <dt><span class="sect1"><a href="#infr.var">21.3. Variable evaluation</a></span></dt>
1.75 rillig 8022: <dd><dl>
1.81 ! rillig 8023: <dt><span class="sect2"><a href="#infr.var.load">21.3.1. At load time</a></span></dt>
! 8024: <dt><span class="sect2"><a href="#infr.var.run">21.3.2. At runtime</a></span></dt>
1.75 rillig 8025: </dl></dd>
1.81 ! rillig 8026: <dt><span class="sect1"><a href="#infr.varspec">21.4. How can variables be specified?</a></span></dt>
! 8027: <dt><span class="sect1"><a href="#infr.design.intf">21.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 8028: <dd><dl>
1.81 ! rillig 8029: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.5.1. Procedures with parameters</a></span></dt>
! 8030: <dt><span class="sect2"><a href="#infr.design.intf.action">21.5.2. Actions taken on behalf of parameters</a></span></dt>
! 8031: </dl></dd>
! 8032: <dt><span class="sect1"><a href="#infr.order">21.6. The order in which files are loaded</a></span></dt>
! 8033: <dd><dl>
! 8034: <dt><span class="sect2"><a href="#infr.order.prefs">21.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
! 8035: <dt><span class="sect2"><a href="#infr.order.pkg">21.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75 rillig 8036: </dl></dd>
8037: </dl></dd>
1.77 rillig 8038: <dt><span class="chapter"><a href="#regression">22. Regression tests</a></span></dt>
1.75 rillig 8039: <dd><dl>
1.77 rillig 8040: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
8041: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
8042: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 8043: <dd><dl>
1.77 rillig 8044: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
8045: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 8046: </dl></dd>
8047: </dl></dd>
1.80 rillig 8048: <dt><span class="chapter"><a href="#porting">23. Porting pkgsrc</a></span></dt>
1.75 rillig 8049: <dd><dl>
1.80 rillig 8050: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
8051: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 8052: </dl></dd>
8053: </dl>
8054: </div>
8055: </div>
8056: <div class="chapter" lang="en">
8057: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8058: <a name="infr.design"></a>Chapter 21. Design of the pkgsrc infrastructure</h2></div></div></div>
1.75 rillig 8059: <div class="toc">
8060: <p><b>Table of Contents</b></p>
8061: <dl>
1.81 ! rillig 8062: <dt><span class="sect1"><a href="#infr.vardef">21.1. The meaning of variable definitions</a></span></dt>
! 8063: <dt><span class="sect1"><a href="#infr.vardef.problems">21.2. Avoiding problems before they arise</a></span></dt>
! 8064: <dt><span class="sect1"><a href="#infr.var">21.3. Variable evaluation</a></span></dt>
! 8065: <dd><dl>
! 8066: <dt><span class="sect2"><a href="#infr.var.load">21.3.1. At load time</a></span></dt>
! 8067: <dt><span class="sect2"><a href="#infr.var.run">21.3.2. At runtime</a></span></dt>
! 8068: </dl></dd>
! 8069: <dt><span class="sect1"><a href="#infr.varspec">21.4. How can variables be specified?</a></span></dt>
! 8070: <dt><span class="sect1"><a href="#infr.design.intf">21.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 8071: <dd><dl>
1.81 ! rillig 8072: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.5.1. Procedures with parameters</a></span></dt>
! 8073: <dt><span class="sect2"><a href="#infr.design.intf.action">21.5.2. Actions taken on behalf of parameters</a></span></dt>
1.75 rillig 8074: </dl></dd>
1.81 ! rillig 8075: <dt><span class="sect1"><a href="#infr.order">21.6. The order in which files are loaded</a></span></dt>
1.75 rillig 8076: <dd><dl>
1.81 ! rillig 8077: <dt><span class="sect2"><a href="#infr.order.prefs">21.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
! 8078: <dt><span class="sect2"><a href="#infr.order.pkg">21.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75 rillig 8079: </dl></dd>
8080: </dl>
8081: </div>
8082: <p>The pkgsrc infrastructure consists of many small Makefile
8083: fragments. Each such fragment needs a properly specified
8084: interface. This chapter explains how such an interface looks
8085: like.</p>
8086: <div class="sect1" lang="en">
8087: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.81 ! rillig 8088: <a name="infr.vardef"></a>21.1. The meaning of variable definitions</h2></div></div></div>
! 8089: <p>Whenever a variable is defined in the pkgsrc
! 8090: infrastructure, the location and the way of definition provide
! 8091: much information about the intended use of that variable.
! 8092: Additionally, more documentation may be found in a header
! 8093: comment or in this pkgsrc guide.</p>
! 8094: <p>A special file is
! 8095: <code class="filename">mk/defaults/mk.conf</code>, which lists all
! 8096: variables that are intended to be user-defined. They are either
! 8097: defined using the <code class="literal">?=</code> operator or they are
! 8098: left undefined because defining them to anything would
! 8099: effectively mean “<span class="quote">yes</span>”. All these variables may be
! 8100: overridden by the pkgsrc user in the <code class="varname">MAKECONF</code>
! 8101: file.</p>
! 8102: <p>Outside this file, the following conventions apply:
! 8103: Variables that are defined using the <code class="literal">?=</code>
! 8104: operator may be overridden by a package.</p>
! 8105: <p>Variables that are defined using the <code class="literal">=</code>
! 8106: operator may be used read-only at run-time.</p>
! 8107: <p>Variables whose name starts with an underscore must not be
! 8108: accessed outside the pkgsrc infrastructure at all. They may
! 8109: change without further notice.</p>
! 8110: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
! 8111: <h3 class="title">Note</h3>
! 8112: <p>These conventions are currently not applied
! 8113: consistently to the complete pkgsrc
! 8114: infrastructure.</p>
! 8115: </div>
! 8116: </div>
! 8117: <div class="sect1" lang="en">
! 8118: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 8119: <a name="infr.vardef.problems"></a>21.2. Avoiding problems before they arise</h2></div></div></div>
! 8120: <p>All variables that contain lists of things should default
! 8121: to being empty. Two examples that do not follow this rule are
! 8122: <code class="varname">USE_LANGUAGES</code> and
! 8123: <code class="varname">DISTFILES</code>. These variables cannot simply be
! 8124: modified using the <code class="literal">+=</code> operator in package
! 8125: <code class="filename">Makefile</code>s (or other files included by
! 8126: them), since there is no guarantee whether the variable is
! 8127: already set or not, and what its value is. In the case of
! 8128: <code class="varname">DISTFILES</code>, the packages “<span class="quote">know</span>”
! 8129: the default value and just define it as in the following
! 8130: example.</p>
! 8131: <pre class="programlisting">
! 8132: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
! 8133: </pre>
! 8134: <p>Because of the selection of this default value, the same
! 8135: value appears in many package Makefiles. Similarly for
! 8136: <code class="varname">USE_LANGUAGES</code>, but in this case the default
! 8137: value (“<span class="quote"><code class="literal">c</code></span>”) is so short that it
! 8138: doesn't stand out. Nevertheless it is mentioned in many
! 8139: files.</p>
! 8140: </div>
! 8141: <div class="sect1" lang="en">
! 8142: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 8143: <a name="infr.var"></a>21.3. Variable evaluation</h2></div></div></div>
1.75 rillig 8144: <div class="sect2" lang="en">
8145: <div class="titlepage"><div><div><h3 class="title">
1.81 ! rillig 8146: <a name="infr.var.load"></a>21.3.1. At load time</h3></div></div></div>
1.75 rillig 8147: <p>Variable evaluation takes place either at load time or at
8148: runtime, depending on the context in which they occur. The
8149: contexts where variables are evaluated at load time are:</p>
8150: <div class="itemizedlist"><ul type="disc">
8151: <li><p>The right hand side of the <code class="literal">:=</code>
8152: and <code class="literal">!=</code> operators,</p></li>
8153: <li><p>Make directives like <code class="literal">.if</code> or
8154: <code class="literal">.for</code>,</p></li>
8155: <li><p>Dependency lines.</p></li>
8156: </ul></div>
8157: <p>A special exception are references to the iteration
8158: variables of <code class="literal">.for</code> loops, which are expanded
8159: inline, no matter in which context they appear.</p>
8160: <p>As the values of variables may change during load time,
8161: care must be taken not to evaluate them by accident. Typical
8162: examples for variables that should not be evaluated at load time
8163: are <code class="varname">DEPENDS</code> and
8164: <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
8165: clear, here is an example:</p>
8166: <pre class="programlisting">
8167: CONFIGURE_ARGS= # none
8168: CFLAGS= -O
8169: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
1.1 grant 8170:
1.75 rillig 8171: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
1.1 grant 8172:
1.75 rillig 8173: CFLAGS+= -Wall
8174: </pre>
8175: <p>This code shows how the use of the <code class="literal">:=</code>
8176: operator can quickly lead to unexpected results. The first
8177: paragraph is fairly common code. The second paragraph evaluates
8178: the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
8179: <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
8180: <code class="literal">-Wall</code> is appended to the
8181: <code class="varname">CFLAGS</code>, but this addition will not appear in
8182: <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
8183: paragraphs from above typically occur in completely unrelated
8184: files.</p>
8185: </div>
8186: <div class="sect2" lang="en">
8187: <div class="titlepage"><div><div><h3 class="title">
1.81 ! rillig 8188: <a name="infr.var.run"></a>21.3.2. At runtime</h3></div></div></div>
1.75 rillig 8189: <p>After all the files have been loaded, the values of the
8190: variables cannot be changed anymore. Variables that are used in
8191: the shell commands are expanded at this point.</p>
8192: </div>
8193: </div>
8194: <div class="sect1" lang="en">
8195: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.81 ! rillig 8196: <a name="infr.varspec"></a>21.4. How can variables be specified?</h2></div></div></div>
1.78 rillig 8197: <p>There are many ways in which the definition and use of a
8198: variable can be restricted in order to detect bugs and
8199: violations of the (mostly unwritten) policies. See the
8200: <code class="literal">pkglint</code> developer's documentation for further
8201: details.</p>
8202: </div>
8203: <div class="sect1" lang="en">
8204: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.81 ! rillig 8205: <a name="infr.design.intf"></a>21.5. Designing interfaces for Makefile fragments</h2></div></div></div>
1.76 rillig 8206: <p>Most of the <code class="filename">.mk</code> files fall into one
1.75 rillig 8207: of the following classes. Cases where a file falls into more
8208: than one class should be avoided as it often leads to subtle
8209: bugs.</p>
8210: <div class="sect2" lang="en">
8211: <div class="titlepage"><div><div><h3 class="title">
1.81 ! rillig 8212: <a name="infr.design.intf.proc"></a>21.5.1. Procedures with parameters</h3></div></div></div>
1.75 rillig 8213: <p>In a traditional imperative programming language some of
1.76 rillig 8214: the <code class="filename">.mk</code> files could be described as
1.78 rillig 8215: procedures. They take some input parameters and—after
8216: inclusion—provide a result in output parameters. Since all
1.76 rillig 8217: variables in <code class="filename">Makefile</code>s have global scope
1.75 rillig 8218: care must be taken not to use parameter names that have already
8219: another meaning. For example, <code class="varname">PKGNAME</code> is a
8220: bad choice for a parameter name.</p>
8221: <p>Procedures are completely evaluated at preprocessing time.
8222: That is, when calling a procedure all input parameters must be
8223: completely resolvable. For example,
8224: <code class="varname">CONFIGURE_ARGS</code> should never be an input
8225: parameter since it is very likely that further text will be
8226: added after calling the procedure, which would effectively apply
8227: the procedure to only a part of the variable. Also, references
8228: to other variables wit will be modified after calling the
8229: procedure.</p>
8230: <p>A procedure can declare its output parameters either as
8231: suitable for use in preprocessing directives or as only
8232: available at runtime. The latter alternative is for variables
8233: that contain references to other runtime variables.</p>
8234: <p>Procedures shall be written such that it is possible to
8235: call the procedure more than once. That is, the file must not
8236: contain multiple-inclusion guards.</p>
8237: <p>Examples for procedures are
1.76 rillig 8238: <code class="filename">mk/bsd.options.mk</code> and
8239: <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
1.75 rillig 8240: that the parameters are evaluated at load time, they should be
8241: assigned using the <code class="literal">:=</code> operator, which should
8242: be used only for this purpose.</p>
8243: </div>
8244: <div class="sect2" lang="en">
8245: <div class="titlepage"><div><div><h3 class="title">
1.81 ! rillig 8246: <a name="infr.design.intf.action"></a>21.5.2. Actions taken on behalf of parameters</h3></div></div></div>
1.75 rillig 8247: <p>Action files take some input parameters and may define
8248: runtime variables. They shall not define loadtime variables.
8249: There are action files that are included implicitly by the
8250: pkgsrc infrastructure, while other must be included
8251: explicitly.</p>
8252: <p>An example for action files is
1.76 rillig 8253: <code class="filename">mk/subst.mk</code>.</p>
1.75 rillig 8254: </div>
8255: </div>
1.81 ! rillig 8256: <div class="sect1" lang="en">
! 8257: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 8258: <a name="infr.order"></a>21.6. The order in which files are loaded</h2></div></div></div>
! 8259: <p>Package <code class="filename">Makefile</code>s usually consist of
! 8260: a set of variable definitions, and include the file
! 8261: <code class="filename">../../mk/bsd.pkg.mk</code> in the very last line.
! 8262: Before that, they may also include various other
! 8263: <code class="filename">*.mk</code> files if they need to query the
! 8264: availability of certain features like the type of compiler or
! 8265: the X11 implementation. Due to the heavy use of preprocessor
! 8266: directives like <code class="literal">.if</code> and
! 8267: <code class="literal">.for</code>, the order in which the files are loaded
! 8268: matters.</p>
! 8269: <p>This section describes at which point the various files
! 8270: are loaded and gives reasons for that order.</p>
! 8271: <div class="sect2" lang="en">
! 8272: <div class="titlepage"><div><div><h3 class="title">
! 8273: <a name="infr.order.prefs"></a>21.6.1. The order in <code class="filename">bsd.prefs.mk</code></h3></div></div></div>
! 8274: <p>The very first action in <code class="filename">bsd.pkg.mk</code>
! 8275: is to define some essential variables like
! 8276: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code> and
! 8277: <code class="varname">MACHINE_ARCH</code>.</p>
! 8278: <p>Then, the user settings are loaded from the file specified
! 8279: in <code class="varname">MAKECONF</code>. If the bmake command from pkgsrc
! 8280: is used, <code class="varname">MAKECONF</code> defaults to
! 8281: <code class="filename"><em class="replaceable"><code>${prefix}</code></em>/etc/mk.conf</code>.
! 8282: With the native <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 on NetBSD, it defaults to
! 8283: <code class="filename">/etc/mk.conf</code>. After that, those variables
! 8284: that have not been overridden by the user are loaded from
! 8285: <code class="filename">mk/defaults/mk.conf</code>.</p>
! 8286: <p>After the user settings, the system settings and platform
! 8287: settings are loaded, which may override the user
! 8288: settings.</p>
! 8289: <p>Then, the tool definitions are loaded. The tool wrappers
! 8290: are not yet in effect. This only happens when building a
! 8291: package, so the proper variables must be used instead of the
! 8292: direct tool names.</p>
! 8293: <p>As the last steps, some essential variables from the
! 8294: wrapper and the package system flavor are loaded, as well as the
! 8295: variables that have been cached in earlier phases of a package
! 8296: build.</p>
! 8297: </div>
! 8298: <div class="sect2" lang="en">
! 8299: <div class="titlepage"><div><div><h3 class="title">
! 8300: <a name="infr.order.pkg"></a>21.6.2. The order in <code class="filename">bsd.pkg.mk</code></h3></div></div></div>
! 8301: <p>First, <code class="filename">bsd.prefs.mk</code> is loaded.</p>
! 8302: <p>Then, the various <code class="filename">*-vars.mk</code> files are
! 8303: loaded, which fill default values for those variables that have
! 8304: not been defined by the the package. These variables may later
! 8305: be used even in unrelated files.</p>
! 8306: <p>Then, the file <code class="filename">bsd.pkg.error.mk</code>
! 8307: provides the target <code class="literal">error-check</code> that is added
! 8308: as a special dependency to all other targets that use
! 8309: <code class="varname">DELAYED_ERROR_MSG</code> or
! 8310: <code class="varname">DELAYED_WARNING_MSG</code>.</p>
! 8311: <p>Then, the package-specific hacks from
! 8312: <code class="filename">hacks.mk</code> are included.</p>
! 8313: <p>Then, various other files follow. Most of them don't have
! 8314: any dependencies on what they need to have included before or
! 8315: after them, though some do.</p>
! 8316: <p>The code to check <code class="varname">PKG_FAIL_REASON</code> and
! 8317: <code class="varname">PKG_SKIP_REASON</code> is then executed, which
! 8318: restricts the use of these variables to all the files that have
! 8319: been included before. Appearances in later files will be
! 8320: silently ignored.</p>
! 8321: <p>Then, the files for the main targets are included, in the
! 8322: order of later execution, though the actual order should not
! 8323: matter.</p>
! 8324: <p>At last, some more files are included that don't set any
! 8325: interesting variables but rather just define make targets to be
! 8326: executed.</p>
! 8327: </div>
! 8328: </div>
1.75 rillig 8329: </div>
8330: <div class="chapter" lang="en">
8331: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8332: <a name="regression"></a>Chapter 22. Regression tests</h2></div></div></div>
1.75 rillig 8333: <div class="toc">
8334: <p><b>Table of Contents</b></p>
8335: <dl>
1.77 rillig 8336: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
8337: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
8338: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 8339: <dd><dl>
1.77 rillig 8340: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
8341: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 8342: </dl></dd>
8343: </dl>
8344: </div>
8345: <p>The pkgsrc infrastructure consists of a large codebase,
8346: and there are many corners where every little bit of a file is
8347: well thought out, making pkgsrc likely to fail as soon as
8348: anything is changed near those parts. To prevent most changes
8349: from breaking anything, a suite of regression tests should go
8350: along with every important part of the pkgsrc infrastructure.
8351: This chapter describes how regression tests work in pkgsrc and
8352: how you can add new tests.</p>
8353: <div class="sect1" lang="en">
8354: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8355: <a name="regression.descr"></a>22.1. The regression tests framework</h2></div></div></div>
1.75 rillig 8356: <p></p>
8357: </div>
8358: <div class="sect1" lang="en">
8359: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8360: <a name="regression.run"></a>22.2. Running the regression tests</h2></div></div></div>
1.76 rillig 8361: <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 8362: provides the <span><strong class="command">pkg_regress</strong></span> command. Then you
8363: can simply run that command, which will run all tests in the
1.76 rillig 8364: <code class="filename">regress</code> category.</p>
1.75 rillig 8365: </div>
8366: <div class="sect1" lang="en">
8367: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8368: <a name="regression.new"></a>22.3. Adding a new regression test</h2></div></div></div>
1.76 rillig 8369: <p>Every directory in the <code class="filename">regress</code>
8370: category that contains a file called <code class="filename">spec</code>
1.75 rillig 8371: is considered a regression test. This file is a shell program
8372: that is included by the <span><strong class="command">pkg_regress</strong></span> command.
8373: The following functions can be overridden to suit your
8374: needs.</p>
8375: <div class="sect2" lang="en">
8376: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 8377: <a name="regression.fun.override"></a>22.3.1. Overridable functions</h3></div></div></div>
1.75 rillig 8378: <p>These functions do not take any parameters. They are all
8379: called in “<span class="quote">set -e</span>” mode, so you should be careful
8380: to check the exitcodes of any commands you run in the
8381: test.</p>
8382: <div class="variablelist"><dl>
8383: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
8384: <dd><p>This function prepares the environment for the
8385: test. By default it does nothing.</p></dd>
8386: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
8387: <dd><p>This function runs the actual test. By default,
8388: it calls <code class="varname">TEST_MAKE</code> with the arguments
8389: <code class="varname">MAKEARGS_TEST</code> and writes its output including
8390: error messages into the file
8391: <code class="varname">TEST_OUTFILE</code>.</p></dd>
8392: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
8393: <dd><p>This function is run after the test and is
8394: typically used to compare the actual output from the one that is
8395: expected. It can make use of the various helper functions from
8396: the next section.</p></dd>
8397: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
8398: <dd><p>This function cleans everything up after the
8399: test has been run. By default it does nothing.</p></dd>
8400: </dl></div>
8401: </div>
8402: <div class="sect2" lang="en">
8403: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 8404: <a name="regression.fun.helper"></a>22.3.2. Helper functions</h3></div></div></div>
1.75 rillig 8405: <div class="variablelist"><dl>
8406: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
8407: <dd><p>This function compares the exitcode of the
8408: <span><strong class="command">do_test()</strong></span> function with its first parameter.
8409: If they differ, the test will fail.</p></dd>
8410: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
8411: <dd><p>This function checks for each of its parameters
8412: if the output from <span><strong class="command">do_test()</strong></span> matches the
8413: extended regular expression. If it does not, the test will
8414: fail.</p></dd>
8415: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
8416: <dd><p>This function checks for each of its parameters
8417: if the output from <span><strong class="command">do_test()</strong></span> does
8418: <span class="emphasis"><em>not</em></span> match the extended regular expression.
8419: If any of the regular expressions matches, the test will
8420: fail.</p></dd>
8421: </dl></div>
8422: </div>
8423: </div>
8424: </div>
8425: <div class="chapter" lang="en">
8426: <div class="titlepage"><div><div><h2 class="title">
1.80 rillig 8427: <a name="porting"></a>Chapter 23. Porting pkgsrc</h2></div></div></div>
1.75 rillig 8428: <div class="toc">
8429: <p><b>Table of Contents</b></p>
8430: <dl>
1.80 rillig 8431: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
8432: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 8433: </dl>
8434: </div>
8435: <p>The pkgsrc system has already been ported to many
8436: operating systems, hardware architectures and compilers. This
8437: chapter explains the necessary steps to make pkgsrc even more
8438: portable.</p>
8439: <div class="sect1" lang="en">
8440: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.80 rillig 8441: <a name="porting.opsys"></a>23.1. Porting pkgsrc to a new operating system</h2></div></div></div>
1.75 rillig 8442: <p>To port pkgsrc to a new operating system (called
8443: <code class="literal">MyOS</code> in this example), you need to touch the
8444: following files:</p>
8445: <div class="variablelist"><dl>
1.76 rillig 8446: <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 8447: <dd><p>This file contains some basic definitions, for
8448: example the name of the C
8449: compiler.</p></dd>
1.76 rillig 8450: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
1.75 rillig 8451: <dd><p>Insert code that defines the variables
8452: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
8453: <code class="varname">LOWER_OS_VERSION</code>,
8454: <code class="varname">LOWER_VENDOR</code>,
8455: <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
8456: <code class="varname">APPEND_ELF</code>, and the other variables that
8457: appear in this file.</p></dd>
1.76 rillig 8458: <dt><span class="term"><code class="filename">mk/platform/MyOS.mk</code></span></dt>
1.75 rillig 8459: <dd><p>This file contains the platform-specific
8460: definitions that are used by pkgsrc. Start by copying one of the
8461: other files and edit it to your
8462: needs.</p></dd>
1.76 rillig 8463: <dt><span class="term"><code class="filename">mk/platform/MyOS.pkg.dist</code></span></dt>
1.75 rillig 8464: <dd><p>This file contains a list of directories,
8465: together with their permission bits and ownership. These
8466: directories will be created automatically with every package
8467: that does not explicitly set <code class="varname">NO_MTREE</code>. There
8468: have been some discussions about whether this file is needed at
8469: all, but with no result.</p></dd>
1.76 rillig 8470: <dt><span class="term"><code class="filename">mk/platform/MyOS.x11.dist</code></span></dt>
1.75 rillig 8471: <dd><p>Just copy one of the pre-existing x11.dist files
8472: to your
1.76 rillig 8473: <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
8474: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
1.75 rillig 8475: <dd><p>On some operating systems, the tools that are
8476: provided with the base system are not good enough for pkgsrc.
8477: 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
8478: narrow limit on the line length they can process. Therefore
8479: pkgsrc brings its own tools, which can be enabled
8480: here.</p></dd>
1.76 rillig 8481: <dt><span class="term"><code class="filename">mk/tools/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
1.75 rillig 8482: <dd><p>This file defines the paths to all the tools
8483: that are needed by one or the other package in pkgsrc, as well
8484: as by pkgsrc itself. Find out where these tools are on your
8485: platform and add them.</p></dd>
8486: </dl></div>
8487: <p>Now, you should be able to build some basic packages, like
1.76 rillig 8488: <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 8489: </div>
8490: <div class="sect1" lang="en">
8491: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.80 rillig 8492: <a name="porting.compiler"></a>23.2. Adding support for a new compiler</h2></div></div></div>
1.75 rillig 8493: <p>TODO</p>
8494: </div>
8495: </div>
8496: </div>
8497: <div class="appendix" lang="en">
8498: <div class="titlepage"><div><div><h2 class="title">
8499: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
8500: <div class="toc">
8501: <p><b>Table of Contents</b></p>
8502: <dl>
8503: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
8504: <dd><dl>
8505: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
8506: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
8507: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
8508: <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>
8509: </dl></dd>
8510: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
8511: </dl>
8512: </div>
8513: <p>We checked to find a piece of software that wasn't in the packages
8514: collection, and picked GNU bison. Quite why someone would want to have
8515: <span><strong class="command">bison</strong></span> when Berkeley <span><strong class="command">yacc</strong></span> is already
8516: present in the tree is beyond us, but it's useful for the purposes of
8517: this exercise.</p>
8518: <div class="sect1" lang="en">
8519: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8520: <a name="example-files"></a>A.1. files</h2></div></div></div>
8521: <div class="sect2" lang="en">
8522: <div class="titlepage"><div><div><h3 class="title">
8523: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
8524: <pre class="programlisting">
1.51 rillig 8525: # $NetBSD$
8526: #
1.1 grant 8527:
1.51 rillig 8528: DISTNAME= bison-1.25
8529: CATEGORIES= devel
8530: MASTER_SITES= ${MASTER_SITE_GNU}
1.1 grant 8531:
1.51 rillig 8532: MAINTAINER= thorpej@NetBSD.org
8533: HOMEPAGE= http://www.gnu.org/software/bison/bison.html
8534: COMMENT= GNU yacc clone
1.1 grant 8535:
1.51 rillig 8536: GNU_CONFIGURE= yes
8537: INFO_FILES= bison.info
1.1 grant 8538:
1.51 rillig 8539: .include "../../mk/bsd.pkg.mk"
1.1 grant 8540: </pre>
1.75 rillig 8541: </div>
8542: <div class="sect2" lang="en">
8543: <div class="titlepage"><div><div><h3 class="title">
8544: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
8545: <pre class="programlisting">
1.51 rillig 8546: GNU version of yacc. Can make re-entrant parsers, and numerous other
1.75 rillig 8547: 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 8548: of the NetBSD source tree is beyond me.
1.1 grant 8549: </pre>
1.75 rillig 8550: </div>
8551: <div class="sect2" lang="en">
8552: <div class="titlepage"><div><div><h3 class="title">
8553: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
8554: <pre class="programlisting">
1.51 rillig 8555: @comment $NetBSD$
8556: bin/bison
8557: man/man1/bison.1.gz
8558: share/bison.simple
8559: share/bison.hairy
1.1 grant 8560: </pre>
1.75 rillig 8561: </div>
8562: <div class="sect2" lang="en">
8563: <div class="titlepage"><div><div><h3 class="title">
8564: <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>
8565: <p>The NetBSD package system comes with
1.76 rillig 8566: <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 8567: which helps to check the contents of these
8568: files. After installation it is quite easy to use, just change to the
8569: directory of the package you wish to examine and execute
8570: <span><strong class="command">pkglint</strong></span>:</p>
8571: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
8572: looks fine.</pre>
8573: <p>Depending on the supplied command line arguments (see pkglint(1)),
8574: more checks will be performed. Use e.g. <span><strong class="command">pkglint -Call
8575: -Wall</strong></span> for a very thorough check.</p>
8576: </div>
8577: </div>
8578: <div class="sect1" lang="en">
8579: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8580: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
8581: <p>Create the directory where the package lives,
8582: plus any auxiliary directories:</p>
8583: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
8584: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
8585: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
8586: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
1.76 rillig 8587: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.77 rillig 8588: <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 8589: then continue with fetching the distfile:</p>
8590: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
1.1 grant 8591: >> bison-1.25.tar.gz doesn't seem to exist on this system.
8592: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
8593: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8594: ftp: Error retrieving file: 500 Internal error
8595:
8596: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
8597: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8598: ftp: Error retrieving file: 500 Internal error
8599:
8600: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
8601: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
1.75 rillig 8602: Successfully retrieved file.</pre>
8603: <p>Generate the checksum of the distfile into
1.76 rillig 8604: <code class="filename">distinfo</code>:</p>
1.75 rillig 8605: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makesum</code></strong></pre>
8606: <p>Now compile:</p>
8607: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 8608: >> Checksum OK for bison-1.25.tar.gz.
8609: ===> Extracting for bison-1.25
8610: ===> Patching for bison-1.25
8611: ===> Ignoring empty patch directory
8612: ===> Configuring for bison-1.25
8613: creating cache ./config.cache
8614: checking for gcc... cc
8615: checking whether we are using GNU C... yes
8616: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
8617: checking how to run the C preprocessor... cc -E
8618: checking for minix/config.h... no
8619: checking for POSIXized ISC... no
8620: checking whether cross-compiling... no
8621: checking for ANSI C header files... yes
8622: checking for string.h... yes
8623: checking for stdlib.h... yes
8624: checking for memory.h... yes
8625: checking for working const... yes
8626: checking for working alloca.h... no
8627: checking for alloca... yes
8628: checking for strerror... yes
8629: updating cache ./config.cache
8630: creating ./config.status
8631: creating Makefile
8632: ===> Building for bison-1.25
8633: 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
8634: 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
8635: 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
8636: 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
8637: 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 8638: 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 8639: 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
8640: 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
8641: 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
8642: 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
8643: 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
8644: 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
8645: 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
8646: 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
8647: 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
8648: 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
8649: 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
8650: 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
8651: 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
8652: 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
8653: 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
8654: 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
8655: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
8656: rm -f bison.s1
1.75 rillig 8657: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1</pre>
8658: <p>Everything seems OK, so install the files:</p>
8659: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 8660: >> Checksum OK for bison-1.25.tar.gz.
8661: ===> Installing for bison-1.25
8662: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
8663: rm -f /usr/pkg/bin/bison
8664: cd /usr/pkg/share; rm -f bison.simple bison.hairy
8665: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
8666: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
8667: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
8668: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
8669: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
8670: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
1.75 rillig 8671: ===> Registering installation for bison-1.25</pre>
8672: <p>You can now use bison, and also - if you decide so - remove it with
8673: <span><strong class="command">pkg_delete bison</strong></span>. Should you decide that you want a
8674: binary package, do this now:</p>
8675: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 8676: >> Checksum OK for bison-1.25.tar.gz.
8677: ===> Building package for bison-1.25
8678: Creating package bison-1.25.tgz
8679: Registering depends:.
1.75 rillig 8680: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
8681: <p>Now that you don't need the source and object files
8682: any more, clean up:</p>
8683: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
8684: ===> Cleaning for bison-1.25</pre>
8685: </div>
8686: </div>
8687: <div class="appendix" lang="en">
8688: <div class="titlepage"><div><div><h2 class="title">
8689: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
8690: <div class="toc">
8691: <p><b>Table of Contents</b></p>
8692: <dl>
8693: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
8694: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
8695: </dl>
8696: </div>
8697: <div class="sect1" lang="en">
8698: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8699: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
8700: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 8701: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8702: => figlet221.tar.gz doesn't seem to exist on this system.
8703: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
8704: => [172219 bytes]
8705: Connected to ftp.plig.net.
8706: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
8707: 331 Guest login ok, send your complete e-mail address as password.
8708: 230-You are user #5 of 500 simultaneous users allowed.
8709: 230-
1.68 rillig 8710: 230- ___ _ _ _
8711: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
1.1 grant 8712: 230- | _| _| . |_| . | | | . |_| . | _| . |
8713: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
8714: 230- |_| |_| |___| |___|
8715: 230-
8716: 230-** Welcome to ftp.plig.org **
8717: 230-
8718: 230-Please note that all transfers from this FTP site are logged. If you
8719: 230-do not like this, please disconnect now.
8720: 230-
8721: 230-This arhive is available via
8722: 230-
8723: 230-HTTP: http://ftp.plig.org/
8724: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
8725: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
8726: 230-
8727: 230-Please email comments, bug reports and requests for packages to be
1.68 rillig 8728: 230-mirrored to ftp-admin@plig.org.
1.1 grant 8729: 230-
8730: 230-
8731: 230 Logged in anonymously.
8732: Remote system type is UNIX.
8733: Using binary mode to transfer files.
8734: 200 Type okay.
8735: 250 "/pub" is new cwd.
8736: 250-"/pub/figlet" is new cwd.
8737: 250-
8738: 250-Welcome to the figlet archive at ftp.figlet.org
1.68 rillig 8739: 250-
1.75 rillig 8740: 250- ftp://ftp.figlet.org/pub/figlet/
1.1 grant 8741: 250-
8742: 250-The official FIGlet web page is:
1.75 rillig 8743: 250- http://www.figlet.org/
1.1 grant 8744: 250-
8745: 250-If you have questions, please mailto:info@figlet.org. If you want to
8746: 250-contribute a font or something else, you can email us.
1.68 rillig 8747: 250
1.1 grant 8748: 250 "/pub/figlet/program" is new cwd.
8749: 250 "/pub/figlet/program/unix" is new cwd.
8750: local: figlet221.tar.gz remote: figlet221.tar.gz
8751: 502 Unimplemented command.
8752: 227 Entering Passive Mode (195,40,6,41,246,104)
8753: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
8754: 38% |************** | 65800 64.16 KB/s 00:01 ETA
8755: 226 Transfer completed.
8756: 172219 bytes received in 00:02 (75.99 KB/s)
8757: 221 Goodbye.
8758: => Checksum OK for figlet221.tar.gz.
8759: ===> Extracting for figlet-2.2.1nb2
8760: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
8761: ===> Patching for figlet-2.2.1nb2
8762: ===> Applying pkgsrc patches for figlet-2.2.1nb2
8763: ===> Overriding tools for figlet-2.2.1nb2
8764: ===> Creating toolchain wrappers for figlet-2.2.1nb2
8765: ===> Configuring for figlet-2.2.1nb2
8766: ===> Building for figlet-2.2.1nb2
8767: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
8768: chmod a+x figlet
8769: gcc -O2 -o chkfont chkfont.c
8770: => Unwrapping files-to-be-installed.
1.14 xtraeme 8771: <code class="prompt">#</code>
1.75 rillig 8772: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 8773: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8774: ===> Installing for figlet-2.2.1nb2
8775: install -d -o root -g wheel -m 755 /usr/pkg/bin
8776: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
8777: mkdir -p /usr/pkg/share/figlet
8778: cp figlet /usr/pkg/bin
8779: cp chkfont /usr/pkg/bin
8780: chmod 555 figlist showfigfonts
8781: cp figlist /usr/pkg/bin
8782: cp showfigfonts /usr/pkg/bin
8783: cp fonts/*.flf /usr/pkg/share/figlet
8784: cp fonts/*.flc /usr/pkg/share/figlet
8785: cp figlet.6 /usr/pkg/man/man6
8786: ===> Registering installation for figlet-2.2.1nb2
1.75 rillig 8787: <code class="prompt">#</code></pre>
8788: </div>
8789: <div class="sect1" lang="en">
8790: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8791: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
8792: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 8793: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8794: ===> Packaging figlet-2.2.1nb2
8795: ===> Building binary package for figlet-2.2.1nb2
8796: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
8797: Using SrcDir value of /usr/pkg
1.68 rillig 8798: Registering depends:.
1.75 rillig 8799: <code class="prompt">#</code></pre>
8800: </div>
8801: </div>
8802: <div class="appendix" lang="en">
8803: <div class="titlepage"><div><div><h2 class="title">
1.76 rillig 8804: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
8805: <div class="toc">
8806: <p><b>Table of Contents</b></p>
8807: <dl>
8808: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
8809: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
8810: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
8811: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
8812: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
8813: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
8814: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
8815: source packages</a></span></dt>
8816: </dl>
8817: </div>
8818: <p>As in other big projects, the directory layout of pkgsrc
8819: is quite complex for newbies. This chapter explains where you
8820: find things on the FTP server. The base directory on
8821: <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>.
8822: This directory contains some subdirectories, which are explained
8823: below.</p>
8824: <div class="sect1" lang="en">
8825: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8826: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
8827: <p>For those who only want to manage binary packages on
8828: systems other than NetBSD, we provide the package management
8829: tools in a separate, small tar file.</p>
8830: </div>
8831: <div class="sect1" lang="en">
8832: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8833: <a name="ftp-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
8834: <p>The directory <code class="filename">distfiles</code> contains lots
8835: of archive files from all pkgsrc packages, which are mirrored
8836: here. The subdirectories are called after their package names
8837: and are used when the distributed files have names that don't
8838: explicitly contain a version number or are otherwise too generic
8839: (for example <code class="filename">release.tar.gz</code>).</p>
8840: </div>
8841: <div class="sect1" lang="en">
8842: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8843: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
8844: <p>This directory is currently not in use.</p>
8845: </div>
8846: <div class="sect1" lang="en">
8847: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8848: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
8849: <p>This directory contains things that individual pkgsrc
8850: developers find worth publishing.</p>
8851: </div>
8852: <div class="sect1" lang="en">
8853: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8854: <a name="ftp-packages"></a>C.5. <code class="filename">packages*</code>: Binary packages</h2></div></div></div>
8855: <p>These directories contain binary packages. Those
8856: directories that have a branch name
8857: (200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>)
8858: contain packages from that particular branch. The directory
8859: <code class="filename">packages</code> contains binary packages from
8860: pkgsrc-current. (However, this does not necessarily mean that
8861: the packages are still current anymore.)</p>
8862: <p>Below the <code class="filename">packages*</code> directories are
8863: directories that distinguish the packages by operating system
8864: and version, the next directory level specifies the hardware
8865: architecture.</p>
8866: <p>In each of the platform-specific directories, there is a
8867: whole binary packages collection. It has a directory called
8868: <code class="filename">All</code> which contains all binary packages.
8869: Besides that, there are various category directories that
8870: contain symbolic links to the real binary packages.</p>
8871: </div>
8872: <div class="sect1" lang="en">
8873: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8874: <a name="ftp-source"></a>C.6. <code class="filename">current</code>,
8875: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
8876: source packages</h2></div></div></div>
8877: <p>These directories contain the “<span class="quote">real</span>” pkgsrc,
8878: that is the files that define how to create binary packages from
8879: source archives.</p>
8880: <p>The directory <code class="filename">pkgsrc</code> contains a
8881: snapshot of the CVS repository, which is updated on a regularly
8882: basis. The file <code class="filename">pkgsrc.tar.gz</code> contains the
8883: same as the directory, ready to be downloaded as a whole.</p>
8884: <p>In the directories for the quarterly branches, there is an
8885: additional file called
8886: <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
8887: which contains the state of pkgsrc when it was branched.</p>
8888: </div>
1.75 rillig 8889: </div>
8890: <div class="appendix" lang="en">
8891: <div class="titlepage"><div><div><h2 class="title">
8892: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
8893: <div class="toc">
8894: <p><b>Table of Contents</b></p>
8895: <dl>
1.79 rillig 8896: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75 rillig 8897: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
8898: </dl>
8899: </div>
1.79 rillig 8900: <p>This section contains information on editing the pkgsrc
8901: guide itself.</p>
1.75 rillig 8902: <div class="sect1" lang="en">
8903: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.79 rillig 8904: <a name="targets"></a>D.1. Make targets</h2></div></div></div>
8905: <p>The pkgsrc guide's source code is stored in
8906: <code class="filename">pkgsrc/doc/guide/files</code>, and several files
8907: are created from it:</p>
8908: <div class="itemizedlist"><ul type="disc">
8909: <li><p><code class="filename">pkgsrc/doc/pkgsrc.txt</code></p></li>
8910: <li><p><code class="filename">pkgsrc/doc/pkgsrc.html</code></p></li>
8911: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/</a></p></li>
8912: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</a>:
8913: The PDF version of the pkgsrc guide.</p></li>
8914: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</a>:
8915: PostScript version of the pkgsrc guide.</p></li>
1.75 rillig 8916: </ul></div>
8917: </div>
8918: <div class="sect1" lang="en">
8919: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8920: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
1.79 rillig 8921: <p>The procedure to edit the pkgsrc guide is:</p>
8922: <div class="procedure"><ol type="1">
8923: <li><p>Make sure you have the packages needed to
8924: re-generate the pkgsrc guide (and other XML-based NetBSD
8925: 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
8926: 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
8927: PostScript and PDF versions. You will need both packages
8928: installed, to make sure documentation is consistent across all
8929: formats.</p></li>
8930: <li><p>Run <span><strong class="command">cd doc/guide</strong></span> to get to the
8931: right directory. All further steps will take place
8932: here.</p></li>
8933: <li><p>Edit the XML file(s) in
8934: <code class="filename">files/</code>.</p></li>
8935: <li><p>Run <span><strong class="command">bmake</strong></span> to check the pkgsrc
8936: guide for valid XML and to build the final output files. If you
8937: get any errors at this stage, you can just edit the files, as
8938: there are only symbolic links in the working directory, pointing
8939: to the files in <code class="filename">files/</code>.</p></li>
8940: <li><p><span><strong class="command">(cd files && cvs
8941: commit)</strong></span></p></li>
8942: <li><p>Run <span><strong class="command">bmake clean && bmake</strong></span> to
8943: regenerate the output files with the proper RCS
8944: Ids.</p></li>
8945: <li><p>Run <span><strong class="command">(cd .. && cvs update pkgsrc.*)
8946: && bmake install-doc</strong></span> to put the generated
8947: files into <code class="filename">pkgsrc/doc</code>.</p></li>
8948: <li><p>Run <span><strong class="command">(cd .. && cvs commit -m
8949: "regenerated." pkgsrc.{html,txt})</strong></span> to commit the
8950: generated documentation.</p></li>
8951: <li><p>Run <span><strong class="command">(cd
8952: ../../../htdocs/Documentation/pkgsrc && cvs update)
8953: && bmake install-htdocs</strong></span> to generate all the
8954: files for the web server.</p></li>
8955: <li><p>Run <span><strong class="command">(cd
8956: ../../../htdocs/Documentation/pkgsrc && cvs commit -m
8957: "regenerated.")</strong></span> to update the files on the web server.
8958: If you have added a chapter, don't forget to run <span><strong class="command">cvs
8959: add *.html</strong></span> before you commit the files.</p></li>
8960: </ol></div>
1.75 rillig 8961: </div>
8962: </div>
8963: </div></body>
1.1 grant 8964: </html>
CVSweb <webmaster@jp.NetBSD.org>