Annotation of pkgsrc/doc/pkgsrc.html, revision 1.78
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.77 rillig 38: <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.19 2006/06/01 08:39:03 rillig Exp $</p></div>
1.76 rillig 39: <div><div class="abstract">
1.75 rillig 40: <p class="title"><b>Abstract</b></p>
41: <p>pkgsrc is a centralized package management system for
42: Unix-like operating systems. This guide provides information for
43: users and developers of pkgsrc. It covers installation of binary
44: and source packages, creation of binary and source packages and
45: a high-level overview about the infrastructure.</p>
46: </div></div>
47: </div>
48: <hr>
49: </div>
50: <div class="toc">
51: <p><b>Table of Contents</b></p>
52: <dl>
53: <dt><span class="chapter"><a href="#introduction">1. What is pkgsrc?</a></span></dt>
54: <dd><dl>
55: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
56: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
57: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.78 ! rillig 58: <dd><dl>
! 59: <dt><span class="sect2"><a href="#term.abbrev">1.3.1. Commonly used abbreviations</a></span></dt>
! 60: <dt><span class="sect2"><a href="#term.people">1.3.2. People involved in pkgsrc</a></span></dt>
! 61: </dl></dd>
1.75 rillig 62: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
63: </dl></dd>
64: <dt><span class="part"><a href="#users-guide">I. The pkgsrc user's guide</a></span></dt>
65: <dd><dl>
66: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
67: <dd><dl>
68: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
69: <dd><dl>
70: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
71: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
72: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
73: </dl></dd>
74: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
75: <dd><dl>
76: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
77: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
78: </dl></dd>
79: </dl></dd>
80: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
81: <dd><dl>
82: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
83: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
84: <dd><dl>
85: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
86: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
87: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
88: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
89: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
90: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
91: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
92: </dl></dd>
93: </dl></dd>
94: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
95: <dd><dl>
96: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
97: <dd><dl>
98: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
99: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
100: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
101: </dl></dd>
102: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
103: <dd><dl>
104: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
105: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
106: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
107: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
108: </dl></dd>
109: </dl></dd>
110: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
111: <dd><dl>
112: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
113: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 ! rillig 114: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
! 115: <dd><dl><dt><span class="sect2"><a href="#conf.cflags">5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt></dl></dd>
! 116: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
! 117: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 118: </dl></dd>
119: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
120: <dd><dl>
121: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
122: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
123: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
124: <dd><dl>
125: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
126: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
127: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
128: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
129: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
130: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
131: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
132: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
133: </dl></dd>
134: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
135: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
136: </dl></dd>
137: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
138: <dd><dl>
139: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
140: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
141: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
142: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
143: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
144: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
145: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
146: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
147: <dt><span class="sect1"><a href="#passive-ftp">7.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
148: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
149: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
150: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
151: <dt><span class="sect1"><a href="#bsd.own.mk-missing">7.12. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</a></span></dt>
152: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
153: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
154: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
155: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
156: </dl></dd>
157: </dl></dd>
158: <dt><span class="part"><a href="#developers-guide">II. The pkgsrc developer's guide</a></span></dt>
159: <dd><dl>
1.77 rillig 160: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
161: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75 rillig 162: <dd><dl>
1.77 rillig 163: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
164: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
165: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
166: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
167: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 ! rillig 168: <dd><dl>
! 169: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
! 170: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
! 171: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
! 172: </dl></dd>
1.77 rillig 173: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
174: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
175: </dl></dd>
176: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
177: <dd><dl>
178: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
179: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
180: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
181: <dd><dl>
182: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
183: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
184: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
185: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
186: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
187: </dl></dd>
188: </dl></dd>
189: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
190: <dd><dl>
191: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
192: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
193: <dt><span class="sect1"><a href="#print-PLIST">11.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
194: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
195: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
196: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
197: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
198: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
199: </dl></dd>
200: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
201: <dd><dl>
202: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
203: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
204: <dd><dl>
205: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
206: <dt><span class="sect2"><a href="#updating-buildlink-depends">12.2.2. Updating <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code> in <code class="filename">buildlink3.mk</code> files</a></span></dt>
207: </dl></dd>
208: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
209: <dd><dl>
210: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">12.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
211: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
212: </dl></dd>
213: </dl></dd>
214: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
215: <dd><dl>
216: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
217: <dd><dl>
218: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
219: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
220: </dl></dd>
221: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
222: <dd><dl>
223: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
224: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
225: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
226: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
227: </dl></dd>
228: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
229: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">13.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
230: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
231: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
232: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
233: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
234: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">13.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
235: </dl></dd>
236: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
237: <dd><dl>
238: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
239: <dt><span class="sect1"><a href="#converting-to-options">14.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
240: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
241: </dl></dd>
242: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
243: <dd><dl>
244: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
245: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
246: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
247: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
248: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
249: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
250: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
251: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
252: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
253: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
254: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
255: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
256: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
257: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
258: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
259: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
260: </dl></dd>
261: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
262: <dd><dl>
263: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
264: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
265: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
266: </dl></dd>
267: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
268: <dd><dl>
269: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
270: <dd><dl>
1.78 ! rillig 271: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
! 272: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">17.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
! 273: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
! 274: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
! 275: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
! 276: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
! 277: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
! 278: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
! 279: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
! 280: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
! 281: <dt><span class="sect2"><a href="#bumping-pkgrevision">17.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
1.77 rillig 282: </dl></dd>
283: <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>
284: <dd><dl>
285: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
286: <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>
287: </dl></dd>
288: <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>
289: <dd><dl>
290: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
291: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
292: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
293: </dl></dd>
294: <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>
295: <dd><dl>
1.78 ! rillig 296: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
! 297: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
! 298: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
! 299: </dl></dd>
! 300: <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>
! 301: <dd><dl>
! 302: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
! 303: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
! 304: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
! 305: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
! 306: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
! 307: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
! 308: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
! 309: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
! 310: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
! 311: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
! 312: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
! 313: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
! 314: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
! 315: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
! 316: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
! 317: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
! 318: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.77 rillig 319: </dl></dd>
1.78 ! rillig 320: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.77 rillig 321: </dl></dd>
322: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
323: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
324: <dd><dl>
325: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
326: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
327: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
328: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
329: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
330: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 331: </dl></dd>
1.77 rillig 332: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.75 rillig 333: </dl></dd>
334: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
335: <dd><dl>
1.77 rillig 336: <dt><span class="chapter"><a href="#infr.design">21. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 337: <dd><dl>
1.77 rillig 338: <dt><span class="sect1"><a href="#infr.var">21.1. Variable evaluation</a></span></dt>
1.75 rillig 339: <dd><dl>
1.77 rillig 340: <dt><span class="sect2"><a href="#infr.var.load">21.1.1. At load time</a></span></dt>
341: <dt><span class="sect2"><a href="#infr.var.run">21.1.2. At runtime</a></span></dt>
1.75 rillig 342: </dl></dd>
1.78 ! rillig 343: <dt><span class="sect1"><a href="#infr.varspec">21.2. How can variables be specified?</a></span></dt>
! 344: <dt><span class="sect1"><a href="#infr.design.intf">21.3. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 345: <dd><dl>
1.78 ! rillig 346: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.3.1. Procedures with parameters</a></span></dt>
! 347: <dt><span class="sect2"><a href="#infr.design.intf.action">21.3.2. Actions taken on behalf of parameters</a></span></dt>
1.75 rillig 348: </dl></dd>
349: </dl></dd>
1.77 rillig 350: <dt><span class="chapter"><a href="#regression">22. Regression tests</a></span></dt>
1.75 rillig 351: <dd><dl>
1.77 rillig 352: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
353: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
354: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 355: <dd><dl>
1.77 rillig 356: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
357: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 358: </dl></dd>
359: </dl></dd>
1.77 rillig 360: <dt><span class="chapter"><a href="#porting">23. Porting pkgsrc</a></span></dt>
1.75 rillig 361: <dd><dl>
1.77 rillig 362: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
363: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 364: </dl></dd>
365: </dl></dd>
366: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
367: <dd><dl>
368: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
369: <dd><dl>
370: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
371: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
372: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
373: <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>
374: </dl></dd>
375: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
376: </dl></dd>
377: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
378: <dd><dl>
379: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
380: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
381: </dl></dd>
1.76 rillig 382: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
383: <dd><dl>
384: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
385: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
386: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
387: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
388: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
389: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
390: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
391: source packages</a></span></dt>
392: </dl></dd>
1.75 rillig 393: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
394: <dd><dl>
395: <dt><span class="sect1"><a href="#targets">D.1. Targets</a></span></dt>
396: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
397: </dl></dd>
398: </dl>
399: </div>
400: <div class="chapter" lang="en">
401: <div class="titlepage"><div><div><h2 class="title">
402: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
403: <div class="toc">
404: <p><b>Table of Contents</b></p>
405: <dl>
406: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
407: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
408: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.78 ! rillig 409: <dd><dl>
! 410: <dt><span class="sect2"><a href="#term.abbrev">1.3.1. Commonly used abbreviations</a></span></dt>
! 411: <dt><span class="sect2"><a href="#term.people">1.3.2. People involved in pkgsrc</a></span></dt>
! 412: </dl></dd>
1.75 rillig 413: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
414: </dl>
415: </div>
416: <div class="sect1" lang="en">
417: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
418: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
419: <p> There is a lot of software freely available for Unix-based
420: systems, which usually runs on NetBSD and other Unix-flavoured
421: systems, too, sometimes with some modifications. The NetBSD
422: Packages Collection (pkgsrc) incorporates any such changes
423: necessary to make that software run, and makes the installation
424: (and de-installation) of the software package easy by means of a
425: single command. </p>
426: <p>Once the software
427: has been built, it is manipulated with the <span><strong class="command">pkg_*</strong></span> tools
428: so that installation
429: and de-installation, printing of an inventory of all installed packages and
430: retrieval of one-line comments or more verbose descriptions are all
431: simple.</p>
432: <p>pkgsrc currently contains several thousand packages,
433: including:</p>
434: <div class="itemizedlist"><ul type="disc">
1.76 rillig 435: <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 436: web server</p></li>
1.76 rillig 437: <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 438: web browser</p></li>
1.76 rillig 439: <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 440: Desktop Environment</p></li>
1.76 rillig 441: <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 442: Desktop Environment</p></li>
443: </ul></div>
444: <p>...just to name a few.</p>
445: <p>pkgsrc has built-in support for handling varying dependencies,
446: such as pthreads and X11, and extended features such as IPv6 support on
447: a range of platforms.</p>
448: <p>pkgsrc was derived from FreeBSD's ports system, and
449: initially developed for NetBSD only. Since then, pkgsrc has
450: grown a lot, and now supports the following platforms:</p>
451: <div class="itemizedlist"><ul type="disc">
452: <li><p><a href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
453: (<a href="http://www.apple.com/macosx/" target="_top">Mac OS X</a>)</p></li>
454: <li><p><a href="http://www.DragonFlyBSD.org/" target="_top">DragonFly BSD</a></p></li>
455: <li><p><a href="http://www.FreeBSD.org/" target="_top">FreeBSD</a></p></li>
456: <li><p>Microsoft Windows, via <a href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a></p></li>
457: <li><p><a href="http://www.sgi.com/software/irix6.5/" target="_top">IRIX</a></p></li>
458: <li><p><a href="http://www.linux.org/" target="_top">Linux</a></p></li>
459: <li><p><a href="http://www.NetBSD.org/" target="_top">NetBSD</a> (of
460: course)</p></li>
461: <li><p><a href="http://h30097.www3.hp.com/" target="_top">Tru64</a>
462: (Digital UNIX, OSF1)</p></li>
463: <li><p><a href="http://www.openbsd.org/" target="_top">OpenBSD</a></p></li>
464: <li><p><a href="http://www.sun.com/solaris/" target="_top">Solaris</a></p></li>
465: </ul></div>
466: </div>
467: <div class="sect1" lang="en">
468: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
469: <a name="overview"></a>1.2. Overview</h2></div></div></div>
470: <p>This document is divided into three parts. The first,
471: <a href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
472: describes how one can use one of the packages in the Package
473: Collection, either by installing a precompiled binary package,
474: or by building one's own copy using the NetBSD package system.
475: 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
476: package so it can be easily built by other NetBSD users without
477: knowing about the package's building details. The third part,
478: <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
479: is intended for those who want to understand how pkgsrc is
480: implemented.</p>
481: <p>This document is available in various formats:
482: <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>
483: </div>
484: <div class="sect1" lang="en">
485: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
486: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
487: <p>There has been a lot of talk about “<span class="quote">ports</span>”,
488: “<span class="quote">packages</span>”, etc. so far. Here is a description of all the
489: terminology used within this document.</p>
490: <div class="variablelist"><dl>
491: <dt><span class="term">Package</span></dt>
492: <dd><p>A set of files and building instructions
493: that describe what's necessary
494: to build a certain piece of software using
495: pkgsrc. Packages are traditionally stored under
1.76 rillig 496: <code class="filename">/usr/pkgsrc</code>.</p></dd>
1.75 rillig 497: <dt><span class="term">The NetBSD package system</span></dt>
498: <dd><p>
499: This is the former name of “<span class="quote">pkgsrc</span>”. It is
500: part of the NetBSD operating system and can be bootstrapped to
501: run on non-NetBSD operating systems as well. It handles
502: building (compiling), installing, and removing of
503: packages.
504: </p></dd>
505: <dt><span class="term">Distfile</span></dt>
506: <dd><p>This term describes the file or files that are
507: provided by the author of the piece of software to
508: distribute his work. All the changes necessary to build on
509: NetBSD are reflected in the corresponding package. Usually
510: the distfile is in the form of a compressed tar-archive,
511: but other types are possible, too. Distfiles are usually
512: stored below
1.76 rillig 513: <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
1.75 rillig 514: <dt><span class="term">Port</span></dt>
515: <dd><p>This is the term used by FreeBSD and OpenBSD people
516: for what we call a package.
517: In NetBSD terminology, “<span class="quote">port</span>” refers to a different
518: architecture.</p></dd>
519: <dt><span class="term">Precompiled/binary package</span></dt>
520: <dd>
521: <p>A set of binaries built with pkgsrc from a distfile
1.76 rillig 522: and stuffed together in a single <code class="filename">.tgz</code>
1.75 rillig 523: file so it can be installed on machines of the same
524: machine architecture without the need to
525: recompile. Packages are usually generated in
1.76 rillig 526: <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.75 rillig 527: an archive on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
528: <p>Sometimes, this is referred to by the term “<span class="quote">package</span>” too,
529: especially in the context of precompiled packages.</p>
530: </dd>
531: <dt><span class="term">Program</span></dt>
532: <dd><p>The piece of software to be installed which will be constructed from
533: all the files in the distfile by the actions defined in the
534: corresponding package.</p></dd>
535: </dl></div>
536: <div class="sect2" lang="en">
537: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 538: <a name="term.abbrev"></a>1.3.1. Commonly used abbreviations</h3></div></div></div>
! 539: <div class="variablelist"><dl>
! 540: <dt><span class="term">ICE</span></dt>
! 541: <dd><p>Internal Compiler
! 542: Error</p></dd>
! 543: </dl></div>
! 544: </div>
! 545: <div class="sect2" lang="en">
! 546: <div class="titlepage"><div><div><h3 class="title">
! 547: <a name="term.people"></a>1.3.2. People involved in pkgsrc</h3></div></div></div>
1.75 rillig 548: <div class="variablelist"><dl>
549: <dt><span class="term">pkgsrc users</span></dt>
550: <dd>
551: <p>The
552: pkgsrc users are people who use the packages provided by pkgsrc.
553: Typically they are system administrators. The people using the
554: software that is inside the packages (maybe called “<span class="quote">end
555: users</span>”) are not covered by the pkgsrc guide.</p>
556: <p>There are two kinds of pkgsrc users: Some only want to
557: install pre-built binary packages. Others build the pkgsrc
558: packages from source, either for installing them directly or for
559: 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
560: documentation.</p>
561: </dd>
562: <dt><span class="term">package maintainers</span></dt>
563: <dd><p>A
564: 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>
565: <dt><span class="term">infrastructure developers</span></dt>
566: <dd><p>These people are involved in all those files
1.76 rillig 567: that live in the <code class="filename">mk/</code> directory and below.
1.75 rillig 568: 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,
569: too.</p></dd>
570: </dl></div>
571: </div>
572: </div>
573: <div class="sect1" lang="en">
574: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
575: <a name="typography"></a>1.4. Typography</h2></div></div></div>
576: <p>When giving examples for commands, shell prompts are used to
577: show if the command should/can be issued as root, or if
578: “<span class="quote">normal</span>” user privileges are sufficient. We use a
579: <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
580: shell prompt, assuming they use the C-shell or tcsh.</p>
581: </div>
582: </div>
583: <div class="part" lang="en">
584: <div class="titlepage"><div><div><h1 class="title">
585: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
586: <div class="toc">
587: <p><b>Table of Contents</b></p>
588: <dl>
589: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
590: <dd><dl>
591: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
592: <dd><dl>
593: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
594: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
595: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
596: </dl></dd>
597: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
598: <dd><dl>
599: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
600: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
601: </dl></dd>
602: </dl></dd>
603: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
604: <dd><dl>
605: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
606: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
607: <dd><dl>
608: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
609: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
610: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
611: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
612: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
613: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
614: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
615: </dl></dd>
616: </dl></dd>
617: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
618: <dd><dl>
619: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
620: <dd><dl>
621: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
622: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
623: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
624: </dl></dd>
625: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
626: <dd><dl>
627: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
628: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
629: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
630: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
631: </dl></dd>
632: </dl></dd>
633: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
634: <dd><dl>
635: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
636: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 ! rillig 637: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
! 638: <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>
! 639: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
! 640: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 641: </dl></dd>
642: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
643: <dd><dl>
644: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
645: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
646: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
647: <dd><dl>
648: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
649: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
650: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
651: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
652: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
653: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
654: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
655: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
656: </dl></dd>
657: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
658: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
659: </dl></dd>
660: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
661: <dd><dl>
662: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
663: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
664: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
665: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
666: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
667: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
668: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
669: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
670: <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>
671: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
672: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
673: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
674: <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>
675: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
676: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
677: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
678: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
679: </dl></dd>
680: </dl>
681: </div>
682: <div class="chapter" lang="en">
683: <div class="titlepage"><div><div><h2 class="title">
684: <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
685: <div class="toc">
686: <p><b>Table of Contents</b></p>
687: <dl>
688: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
689: <dd><dl>
690: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
691: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
692: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
693: </dl></dd>
694: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
695: <dd><dl>
696: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
697: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
698: </dl></dd>
699: </dl>
700: </div>
701: <p>The most common location where pkgsrc is installed is
1.76 rillig 702: <code class="filename">/usr/pkgsrc</code> for the “<span class="quote">package
703: sources</span>” and <code class="filename">/usr/pkg</code> for the
1.75 rillig 704: installed binary packages. You are though free to install the
705: sources and binary packages wherever you want in your
706: filesystem, provided that both paths do not contain white-space
707: or other characters that are interpreted specially by the shell
708: and some other programs. A safe bet is to use only letters,
709: digits, underscores and dashes in the names.</p>
710: <div class="sect1" lang="en">
711: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
712: <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
713: <p>Before you download any pkgsrc files, you should decide
714: whether you want the <span class="emphasis"><em>current</em></span> branch or the
715: <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
716: quarterly basis from the current branch and only gets modified
717: for security updates. The names of the stable branches are built
718: from the year and the quarter, for example
719: <code class="literal">2006Q1</code>.</p>
720: <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
721: want to download pkgsrc. You can get it as a tar file, via SUP,
722: or via CVS. All three ways are described here.</p>
723: <div class="sect2" lang="en">
724: <div class="titlepage"><div><div><h3 class="title">
725: <a name="getting-via-tar"></a>2.1.1. As tar file</h3></div></div></div>
726: <p>The primary download location for all pkgsrc files is
727: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>. There are a
728: number of subdirectories for different purposes, which are
1.76 rillig 729: 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 730: <p>The tar file for the current branch is in the directory
1.76 rillig 731: <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 732: It is autogenerated daily.</p>
733: <p>The tar file for the stable branch 2006Q1 is in the
1.76 rillig 734: 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 735: <p>After downloading the tar file, change to the directory
736: where you want to have pkgsrc. This is usually
1.76 rillig 737: <code class="filename">/usr</code>. Then, run <span><strong class="command">tar xfz
1.75 rillig 738: pkgsrc.tar.gz</strong></span> to extract the files.</p>
739: </div>
740: <div class="sect2" lang="en">
741: <div class="titlepage"><div><div><h3 class="title">
742: <a name="getting-via-sup"></a>2.1.2. Via SUP</h3></div></div></div>
743: <p>As an alternative to the tar file, you can get pkgsrc via
744: the Software Update Protocol, SUP. To do so, make sure your
745: supfile has a line
1.1 grant 746:
1.75 rillig 747: </p>
748: <pre class="programlisting">
1.51 rillig 749: release=pkgsrc
1.1 grant 750: </pre>
1.75 rillig 751: <p>
1.1 grant 752:
1.75 rillig 753: in it, see the examples in
1.76 rillig 754: <code class="filename">/usr/share/examples/supfiles</code>, and that the
755: <code class="filename">/usr/pkgsrc</code> directory exists. Then, simply
1.75 rillig 756: run <span><strong class="command">sup -v
757: <em class="replaceable"><code>/path/to/your/supfile</code></em></strong></span>.</p>
758: </div>
759: <div class="sect2" lang="en">
760: <div class="titlepage"><div><div><h3 class="title">
761: <a name="getting-via-cvs"></a>2.1.3. Via CVS</h3></div></div></div>
762: <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>
763: installed. To do an initial (full) checkout of pkgsrc, you first
764: have to set some environment variables. For the C-Shell,
765: type:</p>
766: <pre class="screen">
767: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
768: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVS_RSH ssh</code></strong>
769: </pre>
770: <p>Or, the same for the bourne shell:</p>
771: <pre class="screen">
772: <code class="prompt">$</code> <strong class="userinput"><code>CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"</code></strong>
773: <code class="prompt">$</code> <strong class="userinput"><code>CVS_RSH="ssh"</code></strong>
774: <code class="prompt">$</code> <strong class="userinput"><code>export CVSROOT CVS_RSH</code></strong>
775: </pre>
776: <p>Then, you change to the directory where you want to have
777: your copy of pkgsrc. In most cases this is
1.76 rillig 778: <code class="filename">/usr</code>. In that directory you run the
1.75 rillig 779: checkout command, which is <span><strong class="command">cvs -q checkout -P
780: pkgsrc</strong></span> for the current branch and <span><strong class="command">cvs -q
781: checkout -rpkgsrc-2006Q1 -P pkgsrc</strong></span> for the stable
782: branch. This command will create a directory called
1.76 rillig 783: <code class="filename">pkgsrc</code> with all the pkgsrc files in
1.75 rillig 784: it.</p>
785: </div>
786: </div>
787: <div class="sect1" lang="en">
788: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
789: <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
790: <p>The preferred way to keep pkgsrc up-to-date is via CVS
791: (which also works if you have first installed it via a tar
792: file). It saves bandwidth and hard disk activity, compared to
793: downloading the tar file again.</p>
794: <div class="sect2" lang="en">
795: <div class="titlepage"><div><div><h3 class="title">
796: <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
797: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
798: <h3 class="title">Warning</h3>
1.77 rillig 799: <p>When updating from a tar file, you first need to
800: completely remove the old pkgsrc directory. Otherwise those
801: files that have been removed from pkgsrc in the mean time will
802: not be removed on your local disk, resulting in inconsistencies.
803: When removing the old files, any changes that you have done to
804: the pkgsrc files will be lost after updating. Therefore updating
805: via CVS is strongly recommended.</p>
1.75 rillig 806: </div>
807: <p>To update pkgsrc from a tar file, download the tar file as
808: explained above. Then, make sure that you have not made any
809: changes to the files in the pkgsrc directory. Remove the pkgsrc
810: directory and extract the new tar file. Done.</p>
811: </div>
812: <div class="sect2" lang="en">
813: <div class="titlepage"><div><div><h3 class="title">
814: <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
815: <p>To update pkgsrc via CVS, make sure the environment
816: variable <code class="varname">CVS_RSH</code> is set as above. Then,
817: change to the pkgsrc directory and run <span><strong class="command">cvs -q update
1.77 rillig 818: -dP</strong></span>.</p>
1.75 rillig 819: <div class="sect3" lang="en">
820: <div class="titlepage"><div><div><h4 class="title">
821: <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
822: <p>When updating pkgsrc, the CVS program keeps track of the
823: branch you selected. But if you, for whatever reason, want to
824: switch from the stable branch to the current one, you can do it
825: by adding the option “<span class="quote">-A</span>” after the
826: “<span class="quote">update</span>” keyword. To switch from the current branch
827: back to the stable branch, add the
828: “<span class="quote">-rpkgsrc-2006Q1</span>” option.</p>
829: </div>
830: <div class="sect3" lang="en">
831: <div class="titlepage"><div><div><h4 class="title">
832: <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
833: <p>When you update pkgsrc, the CVS program will only touch
834: those files that are registered in the CVS repository. That
835: means that any packages that you created on your own will stay
836: unmodified. If you change files that are managed by CVS, later
837: updates will try to merge your changes with those that have been
838: done by others. See the CVS manual, chapter
839: “<span class="quote">update</span>” for details.</p>
840: </div>
841: </div>
842: </div>
843: </div>
844: <div class="chapter" lang="en">
845: <div class="titlepage"><div><div><h2 class="title">
846: <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
847: <div class="toc">
848: <p><b>Table of Contents</b></p>
849: <dl>
850: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
851: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
852: <dd><dl>
853: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
854: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
855: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
856: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
857: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
858: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
859: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
860: </dl></dd>
861: </dl>
862: </div>
863: <div class="sect1" lang="en">
864: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
865: <a name="bootstrapping-pkgsrc"></a>3.1. Bootstrapping pkgsrc</h2></div></div></div>
866: <p>For operating systems other than NetBSD, we provide a bootstrap kit to
867: build the required tools to use pkgsrc on your platform. Besides
868: support for native NetBSD, pkgsrc and the bootstrap kit have support for
869: the following operating systems:</p>
870: <div class="itemizedlist"><ul type="disc">
871: <li><p>Darwin (Mac OS X)</p></li>
872: <li><p>DragonFly BSD</p></li>
873: <li><p>FreeBSD</p></li>
874: <li><p>Interix (Windows 2000, XP, 2003)</p></li>
875: <li><p>IRIX</p></li>
876: <li><p>Linux</p></li>
877: <li><p>OpenBSD</p></li>
878: <li><p>Solaris</p></li>
879: <li><p>Tru64 (Digital UNIX/OSF1)</p></li>
880: </ul></div>
881: <p>Support for other platforms is under development.</p>
882: <p>Installing the bootstrap kit should be as simple as:</p>
883: <pre class="screen">
884: <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
885: <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
886: <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong></pre>
887: <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
888: pkgsrc before bootstrapping. The given
889: <span><strong class="command">bootstrap</strong></span> command will use the defaults of
1.76 rillig 890: <code class="filename">/usr/pkg</code> for the
1.75 rillig 891: <span class="emphasis"><em>prefix</em></span> where programs will be installed in,
1.76 rillig 892: and <code class="filename">/var/db/pkg</code> for the package database
1.75 rillig 893: directory where pkgsrc will do its internal bookkeeping.
894: However, these can also be set using command-line
895: arguments.</p>
896: <p>Binary packages for the pkgsrc tools and an initial set of packages is
897: available for supported platforms. An up-to-date list of these can be
898: found on <a href="http://www.pkgsrc.org/" target="_top">www.pkgsrc.org</a>.
899: Note that this only works for privileged builds that install
1.76 rillig 900: into <code class="filename">/usr/pkg</code>.</p>
1.75 rillig 901: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
902: <h3 class="title">Note</h3>
903: <p>The bootstrap installs a <span><strong class="command">bmake</strong></span> tool.
904: Use this <span><strong class="command">bmake</strong></span> when building via pkgsrc.
905: For examples in this guide, use <span><strong class="command">bmake</strong></span>
906: instead of “<span class="quote">make</span>”.</p>
907: </div>
908: </div>
909: <div class="sect1" lang="en">
910: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
911: <a name="platform-specific-notes"></a>3.2. Platform-specific notes</h2></div></div></div>
912: <p>Here are some platform-specific notes you should be aware of.</p>
913: <div class="sect2" lang="en">
914: <div class="titlepage"><div><div><h3 class="title">
915: <a name="darwin"></a>3.2.1. Darwin (Mac OS X)</h3></div></div></div>
916: <p>Darwin 5.x and 6.x are supported. There are two methods of using
917: pkgsrc on Mac OS X, by using a <a href="#platform.osx-image" title="3.2.1.1. Using a disk image">disk
918: image</a>, or a <a href="#platform.osx-ufs" title="3.2.1.2. Using a UFS partition">UFS
919: partition</a>.</p>
920: <p>Before you start, you will need to download and install the Mac OS X Developer
921: Tools from Apple's Developer Connection. See <a href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
922: for details. Also, make sure you install X11 for Mac OS X and the X11 SDK
923: from <a href="http://www.apple.com/macosx/x11/download/" target="_top">http://www.apple.com/macosx/x11/download/</a>
924: if you intend to build packages that use the X11 Window System.</p>
925: <p>If you already have a UFS partition, or have a spare partition
926: that you can format as UFS, it is recommended to use that instead of
927: the disk image. It'll be somewhat faster and will mount automatically
928: at boot time, where you must manually mount a disk image.</p>
929: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
930: <h3 class="title">Note</h3>
931: <p>You cannot use a HFS+ file system for pkgsrc, because pkgsrc currently
932: requires the file system to be case-sensitive, and HFS+ is not.</p>
933: </div>
934: <div class="sect3" lang="en">
935: <div class="titlepage"><div><div><h4 class="title">
936: <a name="platform.osx-image"></a>3.2.1.1. Using a disk image</h4></div></div></div>
937: <p>Create the disk image:</p>
938: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
939: <code class="prompt">#</code> <strong class="userinput"><code>./ufsdiskimage create ~/Documents/NetBSD 512</code></strong> # megabytes - season to taste
940: <code class="prompt">#</code> <strong class="userinput"><code>./ufsdiskimage mount ~/Documents/NetBSD</code></strong>
941: <code class="prompt">#</code> <strong class="userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong></pre>
942: <p>That's it!</p>
943: </div>
944: <div class="sect3" lang="en">
945: <div class="titlepage"><div><div><h4 class="title">
946: <a name="platform.osx-ufs"></a>3.2.1.2. Using a UFS partition</h4></div></div></div>
1.76 rillig 947: <p>By default, <code class="filename">/usr</code> will be on your root file
1.75 rillig 948: system, normally HFS+. It is possible to use the default
1.76 rillig 949: <span class="emphasis"><em>prefix</em></span> of <code class="filename">/usr/pkg</code>
950: by symlinking <code class="filename">/usr/pkg</code> to a directory on a UFS
1.75 rillig 951: file system. Obviously, another symlink is required if you want to
952: place the package database directory outside the
953: <span class="emphasis"><em>prefix</em></span>. e.g.</p>
954: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb</code></strong></pre>
955: <p>If you created your partitions at the time of installing Mac OS X
956: and formatted the target partition as UFS, it should automatically
1.76 rillig 957: mount on <code class="filename">/Volumes/<volume name></code> when the
1.75 rillig 958: machine boots. If you are (re)formatting a partition as UFS, you need
959: to ensure that the partition map correctly reflects
960: “<span class="quote">Apple_UFS</span>” and not “<span class="quote">Apple_HFS</span>”.</p>
961: <p>The problem is that none of the disk tools will let you touch a
962: disk that is booted from. You can unmount the partition, but even if
963: you newfs it, the partition type will be incorrect and the
964: automounter won't mount it. It can be mounted manually, but it won't
965: appear in Finder.</p>
966: <p>You'll need to boot off of the OS X Installation (User) CD. When
967: the Installation program starts, go up to the menu and select Disk
968: Utility. Now, you will be able to select the partition you want
969: to be UFS, and Format it Apple UFS. Quit the Disk Utility, quit the
970: installer which will reboot your machine. The new UFS file system
971: will appear in Finder.</p>
972: <p>Be aware that the permissions on the new file system will be writable
973: by root only.</p>
974: <p>This note is as of 10.2 (Jaguar) and applies to earlier versions.
975: Hopefully Apple will fix Disk Utility in 10.3 (Panther).</p>
976: </div>
977: </div>
978: <div class="sect2" lang="en">
979: <div class="titlepage"><div><div><h3 class="title">
980: <a name="freebsd"></a>3.2.2. FreeBSD</h3></div></div></div>
981: <p>
982: FreeBSD 4.7 and 5.0 have been tested and are supported, other versions
983: may work.</p>
984: <p>Care should be taken so that the tools that this kit installs do not conflict
985: with the FreeBSD userland tools. There are several steps:</p>
986: <div class="orderedlist"><ol type="1">
987: <li><p>FreeBSD stores its ports pkg database in
1.76 rillig 988: <code class="filename">/var/db/pkg</code>. It is therefore
1.75 rillig 989: recommended that you choose a different location (e.g.
1.76 rillig 990: <code class="filename">/usr/pkgdb</code>) by
1.75 rillig 991: using the --pkgdbdir option to the bootstrap script.</p></li>
992: <li>
993: <p>If you do not intend to use the FreeBSD ports tools, it's probably a
994: good idea to move them out of the way to avoid confusion, e.g.</p>
995: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
996: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
997: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
998: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
999: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
1000: </li>
1.76 rillig 1001: <li><p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1002: <code class="filename">/etc/mk.conf.example</code> file
1.75 rillig 1003: when you use the bootstrap script.</p></li>
1004: </ol></div>
1005: </div>
1006: <div class="sect2" lang="en">
1007: <div class="titlepage"><div><div><h3 class="title">
1008: <a name="interix"></a>3.2.3. Interix</h3></div></div></div>
1009: <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
1010: providing a Unix-like environment with a tighter kernel integration than
1011: available with Cygwin. It is part of the Windows Services for Unix
1012: package, available for free for any licensed copy of Windows 2000, XP
1013: (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>
1014: <p>Services for Unix 3.5, current as of this writing, has been tested. 3.0
1015: or 3.1 may work, but are not officially supported. (The main difference
1016: in 3.0/3.1 is lack of pthreads.)</p>
1017: <div class="sect3" lang="en">
1018: <div class="titlepage"><div><div><h4 class="title">
1019: <a name="platform.interix-sfu-install"></a>3.2.3.1. When installing Interix/SFU</h4></div></div></div>
1020: <p>At an absolute minimum, the following packages must be installed from
1021: the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
1022: <div class="itemizedlist"><ul type="disc">
1023: <li><p>Utilities -> Base Utilities</p></li>
1024: <li><p>Interix GNU Components -> (all)</p></li>
1025: <li><p>Remote Connectivity</p></li>
1026: <li><p>Interix SDK</p></li>
1027: </ul></div>
1028: <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
1029: "UNIX Perl". That is Perl 5.6 without shared module support, installed to
1030: /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
1031: pkgsrc (or from a binary package).</p>
1032: <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
1033: not need to be installed, but Remote Connectivity itself should be
1034: installed in order to have a working inetd.</p>
1035: <p>During installation you may be asked whether to enable setuid
1036: behavior for Interix programs, and whether to make pathnames default to
1037: case-sensitive. Setuid should be enabled, and case-sensitivity MUST be
1038: enabled. (Without case-sensitivity, a large number of packages including
1039: perl will not build.)</p>
1040: <p>NOTE: Newer Windows service packs change the way binary execution
1041: works (via the Data Execution Prevention feature). In order to use
1042: pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
1043: POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
1044: must be installed. Hotfixes are available from Microsoft through a
1045: support contract; however, a NetBSD developer has made most Interix
1046: 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>
1047: </div>
1048: <div class="sect3" lang="en">
1049: <div class="titlepage"><div><div><h4 class="title">
1050: <a name="platform.interix-sfu-postinstall"></a>3.2.3.2. What to do if Interix/SFU is already installed</h4></div></div></div>
1051: <p>If SFU is already installed and you wish to alter these settings to work
1052: with pkgsrc, note the following things.</p>
1053: <div class="itemizedlist"><ul type="disc">
1054: <li><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
1055: Windows Services for UNIX, then click Change. In the installer, choose
1056: Add or Remove, then uncheck Utilities->UNIX Perl.</p></li>
1057: <li>
1058: <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
1059: change the following registry key:</p>
1060: <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
1061: <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
1062: </li>
1063: <li>
1064: <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
1065: following registry key:</p>
1066: <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
1067: <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
1068: </li>
1069: </ul></div>
1070: </div>
1071: <div class="sect3" lang="en">
1072: <div class="titlepage"><div><div><h4 class="title">
1073: <a name="platform.interix-notes"></a>3.2.3.3. Important notes for using pkgsrc</h4></div></div></div>
1074: <p>The package manager (either the pkgsrc "su" user, or the user
1075: running "pkg_add") must be a member of the local Administrators
1076: group. Such a user must also be used to run the bootstrap. This is
1077: slightly relaxed from the normal pkgsrc requirement of "root".</p>
1078: <p>The package manager should use a umask of 002. "make install" will
1079: automatically complain if this is not the case. This ensures that
1080: directories written in /var/db/pkg are Administrators-group writeable.</p>
1081: <p>The popular Interix binary packages from http://www.interopsystems.com/
1082: use an older version of pkgsrc's pkg_* tools. Ideally, these should
1083: NOT be used in conjunction with pkgsrc. If you choose to use them at
1084: the same time as the pkgsrc packages, ensure that you use the proper
1085: pkg_* tools for each type of binary package.</p>
1086: <p>The TERM setting used for DOS-type console windows (including those
1087: invoked by the csh and ksh startup shortcuts) is "interix". Most systems
1088: don't have a termcap/terminfo entry for it, but the following .termcap
1089: entry provides adequate emulation in most cases:</p>
1090: <pre class="programlisting">
1091: interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
1092: </pre>
1093: </div>
1094: <div class="sect3" lang="en">
1095: <div class="titlepage"><div><div><h4 class="title">
1096: <a name="platform.interix-limits"></a>3.2.3.4. Limitations of the Interix platform</h4></div></div></div>
1097: <p>Though Interix suffices as a familiar and flexible substitute
1098: for a full Unix-like platform, it has some drawbacks that should
1099: be noted for those desiring to make the most of Interix.</p>
1100: <div class="itemizedlist"><ul type="disc">
1101: <li>
1102: <p><span class="strong"><strong>X11:</strong></span></p>
1103: <p>Interix comes with the standard set of X11R6 client libraries,
1104: and can run X11 based applications, but it does
1105: <span class="emphasis"><em>not</em></span> come with an X server. Some options are
1106: <a href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
1107: <a href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
1108: (available in a trimmed version for Interix from Interop Systems as the
1109: <a href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
1110: and the free X11 server included with
1111: <a href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
1112: <p>Also, StarNet Communications has graciously provided a free
1113: version of their X-Win32 product that accepts connections only
1114: from localhost:
1115: <a href="http://www.starnet.com/xwin32LX/get_xwin32LX.htm" target="_top">X-Win32 LX</a>,
1116: recommended by the maintainer of Interix pkgsrc support.</p>
1117: </li>
1118: <li>
1119: <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
1120: <p>Because Interix runs in a completely different NT subsystem from
1121: Win32 applications, it does not currently support various X11
1122: protocol extensions for acceleration (such as MIT-SHM or DGA).
1123: Most interactive applications to a local X server will run
1124: reasonably fast, but full motion video and other graphics
1125: intensive applications may require a faster-than-expected CPU.</p>
1126: </li>
1127: <li>
1128: <p><span class="strong"><strong>Audio:</strong></span></p>
1129: <p>Interix has no native support for audio output. For audio
1130: support, pkgsrc uses the <span><strong class="command">esound</strong></span> client/server
1131: audio system on Interix. Unlike on most platforms, the
1.76 rillig 1132: <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 1133: <span class="emphasis"><em>not</em></span> contain the <span><strong class="command">esd</strong></span>
1134: server component. To output audio via an Interix host, the
1.76 rillig 1135: <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 1136: must also be installed.</p>
1137: </li>
1138: <li>
1139: <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
1140: <p>Direct device access is not currently supported in Interix, so it
1141: is not currently possible to access CD/DVD drives, USB devices,
1142: or SCSI devices through non-filesystem means. Among other things,
1143: this makes it impossible to use Interix directly for CD/DVD
1144: burning.</p>
1145: </li>
1146: <li>
1147: <p><span class="strong"><strong>Tape drives:</strong></span></p>
1148: <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
1149: drives are also not directly accessible in Interix. However,
1150: support is in work to make tape drive access possible by using
1151: Cygwin as a bridge (similarly to audio bridged via Cygwin's
1152: esound server).</p>
1153: </li>
1154: </ul></div>
1155: </div>
1156: <div class="sect3" lang="en">
1157: <div class="titlepage"><div><div><h4 class="title">
1158: <a name="platform.interix-knownissues"></a>3.2.3.5. Known issues for pkgsrc on Interix</h4></div></div></div>
1159: <p>It is not necessary, in general, to have a "root" user on the
1160: Windows system; any member of the local Administrators group will
1161: suffice. However, some packages currently assume that the user
1162: named "root" is the privileged user. To accommodate these, you
1163: may create such a user; make sure it is in the local group
1164: Administrators (or your language equivalent).</p>
1165: <p>"pkg_add" creates directories of mode 0755, not 0775, in
1166: $PKG_DBDIR. For the time being, install packages as the local
1167: Administrator (or your language equivalent), or run the following
1168: command after installing a package to work around the issue:</p>
1169: <pre class="screen">
1170: <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong></pre>
1171: </div>
1172: </div>
1173: <div class="sect2" lang="en">
1174: <div class="titlepage"><div><div><h3 class="title">
1175: <a name="irix"></a>3.2.4. IRIX</h3></div></div></div>
1176: <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
1177: compiler (cc/c89). Please set the <code class="varname">CC</code> environment variable
1178: according to your preference. If you do not have a license for the MIPSpro
1179: compiler suite, you can download a gcc tardist file from <a href="http://freeware.sgi.com/" target="_top">http://freeware.sgi.com/</a>.</p>
1180: <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
1181: 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>,
1182: etc.</p>
1183: <p>At this point in time, pkgsrc only supports one ABI at a time. That is, you can not
1184: switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI. If
1185: you start out using "abi=n32", that's what all your packages will be built
1186: with.</p>
1187: <p>Therefore, please make sure that you have no conflicting
1188: <code class="varname">CFLAGS</code> in your environment or the
1.76 rillig 1189: <code class="filename">/etc/mk.conf</code>. Particularly, make sure that you do not
1.75 rillig 1190: try to link n32 object files with lib64 or vice versa. Check your
1.76 rillig 1191: <code class="filename">/etc/compiler.defaults</code>!</p>
1.75 rillig 1192: <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
1193: please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
1194: as it appears that IRIX linker occasionally runs into issues when trying to
1195: link over a network-mounted file system.</p>
1196: <p>The bootstrapping process should set all the right options for programs such
1197: as imake(1), but you may want to set some options depending on your local
1.76 rillig 1198: setup. Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
1.75 rillig 1199: course, your compiler's man pages for details.</p>
1200: <p>If you are using SGI's MIPSPro compiler, please set
1.1 grant 1201:
1.75 rillig 1202: </p>
1203: <pre class="programlisting">
1204: PKGSRC_COMPILER= mipspro
1205: </pre>
1206: <p>
1.1 grant 1207:
1.76 rillig 1208: in <code class="filename">/etc/mk.conf</code>. Otherwise, pkgsrc will assume you
1.75 rillig 1209: are using gcc and may end up passing invalid flags to the compiler. Note that
1.76 rillig 1210: bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
1.75 rillig 1211: default.</p>
1212: <p>If you have both the MIPSPro compiler chain installed as well as gcc,
1213: but want to make sure that MIPRPro is used, please set your <code class="varname">PATH</code>
1214: to <span class="emphasis"><em>not</em></span> include the location of gcc (often
1.76 rillig 1215: <code class="filename">/usr/freeware/bin</code>), and (important) pass the
1.75 rillig 1216: '--preserve-path' flag.</p>
1217: </div>
1218: <div class="sect2" lang="en">
1219: <div class="titlepage"><div><div><h3 class="title">
1220: <a name="linux"></a>3.2.5. Linux</h3></div></div></div>
1221: <p>
1222: Some versions of Linux (for example Debian GNU/Linux) need either
1223: libtermcap or libcurses (libncurses). Installing the distributions
1224: libncurses-dev package (or equivalent) should fix the problem.</p>
1225: <p>
1226: pkgsrc supports both gcc (GNU Compiler Collection) and icc (Intel C++
1227: Compiler). gcc is the default. icc 8.0 and 8.1 on i386 have been tested.
1228: </p>
1229: <p>To bootstrap using icc, assuming the default icc installation
1230: directory:</p>
1231: <pre class="programlisting">
1232: env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
1233: ac_cv___attribute__=yes ./bootstrap
1234: </pre>
1235: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1236: <h3 class="title">Note</h3>
1237: <p>icc 8.1 needs the `-i-static' argument instead of -static-libcxa.</p>
1238: </div>
1239: <p>icc supports __attribute__, but the GNU configure test uses a nested
1240: function, which icc does not support. #undef'ing __attribute__ has the
1241: unfortunate side-effect of breaking many of the Linux header files, which
1242: cannot be compiled properly without __attribute__. The test must be
1243: overridden so that __attribute__ is assumed supported by the
1244: compiler.</p>
1245: <p>After bootstrapping, you should set <code class="varname">PKGSRC_COMPILER</code>
1.76 rillig 1246: in <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1247: <pre class="programlisting">
1248: PKGSRC_COMPILER= icc
1249: </pre>
1250: <p>The default installation directory for icc is
1.76 rillig 1251: <code class="filename">/opt/intel_cc_80</code>, which
1.75 rillig 1252: is also the pkgsrc default. If you have installed it into a different
1253: directory, set <code class="varname">ICCBASE</code> in
1.76 rillig 1254: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1255: <pre class="programlisting">
1256: ICCBASE= /opt/icc
1257: </pre>
1258: <p>pkgsrc uses the static linking method of the runtime libraries
1259: provided by icc, so binaries can be run on other systems which do not
1260: have the shared libraries installed.</p>
1261: <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>
1262: command run when linking a C++ shared library and records it, throwing
1263: away the -Bstatic and -Bdynamic options interspersed between the libraries.
1264: This means that libtool-linked C++ shared libraries will have a
1265: runtime dependency on the icc libraries until this is fixed in libtool.
1266: </p>
1267: </div>
1268: <div class="sect2" lang="en">
1269: <div class="titlepage"><div><div><h3 class="title">
1270: <a name="openbsd"></a>3.2.6. OpenBSD</h3></div></div></div>
1271: <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
1272: <p>Care should be taken so that the tools that this kit installs do not conflict
1273: with the OpenBSD userland tools. There are several steps:</p>
1274: <div class="orderedlist"><ol type="1">
1275: <li><p>OpenBSD stores its ports pkg database in
1.76 rillig 1276: <code class="filename">/var/db/pkg</code>. It is therefore
1.75 rillig 1277: recommended that you choose a different location (e.g.
1.76 rillig 1278: <code class="filename">/usr/pkgdb</code>) by
1.75 rillig 1279: using the --pkgdbdir option to the bootstrap script.</p></li>
1280: <li>
1281: <p>If you do not intend to use the OpenBSD ports tools, it's probably a
1282: good idea to move them out of the way to avoid confusion, e.g.</p>
1283: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1284: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1285: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1286: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1287: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
1288: </li>
1289: <li>
1.76 rillig 1290: <p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1291: <code class="filename">/etc/mk.conf.example</code> file
1.75 rillig 1292: when you use the bootstrap script. OpenBSD's make program uses
1.76 rillig 1293: <code class="filename">/etc/mk.conf</code>
1.75 rillig 1294: as well. You can work around this by enclosing all the pkgsrc-specific parts
1295: of the file with:</p>
1296: <pre class="programlisting">
1297: .ifdef BSD_PKG_MK
1298: # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
1299: .else
1300: # OpenBSD stuff
1.1 grant 1301: .endif
1302: </pre>
1.75 rillig 1303: </li>
1304: </ol></div>
1305: </div>
1306: <div class="sect2" lang="en">
1307: <div class="titlepage"><div><div><h3 class="title">
1308: <a name="solaris"></a>3.2.7. Solaris</h3></div></div></div>
1309: <p>Solaris 2.6 through 9 are supported on both x86 and sparc.
1310: You will need a working C compiler. Both gcc 2.95.3 and
1311: Sun WorkShop 5 have been tested.</p>
1312: <p>The following packages are required on Solaris 8 for the bootstrap
1313: process and to build packages.</p>
1314: <div class="itemizedlist"><ul type="disc">
1315: <li><p>SUNWsprot</p></li>
1316: <li><p>SUNWarc</p></li>
1317: <li><p>SUNWbtool</p></li>
1318: <li><p>SUNWtoo</p></li>
1319: <li><p>SUNWlibm</p></li>
1320: </ul></div>
1.78 ! rillig 1321: <p>Please note that the use of GNU binutils on Solaris is
! 1322: <span class="emphasis"><em>not</em></span> supported, as of June 2006.</p>
1.75 rillig 1323: <p>Whichever compiler you use, please ensure the compiler tools and
1324: your $prefix are in your <code class="varname">PATH</code>. This includes
1.76 rillig 1325: <code class="filename">/usr/ccs/{bin,lib}</code>
1326: and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1.75 rillig 1327: <div class="sect3" lang="en">
1328: <div class="titlepage"><div><div><h4 class="title">
1329: <a name="solaris-gcc-note"></a>3.2.7.1. If you are using gcc</h4></div></div></div>
1330: <p>It makes life much simpler if you only use the same gcc consistently
1331: for building all packages.</p>
1332: <p>It is recommended that an external gcc be used only for bootstrapping,
1333: then either build gcc from
1.76 rillig 1334: <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 1335: package, then remove gcc used during bootstrapping.</p>
1336: <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>
1337: </div>
1338: <div class="sect3" lang="en">
1339: <div class="titlepage"><div><div><h4 class="title">
1340: <a name="solaris-sun-workshop-note"></a>3.2.7.2. If you are using Sun WorkShop</h4></div></div></div>
1341: <p>You will need at least the following packages installed (from WorkShop
1342: 5.0)</p>
1343: <div class="itemizedlist"><ul type="disc">
1344: <li><p>SPROcc
1345: - Sun WorkShop Compiler C 5.0</p></li>
1346: <li><p>SPROcpl
1347: - Sun WorkShop Compiler C++ 5.0</p></li>
1348: <li><p>SPROild
1349: - Sun WorkShop Incremental Linker</p></li>
1350: <li><p>SPROlang
1351: - Sun WorkShop Compilers common components</p></li>
1352: </ul></div>
1353: <p>You should set <code class="varname">CC</code>, <code class="varname">CXX</code> and
1.76 rillig 1354: optionally, <code class="varname">CPP</code> in <code class="filename">/etc/mk.conf</code>,
1.75 rillig 1355: e.g.:</p>
1356: <pre class="programlisting">
1357: CC= cc
1358: CXX= CC
1359: CPP= /usr/ccs/lib/cpp
1.1 grant 1360: </pre>
1.75 rillig 1361: </div>
1362: <div class="sect3" lang="en">
1363: <div class="titlepage"><div><div><h4 class="title">
1364: <a name="solaris-sunpro-64"></a>3.2.7.3. Buildling 64-bit binaries with SunPro</h4></div></div></div>
1365: <p>Building 64-bit binaries is a little trickier. First, you
1366: need to bootstrap pkgsrc in 64-bit mode. One problem here is
1367: that while building one of the programs in the bootstrap kit
1.76 rillig 1368: (<code class="filename">bmake</code>), the <code class="varname">CFLAGS</code>
1.75 rillig 1369: variable is not honored, even if it is set in the environment.
1370: To work around this bug, you can create a simple shell script
1.76 rillig 1371: called <code class="filename">cc64</code> and put it somewhere in the
1.75 rillig 1372: <code class="varname">PATH</code>:</p>
1373: <pre class="programlisting">
1374: #! /bin/sh
1375: exec /opt/SUNWspro/bin/cc -xtarget=ultra -xarch=v9 ${1+"$@"}
1.1 grant 1376: </pre>
1.75 rillig 1377: <p>Then, pass the definition for <code class="varname">CC</code> in the
1378: environment of the <span><strong class="command">bootstrap</strong></span> command:</p>
1379: <pre class="programlisting">
1380: <code class="prompt">$</code> <strong class="userinput"><code>cd bootstrap</code></strong>
1381: <code class="prompt">$</code> <strong class="userinput"><code>CC=cc64 ./bootstrap</code></strong>
1382: </pre>
1383: <p>After bootstrapping, there are two alternative ways,
1384: depending on whether you want to find bugs in packages or get
1385: your system ready quickly. If you just want a running system,
1.76 rillig 1386: add the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1387: file:</p>
1388: <pre class="programlisting">
1389: CC= cc64
1390: CXX= CC64
1391: PKGSRC_COMPILER= sunpro
1.1 grant 1392: </pre>
1.75 rillig 1393: <p>This way, all calls to the compiler will be intercepted by
1394: the above wrapper and therefore get the necessary ABI options
1395: automatically. (Don't forget to create the shell script
1.76 rillig 1396: <code class="filename">CC64</code>, too.)</p>
1.75 rillig 1397: <p>To find packages that ignore the user-specified
1398: <code class="varname">CFLAGS</code> and <code class="varname">CXXFLAGS</code>, add
1.76 rillig 1399: the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1400: file:</p>
1401: <pre class="programlisting">
1402: CC= cc
1403: CXX= CC
1404: PKGSRC_COMPILER= sunpro
1405: CFLAGS= -xtarget=ultra -xarch=v9
1406: CXXFLAGS= -xtarget=ultra -xarch=v9
1407: LDFLAGS= -xtarget=ultra -xarch=v9
1.1 grant 1408: </pre>
1.75 rillig 1409: <p>Packages that don't use the flags provided in the
1410: configuration file will try to build 32-bit binaries and fail
1411: during linking. Detecting this is useful to prevent bugs on
1412: other platforms where the error would not show up but pass
1413: silently.</p>
1414: </div>
1415: <div class="sect3" lang="en">
1416: <div class="titlepage"><div><div><h4 class="title">
1417: <a name="plat.sunos.problems"></a>3.2.7.4. Common problems</h4></div></div></div>
1418: <p>Sometimes, when using <span><strong class="command">libtool</strong></span>,
1.76 rillig 1419: <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
1.75 rillig 1420: The workaround is to use another shell for the configure
1.76 rillig 1421: 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
1422: to your <code class="filename">mk.conf</code>:</p>
1.75 rillig 1423: <pre class="programlisting">
1424: CONFIG_SHELL= ${LOCALBASE}/bin/bash
1425: WRAPPER_SHELL= ${LOCALBASE}/bin/bash
1.1 grant 1426: </pre>
1.76 rillig 1427: <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 1428: </div>
1429: </div>
1430: </div>
1431: </div>
1432: <div class="chapter" lang="en">
1433: <div class="titlepage"><div><div><h2 class="title">
1434: <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
1435: <div class="toc">
1436: <p><b>Table of Contents</b></p>
1437: <dl>
1438: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
1439: <dd><dl>
1440: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
1441: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1442: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
1443: </dl></dd>
1444: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
1445: <dd><dl>
1446: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
1447: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
1448: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
1449: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
1450: </dl></dd>
1451: </dl>
1452: </div>
1453: <p>Basically, there are two ways of using pkgsrc. The first
1454: is to only install the package tools and to use binary packages
1455: that someone else has prepared. This is the “<span class="quote">pkg</span>”
1456: in pkgsrc. The second way is to install the “<span class="quote">src</span>”
1457: of pkgsrc, too. Then you are able to build your own packages,
1458: and you can still use binary packages from someone else.</p>
1459: <div class="sect1" lang="en">
1460: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1461: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
1462: <p>To use binary packages, you need some tools to manage
1463: them. On NetBSD, these tools are already installed. On all other
1464: operating systems, you need to install them first. For the
1465: following platforms, prebuilt versions of the package tools
1466: are available and can simply be downloaded and unpacked in the
1.76 rillig 1467: <code class="filename">/</code> directory:</p>
1.75 rillig 1468: <div class="informaltable">
1469: <a name="binary-bootstrap-kits"></a><table border="1">
1470: <colgroup>
1471: <col>
1472: <col>
1473: </colgroup>
1474: <thead><tr>
1475: <th>Platform</th>
1476: <th>URL</th>
1477: </tr></thead>
1478: <tbody>
1479: <tr>
1480: <td>Solaris 9</td>
1.76 rillig 1481: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1482: </tr>
1483: <tr>
1484: <td>Solaris 10</td>
1.76 rillig 1485: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1486: </tr>
1487: </tbody>
1488: </table>
1489: </div>
1490: <p>These prebuilt package tools use
1.76 rillig 1491: <code class="filename">/usr/pkg</code> for the base directory, and
1492: <code class="filename">/var/db/pkg</code> for the database of installed
1.75 rillig 1493: packages. If you cannot use these directories for whatever
1494: reasons (maybe because you're not root), you have to build the
1495: package tools yourself, which is explained in <a href="#bootstrapping-pkgsrc" title="3.1. Bootstrapping pkgsrc">Section 3.1, “Bootstrapping pkgsrc”</a>.</p>
1496: <div class="sect2" lang="en">
1497: <div class="titlepage"><div><div><h3 class="title">
1498: <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
1499: <p>To install binary packages, you first need to know from
1500: where to get them. You can get them on CD-ROMs, DVDs, or via FTP
1501: or HTTP.</p>
1502: <p>For NetBSD, the binary packages are made available on
1.76 rillig 1503: <code class="filename">ftp.NetBSD.org</code> and its mirrors, in the
1.75 rillig 1504: directory
1.76 rillig 1505: <code class="filename">/pub/NetBSD/packages/<em class="replaceable"><code>OSVERSION</code></em>/<em class="replaceable"><code>ARCH</code></em>/</code>.
1.75 rillig 1506: For <em class="replaceable"><code>OSVERSION</code></em>, you should insert the
1507: output of <span><strong class="command">uname -r</strong></span>, and for
1508: <em class="replaceable"><code>ARCH</code></em> the output of <span><strong class="command">uname
1509: -p</strong></span>.</p>
1510: <p>For some other platforms, binary packages can be found at
1511: the following locations:</p>
1512: <div class="informaltable">
1513: <a name="binary-packages"></a><table border="1">
1514: <colgroup>
1515: <col>
1516: <col>
1517: </colgroup>
1518: <thead><tr>
1519: <th>Platform</th>
1520: <th>URL</th>
1521: </tr></thead>
1522: <tbody>
1523: <tr>
1524: <td>Solaris 9</td>
1.76 rillig 1525: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/</code></td>
1.75 rillig 1526: </tr>
1527: <tr>
1528: <td>Solaris 10</td>
1.76 rillig 1529: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/</code></td>
1.75 rillig 1530: </tr>
1531: </tbody>
1532: </table>
1533: </div>
1534: <p>Most of these directories contain the pkgsrc distribution
1535: for multiple platforms. Select the appropriate subdirectories,
1536: according to your machine architecture and operating system,
1.76 rillig 1537: until you find a directory called <code class="filename">All</code>. This
1.75 rillig 1538: directory contains all the binary packages. Further, there are
1539: subdirectories for categories that contain symbolic links that
1540: point to the actual binary package in
1.76 rillig 1541: <code class="filename">../All</code>. This directory layout is used for
1.75 rillig 1542: all package repositories, no matter if they are accessed via
1543: HTTP, FTP, NFS, CD-ROM, or the local filesystem.</p>
1544: </div>
1545: <div class="sect2" lang="en">
1546: <div class="titlepage"><div><div><h3 class="title">
1547: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
1548: <p> If you have the files on a CD-ROM or downloaded them to
1549: your hard disk, you can install them with the following command
1550: (be sure to <span><strong class="command">su</strong></span> to root first):</p>
1551: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add /path/to/package.tgz</code></strong></pre>
1552: <p> If you have FTP access and you don't want to download the
1553: packages via FTP prior to installation, you can do this
1554: automatically by giving <span><strong class="command">pkg_add</strong></span> an FTP URL:
1555: </p>
1556: <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>
1557: <p>Note that any prerequisite packages needed to run the
1558: package in question will be installed, too, assuming they are
1559: present where you install from. </p>
1560: <p>To save some typing, you can set the
1561: <code class="varname">PKG_PATH</code> environment variable to a semicolon-separated
1562: list of paths (including remote URLs); trailing slashes are not allowed.
1563: </p>
1.76 rillig 1564: <p>Additionally to the <code class="filename">All</code> directory
1565: there exists a <code class="filename">vulnerable</code> directory to
1.75 rillig 1566: which binary packages with known vulnerabilities are
1567: moved, since removing them could cause missing dependencies. To
1.76 rillig 1568: use these packages, add the <code class="filename">vulnerable</code>
1.75 rillig 1569: directory to your <code class="varname">PKG_PATH</code>. However, you should run
1.76 rillig 1570: <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 1571: especially after installing new packages, and verify that the
1572: vulnerabilities are acceptable for your configuration. An example
1573: <code class="varname">PKG_PATH</code> would be:
1.76 rillig 1574: <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 1575: Please note that semicolon (';') is a shell meta-character, so
1576: you'll probably have to quote it.</p>
1577: <p>After you've installed packages, be sure to have
1.76 rillig 1578: <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
1.75 rillig 1579: <code class="varname">PATH</code> so you can actually start the just
1580: installed program. </p>
1581: </div>
1582: <div class="sect2" lang="en">
1583: <div class="titlepage"><div><div><h3 class="title">
1584: <a name="a-word-of-warning"></a>4.1.3. A word of warning</h3></div></div></div>
1585: <p>Please pay very careful attention to the warnings
1586: 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
1587: inherent dangers of installing binary packages which you did
1588: not create yourself, and the security holes that can be
1589: introduced onto your system by indiscriminate adding of such
1590: files.</p>
1591: <p>The same warning of course applies to every package you
1592: install from source when you haven't completely read and
1593: understood the source code of the package, the compiler that
1594: is used to build the package and all the other tools that are
1595: involved.</p>
1596: </div>
1597: </div>
1598: <div class="sect1" lang="en">
1599: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1600: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
1601: <p> This assumes that the package is already in pkgsrc. If it
1602: 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
1603: how to create your own packages.</p>
1604: <div class="sect2" lang="en">
1605: <div class="titlepage"><div><div><h3 class="title">
1606: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
1607: <p> To build packages from source on a NetBSD system the
1608: “<span class="quote">comp</span>” and the “<span class="quote">text</span>” distribution
1609: sets must be installed. If you want to build X11-related
1610: packages the “<span class="quote">xbase</span>” and “<span class="quote">xcomp</span>”
1611: distribution sets are required, too.</p>
1612: </div>
1613: <div class="sect2" lang="en">
1614: <div class="titlepage"><div><div><h3 class="title">
1615: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
1616: <p>The first step for building a package is downloading the
1617: distfiles (i.e. the unmodified source). If they have not yet been
1618: downloaded, pkgsrc will fetch them automatically.</p>
1619: <p>You can overwrite some of the major distribution sites to fit to sites
1620: that are close to your own. Have a look at
1.76 rillig 1621: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find some examples
1.78 ! rillig 1622: — in particular, look for the <code class="varname">MASTER_SORT</code>,
1.75 rillig 1623: <code class="varname">MASTER_SORT_REGEX</code> and
1624: <code class="varname">INET_COUNTRY</code> definitions. This may save some of your
1625: bandwidth and time.</p>
1626: <p>You can change these settings either in your shell's environment, or,
1627: if you want to keep the settings, by editing the
1.76 rillig 1628: <code class="filename">/etc/mk.conf</code> file,
1.75 rillig 1629: and adding the definitions there.</p>
1630: <p>If you don't have a permanent Internet connection and you want to know
1631: which files to download, <span><strong class="command">make fetch-list</strong></span> will tell you
1632: what you'll need. Put these distfiles into
1.76 rillig 1633: <code class="filename">/usr/pkgsrc/distfiles</code>.</p>
1.75 rillig 1634: </div>
1635: <div class="sect2" lang="en">
1636: <div class="titlepage"><div><div><h3 class="title">
1637: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
1638: <p>Assuming that the distfile has been fetched (see previous section), become
1639: root and change into the relevant directory and run
1640: <span><strong class="command">make</strong></span>.</p>
1641: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1642: <h3 class="title">Note</h3>
1643: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
1644: use the pkgsrc <span><strong class="command">bmake</strong></span> command instead of
1645: “<span class="quote">make</span>” in the examples in this guide.</p>
1646: </div>
1647: <p>For example, type </p>
1648: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
1649: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong></pre>
1650: <p>at the shell prompt to build the various components of the
1651: package, and</p>
1652: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong></pre>
1653: <p>to install the various components into the correct places
1654: on your system. Installing the package on your system requires
1655: you to be root. However, pkgsrc has a
1656: <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
1657: to only become root for the actual installation step</p>
1658: <p>Taking the figlet utility as an example, we can install it on our
1659: system by building as shown in <a href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
1660: <p>The program is installed under the default root of the packages tree -
1.76 rillig 1661: <code class="filename">/usr/pkg</code>. Should this not conform to your tastes,
1.75 rillig 1662: set the <code class="varname">LOCALBASE</code>
1663: variable in your environment, and it will use that value as the root of
1.76 rillig 1664: your packages tree. So, to use <code class="filename">/usr/local</code>, set
1.75 rillig 1665: <code class="varname">LOCALBASE=/usr/local</code> in your environment. Please note
1666: that you should use a directory which is
1667: dedicated to packages and not shared with other programs (i.e., do not try
1668: and use <code class="varname">LOCALBASE=/usr</code>). Also, you should not try to
1.76 rillig 1669: add any of your own files or directories (such as <code class="filename">src/</code>,
1670: <code class="filename">obj/</code>, or <code class="filename">pkgsrc/</code>) below the
1.75 rillig 1671: <code class="varname">LOCALBASE</code> tree. This is to prevent possible conflicts
1672: between programs and other files installed by the package system and
1673: whatever else may have been installed there.</p>
1.76 rillig 1674: <p>Some packages look in <code class="filename">/etc/mk.conf</code> to alter some
1.75 rillig 1675: configuration options at build time. Have a look at
1.76 rillig 1676: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to
1.75 rillig 1677: get an overview of what will be set there by default. Environment
1678: variables such as <code class="varname">LOCALBASE</code>
1.76 rillig 1679: can be set in <code class="filename">/etc/mk.conf</code> to
1.75 rillig 1680: save having to remember to set them each time you want to use pkgsrc.</p>
1681: <p>Occasionally, people want to “<span class="quote">look under the covers</span>” to see
1682: what is going on when a package is building or being installed. This may be
1683: for debugging purposes, or out of simple curiosity. A number of utility
1684: values have been added to help with this.</p>
1685: <div class="orderedlist"><ol type="1">
1686: <li>
1687: <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>,
1688: then a huge amount of information will be displayed. For example,</p>
1689: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
1690: <p>will show all the commands that are invoked, up to and including the
1691: “<span class="quote">patch</span>” stage.</p>
1692: </li>
1693: <li>
1694: <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
1695: the <code class="varname">VARNAME</code> definition should be used, in conjunction
1696: 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
1697: <code class="varname">LOCALBASE</code>:</p>
1698: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
1699: /usr/pkg
1700: <code class="prompt">%</code>
1701: </pre>
1702: </li>
1703: </ol></div>
1704: <p>If you want to install a binary package that you've either
1705: created yourself (see next section), that you put into pkgsrc/packages manually or
1706: that is located on a remote FTP server, you can use the "bin-install"
1707: target. This target will install a binary package - if available - via
1708: <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>.
1709: The list of remote
1710: FTP sites searched is kept in the variable
1711: <code class="varname">BINPKG_SITES</code>, which defaults to
1712: 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
1713: into <code class="varname">BIN_INSTALL_FLAGS</code>.
1.76 rillig 1714: See <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more details.</p>
1.75 rillig 1715: <p>A final word of warning: If you set up a system that has a non-standard
1716: setting for <code class="varname">LOCALBASE</code>, be sure to set that
1717: before any packages are installed, as you can not use several directories
1718: for the same purpose. Doing so will result in pkgsrc not being able to
1719: properly detect your installed packages, and fail miserably. Note also that
1720: precompiled binary packages are usually built with the default
1721: <code class="varname">LOCALBASE</code> of
1.76 rillig 1722: <code class="filename">/usr/pkg</code>, and that you should <span class="emphasis"><em>not</em></span>
1.75 rillig 1723: install any if you use a non-standard <code class="varname">LOCALBASE</code>.</p>
1724: </div>
1725: <div class="sect2" lang="en">
1726: <div class="titlepage"><div><div><h3 class="title">
1727: <a name="selecting-the-compiler"></a>4.2.4. Selecting the compiler</h3></div></div></div>
1728: <p>By default, pkgsrc will use GCC to build packages. This may be
1729: overridden by setting the following variables in /etc/mk.conf:
1730: </p>
1731: <div class="variablelist"><dl>
1732: <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
1733: <dd>
1734: <p> This is a list of values specifying the chain of
1735: compilers to invoke when building packages. Valid values
1736: are: </p>
1737: <div class="itemizedlist"><ul type="disc">
1738: <li><p><code class="varname">distcc</code>:
1739: distributed C/C++ (chainable)</p></li>
1740: <li><p><code class="varname">ccache</code>:
1741: compiler cache (chainable)</p></li>
1742: <li><p><code class="varname">gcc</code>:
1743: GNU C/C++ Compiler</p></li>
1744: <li><p><code class="varname">mipspro</code>:
1745: Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
1746: <li><p><code class="varname">mipspro</code>:
1747: Silicon Graphics, Inc. MIPSpro (o32)</p></li>
1748: <li><p><code class="varname">sunpro</code>:
1749: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
1750: </ul></div>
1751: <p> The default is
1752: “<span class="quote"><code class="varname">gcc</code></span>”. You can use
1753: <code class="varname">ccache</code> and/or
1754: <code class="varname">distcc</code> with an appropriate
1755: <code class="varname">PKGSRC_COMPILER</code> setting,
1756: e.g. “<span class="quote"><code class="varname">ccache gcc</code></span>”. This
1757: variable should always be
1758: terminated with a value for a real compiler. </p>
1759: </dd>
1760: <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
1761: <dd><p> This specifies the minimum version of GCC to use
1762: when building packages. If the system GCC doesn't
1763: satisfy this requirement, then pkgsrc will build and
1764: install one of the GCC packages to use instead. </p></dd>
1765: </dl></div>
1766: </div>
1767: </div>
1768: </div>
1769: <div class="chapter" lang="en">
1770: <div class="titlepage"><div><div><h2 class="title">
1771: <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
1772: <div class="toc">
1773: <p><b>Table of Contents</b></p>
1774: <dl>
1775: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
1776: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 ! rillig 1777: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
! 1778: <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>
! 1779: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
! 1780: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 1781: </dl>
1782: </div>
1783: <div class="sect1" lang="en">
1784: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1785: <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
1786: <p>In this section, you can find some variables that apply to all
1787: pkgsrc packages. The preferred method of setting these variables
1.76 rillig 1788: is by setting them in <code class="filename">/etc/mk.conf</code>.
1.75 rillig 1789: </p>
1790: <div class="itemizedlist"><ul type="disc">
1791: <li><p><code class="varname">LOCALBASE</code>: Where
1792: packages will be installed. The default is
1.76 rillig 1793: <code class="filename">/usr/pkg</code>. Do not mix binary packages
1.75 rillig 1794: with different <code class="varname">LOCALBASE</code>s!</p></li>
1795: <li><p><code class="varname">CROSSBASE</code>: Where
1796: “<span class="quote">cross</span>” category packages will be
1797: installed. The default is
1.76 rillig 1798: <code class="filename">${LOCALBASE}/cross</code>.</p></li>
1.75 rillig 1799: <li><p><code class="varname">X11BASE</code>: Where
1800: X11 is installed on the system. The default is
1.76 rillig 1801: <code class="filename">/usr/X11R6</code>.</p></li>
1.75 rillig 1802: <li><p><code class="varname">DISTDIR</code>: Where to store the
1803: downloaded copies of the original source distributions used
1804: for building pkgsrc packages. The default is
1.76 rillig 1805: <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
1.75 rillig 1806: <li><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
1807: If set, override the packages'
1808: <code class="varname">MASTER_SITES</code> with this value.</p></li>
1809: <li><p><code class="varname">MASTER_SITE_BACKUP</code>:
1810: Backup location(s) for distribution files and patch files
1811: if not found locally or in
1.76 rillig 1812: <code class="filename">${MASTER_SITES}</code> or
1813: <code class="filename">${PATCH_SITES}</code> respectively.
1.75 rillig 1814: The defaults are
1.76 rillig 1815: <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
1.75 rillig 1816: and
1.76 rillig 1817: <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
1.75 rillig 1818: <li><p><code class="varname">BINPKG_SITES</code>:
1819: List of sites carrying binary pkgs.</p></li>
1820: </ul></div>
1821: <p>
1822: </p>
1823: </div>
1824: <div class="sect1" lang="en">
1825: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1826: <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
1827: <p>XXX
1828: </p>
1829: <div class="itemizedlist"><ul type="disc">
1830: <li><p><code class="varname">PACKAGES</code>: The top level
1831: directory for the binary packages. The default is
1.76 rillig 1832: <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
1.75 rillig 1833: <li><p><code class="varname">WRKOBJDIR</code>:
1834: The top level directory where, if defined, the separate
1835: working directories will get created, and symbolically
1.76 rillig 1836: linked to from <code class="filename">${WRKDIR}</code> (see below).
1.75 rillig 1837: This is useful for building packages on several
1.76 rillig 1838: architectures, then <code class="filename">${PKGSRCDIR}</code>
1839: can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
1.75 rillig 1840: is local to every architecture. (It should be noted that
1841: <code class="varname">PKGSRCDIR</code> should not be set by the user
1.78 ! rillig 1842: — it is an internal definition which refers to the
1.75 rillig 1843: root of the pkgsrc tree. It is possible to have many
1844: pkgsrc tree instances.)</p></li>
1845: <li><p><code class="varname">LOCALPATCHES</code>:
1846: Directory for local patches that aren't part of pkgsrc.
1.77 rillig 1847: See <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a> for more
1.75 rillig 1848: information. <em class="replaceable"><code>rel</code></em> and
1849: <em class="replaceable"><code>arch</code></em> are replaced with OS
1850: release (“<span class="quote">2.0</span>”, etc.) and architecture
1851: (“<span class="quote">mipsel</span>”, etc.).</p></li>
1852: <li><p><code class="varname">PKGMAKECONF</code>: Location of
1.76 rillig 1853: the <code class="filename">mk.conf</code> file used by a package's
1.75 rillig 1854: BSD-style Makefile. If this is not set,
1855: <code class="varname">MAKECONF</code> is set to
1.76 rillig 1856: <code class="filename">/dev/null</code> to avoid picking up
1857: settings used by builds in <code class="filename">/usr/src</code>.</p></li>
1.75 rillig 1858: </ul></div>
1859: <p>
1860: </p>
1861: </div>
1862: <div class="sect1" lang="en">
1863: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 ! rillig 1864: <a name="conf.compiler"></a>5.3. Selecting and configuring the compiler</h2></div></div></div>
! 1865: <div class="sect2" lang="en">
! 1866: <div class="titlepage"><div><div><h3 class="title">
! 1867: <a name="conf.cflags"></a>5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</h3></div></div></div>
! 1868: <p>If you wish to set the <code class="varname">CFLAGS</code> variable,
! 1869: please make sure to use the <code class="literal">+=</code> operator
! 1870: instead of the <code class="literal">=</code> operator:</p>
! 1871: <pre class="programlisting">
! 1872: CFLAGS+= -your -flags
! 1873: </pre>
! 1874: <p>Using <code class="varname">CFLAGS=</code> (i.e. without the
! 1875: “<span class="quote">+</span>”) may lead to problems with packages that need
! 1876: to add their own flags. Also, you may want to take a look at
! 1877: 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
! 1878: you're interested in optimization for the current CPU.</p>
! 1879: </div>
! 1880: </div>
! 1881: <div class="sect1" lang="en">
! 1882: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 1883: <a name="developer-advanced-settings"></a>5.4. Developer/advanced settings</h2></div></div></div>
1.75 rillig 1884: <p>XXX
1885: </p>
1886: <div class="itemizedlist"><ul type="disc">
1887: <li>
1888: <p><code class="varname">PKG_DEVELOPER</code>:
1889: Run some sanity checks that package developers want:
1890: </p>
1891: <div class="itemizedlist"><ul type="circle">
1892: <li><p>make sure patches apply with zero fuzz</p></li>
1893: <li><p>run check-shlibs to see that all binaries will
1894: find their shared libs.</p></li>
1895: </ul></div>
1896: <p>
1897: </p>
1898: </li>
1899: <li><p><code class="varname">PKG_DEBUG_LEVEL</code>:
1900: The level of debugging output which is displayed whilst
1901: making and installing the package.
1902: The default value for this is 0, which will not display
1903: the commands as they are executed (normal, default, quiet
1904: operation); the value 1 will display all shell commands
1905: before their invocation, and the value 2 will display both
1906: the shell commands before their invocation, and their
1907: actual execution progress with <span><strong class="command">set -x</strong></span>
1908: will be displayed.</p></li>
1909: <li><p><code class="varname">ALLOW_VULNERABILITIES.<em class="replaceable"><code>pkgbase</code></em></code>:
1910: A space separated list of vulnerability IDs that may be ignored when
1911: performing the automated security checks. These IDs are listed in the
1912: pkg-vulnerabilities file and are displayed by
1913: <span><strong class="command">audit-packages</strong></span> when
1914: it finds a vulnerable package.
1915: </p></li>
1916: <li><p><code class="varname">SKIP_AUDIT_PACKAGES</code>:
1917: If this is set to “<span class="quote">yes</span>”, the automated security checks
1.76 rillig 1918: (which use the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>
1.75 rillig 1919: package) will be <span class="strong"><strong>entirely</strong></span> skipped
1920: for <span class="strong"><strong>all</strong></span> packages built. Normally
1921: you'll want to use ALLOW_VULNERABILITIES instead of this.
1922: </p></li>
1923: </ul></div>
1924: <p>
1925: </p>
1926: </div>
1927: <div class="sect1" lang="en">
1928: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 ! rillig 1929: <a name="selecting-build-options"></a>5.5. Selecting Build Options</h2></div></div></div>
1.75 rillig 1930: <p>Some packages have build time options, usually to select between
1931: different dependencies, enable optional support for big dependencies
1932: or enable experimental features.</p>
1933: <p>To see which options, if any, a package supports, and which
1934: options are mutually exclusive, run <span><strong class="command">make show-options</strong></span>,
1935: for example:</p>
1936: <pre class="programlisting">
1937: The following options are supported by this package:
1938: ssl Enable SSL support.
1939: Exactly one of the following gecko options is required:
1940: firefox Use firefox as gecko rendering engine.
1941: mozilla Use mozilla as gecko rendering engine.
1942: At most one of the following database options may be selected:
1943: mysql Enable support for MySQL database.
1944: pgsql Enable support for PostgreSQL database.
1.1 grant 1945:
1.75 rillig 1946: These options are enabled by default: firefox
1947: These options are currently enabled: mozilla ssl
1.1 grant 1948: </pre>
1.75 rillig 1949: <p>The following variables can be defined in
1.76 rillig 1950: <code class="filename">/etc/mk.conf</code> to select which options to enable
1.75 rillig 1951: for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which can be
1952: used to select or disable options for all packages that support them,
1953: and <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
1954: which can be used to select or disable options specifically for
1955: package <em class="replaceable"><code>pkgbase</code></em>. Options listed in these
1956: variables are selected, options preceded by “<span class="quote">-</span>” are
1957: disabled. A few examples:</p>
1958: <pre class="screen">
1959: <code class="prompt">$</code> <span><strong class="command">grep "PKG.*OPTION" /etc/mk.conf</strong></span>
1960: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
1961: PKG_OPTIONS.kdebase= debug -sasl
1962: PKG_OPTIONS.apache= suexec </pre>
1963: <p>The following settings are consulted in the order given, and the
1964: last setting that selects or disables an option is used:</p>
1965: <div class="orderedlist"><ol type="1">
1966: <li><p>the default options as suggested by the package
1967: maintainer</p></li>
1968: <li><p>the options implied by the settings of legacy
1969: variables (see below)</p></li>
1970: <li><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
1971: <li><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
1972: </ol></div>
1973: <p>For groups of mutually exclusive options, the last option
1974: selected is used, all others are automatically disabled. If an option
1975: of the group is explicitly disabled, the previously selected option,
1976: if any, is used. It is an error if no option from a required group of
1977: options is selected, and building the package will fail.</p>
1978: <p>Before the options framework was introduced, build options were
1979: selected by setting a variable (often named
1980: <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
1.76 rillig 1981: <code class="filename">/etc/mk.conf</code> for each option. To ease transition
1.75 rillig 1982: to the options framework for the user, these legacy variables are
1983: converted to the appropriate options setting
1984: (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
1985: automatically. A warning is issued to prompt the user to
1.76 rillig 1986: update <code class="filename">/etc/mk.conf</code> to use the options framework
1.75 rillig 1987: directly. Support for the legacy variables will be removed
1988: eventually.</p>
1989: </div>
1990: </div>
1991: <div class="chapter" lang="en">
1992: <div class="titlepage"><div><div><h2 class="title">
1993: <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
1994: <div class="toc">
1995: <p><b>Table of Contents</b></p>
1996: <dl>
1997: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
1998: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
1999: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
2000: <dd><dl>
2001: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
2002: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
2003: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
2004: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
2005: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
2006: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
2007: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
2008: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
2009: </dl></dd>
2010: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
2011: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
2012: </dl>
2013: </div>
2014: <div class="sect1" lang="en">
2015: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2016: <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
2017: <p>
2018: Once you have built and installed a package, you can create a
2019: <span class="emphasis"><em>binary package</em></span> which can be installed on
2020: 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
2021: the same package on a group of hosts and wasting CPU time. It
2022: also provides a simple means for others to install your package,
2023: should you distribute it.
2024: </p>
2025: <p>
2026: To create a binary package, change into the appropriate
2027: directory in pkgsrc, and run <span><strong class="command">make
2028: package</strong></span>:
2029: </p>
2030: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
2031: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
2032: <p>
2033: This will build and install your package (if not already done),
2034: and then build a binary package from what was installed. You can
2035: then use the <span><strong class="command">pkg_*</strong></span> tools to manipulate
2036: it. Binary packages are created by default in
1.76 rillig 2037: <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
1.75 rillig 2038: gzipped tar file. See <a href="#logs.package" title="B.2. Packaging figlet">Section B.2, “Packaging figlet”</a> for a
1.76 rillig 2039: 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 2040: <p>
1.77 rillig 2041: 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 2042: such a binary package.</p>
2043: </div>
2044: <div class="sect1" lang="en">
2045: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2046: <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
1.77 rillig 2047: <p>See <a href="#build.helpful-targets" title="15.16. Other helpful targets">Section 15.16, “Other helpful targets”</a>.</p>
1.75 rillig 2048: </div>
2049: <div class="sect1" lang="en">
2050: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2051: <a name="bulkbuild"></a>6.3. Doing a bulk build of all packages</h2></div></div></div>
2052: <p>If you want to get a full set of precompiled binary
2053: packages, this section describes how to get them. Beware that
2054: the bulk build will remove all currently installed packages from
2055: your system!</p>
2056: <p>Having an FTP server configured either on the
2057: machine doing the bulk builds or on a nearby NFS server can help
2058: to make the packages available to other machines that can then
2059: 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
2060: more information. If you use a remote NFS server's storage, be
2061: sure to not actually compile on NFS storage, as this slows
2062: things down a lot.</p>
2063: <div class="sect2" lang="en">
2064: <div class="titlepage"><div><div><h3 class="title">
2065: <a name="binary.configuration"></a>6.3.1. Configuration</h3></div></div></div>
2066: <div class="sect3" lang="en">
2067: <div class="titlepage"><div><div><h4 class="title">
1.76 rillig 2068: <a name="binary.bulk.build.conf"></a>6.3.1.1. <code class="filename">build.conf</code></h4></div></div></div>
2069: <p>The <code class="filename">build.conf</code> file is the main
1.75 rillig 2070: configuration file for bulk builds. You can configure how your
2071: copy of pkgsrc is kept up to date, how the distfiles are
2072: downloaded, how the packages are built and how the report is
2073: generated. You can find an annotated example file in
1.76 rillig 2074: <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
2075: it, copy <code class="filename">build.conf-example</code> to
2076: <code class="filename">build.conf</code> and edit it, following the
1.75 rillig 2077: comments in that file.</p>
2078: </div>
2079: <div class="sect3" lang="en">
2080: <div class="titlepage"><div><div><h4 class="title">
2081: <a name="binary.mk.conf"></a>6.3.1.2. /etc/mk.conf</h4></div></div></div>
2082: <p>You may want to set variables in
1.76 rillig 2083: <code class="filename">/etc/mk.conf</code>.
2084: Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
1.75 rillig 2085: details of the default settings. You will want to ensure that
2086: <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
2087: As used in this example, <code class="varname">_ACCEPTABLE=yes</code>
2088: accepts <span class="emphasis"><em>all</em></span> licenses.</p>
2089: <pre class="programlisting">
2090: PACKAGES?= ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
2091: WRKOBJDIR?= /usr/tmp/pkgsrc # build here instead of in pkgsrc
2092: BSDSRCDIR= /usr/src
2093: BSDXSRCDIR= /usr/xsrc # for x11/xservers
2094: OBJHOSTNAME?= yes # use work.`hostname`
2095: FAILOVER_FETCH= yes # insist on the correct checksum
2096: PKG_DEVELOPER?= yes
2097: _ACCEPTABLE= yes
1.1 grant 2098: </pre>
1.75 rillig 2099: <p>Some options that are especially useful for bulk builds
2100: can be found at the top lines of the file
1.76 rillig 2101: <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
1.75 rillig 2102: options of these are briefly described here.</p>
2103: <div class="itemizedlist"><ul type="disc">
2104: <li><p>If you are on a slow machine, you may want to
2105: set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
2106: “<span class="quote">no</span>”.</p></li>
2107: <li><p>If you are doing bulk builds from a read-only
2108: copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
2109: to the directory where all log files are created. Otherwise the
2110: log files are created in the pkgsrc directory.</p></li>
2111: <li><p>Another important variable is
2112: <code class="varname">BULK_PREREQ</code>, which is a list of packages that
2113: should be always available while building other
2114: packages.</p></li>
2115: </ul></div>
2116: <p>Some other options are scattered in the pkgsrc
2117: infrastructure:</p>
2118: <div class="itemizedlist"><ul type="disc">
2119: <li><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
2120: should be set to <code class="literal">yes</code>. The purpose of the bulk
2121: builds is creating binary packages, no matter if they are
2122: vulnerable or not. When uploading the packages to a public
2123: server, the vulnerable packages will be put into a directory of
2124: their own. Leaving this variable unset would prevent the bulk
2125: build system from even trying to build them, so possible
2126: building errors would not show up.</p></li>
2127: <li><p><code class="varname">CHECK_FILES</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 set of files
1.76 rillig 2130: matches the <code class="filename">PLIST</code>.</p></li>
1.75 rillig 2131: <li><p><code class="varname">CHECK_INTERPRETER</code>
1.76 rillig 2132: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75 rillig 2133: “<span class="quote">yes</span>” to check that the installed
2134: “<span class="quote">#!</span>”-scripts will find their
2135: interpreter.</p></li>
2136: </ul></div>
2137: </div>
2138: <div class="sect3" lang="en">
2139: <div class="titlepage"><div><div><h4 class="title">
1.76 rillig 2140: <a name="pre-build.local"></a>6.3.1.3. <code class="filename">pre-build.local</code></h4></div></div></div>
1.75 rillig 2141: <p>It is possible to configure the bulk build to perform
2142: certain site-specific tasks at the end of the pre-build
2143: stage. If the file
1.76 rillig 2144: <code class="filename">pre-build.local</code> exists in
2145: <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
1.75 rillig 2146: (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
2147: stage. An example use of
1.76 rillig 2148: <code class="filename">pre-build.local</code> is to have the line:</p>
1.75 rillig 2149: <pre class="screen">echo "I do not have enough disk space to build this pig." \
2150: > misc/openoffice/$BROKENF</pre>
2151: <p>to prevent the system from trying to build a particular package
2152: which requires nearly 3 GB of disk space.</p>
2153: </div>
2154: </div>
2155: <div class="sect2" lang="en">
2156: <div class="titlepage"><div><div><h3 class="title">
2157: <a name="other-environmental-considerations"></a>6.3.2. Other environmental considerations</h3></div></div></div>
1.76 rillig 2158: <p>As <code class="filename">/usr/pkg</code> will be completely
1.75 rillig 2159: deleted at the start of bulk builds, make sure your login
2160: shell is placed somewhere else. Either drop it into
1.76 rillig 2161: <code class="filename">/usr/local/bin</code> (and adjust your login
1.75 rillig 2162: shell in the passwd file), or (re-)install it via
1.76 rillig 2163: <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 2164: you can login after a reboot (remember that your current
2165: process won't die if the package is removed, you just can't
2166: start any new instances of the shell any more). Also, if you
2167: use NetBSD earlier than 1.5, or you still want to use the pkgsrc
2168: version of ssh for some reason, be sure to install ssh before
1.76 rillig 2169: starting it from <code class="filename">rc.local</code>:</p>
1.75 rillig 2170: <pre class="programlisting">
2171: ( cd /usr/pkgsrc/security/ssh ; make bulk-install )
2172: if [ -f /usr/pkg/etc/rc.d/sshd ]; then
2173: /usr/pkg/etc/rc.d/sshd
2174: fi
1.1 grant 2175: </pre>
1.75 rillig 2176: <p>Not doing so will result in you being not able to log in
2177: via ssh after the bulk build is finished or if the machine
2178: gets rebooted or crashes. You have been warned! :)</p>
2179: </div>
2180: <div class="sect2" lang="en">
2181: <div class="titlepage"><div><div><h3 class="title">
2182: <a name="operation"></a>6.3.3. Operation</h3></div></div></div>
2183: <p>Make sure you don't need any of the packages still
2184: installed.
2185: </p>
2186: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
2187: <h3 class="title">Warning</h3>
2188: <p>During the bulk build, <span class="emphasis"><em>all packages will be
2189: removed!</em></span></p>
2190: </div>
2191: <p>Be sure to remove all other things that might
2192: interfere with builds, like some libs installed in
1.76 rillig 2193: <code class="filename">/usr/local</code>, etc. then become root and type:</p>
1.75 rillig 2194: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2195: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong></pre>
2196: <p>If for some reason your last build didn't complete (power
2197: failure, system panic, ...), you can continue it by
2198: running:</p>
2199: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
2200: <p>
2201: At the end of the bulk build, you will get a summary via mail,
2202: and find build logs in the directory specified by
1.76 rillig 2203: <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
1.75 rillig 2204: file.
2205: </p>
2206: </div>
2207: <div class="sect2" lang="en">
2208: <div class="titlepage"><div><div><h3 class="title">
2209: <a name="what-it-does"></a>6.3.4. What it does</h3></div></div></div>
2210: <p>The bulk builds consist of three steps:</p>
2211: <div class="variablelist"><dl>
2212: <dt><span class="term">1. pre-build</span></dt>
2213: <dd><p>
2214: The script updates your pkgsrc tree via (anon)cvs, then
2215: cleans out any broken distfiles, and removes all
2216: packages installed.</p></dd>
2217: <dt><span class="term">2. the bulk build</span></dt>
2218: <dd><p>
2219: This is basically “<span class="quote">make bulk-package</span>” with
2220: an optimised order in which packages will be
2221: built. Packages that don't require other packages will
2222: be built first, and packages with many dependencies will
2223: be built later.
2224: </p></dd>
2225: <dt><span class="term">3. post-build</span></dt>
2226: <dd><p>
2227: Generates a report that's placed in the directory
1.76 rillig 2228: specified in the <code class="filename">build.conf</code> file
2229: named <code class="filename">broken.html</code>, a short version
1.75 rillig 2230: of that report will also be mailed to the build's
2231: admin.</p></dd>
2232: </dl></div>
2233: <p>
2234: During the build, a list of broken packages will be compiled
1.76 rillig 2235: in <code class="filename">/usr/pkgsrc/.broken</code> (or
2236: <code class="filename">.../.broken.${MACHINE}</code> if
1.75 rillig 2237: <code class="varname">OBJMACHINE</code> is set), individual build logs
2238: of broken builds can be found in the package's
2239: directory. These files are used by the bulk-targets to mark
2240: broken builds to not waste time trying to rebuild them, and
2241: they can be used to debug these broken package builds
2242: later.
2243: </p>
2244: </div>
2245: <div class="sect2" lang="en">
2246: <div class="titlepage"><div><div><h3 class="title">
2247: <a name="disk-space-requirements"></a>6.3.5. Disk space requirements</h3></div></div></div>
2248: <p>Currently, roughly the following requirements are valid for
2249: NetBSD 2.0/i386:</p>
2250: <div class="itemizedlist"><ul type="disc">
2251: <li><p>
2252: 10 GB - distfiles (NFS ok)
2253: </p></li>
2254: <li><p>
2255: 8 GB - full set of all binaries (NFS ok)
2256: </p></li>
2257: <li><p>
2258: 5 GB - temp space for compiling (local disk recommended)
2259: </p></li>
2260: </ul></div>
2261: <p>
2262: Note that all pkgs will be de-installed as soon as they are
2263: turned into a binary package, and that sources are removed,
2264: so there is no excessively huge demand to disk
2265: space. Afterwards, if the package is needed again, it will
2266: 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
2267: there are no cycles wasted by recompiling.
2268: </p>
2269: </div>
2270: <div class="sect2" lang="en">
2271: <div class="titlepage"><div><div><h3 class="title">
2272: <a name="setting-up-a-sandbox"></a>6.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
2273: <p>
2274: If you don't want all the packages nuked from a machine
2275: (rendering it useless for anything but pkg compiling), there
2276: is the possibility of doing the package bulk build inside a
2277: chroot environment.
2278: </p>
2279: <p>
2280: The first step is to set up a chroot sandbox,
1.76 rillig 2281: e.g. <code class="filename">/usr/sandbox</code>. This can be done by
1.75 rillig 2282: using null mounts, or manually.
2283: </p>
2284: <p>
2285: There is a shell script called
1.76 rillig 2286: <code class="filename">pkgsrc/mk/bulk/mksandbox</code> which will set
1.75 rillig 2287: up the sandbox environment using null mounts. It will also
1.76 rillig 2288: create a script called <code class="filename">sandbox</code> in the
1.75 rillig 2289: root of the sandbox environment, which will allow the null
2290: mounts to be activated using the <span><strong class="command">sandbox
2291: mount</strong></span> command and deactivated using the
2292: <span><strong class="command">sandbox umount</strong></span> command.
2293: </p>
2294: <p>
2295: To set up a sandbox environment by hand, after extracting all
2296: the sets from a NetBSD installation or doing a <span><strong class="command">make
2297: distribution DESTDIR=/usr/sandbox</strong></span> in
1.76 rillig 2298: <code class="filename">/usr/src/etc</code>, be sure the following items
1.75 rillig 2299: are present and properly configured:
2300: </p>
2301: <div class="procedure"><ol type="1">
2302: <li>
2303: <p>Kernel</p>
2304: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
2305: </li>
2306: <li>
1.76 rillig 2307: <p><code class="filename">/dev/*</code></p>
1.75 rillig 2308: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
2309: </li>
2310: <li>
1.76 rillig 2311: <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 2312: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
2313: </li>
2314: <li>
2315: <p>Working(!) mail config (hostname, sendmail.cf):</p>
2316: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
2317: </li>
2318: <li>
1.76 rillig 2319: <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 2320: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
2321: </li>
2322: <li>
1.76 rillig 2323: <p><code class="filename">/usr/src</code> (system sources,
1.78 ! rillig 2324: 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 2325: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
2326: <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
2327: </li>
2328: <li>
1.76 rillig 2329: <p>Create <code class="filename">/var/db/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/var/db/pkg</code></strong></pre>
2331: </li>
2332: <li>
1.76 rillig 2333: <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
1.75 rillig 2334: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
2335: </li>
2336: <li>
2337: <p>Checkout pkgsrc via cvs into
1.76 rillig 2338: <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
1.75 rillig 2339: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
2340: <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong></pre>
2341: <p>Do not mount/link this to the copy of your pkgsrc tree
2342: you do development in, as this will likely cause problems!
2343: </p>
2344: </li>
2345: <li><p>Make
1.76 rillig 2346: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
2347: <code class="filename">.../distfiles</code> point somewhere
1.75 rillig 2348: appropriate. NFS- and/or nullfs-mounts may come in handy!
2349: </p></li>
1.76 rillig 2350: <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>
2351: <li><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
1.75 rillig 2352: </ol></div>
2353: <p>When the chroot sandbox is set up, you can start
2354: the build with the following steps:</p>
2355: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2356: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong></pre>
2357: <p>
2358: This will just jump inside the sandbox and start building. At
2359: the end of the build, mail will be sent with the results of
2360: the build. Created binary pkgs will be in
1.76 rillig 2361: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
1.75 rillig 2362: (wherever that points/mounts to/from).</p>
2363: </div>
2364: <div class="sect2" lang="en">
2365: <div class="titlepage"><div><div><h3 class="title">
2366: <a name="building-a-partial-set"></a>6.3.7. Building a partial set of packages</h3></div></div></div>
2367: <p> In addition to building a complete set of all packages in
1.76 rillig 2368: pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
1.75 rillig 2369: may be used to build a subset of the packages contained in
2370: pkgsrc. By setting <code class="varname">SPECIFIC_PKGS</code>
1.76 rillig 2371: in <code class="filename">/etc/mk.conf</code>, the variables</p>
1.75 rillig 2372: <div class="itemizedlist"><ul type="disc">
2373: <li><p>SITE_SPECIFIC_PKGS</p></li>
2374: <li><p>HOST_SPECIFIC_PKGS</p></li>
2375: <li><p>GROUP_SPECIFIC_PKGS</p></li>
2376: <li><p>USER_SPECIFIC_PKGS</p></li>
2377: </ul></div>
2378: <p> will define the set of packages which should be built.
2379: The bulk build code will also include any packages which are
2380: needed as dependencies for the explicitly listed packages.
2381: </p>
2382: <p> One use of this is to do a bulk build with
2383: <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
2384: periodically to have a complete set of the binary packages
2385: needed for your site available without the overhead of
2386: building extra packages that are not needed. </p>
2387: </div>
2388: <div class="sect2" lang="en">
2389: <div class="titlepage"><div><div><h3 class="title">
2390: <a name="bulk-upload"></a>6.3.8. Uploading results of a bulk build</h3></div></div></div>
2391: <p>
2392: This section describes how pkgsrc developers can upload binary
2393: pkgs built by bulk builds to ftp.NetBSD.org.
2394: </p>
2395: <p>
2396: If you would like to automatically create checksum files for the
2397: binary packages you intend to upload, remember to set
2398: <code class="varname">MKSUMS=yes</code> in your
1.76 rillig 2399: <code class="filename">mk/bulk/build.conf</code>.
1.75 rillig 2400: </p>
2401: <p>
2402: If you would like to PGP sign the checksum files (highly
2403: recommended!), remember to set
2404: <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
1.76 rillig 2405: <code class="filename">mk/bulk/build.conf</code>. This will prompt you for
1.75 rillig 2406: your GPG password to sign the files before uploading everything.
2407: </p>
2408: <p>
2409: Then, make sure that you have <code class="varname">RSYNC_DST</code>
1.76 rillig 2410: set properly in your <code class="filename">mk/bulk/build.conf</code>
1.75 rillig 2411: file, i.e. adjust it to something like one of the following:
2412: </p>
2413: <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
2414: <p>Please use appropriate values for "pkgsrc-200xQy",
2415: "NetBSD-a.b.c" and "arch" here. If your login on ftp.NetBSD.org
2416: is different from your local login, write your login directly
2417: into the variable, e.g. my local account is "feyrer", but for my
2418: login "hubertf", I use:</p>
2419: <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
2420: <p>
1.76 rillig 2421: A separate <code class="filename">upload</code> directory is used
1.75 rillig 2422: here to allow "closing" the directory during upload. To do
2423: so, run the following command on ftp.NetBSD.org next:
2424: </p>
2425: <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>
2426: <p>
1.76 rillig 2427: Please note that <code class="filename">/pub/NetBSD/packages</code> is
1.75 rillig 2428: only appropriate for packages for the NetBSD operating
2429: system. Binary packages for other operating systems should go
1.76 rillig 2430: into <code class="filename">/pub/pkgsrc</code>.
1.75 rillig 2431: </p>
2432: <p>
2433: Before uploading the binary pkgs, ssh authentication needs to
2434: be set up. This example shows how to set up temporary keys
2435: for the root account <span class="emphasis"><em>inside the sandbox</em></span>
2436: (assuming that no keys should be present there usually):
2437: </p>
2438: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
2439: chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
2440: chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t dsa</code></strong>
2441: chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong> </pre>
2442: <p>
1.76 rillig 2443: Now take the output of <code class="filename">id-dsa.pub</code> and
2444: append it to your <code class="filename">~/.ssh/authorized_keys</code>
1.75 rillig 2445: file on ftp.NetBSD.org. You can remove the key after the
2446: upload is done!
2447: </p>
2448: <p>
2449: Next, test if your ssh connection really works:
2450: </p>
2451: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
2452: <p>
2453: Use "-l yourNetBSDlogin" here as appropriate!
2454: </p>
2455: <p>
2456: Now after all this works, you can exit the sandbox and start
2457: the upload:
2458: </p>
2459: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
2460: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2461: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong> </pre>
2462: <p>
2463: 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
2464: <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
2465: upload. The upload script will take care of not uploading
2466: restricted packages and putting vulnerable packages into the
1.76 rillig 2467: <code class="filename">vulnerable</code> subdirectory.
1.75 rillig 2468: </p>
2469: <p>
2470: After the upload has ended, first thing is to revoke ssh access:
2471: </p>
2472: <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
2473: Gdd:x! </pre>
2474: <p>
2475: Use whatever is needed to remove the key you've entered
2476: before! Last, move the uploaded packages out of the
1.76 rillig 2477: <code class="filename">upload</code> directory to have them accessible
1.75 rillig 2478: to everyone:
2479: </p>
2480: <pre class="screen">nbftp% <strong class="userinput"><code>cd /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch</code></strong>
2481: nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
2482: nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
2483: nbftp% <strong class="userinput"><code>chmod 755 .</code></strong> </pre>
2484: </div>
2485: </div>
2486: <div class="sect1" lang="en">
2487: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2488: <a name="creating-cdroms"></a>6.4. Creating a multiple CD-ROM packages collection</h2></div></div></div>
2489: <p>
2490: After your pkgsrc bulk-build has completed, you may wish to
2491: create a CD-ROM set of the resulting binary packages to assist
2492: in installing packages on other machines. The
1.76 rillig 2493: <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 2494: a simple tool for creating the ISO 9660 images.
2495: <span><strong class="command">cdpack</strong></span> arranges the packages on the CD-ROMs in a
2496: way that keeps all the dependencies for a given package on the same
2497: CD as that package.
2498: </p>
2499: <div class="sect2" lang="en">
2500: <div class="titlepage"><div><div><h3 class="title">
2501: <a name="cdpack-example"></a>6.4.1. Example of cdpack</h3></div></div></div>
2502: <p>
2503: Complete documentation for cdpack is found in the cdpack(1)
2504: man page. The following short example assumes that the binary
2505: packages are left in
1.76 rillig 2506: <code class="filename">/usr/pkgsrc/packages/All</code> and that
2507: sufficient disk space exists in <code class="filename">/u2</code> to
1.75 rillig 2508: hold the ISO 9660 images.</p>
2509: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
2510: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
2511: <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong></pre>
2512: <p>
2513: If you wish to include a common set of files
1.76 rillig 2514: (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
1.75 rillig 2515: etc.) on each CD in the collection, then you need to create a
2516: directory which contains these files. e.g.
2517: </p>
2518: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
2519: <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" > /tmp/common/README</code></strong>
2520: <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" > /tmp/common/COPYING</code></strong>
2521: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
2522: <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" > /tmp/common/bin/myscript</code></strong>
2523: <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" >> /tmp/common/bin/myscript</code></strong>
2524: <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong></pre>
2525: <p>Now create the images:</p>
2526: <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 2527: <p>Each image will contain <code class="filename">README</code>,
2528: <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
1.75 rillig 2529: in their root directories.</p>
2530: </div>
2531: </div>
2532: </div>
2533: <div class="chapter" lang="en">
2534: <div class="titlepage"><div><div><h2 class="title">
2535: <a name="faq"></a>Chapter 7. Frequently Asked Questions</h2></div></div></div>
2536: <div class="toc">
2537: <p><b>Table of Contents</b></p>
2538: <dl>
2539: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
2540: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
2541: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
2542: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
2543: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
2544: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
2545: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
2546: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
2547: <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>
2548: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
2549: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
2550: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
2551: <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>
2552: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
2553: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
2554: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
2555: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
2556: </dl>
2557: </div>
2558: <p>This section contains hints, tips & tricks on special things in
2559: pkgsrc that we didn't find a better place for in the previous chapters, and
2560: it contains items for both pkgsrc users and developers.</p>
2561: <div class="sect1" lang="en">
2562: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2563: <a name="mailing-list-pointers"></a>7.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
2564: <p>The following mailing lists may be of interest to pkgsrc users:</p>
2565: <div class="itemizedlist"><ul type="disc">
1.78 ! rillig 2566: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-users" target="_top">pkgsrc-users</a>:
! 2567: This is a general purpose list for most issues regarding
! 2568: pkgsrc, regardless of platform, e.g. soliciting user help
! 2569: for pkgsrc configuration, unexpected build failures, using
! 2570: particular packages, upgrading pkgsrc installations,
! 2571: questions regarding the pkgsrc release branches, etc. General announcements or
! 2572: proposals for changes that impact the pkgsrc user community,
! 2573: e.g. major infrastructure changes, new features, package
! 2574: removals, etc., may also be posted.</p></li>
1.75 rillig 2575: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
2576: A list where the results of pkgsrc bulk builds are sent and
2577: discussed.</p></li>
2578: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
2579: This list is for those who are interested in getting a
2580: commit message for every change committed to pkgsrc. It is
2581: also available in digest form, meaning one daily message
2582: containing all commit messages for changes to the package
2583: source tree in that 24 hour period.</p></li>
2584: </ul></div>
2585: <p>To subscribe, do:</p>
2586: <pre class="programlisting">
2587: <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
2588: </pre>
2589: <p>Archives for all these mailing lists are available from
2590: <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
2591: </div>
2592: <div class="sect1" lang="en">
2593: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2594: <a name="pkgviews-docs"></a>7.2. Where's the pkgviews documentation?</h2></div></div></div>
2595: <p>Pkgviews is tightly integrated with buildlink. You can find a
2596: pkgviews User's guide in
1.76 rillig 2597: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
1.75 rillig 2598: </div>
2599: <div class="sect1" lang="en">
2600: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2601: <a name="faq-pkgtools"></a>7.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.76 rillig 2602: <p>The <code class="filename">pkgsrc/pkgtools</code> directory pkgtools contains
1.75 rillig 2603: a number of useful utilities for both users and developers of pkgsrc. This
2604: section attempts only to make the reader aware of the utilities and when
2605: they might be useful, and not to duplicate the documentation that comes
2606: with each package.</p>
2607: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
1.76 rillig 2608: <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 2609: Symlinks for use by buildlink.</p></li></ul></div>
2610: <p>OS tool augmentation (automatically installed when needed):</p>
2611: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2612: <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 2613: Calculates various kinds of checksums (including SHA1).</p></li>
1.76 rillig 2614: <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 2615: Compatibility library for pkgsrc tools.</p></li>
1.76 rillig 2616: <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 2617: non-BSD systems due to lack of native mtree.
2618: </p></li>
1.76 rillig 2619: <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 2620: Up-to-date replacement for
1.76 rillig 2621: <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
1.75 rillig 2622: systems where pkg_install is not present.</p></li>
2623: </ul></div>
2624: <p>Utilities used by pkgsrc (not automatically installed):</p>
2625: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2626: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_tarup/README.html" target="_top"><code class="filename">pkgtools/pkg_tarup</code></a>:
1.75 rillig 2627: Create a binary package from an
2628: already-installed package. Used by <span><strong class="command">make replace</strong></span> to
2629: save the old package.</p></li>
1.76 rillig 2630: <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 2631: Adds extra functionality to pkgsrc, allowing it to fetch distfiles
2632: from multiple locations. It currently supports the following
2633: methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
1.76 rillig 2634: <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 2635: packages someplace else (enabled by default).</p></li>
1.76 rillig 2636: <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 2637: best compiler flags to optimise code for your current CPU and
2638: compiler.</p></li>
2639: </ul></div>
2640: <p>Utilities for keeping track of installed packages, being up to date,
2641: etc:</p>
2642: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2643: <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 2644: packages whose installed versions do not match the latest pkgsrc
2645: entries.</p></li>
1.76 rillig 2646: <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 2647: dependency graphs of packages, to aid in choosing a strategy for
2648: updating.</p></li>
1.76 rillig 2649: <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
2650: 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>
2651: <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 2652: pkglint(1) program checks a pkgsrc entry for errors, lintpkgsrc(1)
2653: does various checks on the complete pkgsrc system.</p></li>
1.76 rillig 2654: <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 2655: packages you have installed.</p></li>
2656: </ul></div>
2657: <p>Utilities for people maintaining or creating individual packages:</p>
2658: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2659: <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 2660: making and maintaining patches for a package (includes pkgdiff,
2661: pkgvi, mkpatches, etc.).</p></li>
1.76 rillig 2662: <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>,
2663: <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 2664: converting to pkgsrc.</p></li>
1.76 rillig 2665: <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 2666: pkgsrc to a Solaris package.</p></li>
2667: </ul></div>
2668: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
2669: utilities)</p>
2670: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2671: <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 2672: packages in a chrooted area.</p></li>
1.76 rillig 2673: <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 2674: kernel version for chrooted cross builds.</p></li>
2675: </ul></div>
2676: </div>
2677: <div class="sect1" lang="en">
2678: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2679: <a name="non-root-pkgsrc"></a>7.4. How to use pkgsrc as non-root</h2></div></div></div>
2680: <p>If you want to use pkgsrc as non-root user, you can set some
2681: variables to make pkgsrc work under these conditions. At the very least,
2682: you need to set <code class="varname">UNPRIVILEGED</code> to “<span class="quote">yes</span>”; this
2683: will turn on unprivileged mode and set multiple related variables to allow
2684: installation of packages as non-root.</p>
2685: <p>In case the defaults are not enough, you may want to tune some other
2686: variables used. For example, if the automatic user/group detection leads
2687: to incorrect values (or not the ones you would like to use), you can change
2688: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
2689: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
2690: <p>As regards bootstrapping, please note that the
2691: <span><strong class="command">bootstrap</strong></span> script will ease non-root configuration when
2692: given the “<span class="quote">--ignore-user-check</span>” flag, as it will choose and
1.76 rillig 2693: use multiple default directories under <code class="filename">~/pkg</code> as the
1.75 rillig 2694: installation targets. These directories can be overriden by the
2695: “<span class="quote">--prefix</span>” flag provided by the script, as well as some others
2696: that allow finer tuning of the tree layout.</p>
2697: </div>
2698: <div class="sect1" lang="en">
2699: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2700: <a name="resume-transfers"></a>7.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
2701: <p>By default, resuming transfers in pkgsrc is disabled, but you can
2702: enable this feature by adding the option
2703: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.76 rillig 2704: <code class="filename">/etc/mk.conf</code>. If, during a fetch step, an incomplete
1.75 rillig 2705: distfile is found, pkgsrc will try to resume it.</p>
2706: <p>You can also
2707: 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
2708: <code class="varname">FETCH_CMD</code> variable. Don't forget to set
2709: <code class="varname">FETCH_RESUME_ARGS</code> and
2710: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
2711: values.</p>
2712: <p>For example, if you want to use
1.76 rillig 2713: <code class="filename">wget</code> to resume downloads, you'll have to use something
1.75 rillig 2714: like:</p>
2715: <pre class="programlisting">
2716: FETCH_CMD= wget
2717: FETCH_BEFORE_ARGS= --passive-ftp
2718: FETCH_RESUME_ARGS= -c
2719: FETCH_OUTPUT_ARGS= -O
1.1 grant 2720: </pre>
1.75 rillig 2721: </div>
2722: <div class="sect1" lang="en">
2723: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2724: <a name="XFree86-from-pkgsrc"></a>7.6. How can I install/use XFree86 from pkgsrc?</h2></div></div></div>
2725: <p>If you want to use XFree86 from pkgsrc instead of your system's own
1.76 rillig 2726: X11 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>,
1.75 rillig 2727: ...), you will have to add the following line into
1.76 rillig 2728: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2729: <pre class="programlisting">
2730: X11_TYPE=XFree86
1.1 grant 2731: </pre>
1.75 rillig 2732: </div>
2733: <div class="sect1" lang="en">
2734: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2735: <a name="x.org-from-pkgsrc"></a>7.7. How can I install/use X.org from pkgsrc?</h2></div></div></div>
2736: <p>If you want to use X.org from pkgsrc instead of your system's own X11
1.76 rillig 2737: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
1.75 rillig 2738: you will have to add the following line into
1.76 rillig 2739: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2740: <pre class="programlisting">
2741: X11_TYPE=xorg
1.1 grant 2742: </pre>
1.75 rillig 2743: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
2744: <h3 class="title">Note</h3>
2745: <p>The DragonFly operating system defaults to using
2746: this X.org X11 implementation from pkgsrc.
2747: </p>
2748: </div>
2749: </div>
2750: <div class="sect1" lang="en">
2751: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2752: <a name="fetch-behind-firewall"></a>7.8. How to fetch files from behind a firewall</h2></div></div></div>
2753: <p>If you are sitting behind a firewall which does not allow direct
2754: connections to Internet hosts (i.e. non-NAT), you may specify the
2755: relevant proxy hosts. This is done using an environment variable in the
2756: form of a URL, e.g. in Amdahl, the machine
2757: “<span class="quote">orpheus.amdahl.com</span>” is one of the firewalls, and it uses
2758: port 80 as the proxy port number. So the proxy environment variables
2759: are:</p>
2760: <pre class="programlisting">
2761: ftp_proxy=ftp://orpheus.amdahl.com:80/
2762: http_proxy=http://orpheus.amdahl.com:80/
1.1 grant 2763: </pre>
1.75 rillig 2764: </div>
2765: <div class="sect1" lang="en">
2766: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2767: <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>
2768: <p>This depends on which utility is used to retrieve distfiles. From
1.76 rillig 2769: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
1.75 rillig 2770: the first available command from the following list:</p>
2771: <div class="itemizedlist"><ul type="disc">
1.76 rillig 2772: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
2773: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
1.75 rillig 2774: </ul></div>
2775: <p>On a default NetBSD installation, this will be
1.76 rillig 2776: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
1.75 rillig 2777: connections first, and falls back to active connections if the server
2778: refuses to do passive. For the other tools, add the following to your
1.76 rillig 2779: <code class="filename">/etc/mk.conf</code> file:
1.75 rillig 2780: <code class="varname">PASSIVE_FETCH=1</code>.</p>
2781: <p>Having that option present will prevent
1.76 rillig 2782: <code class="filename">/usr/bin/ftp</code> from falling back to active
1.75 rillig 2783: transfers.</p>
2784: </div>
2785: <div class="sect1" lang="en">
2786: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2787: <a name="fetching-all-distfiles"></a>7.10. How to fetch all distfiles at once</h2></div></div></div>
2788: <p>You would like to download all the distfiles in a single batch from
2789: work or university, where you can't run a <span><strong class="command">make fetch</strong></span>.
2790: There is an archive of distfiles on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/" target="_top">ftp.NetBSD.org</a>,
2791: but downloading the entire directory may not be appropriate.</p>
2792: <p>The answer here is to do a <span><strong class="command">make fetch-list</strong></span> in
1.76 rillig 2793: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
1.75 rillig 2794: resulting list to your machine at work/school and use it there. If you
2795: 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
2796: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
2797: URL:</p>
2798: <p>At home:</p>
2799: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2800: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh</code></strong>
2801: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
2802: <p>At work:</p>
2803: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
1.76 rillig 2804: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
1.75 rillig 2805: home.</p>
2806: <p>If you have a machine running NetBSD, and you want to get
2807: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your machine
2808: architecture), you can do so by using the above-mentioned <span><strong class="command">make
2809: fetch-list</strong></span> approach, or fetch the distfiles directly by
2810: running:</p>
2811: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
2812: <p>If you even decide to ignore
2813: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
2814: by running:</p>
2815: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
2816: </div>
2817: <div class="sect1" lang="en">
2818: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2819: <a name="tmac.andoc-missing"></a>7.11. What does “<span class="quote">Don't know how to make
2820: /usr/share/tmac/tmac.andoc</span>” mean?</h2></div></div></div>
1.76 rillig 2821: <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 2822: package, you get the error from make that it doesn't know how to make
1.76 rillig 2823: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
1.75 rillig 2824: you don't have installed the “<span class="quote">text</span>” set (nroff, ...) from
2825: the NetBSD base distribution on your machine. It is recommended to do
2826: that to format man pages.</p>
1.76 rillig 2827: <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 2828: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.76 rillig 2829: environment or in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 2830: </div>
2831: <div class="sect1" lang="en">
2832: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2833: <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 2834: <p> You didn't install the compiler set, <code class="filename">comp.tgz</code>,
1.75 rillig 2835: when you installed your NetBSD machine. Please get and install it, by
1.76 rillig 2836: extracting it in <code class="filename">/</code>:</p>
1.75 rillig 2837: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
2838: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
1.76 rillig 2839: <p><code class="filename">comp.tgz</code> is part of every NetBSD release. Get
1.75 rillig 2840: the one that corresponds to your release (determine via <span><strong class="command">uname
2841: -r</strong></span>).</p>
2842: </div>
2843: <div class="sect1" lang="en">
2844: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2845: <a name="using-sudo-with-pkgsrc"></a>7.13. Using 'sudo' with pkgsrc</h2></div></div></div>
2846: <p>When installing packages as non-root user and using the just-in-time
2847: <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
2848: password for each required package installed. To avoid this, the sudo
2849: package can be used, which does password caching over a limited time. To
2850: use it, install sudo (either as binary package or from
1.76 rillig 2851: <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
2852: into your <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 2853: <pre class="programlisting">
2854: .if exists(${LOCALBASE}/bin/sudo)
2855: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
2856: .endif
1.1 grant 2857: </pre>
1.75 rillig 2858: </div>
2859: <div class="sect1" lang="en">
2860: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2861: <a name="faq.conf"></a>7.14. How do I change the location of configuration files?</h2></div></div></div>
2862: <p>As the system administrator, you can choose where configuration files
2863: are installed. The default settings make all these files go into
1.76 rillig 2864: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
1.75 rillig 2865: be suboptimal depending on your expectations (e.g., a read-only,
2866: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
2867: configuration of the provided packages).</p>
2868: <p>In order to change the defaults, you can modify the
2869: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.76 rillig 2870: <code class="filename">/etc/mk.conf</code>) to point to your preferred configuration
2871: directory; some common examples include <code class="filename">/etc</code> or
2872: <code class="filename">/etc/pkg</code>.</p>
1.75 rillig 2873: <p>Furthermore, you can change this value on a per-package basis by
2874: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
2875: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
2876: package you would like to modify, that is, the contents of
2877: <code class="varname">PKGBASE</code>.</p>
2878: <p>Note that after changing these settings, you must rebuild and
2879: reinstall any affected packages.</p>
2880: </div>
2881: <div class="sect1" lang="en">
2882: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2883: <a name="audit-packages"></a>7.15. Automated security checks</h2></div></div></div>
2884: <p>Please be aware that there can often be bugs in third-party software,
2885: and some of these bugs can leave a machine vulnerable to exploitation by
2886: attackers. In an effort to lessen the exposure, the NetBSD packages team
2887: maintains a database of known-exploits to packages which have at one time
2888: been included in pkgsrc. The database can be downloaded automatically, and
2889: a security audit of all packages installed on a system can take place. To
1.76 rillig 2890: 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 2891: components:</p>
2892: <div class="orderedlist"><ol type="1">
2893: <li>
2894: <p><span><strong class="command">download-vulnerability-list</strong></span>, an easy way to
2895: download a list of the security vulnerabilities information. This list
2896: is kept up to date by the NetBSD security officer and the NetBSD
2897: packages team, and is distributed from the NetBSD ftp server:</p>
2898: <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>
2899: </li>
2900: <li><p><span><strong class="command">audit-packages</strong></span>, an easy way to audit the
2901: current machine, checking each vulnerability which is known. If a
2902: vulnerable package is installed, it will be shown by output to stdout,
2903: including a description of the type of vulnerability, and a URL
2904: containing more information.</p></li>
2905: </ol></div>
1.76 rillig 2906: <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 2907: package is strongly recommended! After
2908: “<span class="quote">audit-packages</span>” is installed, please read
2909: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
2910: audit-packages</code></strong>.</p>
2911: <p>If this package is installed, pkgsrc builds will use it to perform
2912: a security check before building any package. See
2913: <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.
2914: </p>
2915: </div>
2916: <div class="sect1" lang="en">
2917: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2918: <a name="ufaq-cflags"></a>7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
2919: <p>When you add your own preferences to the
2920: <code class="varname">CFLAGS</code> variable in your
1.76 rillig 2921: <code class="filename">mk.conf</code>, these flags are passed in
2922: environment variables to the <code class="filename">./configure</code>
1.75 rillig 2923: 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
2924: <code class="varname">CFLAGS</code> from the environment variable by
1.76 rillig 2925: overriding them in the <code class="filename">Makefile</code>s of their
1.75 rillig 2926: package.</p>
2927: <p>Currently there is no solution to this problem. If you
2928: really need the package to use your <code class="varname">CFLAGS</code>
2929: you should run <span><strong class="command">make patch</strong></span> in the package
1.76 rillig 2930: directory and then inspect any <code class="filename">Makefile</code> and
2931: <code class="filename">Makefile.in</code> for whether they define
1.75 rillig 2932: <code class="varname">CFLAGS</code> explicitly. Usually you can remove
2933: these lines. But be aware that some “<span class="quote">smart</span>”
2934: programmers write so bad code that it only works for the
2935: specific combination of <code class="varname">CFLAGS</code> they have
2936: chosen.</p>
2937: </div>
2938: </div>
2939: </div>
2940: <div class="part" lang="en">
2941: <div class="titlepage"><div><div><h1 class="title">
2942: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
1.77 rillig 2943: <div class="partintro" lang="en">
2944: <div></div>
2945: <p>This part of the book deals with creating and
2946: modifying packages. It starts with a “<span class="quote">HOWTO</span>”-like
2947: guide on creating a new package. The remaining chapters are more
2948: like a reference manual for pkgsrc.</p>
1.75 rillig 2949: <div class="toc">
2950: <p><b>Table of Contents</b></p>
2951: <dl>
1.77 rillig 2952: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
2953: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75 rillig 2954: <dd><dl>
1.77 rillig 2955: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
2956: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
2957: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
2958: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
2959: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 ! rillig 2960: <dd><dl>
! 2961: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
! 2962: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
! 2963: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
! 2964: </dl></dd>
1.77 rillig 2965: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
2966: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
2967: </dl></dd>
2968: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
2969: <dd><dl>
2970: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
2971: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
2972: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
2973: <dd><dl>
2974: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
2975: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
2976: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
2977: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
2978: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
2979: </dl></dd>
2980: </dl></dd>
2981: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
2982: <dd><dl>
2983: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
2984: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
2985: <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>
2986: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
2987: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
2988: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
2989: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
2990: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
2991: </dl></dd>
2992: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
2993: <dd><dl>
2994: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
2995: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
2996: <dd><dl>
2997: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
2998: <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>
2999: </dl></dd>
3000: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
3001: <dd><dl>
3002: <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>
3003: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
3004: </dl></dd>
3005: </dl></dd>
3006: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
3007: <dd><dl>
3008: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
3009: <dd><dl>
3010: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
3011: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
3012: </dl></dd>
3013: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
3014: <dd><dl>
3015: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
3016: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
3017: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
3018: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
3019: </dl></dd>
3020: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
3021: <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>
3022: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
3023: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
3024: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
3025: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
3026: <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>
3027: </dl></dd>
3028: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
3029: <dd><dl>
3030: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
3031: <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>
3032: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
3033: </dl></dd>
3034: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
3035: <dd><dl>
3036: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
3037: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
3038: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
3039: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
3040: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
3041: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
3042: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
3043: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
3044: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
3045: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
3046: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
3047: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3048: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
3049: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3050: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
3051: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
3052: </dl></dd>
3053: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
3054: <dd><dl>
3055: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
3056: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
3057: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
3058: </dl></dd>
3059: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
3060: <dd><dl>
3061: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
3062: <dd><dl>
1.78 ! rillig 3063: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
! 3064: <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>
! 3065: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
! 3066: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
! 3067: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
! 3068: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
! 3069: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
! 3070: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
! 3071: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
! 3072: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
! 3073: <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.77 rillig 3074: </dl></dd>
3075: <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>
3076: <dd><dl>
3077: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
3078: <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>
3079: </dl></dd>
3080: <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>
3081: <dd><dl>
3082: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
3083: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
3084: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
3085: </dl></dd>
3086: <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>
3087: <dd><dl>
1.78 ! rillig 3088: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
! 3089: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
! 3090: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
! 3091: </dl></dd>
! 3092: <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>
! 3093: <dd><dl>
! 3094: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
! 3095: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
! 3096: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
! 3097: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
! 3098: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
! 3099: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
! 3100: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
! 3101: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
! 3102: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
! 3103: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
! 3104: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
! 3105: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
! 3106: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
! 3107: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
! 3108: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
! 3109: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
! 3110: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.77 rillig 3111: </dl></dd>
1.78 ! rillig 3112: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.77 rillig 3113: </dl></dd>
3114: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
3115: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
3116: <dd><dl>
3117: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
3118: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
3119: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
3120: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
3121: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
3122: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 3123: </dl></dd>
1.77 rillig 3124: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.75 rillig 3125: </dl>
3126: </div>
1.77 rillig 3127: </div>
3128: <div class="chapter" lang="en">
3129: <div class="titlepage"><div><div><h2 class="title">
3130: <a name="creating"></a>Chapter 8. Creating a new pkgsrc package from scratch</h2></div></div></div>
3131: <p>When you find a package that is not yet in pkgsrc, you
3132: most likely have a URL from where you can download the source
3133: code. Starting with this URL, creating a package involves only a
3134: few steps.</p>
3135: <div class="procedure"><ol type="1">
3136: <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>
3137: <li><p>Then, choose one of the top-level directories as the
3138: category in which you want to place your package. You can also
3139: create a directory of your own (maybe called
3140: <code class="filename">local</code>). In that category directory, create
3141: another directory for your package and change into
3142: it.</p></li>
3143: <li><p>Run the program <span><strong class="command">url2pkg</strong></span>, which
3144: will ask you for a URL. Enter the URL of the distribution file
3145: (in most cases a <code class="filename">.tar.gz</code> file) and watch
3146: how the basic ingredients of your package are created
3147: automatically. The distribution file is extracted automatically
3148: to fill in some details in the <code class="filename">Makefile</code>
3149: that would otherwise have to be done manually.</p></li>
3150: <li>
3151: <p>Examine the extracted files to determine the
3152: dependencies of your package. Ideally, this is mentioned in some
3153: <code class="filename">README</code> file, but things may differ. For
3154: each of these dependencies, look where it exists in pkgsrc, and
3155: if there is a file called <code class="filename">buildlink3.mk</code> in
3156: that directory, add a line to your package
3157: <code class="filename">Makefile</code> which includes that file just
3158: before the last line. If the <code class="filename">buildlink3.mk</code>
3159: file does not exist, add a <code class="varname">DEPENDS</code> line to
3160: the Makefile, which specifies the version of the dependency and
3161: where it can be found in pkgsrc. This line should be placed in
3162: the third paragraph. If the dependency is only needed for
3163: building the package, but not when using it, use
3164: <code class="varname">BUILD_DEPENDS</code> instead of
3165: <code class="varname">DEPENDS</code>. Your package may then look like
3166: this:</p>
3167: <pre class="programlisting">
3168: [...]
3169:
3170: BUILD_DEPENDS+= lua>=5.0:../../lang/lua
3171: DEPENDS+= screen-[0-9]*:../../misc/screen
3172: DEPENDS+= screen>=4.0:../../misc/screen
3173:
3174: [...]
3175:
3176: .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
3177: .include "../../devel/glib2/buildlink3.mk"
3178: .include "../../mk/bsd.pkg.mk"
3179: </pre>
3180: </li>
3181: <li><p>Run <span><strong class="command">pkglint</strong></span> to see what things
3182: still need to be done to make your package a “<span class="quote">good</span>”
3183: one. If you don't know what pkglint's warnings want to tell you,
3184: try <span><strong class="command">pkglint --explain</strong></span> or <span><strong class="command">pkglint
3185: -e</strong></span>, which outputs additional
3186: explanations.</p></li>
3187: <li><p>Now, run <span><strong class="command">bmake</strong></span> to build the
3188: package. For the various things that can go wrong in this phase,
3189: consult <a href="#fixes" title="Chapter 17. Making your package work">Chapter 17, <i>Making your package work</i></a>.</p></li>
3190: <li><p>When the package builds fine, the next step is to
3191: install the package. Run <span><strong class="command">bmake install</strong></span> and
3192: hope that everything works.</p></li>
3193: <li><p>Up to now, the file <code class="filename">PLIST</code>,
3194: which contains a list of the files that are installed by the
3195: package, is nearly empty. Run <span><strong class="command">bmake print-PLIST
3196: >PLIST</strong></span> to generate a probably correct list. Check
3197: the file using your preferred text editor to see if the list of
3198: files looks plausible.</p></li>
3199: <li><p>Run <span><strong class="command">pkglint</strong></span> again to see if the
3200: generated <code class="filename">PLIST</code> contains garbage or
3201: not.</p></li>
3202: <li><p>When you ran <span><strong class="command">bmake install</strong></span>, the
3203: package has been registered in the database of installed files,
3204: but with an empty list of files. To fix this, run <span><strong class="command">bmake
3205: deinstall</strong></span> and <span><strong class="command">bmake install</strong></span> again.
3206: Now the package is registered with the list of files from
3207: <code class="filename">PLIST</code>.</p></li>
3208: <li><p>Run <span><strong class="command">bmake package</strong></span> to create a
3209: binary package from the set of installed files.</p></li>
3210: </ol></div>
3211: </div>
1.75 rillig 3212: <div class="chapter" lang="en">
3213: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3214: <a name="components"></a>Chapter 9. Package components - files, directories and contents</h2></div></div></div>
1.75 rillig 3215: <div class="toc">
3216: <p><b>Table of Contents</b></p>
3217: <dl>
1.77 rillig 3218: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
3219: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
3220: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
3221: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
3222: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 ! rillig 3223: <dd><dl>
! 3224: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
! 3225: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
! 3226: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
! 3227: </dl></dd>
1.77 rillig 3228: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
3229: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
1.75 rillig 3230: </dl>
3231: </div>
3232: <p> Whenever you're preparing a package, there are a number of
3233: files involved which are described in the following
3234: sections. </p>
3235: <div class="sect1" lang="en">
3236: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3237: <a name="components.Makefile"></a>9.1. <code class="filename">Makefile</code></h2></div></div></div>
1.75 rillig 3238: <p>Building, installation and creation of a binary package are all
1.76 rillig 3239: controlled by the package's <code class="filename">Makefile</code>.
3240: The <code class="filename">Makefile</code> describes various things about
1.75 rillig 3241: a package, for example from where to get it, how to configure,
3242: build, and install it.
3243: </p>
1.76 rillig 3244: <p>A package <code class="filename">Makefile</code> contains several
1.75 rillig 3245: sections that describe the package.</p>
3246: <p>In the first section there are the following variables, which
3247: should appear exactly in the order given here.
3248: </p>
3249: <div class="itemizedlist"><ul type="disc">
3250: <li><p><code class="varname">DISTNAME</code> is the basename of the
3251: distribution file to be downloaded from the package's
3252: website.</p></li>
3253: <li><p><code class="varname">PKGNAME</code> is the name of the
3254: package, as used by pkgsrc. You only need to provide it if it
3255: differs from <code class="varname">DISTNAME</code>. Usually it is the directory name together
3256: with the version number. It must match the regular expression
3257: <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
3258: starts with a letter or digit, and contains only letters, digits,
3259: dashes, underscores, dots and plus signs.</p></li>
3260: <li>
3261: <p><code class="varname">CATEGORIES</code> is a list of categories
3262: which the package fits in. You can choose any of the top-level
3263: directories of pkgsrc for it.</p>
3264: <p>Currently the following values are available for
3265: <code class="varname">CATEGORIES</code>. If more than
3266: one is used, they need to be separated by spaces:</p>
3267: <pre class="programlisting">
3268: archivers cross geography meta-pkgs security
3269: audio databases graphics misc shells
3270: benchmarks devel ham multimedia sysutils
3271: biology editors inputmethod net textproc
3272: cad emulators lang news time
3273: chat finance mail parallel wm
3274: comms fonts math pkgtools www
3275: converters games mbone print x11
1.1 grant 3276: </pre>
1.75 rillig 3277: </li>
3278: <li>
3279: <p><code class="varname">MASTER_SITES</code> is a list of URLs where
3280: the distribution files can be downloaded. Each URL must end with a
3281: slash.</p>
3282: <p>The <code class="varname">MASTER_SITES</code> may make use of
3283: the following predefined sites:</p>
3284: <pre class="programlisting">
3285: ${MASTER_SITE_APACHE}
3286: ${MASTER_SITE_BACKUP}
3287: ${MASTER_SITE_CYGWIN}
3288: ${MASTER_SITE_DEBIAN}
3289: ${MASTER_SITE_FREEBSD}
3290: ${MASTER_SITE_FREEBSD_LOCAL}
3291: ${MASTER_SITE_GNOME}
3292: ${MASTER_SITE_GNU}
3293: ${MASTER_SITE_GNUSTEP}
3294: ${MASTER_SITE_IFARCHIVE}
3295: ${MASTER_SITE_MOZILLA}
3296: ${MASTER_SITE_OPENOFFICE}
3297: ${MASTER_SITE_PERL_CPAN}
3298: ${MASTER_SITE_R_CRAN}
3299: ${MASTER_SITE_SOURCEFORGE}
3300: ${MASTER_SITE_SUNSITE}
3301: ${MASTER_SITE_SUSE}
3302: ${MASTER_SITE_TEX_CTAN}
3303: ${MASTER_SITE_XCONTRIB}
3304: ${MASTER_SITE_XEMACS}
1.74 rillig 3305: </pre>
1.75 rillig 3306: <p>If one of these predefined sites is chosen, you may
3307: want to specify a subdirectory of that
3308: site. Since these macros may expand to more than one
3309: actual site, you <span class="emphasis"><em>must</em></span> use the
3310: following construct to specify a subdirectory:</p>
3311: <pre class="programlisting">
3312: ${MASTER_SITE_GNU:=subdirectory/name/}
3313: ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1 grant 3314: </pre>
1.75 rillig 3315: <p>Note the trailing slash after the subdirectory name.</p>
3316: <p>If the package has multiple
3317: <code class="varname">DISTFILES</code> or multiple
3318: <code class="varname">PATCHFILES</code> from different
3319: sites, set <code class="varname">SITES.foo</code> to a list of URIs
3320: where file “<span class="quote">foo</span>” may be
3321: found. “<span class="quote">foo</span>” includes the suffix, e.g.:</p>
3322: <pre class="programlisting">
3323: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
3324: DISTFILES+= foo-file.tar.gz
3325: SITES.foo-file.tar.gz= \
3326: http://www.somewhere.com/somehow/ \
3327: http://www.somewhereelse.com/mirror/somehow/
1.1 grant 3328: </pre>
1.75 rillig 3329: </li>
3330: <li>
3331: <p><code class="varname">DISTFILES</code>: Name(s)
3332: of archive file(s) containing distribution. The default is
1.76 rillig 3333: <code class="filename">${DISTNAME}${EXTRACT_SUFX}</code>. Should only
1.75 rillig 3334: be set if you have more than one distfile.</p>
3335: <p>Note that the normal default setting of
3336: <code class="varname">DISTFILES</code> must be made explicit if you
3337: want to add to it (rather than replace it), as you usually
3338: would.</p>
3339: </li>
3340: <li><p><code class="varname">EXTRACT_SUFX</code>: Suffix of the
3341: distribution file, will be appended to
3342: <code class="varname">DISTNAME</code>. Defaults to
1.76 rillig 3343: <code class="filename">.tar.gz</code>.
1.75 rillig 3344: </p></li>
3345: </ul></div>
3346: <p>
3347: </p>
3348: <p>The second section contains information about separately
3349: downloaded patches, if any.
3350: </p>
3351: <div class="itemizedlist"><ul type="disc">
3352: <li><p><code class="varname">PATCHFILES:</code>
3353: Name(s) of additional files that contain distribution patches.
3354: There is no default. pkgsrc will look for them at
3355: <code class="varname">PATCH_SITES</code>.
3356: They will automatically be uncompressed before patching if
1.76 rillig 3357: the names end with <code class="filename">.gz</code> or
3358: <code class="filename">.Z</code>.</p></li>
1.75 rillig 3359: <li><p><code class="varname">PATCH_SITES</code>:
3360: Primary location(s) for distribution patch files (see
3361: <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
3362: </ul></div>
3363: <p>
3364: </p>
3365: <p>The third section contains the following variables.
3366: </p>
3367: <div class="itemizedlist"><ul type="disc">
3368: <li><p><code class="varname">MAINTAINER</code> is the email address
3369: of the person who feels responsible for this package, and who is
3370: most likely to look at problems or questions regarding this
3371: 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
3372: developers should contact the <code class="varname">MAINTAINER</code> before
3373: making major changes to the package. When packaging a new program,
3374: set <code class="varname">MAINTAINER</code> to yourself. If you really can't
3375: maintain the package for future updates, set it to
3376: <code class="email"><<a href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>></code>.</p></li>
3377: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
3378: find more information about the package.</p></li>
3379: <li><p><code class="varname">COMMENT</code> is a one-line
3380: description of the package (should not include the package
3381: name).</p></li>
3382: </ul></div>
3383: <p>
3384: </p>
3385: <p>Other variables that affect the build:
3386: </p>
3387: <div class="itemizedlist"><ul type="disc"><li>
3388: <p><code class="varname">WRKSRC</code>: The directory where the
3389: interesting distribution files of the package are found. The
1.76 rillig 3390: default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
1.75 rillig 3391: works for most packages.</p>
3392: <p>If a package doesn't create a subdirectory for itself
3393: (most GNU software does, for instance), but extracts itself in
3394: the current directory, you should set <code class="varname">WRKSRC=
3395: ${WRKDIR}</code>.</p>
3396: <p>If a package doesn't create a subdirectory with the name
3397: of <code class="varname">DISTNAME</code> but some different name, set
3398: <code class="varname">WRKSRC</code> to point to the proper name in
1.76 rillig 3399: <code class="filename">${WRKDIR}</code>, for example <code class="varname">WRKSRC=
3400: ${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 3401: <p>The name of the working directory created by pkgsrc is
3402: taken from the <code class="varname">WRKDIR_BASENAME</code> variable. By
1.76 rillig 3403: default, its value is <code class="filename">work</code>. If you want
1.75 rillig 3404: to use the same pkgsrc tree for building different kinds of
3405: binary packages, you can change the variable according to your
3406: needs. Two other variables handle common cases of setting
3407: <code class="varname">WRKDIR_BASENAME</code> individually. If
3408: <code class="varname">OBJHOSTNAME</code> is defined in
1.76 rillig 3409: <code class="filename">/etc/mk.conf</code>, the first component of the
1.75 rillig 3410: host's name is attached to the directory name. If
3411: <code class="varname">OBJMACHINE</code> is defined, the platform name is
1.76 rillig 3412: attached, which might look like <code class="filename">work.i386</code>
3413: or <code class="filename">work.sparc</code>.</p>
1.75 rillig 3414: </li></ul></div>
3415: <p>
3416: </p>
3417: <p>Please pay attention to the following gotchas:</p>
3418: <div class="itemizedlist"><ul type="disc">
3419: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are installed in
3420: compressed form by the package; see comment in
1.76 rillig 3421: <code class="filename">bsd.pkg.mk</code>.</p></li>
3422: <li><p>Replace <code class="filename">/usr/local</code> with
1.75 rillig 3423: “<span class="quote">${PREFIX}</span>” in all files (see patches, below).</p></li>
3424: <li><p>If the package installs any info files, see
1.78 ! rillig 3425: <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 3426: </ul></div>
3427: </div>
3428: <div class="sect1" lang="en">
3429: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3430: <a name="components.distinfo"></a>9.2. <code class="filename">distinfo</code></h2></div></div></div>
1.76 rillig 3431: <p>The <code class="filename">distinfo</code> file contains the message
1.75 rillig 3432: digest, or checksum, of each distfile needed for the package. This
3433: ensures that the distfiles retrieved from the Internet have not been
3434: corrupted during transfer or altered by a malign force to introduce
3435: a security hole. Due to recent rumor about weaknesses of digest
3436: algorithms, all distfiles are protected using both SHA1 and RMD160
3437: message digests, as well as the file size.</p>
1.76 rillig 3438: <p>The <code class="filename">distinfo</code> file also contains the
1.75 rillig 3439: checksums for all the patches found in the
1.77 rillig 3440: <code class="filename">patches</code> directory (see <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a>).</p>
1.76 rillig 3441: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.75 rillig 3442: <span><strong class="command">make makedistinfo</strong></span> or <span><strong class="command">make mdi</strong></span>
3443: command.</p>
3444: <p>Some packages have different sets of distfiles depending on
1.76 rillig 3445: 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
3446: <code class="filename">distinfo</code> file and care should be taken when
1.75 rillig 3447: upgrading such a package to ensure distfile information is not
3448: lost.</p>
3449: </div>
3450: <div class="sect1" lang="en">
3451: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3452: <a name="components.patches"></a>9.3. patches/*</h2></div></div></div>
1.75 rillig 3453: <p>This directory contains files that are used by the
3454: <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
3455: modify the sources as distributed in the distribution file into a form
3456: that will compile and run perfectly on NetBSD. The files are applied
3457: successively in alphabetic order (as returned by a shell
3458: “<span class="quote">patches/patch-*</span>” glob expansion), so
1.76 rillig 3459: <code class="filename">patch-aa</code> is applied before
3460: <code class="filename">patch-ab</code>, etc.</p>
3461: <p>The <code class="filename">patch-*</code> files should be in
1.75 rillig 3462: <span><strong class="command">diff -bu</strong></span> format, and apply without a fuzz to avoid
3463: problems. (To force patches to apply
3464: with fuzz you can set <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>).
3465: Furthermore, do not put changes for more than one file into a single
3466: patch file, as this will make future modifications more difficult.</p>
3467: <p>Similar, a file should be patched at most once, not several times by
3468: several different patches. If a file needs several patches, they should
3469: be combined into one file.</p>
3470: <p>One important thing to mention is to pay attention that no RCS IDs
3471: get stored in the patch files, as these will cause problems when
3472: later checked into the NetBSD CVS tree. Use the
3473: <span><strong class="command">pkgdiff</strong></span> from the
1.76 rillig 3474: <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 3475: these problems.</p>
3476: <p>For even more automation, we recommend using <span><strong class="command">mkpatches</strong></span> from the same
3477: package to make a whole set of patches. You just have to backup files
1.76 rillig 3478: before you edit them to <code class="filename">filename.orig</code>, e.g. with
1.75 rillig 3479: <span><strong class="command">cp -p filename filename.orig</strong></span> or, easier, by using
3480: <span><strong class="command">pkgvi</strong></span> again from the same package. If you upgrade a package
3481: this way, you can easily compare the new set of patches with the
3482: previously existing one with <span><strong class="command">patchdiff</strong></span>.</p>
3483: <p>When you have finished a package, remember to generate the checksums
3484: for the patch files by using the <span><strong class="command">make makepatchsum</strong></span>
1.77 rillig 3485: command, see <a href="#components.distinfo" title="9.2. distinfo">Section 9.2, “<code class="filename">distinfo</code>”</a>.</p>
1.75 rillig 3486: <p>When adding a patch that corrects a problem in the distfile (rather
3487: than e.g. enforcing pkgsrc's view of where man pages should go), send
3488: the patch as a bug report to the maintainer. This benefits
3489: non-pkgsrc users of the package, and usually enables removing
3490: the patch in future version.</p>
3491: <p>Patch files that are distributed by the author or other
3492: maintainers can be listed in
3493: <code class="varname">$PATCHFILES</code>. </p>
3494: <p>If it is desired to store any patches that should not be committed into
3495: pkgsrc, they can be kept outside the pkgsrc tree in the
1.76 rillig 3496: <code class="filename">$LOCALPATCHES</code>
1.75 rillig 3497: directory. The directory tree there is expected to have the same
3498: “<span class="quote">category/package</span>” structure as pkgsrc, and patches are
3499: expected to be stored inside these dirs (also known as
1.76 rillig 3500: <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
1.75 rillig 3501: example, if you want to keep a private patch for
1.76 rillig 3502: <code class="filename">pkgsrc/graphics/png</code>, keep
3503: it in <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
1.75 rillig 3504: files in the named directory are expected to be patch files, and
3505: <span class="emphasis"><em>they are applied after pkgsrc patches are applied</em></span>.</p>
3506: </div>
3507: <div class="sect1" lang="en">
3508: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3509: <a name="other-mandatory-files"></a>9.4. Other mandatory files</h2></div></div></div>
1.75 rillig 3510: <div class="variablelist"><dl>
1.76 rillig 3511: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
1.75 rillig 3512: <dd><p>A multi-line description of the piece of software. This should include
3513: any credits where they are due. Please bear in mind that others do not
3514: share your sense of humour (or spelling idiosyncrasies), and that others
3515: will read everything that you write here.</p></dd>
1.76 rillig 3516: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
1.75 rillig 3517: <dd><p>
3518: This file governs the files that are installed on your system: all the
3519: binaries, manual pages, etc. There are other directives which may be
3520: entered in this file, to control the creation and deletion of
3521: directories, and the location of inserted files.
1.77 rillig 3522: See <a href="#plist" title="Chapter 11. PLIST issues">Chapter 11, <i>PLIST issues</i></a> for more information. </p></dd>
1.75 rillig 3523: </dl></div>
3524: </div>
3525: <div class="sect1" lang="en">
3526: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3527: <a name="components.optional"></a>9.5. Optional files</h2></div></div></div>
1.78 ! rillig 3528: <div class="sect2" lang="en">
! 3529: <div class="titlepage"><div><div><h3 class="title">
! 3530: <a name="components.optional.bin"></a>9.5.1. Files affecting the binary package</h3></div></div></div>
1.75 rillig 3531: <div class="variablelist"><dl>
1.76 rillig 3532: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.75 rillig 3533: <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>.
3534: First time after package
3535: extraction and before files are moved in place, the second time after
3536: the files to install are moved in place. This can be used to do any
3537: custom procedures not possible with @exec commands in
1.76 rillig 3538: <code class="filename">PLIST</code>. See
1.75 rillig 3539: <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 3540: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
1.75 rillig 3541: <dd><p>This script is executed before and after any files are removed. It is
3542: this script's responsibility to clean up any additional messy details
3543: around the package's installation, since all pkg_delete knows is how to
3544: delete the files created in the original distribution.
3545: 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>
3546: 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 3547: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
1.75 rillig 3548: <dd>
3549: <p>This file is displayed after installation of the package.
3550: Useful for things like legal notices on almost-free
3551: software and hints for updating config files after
3552: installing modules for apache, PHP etc.
3553: Please note that you can modify variables in it easily by using
3554: <code class="varname">MESSAGE_SUBST</code> in the package's
1.76 rillig 3555: <code class="filename">Makefile</code>:</p>
1.75 rillig 3556: <pre class="programlisting">
3557: MESSAGE_SUBST+= SOMEVAR="somevalue"
1.1 grant 3558: </pre>
1.75 rillig 3559: <p>replaces "${SOMEVAR}" with “<span class="quote">somevalue</span>” in
1.76 rillig 3560: <code class="filename">MESSAGE</code>.</p>
1.75 rillig 3561: </dd>
1.78 ! rillig 3562: <dt><span class="term"><code class="filename">ALTERNATIVES</code></span></dt>
! 3563: <dd><p>FIXME: There is no documentation on the
! 3564: alternatives framework.</p></dd>
! 3565: </dl></div>
! 3566: </div>
! 3567: <div class="sect2" lang="en">
! 3568: <div class="titlepage"><div><div><h3 class="title">
! 3569: <a name="components.optional.build"></a>9.5.2. Files affecting the build process</h3></div></div></div>
! 3570: <div class="variablelist"><dl>
! 3571: <dt><span class="term"><code class="filename">Makefile.common</code></span></dt>
! 3572: <dd><p>This file contains arbitrary things that could
! 3573: also go into a <code class="filename">Makefile</code>, but its purpose is
! 3574: to be used by more than one package. This file should only be
! 3575: used when the packages that will use the file are known in
! 3576: advance. For other purposes it is often better to write a
! 3577: <code class="filename">*.mk</code> file and give it a good name that
! 3578: describes what it does.</p></dd>
! 3579: <dt><span class="term"><code class="filename">buildlink3.mk</code></span></dt>
! 3580: <dd><p>This file contains the dependency information
! 3581: for the buildlink3 framework (see <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a>).</p></dd>
! 3582: <dt><span class="term"><code class="filename">hacks.mk</code></span></dt>
! 3583: <dd><p>This file contains workarounds for compiler bugs
! 3584: and similar things. It is included automatically by the pkgsrc
! 3585: infrastructure, so you don't need an extra
! 3586: <code class="literal">.include</code> line for
! 3587: it.</p></dd>
! 3588: <dt><span class="term"><code class="filename">options.mk</code></span></dt>
! 3589: <dd><p>This file contains the code for the
! 3590: package-specific options (see <a href="#options" title="Chapter 14. Options handling">Chapter 14, <i>Options handling</i></a>) that can be
! 3591: selected by the user. If a package has only one or two options,
! 3592: it is equally acceptable to put the code directly into the
! 3593: <code class="filename">Makefile</code>.</p></dd>
! 3594: </dl></div>
! 3595: </div>
! 3596: <div class="sect2" lang="en">
! 3597: <div class="titlepage"><div><div><h3 class="title">
! 3598: <a name="components.optional.none"></a>9.5.3. Files affecting nothing at all</h3></div></div></div>
! 3599: <div class="variablelist"><dl>
! 3600: <dt><span class="term"><code class="filename">README*</code></span></dt>
! 3601: <dd><p>These files do not take place in the creation of
! 3602: a package and thus are purely informative to the package
! 3603: developer.</p></dd>
! 3604: <dt><span class="term"><code class="filename">TODO</code></span></dt>
! 3605: <dd><p>This file contains things that need to be done
! 3606: to make the package even
! 3607: better.</p></dd>
1.75 rillig 3608: </dl></div>
3609: </div>
1.78 ! rillig 3610: </div>
1.75 rillig 3611: <div class="sect1" lang="en">
3612: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3613: <a name="work-dir"></a>9.6. <code class="filename">work*</code></h2></div></div></div>
1.75 rillig 3614: <p>When you type <span><strong class="command">make</strong></span>, the distribution files are
3615: unpacked into the directory denoted by
3616: <code class="varname">WRKDIR</code>. It can be removed by running
3617: <span><strong class="command">make clean</strong></span>. Besides the sources, this
3618: directory is also used to keep various timestamp files.
3619: The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
1.76 rillig 3620: The default is <code class="filename">${.CURDIR}/work</code>
3621: or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
1.75 rillig 3622: if <code class="varname">OBJMACHINE</code> is set.</p>
3623: </div>
3624: <div class="sect1" lang="en">
3625: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3626: <a name="files-dir"></a>9.7. <code class="filename">files/*</code></h2></div></div></div>
1.75 rillig 3627: <p>If you have any files that you wish to be placed in the package prior
3628: to configuration or building, you could place these files here and use
3629: a “<span class="quote">${CP}</span>” command in the
3630: “<span class="quote">pre-configure</span>” target to achieve
3631: this. Alternatively, you could simply diff the file against
1.76 rillig 3632: <code class="filename">/dev/null</code> and use the patch mechanism to manage
1.75 rillig 3633: the creation of this file.</p>
3634: </div>
3635: </div>
3636: <div class="chapter" lang="en">
3637: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3638: <a name="makefile"></a>Chapter 10. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.75 rillig 3639: <div class="toc">
3640: <p><b>Table of Contents</b></p>
3641: <dl>
1.77 rillig 3642: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
3643: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
3644: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
3645: <dd><dl>
3646: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
3647: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
3648: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
3649: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
3650: <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 3651: </dl></dd>
3652: </dl>
3653: </div>
1.76 rillig 3654: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
1.75 rillig 3655: each of which forms a well-defined part of the pkgsrc system. Using
3656: 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
3657: like pkgsrc requires some discipline to keep the code correct and
3658: understandable.</p>
1.76 rillig 3659: <p>The basic ingredients for <code class="filename">Makefile</code>
1.75 rillig 3660: programming are variables (which are actually macros) and shell
3661: commands. Among these shell commands may even be more complex ones
3662: 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
3663: as intended it is necessary to quote all variables correctly when they
3664: are used.</p>
3665: <p>This chapter describes some patterns, that appear quite often in
1.76 rillig 3666: <code class="filename">Makefile</code>s, including the pitfalls that come along
1.75 rillig 3667: with them.</p>
3668: <div class="sect1" lang="en">
3669: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3670: <a name="makefile.variables"></a>10.1. <code class="filename">Makefile</code> variables</h2></div></div></div>
1.76 rillig 3671: <p><code class="filename">Makefile</code> variables contain strings that
1.75 rillig 3672: can be processed using the five operators ``='', ``+='', ``?='',
3673: ``:='', 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
3674: page.</p>
3675: <p>When a variable's value is parsed from a
1.76 rillig 3676: <code class="filename">Makefile</code>, the hash character ``#'' and the
1.75 rillig 3677: backslash character ``\'' are handled specially. If a backslash is
3678: followed by a newline, any whitespace immediately in front of the
3679: backslash, the backslash, the newline, and any whitespace
3680: immediately behind the newline are replaced with a single space. A
3681: backslash character and an immediately following hash character are
3682: replaced with a single hash character. Otherwise, the backslash is
3683: passed as is. In a variable assignment, any hash character that is
3684: not preceded by a backslash starts a comment that continues upto the
3685: end of the logical line.</p>
3686: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
3687: the only way to create a variable consisting of a single backslash
3688: is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
3689: <p>So far for defining variables. The other thing you can do with
3690: variables is evaluating them. A variable is evaluated when it is
3691: part of the right side of the ``:='' or the ``!='' operator, or
3692: directly before executing a shell command which the variable is part
3693: 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
3694: is, variables are not evaluated until there's no other way. The
3695: ``modifiers'' mentioned in the man page also evaluate the
3696: variable.</p>
3697: <p>Some of the modifiers split the string into words and then
3698: operate on the words, others operate on the string as a whole. When
3699: a string is split into words, it is split as you would expect
3700: 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 3701: <p>No rule without exception—the <span><strong class="command">.for</strong></span>
1.75 rillig 3702: loop does not follow the shell quoting rules but splits at sequences
3703: of whitespace.</p>
3704: <p>There are several types of variables that should be handled
3705: differently. Strings and two types of lists.</p>
3706: <div class="itemizedlist"><ul type="disc">
3707: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
3708: characters. Nevertheless, you should restrict yourself to only
3709: using printable characters. Examples are
3710: <code class="varname">PREFIX</code> and
3711: <code class="varname">COMMENT</code>.</p></li>
3712: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
3713: are never exported to any shell command. Their elements are
3714: separated by whitespace. Therefore, the elements themselves cannot
3715: have embedded whitespace. Any other characters are allowed.
3716: Internal lists can be used in <span><strong class="command">.for</strong></span> loops.
3717: Examples are <code class="varname">DEPENDS</code> and
3718: <code class="varname">BUILD_DEPENDS</code>.</p></li>
3719: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
3720: may be exported to a shell command. Their elements can contain any
3721: characters, including whitespace. That's why they cannot be used
3722: in <span><strong class="command">.for</strong></span> loops. Examples are
3723: <code class="varname">DISTFILES</code> and
3724: <code class="varname">MASTER_SITES</code>.</p></li>
3725: </ul></div>
3726: <div class="sect2" lang="en">
3727: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3728: <a name="makefile.variables.names"></a>10.1.1. Naming conventions</h3></div></div></div>
1.75 rillig 3729: <div class="itemizedlist"><ul type="disc">
3730: <li><p>All variable names starting with an underscore
3731: are reserved for use by the pkgsrc infrastructure. They shall
3732: not be used by package
1.76 rillig 3733: <code class="filename">Makefile</code>s.</p></li>
1.75 rillig 3734: <li><p>In <span><strong class="command">.for</strong></span> loops you should use
3735: lowercase variable names for the iteration
3736: variables.</p></li>
3737: <li><p>All list variables should have a ``plural''
3738: name, e.g. <code class="varname">PKG_OPTIONS</code> or
3739: <code class="varname">DISTFILES</code>.</p></li>
3740: </ul></div>
3741: </div>
3742: </div>
3743: <div class="sect1" lang="en">
3744: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3745: <a name="makefile.code"></a>10.2. Code snippets</h2></div></div></div>
1.75 rillig 3746: <p>This section presents you with some code snippets you should
3747: use in your own code. If you don't find anything appropriate here,
3748: you should test your code and add it here.</p>
3749: <div class="sect2" lang="en">
3750: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3751: <a name="adding-to-list"></a>10.2.1. Adding things to a list</h3></div></div></div>
1.75 rillig 3752: <pre class="programlisting">
3753: STRING= foo * bar `date`
3754: INT_LIST= # empty
3755: ANOTHER_INT_LIST= apache-[0-9]*:../../www/apache
3756: EXT_LIST= # empty
3757: ANOTHER_EXT_LIST= a=b c=d
1.1 grant 3758:
1.75 rillig 3759: INT_LIST+= ${STRING} # 1
3760: INT_LIST+= ${ANOTHER_INT_LIST} # 2
3761: EXT_LIST+= ${STRING:Q} # 3
3762: EXT_LIST+= ${ANOTHER_EXT_LIST} # 4
1.1 grant 3763: </pre>
1.75 rillig 3764: <p>When you add a string to an external list (example 3), it
3765: must be quoted. In all other cases, you must not add a quoting
3766: level. You must not merge internal and external lists, unless you
3767: are sure that all entries are correctly interpreted in both
3768: lists.</p>
3769: </div>
3770: <div class="sect2" lang="en">
3771: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3772: <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 3773: <pre class="programlisting">
3774: EXT_LIST= # empty
3775: .for i in ${INT_LIST}
3776: EXT_LIST+= ${i:Q}""
3777: .endfor
1.1 grant 3778: </pre>
1.75 rillig 3779: <p>This code converts the internal list
3780: <code class="varname">INT_LIST</code> into the external list
3781: <code class="varname">EXT_LIST</code>. As the elements of an internal list
3782: are unquoted they must be quoted here. The reason for appending
3783: <code class="varname">""</code> is explained below.</p>
3784: </div>
3785: <div class="sect2" lang="en">
3786: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3787: <a name="passing-variable-to-shell"></a>10.2.3. Passing variables to a shell command</h3></div></div></div>
1.75 rillig 3788: <pre class="programlisting">
3789: STRING= foo bar < > * `date` $$HOME ' "
3790: EXT_LIST= string=${STRING:Q} x=second\ item
1.1 grant 3791:
1.75 rillig 3792: all:
3793: echo ${STRING} # 1
3794: echo "${STRING}" # 2
3795: echo "${STRING:Q}" # 3
3796: echo ${STRING:Q} # 4
3797: echo x${STRING:Q} | sed 1s,.,, # 5
3798: env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
1.1 grant 3799: </pre>
1.75 rillig 3800: <p>Example 1 leads to a syntax error in the shell, as the
3801: characters are just copied.</p>
3802: <p>Example 2 leads to a syntax error too, and if you leave out
3803: the last " character from <code class="varname">${STRING}</code>,
3804: <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
3805: variable would be evaluated, too.</p>
3806: <p>Example 3 outputs each space character preceded by a
3807: backslash (or not), depending on the implementation of the
3808: <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>
3809: <p>Example 4 handles correctly every string that does not start
3810: with a dash. In that case, the result depends on the
3811: 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
3812: guarantee that your input does not start with a dash, this form is
3813: appropriate.</p>
3814: <p>Example 5 handles even the case of a leading dash
3815: correctly.</p>
3816: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
3817: because the quoting has already been done when adding elements to
3818: the list.</p>
3819: <p>As internal lists shall not be passed to the shell, there is
3820: no example for it.</p>
3821: </div>
3822: <div class="sect2" lang="en">
3823: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3824: <a name="quoting-guideline"></a>10.2.4. Quoting guideline</h3></div></div></div>
1.75 rillig 3825: <p>There are many possible sources of wrongly quoted variables.
3826: This section lists some of the commonly known ones.</p>
3827: <div class="itemizedlist"><ul type="disc">
3828: <li>
3829: <p>Whenever you use the value of a list, think
3830: about what happens to leading or trailing whitespace. If the
3831: list is a well-formed shell expression, you can apply the
3832: <code class="varname">:M*</code> modifier to strip leading and trailing
3833: whitespace from each word. The <code class="varname">:M</code> operator
3834: first splits its argument according to the rules of the shell,
3835: and then creates a new list consisting of all words that match
3836: the shell glob expression <code class="varname">*</code>, that is: all.
3837: One class of situations where this is needed is when adding a
3838: variable like <code class="varname">CPPFLAGS</code> to
3839: <code class="varname">CONFIGURE_ARGS</code>. If the configure script
3840: invokes other configure scripts, it strips the leading and
3841: trailing whitespace from the variable and then passes it to the
3842: other configure scripts. But these configure scripts expect the
3843: (child) <code class="varname">CPPFLAGS</code> variable to be the same as
3844: the parent <code class="varname">CPPFLAGS</code>. That's why we better
3845: pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
3846: here is how we do it:</p>
3847: <pre class="programlisting">
3848: CPPFLAGS= # empty
3849: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX:Q}\"
3850: CPPFLAGS+= ${MY_CPPFLAGS}
1.1 grant 3851:
1.75 rillig 3852: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
1.1 grant 3853:
1.75 rillig 3854: all:
3855: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
3856: echo x${CONFIGURE_ARGS}x # properly trimmed
1.1 grant 3857: </pre>
1.75 rillig 3858: </li>
3859: <li><p>The example above contains one bug: The
3860: <code class="varname">${PREFIX}</code> is a properly quoted shell
3861: expression, but there is the C compiler after it, which also
3862: expects a properly quoted string (this time in C syntax). The
3863: version above is therefore only correct if
3864: <code class="varname">${PREFIX}</code> does not have embedded backslashes
3865: or double quotes. If you want to allow these, you have to add
3866: another layer of quoting to each variable that is used as a C
3867: string literal. You cannot use the <code class="varname">:Q</code>
3868: operator for it, as this operator only works for the
3869: shell.</p></li>
3870: <li>
3871: <p>Whenever a variable can be empty, the
3872: <code class="varname">:Q</code> operator can have surprising results. Here
3873: are two completely different cases which can be solved with the
3874: same trick.</p>
3875: <pre class="programlisting">
3876: EMPTY= # empty
3877: empty_test:
3878: for i in a ${EMPTY:Q} c; do \
3879: echo "$$i"; \
3880: done
1.1 grant 3881:
1.75 rillig 3882: for_test:
3883: .for i in a:\ a:\test.txt
3884: echo ${i:Q}
3885: echo "foo"
3886: .endfor
1.1 grant 3887: </pre>
1.75 rillig 3888: <p>The first example will only print two of the three lines
3889: we might have expected. This is because
3890: <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
3891: the shell cannot see. The workaround is to write
3892: <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
3893: as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
3894: -f ${FNAME:Q}</code> (both of these are wrong).</p>
3895: <p>The second example will only print three lines instead of
3896: four. The first line looks like <code class="varname">a:\ echo foo</code>.
3897: This is because the backslash of the value
3898: <code class="varname">a:\</code> is interpreted as a line-continuation by
3899: <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
3900: <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
3901: <code class="varname">${i:Q}""</code>.</p>
3902: </li>
3903: </ul></div>
3904: </div>
3905: <div class="sect2" lang="en">
3906: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 3907: <a name="bsd-make-bug-workaround"></a>10.2.5. Workaround for a bug in BSD Make</h3></div></div></div>
1.75 rillig 3908: <p>The pkgsrc bmake program does not handle the following
3909: assignment correctly. In case <code class="varname">_othervar_</code>
3910: contains a ``-'' character, one of the closing braces is included
3911: in <code class="varname">${VAR}</code> after this code executes.</p>
3912: <pre class="programlisting">
3913: VAR:= ${VAR:N${_othervar_:C/-//}}
1.1 grant 3914: </pre>
1.75 rillig 3915: <p>For a more complex code snippet and a workaround, see the
1.76 rillig 3916: 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 3917: <code class="varname">bug1</code>.</p>
3918: </div>
3919: </div>
3920: </div>
3921: <div class="chapter" lang="en">
3922: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3923: <a name="plist"></a>Chapter 11. PLIST issues</h2></div></div></div>
1.75 rillig 3924: <div class="toc">
3925: <p><b>Table of Contents</b></p>
3926: <dl>
1.77 rillig 3927: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
3928: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
3929: <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>
3930: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
3931: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
3932: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
3933: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
3934: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
1.75 rillig 3935: </dl>
3936: </div>
1.76 rillig 3937: <p> The <code class="filename">PLIST</code> file contains a package's
1.75 rillig 3938: “<span class="quote">packing list</span>”, i.e. a list of files that belong to
1.76 rillig 3939: the package (relative to the <code class="filename">${PREFIX}</code>
1.75 rillig 3940: directory it's been installed in) plus some additional statements
3941: - 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.
3942: This chapter addresses some issues that need attention when
1.76 rillig 3943: dealing with the <code class="filename">PLIST</code> file (or files, see
1.75 rillig 3944: below!).</p>
3945: <div class="sect1" lang="en">
3946: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3947: <a name="rcs-id"></a>11.1. RCS ID</h2></div></div></div>
1.75 rillig 3948: <p>
3949: Be sure to add a RCS ID line as the first thing in any
1.76 rillig 3950: <code class="filename">PLIST</code> file you write:
1.75 rillig 3951: </p>
3952: <pre class="programlisting">
3953: @comment $NetBSD$
1.55 rillig 3954: </pre>
1.75 rillig 3955: </div>
3956: <div class="sect1" lang="en">
3957: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3958: <a name="automatic-plist-generation"></a>11.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.75 rillig 3959: <p>You can use the <span><strong class="command">make print-PLIST</strong></span> command
3960: to output a PLIST that matches any new files since the package
1.77 rillig 3961: 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 3962: more information on this target.</p>
3963: </div>
3964: <div class="sect1" lang="en">
3965: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3966: <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 3967: <p> If you have used any of the *-dirs packages, as explained in
1.77 rillig 3968: <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 3969: <span><strong class="command">make print-PLIST</strong></span> outputs a set of
3970: <code class="varname">@comment</code>s instead of real
3971: <code class="varname">@dirrm</code> lines. You can also do this for
3972: specific directories and files, so that the results of that
3973: command are very close to reality. This helps <span class="emphasis"><em>a
3974: lot</em></span> during the update of packages. </p>
3975: <p> The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
3976: of AWK patterns and actions that are used to filter the output of
3977: print-PLIST. You can <span class="emphasis"><em>append</em></span> any chunk of AWK
3978: scripting you like to it, but be careful with quoting. </p>
3979: <p> For example, to get all files inside the
1.76 rillig 3980: <code class="filename">libdata/foo</code> directory removed from the
1.75 rillig 3981: resulting PLIST:</p>
3982: <pre class="programlisting">
3983: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
1.55 rillig 3984: </pre>
1.75 rillig 3985: <p> And to get all the <code class="varname">@dirrm</code> lines referring
3986: to a specific (shared) directory converted to
3987: <code class="varname">@comment</code>s: </p>
3988: <pre class="programlisting">
3989: PRINT_PLIST_AWK+= /^@dirrm share\/specific/ { print "@comment " $$0; next; }
1.51 rillig 3990: </pre>
1.75 rillig 3991: </div>
3992: <div class="sect1" lang="en">
3993: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3994: <a name="plist.misc"></a>11.4. Variable substitution in PLIST</h2></div></div></div>
1.75 rillig 3995: <p>
3996: A number of variables are substituted automatically in PLISTs
3997: when a package is installed on a system. This includes the
3998: following variables: </p>
3999: <div class="variablelist"><dl>
4000: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
4001: <dd>
4002: <p>Some packages like emacs and perl embed information
4003: about which architecture they were built on into the
4004: pathnames where they install their files. To handle this
4005: case, PLIST will be preprocessed before actually used, and
4006: the symbol
4007: “<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>” will be
4008: replaced by what <span><strong class="command">uname -p</strong></span> gives. The
4009: same is done if the string
4010: <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
4011: PLIST somewhere - use this on packages that have GNU
4012: autoconf-created configure scripts.</p>
4013: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
4014: <h3 class="title">Legacy note</h3>
4015: <p>There used to be a symbol
4016: “<span class="quote"><code class="varname">$ARCH</code></span>” that
4017: was replaced by the output of <span><strong class="command">uname
4018: -m</strong></span>, but that's no longer supported and has
4019: been removed.</p>
4020: </div>
4021: </dd>
4022: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
4023: <dd>
4024: <p>Some packages want to embed the OS name and version
4025: into some paths. To do this, use these variables in the
1.76 rillig 4026: <code class="filename">PLIST</code>:
1.75 rillig 4027: </p>
4028: <div class="itemizedlist"><ul type="disc">
4029: <li><p><code class="varname">${OPSYS}</code> - output of “<span class="quote"><span><strong class="command">uname -s</strong></span></span>”</p></li>
4030: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. “<span class="quote">solaris</span>”)</p></li>
4031: <li><p><code class="varname">${OS_VERSION}</code> - “<span class="quote"><span><strong class="command">uname -r</strong></span></span>”</p></li>
4032: </ul></div>
4033: </dd>
4034: </dl></div>
4035: <p> For a complete list of values which are replaced by
1.76 rillig 4036: default, please look in <code class="filename">bsd.pkg.mk</code> (and
1.75 rillig 4037: search for <span class="emphasis"><em>PLIST_SUBST</em></span>). </p>
4038: <p> If you want to change other variables not listed above, you
4039: can add variables and their expansions to this variable in the
1.77 rillig 4040: 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 4041: <pre class="programlisting">
4042: PLIST_SUBST+= SOMEVAR="somevalue"
1.1 grant 4043: </pre>
1.75 rillig 4044: <p>This replaces all occurrences of “<span class="quote">${SOMEVAR}</span>”
4045: in the PLIST with “<span class="quote">somevalue</span>”. </p>
4046: </div>
4047: <div class="sect1" lang="en">
4048: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4049: <a name="manpage-compression"></a>11.5. Man page compression</h2></div></div></div>
1.75 rillig 4050: <p>Man pages should be installed in compressed form if
1.76 rillig 4051: <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
1.75 rillig 4052: and uncompressed otherwise. To handle this in the
1.76 rillig 4053: <code class="filename">PLIST</code> file, the suffix “<span class="quote">.gz</span>” is
1.75 rillig 4054: appended/removed automatically for man pages according to
4055: <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
4056: or not, see above for details. This modification of the
1.76 rillig 4057: <code class="filename">PLIST</code> file is done on a copy of it, not
4058: <code class="filename">PLIST</code> itself.</p>
1.75 rillig 4059: </div>
4060: <div class="sect1" lang="en">
4061: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4062: <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 4063: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
1.75 rillig 4064: in generating the binary package, set the variable
4065: <code class="varname">PLIST_SRC</code> to the names of that file(s).
4066: 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
4067: important.</p>
4068: </div>
4069: <div class="sect1" lang="en">
4070: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4071: <a name="platform-specific-plist"></a>11.7. Platform-specific and differing PLISTs</h2></div></div></div>
1.75 rillig 4072: <p>Some packages decide to install a different set of files based on
4073: the operating system being used. These differences can be
4074: automatically handled by using the following files:</p>
4075: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4076: <li><p><code class="filename">PLIST.common</code></p></li>
4077: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
4078: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
4079: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
4080: <li><p><code class="filename">PLIST.common_end</code></p></li>
1.75 rillig 4081: </ul></div>
4082: </div>
4083: <div class="sect1" lang="en">
4084: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4085: <a name="faq.common-dirs"></a>11.8. Sharing directories between packages</h2></div></div></div>
1.75 rillig 4086: <p> A “<span class="quote">shared directory</span>” is a directory where
4087: multiple (and unrelated) packages install files. These
4088: directories are problematic because you have to add special tricks
4089: in the PLIST to conditionally remove them, or have some
4090: centralized package handle them. </p>
4091: <p> Within pkgsrc, you'll find both approaches. If a directory
4092: is shared by a few unrelated packages, it's often not worth to add
4093: an extra package to remove it. Therefore, one simply does:
4094: </p>
4095: <pre class="programlisting">
4096: @unexec ${RMDIR} %D/path/to/shared/directory 2>/dev/null || ${TRUE}
1.1 grant 4097: </pre>
1.75 rillig 4098: <p> in the PLISTs of all affected packages, instead of the
4099: regular "@dirrm" line. </p>
4100: <p> However, if the directory is shared across many packages, two
4101: different solutions are available: </p>
4102: <div class="orderedlist"><ol type="1">
4103: <li><p> If the packages have a common dependency, the directory
4104: can be removed in that. For example, see
1.76 rillig 4105: <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 4106: removes the shared directory
1.76 rillig 4107: <code class="filename">share/omf</code>. </p></li>
1.75 rillig 4108: <li><p> If the packages using the directory are not related at
4109: all (they have no common dependencies), a *-dirs package is
4110: used. </p></li>
4111: </ol></div>
4112: <p> From now on, we'll discuss the second solution. To get an
4113: idea of the *-dirs packages available, issue: </p>
4114: <pre class="programlisting">
4115: <code class="prompt">%</code> cd .../pkgsrc
4116: <code class="prompt">%</code> ls -d */*-dirs
1.1 grant 4117: </pre>
1.75 rillig 4118: <p> Their use from other packages is very simple. The
4119: <code class="varname">USE_DIRS</code> variable takes a list of package names
4120: (without the “<span class="quote">-dirs</span>” part) together with the required
4121: version number (always pick the latest one when writing new
4122: packages). </p>
4123: <p> For example, if a package installs files under
1.76 rillig 4124: <code class="filename">share/applications</code>, it should have the
1.75 rillig 4125: following line in it:
4126: </p>
4127: <pre class="programlisting">
4128: USE_DIRS+= xdg-1.1
1.1 grant 4129: </pre>
1.75 rillig 4130: <p> After regenerating the PLIST using <span><strong class="command">make
4131: print-PLIST</strong></span>, you should get the right (commented out)
4132: lines. </p>
4133: <p> Note that even if your package is using
1.76 rillig 4134: <code class="filename">$X11BASE</code>, it must not depend on the
1.75 rillig 4135: *-x11-dirs packages. Just specify the name without that part and
1.76 rillig 4136: pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
1.75 rillig 4137: care of it. </p>
4138: </div>
4139: </div>
4140: <div class="chapter" lang="en">
4141: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4142: <a name="buildlink"></a>Chapter 12. Buildlink methodology</h2></div></div></div>
1.75 rillig 4143: <div class="toc">
4144: <p><b>Table of Contents</b></p>
4145: <dl>
1.77 rillig 4146: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
4147: <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 4148: <dd><dl>
1.77 rillig 4149: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
4150: <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 4151: </dl></dd>
1.77 rillig 4152: <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 4153: <dd><dl>
1.77 rillig 4154: <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>
4155: <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 4156: </dl></dd>
4157: </dl>
4158: </div>
4159: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
4160: are seen by a package's configure and build processes. This is implemented
4161: in a two step process:</p>
4162: <div class="orderedlist"><ol type="1">
4163: <li><p>Symlink headers and libraries for dependencies into
4164: <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
4165: of <code class="varname">WRKDIR</code>.</p></li>
4166: <li><p>Create wrapper scripts that are used in place of the normal compiler
4167: tools that translate <code class="option">-I${LOCALBASE}/include</code> and
4168: <code class="option">-L${LOCALBASE}/lib</code> into references to
4169: <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
4170: native compiler on some operating systems look like GCC, so that
4171: packages that expect GCC won't require modifications to build with
4172: those native compilers.</p></li>
4173: </ol></div>
4174: <p>This normalizes the environment in which a package is built so that the
4175: package may be built consistently despite what other software may be
4176: installed. Please note that the normal system header and library paths,
1.76 rillig 4177: e.g. <code class="filename">/usr/include</code>,
4178: <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
1.75 rillig 4179: designed to insulate the package build from non-system-supplied
4180: software. </p>
4181: <div class="sect1" lang="en">
4182: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4183: <a name="converting-to-buildlink3"></a>12.1. Converting packages to use buildlink3</h2></div></div></div>
1.75 rillig 4184: <p>The process of converting packages to use the buildlink3
4185: framework (“<span class="quote">bl3ifying</span>”) is fairly straightforward.
4186: The things to keep in mind are:</p>
4187: <div class="orderedlist"><ol type="1">
4188: <li><p> Ensure that the build always calls the wrapper scripts
4189: instead of the actual toolchain. Some packages are tricky,
4190: and the only way to know for sure is the check
1.76 rillig 4191: <code class="filename">${WRKDIR}/.work.log</code> to see if the
1.75 rillig 4192: wrappers are being invoked. </p></li>
4193: <li><p> Don't override <code class="varname">PREFIX</code> from within
4194: the package Makefile, e.g. Java VMs, standalone shells,
4195: etc., because the code to symlink files into
1.76 rillig 4196: <code class="filename">${BUILDLINK_DIR}</code> looks for files
1.75 rillig 4197: relative to “<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>”.
4198: </p></li>
4199: <li><p> Remember that <span class="emphasis"><em>only</em></span> the
1.76 rillig 4200: <code class="filename">buildlink3.mk</code> files that you list in a
1.75 rillig 4201: package's Makefile are added as dependencies for that package.
4202: </p></li>
4203: </ol></div>
4204: <p> If a dependency on a particular package is required for its libraries and
4205: headers, then we replace: </p>
4206: <pre class="programlisting">
4207: DEPENDS+= foo>=1.1.0:../../category/foo
1.1 grant 4208: </pre>
1.75 rillig 4209: <p>with</p>
4210: <pre class="programlisting">
4211: .include "../../category/foo/buildlink3.mk"
1.1 grant 4212: </pre>
1.75 rillig 4213: <p>The buildlink3.mk files usually define the required dependencies.
4214: If you need a newer version of the dependency when using buildlink3.mk
4215: files, then you can define it in your Makefile; for example:
4216: </p>
4217: <pre class="programlisting">
4218: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
4219: .include "../../category/foo/buildlink3.mk"
1.1 grant 4220: </pre>
1.76 rillig 4221: <p>There are several <code class="filename">buildlink3.mk</code>
4222: files in <code class="filename">pkgsrc/mk</code>
1.75 rillig 4223: that handle special package issues:</p>
4224: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4225: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
1.75 rillig 4226: the native or a pkgsrc Berkeley DB implementation based on
4227: the values of <code class="varname">BDB_ACCEPTED</code> and
4228: <code class="varname">BDB_DEFAULT</code>.</p></li>
1.76 rillig 4229: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
1.75 rillig 4230: comes with neither Curses nor NCurses, this will take care
1.76 rillig 4231: 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>
4232: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
1.75 rillig 4233: of <code class="varname">KRB5_ACCEPTED</code> to choose between
4234: adding a dependency on Heimdal or MIT-krb5 for packages that
4235: require a Kerberos 5 implementation.</p></li>
1.76 rillig 4236: <li><p><code class="filename">motif.buildlink3.mk</code> checks
1.75 rillig 4237: for a system-provided
1.76 rillig 4238: 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
4239: <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>
4240: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
1.75 rillig 4241: variables that may be used by packages that use the
4242: Open Sound System (OSS) API.</p></li>
1.76 rillig 4243: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
1.75 rillig 4244: either Postgres 7.3 or 7.4, whichever is found installed. See
4245: the file for more information. </p></li>
1.76 rillig 4246: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
1.75 rillig 4247: <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
1.76 rillig 4248: 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>
4249: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
1.75 rillig 4250: <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
4251: library.</p></li>
4252: </ul></div>
1.76 rillig 4253: <p>The comments in those <code class="filename">buildlink3.mk</code>
1.75 rillig 4254: files provide a more complete
4255: description of how to use them properly.</p>
4256: </div>
4257: <div class="sect1" lang="en">
4258: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4259: <a name="creating-buildlink3.mk"></a>12.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
1.76 rillig 4260: <p> A package's <code class="filename">buildlink3.mk</code> file is
1.75 rillig 4261: included by Makefiles to indicate the need to compile and link
4262: against header files and libraries provided by the package. A
1.76 rillig 4263: <code class="filename">buildlink3.mk</code> file should always provide
1.75 rillig 4264: enough information to add the correct type of dependency
4265: relationship and include any other
1.76 rillig 4266: <code class="filename">buildlink3.mk</code> files that it needs to find
1.75 rillig 4267: headers and libraries that it needs in turn.</p>
1.76 rillig 4268: <p> To generate an initial <code class="filename">buildlink3.mk</code>
4269: 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 4270: package is highly recommended. For most packages, the following
4271: command will generate a good starting point for
1.76 rillig 4272: <code class="filename">buildlink3.mk</code> files:</p>
1.75 rillig 4273: <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>
4274: <code class="prompt">%</code> createbuildlink >buildlink3.mk</code></strong></pre>
4275: <div class="sect2" lang="en">
4276: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4277: <a name="anatomy-of-bl3"></a>12.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
1.75 rillig 4278: <p>The following real-life example
1.76 rillig 4279: <code class="filename">buildlink3.mk</code> is taken
4280: from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
1.75 rillig 4281: <pre class="programlisting">
4282: # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
1.1 grant 4283:
1.75 rillig 4284: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
4285: TIFF_BUILDLINK3_MK:= ${TIFF_BUILDLINK3_MK}+
1.1 grant 4286:
1.75 rillig 4287: .if !empty(BUILDLINK_DEPTH:M+)
4288: BUILDLINK_DEPENDS+= tiff
4289: .endif
1.1 grant 4290:
1.75 rillig 4291: BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Ntiff}
4292: BUILDLINK_PACKAGES+= tiff
1.1 grant 4293:
1.75 rillig 4294: .if !empty(TIFF_BUILDLINK3_MK:M+)
4295: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
4296: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
4297: .endif # TIFF_BUILDLINK3_MK
1.1 grant 4298:
1.75 rillig 4299: .include "../../devel/zlib/buildlink3.mk"
4300: .include "../../graphics/jpeg/buildlink3.mk"
1.1 grant 4301:
1.75 rillig 4302: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
1.1 grant 4303: </pre>
1.75 rillig 4304: <p> The header and footer manipulate
4305: <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
1.76 rillig 4306: <code class="filename">buildlink3.mk</code> files and is used to track
1.75 rillig 4307: at what depth we are including
1.76 rillig 4308: <code class="filename">buildlink3.mk</code> files.</p>
1.75 rillig 4309: <p> The first section controls if the dependency on
4310: <em class="replaceable"><code>pkg</code></em> is added.
4311: <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
4312: packages for which dependencies are added by
4313: buildlink3.</p>
4314: <p> The second section advises pkgsrc that the
1.76 rillig 4315: <code class="filename">buildlink3.mk</code> file for
1.75 rillig 4316: <em class="replaceable"><code>pkg</code></em> has been included at some point.
4317: <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
1.76 rillig 4318: packages for which <code class="filename">buildlink3.mk</code> files
1.75 rillig 4319: have been included. It must <span class="emphasis"><em>always</em></span> be
1.76 rillig 4320: appended to within a <code class="filename">buildlink3.mk</code>
1.75 rillig 4321: file. </p>
4322: <p> The third section is protected from multiple inclusion
4323: and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
4324: added. Several important variables are set in the section:
4325: </p>
4326: <div class="itemizedlist"><ul type="disc">
4327: <li><p> <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4328: is the actual dependency recorded in the installed
4329: package; this should always be set using
4330: <span><strong class="command">+=</strong></span> to ensure that
4331: we're appending to any pre-existing list of values. This
4332: variable should be set to the first version of the
4333: package that had an API change.
4334: </p></li>
4335: <li><p> <code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
4336: is the location of the <em class="replaceable"><code>pkg</code></em>
4337: pkgsrc directory.</p></li>
4338: <li><p>
4339: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
4340: (not shown above) controls whether we use
4341: <code class="varname">BUILD_DEPENDS</code> or
4342: <code class="varname">DEPENDS</code> to add the dependency on
4343: <em class="replaceable"><code>pkg</code></em>.
4344: The build dependency is selected by setting
4345: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
4346: to “<span class="quote">build</span>”. By default, the
4347: full dependency is used.
4348: </p></li>
4349: <li><p>
4350: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
4351: and
4352: <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
4353: (not shown above) are lists of subdirectories of
1.76 rillig 4354: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4355: to add to the header and library search paths. These
4356: default to “<span class="quote">include</span>” and “<span class="quote">lib</span>”
4357: respectively. </p></li>
4358: <li><p>
4359: <code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
4360: (not shown above) is the list of preprocessor flags to add
4361: to <code class="varname">CPPFLAGS</code>, which are passed on to the
4362: configure and build phases. The “<span class="quote">-I</span>” option
4363: should be avoided and instead be handled using
4364: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
4365: above.</p></li>
4366: </ul></div>
4367: <p> The following variables are all optionally defined within
4368: this second section (protected against multiple inclusion) and
4369: control which package files are symlinked into
1.76 rillig 4370: <code class="filename">${BUILDLINK_DIR}</code> and how their names are
1.75 rillig 4371: transformed during the symlinking: </p>
4372: <div class="itemizedlist"><ul type="disc">
4373: <li><p>
4374: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
4375: (not shown above) is a shell glob pattern relative to
1.76 rillig 4376: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4377: to be symlinked into
1.76 rillig 4378: <code class="filename">${BUILDLINK_DIR}</code>,
4379: e.g. <code class="filename">include/*.h</code>. </p></li>
1.75 rillig 4380: <li><p>
4381: <code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
4382: (not shown above) is a shell pipeline that
4383: outputs to stdout a list of files relative to
1.76 rillig 4384: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
1.75 rillig 4385: The resulting files are to be symlinked
1.76 rillig 4386: into <code class="filename">${BUILDLINK_DIR}</code>. By default,
4387: this takes the <code class="filename">+CONTENTS</code> of a
1.75 rillig 4388: <em class="replaceable"><code>pkg</code></em> and filters it through
4389: <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.
4390: </p></li>
4391: <li><p>
4392: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
4393: (not shown above) is a filter command that filters
1.76 rillig 4394: <code class="filename">+CONTENTS</code> input into a list of files
1.75 rillig 4395: relative to
1.76 rillig 4396: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4397: on stdout. By default for overwrite packages,
4398: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.76 rillig 4399: outputs the contents of the <code class="filename">include</code>
4400: and <code class="filename">lib</code> directories in the package
4401: <code class="filename">+CONTENTS</code>, and for pkgviews packages,
1.75 rillig 4402: it outputs any libtool archives in
1.76 rillig 4403: <code class="filename">lib</code> directories.
1.75 rillig 4404: </p></li>
4405: <li><p>
4406: <code class="varname">BUILDLINK_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
4407: (not shown above) is a list of sed arguments used to
4408: transform the name of the source filename into a
4409: destination filename, e.g. <span><strong class="command">-e
4410: "s|/curses.h|/ncurses.h|g"</strong></span>.
4411: </p></li>
4412: </ul></div>
4413: <p> The last section includes any
1.76 rillig 4414: <code class="filename">buildlink3.mk</code> needed for
1.75 rillig 4415: <em class="replaceable"><code>pkg</code></em>'s library dependencies.
1.76 rillig 4416: Including these <code class="filename">buildlink3.mk</code> files
1.75 rillig 4417: means that the headers and libraries for these
4418: dependencies are also symlinked into
1.76 rillig 4419: <code class="filename">${BUILDLINK_DIR}</code>
1.75 rillig 4420: whenever the <em class="replaceable"><code>pkg</code></em>
1.76 rillig 4421: <code class="filename">buildlink3.mk</code>
1.75 rillig 4422: file is included.
4423: </p>
4424: </div>
4425: <div class="sect2" lang="en">
4426: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4427: <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 4428: <p>
4429: The situation that requires increasing the dependency listed in
4430: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4431: after a package update is when the API or interface to the
4432: header files change.</p>
4433: <p> In this case,
4434: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4435: should be adjusted to require at least the new package
4436: version. In some cases, the packages that depend on this new
4437: version may need their <code class="varname">PKGREVISION</code>s
1.76 rillig 4438: increased and, if they have <code class="filename">buildlink3.mk</code>
1.75 rillig 4439: files, their
4440: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4441: adjusted, too. This is needed so pkgsrc will require the
4442: correct package dependency and not settle for an older one
4443: when building the source.</p>
4444: <p>
4445: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4446: should be increased when the binary interface or sonames
4447: (major number of the library version) of any installed
4448: shared libraries change. This is needed so that binary
4449: packages made using it will require the correct package
4450: dependency and not settle for an older one which will not
4451: contain the necessary shared libraries. </p>
4452: <p>
1.78 ! rillig 4453: See <a href="#dependencies" title="17.1.6. Handling dependencies">Section 17.1.6, “Handling dependencies”</a> for
1.75 rillig 4454: more information about dependencies on other packages,
4455: including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
4456: <code class="varname">ABI_DEPENDS</code> definitions. </p>
4457: <p> Please take careful consideration before adjusting
4458: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4459: or
4460: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4461: as we don't want to cause unneeded package deletions and
4462: rebuilds. In many cases, new versions of packages work just
4463: fine with older dependencies.</p>
4464: <p>
4465: Also it is not needed to set
4466: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4467: when it is identical to
4468: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>. </p>
4469: </div>
4470: </div>
4471: <div class="sect1" lang="en">
4472: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4473: <a name="writing-builtin.mk"></a>12.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.75 rillig 4474: <p>
4475: Some packages in pkgsrc install headers and libraries that
4476: coincide with headers and libraries present in the base system.
1.76 rillig 4477: Aside from a <code class="filename">buildlink3.mk</code> file, these
4478: packages should also include a <code class="filename">builtin.mk</code>
1.75 rillig 4479: file that includes the necessary checks to decide whether using
4480: the built-in software or the pkgsrc software is
4481: appropriate. </p>
4482: <p> The only requirements of a builtin.mk file for
4483: <em class="replaceable"><code>pkg</code></em> are:
4484: </p>
4485: <div class="orderedlist"><ol type="1">
4486: <li><p> It should set
4487: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4488: to either “<span class="quote">yes</span>” or “<span class="quote">no</span>”
4489: after it is included.
4490: </p></li>
4491: <li><p> It should <span class="emphasis"><em>not</em></span> override any
4492: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4493: which is already set before the
1.76 rillig 4494: <code class="filename">builtin.mk</code> file is included.
1.75 rillig 4495: </p></li>
4496: <li><p> It should be written to allow multiple inclusion. This
4497: is <span class="emphasis"><em>very</em></span> important and takes careful
1.76 rillig 4498: attention to <code class="filename">Makefile</code> coding.
1.75 rillig 4499: </p></li>
4500: </ol></div>
4501: <div class="sect2" lang="en">
4502: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4503: <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 4504: <p>The following is the recommended template for builtin.mk
4505: files: </p>
4506: <pre class="programlisting">
4507: .if !defined(IS_BUILTIN.foo)
4508: #
4509: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
4510: # genuinely exists in the system or not.
4511: #
4512: IS_BUILTIN.foo?= no
1.1 grant 4513:
1.75 rillig 4514: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
4515: # version can be determined.
4516: #
4517: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
4518: BUILTIN_PKG.foo?= foo-1.0
4519: . endif
4520: .endif # IS_BUILTIN.foo
1.1 grant 4521:
1.75 rillig 4522: .if !defined(USE_BUILTIN.foo)
4523: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
4524: . if defined(BUILTIN_PKG.foo)
4525: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
4526: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
4527: USE_BUILTIN.foo!= \
4528: if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then \
4529: ${ECHO} "yes"; \
4530: else \
4531: ${ECHO} "no"; \
4532: fi
4533: . endif
4534: . endfor
4535: . endif
4536: .endif # USE_BUILTIN.foo
1.1 grant 4537:
1.75 rillig 4538: CHECK_BUILTIN.foo?= no
4539: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
4540: #
4541: # Here we place code that depends on whether USE_BUILTIN.foo is set to
4542: # "yes" or "no".
4543: #
4544: .endif # CHECK_BUILTIN.foo
1.1 grant 4545: </pre>
1.75 rillig 4546: <p> The first section sets
4547: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4548: depending on if <em class="replaceable"><code>pkg</code></em> really exists
4549: in the base system. This should not be a base system software
4550: with similar functionality to <em class="replaceable"><code>pkg</code></em>;
4551: it should only be “<span class="quote">yes</span>” if the actual package is
4552: included as part of the base system. This variable is only
1.76 rillig 4553: used internally within the <code class="filename">builtin.mk</code>
1.75 rillig 4554: file. </p>
4555: <p> The second section sets
4556: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
4557: to the version of <em class="replaceable"><code>pkg</code></em> in the base
4558: system if it exists (if
4559: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4560: is “<span class="quote">yes</span>”). This variable is only used internally
1.76 rillig 4561: within the <code class="filename">builtin.mk</code> file. </p>
1.75 rillig 4562: <p> The third section sets
4563: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4564: and is <span class="emphasis"><em>required</em></span> in all
1.76 rillig 4565: <code class="filename">builtin.mk</code> files. The code in this
1.75 rillig 4566: section must make the determination whether the built-in
4567: software is adequate to satisfy the dependencies listed in
4568: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
4569: This is typically done by comparing
4570: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
4571: against each of the dependencies in
4572: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
4573: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4574: <span class="emphasis"><em>must</em></span> be set to the correct value by the
1.76 rillig 4575: end of the <code class="filename">builtin.mk</code> file. Note that
1.75 rillig 4576: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4577: may be “<span class="quote">yes</span>” even if
4578: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4579: is “<span class="quote">no</span>” because we may make the determination
4580: that the built-in version of the software is similar enough to
4581: be used as a replacement. </p>
4582: <p> The last section is guarded by
4583: <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
4584: and includes code that uses the value of
4585: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4586: set in the previous section. This typically includes, e.g.,
4587: adding additional dependency restrictions and listing
4588: additional files to symlink into
1.76 rillig 4589: <code class="filename">${BUILDLINK_DIR}</code> (via
1.75 rillig 4590: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).
4591: </p>
4592: </div>
4593: <div class="sect2" lang="en">
4594: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4595: <a name="native-or-pkgsrc-preference"></a>12.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
1.75 rillig 4596: <p>
4597: When building packages, it's possible to choose whether to set
4598: a global preference for using either the built-in (native)
4599: version or the pkgsrc version of software to satisfy a
4600: dependency. This is controlled by setting
4601: <code class="varname">PREFER_PKGSRC</code> and
4602: <code class="varname">PREFER_NATIVE</code>. These variables take values
4603: of either “<span class="quote">yes</span>”, “<span class="quote">no</span>”, or a list of
4604: packages. <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
4605: use the pkgsrc versions of software, while
4606: <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
4607: built-in versions. Preferences are determined by the most
4608: specific instance of the package in either
4609: <code class="varname">PREFER_PKGSRC</code> or
4610: <code class="varname">PREFER_NATIVE</code>. If a package is specified
4611: in neither or in both variables, then
4612: <code class="varname">PREFER_PKGSRC</code> has precedence over
4613: <code class="varname">PREFER_NATIVE</code>. For example, to require
4614: using pkgsrc versions of software for all but the most basic
4615: bits on a NetBSD system, you can set: </p>
4616: <pre class="programlisting">
4617: PREFER_PKGSRC= yes
4618: PREFER_NATIVE= getopt skey tcp_wrappers
1.1 grant 4619: </pre>
1.75 rillig 4620: <p> A package <span class="emphasis"><em>must</em></span> have a
1.76 rillig 4621: <code class="filename">builtin.mk</code>
1.75 rillig 4622: file to be listed in <code class="varname">PREFER_NATIVE</code>,
4623: otherwise it is simply ignored in that list.
4624: </p>
4625: </div>
4626: </div>
4627: </div>
4628: <div class="chapter" lang="en">
4629: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4630: <a name="pkginstall"></a>Chapter 13. The pkginstall framework</h2></div></div></div>
1.75 rillig 4631: <div class="toc">
4632: <p><b>Table of Contents</b></p>
4633: <dl>
1.77 rillig 4634: <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 4635: <dd><dl>
1.77 rillig 4636: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
4637: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
1.75 rillig 4638: </dl></dd>
1.77 rillig 4639: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
1.75 rillig 4640: <dd><dl>
1.77 rillig 4641: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
4642: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
4643: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
4644: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
4645: </dl></dd>
4646: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
4647: <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>
4648: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
4649: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
4650: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
4651: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
4652: <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 4653: </dl>
4654: </div>
4655: <p>This chapter describes the framework known as
4656: <code class="literal">pkginstall</code>, whose key features are:</p>
4657: <div class="itemizedlist"><ul type="disc">
4658: <li><p>Generic installation and manipulation of directories and files
4659: outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
4660: <li><p>Automatic handling of configuration files during installation,
4661: provided that packages are correctly designed.</p></li>
4662: <li><p>Generation and installation of system startup scripts.</p></li>
4663: <li><p>Registration of system users and groups.</p></li>
4664: <li><p>Registration of system shells.</p></li>
4665: <li><p>Automatic updating of fonts databases.</p></li>
4666: </ul></div>
4667: <p>The following sections inspect each of the above points in detail.</p>
4668: <p>You may be thinking that many of the things described here could be
4669: easily done with simple code in the package's post-installation target
4670: (<code class="literal">post-install</code>). <span class="emphasis"><em>This is incorrect</em></span>,
4671: as the code in them is only executed when building from source. Machines
4672: using binary packages could not benefit from it at all (as the code itself
4673: could be unavailable). Therefore, the only way to achieve any of the items
4674: described above is by means of the installation scripts, which are
4675: automatically generated by pkginstall.</p>
4676: <div class="sect1" lang="en">
4677: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4678: <a name="files-and-dirs-outside-prefix"></a>13.1. Files and directories outside the installation prefix</h2></div></div></div>
1.76 rillig 4679: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
1.75 rillig 4680: of files and directories that belong to a package. The names used in it
1.76 rillig 4681: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
1.75 rillig 4682: which means that it cannot register files outside this directory (absolute
4683: path names are not allowed). Despite this restriction, some packages need
4684: to install files outside this location; e.g., under
1.76 rillig 4685: <code class="filename">${VARBASE}</code> or
4686: <code class="filename">${PKG_SYSCONFDIR}</code>.</p>
1.75 rillig 4687: <p>The only way to achieve this is to create such files during
4688: installation time by using the installation scripts. These scripts can run
4689: arbitrary commands, so they have the potential to create and manage files
4690: anywhere in the file system. Here is where pkginstall comes into play: it
4691: provides generic scripts to abstract the manipulation of such files and
4692: directories based on variables set in the package's
1.76 rillig 4693: <code class="filename">Makefile</code>. The rest of this section describes these
1.75 rillig 4694: variables.</p>
4695: <div class="sect2" lang="en">
4696: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4697: <a name="dirs-outside-prefix"></a>13.1.1. Directory manipulation</h3></div></div></div>
1.75 rillig 4698: <p>The following variables can be set to request the creation of
4699: directories anywhere in the file system:</p>
4700: <div class="itemizedlist"><ul type="disc">
4701: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
4702: contain a list of directories that should be created and should attempt
4703: to be destroyed by the installation scripts. The difference between
4704: the two is that the latter prompts the administrator to remove any
4705: directories that may be left after deinstallation (because they were
4706: not empty), while the former does not.</p></li>
4707: <li>
4708: <p><code class="varname">MAKE_DIRS_PERMS</code> and
4709: <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
4710: which directories should be created and should attempt to be destroyed
4711: by the installation scripts. Each tuple holds the following values,
4712: separated by spaces: the directory name, its owner, its group and its
4713: numerical mode. For example:</p>
4714: <pre class="programlisting">
4715: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 4716: </pre>
1.75 rillig 4717: <p>The difference between the two is exactly the same as their
4718: non-<code class="varname">PERMS</code> counterparts.</p>
4719: </li>
4720: </ul></div>
4721: </div>
4722: <div class="sect2" lang="en">
4723: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4724: <a name="files-outside-prefix"></a>13.1.2. File manipulation</h3></div></div></div>
1.75 rillig 4725: <p>Creating non-empty files outside the installation prefix is tricky
1.76 rillig 4726: because the <code class="filename">PLIST</code> forces all files to be inside it.
1.75 rillig 4727: To overcome this problem, the only solution is to extract the file in the
4728: known place (i.e., inside the installation prefix) and copy it to the
4729: appropriate location during installation (done by the installation scripts
4730: generated by pkginstall). We will call the former the <span class="emphasis"><em>master
4731: file</em></span> in the following paragraphs, which describe the variables
4732: that can be used to automatically and consistently handle files outside the
4733: installation prefix:</p>
4734: <div class="itemizedlist"><ul type="disc">
4735: <li>
4736: <p><code class="varname">CONF_FILES</code> and
4737: <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
4738: During installation time, the master file is copied to the target one
4739: if and only if the latter does not exist. Upon deinstallation, the
4740: target file is removed provided that it was not modified by the
4741: installation.</p>
4742: <p>The difference between the two is that the latter prompts the
4743: administrator to remove any files that may be left after
4744: deinstallation (because they were not empty), while the former does
4745: not.</p>
4746: </li>
4747: <li>
4748: <p><code class="varname">CONF_FILES_PERMS</code> and
4749: <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
4750: files as well as their target locations. For each of them, it also
4751: specifies their owner, their group and their numeric permissions, in
4752: this order. For example:</p>
4753: <pre class="programlisting">
4754: SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 4755: </pre>
1.75 rillig 4756: <p>The difference between the two is exactly the same as their
4757: non-<code class="varname">PERMS</code> counterparts.</p>
4758: </li>
4759: </ul></div>
4760: </div>
4761: </div>
4762: <div class="sect1" lang="en">
4763: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4764: <a name="conf-files"></a>13.2. Configuration files</h2></div></div></div>
1.75 rillig 4765: <p>Configuration files are special in the sense that they are installed
4766: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
4767: need special treatment during installation (most of which is automated by
4768: pkginstall). The main concept you must bear in mind is that files marked
4769: as configuration files are automatically copied to the right place (somewhere
4770: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
4771: and only if</em></span> they didn't exist before. Similarly, they will not
4772: be removed if they have local modifications. This ensures that
4773: administrators never lose any custom changes they may have made.</p>
4774: <div class="sect2" lang="en">
4775: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4776: <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 4777: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
4778: specifies where configuration files shall be installed. Its contents are
4779: set based upon the following variables:</p>
4780: <div class="itemizedlist"><ul type="disc">
4781: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
1.76 rillig 4782: directory. Defaults to <code class="filename">${PREFIX}/etc</code> although it may
1.75 rillig 4783: be overridden by the user to point to his preferred location (e.g.,
1.76 rillig 4784: <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
1.75 rillig 4785: Packages must not use it directly.</p></li>
4786: <li>
4787: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
4788: <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
4789: for the package being built shall be installed. The definition of this
4790: variable only makes sense in the package's
1.76 rillig 4791: <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
1.75 rillig 4792: <p>As an example, consider the Apache package,
1.76 rillig 4793: <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 4794: configuration files under the
1.76 rillig 4795: <code class="filename">httpd/</code> subdirectory of
1.75 rillig 4796: <code class="varname">PKG_SYSCONFBASE</code>. This should be set in the package
4797: Makefile.</p>
4798: </li>
4799: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
4800: variable that holds this package's configuration directory (if
4801: different from <code class="varname">PKG_SYSCONFBASE</code>). It defaults to
4802: <code class="varname">PKGBASE</code>'s value, and is always prefixed with
4803: <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
4804: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
4805: directory where the configuration files for the package identified by
4806: <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
4807: </ul></div>
4808: <p>Based on the above variables, pkginstall determines the value of
4809: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
4810: variable that can be used within a package to refer to its configuration
4811: directory. The algorithm used to set its value is basically the
4812: following:</p>
4813: <div class="orderedlist"><ol type="1">
4814: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
4815: its value is used.</p></li>
4816: <li><p>If the previous variable is not defined but
4817: <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
1.76 rillig 4818: <code class="filename">Makefile</code>, the resulting value is
4819: <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
1.75 rillig 4820: <li><p>Otherwise, it is set to
1.76 rillig 4821: <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
1.75 rillig 4822: </ol></div>
1.76 rillig 4823: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
1.77 rillig 4824: 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 4825: </div>
4826: <div class="sect2" lang="en">
4827: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4828: <a name="conf-files-configure"></a>13.2.2. Telling the software where configuration files are</h3></div></div></div>
1.75 rillig 4829: <p>Given that pkgsrc (and users!) expect configuration files to be in a
4830: known place, you need to teach each package where it shall install its
4831: files. In some cases you will have to patch the package Makefiles to
4832: achieve it. If you are lucky, though, it may be as easy as passing an
4833: extra flag to the configuration script; this is the case of GNU Autoconf-
4834: generated files:</p>
4835: <pre class="programlisting">
4836: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1 grant 4837: </pre>
1.75 rillig 4838: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
4839: for</em></span> its configuration files, not where they will be originally
4840: installed (although the difference is never explicit,
4841: unfortunately).</p>
4842: </div>
4843: <div class="sect2" lang="en">
4844: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4845: <a name="conf-files-patching"></a>13.2.3. Patching installations</h3></div></div></div>
1.75 rillig 4846: <p>As said before, pkginstall automatically handles configuration files.
4847: This means that <span class="strong"><strong>the packages themselves must not
1.76 rillig 4848: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
1.75 rillig 4849: directly</strong></span>. Bad news is that many software installation scripts
4850: will, out of the box, mess with the contents of that directory. So what is
4851: the correct procedure to fix this issue?</p>
4852: <p>You must teach the package (usually by manually patching it) to
4853: install any configuration files under the examples hierarchy,
1.76 rillig 4854: <code class="filename">share/examples/${PKGBASE}/</code>. This way, the
4855: <code class="filename">PLIST</code> registers them and the administrator always
1.75 rillig 4856: has the original copies available.</p>
4857: <p>Once the required configuration files are in place (i.e., under the
4858: examples hierarchy), the pkginstall framework can use them as master copies
4859: during the package installation to update what is in
1.76 rillig 4860: <code class="filename">${PKG_SYSCONFDIR}</code>. To achieve this, the variables
1.75 rillig 4861: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
1.77 rillig 4862: 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 4863: about their syntax and their purpose. Here is an example, taken from the
1.76 rillig 4864: <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 4865: <pre class="programlisting">
4866: EGDIR= ${PREFIX}/share/doc/mutt/samples
4867: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1 grant 4868: </pre>
1.75 rillig 4869: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
4870: package and has no meaning outside it.</p>
4871: </div>
4872: <div class="sect2" lang="en">
4873: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4874: <a name="conf-files-disable"></a>13.2.4. Disabling handling of configuration files</h3></div></div></div>
1.75 rillig 4875: <p>The automatic copying of config files can be toggled by setting the
4876: environment variable <code class="varname">PKG_CONFIG</code> prior to package
4877: installation.</p>
4878: </div>
4879: </div>
4880: <div class="sect1" lang="en">
4881: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4882: <a name="rcd-scripts"></a>13.3. System startup scripts</h2></div></div></div>
1.75 rillig 4883: <p>System startup scripts are special files because they must be
4884: installed in a place known by the underlying OS, usually outside the
1.77 rillig 4885: 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 4886: can be used. However, pkginstall provides a special mechanism to handle
4887: these files.</p>
4888: <p>In order to provide system startup scripts, the package has
4889: to:</p>
4890: <div class="orderedlist"><ol type="1">
1.76 rillig 4891: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
1.75 rillig 4892: the <code class="literal">.sh</code> suffix appended. Considering the
1.76 rillig 4893: <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
4894: <code class="filename">cupsd.sh</code> in its files directory.</p></li>
1.75 rillig 4895: <li>
4896: <p>Tell pkginstall to handle it, appending the name of the script,
4897: without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
4898: Continuing the previous example:</p>
4899: <pre class="programlisting">
4900: RCD_SCRIPTS+= cupsd
1.1 grant 4901: </pre>
1.75 rillig 4902: </li>
4903: </ol></div>
4904: <p>Once this is done, pkginstall will do the following steps for each
4905: script in an automated fashion:</p>
4906: <div class="orderedlist"><ol type="1">
4907: <li><p>Process the file found in the files directory applying all the
1.76 rillig 4908: substitutions described in the <code class="filename">FILES_SUBST</code>
1.75 rillig 4909: variable.</p></li>
4910: <li><p>Copy the script from the files directory to the examples
1.76 rillig 4911: hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>. Note
1.75 rillig 4912: that this master file must be explicitly registered in the
1.76 rillig 4913: <code class="filename">PLIST</code>.</p></li>
1.75 rillig 4914: <li><p>Add code to the installation scripts to copy the startup script
4915: from the examples hierarchy into the system-wide startup scripts
4916: directory.</p></li>
4917: </ol></div>
4918: <div class="sect2" lang="en">
4919: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4920: <a name="rcd-scripts-disable"></a>13.3.1. Disabling handling of system startup scripts</h3></div></div></div>
1.75 rillig 4921: <p>The automatic copying of config files can be toggled by setting the
4922: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
4923: installation. Note that the scripts will be always copied inside the
1.76 rillig 4924: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
1.75 rillig 4925: matter what the value of this variable is.</p>
4926: </div>
4927: </div>
4928: <div class="sect1" lang="en">
4929: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4930: <a name="users-and-groups"></a>13.4. System users and groups</h2></div></div></div>
1.75 rillig 4931: <p>If a package needs to create special users and/or groups during
4932: installation, it can do so by using the pkginstall framework.</p>
4933: <p>Users can be created by adding entries to the
4934: <code class="varname">PKG_USERS</code> variable. Each entry has the following
4935: syntax:</p>
4936: <pre class="programlisting">
4937: user:group
1.1 grant 4938: </pre>
1.75 rillig 4939: <p>Further specification of user details may be done by setting per-user
4940: variables.
4941: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the numeric
4942: UID for the user.
4943: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the user's
4944: description or comment.
4945: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the user's
1.76 rillig 4946: home directory, and defaults to <code class="filename">/nonexistent</code> if not
1.75 rillig 4947: specified.
4948: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the user's
1.76 rillig 4949: shell, and defaults to <code class="filename">/sbinno/login</code> if not specified.
1.75 rillig 4950: </p>
4951: <p>Similarly, groups can be created by adding entries to the
4952: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
4953: <pre class="programlisting">
4954: group
1.1 grant 4955: </pre>
1.75 rillig 4956: <p>The numeric GID of the group may be set by defining
4957: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
4958: <p>If a package needs to create the users and groups at an earlier
4959: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
4960: either <code class="literal">configure</code> or <code class="literal">build</code> to
4961: indicate the phase before which the users and groups are created. In
4962: this case, the numeric UIDs and GIDs of the created users and groups
4963: are automatically hardcoded into the final installation scripts.</p>
4964: </div>
4965: <div class="sect1" lang="en">
4966: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4967: <a name="shells"></a>13.5. System shells</h2></div></div></div>
1.75 rillig 4968: <p>Packages that install system shells should register them in the shell
1.76 rillig 4969: database, <code class="filename">/etc/shells</code>, to make things easier to the
1.75 rillig 4970: administrator. This must be done from the installation scripts to keep
4971: binary packages working on any system. pkginstall provides an easy way to
4972: accomplish this task.</p>
4973: <p>When a package provides a shell interpreter, it has to set the
4974: <code class="varname">PKG_SHELL</code> variable to its absolute file name. This will
4975: add some hooks to the installation scripts to handle it. Consider the
1.76 rillig 4976: 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 4977: <pre class="programlisting">
4978: PKG_SHELL= ${PREFIX}/bin/zsh
1.1 grant 4979: </pre>
1.75 rillig 4980: <div class="sect2" lang="en">
4981: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4982: <a name="shells-disable"></a>13.5.1. Disabling shell registration</h3></div></div></div>
1.75 rillig 4983: <p>The automatic registration of shell interpreters can be disabled by
1.76 rillig 4984: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
1.75 rillig 4985: environment variable to <code class="literal">NO</code>.</p>
4986: </div>
4987: </div>
4988: <div class="sect1" lang="en">
4989: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4990: <a name="fonts"></a>13.6. Fonts</h2></div></div></div>
1.75 rillig 4991: <p>Packages that install X11 fonts should update the database files
4992: that index the fonts within each fonts directory. This can easily be
4993: accomplished within the pkginstall framework.</p>
4994: <p>When a package installs X11 fonts, it must list the directories in
4995: which fonts are installed in the
4996: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
4997: where <em class="replaceable"><code>type</code></em> can be one of “<span class="quote">ttf</span>”,
4998: “<span class="quote">type1</span>” or “<span class="quote">x11</span>”. This will add hooks to the
4999: installation scripts to run the appropriate commands to update the fonts
5000: database files within each of those directories. For convenience, if the
5001: directory path is relative, it is taken to be relative to the package's
1.76 rillig 5002: 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 5003: <pre class="programlisting">
5004: FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
1.1 grant 5005: </pre>
1.75 rillig 5006: <div class="sect2" lang="en">
5007: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5008: <a name="fonts-disable"></a>13.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
1.75 rillig 5009: <p>The automatic update of fonts databases can be disabled by
1.76 rillig 5010: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
1.75 rillig 5011: environment variable to <code class="literal">NO</code>.</p>
5012: </div>
5013: </div>
5014: </div>
5015: <div class="chapter" lang="en">
5016: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5017: <a name="options"></a>Chapter 14. Options handling</h2></div></div></div>
1.75 rillig 5018: <div class="toc">
5019: <p><b>Table of Contents</b></p>
5020: <dl>
1.77 rillig 5021: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
5022: <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>
5023: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
1.75 rillig 5024: </dl>
5025: </div>
5026: <p>Many packages have the ability to be built to support different
1.76 rillig 5027: sets of features. <code class="filename">bsd.options.mk</code> is a framework
1.75 rillig 5028: in pkgsrc that provides generic handling of those options that
5029: determine different ways in which the packages can be built. It's
5030: possible for the user to specify exactly which sets of options will be
5031: built into a package or to allow a set of global default options
5032: apply.</p>
5033: <div class="sect1" lang="en">
5034: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5035: <a name="global-default-options"></a>14.1. Global default options</h2></div></div></div>
1.75 rillig 5036: <p>Global default options are listed in
5037: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
5038: that should be built into every package if that option is supported.
1.76 rillig 5039: This variable should be set in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 5040: </div>
5041: <div class="sect1" lang="en">
5042: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5043: <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 5044: <p>The following example shows how
1.76 rillig 5045: <code class="filename">bsd.options.mk</code> should be used
1.75 rillig 5046: by the hypothetical ``wibble'' package, either in the package
1.76 rillig 5047: <code class="filename">Makefile</code>, or in a file,
5048: e.g. <code class="filename">options.mk</code>, that is included by the
5049: main package <code class="filename">Makefile</code>.</p>
1.75 rillig 5050: <pre class="programlisting">
5051: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
5052: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
5053: PKG_OPTIONS_OPTIONAL_GROUPS= database
5054: PKG_OPTIONS_GROUP.database= mysql pgsql
5055: PKG_SUGGESTED_OPTIONS= wibble-foo
5056: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
5057: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
1.1 grant 5058:
1.75 rillig 5059: .include "../../mk/bsd.prefs.mk"
1.69 rillig 5060:
1.75 rillig 5061: # this package was previously named wibble2
5062: .if defined(PKG_OPTIONS.wibble2)
5063: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
5064: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
1.78 ! rillig 5065: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
1.75 rillig 5066: .endif
1.69 rillig 5067:
1.75 rillig 5068: .include "../../mk/bsd.options.mk"
1.69 rillig 5069:
1.75 rillig 5070: # Package-specific option-handling
1.69 rillig 5071:
1.75 rillig 5072: ###
5073: ### FOO support
5074: ###
5075: .if !empty(PKG_OPTIONS:Mwibble-foo)
5076: CONFIGURE_ARGS+= --enable-foo
5077: .endif
1.69 rillig 5078:
1.75 rillig 5079: ###
5080: ### LDAP support
5081: ###
5082: .if !empty(PKG_OPTIONS:Mldap)
1.77 rillig 5083: . include "../../databases/openldap-client/buildlink3.mk"
5084: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
1.75 rillig 5085: .endif
1.69 rillig 5086:
1.75 rillig 5087: ###
5088: ### database support
5089: ###
5090: .if !empty(PKG_OPTIONS:Mmysql)
5091: . include "../../mk/mysql.buildlink3.mk"
5092: .endif
5093: .if !empty(PKG_OPTIONS:Mpgsql)
5094: . include "../../mk/pgsql.buildlink3.mk"
5095: .endif
5096: </pre>
5097: <p>The first section contains the information about which build
5098: options are supported by the package, and any default options settings
5099: if needed.</p>
5100: <div class="orderedlist"><ol type="1">
5101: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
5102: <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
5103: options. It should be set to
1.78 ! rillig 5104: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
! 5105: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is not defined
! 5106: at the point where the options are processed.</p></li>
1.75 rillig 5107: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
5108: build options supported by the package.</p></li>
5109: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
5110: list of names of groups of mutually exclusive options. The options in
5111: each group are listed in
5112: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
5113: The most specific setting of any option from the group takes
5114: precedence over all other options in the group. Options from the
5115: groups will be automatically added to
5116: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
5117: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
5118: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
5119: packages will fail if no option from the group is
5120: selected.</p></li>
5121: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
5122: of names of sets of options. At least one option from each set must
5123: be selected. The options in each set are listed in
5124: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
5125: Options from the sets will be automatically added to
5126: <code class="varname">PKG_SUPPORTED_OPTIONS</code>. Building the package will
5127: fail if no option from the set is selected.</p></li>
5128: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
5129: build options which are enabled by default.</p></li>
5130: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
5131: of
5132: “<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>”
1.76 rillig 5133: pairs that map legacy <code class="filename">/etc/mk.conf</code> variables to
1.75 rillig 5134: their option counterparts. Pairs should be added with
5135: “<span class="quote">+=</span>” to keep the listing of global legacy variables. A
5136: warning will be issued if the user uses a legacy
5137: variable.</p></li>
5138: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
5139: of
5140: “<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>”
5141: pairs that map options that have been renamed to their new
5142: counterparts. Pairs should be added with “<span class="quote">+=</span>” to keep
5143: the listing of global legacy options. A warning will be issued if
5144: the user uses a legacy option.</p></li>
5145: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
5146: options implied by deprecated variables used. This can be used for
5147: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
5148: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
5149: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
5150: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
5151: a list of warnings about deprecated variables or options used, and
5152: what to use instead.</p></li>
5153: </ol></div>
5154: <p>A package should never modify
5155: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
5156: <code class="varname">PKG_OPTIONS_VAR</code>. These are strictly user-settable.
5157: To suggest a default set of options, use
5158: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
5159: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
1.76 rillig 5160: including <code class="filename">bsd.options.mk</code>. If none of
1.75 rillig 5161: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
5162: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
5163: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
5164: happen with platform-specific options if none of them is supported on
5165: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
5166: empty list and the package is otherwise treated as not using the
5167: options framework.</p>
1.76 rillig 5168: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
1.75 rillig 5169: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
5170: build options, properly filtered to remove unsupported and duplicate
5171: options.</p>
5172: <p>The remaining sections contain the logic that is specific to
5173: each option. The correct way to check for an option is to check
5174: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
5175: <pre class="programlisting">
5176: .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
5177: </pre>
5178: </div>
5179: <div class="sect1" lang="en">
5180: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5181: <a name="option-names"></a>14.3. Option Names</h2></div></div></div>
1.75 rillig 5182: <p>Options that enable similar features in different packages (like
5183: optional support for a library) should use a common name in all
5184: packages that support it (like the name of the library). If another
5185: package already has an option with the same meaning, use the same
5186: name.</p>
5187: <p>Options that enable features specific to one package, where it's
5188: unlikely that another (unrelated) package has the same (or a similar)
5189: optional feature, should use a name prefixed with
5190: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
5191: <p>If a group of related packages share an optional feature
5192: specific to that group, prefix it with the name of the
5193: “<span class="quote">main</span>” package
5194: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
5195: <p>For new options, add a line to
1.76 rillig 5196: <code class="filename">mk/defaults/options.description</code>. Lines have two
1.75 rillig 5197: fields, separated by tab. The first field is the option name, the
5198: second its description. The description should be a whole sentence
5199: (starting with an uppercase letter and ending with a period) that
5200: describes what enabling the option does. E. g. “<span class="quote">Enable ispell
5201: support.</span>” The file is sorted by option names.</p>
5202: </div>
5203: </div>
5204: <div class="chapter" lang="en">
5205: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5206: <a name="build"></a>Chapter 15. The build process</h2></div></div></div>
1.75 rillig 5207: <div class="toc">
5208: <p><b>Table of Contents</b></p>
5209: <dl>
1.77 rillig 5210: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
5211: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
5212: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
5213: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
5214: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
5215: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
5216: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
5217: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
5218: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
5219: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
5220: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
5221: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
5222: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
5223: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
5224: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
5225: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
1.75 rillig 5226: </dl>
5227: </div>
5228: <div class="sect1" lang="en">
5229: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5230: <a name="build.intro"></a>15.1. Introduction</h2></div></div></div>
1.75 rillig 5231: <p>This chapter gives a detailed description on how a package is
5232: built. Building a package is separated into different
5233: <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
5234: <code class="varname">build</code>, <code class="varname">install</code>), all of which are
5235: described in the following sections. Each phase is splitted into
5236: so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
5237: containing phase, prefixed by one of <code class="varname">pre-</code>,
5238: <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
5239: <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
5240: of the actual work is done in the <code class="varname">do-*</code> stages.</p>
5241: <p>The basic steps for building a program are always the same. First
5242: the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
5243: the local system and then extracted. After any pkgsrc-specific patches
5244: to compile properly are applied, the software can be configured, then
5245: built (usually by compiling), and finally the generated binaries, etc.
5246: can be put into place on the system.</p>
5247: </div>
5248: <div class="sect1" lang="en">
5249: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5250: <a name="build.prefix"></a>15.2. Program location</h2></div></div></div>
1.75 rillig 5251: <p>Before outlining the process performed by the NetBSD package system in
5252: the next section, here's a brief discussion on where programs are
5253: installed, and which variables influence this.</p>
5254: <p>The automatic variable <code class="varname">PREFIX</code> indicates
5255: where all files of the final program shall be installed. It is
5256: usually set to <code class="varname">LOCALBASE</code>
1.76 rillig 5257: (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
1.75 rillig 5258: for pkgs in the “<span class="quote">cross</span>” category. The value of
5259: <code class="varname">PREFIX</code> needs to be put
5260: into the various places in the program's source where paths to
1.77 rillig 5261: 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 5262: <p>When choosing which of these variables to use,
5263: follow the following rules:</p>
5264: <div class="itemizedlist"><ul type="disc">
5265: <li><p><code class="varname">PREFIX</code> always points to the location where the current
5266: pkg will be installed. When referring to a pkg's own installation path,
5267: use “<span class="quote">${PREFIX}</span>”.</p></li>
5268: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs are installed.
5269: If you need to construct a -I or -L argument to the compiler to find
5270: includes and libraries installed by another non-X11 pkg, use
1.78 ! rillig 5271: “<span class="quote">${LOCALBASE}</span>”. The name
! 5272: <code class="varname">LOCALBASE</code> stems from FreeBSD, which
! 5273: installed all packages in <code class="filename">/usr/local</code>. As
! 5274: pkgsrc leaves <code class="filename">/usr/local</code> for the system
! 5275: administrator, this variable is a misnomer.</p></li>
1.75 rillig 5276: <li><p><code class="varname">X11BASE</code> is where the actual X11 distribution (from
5277: xsrc, etc.) is installed. When looking for
5278: <span class="emphasis"><em>standard</em></span> X11 includes (not
5279: those installed by a pkg), use “<span class="quote">${X11BASE}</span>”.</p></li>
5280: <li>
5281: <p>X11-based packages are special in that they may be installed in
5282: either <code class="varname">X11BASE</code> or <code class="varname">LOCALBASE</code>.</p>
5283: <p>Usually, X11 packages should be installed under
5284: <code class="varname">LOCALBASE</code> whenever possible. Note that you will
1.76 rillig 5285: need to include <code class="filename">../../mk/x11.buildlink3.mk</code>
1.75 rillig 5286: in them to request the
5287: presence of X11 and to get the right compilation flags.</p>
5288: <p>Even though, there are some packages that cannot be installed
5289: under <code class="varname">LOCALBASE</code>: those that come with app-defaults
5290: files. These packages are special and they must be placed under
5291: <code class="varname">X11BASE</code>. To accomplish this, set either
5292: <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
5293: your package.</p>
5294: <p>Some notes: If you need
5295: to find includes or libraries installed by a pkg that has
5296: <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
1.76 rillig 5297: its pkg <code class="filename">Makefile</code>, you need to look in
5298: <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
5299: <code class="filename">${LOCALBASE}</code>. To force installation of
1.75 rillig 5300: all X11 packages in <code class="varname">LOCALBASE</code>, the
1.76 rillig 5301: <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 5302: is enabled by default.</p>
5303: </li>
5304: <li><p><code class="varname">X11PREFIX</code> should be used to refer to the installed
5305: location of an X11 package. <code class="varname">X11PREFIX</code> will be set to
5306: <code class="varname">X11BASE</code> if xpkgwedge is not installed,
5307: and to <code class="varname">LOCALBASE</code> if xpkgwedge is installed.</p></li>
5308: <li>
5309: <p>If xpkgwedge is installed, it is possible to have some packages installed
5310: in <code class="varname">X11BASE</code> and some in <code class="varname">LOCALBASE</code>.
5311: To determine the prefix of an installed package, the
5312: <code class="varname">EVAL_PREFIX</code> definition can be used. It takes pairs in the
5313: 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
5314: <code class="varname">DIRNAME</code> will be set to the prefix of the installed
5315: package <package>, or “<span class="quote">${X11PREFIX}</span>” if the package is
5316: not installed.</p>
5317: <p>This is best illustrated by example.</p>
5318: <p>The following lines are taken from
1.76 rillig 5319: <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
1.75 rillig 5320: <pre class="programlisting">
5321: EVAL_PREFIX+= GTKDIR=gtk+
5322: CONFIGURE_ARGS+= --with-guile-prefix=${LOCALBASE:Q}
5323: CONFIGURE_ARGS+= --with-gtk-prefix=${GTKDIR:Q}
5324: CONFIGURE_ARGS+= --enable-multibyte
5325: </pre>
5326: <p>Specific defaults can be defined for the packages evaluated using
5327: <code class="varname">EVAL_PREFIX</code>, by using a definition of the form:</p>
5328: <pre class="programlisting">
5329: GTKDIR_DEFAULT= ${LOCALBASE}
5330: </pre>
5331: <p>where <code class="varname">GTKDIR</code> corresponds
5332: to the first definition in
5333: the <code class="varname">EVAL_PREFIX</code> pair.</p>
5334: </li>
1.76 rillig 5335: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.75 rillig 5336: 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 5337: manual pages go into <code class="filename">${PREFIX}/man</code>, not
5338: <code class="filename">${PREFIX}/share/man</code>.</p></li>
1.75 rillig 5339: </ul></div>
5340: </div>
5341: <div class="sect1" lang="en">
5342: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5343: <a name="build.builddirs"></a>15.3. Directories used during the build process</h2></div></div></div>
1.75 rillig 5344: <p>When building a package, a number of directories is used to store
5345: source files, temporary files, pkgsrc-internal files, and so on. These
5346: directories are explained here.</p>
5347: <p>Some of the directory variables contain relative pathnames. There
5348: are two common base directories for these relative directories:
5349: <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
5350: pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
5351: inside the package itself.</p>
5352: <div class="variablelist"><dl>
5353: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
5354: <dd><p>This is an absolute pathname that points to the pkgsrc
5355: root directory. Generally, you don't need
5356: it.</p></dd>
5357: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
5358: <dd><p>This is a pathname relative to
5359: <code class="varname">PKGSRCDIR</code> that points to the current
5360: package.</p></dd>
5361: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
5362: <dd><p>This is an absolute pathname pointing to the directory
5363: where all work takes place. The distfiles are extraced to this
5364: directory. It also contains temporary directories and log files used by
5365: the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
5366: the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
5367: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
5368: <dd><p>This is an absolute pathname pointing to the directory
5369: where the distfiles are extracted. It is usually a direct subdirectory
5370: of <code class="varname">WRKDIR</code>, and often it's the only directory entry
5371: that isn't hidden. This variable may be changed by a package
1.76 rillig 5372: <code class="filename">Makefile</code>.</p></dd>
1.75 rillig 5373: </dl></div>
5374: </div>
5375: <div class="sect1" lang="en">
5376: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5377: <a name="build.running"></a>15.4. Running a phase</h2></div></div></div>
1.75 rillig 5378: <p>You can run a particular phase by typing <span><strong class="command">make
5379: phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
5380: phase. This will automatically run all phases that are required for this
5381: phase. The default phase is <code class="varname">build</code>, that is, when you
5382: run <span><strong class="command">make</strong></span> without parameters in a package directory,
5383: the package will be built, but not installed.</p>
5384: </div>
5385: <div class="sect1" lang="en">
5386: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5387: <a name="build.fetch"></a>15.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.75 rillig 5388: <p>This will check if the file(s) given in the variables
5389: <code class="varname">DISTFILES</code> and <code class="varname">PATCHFILES</code> (as
5390: defined in the package's Makefile) are present on the
1.76 rillig 5391: local system in <code class="filename">/usr/pkgsrc/distfiles</code>. If they
1.75 rillig 5392: are not present, an attempt will be made to fetch them using commands
5393: of the form:</p>
5394: <pre class="programlisting">
5395: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
5396: </pre>
5397: <p>where ${site} varies through several possibilities in turn: first,
5398: <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the sites
5399: specified in either <code class="varname">SITES.file</code> if defined, else
5400: <code class="varname">MASTER_SITES</code> or <code class="varname">PATCH_SITES</code>, as
5401: applies, then finally the value of
5402: <code class="varname">MASTER_SITE_BACKUP</code>. The order of all except the
5403: first can be optionally sorted by the user, via setting either
5404: <code class="varname">MASTER_SORT_AWK</code> or
5405: <code class="varname">MASTER_SORT_REGEX</code>.</p>
5406: </div>
5407: <div class="sect1" lang="en">
5408: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5409: <a name="build.checksum"></a>15.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
1.75 rillig 5410: <p>After the distfile(s) are fetched, their checksum is generated and
5411: compared with the checksums stored in the distinfo file. If the
5412: checksums don't match, the build is aborted. This is to ensure the same
5413: distfile is used for building, and that the distfile wasn't changed,
5414: e.g. by some malign force, deliberately changed distfiles on the master
5415: distribution site or network lossage.</p>
5416: </div>
5417: <div class="sect1" lang="en">
5418: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5419: <a name="build.extract"></a>15.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
1.75 rillig 5420: <p>When the distfiles are present on the local system, they
5421: need to be extracted, as they usually come in the form of some
5422: compressed archive format.</p>
5423: <p>By default, all <code class="varname">DISTFILES</code> are
5424: extracted. If you only need some of them, you can set the
5425: <code class="varname">EXTRACT_ONLY</code> variable to the list of those
5426: files.</p>
5427: <p>Extracting the files is usually done by a little program,
1.76 rillig 5428: <code class="filename">mk/scripts/extract</code>, which already knows how
1.75 rillig 5429: to extract various archive formats, so most likely you will not
5430: need to change anything here. But if you need, the following
5431: variables may help you:</p>
5432: <div class="variablelist"><dl>
5433: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
5434: <dd><p>Use these variables to override the default
5435: options for an extract command, which are defined in
1.76 rillig 5436: <code class="filename">mk/scripts/extract</code>.</p></dd>
1.75 rillig 5437: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
5438: <dd><p>This variable can be set to
5439: <code class="literal">pax</code>, <code class="literal">tar</code> or an absolute
5440: pathname pointing to the command with which tar archives should
5441: be extracted.</p></dd>
5442: </dl></div>
1.76 rillig 5443: <p>If the <code class="filename">extract</code> program doesn't serve
1.75 rillig 5444: your needs, you can also override the
5445: <code class="varname">EXTRACT_CMD</code> variable, which holds the command
5446: used for extracting the files. This command is executed in the
1.76 rillig 5447: <code class="filename">${WRKSRC}</code> directory. During execution of
1.75 rillig 5448: this command, the shell variable <code class="varname">extract_file</code>
5449: holds the absolute pathname of the file that is going to be
5450: extracted.</p>
5451: <p>And if that still does not suffice, you can override the
5452: <code class="varname">do-extract</code> target in the package
5453: Makefile.</p>
5454: </div>
5455: <div class="sect1" lang="en">
5456: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5457: <a name="build.patch"></a>15.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
1.75 rillig 5458: <p>After extraction, all the patches named by the
5459: <code class="varname">PATCHFILES</code>, those present in the patches
5460: subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
1.76 rillig 5461: <code class="filename">/usr/local/patches/graphics/png</code>) are applied.
5462: Patchfiles ending in <code class="filename">.Z</code> or
5463: <code class="filename">.gz</code> are uncompressed before they are applied,
5464: files ending in <code class="filename">.orig</code> or
5465: <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 5466: can be handed in <code class="varname">PATCH_DIST_ARGS</code>.
1.77 rillig 5467: See <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a> for more details.</p>
1.75 rillig 5468: <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
5469: patches apply with some lines of fuzz. Please fix (regen) the patches
5470: so that they apply cleanly. The rationale behind this is that
5471: patches that don't apply cleanly may end up being applied in the wrong
5472: place, and cause severe harm there.</p>
5473: </div>
5474: <div class="sect1" lang="en">
5475: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5476: <a name="build.tools"></a>15.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
1.75 rillig 5477: <p>This is covered in
1.77 rillig 5478: <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 5479: </p>
5480: </div>
5481: <div class="sect1" lang="en">
5482: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5483: <a name="build.wrapper"></a>15.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
1.75 rillig 5484: <p>This phase creates wrapper programs for the compilers and
5485: linkers. The following variables can be used to tweak the
5486: wrappers.</p>
5487: <div class="variablelist"><dl>
5488: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
5489: <dd><p>The command used to print progress
5490: messages. Does nothing by default. Set to
5491: <code class="literal">${ECHO}</code> to see the progress
5492: messages.</p></dd>
5493: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
5494: <dd><p>This variable can be set to
5495: <code class="literal">yes</code> (default) or
5496: <code class="literal">no</code>, depending on whether you want
5497: additional information in the wrapper log
5498: file.</p></dd>
5499: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
5500: <dd><p>This variable can be set to
5501: <code class="literal">yes</code> or <code class="literal">no</code>,
5502: depending on whether the wrapper should use its cache,
5503: which will improve the speed. The default value is
5504: <code class="literal">yes</code>, but is forced to
5505: <code class="literal">no</code> if the platform does not support
5506: it.</p></dd>
5507: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
5508: <dd><p>A list of reordering commands. A
5509: reordering command has the form
5510: <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
5511: It ensures that that
5512: <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code>
5513: occurs before
5514: <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
5515: </p></dd>
5516: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
5517: <dd><p>A list of transformation commands. [TODO:
5518: investigate further]</p></dd>
5519: </dl></div>
5520: </div>
5521: <div class="sect1" lang="en">
5522: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5523: <a name="build.configure"></a>15.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.75 rillig 5524: <p>Most pieces of software need information on the header files,
5525: system calls, and library routines which are available on the platform
5526: they run on. The process of determining this information is known as
5527: configuration, and is usually automated. In most cases, a script is
5528: supplied with the distfiles, and its invocation results in generation of
5529: header files, Makefiles, etc.</p>
5530: <p>If the package contains a configure script, this can be invoked by
5531: setting <code class="varname">HAS_CONFIGURE</code> to “<span class="quote">yes</span>”. If the
5532: configure script is a GNU autoconf script, you should set
5533: <code class="varname">GNU_CONFIGURE</code> to “<span class="quote">yes</span>” instead. What
5534: happens in the <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
5535: <pre class="programlisting">
5536: .for d in ${CONFIGURE_DIRS}
5537: cd ${WRKSRC} && cd ${d} && env ${CONFIGURE_ENV} \
5538: ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
5539: .endfor
5540: </pre>
5541: <p><code class="varname">CONFIGURE_DIRS</code> (default: “<span class="quote">.</span>”) is a
5542: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
5543: these directories, the configure script is run with the environment
5544: <code class="varname">CONFIGURE_ENV</code> and arguments
5545: <code class="varname">CONFIGURE_ARGS</code>. The variables
5546: <code class="varname">CONFIGURE_ENV</code>, <code class="varname">CONFIGURE_SCRIPT</code>
5547: (default: “<span class="quote">./configure</span>”) and
5548: <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
5549: package.</p>
1.76 rillig 5550: <p>If the program uses an <code class="filename">Imakefile</code> for
1.75 rillig 5551: configuration, the appropriate steps can be invoked by setting
5552: <code class="varname">USE_IMAKE</code> to “<span class="quote">yes</span>”. (If you only want
5553: the package installed in <code class="varname">${X11PREFIX}</code> but xmkmf not
5554: being run, set <code class="varname">USE_X11BASE</code> instead.)</p>
5555: </div>
5556: <div class="sect1" lang="en">
5557: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5558: <a name="build.build"></a>15.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.75 rillig 5559: <p>For building a package, a rough equivalent of the following code
5560: is executed.</p>
5561: <pre class="programlisting">
5562: .for d in ${BUILD_DIRS}
5563: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
5564: ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
5565: -f ${MAKEFILE} ${BUILD_TARGET}
5566: .endfor
5567: </pre>
5568: <p><code class="varname">BUILD_DIRS</code> (default: “<span class="quote">.</span>”) is a
5569: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
5570: these directories, <code class="varname">MAKE_PROGRAM</code> is run with the
5571: environment <code class="varname">MAKE_ENV</code> and arguments
5572: <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
5573: <code class="varname">MAKE_ENV</code>, <code class="varname">BUILD_MAKE_FLAGS</code>,
5574: <code class="varname">MAKEFILE</code> and <code class="varname">BUILD_TARGET</code> may all
5575: be changed by the package.</p>
5576: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
5577: “<span class="quote">gmake</span>” if <code class="varname">USE_TOOLS</code> contains
5578: “<span class="quote">gmake</span>”, “<span class="quote">make</span>” otherwise. The default value
5579: of <code class="varname">MAKEFILE</code> is “<span class="quote">Makefile</span>”, and
5580: <code class="varname">BUILD_TARGET</code> defaults to “<span class="quote">all</span>”.</p>
5581: </div>
5582: <div class="sect1" lang="en">
5583: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5584: <a name="build.test"></a>15.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
1.75 rillig 5585: <p>[TODO]</p>
5586: </div>
5587: <div class="sect1" lang="en">
5588: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5589: <a name="build.install"></a>15.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75 rillig 5590: <p>Once the build stage has completed, the final step is to
5591: install the software in public directories, so users can access
5592: the programs and files.</p>
5593: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
5594: equivalent of the following code is executed. Additionally,
5595: before and after this code, much magic is performed to do
5596: consistency checks, registering the package, and so on.</p>
5597: <pre class="programlisting">
5598: .for d in ${INSTALL_DIRS}
5599: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
5600: ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
5601: -f ${MAKEFILE} ${BUILD_TARGET}
5602: .endfor
5603: </pre>
5604: <p>The variable's meanings are analogous to the ones in the
5605: <span class="emphasis"><em>build</em></span> phase.
5606: <code class="varname">INSTALL_DIRS</code> defaults to
5607: <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
5608: is “<span class="quote">install</span>” by default, plus
5609: “<span class="quote">install.man</span>” if <code class="varname">USE_IMAKE</code> is
5610: defined.</p>
5611: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
5612: variables are useful. They are all variations of the
5613: <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
5614: permissions preset. <code class="varname">INSTALL</code> is the plain
5615: install command. The specialized variants, together with their
5616: intended use, are:</p>
5617: <div class="variablelist"><dl>
5618: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
5619: <dd><p>directories that contain binaries</p></dd>
5620: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
5621: <dd><p>directories that contain scripts</p></dd>
5622: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
5623: <dd><p>directories that contain shared and static libraries</p></dd>
5624: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
5625: <dd><p>directories that contain data files</p></dd>
5626: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
5627: <dd><p>directories that contain man pages</p></dd>
5628: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
5629: <dd><p>binaries that can be stripped from debugging symbols</p></dd>
5630: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
5631: <dd><p>binaries that cannot be stripped</p></dd>
5632: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
5633: <dd><p>game binaries</p></dd>
5634: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
5635: <dd><p>shared and static libraries</p></dd>
5636: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
5637: <dd><p>data files</p></dd>
5638: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
5639: <dd><p>data files for games</p></dd>
5640: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
5641: <dd><p>man pages</p></dd>
5642: </dl></div>
5643: <p>Some other variables are:</p>
5644: <div class="variablelist"><dl>
5645: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
5646: <dd><p>A list of directories relative to
5647: <code class="varname">PREFIX</code> that are created by pkgsrc at
1.78 ! rillig 5648: the beginning of the <span class="emphasis"><em>install</em></span> phase.
! 5649: If this variable is set,
1.75 rillig 5650: <code class="varname">NO_MTREE</code>=“<span class="quote">yes</span>” is
5651: assumed, which means that the package claims to create
5652: all needed directories itself before installing files to
5653: it. Therefore this variable should only be set in
1.76 rillig 5654: <code class="filename">Makefile</code>s that are under control of
1.78 ! rillig 5655: the package's author. The directories are created with
! 5656: the correct ownership, depending on their
! 5657: name.</p></dd>
1.75 rillig 5658: </dl></div>
5659: </div>
5660: <div class="sect1" lang="en">
5661: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5662: <a name="build.package"></a>15.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
1.75 rillig 5663: <p>[TODO]</p>
5664: </div>
5665: <div class="sect1" lang="en">
5666: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5667: <a name="build.helpful-targets"></a>15.16. Other helpful targets</h2></div></div></div>
1.75 rillig 5668: <div class="variablelist"><dl>
5669: <dt><span class="term">pre/post-*</span></dt>
5670: <dd><p>For any of the main targets described in the previous section, two
5671: auxiliary targets exist with “<span class="quote">pre-</span>” and
5672: “<span class="quote">post-</span>” used as a prefix
5673: for the main target's name. These targets are invoked before and
5674: after the main target is called, allowing extra configuration or
5675: installation steps be performed from a package's Makefile, for
5676: example, which a program's configure script
5677: or install target omitted.</p></dd>
5678: <dt><span class="term">do-*</span></dt>
5679: <dd><p>Should one of the main targets do the wrong thing, and should there
5680: be no variable to fix this, you can redefine it with the do-*
5681: target. (Note that redefining the target itself instead of the
5682: do-* target is a bad idea, as the pre-* and post-* targets won't be
5683: called anymore, etc.) You will not usually need to do this.</p></dd>
5684: <dt><span class="term">reinstall</span></dt>
5685: <dd><p>If you did a <span><strong class="command">make install</strong></span> and you noticed some file
5686: was not installed properly, you can repeat the installation with this
5687: target, which will ignore the “<span class="quote">already installed</span>” flag.</p></dd>
5688: <dt><span class="term">deinstall</span></dt>
5689: <dd>
5690: <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,
5691: effectively de-installing the package. The following variables can
5692: be used to tune the behaviour:</p>
5693: <div class="variablelist"><dl>
5694: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
5695: <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>
5696: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
5697: <dd><p>Remove all packages that require (depend on) the given package.
5698: This can be used to remove any packages that may have been pulled in
5699: by a given package, e.g. if <span><strong class="command">make deinstall
5700: DEINSTALLDEPENDS=1</strong></span> is done in
1.76 rillig 5701: <code class="filename">pkgsrc/x11/kde</code>, this is likely to remove whole
1.75 rillig 5702: 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>
5703: </dl></div>
5704: </dd>
5705: <dt><span class="term">update</span></dt>
5706: <dd>
5707: <p>This target causes the current package to be updated to the latest
5708: version. The package and all depending packages first get de-installed,
5709: then current versions of the corresponding packages get compiled and
5710: installed. This is similar to manually noting which packages are
5711: currently installed, then performing a series of <span><strong class="command">make
5712: deinstall</strong></span> and <span><strong class="command">make install</strong></span> (or whatever
5713: <code class="varname">UPDATE_TARGET</code> is set to) for these packages.</p>
5714: <p>You can use the “<span class="quote">update</span>” target to resume package
5715: updating in case a previous <span><strong class="command">make update</strong></span> was interrupted
5716: for some reason. However, in this case, make sure you don't call
5717: <span><strong class="command">make clean</strong></span> or otherwise remove the list of dependent
5718: packages in <code class="varname">WRKDIR</code>. Otherwise, you lose the
5719: ability to automatically update the current package along with the
5720: dependent packages you have installed.</p>
5721: <p>Resuming an interrupted <span><strong class="command">make update</strong></span> will only work as
5722: long as the package tree remains unchanged. If the source code for
5723: one of the packages to be updated has been changed, resuming
5724: <span><strong class="command">make update</strong></span> will most certainly fail!</p>
5725: <p>The following variables can be used either on the command line or in
1.76 rillig 5726: <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75 rillig 5727: <span><strong class="command">make update</strong></span>:</p>
5728: <div class="variablelist"><dl>
5729: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
5730: <dd><p>Install target to recursively use for the updated package and the
5731: dependent packages. Defaults to <code class="varname">DEPENDS_TARGET</code> if set,
5732: “<span class="quote">install</span>” otherwise for <span><strong class="command">make update</strong></span>.
5733: e.g. <span><strong class="command">make update UPDATE_TARGET=package</strong></span></p></dd>
5734: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
5735: <dd><p>Don't clean up after updating. Useful if you want to leave the
5736: work sources of the updated packages around for inspection or
5737: other purposes. Be sure you eventually clean up the source
5738: tree (see the “<span class="quote">clean-update</span>” target below) or you may
5739: run into troubles with old source code still lying around on your
5740: next <span><strong class="command">make</strong></span> or <span><strong class="command">make update</strong></span>.</p></dd>
5741: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
5742: <dd><p>Deinstall each package before installing (making
5743: <code class="varname">DEPENDS_TARGET</code>). This may be necessary if the
5744: “<span class="quote">clean-update</span>” target (see below) was called after
5745: interrupting a running <span><strong class="command">make update</strong></span>.</p></dd>
5746: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
5747: <dd><p>Allows you to disable recursion and hardcode the target for
5748: packages. The default is “<span class="quote">update</span>” for the update target,
5749: facilitating a recursive update of prerequisite packages.
5750: Only set <code class="varname">DEPENDS_TARGET</code> if you want to disable
5751: recursive updates. Use <code class="varname">UPDATE_TARGET</code> instead to just
5752: set a specific target for each package to be installed during
5753: <span><strong class="command">make update</strong></span> (see above).</p></dd>
5754: </dl></div>
5755: </dd>
5756: <dt><span class="term">clean-update</span></dt>
5757: <dd>
5758: <p>Clean the source tree for all packages that would get updated if
5759: <span><strong class="command">make update</strong></span> was called from the current directory.
5760: This target should not be used if the current package (or any of its
5761: depending packages) have already been de-installed (e.g., after calling
5762: <span><strong class="command">make update</strong></span>) or you may lose some packages you intended
5763: to update. As a rule of thumb: only use this target
5764: <span class="emphasis"><em>before</em></span> the first time you run
5765: <span><strong class="command">make update</strong></span> and only if you have a dirty package tree
5766: (e.g., if you used <code class="varname">NOCLEAN</code>).</p>
5767: <p>If you are unsure about whether your tree is clean, you can either
5768: perform a <span><strong class="command">make clean</strong></span> at the top of the tree, or use
5769: the following sequence of commands from the directory of the package
5770: you want to update (<span class="emphasis"><em>before</em></span> running
5771: <span><strong class="command">make update</strong></span> for the first time, otherwise you lose
5772: all the packages you wanted to update!):</p>
5773: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
5774: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
5775: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong></pre>
5776: <p>The following variables can be used either on the command line or in
1.76 rillig 5777: <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75 rillig 5778: <span><strong class="command">make clean-update</strong></span>:</p>
5779: <div class="variablelist"><dl>
5780: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
5781: <dd><p>After <span><strong class="command">make clean</strong></span>, do not reconstruct the list of
5782: directories to update for this package. Only use this if <span><strong class="command">make
5783: update</strong></span> successfully installed all packages you wanted to
5784: update. Normally, this is done automatically on <span><strong class="command">make
5785: update</strong></span>, but may have been suppressed by the
5786: <code class="varname">NOCLEAN</code> variable (see above).</p></dd>
5787: </dl></div>
5788: </dd>
5789: <dt><span class="term">info</span></dt>
5790: <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
5791: package. You can use this to check which version of a package is
5792: installed.</p></dd>
5793: <dt><span class="term">readme</span></dt>
1.76 rillig 5794: <dd><p>This target generates a <code class="filename">README.html</code> file, which
1.75 rillig 5795: can be viewed using a browser such as
1.76 rillig 5796: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/mozilla/README.html" target="_top"><code class="filename">www/mozilla</code></a> or
5797: <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 5798: The generated files contain references to any
5799: packages which are in the <code class="varname">PACKAGES</code> directory on
5800: the local host. The generated files can be made to refer to URLs based on
5801: <code class="varname">FTP_PKG_URL_HOST</code> and
5802: <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I wanted to generate
1.76 rillig 5803: <code class="filename">README.html</code> files which pointed to binary packages
1.75 rillig 5804: on the local machine, in the directory
1.76 rillig 5805: <code class="filename">/usr/packages</code>, set
1.75 rillig 5806: <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
5807: <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
5808: <code class="varname">${PACKAGES}</code> directory and its subdirectories will be
5809: searched for all the binary packages.</p></dd>
5810: <dt><span class="term">readme-all</span></dt>
1.76 rillig 5811: <dd><p>Use this target to create a file <code class="filename">README-all.html</code>
1.75 rillig 5812: which contains a list of all packages currently available in the NetBSD
5813: Packages Collection, together with the category they belong to and a
5814: short description. This file is compiled from the
1.76 rillig 5815: <code class="filename">pkgsrc/*/README.html</code> files, so be sure to run
1.75 rillig 5816: this <span class="emphasis"><em>after</em></span> a <span><strong class="command">make readme</strong></span>.</p></dd>
5817: <dt><span class="term">cdrom-readme</span></dt>
5818: <dd><p>This is very much the same as the “<span class="quote">readme</span>” target (see
5819: above), but is to be used when generating a pkgsrc tree to be written
5820: to a CD-ROM. This target also produces
1.76 rillig 5821: <code class="filename">README.html</code> files, and can be made to refer
1.75 rillig 5822: to URLs based on <code class="varname">CDROM_PKG_URL_HOST</code> and
5823: <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
5824: <dt><span class="term">show-distfiles</span></dt>
5825: <dd><p>This target shows which distfiles and patchfiles are needed to build
5826: the package. (<code class="varname">DISTFILES</code> and
1.76 rillig 5827: <code class="varname">PATCHFILES</code>, but not <code class="filename">patches/*</code>)</p></dd>
1.75 rillig 5828: <dt><span class="term">show-downlevel</span></dt>
5829: <dd><p>This target shows nothing if the package is not installed. If a version
5830: of this package is installed, but is not the version provided in this
5831: version of pkgsrc, then a warning message is displayed. This target can
5832: be used to show which of your installed packages are downlevel, and so
5833: the old versions can be deleted, and the current ones added.</p></dd>
5834: <dt><span class="term">show-pkgsrc-dir</span></dt>
5835: <dd><p>This target shows the directory in the pkgsrc hierarchy from which the
5836: package can be built and installed. This may not be the same directory
5837: as the one from which the package was installed. This target is intended
5838: to be used by people who may wish to upgrade many packages on a single
5839: host, and can be invoked from the top-level pkgsrc Makefile by using the
5840: “<span class="quote">show-host-specific-pkgs</span>” target.</p></dd>
5841: <dt><span class="term">show-installed-depends</span></dt>
5842: <dd><p>This target shows which installed packages match the current package's
5843: <code class="varname">DEPENDS</code>. Useful if out of date dependencies are
5844: causing build problems.</p></dd>
5845: <dt><span class="term">check-shlibs</span></dt>
5846: <dd><p>After a package is installed, check all its binaries and (on ELF
5847: platforms) shared libraries to see if they find the shared libs they need.
5848: Run by default if <code class="varname">PKG_DEVELOPER</code> is set in
1.76 rillig 5849: <code class="filename">/etc/mk.conf</code>.</p></dd>
1.75 rillig 5850: <dt><span class="term">print-PLIST</span></dt>
5851: <dd>
5852: <p>After a “<span class="quote">make install</span>” from a new or
5853: upgraded pkg, this prints out an attempt to generate a new
1.76 rillig 5854: <code class="filename">PLIST</code> from a <span><strong class="command">find -newer
1.75 rillig 5855: work/.extract_done</strong></span>. An attempt is made to care
5856: for shared libs etc., but it is
5857: <span class="emphasis"><em>strongly</em></span> recommended to review the
5858: result before putting it into
1.76 rillig 5859: <code class="filename">PLIST</code>. On upgrades, it's useful to
1.75 rillig 5860: diff the output of this command against an already
1.76 rillig 5861: existing <code class="filename">PLIST</code> file.</p>
1.75 rillig 5862: <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
5863: methods that don't update file access times, be sure to
5864: add these files manually to your
1.76 rillig 5865: <code class="filename">PLIST</code>, as the “<span class="quote">find
1.75 rillig 5866: -newer</span>” command used by this target won't catch
5867: them!</p>
1.77 rillig 5868: <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 5869: information on this target.</p>
5870: </dd>
5871: <dt><span class="term">bulk-package</span></dt>
5872: <dd>
5873: <p>Used to do bulk builds. If an appropriate binary package already exists,
5874: no action is taken. If not, this target will compile, install and
5875: package it (and its depends, if <code class="varname">PKG_DEPENDS</code> is
5876: set properly. See <a href="#binary.configuration" title="6.3.1. Configuration">Section 6.3.1, “Configuration”</a>).
5877: After creating the binary
5878: package, the sources, the just-installed package and its required
5879: packages are removed, preserving free disk space.</p>
5880: <p><span class="emphasis"><em>Beware that this target may deinstall all
5881: packages installed on a system!</em></span></p>
5882: </dd>
5883: <dt><span class="term">bulk-install</span></dt>
5884: <dd>
5885: <p>Used during bulk-installs to install required packages. If an
5886: up-to-date binary package is available, it will be installed via
5887: <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,
5888: but the installed binary won't be removed. </p>
5889: <p> A binary package is considered “<span class="quote">up-to-date</span>” to be
5890: 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>
5891: <div class="itemizedlist"><ul type="disc">
1.76 rillig 5892: <li><p>None of the package's files (<code class="filename">Makefile</code>,
1.75 rillig 5893: ...) were modified since it was built.</p></li>
5894: <li><p>None of the package's required (binary) packages were
5895: modified since it was built.</p></li>
5896: </ul></div>
5897: <p><span class="emphasis"><em>Beware that this target may deinstall all
5898: packages installed on a system!</em></span></p>
5899: </dd>
5900: </dl></div>
5901: </div>
5902: </div>
5903: <div class="chapter" lang="en">
5904: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5905: <a name="tools"></a>Chapter 16. Tools needed for building or running</h2></div></div></div>
1.75 rillig 5906: <div class="toc">
5907: <p><b>Table of Contents</b></p>
5908: <dl>
1.77 rillig 5909: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
5910: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
5911: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
1.75 rillig 5912: </dl>
5913: </div>
5914: <p>
5915: The <code class="varname">USE_TOOLS</code> definition is used both internally
5916: by pkgsrc and also for individual packages to define what commands
5917: are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
5918: or for later run-time of an installed packaged (such as
5919: <code class="varname">DEPENDS</code>).
5920: If the native system provides an adequate tool, then in many cases, a pkgsrc
5921: package will not be used.
5922: </p>
5923: <p>
5924: When building a package, the replacement tools are
5925: made available in a directory (as symlinks or wrapper scripts)
5926: that is early in the executable search path. Just like the buildlink
5927: system, this helps with consistent builds.
5928: </p>
5929: <p>
5930: A tool may be needed to help build a specific package. For example,
5931: perl, GNU make (gmake) or yacc may be needed.
5932: </p>
5933: <p>
5934: Also a tool may be needed, for example, because the native system's supplied
5935: tool may be inefficient for building a package with pkgsrc.
5936: For example, a package may need GNU awk, bison (instead of
5937: yacc) or a better sed.
5938: </p>
5939: <p>
5940: The tools used by a package can be listed by running
5941: <span><strong class="command">make show-tools</strong></span>.
5942: </p>
5943: <div class="sect1" lang="en">
5944: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5945: <a name="pkgsrc-tools"></a>16.1. Tools for pkgsrc builds</h2></div></div></div>
1.75 rillig 5946: <p>
5947: The default set of tools used by pkgsrc is defined in
1.76 rillig 5948: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.75 rillig 5949: such as: <span><strong class="command">cat</strong></span>, <span><strong class="command">awk</strong></span>,
5950: <span><strong class="command">chmod</strong></span>, <span><strong class="command">test</strong></span>, and so on.
5951: These can be seen by running:
5952: <span><strong class="command">make show-var VARNAME=USE_TOOLS</strong></span>.
5953: </p>
5954: <p>
5955: If a package needs a specific program to build
5956: then the <code class="varname">USE_TOOLS</code> variable can be used
5957: to define the tools needed.
5958: </p>
5959: </div>
5960: <div class="sect1" lang="en">
5961: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5962: <a name="package-tools"></a>16.2. Tools needed by packages</h2></div></div></div>
1.75 rillig 5963: <p>
5964: In the following examples, the :pkgsrc means to use the pkgsrc version
5965: and not the native version for a build dependency.
5966: And the :run means that it is used for a
5967: run-time dependencies also (and becomes a DEPENDS).
5968: The default is a build dependency which can be set with
5969: :build. (So in this example, it is the same as gmake:build
5970: and pkg-config:build.)
5971: </p>
5972: <pre class="programlisting">
5973: USE_TOOLS+= mktemp:pkgsrc
5974: USE_TOOLS+= gmake perl:run pkg-config
5975: </pre>
5976: <p>
5977: When using the tools framework, a
5978: <code class="varname">TOOLS_PATH.foo</code> variable is defined
5979: which contains the full path to the appropriate tool. For example,
5980: <code class="varname">TOOLS_PATH.bash</code> could be “<span class="quote">/bin/bash</span>”
5981: on Linux systems.
5982: </p>
5983: <p>
5984: If you always need a pkgsrc version of the
5985: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
5986:
5987: </p>
5988: </div>
5989: <div class="sect1" lang="en">
5990: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5991: <a name="platform-tools"></a>16.3. Tools provided by platforms</h2></div></div></div>
1.75 rillig 5992: <p>
5993: When improving or porting pkgsrc to a new platform, have a look
5994: at (or create) the corresponding platform specific make file fragment under
1.76 rillig 5995: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
1.75 rillig 5996: the name of the common tools. For example:</p>
5997: <pre class="programlisting">
5998: .if exists(/usr/bin/bzcat)
5999: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
6000: .elif exists(/usr/bin/bzip2)
6001: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
6002: .endif
1.69 rillig 6003:
1.75 rillig 6004: TOOLS_PLATFORM.true?= true # shell builtin
6005: </pre>
6006: </div>
6007: </div>
6008: <div class="chapter" lang="en">
6009: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 6010: <a name="fixes"></a>Chapter 17. Making your package work</h2></div></div></div>
1.75 rillig 6011: <div class="toc">
6012: <p><b>Table of Contents</b></p>
6013: <dl>
1.77 rillig 6014: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
1.75 rillig 6015: <dd><dl>
1.78 ! rillig 6016: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
! 6017: <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>
! 6018: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
! 6019: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
! 6020: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
! 6021: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
! 6022: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
! 6023: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
! 6024: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
! 6025: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
! 6026: <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.77 rillig 6027: </dl></dd>
6028: <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>
6029: <dd><dl>
6030: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
6031: <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>
6032: </dl></dd>
6033: <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>
6034: <dd><dl>
6035: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
6036: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
6037: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
6038: </dl></dd>
6039: <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>
6040: <dd><dl>
1.78 ! rillig 6041: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
! 6042: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
! 6043: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
! 6044: </dl></dd>
! 6045: <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>
! 6046: <dd><dl>
! 6047: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
! 6048: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
! 6049: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
! 6050: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
! 6051: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
! 6052: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
! 6053: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
! 6054: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
! 6055: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
! 6056: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
! 6057: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
! 6058: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
! 6059: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
! 6060: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
! 6061: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
! 6062: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
! 6063: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.75 rillig 6064: </dl></dd>
1.78 ! rillig 6065: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.75 rillig 6066: </dl>
6067: </div>
6068: <div class="sect1" lang="en">
6069: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6070: <a name="general-operation"></a>17.1. General operation</h2></div></div></div>
1.75 rillig 6071: <div class="sect2" lang="en">
6072: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 6073: <a name="portability-of-packages"></a>17.1.1. Portability of packages</h3></div></div></div>
! 6074: <p>One appealing feature of pkgsrc is that it runs on many
! 6075: different platforms. As a result, it is important to ensure,
! 6076: where possible, that packages in pkgsrc are portable. This
! 6077: chapter mentions some particular details you should pay
! 6078: attention to while working on pkgsrc.</p>
! 6079: </div>
! 6080: <div class="sect2" lang="en">
! 6081: <div class="titlepage"><div><div><h3 class="title">
! 6082: <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>
! 6083: <p>The pkgsrc user can configure pkgsrc by overriding several
! 6084: variables in the file pointed to by <code class="varname">MAKECONF</code>,
! 6085: which is <code class="filename">/etc/mk.conf</code> by default. When you
! 6086: want to use those variables in the preprocessor directives of
! 6087: <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
! 6088: <code class="literal">.for</code>), you need to include the file
! 6089: <code class="filename">../../mk/bsd.prefs.mk</code> before, which in turn
! 6090: loads the user preferences.</p>
! 6091: <p>But note that some variables may not be completely defined
! 6092: after <code class="filename">../../mk/bsd.prefs.mk</code> has been
! 6093: included, as they may contain references to variables that are
! 6094: not yet defined. In shell commands this is no problem, since
! 6095: variables are actually macros, which are only expanded when they
! 6096: are used. But in the preprocessor directives mentioned above and
! 6097: in dependency lines (of the form <code class="literal">target:
! 6098: dependencies</code>) the variables are expanded at load
! 6099: time.</p>
! 6100: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
! 6101: <h3 class="title">Note</h3>
! 6102: <p>Currently there is no exhaustive list of all
! 6103: variables that tells you whether they can be used at load time
! 6104: or only at run time, but it is in preparation.</p>
! 6105: </div>
! 6106: </div>
! 6107: <div class="sect2" lang="en">
! 6108: <div class="titlepage"><div><div><h3 class="title">
! 6109: <a name="user-interaction"></a>17.1.3. User interaction</h3></div></div></div>
! 6110: <p>Occasionally, packages require interaction from the user, and this can be
! 6111: in a number of ways:</p>
! 6112: <div class="itemizedlist"><ul type="disc">
! 6113: <li><p>When extracting the distfiles, some packages may ask for passwords.</p></li>
! 6114: <li><p>help to configure the package before it is built</p></li>
! 6115: <li><p>help during the build process</p></li>
! 6116: <li><p>help during the installation of a package</p></li>
! 6117: </ul></div>
! 6118: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is provided to notify
! 6119: the pkgsrc mechanism of an interactive stage which will be needed, and
! 6120: this should be set in the package's <code class="filename">Makefile</code>, e.g.:</p>
1.75 rillig 6121: <pre class="programlisting">
1.78 ! rillig 6122: INTERACTIVE_STAGE= build
1.75 rillig 6123: </pre>
1.78 ! rillig 6124: <p>Multiple interactive stages can be specified:</p>
1.75 rillig 6125: <pre class="programlisting">
1.78 ! rillig 6126: INTERACTIVE_STAGE= configure install
1.75 rillig 6127: </pre>
6128: </div>
6129: <div class="sect2" lang="en">
6130: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 6131: <a name="handling-licenses"></a>17.1.4. Handling licenses</h3></div></div></div>
! 6132: <p>A package may be covered by a license which the user has
! 6133: or has not agreed to accept. For these cases, pkgsrc contains
! 6134: a mechanism to note that a package is covered by a particular
! 6135: license, and the package cannot be built unless the user has
! 6136: accepted the license. (Installation of binary packages are
! 6137: not currently subject to this mechanism.) Packages with
! 6138: licenses that are either Open Source according to the Open
! 6139: Source Initiative or Free according to the Free Software
! 6140: Foundation will not be marked with a license tag. Packages
! 6141: with licenses that have not been determined to meet either
! 6142: definition will be marked with a license tag referring to the
! 6143: license. This will prevent building unless pkgsrc is informed
! 6144: that the license is acceptable, and enables displaying the
! 6145: license.</p>
! 6146: <p>The license tag mechanism is intended to address
! 6147: copyright-related issues surrounding building, installing and
! 6148: using a package, and not to address redistribution issues (see
! 6149: <code class="varname">RESTRICTED</code> and
! 6150: <code class="varname">NO_SRC_ON_FTP</code>, etc.). However, the above
! 6151: definition of licenses for which tags are not needed implies
! 6152: that packages with redistribution restrictions should have
! 6153: tags.</p>
! 6154: <p>
! 6155: Denoting that a package is covered by a particular license is
! 6156: done by placing the license in
! 6157: <code class="filename">pkgsrc/licenses</code> and setting the
! 6158: <code class="varname">LICENSE</code> variable to a string identifying
! 6159: the license, e.g. in
! 6160: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>: </p>
! 6161: <pre class="programlisting">
! 6162: LICENSE= xv-license
! 6163: </pre>
! 6164: <p>
! 6165: When trying to build, the user will get a notice that the
! 6166: package is covered by a license which has not been
! 6167: accepted:</p>
! 6168: <pre class="programlisting">
! 6169: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
! 6170: ===> xv-3.10anb9 has an unacceptable license: xv-license.
! 6171: ===> To view the license, enter "/usr/bin/make show-license".
! 6172: ===> To indicate acceptance, add this line to your /etc/mk.conf:
! 6173: ===> ACCEPTABLE_LICENSES+=xv-license
! 6174: *** Error code 1
! 6175: </pre>
! 6176: <p>The license can be viewed with <span><strong class="command">make
! 6177: show-license</strong></span>, and if it is considered appropriate,
! 6178: the line printed above can be added to
! 6179: <code class="filename">/etc/mk.conf</code> to indicate acceptance of
! 6180: the particular license:</p>
! 6181: <pre class="programlisting">
! 6182: ACCEPTABLE_LICENSES+=xv-license
! 6183: </pre>
! 6184: <p>When adding a package with a new license, the license
! 6185: text should be added to <code class="filename">pkgsrc/licenses</code>
! 6186: for displaying. A list of known licenses can be seen in this
! 6187: directory as well as by looking at the list of (commented
! 6188: out) <code class="varname">ACCEPTABLE_LICENSES</code> variable
! 6189: settings in
! 6190: <code class="filename">pkgsrc/mk/defaults/mk.conf</code>.</p>
! 6191: <p>The use of <code class="varname">LICENSE=shareware</code>,
! 6192: <code class="varname">LICENSE=no-commercial-use</code>, and similar
! 6193: language is deprecated because it does not crisply refer to
! 6194: a particular license text. Another problem with such usage
! 6195: is that it does not enable a user to denote acceptance of
! 6196: the license for a single package without accepting the same
! 6197: license text for another package. In particular, this can
! 6198: be inappropriate when e.g. one accepts a particular license to
! 6199: indicate to pkgsrc that a fee has been paid.</p>
1.75 rillig 6200: </div>
6201: <div class="sect2" lang="en">
6202: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 6203: <a name="restricted-packages"></a>17.1.5. Restricted packages</h3></div></div></div>
1.75 rillig 6204: <p>Some licenses restrict how software may be re-distributed.
6205: In order to satisfy these restrictions, the package system
6206: defines five make variables that can be set to note these
6207: restrictions:</p>
6208: <div class="itemizedlist"><ul type="disc">
6209: <li>
6210: <p><code class="varname">RESTRICTED</code></p>
6211: <p>This variable should be set whenever a restriction
6212: exists (regardless of its kind). Set this variable to a
6213: string containing the reason for the restriction.</p>
6214: </li>
6215: <li>
6216: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
6217: <p>Binaries may not be placed on CD-ROM. Set this
6218: variable to <code class="varname">${RESTRICTED}</code> whenever a
6219: binary package may not be included on a CD-ROM.</p>
6220: </li>
6221: <li>
6222: <p><code class="varname">NO_BIN_ON_FTP</code></p>
6223: <p>Binaries may not be placed on an FTP server. Set
6224: this variable to <code class="varname">${RESTRICTED}</code>
6225: whenever a binary package may not not be made available
6226: on the Internet.</p>
6227: </li>
6228: <li>
6229: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
6230: <p>Distfiles may not be placed on CD-ROM. Set this
6231: variable to <code class="varname">${RESTRICTED}</code> if
6232: re-distribution of the source code or other distfile(s) is
6233: not allowed on CD-ROMs.</p>
6234: </li>
6235: <li>
6236: <p><code class="varname">NO_SRC_ON_FTP</code></p>
6237: <p>Distfiles may not be placed on FTP. Set this variable
6238: to <code class="varname">${RESTRICTED}</code> if re-distribution of
6239: the source code or other distfile(s) via the Internet is not
6240: allowed.</p>
6241: </li>
6242: </ul></div>
6243: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
6244: <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
6245: generic make variables to denote restrictions is deprecated,
6246: because they unconditionally prevent users from generating
6247: binary packages!</p>
6248: </div>
6249: <div class="sect2" lang="en">
6250: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 6251: <a name="dependencies"></a>17.1.6. Handling dependencies</h3></div></div></div>
1.75 rillig 6252: <p>Your package may depend on some other package being present
6253: - and there are various ways of expressing this
6254: dependency. pkgsrc supports the <code class="varname">BUILD_DEPENDS</code>
6255: and <code class="varname">DEPENDS</code> definitions, the
6256: <code class="varname">USE_TOOLS</code> definition, as well as
1.76 rillig 6257: dependencies via <code class="filename">buildlink3.mk</code>, which is
1.75 rillig 6258: the preferred way to handle dependencies, and which uses the
1.77 rillig 6259: variables named above. See <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a> for more
1.75 rillig 6260: information.</p>
6261: <p>The basic difference between the two variables is as
6262: follows: The <code class="varname">DEPENDS</code> definition registers
6263: that pre-requisite in the binary package so it will be pulled in
6264: when the binary package is later installed, whilst the
6265: <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
6266: dependency that is only needed for building the package.
6267: </p>
6268: <p>This means that if you only need a package present whilst
6269: you are building, it should be noted as a
6270: <code class="varname">BUILD_DEPENDS</code>.</p>
6271: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
6272: <code class="varname">DEPENDS</code> definition is:</p>
6273: <pre class="programlisting">
6274: <pre-req-package-name>:../../<category>/<pre-req-package>
6275: </pre>
6276: <p>Please note that the “<span class="quote">pre-req-package-name</span>”
6277: may include any of the wildcard version numbers recognized by
6278: <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>
6279: <div class="orderedlist"><ol type="1">
6280: <li>
6281: <p>If your package needs another package's binaries or
6282: libraries to build or run, and if that package has a
1.76 rillig 6283: <code class="filename">buildlink3.mk</code> file available, use it:
1.75 rillig 6284: </p>
6285: <pre class="programlisting">
6286: .include "../../graphics/jpeg/buildlink3.mk"
6287: </pre>
6288: </li>
6289: <li>
6290: <p>If your package needs to use another package to build
1.76 rillig 6291: itself and there is no <code class="filename">buildlink3.mk</code>
1.75 rillig 6292: file available, use the <code class="varname">BUILD_DEPENDS</code>
6293: definition:</p>
6294: <pre class="programlisting">
6295: BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
6296: </pre>
6297: </li>
6298: <li>
6299: <p>If your package needs a library with which to link and
1.76 rillig 6300: again there is no <code class="filename">buildlink3.mk</code> file
1.75 rillig 6301: available, this is specified using the
6302: <code class="varname">DEPENDS</code> definition. For example:</p>
6303: <pre class="programlisting">
6304: DEPENDS+= xpm-3.4j:../../graphics/xpm
6305: </pre>
6306: <p>You can also use wildcards in package dependences:</p>
6307: <pre class="programlisting">
6308: DEPENDS+= xpm-[0-9]*:../../graphics/xpm
6309: </pre>
6310: <p>Note that such wildcard dependencies are retained when
6311: creating binary packages. The dependency is checked when
6312: installing the binary package and any package which matches
6313: the pattern will be used. Wildcard dependencies should be
6314: used with care.</p>
6315: <p>The “<span class="quote">-[0-9]*</span>” should be used instead of
6316: “<span class="quote">-*</span>” to avoid potentially ambiguous matches
6317: such as “<span class="quote">tk-postgresql</span>” matching a
6318: “<span class="quote">tk-*</span>” <code class="varname">DEPENDS</code>.</p>
6319: <p>Wildcards can also be used to specify that a package
6320: will only build against a certain minimum version of a
6321: pre-requisite:</p>
6322: <pre class="programlisting">
6323: DEPENDS+= tiff>=3.5.4:../../graphics/tiff
6324: </pre>
6325: <p>This means that the package will build against version
6326: 3.5.4 of the tiff library or newer. Such a dependency may
6327: be warranted if, for example, the API of the library has
6328: changed with version 3.5.4 and a package would not compile
6329: against an earlier version of tiff.</p>
6330: <p>Please note that such dependencies should only be
6331: updated if a package requires a newer pre-requisite, but
6332: not to denote recommendations such as
6333: ABI changes that do not prevent a package from building
6334: correctly. Such recommendations can be expressed using
6335: <code class="varname">ABI_DEPENDS</code>:</p>
6336: <pre class="programlisting">
6337: ABI_DEPENDS+= tiff>=3.6.1:../../graphics/tiff
6338: </pre>
6339: <p>In addition to the above <code class="varname">DEPENDS</code>
6340: line, this denotes that while a package will build against
6341: tiff>=3.5.4, at least version 3.6.1 is recommended.
6342: <code class="varname">ABI_DEPENDS</code> entries will be turned into
6343: dependencies unless explicitly ignored (in which case a
6344: warning will be printed).</p>
6345: <p>To ignore these ABI dependency recommendations and just
6346: use the required <code class="varname">DEPENDS</code>, set
6347: <code class="varname">USE_ABI_DEPENDS=NO</code>. This may make
6348: it easier and faster to update packages built using pkgsrc,
6349: since older compatible dependencies can continue to be
6350: used. This is useful for people who watch their rebuilds
6351: very carefully; it is not very good as a general-purpose
6352: hammer. If you use it, you need to be mindful of possible
6353: ABI changes, including those from the underlying OS.
6354: </p>
6355: <p>Packages that are built with recommendations ignored
6356: may not be uploaded to ftp.NetBSD.org by developers and
6357: should not be used across different systems that may have
6358: different versions of binary packages installed.</p>
6359: <p>For security fixes, please update the package
1.78 ! rillig 6360: 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 6361: information.</p>
6362: </li>
6363: <li>
6364: <p>If your package needs some executable to be able to run
6365: correctly and if there's no
1.76 rillig 6366: <code class="filename">buildlink3.mk</code> file, this is specified
1.75 rillig 6367: using the <code class="varname">DEPENDS</code> variable. The
1.76 rillig 6368: <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 6369: be able to execute the latex binary from the teTeX package
6370: when it runs, and that is specified:</p>
6371: <pre class="programlisting">
6372: DEPENDS+= teTeX-[0-9]*:../../print/teTeX
6373: </pre>
6374: <p>The comment about wildcard dependencies from previous
6375: paragraph applies here, too.</p>
6376: </li>
6377: </ol></div>
6378: <p>If your package needs files from another package to build,
6379: add the relevant distribution files to
6380: <code class="varname">DISTFILES</code>, so they will be extracted
1.76 rillig 6381: 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 6382: (It relies on the jpeg sources being present in source form
6383: during the build.)</p>
6384: <p>Please also note the <code class="varname">BUILD_USES_MSGFMT</code>
6385: and <code class="varname">BUILD_USES_GETTEXT_M4</code> definitions, which
6386: are provided as convenience definitions. The former works out
6387: 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 6388: 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 6389: The latter adds a build dependency on either an installed
6390: version of an older gettext package, or if it isn't, installs the
1.76 rillig 6391: <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 6392: </div>
6393: <div class="sect2" lang="en">
6394: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 6395: <a name="conflicts"></a>17.1.7. Handling conflicts with other packages</h3></div></div></div>
1.75 rillig 6396: <p>Your package may conflict with other packages a user might
6397: already have installed on his system, e.g. if your package
6398: installs the same set of files like another package in our
6399: pkgsrc tree.</p>
6400: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
6401: space-separated list of packages (including version string) your
6402: package conflicts with.</p>
1.76 rillig 6403: <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>
6404: 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 6405: install the same shared library, thus you set in
1.76 rillig 6406: <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
1.75 rillig 6407: <pre class="programlisting">
6408: CONFLICTS= Xaw-Xpm-[0-9]*
6409: </pre>
1.76 rillig 6410: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:
1.75 rillig 6411: </p>
6412: <pre class="programlisting">
6413: CONFLICTS= Xaw3d-[0-9]*
6414: </pre>
6415: <p>Packages will automatically conflict with other packages
6416: with the name prefix and a different version
6417: string. “<span class="quote">Xaw3d-1.5</span>” e.g. will automatically
6418: conflict with the older version “<span class="quote">Xaw3d-1.3</span>”.
6419: </p>
6420: </div>
6421: <div class="sect2" lang="en">
6422: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 6423: <a name="not-building-packages"></a>17.1.8. Packages that cannot or should not be built</h3></div></div></div>
1.75 rillig 6424: <p>There are several reasons why a package might be
6425: instructed to not build under certain circumstances. If the
6426: package builds and runs on most platforms, the exceptions
6427: should be noted with <code class="varname">NOT_FOR_PLATFORM</code>. If
6428: the package builds and runs on a small handful of platforms,
6429: set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
6430: Both <code class="varname">ONLY_FOR_PLATFORM</code> and
6431: <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
6432: (OS-version-platform) that can use glob-style
6433: wildcards.</p>
6434: <p>If the package should be skipped (for example, because it
6435: provides functionality already provided by the system), set
6436: <code class="varname">PKG_SKIP_REASON</code> to a descriptive message.
6437: If the package should fail because some preconditions are not
6438: met, set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
6439: message.</p>
6440: </div>
6441: <div class="sect2" lang="en">
6442: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 6443: <a name="undeletable-packages"></a>17.1.9. Packages which should not be deleted, once installed</h3></div></div></div>
1.75 rillig 6444: <p>To ensure that a package may not be deleted, once it has been
6445: installed, the <code class="varname">PKG_PRESERVE</code> definition should
6446: be set in the package Makefile. This will be carried into any
6447: binary package that is made from this pkgsrc entry. A
6448: “<span class="quote">preserved</span>” package will
6449: 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
6450: “<span class="quote">-f</span>” option is used.</p>
6451: </div>
6452: <div class="sect2" lang="en">
6453: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 6454: <a name="security-handling"></a>17.1.10. Handling packages with security problems</h3></div></div></div>
1.75 rillig 6455: <p>When a vulnerability is found, this should be noted in
1.76 rillig 6456: <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
1.75 rillig 6457: and after committing that file, use <span><strong class="command">make upload</strong></span>
6458: in the same directory to update the file on ftp.NetBSD.org.</p>
6459: <p>After fixing the vulnerability by a patch, its
6460: <code class="varname">PKGREVISION</code> should be increased (this
6461: is of course not necessary if the problem is fixed by using
6462: a newer release of the software).</p>
6463: <p>Also, if the fix should be applied to the stable pkgsrc
6464: branch, be sure to submit a pullup request!</p>
6465: <p>Binary packages already on ftp.NetBSD.org will be handled
6466: semi-automatically by a weekly cron job.</p>
6467: </div>
6468: <div class="sect2" lang="en">
6469: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 6470: <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 6471: <p>When making fixes to an existing package it can be useful
6472: to change the version number in <code class="varname">PKGNAME</code>. To
6473: avoid conflicting with future versions by the original author, a
6474: “<span class="quote">nb1</span>”, “<span class="quote">nb2</span>”, ... suffix can be used
6475: on package versions by setting <code class="varname">PKGREVISION=1</code>
6476: (2, ...). The “<span class="quote">nb</span>” is treated like a
6477: “<span class="quote">.</span>” by the pkg tools. e.g.</p>
6478: <pre class="programlisting">
6479: DISTNAME= foo-17.42
6480: PKGREVISION= 9
6481: </pre>
6482: <p>will result in a <code class="varname">PKGNAME</code> of
6483: “<span class="quote">foo-17.42nb9</span>”.</p>
6484: <p>When a new release of the package is released, the
6485: <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
6486: minor release of the above package, things should be like:</p>
6487: <pre class="programlisting">
6488: DISTNAME= foo-17.43
6489: </pre>
1.78 ! rillig 6490: <p>PKGREVISION should be incremented for any non-trivial change in the
! 6491: resulting binary package. Without a PKGREVISION bump, someone with
! 6492: the previous version installed has no way of knowing that their
! 6493: package is out of date. Thus, changes without increasing PKGREVISION
! 6494: are essentially labeled "this is so trivial that no reasonable person
! 6495: would want to upgrade", and this is the rough test for when increasing
! 6496: PKGREVISION is appropriate. Examples of changes that do not merit
! 6497: increasing PKGREVISION are:</p>
! 6498: <pre class="programlisting">
! 6499: Changing HOMEPAGE, MAINTAINER, or comments in Makefile.
! 6500: Changing build variables if the resulting binary package is the same.
! 6501: Changing DESCR.
! 6502: Adding PKG_OPTIONS if the default options don't change.
! 6503: </pre>
! 6504: <p>Examples of changes that do merit an increase to PKGREVISION
! 6505: include:</p>
! 6506: <pre class="programlisting">
! 6507: Security fixes
! 6508: Changes or additions to a patch file
! 6509: Changes to the PLIST
1.75 rillig 6510: </pre>
1.78 ! rillig 6511: <p>PKGREVISION must also be incremented when dependencies have ABI
! 6512: changes.</p>
1.75 rillig 6513: </div>
6514: </div>
6515: <div class="sect1" lang="en">
6516: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6517: <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 6518: <div class="sect2" lang="en">
6519: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6520: <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 6521: <p>If you need to download from a dynamic URL you can set
6522: <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span><strong class="command">make
1.76 rillig 6523: fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
1.75 rillig 6524: with the name of each file to download as an argument, expecting
6525: it to output the URL of the directory from which to download
1.76 rillig 6526: it. <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/ns-cult3d/README.html" target="_top"><code class="filename">graphics/ns-cult3d</code></a> is an
1.75 rillig 6527: example of this usage.
6528: </p>
6529: <p>If the download can't be automated, because the user must
6530: submit personal information to apply for a password, or must pay
6531: for the source, or whatever, you can set
6532: <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
6533: displayed to the user before aborting the build. Example:</p>
6534: <pre class="programlisting">
6535: FETCH_MESSAGE= "Please download the files"
6536: FETCH_MESSAGE+= " "${DISTFILES:Q}
6537: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
6538: </pre>
6539: </div>
6540: <div class="sect2" lang="en">
6541: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6542: <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 6543: <p>Sometimes authors of a software package make some
6544: modifications after the software was released, and they put up a
6545: new distfile without changing the package's version number. If a
6546: package is already in pkgsrc at that time, the checksum will
6547: no longer match. The contents of the new distfile should be
6548: compared against the old one before changing anything, to make
6549: sure the distfile was really updated on purpose, and that
6550: no trojan horse or so crept in.
6551: Then, the correct way to work around this is to
6552: set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
6553: usually based on <code class="varname">PKGNAME_NOREV</code>. In case this
6554: happens more often, <code class="varname">PKGNAME</code> can be used (thus
1.76 rillig 6555: including the <code class="filename">nbX</code> suffix) or a date stamp
1.75 rillig 6556: can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
1.76 rillig 6557: Do not forget regenerating the <code class="filename">distinfo</code> file
1.75 rillig 6558: after that, since it contains the <code class="varname">DIST_SUBDIR</code>
6559: path in the filenames.
6560: Furthermore, a mail to the package's authors seems appropriate
6561: telling them that changing distfiles after releases without
6562: changing the file names is not good practice.</p>
6563: </div>
6564: </div>
6565: <div class="sect1" lang="en">
6566: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6567: <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 6568: <div class="sect2" lang="en">
6569: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6570: <a name="fixes.libtool"></a>17.3.1. Shared libraries - libtool</h3></div></div></div>
1.75 rillig 6571: <p>pkgsrc supports many different machines, with different
6572: object formats like a.out and ELF, and varying abilities to do
6573: shared library and dynamic loading at all. To accompany this,
6574: varying commands and options have to be passed to the
6575: compiler, linker, etc. to get the Right Thing, which can be
6576: pretty annoying especially if you don't have all the machines
6577: at your hand to test things. The
1.76 rillig 6578: <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 6579: can help here, as it just “<span class="quote">knows</span>” how to build
6580: both static and dynamic libraries from a set of source files,
6581: thus being platform-independent.</p>
6582: <p>Here's how to use libtool in a pkg in seven simple
6583: steps:</p>
6584: <div class="orderedlist"><ol type="1">
6585: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
6586: Makefile.</p></li>
6587: <li><p>For library objects, use “<span class="quote">${LIBTOOL} --mode=compile
6588: ${CC}</span>” in place of “<span class="quote">${CC}</span>”. You could even
6589: add it to the definition of <code class="varname">CC</code>, if only
6590: libraries are being built in a given Makefile. This one command
6591: will build both PIC and non-PIC library objects, so you need not
6592: have separate shared and non-shared library rules.</p></li>
6593: <li>
6594: <p>For the linking of the library, remove any
6595: “<span class="quote">ar</span>”, “<span class="quote">ranlib</span>”, and “<span class="quote">ld
6596: -Bshareable</span>” commands, and instead use:</p>
6597: <pre class="programlisting">
6598: ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
6599: -rpath ${PREFIX}/lib -version-info major:minor
6600: </pre>
6601: <p>Note that the library is changed to have a
1.76 rillig 6602: <code class="filename">.la</code> extension, and the objects are
6603: changed to have a <code class="filename">.lo</code>
1.75 rillig 6604: extension. Change <code class="varname">OBJS</code> as
6605: necessary. This automatically creates all of the
1.76 rillig 6606: <code class="filename">.a</code>,
6607: <code class="filename">.so.major.minor</code>, and ELF symlinks (if
1.75 rillig 6608: necessary) in the build directory. Be sure to include
6609: “<span class="quote">-version-info</span>”, especially when major and
6610: minor are zero, as libtool will otherwise strip off the
6611: shared library version.</p>
6612: <p>From the libtool manual:</p>
6613: <pre class="programlisting">
6614: So, libtool library versions are described by three integers:
1.69 rillig 6615:
1.75 rillig 6616: CURRENT
6617: The most recent interface number that this library implements.
1.69 rillig 6618:
1.75 rillig 6619: REVISION
6620: The implementation number of the CURRENT interface.
1.69 rillig 6621:
1.75 rillig 6622: AGE
6623: The difference between the newest and oldest interfaces that
6624: this library implements. In other words, the library implements
6625: all the interface numbers in the range from number `CURRENT -
6626: AGE' to `CURRENT'.
1.1 grant 6627:
1.75 rillig 6628: If two libraries have identical CURRENT and AGE numbers, then the
6629: dynamic linker chooses the library with the greater REVISION number.
6630: </pre>
6631: <p>The “<span class="quote">-release</span>” option will produce
6632: different results for a.out and ELF (excluding symlinks)
6633: in only one case. An ELF library of the form
6634: “<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
6635: will have a symlink of
6636: “<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
6637: on an a.out platform. This is handled
6638: automatically.</p>
6639: <p>The “<span class="quote">-rpath argument</span>” is the install
6640: directory of the library being built.</p>
1.76 rillig 6641: <p>In the <code class="filename">PLIST</code>, include only the
6642: <code class="filename">.la</code> file, the other files will be
1.75 rillig 6643: added automatically.</p>
6644: </li>
6645: <li>
1.76 rillig 6646: <p>When linking shared object (<code class="filename">.so</code>)
1.75 rillig 6647: 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
6648: shared libraries, use “<span class="quote">-module
6649: -avoid-version</span>” to prevent them getting version
6650: tacked on.</p>
1.76 rillig 6651: <p>The <code class="filename">PLIST</code> file gets the
6652: <code class="filename">foo.so</code> entry.</p>
1.75 rillig 6653: </li>
6654: <li>
6655: <p>When linking programs that depend on these libraries
6656: <span class="emphasis"><em>before</em></span> they are installed, preface
6657: 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}
6658: --mode=link</span>”, and it will find the correct
6659: libraries (static or shared), but please be aware that
6660: libtool will not allow you to specify a relative path in
6661: -L (such as “<span class="quote">-L../somelib</span>”), because it
6662: expects you to change that argument to be the
1.76 rillig 6663: <code class="filename">.la</code> file. e.g.</p>
1.75 rillig 6664: <pre class="programlisting">
6665: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
6666: </pre>
6667: <p>should be changed to:</p>
6668: <pre class="programlisting">
6669: ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
6670: </pre>
6671: <p>and it will do the right thing with the libraries.</p>
6672: </li>
6673: <li>
6674: <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>
6675: 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}
6676: --mode=install</span>”, and change the library name to
1.76 rillig 6677: <code class="filename">.la</code>. e.g.</p>
1.75 rillig 6678: <pre class="programlisting">
6679: ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
6680: </pre>
1.76 rillig 6681: <p>This will install the static <code class="filename">.a</code>,
1.75 rillig 6682: shared library, any needed symlinks, and run
6683: <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>
6684: </li>
1.76 rillig 6685: <li><p>In your <code class="filename">PLIST</code>, include only
6686: the <code class="filename">.la</code>
1.75 rillig 6687: file (this is a change from previous behaviour).</p></li>
6688: </ol></div>
6689: </div>
6690: <div class="sect2" lang="en">
6691: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6692: <a name="using-libtool"></a>17.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
1.75 rillig 6693: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
6694: package Makefile. This will override the package's own libtool
6695: in most cases. For older libtool using packages, libtool is
6696: made by ltconfig script during the do-configure step; you can
6697: check the libtool script location by doing <span><strong class="command">make
6698: configure; find work*/ -name libtool</strong></span>.</p>
6699: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
6700: scripts, relative to <code class="varname">WRKSRC</code>, to override. By
6701: default, it is set to “<span class="quote">libtool */libtool
6702: */*/libtool</span>”. If this does not match the location of the
6703: package's libtool script(s), set it as appropriate.</p>
1.76 rillig 6704: <p>If you do not need <code class="filename">*.a</code> static
1.75 rillig 6705: libraries built and installed, then use
6706: <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
6707: <p>If your package makes use of the platform-independent library
6708: for loading dynamic shared objects, that comes with libtool
6709: (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
6710: <p>Some packages use libtool incorrectly so that the package may not work or
6711: build in some circumstances. Some of the more common errors are:</p>
6712: <div class="itemizedlist"><ul type="disc">
6713: <li>
6714: <p>The inclusion of a shared object (-module) as a dependent library in an
6715: executable or library. This in itself isn't a problem if one of two things
6716: has been done:</p>
6717: <div class="orderedlist"><ol type="1">
6718: <li><p>The shared object is named correctly, i.e.
1.76 rillig 6719: <code class="filename">libfoo.la</code>, not
6720: <code class="filename">foo.la</code></p></li>
1.75 rillig 6721: <li><p>The -dlopen option is used when linking an executable.</p></li>
6722: </ol></div>
6723: </li>
6724: <li><p>The use of libltdl without the correct calls to initialisation routines.
6725: The function lt_dlinit() should be called and the macro
6726: <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
6727: executables.</p></li>
6728: </ul></div>
6729: </div>
6730: <div class="sect2" lang="en">
6731: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 6732: <a name="autoconf-automake"></a>17.3.3. GNU Autoconf/Automake</h3></div></div></div>
1.75 rillig 6733: <p>If a package needs GNU autoconf or automake to be executed
6734: to regenerate the configure script and Makefile.in makefile
6735: templates, then they should be executed in a pre-configure
6736: target.</p>
6737: <p>For packages that need only autoconf:</p>
6738: <pre class="programlisting">
6739: AUTOCONF_REQD= 2.50 # if default version is not good enough
6740: USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
6741: ...
1.1 grant 6742:
1.75 rillig 6743: pre-configure:
6744: cd ${WRKSRC}; autoconf
1.1 grant 6745:
1.75 rillig 6746: ...
6747: </pre>
6748: <p>and for packages that need automake and autoconf:</p>
6749: <pre class="programlisting">
6750: AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
6751: USE_TOOLS+= automake # use "automake14" for automake-1.4
6752: ...
1.1 grant 6753:
1.75 rillig 6754: pre-configure:
6755: cd ${WRKSRC}; \
6756: aclocal; autoheader; \
6757: automake -a --foreign -i; autoconf
1.1 grant 6758:
1.75 rillig 6759: ...
6760: </pre>
6761: <p>Packages which use GNU Automake will almost certainly
6762: require GNU Make.</p>
6763: <p>There are times when the configure process makes
6764: additional changes to the generated files, which then causes
6765: the build process to try to re-execute the automake sequence.
6766: This is prevented by touching various files in the configure
6767: stage. If this causes problems with your package you can set
6768: <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
6769: Makefile.</p>
6770: </div>
6771: </div>
6772: <div class="sect1" lang="en">
6773: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6774: <a name="fixes.build"></a>17.4. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
6775: <p>The most common failures when building a package are that
6776: some platforms do not provide certain header files, functions or
6777: libraries, or they provide the functions in a library that the
6778: original package author didn't know. To work around this, you
6779: can rewrite the source code in most cases so that it does not
6780: use the missing functions or provides a replacement function.</p>
6781: <div class="sect2" lang="en">
6782: <div class="titlepage"><div><div><h3 class="title">
6783: <a name="fixes.build.cpp"></a>17.4.1. Compiling C and C++ code conditionally</h3></div></div></div>
6784: <p>If a package already comes with a GNU configure script, the
6785: preferred way to fix the build failure is to change the
6786: configure script, not the code. In the other cases, you can
6787: utilize the C preprocessor, which defines certain macros
6788: depending on the operating system and hardware architecture it
6789: compiles for. These macros can be queried using for example
6790: <code class="varname">#if defined(__i386)</code>. Almost every operating
6791: system, hardware architecture and compiler has its own macro.
6792: For example, if the macros <code class="varname">__GNUC__</code>,
6793: <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
6794: are all defined, you know that you are using NetBSD on an i386
6795: compatible CPU, and your compiler is GCC.</p>
6796: <p>The list of the following macros for hardware and
6797: operating system depends on the compiler that is used. For
6798: example, if you want to conditionally compile code on Solaris,
6799: don't use <code class="varname">__sun__</code>, as the SunPro compiler
6800: does not define it. Use <code class="varname">__sun</code> instead.</p>
1.75 rillig 6801: <div class="sect3" lang="en">
6802: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 6803: <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 6804: <p>To distinguish between 4.4 BSD-derived systems and the
6805: rest of the world, you should use the following code.</p>
6806: <pre class="programlisting">
6807: #include <sys/param.h>
6808: #if (defined(BSD) && BSD >= 199306)
6809: /* BSD-specific code goes here */
6810: #else
6811: /* non-BSD-specific code goes here */
6812: #endif
6813: </pre>
1.77 rillig 6814: <p>If this distinction is not fine enough, you can also test
6815: for the following macros.</p>
1.75 rillig 6816: <pre class="programlisting">
6817: FreeBSD __FreeBSD__
6818: DragonFly __DragonFly__
6819: Interix __INTERIX
6820: Linux linux, __linux, __linux__
6821: NetBSD __NetBSD__
6822: OpenBSD __OpenBSD__
6823: Solaris sun, __sun
6824: </pre>
6825: </div>
6826: <div class="sect3" lang="en">
6827: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 6828: <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 6829: <pre class="programlisting">
6830: i386 i386, __i386, __i386__
6831: MIPS __mips
6832: SPARC sparc, __sparc
6833: </pre>
6834: </div>
6835: <div class="sect3" lang="en">
6836: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 6837: <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 6838: <pre class="programlisting">
6839: GCC __GNUC__ (major version), __GNUC_MINOR__
6840: SunPro __SUNPRO_C (0x570 for version 5.7)
6841: </pre>
6842: </div>
6843: </div>
1.78 ! rillig 6844: <div class="sect2" lang="en">
! 6845: <div class="titlepage"><div><div><h3 class="title">
! 6846: <a name="compiler-bugs"></a>17.4.2. How to handle compiler bugs</h3></div></div></div>
! 6847: <p>Some source files trigger bugs in the compiler, based on
! 6848: combinations of compiler version and architecture and almost
! 6849: always relation to optimisation being enabled. Common symptoms
! 6850: are gcc internal errors or never finishing compiling a
! 6851: file.</p>
! 6852: <p>Typically, a workaround involves testing the
! 6853: <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
! 6854: optimisation for that combination of file,
! 6855: <code class="varname">MACHINE_ARCH</code> and compiler, and documenting it
! 6856: in <code class="filename">pkgsrc/doc/HACKS</code>. See that file for a
! 6857: number of examples.</p>
! 6858: </div>
! 6859: <div class="sect2" lang="en">
! 6860: <div class="titlepage"><div><div><h3 class="title">
! 6861: <a name="undefined-reference"></a>17.4.3. Undefined reference to “<span class="quote">...</span>”</h3></div></div></div>
! 6862: <p>This compiler error often means that a package did not
! 6863: link to a shared library it needs. The following functions are
! 6864: known to cause this error message over and over.</p>
! 6865: <div class="informaltable">
! 6866: <a name="undefined-reference-functions"></a><table border="1">
! 6867: <colgroup>
! 6868: <col>
! 6869: <col>
! 6870: <col>
! 6871: </colgroup>
! 6872: <thead><tr>
! 6873: <th>Function</th>
! 6874: <th>Library</th>
! 6875: <th>Affected platforms</th>
! 6876: </tr></thead>
! 6877: <tbody>
! 6878: <tr>
! 6879: <td>accept, bind, connect</td>
! 6880: <td>-lsocket</td>
! 6881: <td>Solaris</td>
! 6882: </tr>
! 6883: <tr>
! 6884: <td>crypt</td>
! 6885: <td>-lcrypt</td>
! 6886: <td>DragonFly, NetBSD</td>
! 6887: </tr>
! 6888: <tr>
! 6889: <td>dlopen, dlsym</td>
! 6890: <td>-ldl</td>
! 6891: <td>Linux</td>
! 6892: </tr>
! 6893: <tr>
! 6894: <td>gethost*</td>
! 6895: <td>-lnsl</td>
! 6896: <td>Solaris</td>
! 6897: </tr>
! 6898: <tr>
! 6899: <td>inet_aton</td>
! 6900: <td>-lresolv</td>
! 6901: <td>Solaris</td>
! 6902: </tr>
! 6903: <tr>
! 6904: <td>nanosleep, sem_*, timer_*</td>
! 6905: <td>-lrt</td>
! 6906: <td>Solaris</td>
! 6907: </tr>
! 6908: <tr>
! 6909: <td>openpty</td>
! 6910: <td>-lutil</td>
! 6911: <td>Linux</td>
! 6912: </tr>
! 6913: </tbody>
! 6914: </table>
! 6915: </div>
! 6916: <p>To fix these linker errors, it is often sufficient to say
! 6917: <code class="literal">LIBS.<em class="replaceable"><code>OperatingSystem</code></em>+=
! 6918: -l<em class="replaceable"><code>foo</code></em></code> to the package
! 6919: <code class="filename">Makefile</code> and then say <span><strong class="command">bmake clean;
! 6920: bmake</strong></span>.</p>
! 6921: </div>
1.75 rillig 6922: </div>
6923: <div class="sect1" lang="en">
6924: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 ! rillig 6925: <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 6926: <div class="sect2" lang="en">
6927: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 6928: <a name="install-scripts"></a>17.5.1. Creating needed directories</h3></div></div></div>
! 6929: <p>The BSD-compatible <span><strong class="command">install</strong></span> supplied
! 6930: with some operating systems cannot create more than one
! 6931: directory at a time. As such, you should call
! 6932: <code class="literal">${INSTALL_*_DIR}</code> like this:</p>
1.75 rillig 6933: <pre class="programlisting">
1.78 ! rillig 6934: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
! 6935: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
1.75 rillig 6936: </pre>
1.78 ! rillig 6937: <p>You can also just append “<span class="quote"><code class="literal">dir1
! 6938: dir2</code></span>” to the
! 6939: <code class="varname">INSTALLATION_DIRS</code> variable, which will
! 6940: automatically do the right thing.</p>
1.75 rillig 6941: </div>
6942: <div class="sect2" lang="en">
6943: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 6944: <a name="where-to-install-documentation"></a>17.5.2. Where to install documentation</h3></div></div></div>
! 6945: <p>Documentation should be installed into
! 6946: <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
! 6947: <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the latter
! 6948: includes the version number of the package).</p>
1.75 rillig 6949: </div>
6950: <div class="sect2" lang="en">
6951: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 6952: <a name="installing-score-files"></a>17.5.3. Installing score files</h3></div></div></div>
1.75 rillig 6953: <p>Certain packages, most of them in the games category, install
6954: a score file that allows all users on the system to record their
6955: highscores. In order for this to work, the binaries need to be
6956: installed setgid and the score files owned by the appropriate
6957: group and/or owner (traditionally the "games" user/group). The
6958: following variables, documented in more detail in
1.76 rillig 6959: <code class="filename">mk/defaults/mk.conf</code>, control this
1.75 rillig 6960: behaviour: <code class="varname">SETGIDGAME</code>,
6961: <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
6962: <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
6963: <p>Note that per default, setgid installation of games is
6964: disabled; setting <code class="varname">SETGIDGAME=YES</code> will set all
6965: the other variables accordingly.</p>
6966: <p>A package should therefor never hard code file ownership or
6967: access permissions but rely on <code class="varname">INSTALL_GAME</code> and
6968: <code class="varname">INSTALL_GAME_DATA</code> to set these
6969: correctly.</p>
6970: </div>
6971: <div class="sect2" lang="en">
6972: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 6973: <a name="perl-scripts"></a>17.5.4. Packages containing perl scripts</h3></div></div></div>
1.75 rillig 6974: <p>
6975: If your package contains interpreted perl scripts, set
6976: <code class="varname">REPLACE_PERL</code> to ensure that the proper
6977: interpreter path is set. <code class="varname">REPLACE_PERL</code> should
6978: contain a list of scripts, relative to
6979: <code class="varname">WRKSRC</code>, that you want adjusted.</p>
6980: </div>
6981: <div class="sect2" lang="en">
6982: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 6983: <a name="hardcoded-paths"></a>17.5.5. Packages with hardcoded paths to other interpreters</h3></div></div></div>
1.75 rillig 6984: <p>
6985: Your package may also contain scripts with hardcoded paths to
6986: other interpreters besides (or as well as) perl. To correct the
6987: full pathname to the script interpreter, you need to set the
1.76 rillig 6988: following definitions in your <code class="filename">Makefile</code> (we
1.75 rillig 6989: shall use <span><strong class="command">tclsh</strong></span> in this example):</p>
6990: <pre class="programlisting">
6991: REPLACE_INTERPRETER+= tcl
6992: REPLACE.tcl.old= .*/bin/tclsh
6993: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
6994: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
6995: # relative to ${WRKSRC}, just as in REPLACE_PERL
6996: </pre>
6997: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
6998: <h3 class="title">Note</h3>
6999: <p>Before March 2006, these variables were called
7000: <code class="varname">_REPLACE.*</code> and
7001: <code class="varname">_REPLACE_FILES.*</code>.</p>
7002: </div>
7003: </div>
7004: <div class="sect2" lang="en">
7005: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 7006: <a name="perl-modules"></a>17.5.6. Packages installing perl modules</h3></div></div></div>
1.75 rillig 7007: <p>Makefiles of packages providing perl5 modules should include
7008: the Makefile fragment
1.76 rillig 7009: <code class="filename">../../lang/perl5/module.mk</code>. It provides a
1.75 rillig 7010: <span><strong class="command">do-configure</strong></span> target for the standard perl
7011: configuration for such modules as well as various hooks to tune
7012: this configuration. See comments in this file for
7013: details.</p>
7014: <p>Perl5 modules will install into different places depending
7015: on the version of perl used during the build process. To
7016: address this, pkgsrc will append lines to the
1.76 rillig 7017: <code class="filename">PLIST</code> corresponding to the files listed in
7018: the installed <code class="filename">.packlist</code> file generated by
1.75 rillig 7019: most perl5 modules. This is invoked by defining
7020: <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
7021: paths to packlist files, e.g.:</p>
7022: <pre class="programlisting">
7023: PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
7024: </pre>
7025: <p>The variables <code class="varname">PERL5_SITELIB</code>,
7026: <code class="varname">PERL5_SITEARCH</code>, and
7027: <code class="varname">PERL5_ARCHLIB</code> represent the three locations
7028: in which perl5 modules may be installed, and may be used by
7029: perl5 packages that don't have a packlist. These three
7030: variables are also substituted for in the
1.76 rillig 7031: <code class="filename">PLIST</code>.</p>
1.75 rillig 7032: </div>
7033: <div class="sect2" lang="en">
7034: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 7035: <a name="faq.info-files"></a>17.5.7. Packages installing info files</h3></div></div></div>
1.75 rillig 7036: <p>Some packages install info files or use the
7037: “<span class="quote">makeinfo</span>” or “<span class="quote">install-info</span>”
7038: commands. <code class="varname">INFO_FILES</code> should be defined in
1.76 rillig 7039: the package Makefile so that <code class="filename">INSTALL</code> and
7040: <code class="filename">DEINSTALL</code> scripts will be generated to
1.75 rillig 7041: handle registration of the info files in the Info directory
7042: file. The “<span class="quote">install-info</span>” command used for the info
7043: files registration is either provided by the system, or by a
7044: special purpose package automatically added as dependency if
7045: needed.</p>
7046: <p><code class="varname">PKGINFODIR</code> is the directory under
1.76 rillig 7047: <code class="filename">${PREFIX}</code> where info files are primarily
1.75 rillig 7048: located. <code class="varname">PKGINFODIR</code> defaults to
7049: “<span class="quote">info</span>” and can be overridden by the user.</p>
7050: <p>The info files for the package should be listed in the
1.76 rillig 7051: package <code class="filename">PLIST</code>; however any split info files
1.75 rillig 7052: need not be listed.</p>
7053: <p>A package which needs the “<span class="quote">makeinfo</span>” command
7054: at build time must add “<span class="quote">makeinfo</span>” to
7055: <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
7056: version of the “<span class="quote">makeinfo</span>” command is needed it
7057: should be noted with the <code class="varname">TEXINFO_REQD</code>
1.76 rillig 7058: variable in the package <code class="filename">Makefile</code>. By
1.75 rillig 7059: default, a minimum version of 3.12 is required. If the system
7060: does not provide a <span><strong class="command">makeinfo</strong></span> command or if it
7061: does not match the required minimum, a build dependency on the
1.76 rillig 7062: <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 7063: be added automatically.</p>
7064: <p>The build and installation process of the software provided
7065: by the package should not use the
7066: <span><strong class="command">install-info</strong></span> command as the registration of
7067: info files is the task of the package
1.76 rillig 7068: <code class="filename">INSTALL</code> script, and it must use the
1.75 rillig 7069: appropriate <span><strong class="command">makeinfo</strong></span> command.</p>
7070: <p>To achieve this goal, the pkgsrc infrastructure creates
7071: overriding scripts for the <span><strong class="command">install-info</strong></span> and
7072: <span><strong class="command">makeinfo</strong></span> commands in a directory listed early
7073: in <code class="varname">PATH</code>.</p>
7074: <p>The script overriding <span><strong class="command">install-info</strong></span> has
7075: no effect except the logging of a message. The script overriding
7076: <span><strong class="command">makeinfo</strong></span> logs a message and according to the
7077: value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
7078: <span><strong class="command">makeinfo</strong></span> command or exit on error.</p>
7079: </div>
7080: <div class="sect2" lang="en">
7081: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 7082: <a name="manpages"></a>17.5.8. Packages installing man pages</h3></div></div></div>
1.75 rillig 7083: <p>Many packages install manual pages. The man pages
7084: are installed under <code class="varname">${PREFIX}/${PKGMANDIR}</code>
1.76 rillig 7085: which is <code class="filename">/usr/pkg/man</code> by default.
1.75 rillig 7086: <code class="varname">PKGMANDIR</code> defaults to “<span class="quote">man</span>”.
7087: For example, you can set <code class="varname">PKGMANDIR</code> to
7088: “<span class="quote">share/man</span>” to have man pages install under
1.76 rillig 7089: <code class="filename">/usr/pkg/share/man/</code> by default.
1.75 rillig 7090: </p>
7091: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7092: <h3 class="title">Note</h3>
7093: <p>The support for a custom <code class="varname">PKGMANDIR</code>
7094: is not complete.
7095: </p>
7096: </div>
1.76 rillig 7097: <p>The <code class="filename">PLIST</code> files can just
7098: use <code class="filename">man/</code> as the top level directory
1.75 rillig 7099: for the man page file entries
7100: and the pkgsrc framework will convert as needed.
7101: </p>
7102: <p> Packages that are
7103: configured with <code class="varname">GNU_CONFIGURE</code> set as
7104: “<span class="quote">yes</span>”, by default will use the
1.76 rillig 7105: <code class="filename">./configure</code>
1.75 rillig 7106: --mandir switch to set where the man pages should be installed.
7107: The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
7108: to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.
7109: </p>
7110: <p>
7111: Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
7112: use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
7113: to “<span class="quote">no</span>”.
1.76 rillig 7114: Or if the <code class="filename">./configure</code> script uses
1.75 rillig 7115: a non-standard use of --mandir, you can set
7116: <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.
7117: </p>
1.77 rillig 7118: <p>See <a href="#manpage-compression" title="11.5. Man page compression">Section 11.5, “Man page compression”</a> for
1.75 rillig 7119: information on installation of compressed manual pages.
7120: </p>
7121: </div>
7122: <div class="sect2" lang="en">
7123: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 7124: <a name="gconf2-data-files"></a>17.5.9. Packages installing GConf2 data files</h3></div></div></div>
1.75 rillig 7125: <p>
1.76 rillig 7126: If a package installs <code class="filename">.schemas</code> or
7127: <code class="filename">.entries</code> files, used by GConf2,
1.75 rillig 7128: you need to take some extra steps to make sure they get registered
7129: in the database:
7130: </p>
7131: <div class="orderedlist"><ol type="1">
1.76 rillig 7132: <li><p>Include <code class="filename">../../devel/GConf2/schemas.mk</code>
7133: instead of its <code class="filename">buildlink3.mk</code> file. This
1.75 rillig 7134: takes care of rebuilding the GConf2 database at installation and
7135: deinstallation time, and tells the package where to install
7136: GConf2 data files using some standard configure arguments. It
7137: also disallows any access to the database directly from the
7138: package.</p></li>
7139: <li><p>Ensure that the package installs its
1.76 rillig 7140: <code class="filename">.schemas</code> files under
7141: <code class="filename">${PREFIX}/share/gconf/schemas</code>. If they get
7142: installed under <code class="filename">${PREFIX}/etc</code>, you will
1.75 rillig 7143: need to manually patch the package.</p></li>
7144: <li><p>Check the PLIST and remove any entries under the etc/gconf
7145: directory, as they will be handled automatically. See
7146: <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>
7147: <li><p>Define the <code class="varname">GCONF2_SCHEMAS</code> variable in
1.76 rillig 7148: your <code class="filename">Makefile</code> with a list of all
7149: <code class="filename">.schemas</code> files installed by the package, if
1.75 rillig 7150: any. Names must not contain any directories in them.</p></li>
7151: <li><p>Define the <code class="varname">GCONF2_ENTRIES</code> variable in
1.76 rillig 7152: your <code class="filename">Makefile</code> with a
7153: list of all <code class="filename">.entries</code> files installed by the
1.75 rillig 7154: package, if any. Names must not contain any directories in
7155: them.</p></li>
7156: </ol></div>
7157: </div>
7158: <div class="sect2" lang="en">
7159: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 7160: <a name="scrollkeeper-data-files"></a>17.5.10. Packages installing scrollkeeper data files</h3></div></div></div>
1.75 rillig 7161: <p>
1.76 rillig 7162: If a package installs <code class="filename">.omf</code> files, used by
1.75 rillig 7163: scrollkeeper, you need to take some extra steps to make sure they
7164: get registered in the database:
7165: </p>
7166: <div class="orderedlist"><ol type="1">
7167: <li><p>Include
1.76 rillig 7168: <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
7169: instead of its <code class="filename">buildlink3.mk</code> file. This
1.75 rillig 7170: takes care of rebuilding the scrollkeeper database at
7171: installation and deinstallation time, and disallows any access
7172: to it directly from the package.
7173: </p></li>
7174: <li><p>Check the PLIST and remove any entries under the
1.76 rillig 7175: <code class="filename">libdata/scrollkeeper</code> directory, as they
1.75 rillig 7176: will be handled automatically.</p></li>
1.76 rillig 7177: <li><p>Remove the <code class="filename">share/omf</code> directory from
1.75 rillig 7178: the PLIST. It will be handled by scrollkeeper.</p></li>
7179: </ol></div>
7180: </div>
7181: <div class="sect2" lang="en">
7182: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 7183: <a name="x11-fonts"></a>17.5.11. Packages installing X11 fonts</h3></div></div></div>
1.75 rillig 7184: <p>If a package installs font files, you will need to rebuild
7185: the fonts database in the directory where they get installed at
7186: installation and deinstallation time. This can be automatically
7187: done by using the pkginstall framework.</p>
7188: <p>You can list the directories where fonts are installed in the
7189: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
7190: variables, where <em class="replaceable"><code>type</code></em> can be one of
7191: “<span class="quote">ttf</span>”, “<span class="quote">type1</span>” or “<span class="quote">x11</span>”.
7192: Also make sure that the database file
1.76 rillig 7193: <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
1.75 rillig 7194: <p>Note that you should not create new directories for fonts;
7195: instead use the standard ones to avoid that the user needs to
7196: manually configure his X server to find them.</p>
7197: </div>
7198: <div class="sect2" lang="en">
7199: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 7200: <a name="gtk2-modules"></a>17.5.12. Packages installing GTK2 modules</h3></div></div></div>
1.75 rillig 7201: <p>If a package installs GTK2 immodules or loaders, you need to
7202: take some extra steps to get them registered in the GTK2 database
7203: properly:</p>
7204: <div class="orderedlist"><ol type="1">
7205: <li><p>Include
1.76 rillig 7206: <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
7207: <code class="filename">buildlink3.mk</code> file. This takes care of
1.75 rillig 7208: rebuilding the database at installation and deinstallation time.
7209: </p></li>
7210: <li><p>
7211: Set <code class="varname">GTK2_IMMODULES=YES</code> if
7212: your package installs GTK2 immodules.</p></li>
7213: <li><p>
7214: Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
7215: GTK2 loaders.</p></li>
7216: <li>
7217: <p>
7218: Patch the package to not touch any of the GTK2 databases directly.
7219: These are:
7220:
7221: </p>
7222: <div class="itemizedlist"><ul type="disc">
1.76 rillig 7223: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
7224: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
1.75 rillig 7225: </ul></div>
7226: <p>
7227: </p>
7228: </li>
7229: <li><p>
7230: Check the PLIST and remove any entries under the
1.76 rillig 7231: <code class="filename">libdata/gtk-2.0</code> directory, as they will be
1.75 rillig 7232: handled automatically.</p></li>
7233: </ol></div>
7234: </div>
7235: <div class="sect2" lang="en">
7236: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 7237: <a name="sgml-xml-data"></a>17.5.13. Packages installing SGML or XML data</h3></div></div></div>
1.75 rillig 7238: <p>If a package installs SGML or XML data files that need to be
7239: registered in system-wide catalogs (like DTDs, sub-catalogs,
7240: etc.), you need to take some extra steps:
7241: </p>
7242: <div class="orderedlist"><ol type="1">
7243: <li><p>Include
1.76 rillig 7244: <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
7245: your <code class="filename">Makefile</code>, which takes care of
1.75 rillig 7246: registering those files in system-wide catalogs at
7247: installation and deinstallation time.</p></li>
7248: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
7249: any SGML catalogs installed by the package.</p></li>
7250: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
7251: any XML catalogs installed by the package.</p></li>
7252: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
7253: to be added to the SGML catalog. These come in groups of
7254: three strings; see xmlcatmgr(1) for more information
7255: (specifically, arguments recognized by the 'add' action).
7256: Note that you will normally not use this variable.</p></li>
7257: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
7258: to be added to the XML catalog. These come in groups of three
7259: strings; see xmlcatmgr(1) for more information (specifically,
7260: arguments recognized by the 'add' action). Note that you will
7261: normally not use this variable.
7262: </p></li>
7263: </ol></div>
7264: </div>
7265: <div class="sect2" lang="en">
7266: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 7267: <a name="mime-database"></a>17.5.14. Packages installing extensions to the MIME database</h3></div></div></div>
1.75 rillig 7268: <p>If a package provides extensions to the MIME database by
1.76 rillig 7269: installing <code class="filename">.xml</code> files inside
7270: <code class="filename">${PREFIX}/share/mime/packages</code>, you
1.75 rillig 7271: need to take some extra steps to ensure that the database is kept
7272: consistent with respect to these new files:
7273: </p>
7274: <div class="orderedlist"><ol type="1">
7275: <li><p>Include
1.76 rillig 7276: <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
7277: (avoid using the <code class="filename">buildlink3.mk</code> file from
1.75 rillig 7278: this same directory, which is reserved for inclusion from
1.76 rillig 7279: other <code class="filename">buildlink3.mk</code> files). It takes
1.75 rillig 7280: care of rebuilding the MIME database at installation and
7281: deinstallation time, and disallows any access to it directly
7282: from the package.</p></li>
7283: <li><p>Check the PLIST and remove any entries under the
1.76 rillig 7284: <code class="filename">share/mime</code> directory,
1.75 rillig 7285: <span class="emphasis"><em>except</em></span> for files saved under
1.76 rillig 7286: <code class="filename">share/mime/packages</code>. The former are
1.75 rillig 7287: handled automatically by
7288: the update-mime-database program, but the latter are
7289: package-dependent and must be removed by the package that
7290: installed them in the first place.</p></li>
1.76 rillig 7291: <li><p>Remove any <code class="filename">share/mime/*</code> directories
1.75 rillig 7292: from the PLIST. They will be handled by the shared-mime-info
7293: package.</p></li>
7294: </ol></div>
7295: </div>
7296: <div class="sect2" lang="en">
7297: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 7298: <a name="intltool"></a>17.5.15. Packages using intltool</h3></div></div></div>
1.75 rillig 7299: <p>If a package uses intltool during its build, include the
1.76 rillig 7300: <code class="filename">../../textproc/intltool/buildlink3.mk</code> file,
1.75 rillig 7301: which forces it to use the intltool package provided by pkgsrc,
7302: instead of the one bundled with the distribution file.
7303: </p>
7304: <p>This tracks intltool's build-time dependencies and uses the
7305: latest available version; this way, the package benefits of any
7306: bug fixes that may have appeared since it was released.
7307: </p>
7308: </div>
7309: <div class="sect2" lang="en">
7310: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 7311: <a name="startup-scripts"></a>17.5.16. Packages installing startup scripts</h3></div></div></div>
1.75 rillig 7312: <p>If a package contains a rc.d script, it won't be copied into
7313: the startup directory by default, but you can enable it, by adding
7314: the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
1.76 rillig 7315: <code class="filename">/etc/mk.conf</code>. This option will copy the scripts
7316: into <code class="filename">/etc/rc.d</code> when a package is installed, and
1.75 rillig 7317: it will automatically remove the scripts when the package is
7318: deinstalled.</p>
7319: </div>
7320: <div class="sect2" lang="en">
7321: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 7322: <a name="tex-packages"></a>17.5.17. Packages installing TeX modules</h3></div></div></div>
1.75 rillig 7323: <p>If a package installs TeX packages into the texmf tree,
1.76 rillig 7324: the <code class="filename">ls-R</code> database of the tree needs to be
1.75 rillig 7325: updated.</p>
7326: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7327: <h3 class="title">Note</h3>
7328: <p>Except the main TeX packages such as teTeX-texmf,
7329: packages should install files
7330: into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
7331: not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
7332: </div>
7333: <div class="orderedlist"><ol type="1">
7334: <li><p>Include
1.76 rillig 7335: <code class="filename">../../print/teTeX/module.mk</code> instead
7336: of <code class="filename">../../mk/tex.buildlink3.mk</code>. This
7337: takes care of rebuilding the <code class="filename">ls-R</code>
1.75 rillig 7338: database at installation and deinstallation time.</p></li>
7339: <li>
7340: <p>If your package installs files into a texmf
7341: tree other than the one
7342: at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
7343: set <code class="varname">TEXMFDIRS</code> to the list of all texmf
7344: trees that need database update.</p>
7345: <p>If your package also installs font map files that need
7346: to be registered using <span><strong class="command">updmap</strong></span>,
7347: set <code class="varname">TEX_FONTMAPS</code> to the list of all
7348: such font map files. Then <span><strong class="command">updmap</strong></span> will
7349: be run automatically at installation/deinstallation to
7350: enable/disable font map files for TeX output
7351: drivers.</p>
7352: </li>
1.76 rillig 7353: <li><p>Make sure that none of <code class="filename">ls-R</code>
7354: databases are included in <code class="filename">PLIST</code>, as
1.75 rillig 7355: they will be removed only by the teTeX-bin package.</p></li>
7356: </ol></div>
7357: </div>
7358: </div>
7359: <div class="sect1" lang="en">
7360: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 ! rillig 7361: <a name="feedback-to-author"></a>17.6. Feedback to the author</h2></div></div></div>
1.75 rillig 7362: <p>If you have found any bugs in the package you make available,
7363: if you had to do special steps to make it run under NetBSD or
7364: if you enhanced the software in various other ways, be sure
7365: to report these changes back to the original author of the
7366: program! With that kind of support, the next release of the
7367: program can incorporate these fixes, and people not using the
7368: NetBSD packages system can win from your efforts.</p>
7369: <p>Support the idea of free software!</p>
7370: </div>
7371: </div>
7372: <div class="chapter" lang="en">
7373: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7374: <a name="debug"></a>Chapter 18. Debugging</h2></div></div></div>
1.75 rillig 7375: <p>To check out all the gotchas when building a package, here are the steps
7376: that I do in order to get a package working. Please note this is basically
7377: the same as what was explained in the previous sections, only with some
7378: debugging aids.</p>
7379: <div class="itemizedlist"><ul type="disc">
7380: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=1</code>
1.76 rillig 7381: in <code class="filename">/etc/mk.conf</code></p></li>
1.75 rillig 7382: <li>
1.76 rillig 7383: <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 7384: create a directory for a new package, change into it, then run
7385: <span><strong class="command">url2pkg</strong></span>:</p>
7386: <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>
7387: <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>
7388: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
7389: </li>
1.76 rillig 7390: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
7391: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.75 rillig 7392: <li><p>Run <span><strong class="command">make configure</strong></span>
7393: </p></li>
7394: <li><p>Add any dependencies glimpsed from documentation and the
7395: configure step to the package's
1.76 rillig 7396: <code class="filename">Makefile</code>.</p></li>
1.75 rillig 7397: <li>
7398: <p>Make the package compile, doing multiple rounds of</p>
7399: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
7400: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
7401: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
7402: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
7403: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
7404: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
7405: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
7406: <p>Doing as non-root user will ensure that no files are modified that
7407: shouldn't be, especially during the build
7408: phase. <span><strong class="command">mkpatches</strong></span>,
7409: <span><strong class="command">patchdiff</strong></span> and <span><strong class="command">pkgvi</strong></span> are
1.76 rillig 7410: 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 7411: package. </p>
7412: </li>
1.76 rillig 7413: <li><p>Look at the <code class="filename">Makefile</code>, fix if necessary;
1.77 rillig 7414: see <a href="#components.Makefile" title="9.1. Makefile">Section 9.1, “<code class="filename">Makefile</code>”</a>.</p></li>
1.75 rillig 7415: <li>
1.76 rillig 7416: <p>Generate a <code class="filename">PLIST</code>:</p>
1.75 rillig 7417: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
7418: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST >PLIST</code></strong>
7419: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
7420: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
7421: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
1.76 rillig 7422: <p>You usually need to be <code class="username">root</code> to do this.
1.75 rillig 7423: Look if there are any files left:</p>
7424: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
7425: <p>If this reveals any files that are missing in
1.76 rillig 7426: <code class="filename">PLIST</code>, add them.</p>
1.75 rillig 7427: </li>
7428: <li>
1.76 rillig 7429: <p>Now that the <code class="filename">PLIST</code> is OK,
1.75 rillig 7430: install the package again and make a binary package:</p>
7431: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
7432: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
7433: </li>
7434: <li>
7435: <p>Delete the installed package:</p>
7436: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete blub</code></strong></pre>
7437: </li>
7438: <li>
7439: <p>Repeat the above <span><strong class="command">make print-PLIST</strong></span> command,
7440: which shouldn't find anything now:</p>
7441: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
7442: </li>
7443: <li>
7444: <p>Reinstall the binary package:</p>
7445: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkgadd .../blub.tgz</code></strong></pre>
7446: </li>
7447: <li><p>Play with it. Make sure everything works.</p></li>
7448: <li>
7449: <p>Run <span><strong class="command">pkglint</strong></span> from
1.76 rillig 7450: <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 7451: and fix the problems it reports:</p>
7452: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
7453: </li>
7454: <li><p>Submit (or commit, if you have cvs access);
1.77 rillig 7455: see <a href="#submit" title="Chapter 19. Submitting and Committing">Chapter 19, <i>Submitting and Committing</i></a>.</p></li>
1.75 rillig 7456: </ul></div>
7457: </div>
7458: <div class="chapter" lang="en">
7459: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7460: <a name="submit"></a>Chapter 19. Submitting and Committing</h2></div></div></div>
1.75 rillig 7461: <div class="toc">
7462: <p><b>Table of Contents</b></p>
7463: <dl>
1.77 rillig 7464: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
7465: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
7466: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
7467: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
7468: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
7469: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 7470: </dl>
7471: </div>
7472: <div class="sect1" lang="en">
7473: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7474: <a name="submitting-binary-packages"></a>19.1. Submitting binary packages</h2></div></div></div>
1.75 rillig 7475: <p>Our policy is that we accept binaries only from pkgsrc
7476: developers to guarantee that the packages don't contain any
7477: trojan horses etc. This is not to annoy anyone but rather to
7478: protect our users! You're still free to put up your home-made
7479: binary packages and tell the world where to get them. NetBSD
7480: developers doing bulk builds and wanting to upload them please
7481: 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>
7482: </div>
7483: <div class="sect1" lang="en">
7484: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7485: <a name="submitting-your-package"></a>19.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
1.75 rillig 7486: <p>First, check that your package is complete, compiles and
1.77 rillig 7487: runs well; see <a href="#debug" title="Chapter 18. Debugging">Chapter 18, <i>Debugging</i></a> and the rest of this
1.75 rillig 7488: 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>
7489: archive, preferably with all files in a single directory.
7490: Finally, <span><strong class="command">send-pr</strong></span> with category
7491: “<span class="quote">pkg</span>”, a synopsis which includes the package name
7492: and version number, a short description of your package
7493: (contents of the COMMENT variable or DESCR file are OK) and
7494: attach the archive to your PR.</p>
7495: <p>If you want to submit several packages, please send a
7496: separate PR for each one, it's easier for us to track things
7497: that way.</p>
7498: <p>Alternatively, you can also import new packages into
7499: pkgsrc-wip (“<span class="quote">pkgsrc work-in-progress</span>”); see the
7500: homepage at <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
7501: for details.</p>
7502: </div>
7503: <div class="sect1" lang="en">
7504: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7505: <a name="general-notes-for-changes"></a>19.3. General notes when adding, updating, or removing packages</h2></div></div></div>
1.75 rillig 7506: <p>Please note all package additions, updates, moves, and
1.76 rillig 7507: removals in <code class="filename">pkgsrc/doc/CHANGES</code>. It's very
1.75 rillig 7508: important to keep this file up to date and conforming to the
7509: existing format, because it will be used by scripts to
7510: automatically update pages on <a href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
7511: sites. Additionally, check the
1.76 rillig 7512: <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
1.75 rillig 7513: for the package you updated or removed, in case it was mentioned
7514: there.</p>
7515: <p>When the <code class="varname">PKGREVISION</code> of a package is
7516: bumped, the change should appear in
1.76 rillig 7517: <code class="filename">pkgsrc/doc/CHANGES</code> if it is security
1.75 rillig 7518: related or otherwise relevant. Mass bumps that result from a
7519: dependency being updated should not be mentioned. In all other
7520: cases it's the developer's decision.</p>
7521: <p>There is a make target that helps in creating proper
1.76 rillig 7522: <code class="filename">CHANGES</code> entries: <span><strong class="command">make
1.75 rillig 7523: changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
7524: and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
1.76 rillig 7525: usage is to first make sure that your <code class="filename">CHANGES</code>
1.75 rillig 7526: file is up-to-date (to avoid having to resolve conflicts later-on)
7527: and then to <span><strong class="command">cd</strong></span> to the package directory. For
7528: package updates, <span><strong class="command">make changes-entry</strong></span> is enough.
7529: For new packages, or package moves or removals, set the
7530: <code class="varname">CTYPE</code> variable on the command line to "Added",
7531: "Moved", or "Removed". You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.76 rillig 7532: in <code class="filename">/etc/mk.conf</code> if your local login name is
1.75 rillig 7533: not the same as your NetBSD login name. Don't forget to commit
1.76 rillig 7534: the changes to <code class="filename">pkgsrc/doc/CHANGES</code>!</p>
1.75 rillig 7535: </div>
7536: <div class="sect1" lang="en">
7537: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7538: <a name="committing-importing"></a>19.4. Committing: Importing a package into CVS</h2></div></div></div>
1.75 rillig 7539: <p>
7540: This section is only of interest for pkgsrc developers with write
7541: access to the pkgsrc repository. Please remember that cvs
7542: imports files relative to the current working directory, and that
7543: the pathname that you
7544: give the <span><strong class="command">cvs import</strong></span> command is so that it knows where
7545: to place the files in the repository. Newly created packages should be
7546: imported with a vendor tag of “<span class="quote">TNF</span>” and a release tag of
7547: “<span class="quote">pkgsrc-base</span>”, e.g:
7548: </p>
7549: <pre class="programlisting">
7550: <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
7551: <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
7552: </pre>
7553: <p>
7554: Remember to move the directory from which you imported out of
7555: the way, or cvs will complain the next time you “<span class="quote">cvs
7556: update</span>” your source tree. Also don't forget to add the new
1.76 rillig 7557: package to the category's <code class="filename">Makefile</code>.
1.75 rillig 7558: </p>
7559: <p>
7560: The commit message of the initial import should include part of the
1.76 rillig 7561: <code class="filename">DESCR</code> file, so people reading the mailing lists know
1.75 rillig 7562: what the package is/does.
7563: </p>
7564: <p>
7565: For new packages, “<span class="quote">cvs import</span>” is preferred to “<span class="quote">cvs
7566: add</span>” because the former gets everything with a single command,
7567: and provides a consistent tag.
7568: </p>
7569: </div>
7570: <div class="sect1" lang="en">
7571: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7572: <a name="updating-package"></a>19.5. Updating a package to a newer version</h2></div></div></div>
1.75 rillig 7573: <p>
7574: Please always put a concise, appropriate and relevant summary of the
7575: changes between old and new versions into the commit log when updating
7576: a package. There are various reasons for this:
7577: </p>
7578: <div class="itemizedlist"><ul type="disc">
7579: <li><p>
7580: A URL is volatile, and can change over time. It may go away completely
7581: or its information may be overwritten by newer information.
7582: </p></li>
7583: <li><p>
7584: Having the change information between old and new versions in our CVS
7585: repository is very useful for people who use either cvs or anoncvs.
7586: </p></li>
7587: <li><p>
7588: Having the change information between old and new versions in our CVS
7589: repository is very useful for people who read the pkgsrc-changes mailing
7590: list, so that they can make tactical decisions about when to upgrade
7591: the package.
7592: </p></li>
7593: </ul></div>
7594: <p>
7595: Please also recognize that, just because a new version of a package
7596: has been released, it should not automatically be upgraded in the CVS
7597: repository. We prefer to be conservative in the packages that are
7598: included in pkgsrc - development or beta packages are not really the
7599: best thing for most places in which pkgsrc is used. Please use your
7600: judgement about what should go into pkgsrc, and bear in mind that
7601: stability is to be preferred above new and possibly untested features.
7602: </p>
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="moving-package"></a>19.6. Moving a package in pkgsrc</h2></div></div></div>
1.75 rillig 7607: <div class="orderedlist"><ol type="1">
7608: <li><p>Make a copy of the directory somewhere else.</p></li>
7609: <li>
7610: <p>Remove all CVS dirs.</p>
7611: <p>
7612: Alternatively to the first two steps you can also do:
7613: </p>
7614: <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>
7615: <p>
7616: and use that for further work.
7617: </p>
7618: </li>
7619: <li><p>Fix <code class="varname">CATEGORIES</code> and any
7620: <code class="varname">DEPENDS</code> paths that just did “<span class="quote">../package</span>”
7621: instead of “<span class="quote">../../category/package</span>”.</p></li>
7622: <li><p><span><strong class="command">cvs import</strong></span> the modified package in the new
7623: place.</p></li>
7624: <li>
7625: <p>Check if any package depends on it:
7626: </p>
7627: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
7628: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
7629: <p>
7630: </p>
7631: </li>
7632: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
7633: <li><p><span><strong class="command">cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.76 rillig 7634: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
7635: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
1.75 rillig 7636: <li>
7637: <p>Commit the changed and removed files:</p>
7638: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong></pre>
7639: <p>
7640: (and any packages from step 5, of course).
7641: </p>
7642: </li>
7643: </ol></div>
7644: </div>
7645: </div>
7646: <div class="chapter" lang="en">
7647: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7648: <a name="devfaq"></a>Chapter 20. Frequently Asked Questions</h2></div></div></div>
1.75 rillig 7649: <p>This section contains the answers to questions that may
7650: arise when you are writing a package. If you don't find your
7651: question answered here, first have a look in the other chapters,
7652: and if you still don't have the answer, ask on the
7653: <code class="literal">pkgsrc-users</code> mailing list.</p>
7654: <div class="qandaset">
7655: <dl>
1.78 ! rillig 7656: <dt>20.1. <a href="#id2654827">What is the difference between
1.75 rillig 7657: MAKEFLAGS, .MAKEFLAGS and
7658: MAKE_FLAGS?</a>
7659: </dt>
1.78 ! rillig 7660: <dt>20.2. <a href="#id2654864">What is the difference between
1.75 rillig 7661: MAKE, GMAKE and
7662: MAKE_PROGRAM?</a>
7663: </dt>
1.78 ! rillig 7664: <dt>20.3. <a href="#id2654902">What is the difference between
1.75 rillig 7665: CC, PKG_CC and
7666: PKGSRC_COMPILER?</a>
7667: </dt>
1.78 ! rillig 7668: <dt>20.4. <a href="#id2654939">What is the difference between
1.75 rillig 7669: BUILDLINK_LDFLAGS,
7670: BUILDLINK_LDADD and
7671: BUILDLINK_LIBS?</a>
7672: </dt>
1.78 ! rillig 7673: <dt>20.5. <a href="#id2654957">Why does make show-var
1.75 rillig 7674: VARNAME=BUILDLINK_PREFIX.foo
7675: say it's empty?</a>
7676: </dt>
1.78 ! rillig 7677: <dt>20.6. <a href="#id2655053">What does
! 7678: ${MASTER_SITE_SOURCEFORGE:=package/} mean? I
! 7679: don't understand the := inside
! 7680: it.</a>
! 7681: </dt>
! 7682: <dt>20.7. <a href="#id2655128">Which mailing lists are there for package
! 7683: developers?</a>
! 7684: </dt>
1.75 rillig 7685: </dl>
7686: <table border="0" summary="Q and A Set">
7687: <col align="left" width="1%">
7688: <tbody>
7689: <tr class="question">
7690: <td align="left" valign="top">
1.78 ! rillig 7691: <a name="id2654827"></a><a name="id2654828"></a><b>20.1.</b>
1.75 rillig 7692: </td>
7693: <td align="left" valign="top"><p>What is the difference between
7694: <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
7695: <code class="varname">MAKE_FLAGS</code>?</p></td>
7696: </tr>
7697: <tr class="answer">
7698: <td align="left" valign="top"><b></b></td>
7699: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
7700: 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
7701: <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
7702: the <code class="varname">MAKE_PROGRAM</code> when building the
7703: package. [FIXME: What is .MAKEFLAGS for?]</p></td>
7704: </tr>
7705: <tr class="question">
7706: <td align="left" valign="top">
1.78 ! rillig 7707: <a name="id2654864"></a><a name="id2654865"></a><b>20.2.</b>
1.75 rillig 7708: </td>
7709: <td align="left" valign="top"><p>What is the difference between
7710: <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
7711: <code class="varname">MAKE_PROGRAM</code>?</p></td>
7712: </tr>
7713: <tr class="answer">
7714: <td align="left" valign="top"><b></b></td>
7715: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
7716: <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
7717: infrastructure. <code class="varname">GMAKE</code> is the path to GNU
7718: Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
7719: use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
7720: Make program that is used for building the
7721: package.</p></td>
7722: </tr>
7723: <tr class="question">
7724: <td align="left" valign="top">
1.78 ! rillig 7725: <a name="id2654902"></a><a name="id2654903"></a><b>20.3.</b>
1.75 rillig 7726: </td>
7727: <td align="left" valign="top"><p>What is the difference between
7728: <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
7729: <code class="varname">PKGSRC_COMPILER</code>?</p></td>
7730: </tr>
7731: <tr class="answer">
7732: <td align="left" valign="top"><b></b></td>
7733: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
7734: compiler, which can be configured by the pkgsrc user.
7735: <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
7736: <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
7737: path to a compiler, but the type of compiler that should be
1.76 rillig 7738: used. See <code class="filename">mk/compiler.mk</code> for more
1.75 rillig 7739: information about the latter variable.</p></td>
7740: </tr>
7741: <tr class="question">
7742: <td align="left" valign="top">
1.78 ! rillig 7743: <a name="id2654939"></a><a name="id2654940"></a><b>20.4.</b>
1.75 rillig 7744: </td>
7745: <td align="left" valign="top"><p>What is the difference between
7746: <code class="varname">BUILDLINK_LDFLAGS</code>,
7747: <code class="varname">BUILDLINK_LDADD</code> and
7748: <code class="varname">BUILDLINK_LIBS</code>?</p></td>
7749: </tr>
7750: <tr class="answer">
7751: <td align="left" valign="top"><b></b></td>
7752: <td align="left" valign="top"><p>[FIXME]</p></td>
7753: </tr>
7754: <tr class="question">
7755: <td align="left" valign="top">
1.78 ! rillig 7756: <a name="id2654957"></a><a name="id2655027"></a><b>20.5.</b>
1.75 rillig 7757: </td>
7758: <td align="left" valign="top"><p>Why does <span><strong class="command">make show-var
7759: VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
7760: say it's empty?</p></td>
7761: </tr>
7762: <tr class="answer">
7763: <td align="left" valign="top"><b></b></td>
7764: <td align="left" valign="top"><p>For optimization reasons, some variables are only
7765: available in the “<span class="quote">wrapper</span>” phase and later. To
7766: “<span class="quote">simulate</span>” the wrapper phase, append
7767: <span><strong class="command">PKG_PHASE=wrapper</strong></span> to the above
7768: command.</p></td>
7769: </tr>
1.78 ! rillig 7770: <tr class="question">
! 7771: <td align="left" valign="top">
! 7772: <a name="id2655053"></a><a name="id2655054"></a><b>20.6.</b>
! 7773: </td>
! 7774: <td align="left" valign="top"><p>What does
! 7775: <code class="literal">${MASTER_SITE_SOURCEFORGE:=package/}</code> mean? I
! 7776: don't understand the <code class="literal">:=</code> inside
! 7777: it.</p></td>
! 7778: </tr>
! 7779: <tr class="answer">
! 7780: <td align="left" valign="top"><b></b></td>
! 7781: <td align="left" valign="top"><p>The <code class="literal">:=</code> is not really an
! 7782: assignment operator, like you might expect at first sight.
! 7783: Instead, it is a degenerate form of
! 7784: <code class="literal">${LIST:<em class="replaceable"><code>old_string</code></em>=<em class="replaceable"><code>new_string</code></em>}</code>,
! 7785: 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
! 7786: may have seen as in <code class="literal">${SRCS:.c=.o}</code>. In the
! 7787: case of <code class="varname">MASTER_SITE_*</code>,
! 7788: <em class="replaceable"><code>old_string</code></em> is the empty string and
! 7789: <em class="replaceable"><code>new_string</code></em> is
! 7790: <code class="literal">package/</code>. That's where the
! 7791: <code class="literal">:</code> and the <code class="literal">=</code> fall
! 7792: together.</p></td>
! 7793: </tr>
! 7794: <tr class="question">
! 7795: <td align="left" valign="top">
! 7796: <a name="id2655128"></a><a name="id2655129"></a><b>20.7.</b>
! 7797: </td>
! 7798: <td align="left" valign="top"><p>Which mailing lists are there for package
! 7799: developers?</p></td>
! 7800: </tr>
! 7801: <tr class="answer">
! 7802: <td align="left" valign="top"><b></b></td>
! 7803: <td align="left" valign="top"><div class="variablelist"><dl>
! 7804: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">tech-pkg</a></span></dt>
! 7805: <dd><p>This is a list for technical discussions related
! 7806: to pkgsrc development, e.g. soliciting feedback for changes to
! 7807: pkgsrc infrastructure, proposed new features, questions related
! 7808: to porting pkgsrc to a new platform, advice for maintaining a
! 7809: package, patches that affect many packages, help requests moved
! 7810: from pkgsrc-users when an infrastructure bug is found,
! 7811: etc.</p></dd>
! 7812: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a></span></dt>
! 7813: <dd><p>All bug reports in category "pkg" sent with
! 7814: <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
! 7815: directly; use one of the other mailing
! 7816: lists.</p></dd>
! 7817: </dl></div></td>
! 7818: </tr>
1.75 rillig 7819: </tbody>
7820: </table>
7821: </div>
7822: </div>
7823: </div>
7824: <div class="part" lang="en">
7825: <div class="titlepage"><div><div><h1 class="title">
7826: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
7827: <div class="partintro" lang="en">
7828: <div></div>
7829: <p>This part of the guide deals with everything
7830: from the infrastructure that is behind the interfaces described
7831: in the developer's guide. A casual package maintainer should not
7832: need anything from this part.</p>
7833: <div class="toc">
7834: <p><b>Table of Contents</b></p>
7835: <dl>
1.77 rillig 7836: <dt><span class="chapter"><a href="#infr.design">21. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 7837: <dd><dl>
1.77 rillig 7838: <dt><span class="sect1"><a href="#infr.var">21.1. Variable evaluation</a></span></dt>
1.75 rillig 7839: <dd><dl>
1.77 rillig 7840: <dt><span class="sect2"><a href="#infr.var.load">21.1.1. At load time</a></span></dt>
7841: <dt><span class="sect2"><a href="#infr.var.run">21.1.2. At runtime</a></span></dt>
1.75 rillig 7842: </dl></dd>
1.78 ! rillig 7843: <dt><span class="sect1"><a href="#infr.varspec">21.2. How can variables be specified?</a></span></dt>
! 7844: <dt><span class="sect1"><a href="#infr.design.intf">21.3. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 7845: <dd><dl>
1.78 ! rillig 7846: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.3.1. Procedures with parameters</a></span></dt>
! 7847: <dt><span class="sect2"><a href="#infr.design.intf.action">21.3.2. Actions taken on behalf of parameters</a></span></dt>
1.75 rillig 7848: </dl></dd>
7849: </dl></dd>
1.77 rillig 7850: <dt><span class="chapter"><a href="#regression">22. Regression tests</a></span></dt>
1.75 rillig 7851: <dd><dl>
1.77 rillig 7852: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
7853: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
7854: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 7855: <dd><dl>
1.77 rillig 7856: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
7857: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 7858: </dl></dd>
7859: </dl></dd>
1.77 rillig 7860: <dt><span class="chapter"><a href="#porting">23. Porting pkgsrc</a></span></dt>
1.75 rillig 7861: <dd><dl>
1.77 rillig 7862: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
7863: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 7864: </dl></dd>
7865: </dl>
7866: </div>
7867: </div>
7868: <div class="chapter" lang="en">
7869: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7870: <a name="infr.design"></a>Chapter 21. Design of the pkgsrc infrastructure</h2></div></div></div>
1.75 rillig 7871: <div class="toc">
7872: <p><b>Table of Contents</b></p>
7873: <dl>
1.77 rillig 7874: <dt><span class="sect1"><a href="#infr.var">21.1. Variable evaluation</a></span></dt>
1.75 rillig 7875: <dd><dl>
1.77 rillig 7876: <dt><span class="sect2"><a href="#infr.var.load">21.1.1. At load time</a></span></dt>
7877: <dt><span class="sect2"><a href="#infr.var.run">21.1.2. At runtime</a></span></dt>
1.75 rillig 7878: </dl></dd>
1.78 ! rillig 7879: <dt><span class="sect1"><a href="#infr.varspec">21.2. How can variables be specified?</a></span></dt>
! 7880: <dt><span class="sect1"><a href="#infr.design.intf">21.3. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 7881: <dd><dl>
1.78 ! rillig 7882: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.3.1. Procedures with parameters</a></span></dt>
! 7883: <dt><span class="sect2"><a href="#infr.design.intf.action">21.3.2. Actions taken on behalf of parameters</a></span></dt>
1.75 rillig 7884: </dl></dd>
7885: </dl>
7886: </div>
7887: <p>The pkgsrc infrastructure consists of many small Makefile
7888: fragments. Each such fragment needs a properly specified
7889: interface. This chapter explains how such an interface looks
7890: like.</p>
7891: <div class="sect1" lang="en">
7892: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7893: <a name="infr.var"></a>21.1. Variable evaluation</h2></div></div></div>
1.75 rillig 7894: <div class="sect2" lang="en">
7895: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7896: <a name="infr.var.load"></a>21.1.1. At load time</h3></div></div></div>
1.75 rillig 7897: <p>Variable evaluation takes place either at load time or at
7898: runtime, depending on the context in which they occur. The
7899: contexts where variables are evaluated at load time are:</p>
7900: <div class="itemizedlist"><ul type="disc">
7901: <li><p>The right hand side of the <code class="literal">:=</code>
7902: and <code class="literal">!=</code> operators,</p></li>
7903: <li><p>Make directives like <code class="literal">.if</code> or
7904: <code class="literal">.for</code>,</p></li>
7905: <li><p>Dependency lines.</p></li>
7906: </ul></div>
7907: <p>A special exception are references to the iteration
7908: variables of <code class="literal">.for</code> loops, which are expanded
7909: inline, no matter in which context they appear.</p>
7910: <p>As the values of variables may change during load time,
7911: care must be taken not to evaluate them by accident. Typical
7912: examples for variables that should not be evaluated at load time
7913: are <code class="varname">DEPENDS</code> and
7914: <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
7915: clear, here is an example:</p>
7916: <pre class="programlisting">
7917: CONFIGURE_ARGS= # none
7918: CFLAGS= -O
7919: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
1.1 grant 7920:
1.75 rillig 7921: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
1.1 grant 7922:
1.75 rillig 7923: CFLAGS+= -Wall
7924: </pre>
7925: <p>This code shows how the use of the <code class="literal">:=</code>
7926: operator can quickly lead to unexpected results. The first
7927: paragraph is fairly common code. The second paragraph evaluates
7928: the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
7929: <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
7930: <code class="literal">-Wall</code> is appended to the
7931: <code class="varname">CFLAGS</code>, but this addition will not appear in
7932: <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
7933: paragraphs from above typically occur in completely unrelated
7934: files.</p>
7935: </div>
7936: <div class="sect2" lang="en">
7937: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7938: <a name="infr.var.run"></a>21.1.2. At runtime</h3></div></div></div>
1.75 rillig 7939: <p>After all the files have been loaded, the values of the
7940: variables cannot be changed anymore. Variables that are used in
7941: the shell commands are expanded at this point.</p>
7942: </div>
7943: </div>
7944: <div class="sect1" lang="en">
7945: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 ! rillig 7946: <a name="infr.varspec"></a>21.2. How can variables be specified?</h2></div></div></div>
! 7947: <p>There are many ways in which the definition and use of a
! 7948: variable can be restricted in order to detect bugs and
! 7949: violations of the (mostly unwritten) policies. See the
! 7950: <code class="literal">pkglint</code> developer's documentation for further
! 7951: details.</p>
! 7952: </div>
! 7953: <div class="sect1" lang="en">
! 7954: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 7955: <a name="infr.design.intf"></a>21.3. Designing interfaces for Makefile fragments</h2></div></div></div>
1.76 rillig 7956: <p>Most of the <code class="filename">.mk</code> files fall into one
1.75 rillig 7957: of the following classes. Cases where a file falls into more
7958: than one class should be avoided as it often leads to subtle
7959: bugs.</p>
7960: <div class="sect2" lang="en">
7961: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 7962: <a name="infr.design.intf.proc"></a>21.3.1. Procedures with parameters</h3></div></div></div>
1.75 rillig 7963: <p>In a traditional imperative programming language some of
1.76 rillig 7964: the <code class="filename">.mk</code> files could be described as
1.78 ! rillig 7965: procedures. They take some input parameters and—after
! 7966: inclusion—provide a result in output parameters. Since all
1.76 rillig 7967: variables in <code class="filename">Makefile</code>s have global scope
1.75 rillig 7968: care must be taken not to use parameter names that have already
7969: another meaning. For example, <code class="varname">PKGNAME</code> is a
7970: bad choice for a parameter name.</p>
7971: <p>Procedures are completely evaluated at preprocessing time.
7972: That is, when calling a procedure all input parameters must be
7973: completely resolvable. For example,
7974: <code class="varname">CONFIGURE_ARGS</code> should never be an input
7975: parameter since it is very likely that further text will be
7976: added after calling the procedure, which would effectively apply
7977: the procedure to only a part of the variable. Also, references
7978: to other variables wit will be modified after calling the
7979: procedure.</p>
7980: <p>A procedure can declare its output parameters either as
7981: suitable for use in preprocessing directives or as only
7982: available at runtime. The latter alternative is for variables
7983: that contain references to other runtime variables.</p>
7984: <p>Procedures shall be written such that it is possible to
7985: call the procedure more than once. That is, the file must not
7986: contain multiple-inclusion guards.</p>
7987: <p>Examples for procedures are
1.76 rillig 7988: <code class="filename">mk/bsd.options.mk</code> and
7989: <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
1.75 rillig 7990: that the parameters are evaluated at load time, they should be
7991: assigned using the <code class="literal">:=</code> operator, which should
7992: be used only for this purpose.</p>
7993: </div>
7994: <div class="sect2" lang="en">
7995: <div class="titlepage"><div><div><h3 class="title">
1.78 ! rillig 7996: <a name="infr.design.intf.action"></a>21.3.2. Actions taken on behalf of parameters</h3></div></div></div>
1.75 rillig 7997: <p>Action files take some input parameters and may define
7998: runtime variables. They shall not define loadtime variables.
7999: There are action files that are included implicitly by the
8000: pkgsrc infrastructure, while other must be included
8001: explicitly.</p>
8002: <p>An example for action files is
1.76 rillig 8003: <code class="filename">mk/subst.mk</code>.</p>
1.75 rillig 8004: </div>
8005: </div>
8006: </div>
8007: <div class="chapter" lang="en">
8008: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8009: <a name="regression"></a>Chapter 22. Regression tests</h2></div></div></div>
1.75 rillig 8010: <div class="toc">
8011: <p><b>Table of Contents</b></p>
8012: <dl>
1.77 rillig 8013: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
8014: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
8015: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 8016: <dd><dl>
1.77 rillig 8017: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
8018: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 8019: </dl></dd>
8020: </dl>
8021: </div>
8022: <p>The pkgsrc infrastructure consists of a large codebase,
8023: and there are many corners where every little bit of a file is
8024: well thought out, making pkgsrc likely to fail as soon as
8025: anything is changed near those parts. To prevent most changes
8026: from breaking anything, a suite of regression tests should go
8027: along with every important part of the pkgsrc infrastructure.
8028: This chapter describes how regression tests work in pkgsrc and
8029: how you can add new tests.</p>
8030: <div class="sect1" lang="en">
8031: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8032: <a name="regression.descr"></a>22.1. The regression tests framework</h2></div></div></div>
1.75 rillig 8033: <p></p>
8034: </div>
8035: <div class="sect1" lang="en">
8036: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8037: <a name="regression.run"></a>22.2. Running the regression tests</h2></div></div></div>
1.76 rillig 8038: <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 8039: provides the <span><strong class="command">pkg_regress</strong></span> command. Then you
8040: can simply run that command, which will run all tests in the
1.76 rillig 8041: <code class="filename">regress</code> category.</p>
1.75 rillig 8042: </div>
8043: <div class="sect1" lang="en">
8044: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8045: <a name="regression.new"></a>22.3. Adding a new regression test</h2></div></div></div>
1.76 rillig 8046: <p>Every directory in the <code class="filename">regress</code>
8047: category that contains a file called <code class="filename">spec</code>
1.75 rillig 8048: is considered a regression test. This file is a shell program
8049: that is included by the <span><strong class="command">pkg_regress</strong></span> command.
8050: The following functions can be overridden to suit your
8051: needs.</p>
8052: <div class="sect2" lang="en">
8053: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 8054: <a name="regression.fun.override"></a>22.3.1. Overridable functions</h3></div></div></div>
1.75 rillig 8055: <p>These functions do not take any parameters. They are all
8056: called in “<span class="quote">set -e</span>” mode, so you should be careful
8057: to check the exitcodes of any commands you run in the
8058: test.</p>
8059: <div class="variablelist"><dl>
8060: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
8061: <dd><p>This function prepares the environment for the
8062: test. By default it does nothing.</p></dd>
8063: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
8064: <dd><p>This function runs the actual test. By default,
8065: it calls <code class="varname">TEST_MAKE</code> with the arguments
8066: <code class="varname">MAKEARGS_TEST</code> and writes its output including
8067: error messages into the file
8068: <code class="varname">TEST_OUTFILE</code>.</p></dd>
8069: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
8070: <dd><p>This function is run after the test and is
8071: typically used to compare the actual output from the one that is
8072: expected. It can make use of the various helper functions from
8073: the next section.</p></dd>
8074: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
8075: <dd><p>This function cleans everything up after the
8076: test has been run. By default it does nothing.</p></dd>
8077: </dl></div>
8078: </div>
8079: <div class="sect2" lang="en">
8080: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 8081: <a name="regression.fun.helper"></a>22.3.2. Helper functions</h3></div></div></div>
1.75 rillig 8082: <div class="variablelist"><dl>
8083: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
8084: <dd><p>This function compares the exitcode of the
8085: <span><strong class="command">do_test()</strong></span> function with its first parameter.
8086: If they differ, the test will fail.</p></dd>
8087: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
8088: <dd><p>This function checks for each of its parameters
8089: if the output from <span><strong class="command">do_test()</strong></span> matches the
8090: extended regular expression. If it does not, the test will
8091: fail.</p></dd>
8092: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
8093: <dd><p>This function checks for each of its parameters
8094: if the output from <span><strong class="command">do_test()</strong></span> does
8095: <span class="emphasis"><em>not</em></span> match the extended regular expression.
8096: If any of the regular expressions matches, the test will
8097: fail.</p></dd>
8098: </dl></div>
8099: </div>
8100: </div>
8101: </div>
8102: <div class="chapter" lang="en">
8103: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8104: <a name="porting"></a>Chapter 23. Porting pkgsrc</h2></div></div></div>
1.75 rillig 8105: <div class="toc">
8106: <p><b>Table of Contents</b></p>
8107: <dl>
1.77 rillig 8108: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
8109: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 8110: </dl>
8111: </div>
8112: <p>The pkgsrc system has already been ported to many
8113: operating systems, hardware architectures and compilers. This
8114: chapter explains the necessary steps to make pkgsrc even more
8115: portable.</p>
8116: <div class="sect1" lang="en">
8117: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8118: <a name="porting.opsys"></a>23.1. Porting pkgsrc to a new operating system</h2></div></div></div>
1.75 rillig 8119: <p>To port pkgsrc to a new operating system (called
8120: <code class="literal">MyOS</code> in this example), you need to touch the
8121: following files:</p>
8122: <div class="variablelist"><dl>
1.76 rillig 8123: <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 8124: <dd><p>This file contains some basic definitions, for
8125: example the name of the C
8126: compiler.</p></dd>
1.76 rillig 8127: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
1.75 rillig 8128: <dd><p>Insert code that defines the variables
8129: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
8130: <code class="varname">LOWER_OS_VERSION</code>,
8131: <code class="varname">LOWER_VENDOR</code>,
8132: <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
8133: <code class="varname">APPEND_ELF</code>, and the other variables that
8134: appear in this file.</p></dd>
1.76 rillig 8135: <dt><span class="term"><code class="filename">mk/platform/MyOS.mk</code></span></dt>
1.75 rillig 8136: <dd><p>This file contains the platform-specific
8137: definitions that are used by pkgsrc. Start by copying one of the
8138: other files and edit it to your
8139: needs.</p></dd>
1.76 rillig 8140: <dt><span class="term"><code class="filename">mk/platform/MyOS.pkg.dist</code></span></dt>
1.75 rillig 8141: <dd><p>This file contains a list of directories,
8142: together with their permission bits and ownership. These
8143: directories will be created automatically with every package
8144: that does not explicitly set <code class="varname">NO_MTREE</code>. There
8145: have been some discussions about whether this file is needed at
8146: all, but with no result.</p></dd>
1.76 rillig 8147: <dt><span class="term"><code class="filename">mk/platform/MyOS.x11.dist</code></span></dt>
1.75 rillig 8148: <dd><p>Just copy one of the pre-existing x11.dist files
8149: to your
1.76 rillig 8150: <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
8151: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
1.75 rillig 8152: <dd><p>On some operating systems, the tools that are
8153: provided with the base system are not good enough for pkgsrc.
8154: 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
8155: narrow limit on the line length they can process. Therefore
8156: pkgsrc brings its own tools, which can be enabled
8157: here.</p></dd>
1.76 rillig 8158: <dt><span class="term"><code class="filename">mk/tools/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
1.75 rillig 8159: <dd><p>This file defines the paths to all the tools
8160: that are needed by one or the other package in pkgsrc, as well
8161: as by pkgsrc itself. Find out where these tools are on your
8162: platform and add them.</p></dd>
8163: </dl></div>
8164: <p>Now, you should be able to build some basic packages, like
1.76 rillig 8165: <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 8166: </div>
8167: <div class="sect1" lang="en">
8168: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8169: <a name="porting.compiler"></a>23.2. Adding support for a new compiler</h2></div></div></div>
1.75 rillig 8170: <p>TODO</p>
8171: </div>
8172: </div>
8173: </div>
8174: <div class="appendix" lang="en">
8175: <div class="titlepage"><div><div><h2 class="title">
8176: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
8177: <div class="toc">
8178: <p><b>Table of Contents</b></p>
8179: <dl>
8180: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
8181: <dd><dl>
8182: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
8183: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
8184: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
8185: <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>
8186: </dl></dd>
8187: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
8188: </dl>
8189: </div>
8190: <p>We checked to find a piece of software that wasn't in the packages
8191: collection, and picked GNU bison. Quite why someone would want to have
8192: <span><strong class="command">bison</strong></span> when Berkeley <span><strong class="command">yacc</strong></span> is already
8193: present in the tree is beyond us, but it's useful for the purposes of
8194: this exercise.</p>
8195: <div class="sect1" lang="en">
8196: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8197: <a name="example-files"></a>A.1. files</h2></div></div></div>
8198: <div class="sect2" lang="en">
8199: <div class="titlepage"><div><div><h3 class="title">
8200: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
8201: <pre class="programlisting">
1.51 rillig 8202: # $NetBSD$
8203: #
1.1 grant 8204:
1.51 rillig 8205: DISTNAME= bison-1.25
8206: CATEGORIES= devel
8207: MASTER_SITES= ${MASTER_SITE_GNU}
1.1 grant 8208:
1.51 rillig 8209: MAINTAINER= thorpej@NetBSD.org
8210: HOMEPAGE= http://www.gnu.org/software/bison/bison.html
8211: COMMENT= GNU yacc clone
1.1 grant 8212:
1.51 rillig 8213: GNU_CONFIGURE= yes
8214: INFO_FILES= bison.info
1.1 grant 8215:
1.51 rillig 8216: .include "../../mk/bsd.pkg.mk"
1.1 grant 8217: </pre>
1.75 rillig 8218: </div>
8219: <div class="sect2" lang="en">
8220: <div class="titlepage"><div><div><h3 class="title">
8221: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
8222: <pre class="programlisting">
1.51 rillig 8223: GNU version of yacc. Can make re-entrant parsers, and numerous other
1.75 rillig 8224: 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 8225: of the NetBSD source tree is beyond me.
1.1 grant 8226: </pre>
1.75 rillig 8227: </div>
8228: <div class="sect2" lang="en">
8229: <div class="titlepage"><div><div><h3 class="title">
8230: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
8231: <pre class="programlisting">
1.51 rillig 8232: @comment $NetBSD$
8233: bin/bison
8234: man/man1/bison.1.gz
8235: share/bison.simple
8236: share/bison.hairy
1.1 grant 8237: </pre>
1.75 rillig 8238: </div>
8239: <div class="sect2" lang="en">
8240: <div class="titlepage"><div><div><h3 class="title">
8241: <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>
8242: <p>The NetBSD package system comes with
1.76 rillig 8243: <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 8244: which helps to check the contents of these
8245: files. After installation it is quite easy to use, just change to the
8246: directory of the package you wish to examine and execute
8247: <span><strong class="command">pkglint</strong></span>:</p>
8248: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
8249: looks fine.</pre>
8250: <p>Depending on the supplied command line arguments (see pkglint(1)),
8251: more checks will be performed. Use e.g. <span><strong class="command">pkglint -Call
8252: -Wall</strong></span> for a very thorough check.</p>
8253: </div>
8254: </div>
8255: <div class="sect1" lang="en">
8256: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8257: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
8258: <p>Create the directory where the package lives,
8259: plus any auxiliary directories:</p>
8260: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
8261: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
8262: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
8263: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
1.76 rillig 8264: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.77 rillig 8265: <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 8266: then continue with fetching the distfile:</p>
8267: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
1.1 grant 8268: >> bison-1.25.tar.gz doesn't seem to exist on this system.
8269: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
8270: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8271: ftp: Error retrieving file: 500 Internal error
8272:
8273: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
8274: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8275: ftp: Error retrieving file: 500 Internal error
8276:
8277: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
8278: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
1.75 rillig 8279: Successfully retrieved file.</pre>
8280: <p>Generate the checksum of the distfile into
1.76 rillig 8281: <code class="filename">distinfo</code>:</p>
1.75 rillig 8282: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makesum</code></strong></pre>
8283: <p>Now compile:</p>
8284: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 8285: >> Checksum OK for bison-1.25.tar.gz.
8286: ===> Extracting for bison-1.25
8287: ===> Patching for bison-1.25
8288: ===> Ignoring empty patch directory
8289: ===> Configuring for bison-1.25
8290: creating cache ./config.cache
8291: checking for gcc... cc
8292: checking whether we are using GNU C... yes
8293: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
8294: checking how to run the C preprocessor... cc -E
8295: checking for minix/config.h... no
8296: checking for POSIXized ISC... no
8297: checking whether cross-compiling... no
8298: checking for ANSI C header files... yes
8299: checking for string.h... yes
8300: checking for stdlib.h... yes
8301: checking for memory.h... yes
8302: checking for working const... yes
8303: checking for working alloca.h... no
8304: checking for alloca... yes
8305: checking for strerror... yes
8306: updating cache ./config.cache
8307: creating ./config.status
8308: creating Makefile
8309: ===> Building for bison-1.25
8310: 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
8311: 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
8312: 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
8313: 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
8314: 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 8315: 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 8316: 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
8317: 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
8318: 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
8319: 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
8320: 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
8321: 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
8322: 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
8323: 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
8324: 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
8325: 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
8326: 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
8327: 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
8328: 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
8329: 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
8330: 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
8331: 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
8332: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
8333: rm -f bison.s1
1.75 rillig 8334: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1</pre>
8335: <p>Everything seems OK, so install the files:</p>
8336: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 8337: >> Checksum OK for bison-1.25.tar.gz.
8338: ===> Installing for bison-1.25
8339: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
8340: rm -f /usr/pkg/bin/bison
8341: cd /usr/pkg/share; rm -f bison.simple bison.hairy
8342: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
8343: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
8344: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
8345: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
8346: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
8347: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
1.75 rillig 8348: ===> Registering installation for bison-1.25</pre>
8349: <p>You can now use bison, and also - if you decide so - remove it with
8350: <span><strong class="command">pkg_delete bison</strong></span>. Should you decide that you want a
8351: binary package, do this now:</p>
8352: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 8353: >> Checksum OK for bison-1.25.tar.gz.
8354: ===> Building package for bison-1.25
8355: Creating package bison-1.25.tgz
8356: Registering depends:.
1.75 rillig 8357: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
8358: <p>Now that you don't need the source and object files
8359: any more, clean up:</p>
8360: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
8361: ===> Cleaning for bison-1.25</pre>
8362: </div>
8363: </div>
8364: <div class="appendix" lang="en">
8365: <div class="titlepage"><div><div><h2 class="title">
8366: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
8367: <div class="toc">
8368: <p><b>Table of Contents</b></p>
8369: <dl>
8370: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
8371: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
8372: </dl>
8373: </div>
8374: <div class="sect1" lang="en">
8375: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8376: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
8377: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 8378: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8379: => figlet221.tar.gz doesn't seem to exist on this system.
8380: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
8381: => [172219 bytes]
8382: Connected to ftp.plig.net.
8383: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
8384: 331 Guest login ok, send your complete e-mail address as password.
8385: 230-You are user #5 of 500 simultaneous users allowed.
8386: 230-
1.68 rillig 8387: 230- ___ _ _ _
8388: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
1.1 grant 8389: 230- | _| _| . |_| . | | | . |_| . | _| . |
8390: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
8391: 230- |_| |_| |___| |___|
8392: 230-
8393: 230-** Welcome to ftp.plig.org **
8394: 230-
8395: 230-Please note that all transfers from this FTP site are logged. If you
8396: 230-do not like this, please disconnect now.
8397: 230-
8398: 230-This arhive is available via
8399: 230-
8400: 230-HTTP: http://ftp.plig.org/
8401: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
8402: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
8403: 230-
8404: 230-Please email comments, bug reports and requests for packages to be
1.68 rillig 8405: 230-mirrored to ftp-admin@plig.org.
1.1 grant 8406: 230-
8407: 230-
8408: 230 Logged in anonymously.
8409: Remote system type is UNIX.
8410: Using binary mode to transfer files.
8411: 200 Type okay.
8412: 250 "/pub" is new cwd.
8413: 250-"/pub/figlet" is new cwd.
8414: 250-
8415: 250-Welcome to the figlet archive at ftp.figlet.org
1.68 rillig 8416: 250-
1.75 rillig 8417: 250- ftp://ftp.figlet.org/pub/figlet/
1.1 grant 8418: 250-
8419: 250-The official FIGlet web page is:
1.75 rillig 8420: 250- http://www.figlet.org/
1.1 grant 8421: 250-
8422: 250-If you have questions, please mailto:info@figlet.org. If you want to
8423: 250-contribute a font or something else, you can email us.
1.68 rillig 8424: 250
1.1 grant 8425: 250 "/pub/figlet/program" is new cwd.
8426: 250 "/pub/figlet/program/unix" is new cwd.
8427: local: figlet221.tar.gz remote: figlet221.tar.gz
8428: 502 Unimplemented command.
8429: 227 Entering Passive Mode (195,40,6,41,246,104)
8430: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
8431: 38% |************** | 65800 64.16 KB/s 00:01 ETA
8432: 226 Transfer completed.
8433: 172219 bytes received in 00:02 (75.99 KB/s)
8434: 221 Goodbye.
8435: => Checksum OK for figlet221.tar.gz.
8436: ===> Extracting for figlet-2.2.1nb2
8437: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
8438: ===> Patching for figlet-2.2.1nb2
8439: ===> Applying pkgsrc patches for figlet-2.2.1nb2
8440: ===> Overriding tools for figlet-2.2.1nb2
8441: ===> Creating toolchain wrappers for figlet-2.2.1nb2
8442: ===> Configuring for figlet-2.2.1nb2
8443: ===> Building for figlet-2.2.1nb2
8444: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
8445: chmod a+x figlet
8446: gcc -O2 -o chkfont chkfont.c
8447: => Unwrapping files-to-be-installed.
1.14 xtraeme 8448: <code class="prompt">#</code>
1.75 rillig 8449: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 8450: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8451: ===> Installing for figlet-2.2.1nb2
8452: install -d -o root -g wheel -m 755 /usr/pkg/bin
8453: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
8454: mkdir -p /usr/pkg/share/figlet
8455: cp figlet /usr/pkg/bin
8456: cp chkfont /usr/pkg/bin
8457: chmod 555 figlist showfigfonts
8458: cp figlist /usr/pkg/bin
8459: cp showfigfonts /usr/pkg/bin
8460: cp fonts/*.flf /usr/pkg/share/figlet
8461: cp fonts/*.flc /usr/pkg/share/figlet
8462: cp figlet.6 /usr/pkg/man/man6
8463: ===> Registering installation for figlet-2.2.1nb2
1.75 rillig 8464: <code class="prompt">#</code></pre>
8465: </div>
8466: <div class="sect1" lang="en">
8467: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8468: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
8469: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 8470: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8471: ===> Packaging figlet-2.2.1nb2
8472: ===> Building binary package for figlet-2.2.1nb2
8473: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
8474: Using SrcDir value of /usr/pkg
1.68 rillig 8475: Registering depends:.
1.75 rillig 8476: <code class="prompt">#</code></pre>
8477: </div>
8478: </div>
8479: <div class="appendix" lang="en">
8480: <div class="titlepage"><div><div><h2 class="title">
1.76 rillig 8481: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
8482: <div class="toc">
8483: <p><b>Table of Contents</b></p>
8484: <dl>
8485: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
8486: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
8487: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
8488: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
8489: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
8490: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
8491: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
8492: source packages</a></span></dt>
8493: </dl>
8494: </div>
8495: <p>As in other big projects, the directory layout of pkgsrc
8496: is quite complex for newbies. This chapter explains where you
8497: find things on the FTP server. The base directory on
8498: <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>.
8499: This directory contains some subdirectories, which are explained
8500: below.</p>
8501: <div class="sect1" lang="en">
8502: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8503: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
8504: <p>For those who only want to manage binary packages on
8505: systems other than NetBSD, we provide the package management
8506: tools in a separate, small tar file.</p>
8507: </div>
8508: <div class="sect1" lang="en">
8509: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8510: <a name="ftp-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
8511: <p>The directory <code class="filename">distfiles</code> contains lots
8512: of archive files from all pkgsrc packages, which are mirrored
8513: here. The subdirectories are called after their package names
8514: and are used when the distributed files have names that don't
8515: explicitly contain a version number or are otherwise too generic
8516: (for example <code class="filename">release.tar.gz</code>).</p>
8517: </div>
8518: <div class="sect1" lang="en">
8519: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8520: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
8521: <p>This directory is currently not in use.</p>
8522: </div>
8523: <div class="sect1" lang="en">
8524: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8525: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
8526: <p>This directory contains things that individual pkgsrc
8527: developers find worth publishing.</p>
8528: </div>
8529: <div class="sect1" lang="en">
8530: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8531: <a name="ftp-packages"></a>C.5. <code class="filename">packages*</code>: Binary packages</h2></div></div></div>
8532: <p>These directories contain binary packages. Those
8533: directories that have a branch name
8534: (200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>)
8535: contain packages from that particular branch. The directory
8536: <code class="filename">packages</code> contains binary packages from
8537: pkgsrc-current. (However, this does not necessarily mean that
8538: the packages are still current anymore.)</p>
8539: <p>Below the <code class="filename">packages*</code> directories are
8540: directories that distinguish the packages by operating system
8541: and version, the next directory level specifies the hardware
8542: architecture.</p>
8543: <p>In each of the platform-specific directories, there is a
8544: whole binary packages collection. It has a directory called
8545: <code class="filename">All</code> which contains all binary packages.
8546: Besides that, there are various category directories that
8547: contain symbolic links to the real binary packages.</p>
8548: </div>
8549: <div class="sect1" lang="en">
8550: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8551: <a name="ftp-source"></a>C.6. <code class="filename">current</code>,
8552: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
8553: source packages</h2></div></div></div>
8554: <p>These directories contain the “<span class="quote">real</span>” pkgsrc,
8555: that is the files that define how to create binary packages from
8556: source archives.</p>
8557: <p>The directory <code class="filename">pkgsrc</code> contains a
8558: snapshot of the CVS repository, which is updated on a regularly
8559: basis. The file <code class="filename">pkgsrc.tar.gz</code> contains the
8560: same as the directory, ready to be downloaded as a whole.</p>
8561: <p>In the directories for the quarterly branches, there is an
8562: additional file called
8563: <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
8564: which contains the state of pkgsrc when it was branched.</p>
8565: </div>
1.75 rillig 8566: </div>
8567: <div class="appendix" lang="en">
8568: <div class="titlepage"><div><div><h2 class="title">
8569: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
8570: <div class="toc">
8571: <p><b>Table of Contents</b></p>
8572: <dl>
8573: <dt><span class="sect1"><a href="#targets">D.1. Targets</a></span></dt>
8574: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
8575: </dl>
8576: </div>
8577: <p>
8578: This section contains information on editing the pkgsrc guide
8579: itself.
8580: </p>
8581: <div class="sect1" lang="en">
8582: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8583: <a name="targets"></a>D.1. Targets</h2></div></div></div>
8584: <p>
8585: The pkgsrc guide's source code is stored in
1.76 rillig 8586: <code class="filename">pkgsrc/doc/guide/files</code>, and several files are
1.75 rillig 8587: created from it:
8588: </p>
8589: <div class="itemizedlist"><ul type="disc">
8590: <li><p>
1.76 rillig 8591: <code class="filename">pkgsrc/doc/pkgsrc.txt</code>
1.75 rillig 8592: </p></li>
8593: <li><p>
1.76 rillig 8594: <code class="filename">pkgsrc/doc/pkgsrc.html</code>
1.75 rillig 8595: </p></li>
8596: <li><p>
1.76 rillig 8597: <code class="filename">http://www.NetBSD.org/Documentation/pkgsrc/</code>:
1.75 rillig 8598: the documentation on the NetBSD website will be built from
8599: pkgsrc and kept up to date on the web server itself. This
8600: means you <span class="emphasis"><em>must</em></span> make sure that your
8601: changes haven't broken the build!
8602: </p></li>
8603: <li><p>
1.76 rillig 8604: <code class="filename">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</code>:
1.75 rillig 8605: PDF version of the pkgsrc guide.
8606: </p></li>
8607: <li><p>
1.76 rillig 8608: <code class="filename">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</code>:
1.75 rillig 8609: PostScript version of the pkgsrc guide.
8610: </p></li>
8611: </ul></div>
8612: </div>
8613: <div class="sect1" lang="en">
8614: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8615: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
8616: <p>
8617: The procedure to edit the pkgsrc guide is:
8618: </p>
8619: <div class="itemizedlist"><ul type="disc">
8620: <li><p>
8621: Make sure you have the packages needed to re-generate the
8622: pkgsrc guide (and other XML-based NetBSD documentation)
8623: installed. These are “<span class="quote">netbsd-doc</span>” for creating the
8624: ASCII and HTML versions, and
8625: “<span class="quote">netbsd-doc-print</span>” for the PostScript and PDF
8626: versions. You will need both packages installed, to make sure
8627: documentation is consistent across all formats. The packages
8628: can be found in
1.76 rillig 8629: <code class="filename">pkgsrc/meta-pkgs/netbsd-doc</code> and
8630: <code class="filename">pkgsrc/meta-pkgs/netbsd-doc-print</code>.
1.75 rillig 8631: </p></li>
8632: <li><p>
8633: Edit the XML file(s) in
1.76 rillig 8634: <code class="filename">pkgsrc/doc/guide/files</code>.
1.75 rillig 8635: </p></li>
8636: <li><p>
8637: Run <span><strong class="command">make extract && make do-lint</strong></span> in
1.76 rillig 8638: <code class="filename">pkgsrc/doc/guide</code> to check the XML
1.75 rillig 8639: syntax, and fix it if needed.
8640: </p></li>
8641: <li><p>
8642: Run <span><strong class="command">make</strong></span> in
1.76 rillig 8643: <code class="filename">pkgsrc/doc/guide</code> to build the HTML and
1.75 rillig 8644: ASCII version.
8645: </p></li>
8646: <li><p>
8647: If all is well, run <span><strong class="command">make install-doc</strong></span> to put
1.76 rillig 8648: the generated files into <code class="filename">pkgsrc/doc</code>.
1.75 rillig 8649: </p></li>
8650: <li><p>
8651: <span><strong class="command">cvs commit pkgsrc/doc/guide/files</strong></span>
8652: </p></li>
8653: <li><p>
8654: <span><strong class="command">cvs commit -m re-generate pkgsrc/doc/pkgsrc.{html,txt}</strong></span>
8655: </p></li>
8656: <li><p>
8657: Until the webserver on www.NetBSD.org is really updated
8658: automatically to pick up changes to the pkgsrc guide
8659: automatically, also run <span><strong class="command">make install-htdocs
8660: HTDOCSDIR=../../../htdocs</strong></span> (or similar, adjust
8661: <code class="varname">HTDOCSDIR</code>!).
8662: </p></li>
8663: <li><p>
8664: <span><strong class="command">cvs commit htdocs/Documentation/pkgsrc</strong></span>
8665: </p></li>
8666: </ul></div>
8667: </div>
8668: </div>
8669: </div></body>
1.1 grant 8670: </html>
CVSweb <webmaster@jp.NetBSD.org>