Annotation of pkgsrc/doc/pkgsrc.html, revision 1.82
1.75 rillig 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2: <html>
1.1 grant 3: <head>
1.75 rillig 4: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
5: <title>The pkgsrc guide</title>
6: <link rel="stylesheet" href="/NetBSD.css" type="text/css">
7: <meta name="generator" content="DocBook XSL Stylesheets VX.X.X">
8: <meta name="description" content="pkgsrc is a centralized package management system for
9: Unix-like operating systems. This guide provides information for
10: users and developers of pkgsrc. It covers installation of binary
11: and source packages, creation of binary and source packages and
12: a high-level overview about the infrastructure.">
13: </head>
14: <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" lang="en">
15: <div class="titlepage">
16: <div>
17: <div><h1 class="title">
18: <a name="the-pkgsrc-guide"></a>The pkgsrc guide</h1></div>
19: <div><h2 class="subtitle">Documentation on the NetBSD packages system</h2></div>
20: <div><div class="authorgroup">
21: <div class="author">
22: <h3 class="author">
23: <span class="firstname">Alistair</span> <span class="surname">Crooks</span>
24: </h3>
25: <div class="affiliation"><div class="address"><p><code class="email"><<a href="mailto:agc@NetBSD.org">agc@NetBSD.org</a>></code></p></div></div>
26: </div>
27: <div class="author">
28: <h3 class="author">
29: <span class="firstname">Hubert</span> <span class="surname">Feyrer</span>
30: </h3>
31: <div class="affiliation"><div class="address"><p><code class="email"><<a href="mailto:hubertf@NetBSD.org">hubertf@NetBSD.org</a>></code></p></div></div>
32: </div>
33: <h3 class="corpauthor">
34: The pkgsrc Developers
35: </h3>
36: </div></div>
37: <div><p class="copyright">Copyright © 1994-2006 The NetBSD Foundation, Inc</p></div>
1.80 rillig 38: <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.21 2006/07/03 23:51:01 rillig Exp $</p></div>
1.76 rillig 39: <div><div class="abstract">
1.75 rillig 40: <p class="title"><b>Abstract</b></p>
41: <p>pkgsrc is a centralized package management system for
42: Unix-like operating systems. This guide provides information for
43: users and developers of pkgsrc. It covers installation of binary
44: and source packages, creation of binary and source packages and
45: a high-level overview about the infrastructure.</p>
46: </div></div>
47: </div>
48: <hr>
49: </div>
50: <div class="toc">
51: <p><b>Table of Contents</b></p>
52: <dl>
53: <dt><span class="chapter"><a href="#introduction">1. What is pkgsrc?</a></span></dt>
54: <dd><dl>
55: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
1.82 ! rillig 56: <dd><dl>
! 57: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
! 58: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
! 59: </dl></dd>
1.75 rillig 60: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
61: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.78 rillig 62: <dd><dl>
63: <dt><span class="sect2"><a href="#term.abbrev">1.3.1. Commonly used abbreviations</a></span></dt>
1.82 ! rillig 64: <dt><span class="sect2"><a href="#term.roles">1.3.2. Roles involved in pkgsrc</a></span></dt>
1.78 rillig 65: </dl></dd>
1.75 rillig 66: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
67: </dl></dd>
68: <dt><span class="part"><a href="#users-guide">I. The pkgsrc user's guide</a></span></dt>
69: <dd><dl>
70: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
71: <dd><dl>
72: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
73: <dd><dl>
74: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
75: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
76: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
77: </dl></dd>
78: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
79: <dd><dl>
80: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
81: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
82: </dl></dd>
83: </dl></dd>
84: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
85: <dd><dl>
1.82 ! rillig 86: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
! 87: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
! 88: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
! 89: <dd><dl>
! 90: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
! 91: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
! 92: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
! 93: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
! 94: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
! 95: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
! 96: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75 rillig 97: </dl></dd>
98: </dl></dd>
99: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
100: <dd><dl>
101: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
102: <dd><dl>
103: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
104: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82 ! rillig 105: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
! 106: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
! 107: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
! 108: <dt><span class="sect2"><a href="#pkg_versions">4.1.6. Finding if newer versions of your installed packages are in pkgsrc</a></span></dt>
! 109: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
! 110: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75 rillig 111: </dl></dd>
112: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
113: <dd><dl>
114: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
115: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
116: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
117: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
118: </dl></dd>
119: </dl></dd>
120: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
121: <dd><dl>
122: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
123: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 124: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
125: <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>
126: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
127: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 128: </dl></dd>
129: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
130: <dd><dl>
131: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
132: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
133: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
134: <dd><dl>
135: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
136: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
137: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
138: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
139: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
140: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
141: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
142: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
143: </dl></dd>
144: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
145: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
146: </dl></dd>
147: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
148: <dd><dl>
149: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
150: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
151: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
152: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
153: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
154: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
155: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
156: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
157: <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>
158: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
159: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
160: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
161: <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>
162: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
163: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
164: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
165: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
1.80 rillig 166: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.75 rillig 167: </dl></dd>
168: </dl></dd>
169: <dt><span class="part"><a href="#developers-guide">II. The pkgsrc developer's guide</a></span></dt>
170: <dd><dl>
1.77 rillig 171: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
172: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75 rillig 173: <dd><dl>
1.77 rillig 174: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
175: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
176: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
177: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
178: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 179: <dd><dl>
180: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
181: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
182: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
183: </dl></dd>
1.77 rillig 184: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
185: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
186: </dl></dd>
187: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
188: <dd><dl>
189: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
190: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
191: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
192: <dd><dl>
193: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
194: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
195: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
196: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
197: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
198: </dl></dd>
199: </dl></dd>
200: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
201: <dd><dl>
202: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
203: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
204: <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>
205: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
206: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
207: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
208: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
209: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
210: </dl></dd>
211: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
212: <dd><dl>
213: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
214: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
215: <dd><dl>
216: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
217: <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>
218: </dl></dd>
219: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
220: <dd><dl>
221: <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>
222: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
223: </dl></dd>
224: </dl></dd>
225: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
226: <dd><dl>
227: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
228: <dd><dl>
229: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
230: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
231: </dl></dd>
232: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
233: <dd><dl>
234: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
235: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
236: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
237: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
238: </dl></dd>
239: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
240: <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>
241: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
242: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
243: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
244: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
245: <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>
246: </dl></dd>
247: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
248: <dd><dl>
249: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
250: <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>
251: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
252: </dl></dd>
253: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
254: <dd><dl>
255: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
256: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
257: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
258: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
259: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
1.81 rillig 260: <dd><dl>
261: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
262: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
263: </dl></dd>
1.77 rillig 264: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
265: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
266: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
267: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
268: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
269: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
270: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
271: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
272: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
273: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
274: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
275: </dl></dd>
276: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
277: <dd><dl>
278: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
279: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
280: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
281: </dl></dd>
282: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
283: <dd><dl>
284: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
285: <dd><dl>
1.78 rillig 286: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
287: <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>
288: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
289: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
290: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
291: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
292: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
293: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
294: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
295: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
296: <dt><span class="sect2"><a href="#bumping-pkgrevision">17.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
1.79 rillig 297: <dt><span class="sect2"><a href="#fixes.subst">17.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
1.77 rillig 298: </dl></dd>
299: <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>
300: <dd><dl>
301: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
302: <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>
303: </dl></dd>
304: <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>
305: <dd><dl>
306: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
307: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
308: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
309: </dl></dd>
310: <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>
311: <dd><dl>
1.78 rillig 312: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
313: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
314: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
315: </dl></dd>
316: <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>
317: <dd><dl>
318: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
319: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
320: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
321: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
322: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
323: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
324: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
325: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
326: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
327: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
328: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
329: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
330: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
331: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
332: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
333: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
334: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.77 rillig 335: </dl></dd>
1.78 rillig 336: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.77 rillig 337: </dl></dd>
338: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
339: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
340: <dd><dl>
341: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
342: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
343: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
344: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
345: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
346: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 347: </dl></dd>
1.77 rillig 348: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.75 rillig 349: </dl></dd>
350: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
351: <dd><dl>
1.77 rillig 352: <dt><span class="chapter"><a href="#infr.design">21. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 353: <dd><dl>
1.81 rillig 354: <dt><span class="sect1"><a href="#infr.vardef">21.1. The meaning of variable definitions</a></span></dt>
355: <dt><span class="sect1"><a href="#infr.vardef.problems">21.2. Avoiding problems before they arise</a></span></dt>
356: <dt><span class="sect1"><a href="#infr.var">21.3. Variable evaluation</a></span></dt>
357: <dd><dl>
358: <dt><span class="sect2"><a href="#infr.var.load">21.3.1. At load time</a></span></dt>
359: <dt><span class="sect2"><a href="#infr.var.run">21.3.2. At runtime</a></span></dt>
360: </dl></dd>
361: <dt><span class="sect1"><a href="#infr.varspec">21.4. How can variables be specified?</a></span></dt>
362: <dt><span class="sect1"><a href="#infr.design.intf">21.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 363: <dd><dl>
1.81 rillig 364: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.5.1. Procedures with parameters</a></span></dt>
365: <dt><span class="sect2"><a href="#infr.design.intf.action">21.5.2. Actions taken on behalf of parameters</a></span></dt>
1.75 rillig 366: </dl></dd>
1.81 rillig 367: <dt><span class="sect1"><a href="#infr.order">21.6. The order in which files are loaded</a></span></dt>
1.75 rillig 368: <dd><dl>
1.81 rillig 369: <dt><span class="sect2"><a href="#infr.order.prefs">21.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
370: <dt><span class="sect2"><a href="#infr.order.pkg">21.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75 rillig 371: </dl></dd>
372: </dl></dd>
1.77 rillig 373: <dt><span class="chapter"><a href="#regression">22. Regression tests</a></span></dt>
1.75 rillig 374: <dd><dl>
1.77 rillig 375: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
376: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
377: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 378: <dd><dl>
1.77 rillig 379: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
380: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 381: </dl></dd>
382: </dl></dd>
1.80 rillig 383: <dt><span class="chapter"><a href="#porting">23. Porting pkgsrc</a></span></dt>
1.75 rillig 384: <dd><dl>
1.80 rillig 385: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
386: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 387: </dl></dd>
388: </dl></dd>
389: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
390: <dd><dl>
391: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
392: <dd><dl>
393: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
394: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
395: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
396: <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>
397: </dl></dd>
398: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
399: </dl></dd>
400: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
401: <dd><dl>
402: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
403: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
404: </dl></dd>
1.76 rillig 405: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
406: <dd><dl>
407: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
408: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
409: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
410: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
411: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
412: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
413: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
414: source packages</a></span></dt>
415: </dl></dd>
1.75 rillig 416: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
417: <dd><dl>
1.79 rillig 418: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75 rillig 419: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
420: </dl></dd>
421: </dl>
422: </div>
1.82 ! rillig 423: <div class="list-of-tables">
! 424: <p><b>List of Tables</b></p>
! 425: <dl>
! 426: <dt>1.1. <a href="#supported-platforms">Platforms supported by pkgsrc</a>
! 427: </dt>
! 428: <dt>3.1. <a href="#binary-kits">Binary kits and available packages</a>
! 429: </dt>
! 430: </dl>
! 431: </div>
1.75 rillig 432: <div class="chapter" lang="en">
433: <div class="titlepage"><div><div><h2 class="title">
434: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
435: <div class="toc">
436: <p><b>Table of Contents</b></p>
437: <dl>
438: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
1.82 ! rillig 439: <dd><dl>
! 440: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
! 441: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
! 442: </dl></dd>
1.75 rillig 443: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
444: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.78 rillig 445: <dd><dl>
446: <dt><span class="sect2"><a href="#term.abbrev">1.3.1. Commonly used abbreviations</a></span></dt>
1.82 ! rillig 447: <dt><span class="sect2"><a href="#term.roles">1.3.2. Roles involved in pkgsrc</a></span></dt>
1.78 rillig 448: </dl></dd>
1.75 rillig 449: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
450: </dl>
451: </div>
452: <div class="sect1" lang="en">
453: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
454: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
1.82 ! rillig 455: <p>There is a lot of software freely available for Unix-based
! 456: systems, which is usually available in form of the source code. Before
! 457: such software can be used, it needs to be configured to the local
! 458: system, compiled and installed, and this is exactly what The NetBSD
! 459: Packages Collection (pkgsrc) does. pkgsrc also has some basic commands
! 460: to handle binary packages, so that not every user has to build the
! 461: packages for himself, which is a time-costly task.</p>
1.75 rillig 462: <p>pkgsrc currently contains several thousand packages,
463: including:</p>
464: <div class="itemizedlist"><ul type="disc">
1.76 rillig 465: <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 466: web server</p></li>
1.76 rillig 467: <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 468: web browser</p></li>
1.76 rillig 469: <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 470: Desktop Environment</p></li>
1.76 rillig 471: <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 472: Desktop Environment</p></li>
473: </ul></div>
474: <p>...just to name a few.</p>
475: <p>pkgsrc has built-in support for handling varying dependencies,
476: such as pthreads and X11, and extended features such as IPv6 support on
477: a range of platforms.</p>
1.82 ! rillig 478: <div class="sect2" lang="en">
! 479: <div class="titlepage"><div><div><h3 class="title">
! 480: <a name="why-pkgsrc"></a>1.1.1. Why pkgsrc?</h3></div></div></div>
! 481: <p>
! 482: pkgsrc provides the following key features:
! 483: </p>
! 484: <div class="itemizedlist"><ul type="disc">
! 485: <li><p>Easy building of software from source as well as the creation
! 486: and installation of binary packages. The source and latest
! 487: patches are retrieved from a master or mirror download site, checksum
! 488: verified, then built on your system. Support for binary-only
! 489: distributions is available for both native platforms and NetBSD
! 490: emulated platforms.</p></li>
! 491: <li><p>All packages are installed in a consistent directory tree,
! 492: including binaries, libraries, man pages and other
! 493: documentation.</p></li>
! 494: <li><p>Package dependencies, including when performing package updates,
! 495: are handled automatically. The configuration files of various
! 496: packages are handled automatically during updates, so local changes
! 497: are preserved.</p></li>
! 498: <li><p>Like NetBSD, pkgsrc is designed with portability in mind and
! 499: consists of highly portable code. This allows the greatest speed of
! 500: development when porting to new a platform. This portability also
! 501: ensures that pkgsrc is <span class="emphasis"><em>consistent across all
! 502: platforms</em></span>.</p></li>
! 503: <li><p>The installation prefix, acceptable software licenses,
! 504: international encryption requirements and build-time options for a
! 505: large number of packages are all set in a simple, central
! 506: configuration file.</p></li>
! 507: <li><p>The entire source (not including the distribution files) is
! 508: freely available under a BSD license, so you may extend and adapt
! 509: pkgsrc to your needs. Support for local packages and patches is
! 510: available right out of the box, so you can configure it specifically
! 511: for your environment.</p></li>
! 512: </ul></div>
! 513: </div>
! 514: <div class="sect2" lang="en">
! 515: <div class="titlepage"><div><div><h3 class="title">
! 516: <a name="intro.platforms"></a>1.1.2. Supported platforms</h3></div></div></div>
! 517: <p>pkgsrc consists of both a source distribution and a binary
! 518: distribution for these operating systems. After retrieving the required
! 519: source or binaries, you can be up and running with pkgsrc in just
! 520: minutes!</p>
1.75 rillig 521: <p>pkgsrc was derived from FreeBSD's ports system, and
522: initially developed for NetBSD only. Since then, pkgsrc has
523: grown a lot, and now supports the following platforms:</p>
1.82 ! rillig 524: <div class="table">
! 525: <a name="supported-platforms"></a><p class="title"><b>Table 1.1. Platforms supported by pkgsrc</b></p>
! 526: <table summary="Platforms supported by pkgsrc" border="1">
! 527: <colgroup>
! 528: <col>
! 529: <col>
! 530: </colgroup>
! 531: <thead><tr>
! 532: <th>Platform</th>
! 533: <th>Date Support Added</th>
! 534: </tr></thead>
! 535: <tbody>
! 536: <tr>
! 537: <td><a href="http://www.NetBSD.org/" target="_top">NetBSD</a></td>
! 538: <td align="center">Aug 1997</td>
! 539: </tr>
! 540: <tr>
! 541: <td><a href="http://wwws.sun.com/software/solaris/" target="_top">Solaris</a></td>
! 542: <td align="center">Mar 1999</td>
! 543: </tr>
! 544: <tr>
! 545: <td><a href="http://www.kernel.org/" target="_top">Linux</a></td>
! 546: <td align="center">Jun 1999</td>
! 547: </tr>
! 548: <tr>
! 549: <td>
! 550: <a href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
! 551: (<a href="http://developer.apple.com/macosx/" target="_top">Mac OS X</a>)
! 552: </td>
! 553: <td align="center">Oct 2001</td>
! 554: </tr>
! 555: <tr>
! 556: <td><a href="http://www.freebsd.org/" target="_top">FreeBSD</a></td>
! 557: <td align="center">Nov 2002</td>
! 558: </tr>
! 559: <tr>
! 560: <td><a href="http://www.openbsd.org/" target="_top">OpenBSD</a></td>
! 561: <td align="center">Nov 2002</td>
! 562: </tr>
! 563: <tr>
! 564: <td><a href="http://www.sgi.com/software/irix/" target="_top">IRIX</a></td>
! 565: <td align="center">Dec 2002</td>
! 566: </tr>
! 567: <tr>
! 568: <td>BSD/OS</td>
! 569: <td align="center">Dec 2003</td>
! 570: </tr>
! 571: <tr>
! 572: <td><a href="http://www-1.ibm.com/servers/aix/" target="_top">AIX</a></td>
! 573: <td align="center">Dec 2003</td>
! 574: </tr>
! 575: <tr>
! 576: <td>
! 577: <a href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a>
! 578: (Microsoft Windows Services for Unix)
! 579: </td>
! 580: <td align="center">Mar 2004</td>
! 581: </tr>
! 582: <tr>
! 583: <td><a href="http://www.dragonflybsd.org/" target="_top">DragonFlyBSD</a></td>
! 584: <td align="center">Oct 2004</td>
! 585: </tr>
! 586: <tr>
! 587: <td><a href="http://www.tru64.org/" target="_top">OSF/1</a></td>
! 588: <td align="center">Nov 2004</td>
! 589: </tr>
! 590: </tbody>
! 591: </table>
! 592: </div>
! 593: </div>
1.75 rillig 594: </div>
595: <div class="sect1" lang="en">
596: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
597: <a name="overview"></a>1.2. Overview</h2></div></div></div>
598: <p>This document is divided into three parts. The first,
599: <a href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
600: describes how one can use one of the packages in the Package
601: Collection, either by installing a precompiled binary package,
602: or by building one's own copy using the NetBSD package system.
603: 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
604: package so it can be easily built by other NetBSD users without
605: knowing about the package's building details. The third part,
606: <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
607: is intended for those who want to understand how pkgsrc is
608: implemented.</p>
609: <p>This document is available in various formats:
610: <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>
611: </div>
612: <div class="sect1" lang="en">
613: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
614: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
615: <p>There has been a lot of talk about “<span class="quote">ports</span>”,
616: “<span class="quote">packages</span>”, etc. so far. Here is a description of all the
617: terminology used within this document.</p>
618: <div class="variablelist"><dl>
619: <dt><span class="term">Package</span></dt>
620: <dd><p>A set of files and building instructions
621: that describe what's necessary
622: to build a certain piece of software using
623: pkgsrc. Packages are traditionally stored under
1.76 rillig 624: <code class="filename">/usr/pkgsrc</code>.</p></dd>
1.75 rillig 625: <dt><span class="term">The NetBSD package system</span></dt>
626: <dd><p>
627: This is the former name of “<span class="quote">pkgsrc</span>”. It is
628: part of the NetBSD operating system and can be bootstrapped to
629: run on non-NetBSD operating systems as well. It handles
630: building (compiling), installing, and removing of
631: packages.
632: </p></dd>
633: <dt><span class="term">Distfile</span></dt>
634: <dd><p>This term describes the file or files that are
635: provided by the author of the piece of software to
636: distribute his work. All the changes necessary to build on
637: NetBSD are reflected in the corresponding package. Usually
638: the distfile is in the form of a compressed tar-archive,
639: but other types are possible, too. Distfiles are usually
640: stored below
1.76 rillig 641: <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
1.75 rillig 642: <dt><span class="term">Port</span></dt>
643: <dd><p>This is the term used by FreeBSD and OpenBSD people
644: for what we call a package.
645: In NetBSD terminology, “<span class="quote">port</span>” refers to a different
646: architecture.</p></dd>
647: <dt><span class="term">Precompiled/binary package</span></dt>
648: <dd>
649: <p>A set of binaries built with pkgsrc from a distfile
1.76 rillig 650: and stuffed together in a single <code class="filename">.tgz</code>
1.75 rillig 651: file so it can be installed on machines of the same
652: machine architecture without the need to
653: recompile. Packages are usually generated in
1.76 rillig 654: <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.75 rillig 655: an archive on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
656: <p>Sometimes, this is referred to by the term “<span class="quote">package</span>” too,
657: especially in the context of precompiled packages.</p>
658: </dd>
659: <dt><span class="term">Program</span></dt>
660: <dd><p>The piece of software to be installed which will be constructed from
661: all the files in the distfile by the actions defined in the
662: corresponding package.</p></dd>
663: </dl></div>
664: <div class="sect2" lang="en">
665: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 666: <a name="term.abbrev"></a>1.3.1. Commonly used abbreviations</h3></div></div></div>
667: <div class="variablelist"><dl>
668: <dt><span class="term">ICE</span></dt>
669: <dd><p>Internal Compiler
670: Error</p></dd>
671: </dl></div>
672: </div>
673: <div class="sect2" lang="en">
674: <div class="titlepage"><div><div><h3 class="title">
1.82 ! rillig 675: <a name="term.roles"></a>1.3.2. Roles involved in pkgsrc</h3></div></div></div>
1.75 rillig 676: <div class="variablelist"><dl>
677: <dt><span class="term">pkgsrc users</span></dt>
678: <dd>
679: <p>The
680: pkgsrc users are people who use the packages provided by pkgsrc.
681: Typically they are system administrators. The people using the
682: software that is inside the packages (maybe called “<span class="quote">end
683: users</span>”) are not covered by the pkgsrc guide.</p>
684: <p>There are two kinds of pkgsrc users: Some only want to
685: install pre-built binary packages. Others build the pkgsrc
686: packages from source, either for installing them directly or for
687: 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
688: documentation.</p>
689: </dd>
690: <dt><span class="term">package maintainers</span></dt>
691: <dd><p>A
692: 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>
693: <dt><span class="term">infrastructure developers</span></dt>
694: <dd><p>These people are involved in all those files
1.76 rillig 695: that live in the <code class="filename">mk/</code> directory and below.
1.75 rillig 696: 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,
697: too.</p></dd>
698: </dl></div>
699: </div>
700: </div>
701: <div class="sect1" lang="en">
702: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
703: <a name="typography"></a>1.4. Typography</h2></div></div></div>
704: <p>When giving examples for commands, shell prompts are used to
705: show if the command should/can be issued as root, or if
706: “<span class="quote">normal</span>” user privileges are sufficient. We use a
707: <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
708: shell prompt, assuming they use the C-shell or tcsh.</p>
709: </div>
710: </div>
711: <div class="part" lang="en">
712: <div class="titlepage"><div><div><h1 class="title">
713: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
714: <div class="toc">
715: <p><b>Table of Contents</b></p>
716: <dl>
717: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
718: <dd><dl>
719: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
720: <dd><dl>
721: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
722: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
723: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
724: </dl></dd>
725: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
726: <dd><dl>
727: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
728: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
729: </dl></dd>
730: </dl></dd>
731: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
732: <dd><dl>
1.82 ! rillig 733: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
! 734: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
! 735: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
! 736: <dd><dl>
! 737: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
! 738: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
! 739: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
! 740: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
! 741: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
! 742: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
! 743: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75 rillig 744: </dl></dd>
745: </dl></dd>
746: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
747: <dd><dl>
748: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
749: <dd><dl>
750: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
751: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82 ! rillig 752: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
! 753: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
! 754: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
! 755: <dt><span class="sect2"><a href="#pkg_versions">4.1.6. Finding if newer versions of your installed packages are in pkgsrc</a></span></dt>
! 756: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
! 757: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75 rillig 758: </dl></dd>
759: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
760: <dd><dl>
761: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
762: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
763: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
764: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
765: </dl></dd>
766: </dl></dd>
767: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
768: <dd><dl>
769: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
770: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 771: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
772: <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>
773: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
774: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 775: </dl></dd>
776: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
777: <dd><dl>
778: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
779: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
780: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
781: <dd><dl>
782: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
783: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
784: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
785: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
786: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
787: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
788: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
789: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
790: </dl></dd>
791: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
792: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
793: </dl></dd>
794: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
795: <dd><dl>
796: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
797: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
798: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
799: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
800: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
801: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
802: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
803: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
804: <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>
805: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
806: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
807: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
808: <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>
809: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
810: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
811: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
812: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
1.80 rillig 813: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.75 rillig 814: </dl></dd>
815: </dl>
816: </div>
817: <div class="chapter" lang="en">
818: <div class="titlepage"><div><div><h2 class="title">
819: <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
820: <div class="toc">
821: <p><b>Table of Contents</b></p>
822: <dl>
823: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
824: <dd><dl>
825: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
826: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
827: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
828: </dl></dd>
829: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
830: <dd><dl>
831: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
832: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
833: </dl></dd>
834: </dl>
835: </div>
836: <p>The most common location where pkgsrc is installed is
1.76 rillig 837: <code class="filename">/usr/pkgsrc</code> for the “<span class="quote">package
838: sources</span>” and <code class="filename">/usr/pkg</code> for the
1.75 rillig 839: installed binary packages. You are though free to install the
840: sources and binary packages wherever you want in your
841: filesystem, provided that both paths do not contain white-space
842: or other characters that are interpreted specially by the shell
843: and some other programs. A safe bet is to use only letters,
844: digits, underscores and dashes in the names.</p>
845: <div class="sect1" lang="en">
846: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
847: <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
848: <p>Before you download any pkgsrc files, you should decide
849: whether you want the <span class="emphasis"><em>current</em></span> branch or the
850: <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
851: quarterly basis from the current branch and only gets modified
852: for security updates. The names of the stable branches are built
853: from the year and the quarter, for example
854: <code class="literal">2006Q1</code>.</p>
855: <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
856: want to download pkgsrc. You can get it as a tar file, via SUP,
857: or via CVS. All three ways are described here.</p>
858: <div class="sect2" lang="en">
859: <div class="titlepage"><div><div><h3 class="title">
860: <a name="getting-via-tar"></a>2.1.1. As tar file</h3></div></div></div>
861: <p>The primary download location for all pkgsrc files is
862: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>. There are a
863: number of subdirectories for different purposes, which are
1.76 rillig 864: 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 865: <p>The tar file for the current branch is in the directory
1.76 rillig 866: <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 867: It is autogenerated daily.</p>
868: <p>The tar file for the stable branch 2006Q1 is in the
1.76 rillig 869: 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 870: <p>After downloading the tar file, change to the directory
871: where you want to have pkgsrc. This is usually
1.76 rillig 872: <code class="filename">/usr</code>. Then, run <span><strong class="command">tar xfz
1.75 rillig 873: pkgsrc.tar.gz</strong></span> to extract the files.</p>
874: </div>
875: <div class="sect2" lang="en">
876: <div class="titlepage"><div><div><h3 class="title">
877: <a name="getting-via-sup"></a>2.1.2. Via SUP</h3></div></div></div>
878: <p>As an alternative to the tar file, you can get pkgsrc via
879: the Software Update Protocol, SUP. To do so, make sure your
880: supfile has a line
1.1 grant 881:
1.75 rillig 882: </p>
883: <pre class="programlisting">
1.51 rillig 884: release=pkgsrc
1.1 grant 885: </pre>
1.75 rillig 886: <p>
1.1 grant 887:
1.75 rillig 888: in it, see the examples in
1.76 rillig 889: <code class="filename">/usr/share/examples/supfiles</code>, and that the
890: <code class="filename">/usr/pkgsrc</code> directory exists. Then, simply
1.75 rillig 891: run <span><strong class="command">sup -v
892: <em class="replaceable"><code>/path/to/your/supfile</code></em></strong></span>.</p>
893: </div>
894: <div class="sect2" lang="en">
895: <div class="titlepage"><div><div><h3 class="title">
896: <a name="getting-via-cvs"></a>2.1.3. Via CVS</h3></div></div></div>
897: <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>
898: installed. To do an initial (full) checkout of pkgsrc, you first
899: have to set some environment variables. For the C-Shell,
900: type:</p>
901: <pre class="screen">
902: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
903: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVS_RSH ssh</code></strong>
904: </pre>
905: <p>Or, the same for the bourne shell:</p>
906: <pre class="screen">
907: <code class="prompt">$</code> <strong class="userinput"><code>CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"</code></strong>
908: <code class="prompt">$</code> <strong class="userinput"><code>CVS_RSH="ssh"</code></strong>
909: <code class="prompt">$</code> <strong class="userinput"><code>export CVSROOT CVS_RSH</code></strong>
910: </pre>
911: <p>Then, you change to the directory where you want to have
912: your copy of pkgsrc. In most cases this is
1.76 rillig 913: <code class="filename">/usr</code>. In that directory you run the
1.75 rillig 914: checkout command, which is <span><strong class="command">cvs -q checkout -P
915: pkgsrc</strong></span> for the current branch and <span><strong class="command">cvs -q
916: checkout -rpkgsrc-2006Q1 -P pkgsrc</strong></span> for the stable
917: branch. This command will create a directory called
1.76 rillig 918: <code class="filename">pkgsrc</code> with all the pkgsrc files in
1.75 rillig 919: it.</p>
920: </div>
921: </div>
922: <div class="sect1" lang="en">
923: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
924: <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
925: <p>The preferred way to keep pkgsrc up-to-date is via CVS
926: (which also works if you have first installed it via a tar
927: file). It saves bandwidth and hard disk activity, compared to
928: downloading the tar file again.</p>
929: <div class="sect2" lang="en">
930: <div class="titlepage"><div><div><h3 class="title">
931: <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
932: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
933: <h3 class="title">Warning</h3>
1.77 rillig 934: <p>When updating from a tar file, you first need to
935: completely remove the old pkgsrc directory. Otherwise those
936: files that have been removed from pkgsrc in the mean time will
937: not be removed on your local disk, resulting in inconsistencies.
938: When removing the old files, any changes that you have done to
939: the pkgsrc files will be lost after updating. Therefore updating
940: via CVS is strongly recommended.</p>
1.75 rillig 941: </div>
1.82 ! rillig 942: <p>Note that by default the distfiles and the binary packages
! 943: are saved in the pkgsrc tree, so don't forget to rescue them
! 944: before updating. You can also configure pkgsrc to use other than
! 945: the default directories by setting the
! 946: <code class="varname">DISTDIR</code> and <code class="varname">PACKAGES</code>
! 947: variables. See <a href="#configuring" title="Chapter 5. Configuring pkgsrc">Chapter 5, <i>Configuring pkgsrc</i></a> for the details.</p>
1.75 rillig 948: <p>To update pkgsrc from a tar file, download the tar file as
949: explained above. Then, make sure that you have not made any
950: changes to the files in the pkgsrc directory. Remove the pkgsrc
951: directory and extract the new tar file. Done.</p>
952: </div>
953: <div class="sect2" lang="en">
954: <div class="titlepage"><div><div><h3 class="title">
955: <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
956: <p>To update pkgsrc via CVS, make sure the environment
957: variable <code class="varname">CVS_RSH</code> is set as above. Then,
958: change to the pkgsrc directory and run <span><strong class="command">cvs -q update
1.77 rillig 959: -dP</strong></span>.</p>
1.75 rillig 960: <div class="sect3" lang="en">
961: <div class="titlepage"><div><div><h4 class="title">
962: <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
963: <p>When updating pkgsrc, the CVS program keeps track of the
964: branch you selected. But if you, for whatever reason, want to
965: switch from the stable branch to the current one, you can do it
966: by adding the option “<span class="quote">-A</span>” after the
967: “<span class="quote">update</span>” keyword. To switch from the current branch
968: back to the stable branch, add the
969: “<span class="quote">-rpkgsrc-2006Q1</span>” option.</p>
970: </div>
971: <div class="sect3" lang="en">
972: <div class="titlepage"><div><div><h4 class="title">
973: <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
974: <p>When you update pkgsrc, the CVS program will only touch
975: those files that are registered in the CVS repository. That
976: means that any packages that you created on your own will stay
977: unmodified. If you change files that are managed by CVS, later
978: updates will try to merge your changes with those that have been
979: done by others. See the CVS manual, chapter
980: “<span class="quote">update</span>” for details.</p>
981: </div>
982: </div>
983: </div>
984: </div>
985: <div class="chapter" lang="en">
986: <div class="titlepage"><div><div><h2 class="title">
987: <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
988: <div class="toc">
989: <p><b>Table of Contents</b></p>
990: <dl>
1.82 ! rillig 991: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
! 992: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
! 993: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
! 994: <dd><dl>
! 995: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
! 996: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
! 997: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
! 998: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
! 999: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
! 1000: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
! 1001: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75 rillig 1002: </dl></dd>
1003: </dl>
1004: </div>
1005: <div class="sect1" lang="en">
1006: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82 ! rillig 1007: <a name="binarydist"></a>3.1. Binary distribution</h2></div></div></div>
! 1008: <p>
! 1009: We provide a bootstrap kit in both source and binary form for other
! 1010: platforms than NetBSD, consisting of the pkg administration tools and other
! 1011: tools required to use pkgsrc and build packages.
! 1012: </p>
! 1013: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
! 1014: <h3 class="title">Note</h3>
! 1015: <p>
! 1016: Older binary snapshots are available in the
! 1017: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/archive/" target="_top">bootstrap-pkgsrc/archive</a>
! 1018: directory on ftp.NetBSD.org.</p>
! 1019: </div>
! 1020: <div class="table">
! 1021: <a name="binary-kits"></a><p class="title"><b>Table 3.1. Binary kits and available packages</b></p>
! 1022: <table summary="Binary kits and available packages" border="1">
! 1023: <colgroup>
! 1024: <col>
! 1025: <col>
! 1026: <col>
! 1027: <col>
! 1028: </colgroup>
! 1029: <thead><tr>
! 1030: <th>Platform</th>
! 1031: <th>Latest snapshot</th>
! 1032: <th>Binary kit</th>
! 1033: <th>Binary packages</th>
! 1034: </tr></thead>
! 1035: <tbody>
! 1036: <tr>
! 1037: <td class="osname">Darwin 5.5/powerpc (Mac OS X 10.1.5)</td>
! 1038: <td class="date">20021209</td>
! 1039: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-5.5-powerpc-20021209.tar.gz" target="_top">binary kit</a></td>
! 1040: <td class="binary-pkgs-url"> </td>
! 1041: </tr>
! 1042: <tr>
! 1043: <td class="osname">Darwin 6.6/powerpc (Mac OS X 10.2.6)</td>
! 1044: <td class="date">20030623</td>
! 1045: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-6.6-powerpc-20030623.tar.gz" target="_top">binary kit</a></td>
! 1046: <td class="binary-pkgs-url"> </td>
! 1047: </tr>
! 1048: <tr>
! 1049: <td class="osname">Darwin 7.6/powerpc (Mac OS X 10.3.6)</td>
! 1050: <td class="date">20041219</td>
! 1051: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-7.6.0-powerpc-20041219.tar.gz" target="_top">binary kit</a></td>
! 1052: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/Darwin-7.6/" target="_top">binary packages</a></td>
! 1053: </tr>
! 1054: <tr>
! 1055: <td class="osname">Darwin 7.8/powerpc (Mac OS X 10.3.8)</td>
! 1056: <td class="date">20050320</td>
! 1057: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-7.8.0-powerpc-20050320.tar.gz" target="_top">binary kit</a></td>
! 1058: <td class="binary-pkgs-url"> </td>
! 1059: </tr>
! 1060: <tr>
! 1061: <td class="osname">Darwin 8.1/powerpc (Mac OS X 10.4.1)</td>
! 1062: <td class="date">20050625</td>
! 1063: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-8.1.0-powerpc-20050625.tar.gz" target="_top">binary kit</a></td>
! 1064: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/Darwin-8.1/powerpc/current/" target="_top">binary packages</a></td>
! 1065: </tr>
! 1066: <tr>
! 1067: <td class="osname">Debian GNU Linux/i386</td>
! 1068: <td class="date">20031023</td>
! 1069: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.4.22-debian-i386-20031023.tar.gz" target="_top">binary kit</a></td>
! 1070: <td class="binary-pkgs-url"> </td>
! 1071: </tr>
! 1072: <tr>
! 1073: <td class="osname">Fedora Core 2 Linux/i386</td>
! 1074: <td class="date">20050618</td>
! 1075: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.6.10-i386-fc2-20050618.tar.gz" target="_top">binary kit</a></td>
! 1076: <td class="binary-pkgs-url"> </td>
! 1077: </tr>
! 1078: <tr>
! 1079: <td class="osname">Fedora Core 4 Linux/i386</td>
! 1080: <td class="date">20060105</td>
! 1081: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.6.11-i386-fc4-20060105.tar.gz" target="_top">binary kit</a></td>
! 1082: <td class="binary-pkgs-url"> </td>
! 1083: </tr>
! 1084: <tr>
! 1085: <td class="osname">FreeBSD 3.5/i386</td>
! 1086: <td class="date">20030411</td>
! 1087: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-3.5-STABLE-i386-20030411.tar.gz" target="_top">binary kit</a></td>
! 1088: <td class="binary-pkgs-url"> </td>
! 1089: </tr>
! 1090: <tr>
! 1091: <td class="osname">FreeBSD 4.7/i386</td>
! 1092: <td class="date">20021211</td>
! 1093: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-4.7-RELEASE-i386-20021211.tar.gz" target="_top">binary kit</a></td>
! 1094: <td class="binary-pkgs-url"> </td>
! 1095: </tr>
! 1096: <tr>
! 1097: <td class="osname">FreeBSD 5.0/i386</td>
! 1098: <td class="date">20030411</td>
! 1099: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-5.0-RELEASE-i386-20030411.tar.gz" target="_top">binary kit</a></td>
! 1100: <td class="binary-pkgs-url"> </td>
! 1101: </tr>
! 1102: <tr>
! 1103: <td class="osname">FreeBSD 5.1/i386</td>
! 1104: <td class="date">20030630</td>
! 1105: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-5.1-RELEASE-i386-20030630.tar.gz" target="_top">binary kit</a></td>
! 1106: <td class="binary-pkgs-url"> </td>
! 1107: </tr>
! 1108: <tr>
! 1109: <td class="osname">FreeBSD 5.2.1/i386</td>
! 1110: <td class="date">20040227</td>
! 1111: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-5.2.1-RELEASE-i386-20040227.tar.gz" target="_top">binary kit</a></td>
! 1112: <td class="binary-pkgs-url"> </td>
! 1113: </tr>
! 1114: <tr>
! 1115: <td class="osname">FreeBSD 5.3/i386</td>
! 1116: <td class="date">20050119</td>
! 1117: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-5.3-RELEASE-i386-20050119.tar" target="_top">binary kit</a></td>
! 1118: <td class="binary-pkgs-url"> </td>
! 1119: </tr>
! 1120: <tr>
! 1121: <td class="osname">Interix 3.5</td>
! 1122: <td class="date">20051010</td>
! 1123: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Interix-3.5-i386-20051010.tar.gz" target="_top">binary kit</a></td>
! 1124: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/Interix-3.5/i386/current/" target="_top">binary packages</a></td>
! 1125: </tr>
! 1126: <tr>
! 1127: <td class="osname">IRIX 6.5 n32-bit ABI</td>
! 1128: <td class="date">20040911</td>
! 1129: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-IRIX-6.5-mips-20040911.tar.gz" target="_top">binary kit</a></td>
! 1130: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/n32/" target="_top">binary packages</a></td>
! 1131: </tr>
! 1132: <tr>
! 1133: <td class="osname">IRIX 6.5 64-bit ABI</td>
! 1134: <td class="date">20040912</td>
! 1135: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-IRIX64-6.5-mips-20040912.tar.gz" target="_top">binary kit</a></td>
! 1136: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/64/" target="_top">binary packages</a></td>
! 1137: </tr>
! 1138: <tr>
! 1139: <td class="osname">OpenBSD 3.2/i386</td>
! 1140: <td class="date">20030420</td>
! 1141: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-OpenBSD-3.2-i386-20030420.tar.gz" target="_top">binary kit</a></td>
! 1142: <td class="binary-pkgs-url"> </td>
! 1143: </tr>
! 1144: <tr>
! 1145: <td class="osname">OpenBSD 3.3/i386</td>
! 1146: <td class="date">20030503</td>
! 1147: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-OpenBSD-3.3-i386-20030503.tar.gz" target="_top">binary kit</a></td>
! 1148: <td class="binary-pkgs-url"> </td>
! 1149: </tr>
! 1150: <tr>
! 1151: <td class="osname">OpenBSD 3.5/i386</td>
! 1152: <td class="date">20040507</td>
! 1153: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-OpenBSD-3.5-i386-20040703.tar.gz" target="_top">binary kit</a></td>
! 1154: <td class="binary-pkgs-url"> </td>
! 1155: </tr>
! 1156: <tr>
! 1157: <td class="osname">Slackware Linux 8.1/i386</td>
! 1158: <td class="date">20030417</td>
! 1159: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.4.18-slackware-20030417.tar.gz" target="_top">binary kit</a></td>
! 1160: <td class="binary-pkgs-url"> </td>
! 1161: </tr>
! 1162: <tr>
! 1163: <td class="osname">Slackware Linux 9/i386</td>
! 1164: <td class="date">20031023</td>
! 1165: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.4.22-i386-slackware9-20040703.tar.gz" target="_top">binary kit</a></td>
! 1166: <td class="binary-pkgs-url"> </td>
! 1167: </tr>
! 1168: <tr>
! 1169: <td class="osname">Solaris 8/sparc</td>
! 1170: <td class="date">20050220</td>
! 1171: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-SunOS-5.8-sparc-20050220.tar.gz" target="_top">binary kit</a></td>
! 1172: <td class="binary-pkgs-url"> </td>
! 1173: </tr>
! 1174: <tr>
! 1175: <td class="osname">Solaris 8/i386</td>
! 1176: <td class="date">20050220</td>
! 1177: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-SunOS-5.8-i386-20050220.tar.gz" target="_top">binary kit</a></td>
! 1178: <td class="binary-pkgs-url"> </td>
! 1179: </tr>
! 1180: <tr>
! 1181: <td class="osname">Solaris 9/sparc</td>
! 1182: <td class="date">20041208</td>
! 1183: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-SunOS-5.9-sparc-20041208.tar.gz" target="_top">binary kit</a></td>
! 1184: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/SunOS-5.9/sparc/" target="_top">binary packages</a></td>
! 1185: </tr>
! 1186: <tr>
! 1187: <td class="osname">Solaris 9/i386</td>
! 1188: <td class="date">20030411</td>
! 1189: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-SunOS-5.9-i386-20030411.tar.gz" target="_top">binary kit</a></td>
! 1190: <td class="binary-pkgs-url"> </td>
! 1191: </tr>
! 1192: </tbody>
! 1193: </table>
! 1194: </div>
! 1195: <p>
! 1196: Simply download the binary kit for your platform, and extract it into
! 1197: <code class="filename">/</code> e.g.
! 1198: </p>
! 1199: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
! 1200: <code class="prompt">#</code> <strong class="userinput"><code>gzip -c -d /tmp/bootstrap-pkgsrc-SunOS-5.9-sparc-20031023.tar.gz \
! 1201: | tar -xpf -</code></strong></pre>
! 1202: <p>
! 1203: Of course, as with any binary distributions, you should verify the
! 1204: checksum against the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/SUM" target="_top">SUM</a>
! 1205: or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/CKSUM" target="_top">CKSUM</a>
! 1206: file and inspect the contents before extracting it.
! 1207: </p>
! 1208: </div>
! 1209: <div class="sect1" lang="en">
! 1210: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 1211: <a name="bootstrapping-pkgsrc"></a>3.2. Bootstrapping pkgsrc</h2></div></div></div>
! 1212: <p>Installing the bootstrap kit from source should be as simple as:</p>
1.75 rillig 1213: <pre class="screen">
1214: <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
1215: <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1216: <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong></pre>
1217: <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
1218: pkgsrc before bootstrapping. The given
1219: <span><strong class="command">bootstrap</strong></span> command will use the defaults of
1.76 rillig 1220: <code class="filename">/usr/pkg</code> for the
1.75 rillig 1221: <span class="emphasis"><em>prefix</em></span> where programs will be installed in,
1.76 rillig 1222: and <code class="filename">/var/db/pkg</code> for the package database
1.75 rillig 1223: directory where pkgsrc will do its internal bookkeeping.
1224: However, these can also be set using command-line
1225: arguments.</p>
1226: <p>Binary packages for the pkgsrc tools and an initial set of packages is
1227: available for supported platforms. An up-to-date list of these can be
1228: found on <a href="http://www.pkgsrc.org/" target="_top">www.pkgsrc.org</a>.
1229: Note that this only works for privileged builds that install
1.76 rillig 1230: into <code class="filename">/usr/pkg</code>.</p>
1.75 rillig 1231: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1232: <h3 class="title">Note</h3>
1233: <p>The bootstrap installs a <span><strong class="command">bmake</strong></span> tool.
1234: Use this <span><strong class="command">bmake</strong></span> when building via pkgsrc.
1235: For examples in this guide, use <span><strong class="command">bmake</strong></span>
1236: instead of “<span class="quote">make</span>”.</p>
1237: </div>
1238: </div>
1239: <div class="sect1" lang="en">
1240: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82 ! rillig 1241: <a name="platform-specific-notes"></a>3.3. Platform-specific notes</h2></div></div></div>
1.75 rillig 1242: <p>Here are some platform-specific notes you should be aware of.</p>
1243: <div class="sect2" lang="en">
1244: <div class="titlepage"><div><div><h3 class="title">
1.82 ! rillig 1245: <a name="darwin"></a>3.3.1. Darwin (Mac OS X)</h3></div></div></div>
1.75 rillig 1246: <p>Darwin 5.x and 6.x are supported. There are two methods of using
1.82 ! rillig 1247: pkgsrc on Mac OS X, by using a <a href="#platform.osx-image" title="3.3.1.1. Using a disk image">disk
! 1248: image</a>, or a <a href="#platform.osx-ufs" title="3.3.1.2. Using a UFS partition">UFS
1.75 rillig 1249: partition</a>.</p>
1250: <p>Before you start, you will need to download and install the Mac OS X Developer
1251: Tools from Apple's Developer Connection. See <a href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
1252: for details. Also, make sure you install X11 for Mac OS X and the X11 SDK
1253: from <a href="http://www.apple.com/macosx/x11/download/" target="_top">http://www.apple.com/macosx/x11/download/</a>
1254: if you intend to build packages that use the X11 Window System.</p>
1255: <p>If you already have a UFS partition, or have a spare partition
1256: that you can format as UFS, it is recommended to use that instead of
1257: the disk image. It'll be somewhat faster and will mount automatically
1258: at boot time, where you must manually mount a disk image.</p>
1259: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1260: <h3 class="title">Note</h3>
1261: <p>You cannot use a HFS+ file system for pkgsrc, because pkgsrc currently
1262: requires the file system to be case-sensitive, and HFS+ is not.</p>
1263: </div>
1264: <div class="sect3" lang="en">
1265: <div class="titlepage"><div><div><h4 class="title">
1.82 ! rillig 1266: <a name="platform.osx-image"></a>3.3.1.1. Using a disk image</h4></div></div></div>
1.75 rillig 1267: <p>Create the disk image:</p>
1268: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1269: <code class="prompt">#</code> <strong class="userinput"><code>./ufsdiskimage create ~/Documents/NetBSD 512</code></strong> # megabytes - season to taste
1270: <code class="prompt">#</code> <strong class="userinput"><code>./ufsdiskimage mount ~/Documents/NetBSD</code></strong>
1271: <code class="prompt">#</code> <strong class="userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong></pre>
1272: <p>That's it!</p>
1273: </div>
1274: <div class="sect3" lang="en">
1275: <div class="titlepage"><div><div><h4 class="title">
1.82 ! rillig 1276: <a name="platform.osx-ufs"></a>3.3.1.2. Using a UFS partition</h4></div></div></div>
1.76 rillig 1277: <p>By default, <code class="filename">/usr</code> will be on your root file
1.75 rillig 1278: system, normally HFS+. It is possible to use the default
1.76 rillig 1279: <span class="emphasis"><em>prefix</em></span> of <code class="filename">/usr/pkg</code>
1280: by symlinking <code class="filename">/usr/pkg</code> to a directory on a UFS
1.75 rillig 1281: file system. Obviously, another symlink is required if you want to
1282: place the package database directory outside the
1283: <span class="emphasis"><em>prefix</em></span>. e.g.</p>
1284: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb</code></strong></pre>
1285: <p>If you created your partitions at the time of installing Mac OS X
1286: and formatted the target partition as UFS, it should automatically
1.76 rillig 1287: mount on <code class="filename">/Volumes/<volume name></code> when the
1.75 rillig 1288: machine boots. If you are (re)formatting a partition as UFS, you need
1289: to ensure that the partition map correctly reflects
1290: “<span class="quote">Apple_UFS</span>” and not “<span class="quote">Apple_HFS</span>”.</p>
1291: <p>The problem is that none of the disk tools will let you touch a
1292: disk that is booted from. You can unmount the partition, but even if
1293: you newfs it, the partition type will be incorrect and the
1294: automounter won't mount it. It can be mounted manually, but it won't
1295: appear in Finder.</p>
1296: <p>You'll need to boot off of the OS X Installation (User) CD. When
1297: the Installation program starts, go up to the menu and select Disk
1298: Utility. Now, you will be able to select the partition you want
1299: to be UFS, and Format it Apple UFS. Quit the Disk Utility, quit the
1300: installer which will reboot your machine. The new UFS file system
1301: will appear in Finder.</p>
1302: <p>Be aware that the permissions on the new file system will be writable
1303: by root only.</p>
1304: <p>This note is as of 10.2 (Jaguar) and applies to earlier versions.
1305: Hopefully Apple will fix Disk Utility in 10.3 (Panther).</p>
1306: </div>
1307: </div>
1308: <div class="sect2" lang="en">
1309: <div class="titlepage"><div><div><h3 class="title">
1.82 ! rillig 1310: <a name="freebsd"></a>3.3.2. FreeBSD</h3></div></div></div>
1.75 rillig 1311: <p>
1312: FreeBSD 4.7 and 5.0 have been tested and are supported, other versions
1313: may work.</p>
1314: <p>Care should be taken so that the tools that this kit installs do not conflict
1315: with the FreeBSD userland tools. There are several steps:</p>
1316: <div class="orderedlist"><ol type="1">
1317: <li><p>FreeBSD stores its ports pkg database in
1.76 rillig 1318: <code class="filename">/var/db/pkg</code>. It is therefore
1.75 rillig 1319: recommended that you choose a different location (e.g.
1.76 rillig 1320: <code class="filename">/usr/pkgdb</code>) by
1.75 rillig 1321: using the --pkgdbdir option to the bootstrap script.</p></li>
1322: <li>
1323: <p>If you do not intend to use the FreeBSD ports tools, it's probably a
1324: good idea to move them out of the way to avoid confusion, e.g.</p>
1325: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1326: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1327: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1328: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1329: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
1330: </li>
1.76 rillig 1331: <li><p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1332: <code class="filename">/etc/mk.conf.example</code> file
1.75 rillig 1333: when you use the bootstrap script.</p></li>
1334: </ol></div>
1335: </div>
1336: <div class="sect2" lang="en">
1337: <div class="titlepage"><div><div><h3 class="title">
1.82 ! rillig 1338: <a name="interix"></a>3.3.3. Interix</h3></div></div></div>
1.75 rillig 1339: <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
1340: providing a Unix-like environment with a tighter kernel integration than
1341: available with Cygwin. It is part of the Windows Services for Unix
1342: package, available for free for any licensed copy of Windows 2000, XP
1343: (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>
1344: <p>Services for Unix 3.5, current as of this writing, has been tested. 3.0
1345: or 3.1 may work, but are not officially supported. (The main difference
1346: in 3.0/3.1 is lack of pthreads.)</p>
1347: <div class="sect3" lang="en">
1348: <div class="titlepage"><div><div><h4 class="title">
1.82 ! rillig 1349: <a name="platform.interix-sfu-install"></a>3.3.3.1. When installing Interix/SFU</h4></div></div></div>
1.75 rillig 1350: <p>At an absolute minimum, the following packages must be installed from
1351: the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
1352: <div class="itemizedlist"><ul type="disc">
1353: <li><p>Utilities -> Base Utilities</p></li>
1354: <li><p>Interix GNU Components -> (all)</p></li>
1355: <li><p>Remote Connectivity</p></li>
1356: <li><p>Interix SDK</p></li>
1357: </ul></div>
1358: <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
1359: "UNIX Perl". That is Perl 5.6 without shared module support, installed to
1360: /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
1361: pkgsrc (or from a binary package).</p>
1362: <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
1363: not need to be installed, but Remote Connectivity itself should be
1364: installed in order to have a working inetd.</p>
1365: <p>During installation you may be asked whether to enable setuid
1366: behavior for Interix programs, and whether to make pathnames default to
1367: case-sensitive. Setuid should be enabled, and case-sensitivity MUST be
1368: enabled. (Without case-sensitivity, a large number of packages including
1369: perl will not build.)</p>
1370: <p>NOTE: Newer Windows service packs change the way binary execution
1371: works (via the Data Execution Prevention feature). In order to use
1372: pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
1373: POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
1374: must be installed. Hotfixes are available from Microsoft through a
1375: support contract; however, a NetBSD developer has made most Interix
1376: 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>
1377: </div>
1378: <div class="sect3" lang="en">
1379: <div class="titlepage"><div><div><h4 class="title">
1.82 ! rillig 1380: <a name="platform.interix-sfu-postinstall"></a>3.3.3.2. What to do if Interix/SFU is already installed</h4></div></div></div>
1.75 rillig 1381: <p>If SFU is already installed and you wish to alter these settings to work
1382: with pkgsrc, note the following things.</p>
1383: <div class="itemizedlist"><ul type="disc">
1384: <li><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
1385: Windows Services for UNIX, then click Change. In the installer, choose
1386: Add or Remove, then uncheck Utilities->UNIX Perl.</p></li>
1387: <li>
1388: <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
1389: change the following registry key:</p>
1390: <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
1391: <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
1392: </li>
1393: <li>
1394: <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
1395: following registry key:</p>
1396: <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
1397: <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
1398: </li>
1399: </ul></div>
1400: </div>
1401: <div class="sect3" lang="en">
1402: <div class="titlepage"><div><div><h4 class="title">
1.82 ! rillig 1403: <a name="platform.interix-notes"></a>3.3.3.3. Important notes for using pkgsrc</h4></div></div></div>
1.75 rillig 1404: <p>The package manager (either the pkgsrc "su" user, or the user
1405: running "pkg_add") must be a member of the local Administrators
1406: group. Such a user must also be used to run the bootstrap. This is
1407: slightly relaxed from the normal pkgsrc requirement of "root".</p>
1408: <p>The package manager should use a umask of 002. "make install" will
1409: automatically complain if this is not the case. This ensures that
1410: directories written in /var/db/pkg are Administrators-group writeable.</p>
1411: <p>The popular Interix binary packages from http://www.interopsystems.com/
1412: use an older version of pkgsrc's pkg_* tools. Ideally, these should
1413: NOT be used in conjunction with pkgsrc. If you choose to use them at
1414: the same time as the pkgsrc packages, ensure that you use the proper
1415: pkg_* tools for each type of binary package.</p>
1416: <p>The TERM setting used for DOS-type console windows (including those
1417: invoked by the csh and ksh startup shortcuts) is "interix". Most systems
1418: don't have a termcap/terminfo entry for it, but the following .termcap
1419: entry provides adequate emulation in most cases:</p>
1420: <pre class="programlisting">
1421: interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
1422: </pre>
1423: </div>
1424: <div class="sect3" lang="en">
1425: <div class="titlepage"><div><div><h4 class="title">
1.82 ! rillig 1426: <a name="platform.interix-limits"></a>3.3.3.4. Limitations of the Interix platform</h4></div></div></div>
1.75 rillig 1427: <p>Though Interix suffices as a familiar and flexible substitute
1428: for a full Unix-like platform, it has some drawbacks that should
1429: be noted for those desiring to make the most of Interix.</p>
1430: <div class="itemizedlist"><ul type="disc">
1431: <li>
1432: <p><span class="strong"><strong>X11:</strong></span></p>
1433: <p>Interix comes with the standard set of X11R6 client libraries,
1434: and can run X11 based applications, but it does
1435: <span class="emphasis"><em>not</em></span> come with an X server. Some options are
1436: <a href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
1437: <a href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
1438: (available in a trimmed version for Interix from Interop Systems as the
1439: <a href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
1440: and the free X11 server included with
1441: <a href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
1442: <p>Also, StarNet Communications has graciously provided a free
1443: version of their X-Win32 product that accepts connections only
1444: from localhost:
1445: <a href="http://www.starnet.com/xwin32LX/get_xwin32LX.htm" target="_top">X-Win32 LX</a>,
1446: recommended by the maintainer of Interix pkgsrc support.</p>
1447: </li>
1448: <li>
1449: <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
1450: <p>Because Interix runs in a completely different NT subsystem from
1451: Win32 applications, it does not currently support various X11
1452: protocol extensions for acceleration (such as MIT-SHM or DGA).
1453: Most interactive applications to a local X server will run
1454: reasonably fast, but full motion video and other graphics
1455: intensive applications may require a faster-than-expected CPU.</p>
1456: </li>
1457: <li>
1458: <p><span class="strong"><strong>Audio:</strong></span></p>
1459: <p>Interix has no native support for audio output. For audio
1460: support, pkgsrc uses the <span><strong class="command">esound</strong></span> client/server
1461: audio system on Interix. Unlike on most platforms, the
1.76 rillig 1462: <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 1463: <span class="emphasis"><em>not</em></span> contain the <span><strong class="command">esd</strong></span>
1464: server component. To output audio via an Interix host, the
1.76 rillig 1465: <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 1466: must also be installed.</p>
1467: </li>
1468: <li>
1469: <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
1470: <p>Direct device access is not currently supported in Interix, so it
1471: is not currently possible to access CD/DVD drives, USB devices,
1472: or SCSI devices through non-filesystem means. Among other things,
1473: this makes it impossible to use Interix directly for CD/DVD
1474: burning.</p>
1475: </li>
1476: <li>
1477: <p><span class="strong"><strong>Tape drives:</strong></span></p>
1478: <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
1479: drives are also not directly accessible in Interix. However,
1480: support is in work to make tape drive access possible by using
1481: Cygwin as a bridge (similarly to audio bridged via Cygwin's
1482: esound server).</p>
1483: </li>
1484: </ul></div>
1485: </div>
1486: <div class="sect3" lang="en">
1487: <div class="titlepage"><div><div><h4 class="title">
1.82 ! rillig 1488: <a name="platform.interix-knownissues"></a>3.3.3.5. Known issues for pkgsrc on Interix</h4></div></div></div>
1.75 rillig 1489: <p>It is not necessary, in general, to have a "root" user on the
1490: Windows system; any member of the local Administrators group will
1491: suffice. However, some packages currently assume that the user
1492: named "root" is the privileged user. To accommodate these, you
1493: may create such a user; make sure it is in the local group
1494: Administrators (or your language equivalent).</p>
1495: <p>"pkg_add" creates directories of mode 0755, not 0775, in
1496: $PKG_DBDIR. For the time being, install packages as the local
1497: Administrator (or your language equivalent), or run the following
1498: command after installing a package to work around the issue:</p>
1499: <pre class="screen">
1500: <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong></pre>
1501: </div>
1502: </div>
1503: <div class="sect2" lang="en">
1504: <div class="titlepage"><div><div><h3 class="title">
1.82 ! rillig 1505: <a name="irix"></a>3.3.4. IRIX</h3></div></div></div>
1.75 rillig 1506: <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
1507: compiler (cc/c89). Please set the <code class="varname">CC</code> environment variable
1508: according to your preference. If you do not have a license for the MIPSpro
1509: compiler suite, you can download a gcc tardist file from <a href="http://freeware.sgi.com/" target="_top">http://freeware.sgi.com/</a>.</p>
1510: <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
1511: 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>,
1512: etc.</p>
1513: <p>At this point in time, pkgsrc only supports one ABI at a time. That is, you can not
1514: switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI. If
1515: you start out using "abi=n32", that's what all your packages will be built
1516: with.</p>
1517: <p>Therefore, please make sure that you have no conflicting
1518: <code class="varname">CFLAGS</code> in your environment or the
1.76 rillig 1519: <code class="filename">/etc/mk.conf</code>. Particularly, make sure that you do not
1.75 rillig 1520: try to link n32 object files with lib64 or vice versa. Check your
1.76 rillig 1521: <code class="filename">/etc/compiler.defaults</code>!</p>
1.75 rillig 1522: <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
1523: please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
1524: as it appears that IRIX linker occasionally runs into issues when trying to
1525: link over a network-mounted file system.</p>
1526: <p>The bootstrapping process should set all the right options for programs such
1527: as imake(1), but you may want to set some options depending on your local
1.76 rillig 1528: setup. Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
1.75 rillig 1529: course, your compiler's man pages for details.</p>
1530: <p>If you are using SGI's MIPSPro compiler, please set
1.1 grant 1531:
1.75 rillig 1532: </p>
1533: <pre class="programlisting">
1534: PKGSRC_COMPILER= mipspro
1535: </pre>
1536: <p>
1.1 grant 1537:
1.76 rillig 1538: in <code class="filename">/etc/mk.conf</code>. Otherwise, pkgsrc will assume you
1.75 rillig 1539: are using gcc and may end up passing invalid flags to the compiler. Note that
1.76 rillig 1540: bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
1.75 rillig 1541: default.</p>
1542: <p>If you have both the MIPSPro compiler chain installed as well as gcc,
1543: but want to make sure that MIPRPro is used, please set your <code class="varname">PATH</code>
1544: to <span class="emphasis"><em>not</em></span> include the location of gcc (often
1.76 rillig 1545: <code class="filename">/usr/freeware/bin</code>), and (important) pass the
1.75 rillig 1546: '--preserve-path' flag.</p>
1547: </div>
1548: <div class="sect2" lang="en">
1549: <div class="titlepage"><div><div><h3 class="title">
1.82 ! rillig 1550: <a name="linux"></a>3.3.5. Linux</h3></div></div></div>
1.75 rillig 1551: <p>
1552: Some versions of Linux (for example Debian GNU/Linux) need either
1553: libtermcap or libcurses (libncurses). Installing the distributions
1554: libncurses-dev package (or equivalent) should fix the problem.</p>
1555: <p>
1556: pkgsrc supports both gcc (GNU Compiler Collection) and icc (Intel C++
1557: Compiler). gcc is the default. icc 8.0 and 8.1 on i386 have been tested.
1558: </p>
1559: <p>To bootstrap using icc, assuming the default icc installation
1560: directory:</p>
1561: <pre class="programlisting">
1562: env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
1563: ac_cv___attribute__=yes ./bootstrap
1564: </pre>
1565: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1566: <h3 class="title">Note</h3>
1567: <p>icc 8.1 needs the `-i-static' argument instead of -static-libcxa.</p>
1568: </div>
1569: <p>icc supports __attribute__, but the GNU configure test uses a nested
1570: function, which icc does not support. #undef'ing __attribute__ has the
1571: unfortunate side-effect of breaking many of the Linux header files, which
1572: cannot be compiled properly without __attribute__. The test must be
1573: overridden so that __attribute__ is assumed supported by the
1574: compiler.</p>
1575: <p>After bootstrapping, you should set <code class="varname">PKGSRC_COMPILER</code>
1.76 rillig 1576: in <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1577: <pre class="programlisting">
1578: PKGSRC_COMPILER= icc
1579: </pre>
1580: <p>The default installation directory for icc is
1.76 rillig 1581: <code class="filename">/opt/intel_cc_80</code>, which
1.75 rillig 1582: is also the pkgsrc default. If you have installed it into a different
1583: directory, set <code class="varname">ICCBASE</code> in
1.76 rillig 1584: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1585: <pre class="programlisting">
1586: ICCBASE= /opt/icc
1587: </pre>
1588: <p>pkgsrc uses the static linking method of the runtime libraries
1589: provided by icc, so binaries can be run on other systems which do not
1590: have the shared libraries installed.</p>
1591: <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>
1592: command run when linking a C++ shared library and records it, throwing
1593: away the -Bstatic and -Bdynamic options interspersed between the libraries.
1594: This means that libtool-linked C++ shared libraries will have a
1595: runtime dependency on the icc libraries until this is fixed in libtool.
1596: </p>
1597: </div>
1598: <div class="sect2" lang="en">
1599: <div class="titlepage"><div><div><h3 class="title">
1.82 ! rillig 1600: <a name="openbsd"></a>3.3.6. OpenBSD</h3></div></div></div>
1.75 rillig 1601: <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
1602: <p>Care should be taken so that the tools that this kit installs do not conflict
1603: with the OpenBSD userland tools. There are several steps:</p>
1604: <div class="orderedlist"><ol type="1">
1605: <li><p>OpenBSD stores its ports pkg database in
1.76 rillig 1606: <code class="filename">/var/db/pkg</code>. It is therefore
1.75 rillig 1607: recommended that you choose a different location (e.g.
1.76 rillig 1608: <code class="filename">/usr/pkgdb</code>) by
1.75 rillig 1609: using the --pkgdbdir option to the bootstrap script.</p></li>
1610: <li>
1611: <p>If you do not intend to use the OpenBSD ports tools, it's probably a
1612: good idea to move them out of the way to avoid confusion, e.g.</p>
1613: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1614: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1615: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1616: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1617: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
1618: </li>
1619: <li>
1.76 rillig 1620: <p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1621: <code class="filename">/etc/mk.conf.example</code> file
1.75 rillig 1622: when you use the bootstrap script. OpenBSD's make program uses
1.76 rillig 1623: <code class="filename">/etc/mk.conf</code>
1.75 rillig 1624: as well. You can work around this by enclosing all the pkgsrc-specific parts
1625: of the file with:</p>
1626: <pre class="programlisting">
1627: .ifdef BSD_PKG_MK
1628: # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
1629: .else
1630: # OpenBSD stuff
1.1 grant 1631: .endif
1632: </pre>
1.75 rillig 1633: </li>
1634: </ol></div>
1635: </div>
1636: <div class="sect2" lang="en">
1637: <div class="titlepage"><div><div><h3 class="title">
1.82 ! rillig 1638: <a name="solaris"></a>3.3.7. Solaris</h3></div></div></div>
1.75 rillig 1639: <p>Solaris 2.6 through 9 are supported on both x86 and sparc.
1640: You will need a working C compiler. Both gcc 2.95.3 and
1641: Sun WorkShop 5 have been tested.</p>
1642: <p>The following packages are required on Solaris 8 for the bootstrap
1643: process and to build packages.</p>
1644: <div class="itemizedlist"><ul type="disc">
1645: <li><p>SUNWsprot</p></li>
1646: <li><p>SUNWarc</p></li>
1647: <li><p>SUNWbtool</p></li>
1648: <li><p>SUNWtoo</p></li>
1649: <li><p>SUNWlibm</p></li>
1650: </ul></div>
1.78 rillig 1651: <p>Please note that the use of GNU binutils on Solaris is
1652: <span class="emphasis"><em>not</em></span> supported, as of June 2006.</p>
1.75 rillig 1653: <p>Whichever compiler you use, please ensure the compiler tools and
1654: your $prefix are in your <code class="varname">PATH</code>. This includes
1.76 rillig 1655: <code class="filename">/usr/ccs/{bin,lib}</code>
1656: and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1.75 rillig 1657: <div class="sect3" lang="en">
1658: <div class="titlepage"><div><div><h4 class="title">
1.82 ! rillig 1659: <a name="solaris-gcc-note"></a>3.3.7.1. If you are using gcc</h4></div></div></div>
1.75 rillig 1660: <p>It makes life much simpler if you only use the same gcc consistently
1661: for building all packages.</p>
1662: <p>It is recommended that an external gcc be used only for bootstrapping,
1663: then either build gcc from
1.76 rillig 1664: <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 1665: package, then remove gcc used during bootstrapping.</p>
1666: <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>
1667: </div>
1668: <div class="sect3" lang="en">
1669: <div class="titlepage"><div><div><h4 class="title">
1.82 ! rillig 1670: <a name="solaris-sun-workshop-note"></a>3.3.7.2. If you are using Sun WorkShop</h4></div></div></div>
1.75 rillig 1671: <p>You will need at least the following packages installed (from WorkShop
1672: 5.0)</p>
1673: <div class="itemizedlist"><ul type="disc">
1674: <li><p>SPROcc
1675: - Sun WorkShop Compiler C 5.0</p></li>
1676: <li><p>SPROcpl
1677: - Sun WorkShop Compiler C++ 5.0</p></li>
1678: <li><p>SPROild
1679: - Sun WorkShop Incremental Linker</p></li>
1680: <li><p>SPROlang
1681: - Sun WorkShop Compilers common components</p></li>
1682: </ul></div>
1683: <p>You should set <code class="varname">CC</code>, <code class="varname">CXX</code> and
1.76 rillig 1684: optionally, <code class="varname">CPP</code> in <code class="filename">/etc/mk.conf</code>,
1.75 rillig 1685: e.g.:</p>
1686: <pre class="programlisting">
1687: CC= cc
1688: CXX= CC
1689: CPP= /usr/ccs/lib/cpp
1.1 grant 1690: </pre>
1.75 rillig 1691: </div>
1692: <div class="sect3" lang="en">
1693: <div class="titlepage"><div><div><h4 class="title">
1.82 ! rillig 1694: <a name="solaris-sunpro-64"></a>3.3.7.3. Buildling 64-bit binaries with SunPro</h4></div></div></div>
1.75 rillig 1695: <p>Building 64-bit binaries is a little trickier. First, you
1696: need to bootstrap pkgsrc in 64-bit mode. One problem here is
1697: that while building one of the programs in the bootstrap kit
1.76 rillig 1698: (<code class="filename">bmake</code>), the <code class="varname">CFLAGS</code>
1.75 rillig 1699: variable is not honored, even if it is set in the environment.
1700: To work around this bug, you can create a simple shell script
1.76 rillig 1701: called <code class="filename">cc64</code> and put it somewhere in the
1.75 rillig 1702: <code class="varname">PATH</code>:</p>
1703: <pre class="programlisting">
1704: #! /bin/sh
1705: exec /opt/SUNWspro/bin/cc -xtarget=ultra -xarch=v9 ${1+"$@"}
1.1 grant 1706: </pre>
1.75 rillig 1707: <p>Then, pass the definition for <code class="varname">CC</code> in the
1708: environment of the <span><strong class="command">bootstrap</strong></span> command:</p>
1709: <pre class="programlisting">
1710: <code class="prompt">$</code> <strong class="userinput"><code>cd bootstrap</code></strong>
1711: <code class="prompt">$</code> <strong class="userinput"><code>CC=cc64 ./bootstrap</code></strong>
1712: </pre>
1713: <p>After bootstrapping, there are two alternative ways,
1714: depending on whether you want to find bugs in packages or get
1715: your system ready quickly. If you just want a running system,
1.76 rillig 1716: add the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1717: file:</p>
1718: <pre class="programlisting">
1719: CC= cc64
1720: CXX= CC64
1721: PKGSRC_COMPILER= sunpro
1.1 grant 1722: </pre>
1.75 rillig 1723: <p>This way, all calls to the compiler will be intercepted by
1724: the above wrapper and therefore get the necessary ABI options
1725: automatically. (Don't forget to create the shell script
1.76 rillig 1726: <code class="filename">CC64</code>, too.)</p>
1.75 rillig 1727: <p>To find packages that ignore the user-specified
1728: <code class="varname">CFLAGS</code> and <code class="varname">CXXFLAGS</code>, add
1.76 rillig 1729: the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1730: file:</p>
1731: <pre class="programlisting">
1732: CC= cc
1733: CXX= CC
1734: PKGSRC_COMPILER= sunpro
1735: CFLAGS= -xtarget=ultra -xarch=v9
1736: CXXFLAGS= -xtarget=ultra -xarch=v9
1737: LDFLAGS= -xtarget=ultra -xarch=v9
1.1 grant 1738: </pre>
1.75 rillig 1739: <p>Packages that don't use the flags provided in the
1740: configuration file will try to build 32-bit binaries and fail
1741: during linking. Detecting this is useful to prevent bugs on
1742: other platforms where the error would not show up but pass
1743: silently.</p>
1744: </div>
1745: <div class="sect3" lang="en">
1746: <div class="titlepage"><div><div><h4 class="title">
1.82 ! rillig 1747: <a name="plat.sunos.problems"></a>3.3.7.4. Common problems</h4></div></div></div>
1.75 rillig 1748: <p>Sometimes, when using <span><strong class="command">libtool</strong></span>,
1.76 rillig 1749: <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
1.75 rillig 1750: The workaround is to use another shell for the configure
1.76 rillig 1751: 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
1752: to your <code class="filename">mk.conf</code>:</p>
1.75 rillig 1753: <pre class="programlisting">
1754: CONFIG_SHELL= ${LOCALBASE}/bin/bash
1755: WRAPPER_SHELL= ${LOCALBASE}/bin/bash
1.1 grant 1756: </pre>
1.76 rillig 1757: <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 1758: </div>
1759: </div>
1760: </div>
1761: </div>
1762: <div class="chapter" lang="en">
1763: <div class="titlepage"><div><div><h2 class="title">
1764: <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
1765: <div class="toc">
1766: <p><b>Table of Contents</b></p>
1767: <dl>
1768: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
1769: <dd><dl>
1770: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
1771: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82 ! rillig 1772: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
! 1773: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
! 1774: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
! 1775: <dt><span class="sect2"><a href="#pkg_versions">4.1.6. Finding if newer versions of your installed packages are in pkgsrc</a></span></dt>
! 1776: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
! 1777: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75 rillig 1778: </dl></dd>
1779: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
1780: <dd><dl>
1781: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
1782: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
1783: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
1784: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
1785: </dl></dd>
1786: </dl>
1787: </div>
1788: <p>Basically, there are two ways of using pkgsrc. The first
1789: is to only install the package tools and to use binary packages
1790: that someone else has prepared. This is the “<span class="quote">pkg</span>”
1791: in pkgsrc. The second way is to install the “<span class="quote">src</span>”
1792: of pkgsrc, too. Then you are able to build your own packages,
1793: and you can still use binary packages from someone else.</p>
1794: <div class="sect1" lang="en">
1795: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1796: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
1797: <p>To use binary packages, you need some tools to manage
1798: them. On NetBSD, these tools are already installed. On all other
1799: operating systems, you need to install them first. For the
1800: following platforms, prebuilt versions of the package tools
1801: are available and can simply be downloaded and unpacked in the
1.76 rillig 1802: <code class="filename">/</code> directory:</p>
1.75 rillig 1803: <div class="informaltable">
1804: <a name="binary-bootstrap-kits"></a><table border="1">
1805: <colgroup>
1806: <col>
1807: <col>
1808: </colgroup>
1809: <thead><tr>
1810: <th>Platform</th>
1811: <th>URL</th>
1812: </tr></thead>
1813: <tbody>
1814: <tr>
1815: <td>Solaris 9</td>
1.76 rillig 1816: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1817: </tr>
1818: <tr>
1819: <td>Solaris 10</td>
1.76 rillig 1820: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1821: </tr>
1822: </tbody>
1823: </table>
1824: </div>
1.82 ! rillig 1825: <p>These pre-built package tools use
1.76 rillig 1826: <code class="filename">/usr/pkg</code> for the base directory, and
1827: <code class="filename">/var/db/pkg</code> for the database of installed
1.75 rillig 1828: packages. If you cannot use these directories for whatever
1829: reasons (maybe because you're not root), you have to build the
1.82 ! rillig 1830: package tools yourself, which is explained in <a href="#bootstrapping-pkgsrc" title="3.2. Bootstrapping pkgsrc">Section 3.2, “Bootstrapping pkgsrc”</a>.</p>
1.75 rillig 1831: <div class="sect2" lang="en">
1832: <div class="titlepage"><div><div><h3 class="title">
1833: <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
1834: <p>To install binary packages, you first need to know from
1835: where to get them. You can get them on CD-ROMs, DVDs, or via FTP
1836: or HTTP.</p>
1.81 rillig 1837: <p>The binary packages can be found at the following
1838: locations.</p>
1.75 rillig 1839: <div class="informaltable">
1840: <a name="binary-packages"></a><table border="1">
1841: <colgroup>
1842: <col>
1843: <col>
1844: </colgroup>
1845: <thead><tr>
1846: <th>Platform</th>
1847: <th>URL</th>
1848: </tr></thead>
1849: <tbody>
1850: <tr>
1.81 rillig 1851: <td>NetBSD</td>
1852: <td><code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/</code></td>
1853: </tr>
1854: <tr>
1.75 rillig 1855: <td>Solaris 9</td>
1.76 rillig 1856: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/</code></td>
1.75 rillig 1857: </tr>
1858: <tr>
1859: <td>Solaris 10</td>
1.76 rillig 1860: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/</code></td>
1.75 rillig 1861: </tr>
1862: </tbody>
1863: </table>
1864: </div>
1.81 rillig 1865: <p>Most of these directories contain binary packages for
1866: multiple platforms. Select the appropriate subdirectories,
1.75 rillig 1867: according to your machine architecture and operating system,
1.76 rillig 1868: until you find a directory called <code class="filename">All</code>. This
1.75 rillig 1869: directory contains all the binary packages. Further, there are
1870: subdirectories for categories that contain symbolic links that
1871: point to the actual binary package in
1.76 rillig 1872: <code class="filename">../All</code>. This directory layout is used for
1.75 rillig 1873: all package repositories, no matter if they are accessed via
1874: HTTP, FTP, NFS, CD-ROM, or the local filesystem.</p>
1875: </div>
1876: <div class="sect2" lang="en">
1877: <div class="titlepage"><div><div><h3 class="title">
1878: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
1879: <p> If you have the files on a CD-ROM or downloaded them to
1880: your hard disk, you can install them with the following command
1881: (be sure to <span><strong class="command">su</strong></span> to root first):</p>
1882: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add /path/to/package.tgz</code></strong></pre>
1883: <p> If you have FTP access and you don't want to download the
1884: packages via FTP prior to installation, you can do this
1885: automatically by giving <span><strong class="command">pkg_add</strong></span> an FTP URL:
1886: </p>
1.82 ! rillig 1887: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add ftp://ftp.NetBSD.org/pub/NetBSD/packages/<OSVERSION>/<ARCH>/All/package</code></strong></pre>
1.75 rillig 1888: <p>Note that any prerequisite packages needed to run the
1889: package in question will be installed, too, assuming they are
1890: present where you install from. </p>
1891: <p>To save some typing, you can set the
1892: <code class="varname">PKG_PATH</code> environment variable to a semicolon-separated
1893: list of paths (including remote URLs); trailing slashes are not allowed.
1894: </p>
1.76 rillig 1895: <p>Additionally to the <code class="filename">All</code> directory
1896: there exists a <code class="filename">vulnerable</code> directory to
1.75 rillig 1897: which binary packages with known vulnerabilities are
1898: moved, since removing them could cause missing dependencies. To
1.76 rillig 1899: use these packages, add the <code class="filename">vulnerable</code>
1.75 rillig 1900: directory to your <code class="varname">PKG_PATH</code>. However, you should run
1.76 rillig 1901: <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 1902: especially after installing new packages, and verify that the
1903: vulnerabilities are acceptable for your configuration. An example
1904: <code class="varname">PKG_PATH</code> would be:
1.76 rillig 1905: <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 1906: Please note that semicolon (';') is a shell meta-character, so
1907: you'll probably have to quote it.</p>
1908: <p>After you've installed packages, be sure to have
1.76 rillig 1909: <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
1.75 rillig 1910: <code class="varname">PATH</code> so you can actually start the just
1911: installed program. </p>
1912: </div>
1913: <div class="sect2" lang="en">
1914: <div class="titlepage"><div><div><h3 class="title">
1.82 ! rillig 1915: <a name="using.pkg_delete"></a>4.1.3. Deinstalling packages</h3></div></div></div>
! 1916: <p>To deinstall a package, it does not matter whether it was
! 1917: installed from source code or from a binary package. The
! 1918: <span><strong class="command">pkg_delete</strong></span> command does not know it anyway.
! 1919: To delete a package, you can just run <span><strong class="command">pkg_delete
! 1920: <em class="replaceable"><code>package-name</code></em></strong></span>. The package
! 1921: name can be given with or without version number. Wildcards can
! 1922: also be used to deinstall a set of packages, for example
! 1923: <code class="literal">*emacs*</code>. Be sure to include them in quotes,
! 1924: so that the shell does not expand them before
! 1925: <code class="literal">pkg_delete</code> sees them.</p>
! 1926: <p>The <code class="option">-r</code> option is very powerful: it
! 1927: removes all the packages that require the package in question
! 1928: and then removes the package itself. For example:
! 1929:
! 1930: </p>
! 1931: <pre class="screen">
! 1932: <code class="prompt">#</code> <strong class="userinput"><code>pkg_delete -r jpeg</code></strong>
! 1933: </pre>
! 1934: <p>
! 1935:
! 1936: will remove jpeg and all the packages that used it; this allows
! 1937: upgrading the jpeg package.</p>
! 1938: </div>
! 1939: <div class="sect2" lang="en">
! 1940: <div class="titlepage"><div><div><h3 class="title">
! 1941: <a name="using.pkg_info"></a>4.1.4. Getting information about installed packages</h3></div></div></div>
! 1942: <p>The <span><strong class="command">pkg_info</strong></span> shows information about
! 1943: installed packages or binary package files.</p>
! 1944: </div>
! 1945: <div class="sect2" lang="en">
! 1946: <div class="titlepage"><div><div><h3 class="title">
! 1947: <a name="vulnerabilities"></a>4.1.5. Checking for security vulnerabilities in installed packages</h3></div></div></div>
! 1948: <p>
! 1949: The NetBSD Security-Officer and Packages Groups maintain a list of
! 1950: known security vulnerabilities to packages which are (or have been)
! 1951: included in pkgsrc. The list is available from the NetBSD
! 1952: FTP site at <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities</a>.
! 1953: </p>
! 1954: <p>
! 1955: Through <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>,
! 1956: this list can be downloaded
! 1957: automatically, and a security audit of all packages installed on a system
! 1958: can take place.
! 1959: </p>
! 1960: <p>
! 1961: There are two components to
! 1962: <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>. The first
! 1963: component, “<span class="quote">download-vulnerability-list</span>”, is for downloading
! 1964: the list of vulnerabilities from the NetBSD FTP site. The second
! 1965: component, “<span class="quote">audit-packages</span>”, checks to see if any of your
! 1966: installed packages are vulnerable. If a package is vulnerable, you
! 1967: will see output similar to the following:
! 1968: </p>
! 1969: <pre class="screen">Package samba-2.0.9 has a local-root-shell vulnerability, see
! 1970: http://www.samba.org/samba/whatsnew/macroexploit.html</pre>
! 1971: <p>
! 1972: One can set up <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> to download the
! 1973: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">vulnerabilities</a>
! 1974: file daily, and include a package audit in the daily security script.
! 1975: Details on this are located in the <a href="http://cvsweb.NetBSD.org/bsdweb.cgi/pkgsrc/security/audit-packages/MESSAGE?rev=HEAD&content-type=text/x-cvsweb-markup" target="_top">MESSAGE</a>
! 1976: file for <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>.
! 1977: </p>
! 1978: </div>
! 1979: <div class="sect2" lang="en">
! 1980: <div class="titlepage"><div><div><h3 class="title">
! 1981: <a name="pkg_versions"></a>4.1.6. Finding if newer versions of your installed packages are in pkgsrc</h3></div></div></div>
! 1982: <p>
! 1983: Install <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a> and run
! 1984: <span><strong class="command">lintpkgsrc</strong></span> with the “<span class="quote">-i</span>”
! 1985: argument to check if your packages are up-to-date, e.g.
! 1986: </p>
! 1987: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>lintpkgsrc -i</code></strong>
! 1988: ...
! 1989: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00</pre>
! 1990: <p>You can then use <span><strong class="command">make update</strong></span> to update the
! 1991: package on your system and rebuild any dependencies.
! 1992: </p>
! 1993: </div>
! 1994: <div class="sect2" lang="en">
! 1995: <div class="titlepage"><div><div><h3 class="title">
! 1996: <a name="using.pkg_admin"></a>4.1.7. Other administrative functions</h3></div></div></div>
! 1997: <p>The <span><strong class="command">pkg_admin</strong></span> executes various
! 1998: administrative functions on the package system.</p>
! 1999: </div>
! 2000: <div class="sect2" lang="en">
! 2001: <div class="titlepage"><div><div><h3 class="title">
! 2002: <a name="a-word-of-warning"></a>4.1.8. A word of warning</h3></div></div></div>
1.75 rillig 2003: <p>Please pay very careful attention to the warnings
2004: 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
2005: inherent dangers of installing binary packages which you did
2006: not create yourself, and the security holes that can be
2007: introduced onto your system by indiscriminate adding of such
2008: files.</p>
2009: <p>The same warning of course applies to every package you
2010: install from source when you haven't completely read and
2011: understood the source code of the package, the compiler that
2012: is used to build the package and all the other tools that are
2013: involved.</p>
2014: </div>
2015: </div>
2016: <div class="sect1" lang="en">
2017: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2018: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
1.82 ! rillig 2019: <p>
! 2020: After obtaining pkgsrc, the <code class="filename">pkgsrc</code> directory
! 2021: now contains a set of packages, organized into categories. You can browse
! 2022: the online index of packages, or run <span><strong class="command">make readme</strong></span>
! 2023: from the <code class="filename">pkgsrc</code> directory to build local
! 2024: <code class="filename">README.html</code> files for all packages, viewable with any web browser such as
! 2025: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/lynx/README.html" target="_top"><code class="filename">www/lynx</code></a> or
! 2026: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/mozilla/README.html" target="_top"><code class="filename">www/mozilla</code></a>.</p>
! 2027: <p>The default <span class="emphasis"><em>prefix</em></span> for installed packages is
! 2028: <code class="filename">/usr/pkg</code>. If you wish to change this, you should do
! 2029: so by setting <code class="varname">LOCALBASE</code> in
! 2030: <code class="filename">mk.conf</code>. You should not try to use multiple
! 2031: different <code class="varname">LOCALBASE</code> definitions on the same system
! 2032: (inside a chroot is an exception). </p>
! 2033: <p>The rest of this chapter assumes that the package is already in pkgsrc. If it
1.75 rillig 2034: 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
2035: how to create your own packages.</p>
2036: <div class="sect2" lang="en">
2037: <div class="titlepage"><div><div><h3 class="title">
2038: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
1.82 ! rillig 2039: <p>To build packages from source, you need a working C
! 2040: compiler. On NetBSD, you need to install the
! 2041: “<span class="quote">comp</span>” and the “<span class="quote">text</span>” distribution
! 2042: sets. If you want to build X11-related packages, the
! 2043: “<span class="quote">xbase</span>” and “<span class="quote">xcomp</span>” distribution
! 2044: sets are required, too.</p>
1.75 rillig 2045: </div>
2046: <div class="sect2" lang="en">
2047: <div class="titlepage"><div><div><h3 class="title">
2048: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
2049: <p>The first step for building a package is downloading the
2050: distfiles (i.e. the unmodified source). If they have not yet been
2051: downloaded, pkgsrc will fetch them automatically.</p>
1.82 ! rillig 2052: <p>
! 2053: If you have all files that you need in the
! 2054: <code class="filename">distfiles</code> directory,
! 2055: you don't need to connect. If the distfiles are on CD-ROM, you can
! 2056: mount the CD-ROM on <code class="filename">/cdrom</code> and add:
! 2057: </p>
! 2058: <pre class="screen">DISTDIR=/cdrom/pkgsrc/distfiles</pre>
! 2059: <p>
! 2060: to your <code class="filename">mk.conf</code>.
! 2061: </p>
1.75 rillig 2062: <p>You can overwrite some of the major distribution sites to fit to sites
2063: that are close to your own. Have a look at
1.76 rillig 2064: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find some examples
1.78 rillig 2065: — in particular, look for the <code class="varname">MASTER_SORT</code>,
1.75 rillig 2066: <code class="varname">MASTER_SORT_REGEX</code> and
2067: <code class="varname">INET_COUNTRY</code> definitions. This may save some of your
2068: bandwidth and time.</p>
2069: <p>You can change these settings either in your shell's environment, or,
2070: if you want to keep the settings, by editing the
1.76 rillig 2071: <code class="filename">/etc/mk.conf</code> file,
1.75 rillig 2072: and adding the definitions there.</p>
1.82 ! rillig 2073: <p>
! 2074: If a package depends on many other packages (such as
! 2075: <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 build process may
! 2076: alternate between periods of
! 2077: downloading source, and compiling. To ensure you have all the source
! 2078: downloaded initially you can run the command:
! 2079: </p>
! 2080: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch-list | sh</code></strong></pre>
! 2081: <p>
! 2082: which will output and run a set of shell commands to fetch the
! 2083: necessary files into the <code class="filename">distfiles</code> directory. You can
! 2084: also choose to download the files manually.
! 2085: </p>
1.75 rillig 2086: </div>
2087: <div class="sect2" lang="en">
2088: <div class="titlepage"><div><div><h3 class="title">
2089: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
1.82 ! rillig 2090: <p>
! 2091: Once the software has downloaded, any patches will be applied, then it
! 2092: will be compiled for you. This may take some time depending on your
! 2093: computer, and how many other packages the software depends on and their
! 2094: compile time.
! 2095: </p>
1.75 rillig 2096: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
2097: <h3 class="title">Note</h3>
2098: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
2099: use the pkgsrc <span><strong class="command">bmake</strong></span> command instead of
2100: “<span class="quote">make</span>” in the examples in this guide.</p>
2101: </div>
2102: <p>For example, type </p>
2103: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
2104: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong></pre>
2105: <p>at the shell prompt to build the various components of the
1.82 ! rillig 2106: package.</p>
! 2107: <p>The next stage is to actually install the newly compiled
! 2108: program onto your system. Do this by entering:
! 2109:
! 2110: </p>
! 2111: <pre class="screen">
! 2112: <code class="prompt">%</code> <strong class="userinput"><code>make install</code></strong>
! 2113: </pre>
! 2114: <p>
! 2115:
! 2116: while you are still in the directory for whatever package you
! 2117: are installing.</p>
! 2118: <p>Installing the package on your system may require you to
! 2119: be root. However, pkgsrc has a
1.75 rillig 2120: <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
1.82 ! rillig 2121: to only become root for the actual installation step.</p>
! 2122: <p>That's it, the software should now be installed and setup for use.
! 2123: You can now enter:
! 2124:
! 2125: </p>
! 2126: <pre class="screen">
! 2127: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong>
! 2128: </pre>
! 2129: <p>
! 2130:
! 2131: to remove the compiled files in the work directory, as you shouldn't need
! 2132: them any more. If other packages were also added to your system
! 2133: (dependencies) to allow your program to compile, you can tidy these up
! 2134: also with the command:</p>
! 2135: <pre class="screen">
! 2136: <code class="prompt">%</code> <strong class="userinput"><code>make clean-depends</code></strong>
! 2137: </pre>
1.75 rillig 2138: <p>Taking the figlet utility as an example, we can install it on our
2139: system by building as shown in <a href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
2140: <p>The program is installed under the default root of the packages tree -
1.76 rillig 2141: <code class="filename">/usr/pkg</code>. Should this not conform to your tastes,
1.75 rillig 2142: set the <code class="varname">LOCALBASE</code>
2143: variable in your environment, and it will use that value as the root of
1.76 rillig 2144: your packages tree. So, to use <code class="filename">/usr/local</code>, set
1.75 rillig 2145: <code class="varname">LOCALBASE=/usr/local</code> in your environment. Please note
2146: that you should use a directory which is
2147: dedicated to packages and not shared with other programs (i.e., do not try
2148: and use <code class="varname">LOCALBASE=/usr</code>). Also, you should not try to
1.76 rillig 2149: add any of your own files or directories (such as <code class="filename">src/</code>,
2150: <code class="filename">obj/</code>, or <code class="filename">pkgsrc/</code>) below the
1.75 rillig 2151: <code class="varname">LOCALBASE</code> tree. This is to prevent possible conflicts
2152: between programs and other files installed by the package system and
2153: whatever else may have been installed there.</p>
1.76 rillig 2154: <p>Some packages look in <code class="filename">/etc/mk.conf</code> to alter some
1.75 rillig 2155: configuration options at build time. Have a look at
1.76 rillig 2156: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to
1.75 rillig 2157: get an overview of what will be set there by default. Environment
2158: variables such as <code class="varname">LOCALBASE</code>
1.76 rillig 2159: can be set in <code class="filename">/etc/mk.conf</code> to
1.75 rillig 2160: save having to remember to set them each time you want to use pkgsrc.</p>
2161: <p>Occasionally, people want to “<span class="quote">look under the covers</span>” to see
2162: what is going on when a package is building or being installed. This may be
2163: for debugging purposes, or out of simple curiosity. A number of utility
2164: values have been added to help with this.</p>
2165: <div class="orderedlist"><ol type="1">
2166: <li>
2167: <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>,
2168: then a huge amount of information will be displayed. For example,</p>
2169: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
2170: <p>will show all the commands that are invoked, up to and including the
2171: “<span class="quote">patch</span>” stage.</p>
2172: </li>
2173: <li>
2174: <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
2175: the <code class="varname">VARNAME</code> definition should be used, in conjunction
2176: 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
2177: <code class="varname">LOCALBASE</code>:</p>
2178: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
2179: /usr/pkg
2180: <code class="prompt">%</code>
2181: </pre>
2182: </li>
2183: </ol></div>
2184: <p>If you want to install a binary package that you've either
2185: created yourself (see next section), that you put into pkgsrc/packages manually or
2186: that is located on a remote FTP server, you can use the "bin-install"
2187: target. This target will install a binary package - if available - via
2188: <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>.
2189: The list of remote
2190: FTP sites searched is kept in the variable
2191: <code class="varname">BINPKG_SITES</code>, which defaults to
2192: 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
2193: into <code class="varname">BIN_INSTALL_FLAGS</code>.
1.76 rillig 2194: See <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more details.</p>
1.75 rillig 2195: <p>A final word of warning: If you set up a system that has a non-standard
2196: setting for <code class="varname">LOCALBASE</code>, be sure to set that
2197: before any packages are installed, as you can not use several directories
2198: for the same purpose. Doing so will result in pkgsrc not being able to
2199: properly detect your installed packages, and fail miserably. Note also that
2200: precompiled binary packages are usually built with the default
2201: <code class="varname">LOCALBASE</code> of
1.76 rillig 2202: <code class="filename">/usr/pkg</code>, and that you should <span class="emphasis"><em>not</em></span>
1.75 rillig 2203: install any if you use a non-standard <code class="varname">LOCALBASE</code>.</p>
2204: </div>
2205: <div class="sect2" lang="en">
2206: <div class="titlepage"><div><div><h3 class="title">
2207: <a name="selecting-the-compiler"></a>4.2.4. Selecting the compiler</h3></div></div></div>
2208: <p>By default, pkgsrc will use GCC to build packages. This may be
2209: overridden by setting the following variables in /etc/mk.conf:
2210: </p>
2211: <div class="variablelist"><dl>
2212: <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
2213: <dd>
2214: <p> This is a list of values specifying the chain of
2215: compilers to invoke when building packages. Valid values
2216: are: </p>
2217: <div class="itemizedlist"><ul type="disc">
2218: <li><p><code class="varname">distcc</code>:
2219: distributed C/C++ (chainable)</p></li>
2220: <li><p><code class="varname">ccache</code>:
2221: compiler cache (chainable)</p></li>
2222: <li><p><code class="varname">gcc</code>:
2223: GNU C/C++ Compiler</p></li>
2224: <li><p><code class="varname">mipspro</code>:
2225: Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
2226: <li><p><code class="varname">mipspro</code>:
2227: Silicon Graphics, Inc. MIPSpro (o32)</p></li>
2228: <li><p><code class="varname">sunpro</code>:
2229: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
2230: </ul></div>
2231: <p> The default is
2232: “<span class="quote"><code class="varname">gcc</code></span>”. You can use
2233: <code class="varname">ccache</code> and/or
2234: <code class="varname">distcc</code> with an appropriate
2235: <code class="varname">PKGSRC_COMPILER</code> setting,
2236: e.g. “<span class="quote"><code class="varname">ccache gcc</code></span>”. This
2237: variable should always be
2238: terminated with a value for a real compiler. </p>
2239: </dd>
2240: <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
2241: <dd><p> This specifies the minimum version of GCC to use
2242: when building packages. If the system GCC doesn't
2243: satisfy this requirement, then pkgsrc will build and
2244: install one of the GCC packages to use instead. </p></dd>
2245: </dl></div>
2246: </div>
2247: </div>
2248: </div>
2249: <div class="chapter" lang="en">
2250: <div class="titlepage"><div><div><h2 class="title">
2251: <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
2252: <div class="toc">
2253: <p><b>Table of Contents</b></p>
2254: <dl>
2255: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
2256: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 2257: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
2258: <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>
2259: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
2260: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 2261: </dl>
2262: </div>
2263: <div class="sect1" lang="en">
2264: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2265: <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
2266: <p>In this section, you can find some variables that apply to all
1.82 ! rillig 2267: pkgsrc packages. The preferred method of setting these variables is
! 2268: by setting them in <code class="filename">/etc/mk.conf</code>. A complete
! 2269: list of the variables that can be configured by the user is
! 2270: available in <code class="filename">mk/defaults/mk.conf</code>, together with
! 2271: some comments that describe the variable's intent.</p>
1.75 rillig 2272: <div class="itemizedlist"><ul type="disc">
2273: <li><p><code class="varname">LOCALBASE</code>: Where
2274: packages will be installed. The default is
1.76 rillig 2275: <code class="filename">/usr/pkg</code>. Do not mix binary packages
1.75 rillig 2276: with different <code class="varname">LOCALBASE</code>s!</p></li>
2277: <li><p><code class="varname">CROSSBASE</code>: Where
2278: “<span class="quote">cross</span>” category packages will be
2279: installed. The default is
1.76 rillig 2280: <code class="filename">${LOCALBASE}/cross</code>.</p></li>
1.75 rillig 2281: <li><p><code class="varname">X11BASE</code>: Where
2282: X11 is installed on the system. The default is
1.76 rillig 2283: <code class="filename">/usr/X11R6</code>.</p></li>
1.75 rillig 2284: <li><p><code class="varname">DISTDIR</code>: Where to store the
2285: downloaded copies of the original source distributions used
2286: for building pkgsrc packages. The default is
1.76 rillig 2287: <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
1.75 rillig 2288: <li><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
2289: If set, override the packages'
2290: <code class="varname">MASTER_SITES</code> with this value.</p></li>
2291: <li><p><code class="varname">MASTER_SITE_BACKUP</code>:
2292: Backup location(s) for distribution files and patch files
2293: if not found locally or in
1.76 rillig 2294: <code class="filename">${MASTER_SITES}</code> or
2295: <code class="filename">${PATCH_SITES}</code> respectively.
1.75 rillig 2296: The defaults are
1.76 rillig 2297: <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
1.75 rillig 2298: and
1.76 rillig 2299: <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
1.75 rillig 2300: <li><p><code class="varname">BINPKG_SITES</code>:
2301: List of sites carrying binary pkgs.</p></li>
1.82 ! rillig 2302: <li><p><code class="varname">ACCEPTABLE_LICENSES</code>:
! 2303: List of acceptable licenses. Whenever you try to build a package
! 2304: whose license is not in this list, you will get an error message
! 2305: that includes instructions on how to change this variable.</p></li>
1.75 rillig 2306: </ul></div>
2307: </div>
2308: <div class="sect1" lang="en">
2309: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2310: <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
2311: <p>XXX
2312: </p>
2313: <div class="itemizedlist"><ul type="disc">
2314: <li><p><code class="varname">PACKAGES</code>: The top level
2315: directory for the binary packages. The default is
1.76 rillig 2316: <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
1.75 rillig 2317: <li><p><code class="varname">WRKOBJDIR</code>:
2318: The top level directory where, if defined, the separate
2319: working directories will get created, and symbolically
1.76 rillig 2320: linked to from <code class="filename">${WRKDIR}</code> (see below).
1.75 rillig 2321: This is useful for building packages on several
1.76 rillig 2322: architectures, then <code class="filename">${PKGSRCDIR}</code>
2323: can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
1.75 rillig 2324: is local to every architecture. (It should be noted that
2325: <code class="varname">PKGSRCDIR</code> should not be set by the user
1.78 rillig 2326: — it is an internal definition which refers to the
1.75 rillig 2327: root of the pkgsrc tree. It is possible to have many
2328: pkgsrc tree instances.)</p></li>
2329: <li><p><code class="varname">LOCALPATCHES</code>:
2330: Directory for local patches that aren't part of pkgsrc.
1.77 rillig 2331: See <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a> for more
1.75 rillig 2332: information. <em class="replaceable"><code>rel</code></em> and
2333: <em class="replaceable"><code>arch</code></em> are replaced with OS
2334: release (“<span class="quote">2.0</span>”, etc.) and architecture
2335: (“<span class="quote">mipsel</span>”, etc.).</p></li>
2336: <li><p><code class="varname">PKGMAKECONF</code>: Location of
1.76 rillig 2337: the <code class="filename">mk.conf</code> file used by a package's
1.75 rillig 2338: BSD-style Makefile. If this is not set,
2339: <code class="varname">MAKECONF</code> is set to
1.76 rillig 2340: <code class="filename">/dev/null</code> to avoid picking up
2341: settings used by builds in <code class="filename">/usr/src</code>.</p></li>
1.82 ! rillig 2342: <li><p><code class="varname">DEPENDS_TARGET</code>:
! 2343: By default, dependencies are only installed, and no binary
! 2344:
! 2345: package is created for them. You can set this variable to
! 2346: <code class="literal">package</code> to automatically create binary
! 2347: packages after installing dependencies.</p></li>
1.75 rillig 2348: </ul></div>
2349: <p>
2350: </p>
2351: </div>
2352: <div class="sect1" lang="en">
2353: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 2354: <a name="conf.compiler"></a>5.3. Selecting and configuring the compiler</h2></div></div></div>
2355: <div class="sect2" lang="en">
2356: <div class="titlepage"><div><div><h3 class="title">
2357: <a name="conf.cflags"></a>5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</h3></div></div></div>
2358: <p>If you wish to set the <code class="varname">CFLAGS</code> variable,
2359: please make sure to use the <code class="literal">+=</code> operator
2360: instead of the <code class="literal">=</code> operator:</p>
2361: <pre class="programlisting">
2362: CFLAGS+= -your -flags
2363: </pre>
2364: <p>Using <code class="varname">CFLAGS=</code> (i.e. without the
2365: “<span class="quote">+</span>”) may lead to problems with packages that need
2366: to add their own flags. Also, you may want to take a look at
2367: 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
2368: you're interested in optimization for the current CPU.</p>
2369: </div>
2370: </div>
2371: <div class="sect1" lang="en">
2372: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2373: <a name="developer-advanced-settings"></a>5.4. Developer/advanced settings</h2></div></div></div>
1.75 rillig 2374: <p>XXX
2375: </p>
2376: <div class="itemizedlist"><ul type="disc">
2377: <li>
2378: <p><code class="varname">PKG_DEVELOPER</code>:
2379: Run some sanity checks that package developers want:
2380: </p>
2381: <div class="itemizedlist"><ul type="circle">
2382: <li><p>make sure patches apply with zero fuzz</p></li>
2383: <li><p>run check-shlibs to see that all binaries will
2384: find their shared libs.</p></li>
2385: </ul></div>
2386: <p>
2387: </p>
2388: </li>
2389: <li><p><code class="varname">PKG_DEBUG_LEVEL</code>:
2390: The level of debugging output which is displayed whilst
2391: making and installing the package.
2392: The default value for this is 0, which will not display
2393: the commands as they are executed (normal, default, quiet
2394: operation); the value 1 will display all shell commands
2395: before their invocation, and the value 2 will display both
2396: the shell commands before their invocation, and their
2397: actual execution progress with <span><strong class="command">set -x</strong></span>
2398: will be displayed.</p></li>
2399: </ul></div>
2400: <p>
2401: </p>
2402: </div>
2403: <div class="sect1" lang="en">
2404: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 2405: <a name="selecting-build-options"></a>5.5. Selecting Build Options</h2></div></div></div>
1.75 rillig 2406: <p>Some packages have build time options, usually to select between
2407: different dependencies, enable optional support for big dependencies
2408: or enable experimental features.</p>
2409: <p>To see which options, if any, a package supports, and which
2410: options are mutually exclusive, run <span><strong class="command">make show-options</strong></span>,
2411: for example:</p>
2412: <pre class="programlisting">
2413: The following options are supported by this package:
2414: ssl Enable SSL support.
2415: Exactly one of the following gecko options is required:
2416: firefox Use firefox as gecko rendering engine.
2417: mozilla Use mozilla as gecko rendering engine.
2418: At most one of the following database options may be selected:
2419: mysql Enable support for MySQL database.
2420: pgsql Enable support for PostgreSQL database.
1.1 grant 2421:
1.75 rillig 2422: These options are enabled by default: firefox
2423: These options are currently enabled: mozilla ssl
1.1 grant 2424: </pre>
1.75 rillig 2425: <p>The following variables can be defined in
1.76 rillig 2426: <code class="filename">/etc/mk.conf</code> to select which options to enable
1.75 rillig 2427: for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which can be
2428: used to select or disable options for all packages that support them,
2429: and <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
2430: which can be used to select or disable options specifically for
2431: package <em class="replaceable"><code>pkgbase</code></em>. Options listed in these
2432: variables are selected, options preceded by “<span class="quote">-</span>” are
2433: disabled. A few examples:</p>
2434: <pre class="screen">
2435: <code class="prompt">$</code> <span><strong class="command">grep "PKG.*OPTION" /etc/mk.conf</strong></span>
2436: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
2437: PKG_OPTIONS.kdebase= debug -sasl
2438: PKG_OPTIONS.apache= suexec </pre>
2439: <p>The following settings are consulted in the order given, and the
2440: last setting that selects or disables an option is used:</p>
2441: <div class="orderedlist"><ol type="1">
2442: <li><p>the default options as suggested by the package
2443: maintainer</p></li>
2444: <li><p>the options implied by the settings of legacy
2445: variables (see below)</p></li>
2446: <li><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
2447: <li><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
2448: </ol></div>
2449: <p>For groups of mutually exclusive options, the last option
2450: selected is used, all others are automatically disabled. If an option
2451: of the group is explicitly disabled, the previously selected option,
2452: if any, is used. It is an error if no option from a required group of
2453: options is selected, and building the package will fail.</p>
2454: <p>Before the options framework was introduced, build options were
2455: selected by setting a variable (often named
2456: <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
1.76 rillig 2457: <code class="filename">/etc/mk.conf</code> for each option. To ease transition
1.75 rillig 2458: to the options framework for the user, these legacy variables are
2459: converted to the appropriate options setting
2460: (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
2461: automatically. A warning is issued to prompt the user to
1.76 rillig 2462: update <code class="filename">/etc/mk.conf</code> to use the options framework
1.75 rillig 2463: directly. Support for the legacy variables will be removed
2464: eventually.</p>
2465: </div>
2466: </div>
2467: <div class="chapter" lang="en">
2468: <div class="titlepage"><div><div><h2 class="title">
2469: <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
2470: <div class="toc">
2471: <p><b>Table of Contents</b></p>
2472: <dl>
2473: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
2474: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
2475: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
2476: <dd><dl>
2477: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
2478: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
2479: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
2480: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
2481: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
2482: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
2483: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
2484: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
2485: </dl></dd>
2486: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
2487: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
2488: </dl>
2489: </div>
2490: <div class="sect1" lang="en">
2491: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2492: <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
2493: <p>
2494: Once you have built and installed a package, you can create a
2495: <span class="emphasis"><em>binary package</em></span> which can be installed on
2496: 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
2497: the same package on a group of hosts and wasting CPU time. It
2498: also provides a simple means for others to install your package,
2499: should you distribute it.
2500: </p>
2501: <p>
2502: To create a binary package, change into the appropriate
2503: directory in pkgsrc, and run <span><strong class="command">make
2504: package</strong></span>:
2505: </p>
2506: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
2507: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
2508: <p>
2509: This will build and install your package (if not already done),
2510: and then build a binary package from what was installed. You can
2511: then use the <span><strong class="command">pkg_*</strong></span> tools to manipulate
2512: it. Binary packages are created by default in
1.76 rillig 2513: <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
1.75 rillig 2514: gzipped tar file. See <a href="#logs.package" title="B.2. Packaging figlet">Section B.2, “Packaging figlet”</a> for a
1.76 rillig 2515: 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 2516: <p>
1.77 rillig 2517: 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 2518: such a binary package.</p>
2519: </div>
2520: <div class="sect1" lang="en">
2521: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2522: <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
1.77 rillig 2523: <p>See <a href="#build.helpful-targets" title="15.16. Other helpful targets">Section 15.16, “Other helpful targets”</a>.</p>
1.75 rillig 2524: </div>
2525: <div class="sect1" lang="en">
2526: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2527: <a name="bulkbuild"></a>6.3. Doing a bulk build of all packages</h2></div></div></div>
2528: <p>If you want to get a full set of precompiled binary
2529: packages, this section describes how to get them. Beware that
2530: the bulk build will remove all currently installed packages from
2531: your system!</p>
2532: <p>Having an FTP server configured either on the
2533: machine doing the bulk builds or on a nearby NFS server can help
2534: to make the packages available to other machines that can then
2535: 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
2536: more information. If you use a remote NFS server's storage, be
2537: sure to not actually compile on NFS storage, as this slows
2538: things down a lot.</p>
2539: <div class="sect2" lang="en">
2540: <div class="titlepage"><div><div><h3 class="title">
2541: <a name="binary.configuration"></a>6.3.1. Configuration</h3></div></div></div>
2542: <div class="sect3" lang="en">
2543: <div class="titlepage"><div><div><h4 class="title">
1.76 rillig 2544: <a name="binary.bulk.build.conf"></a>6.3.1.1. <code class="filename">build.conf</code></h4></div></div></div>
2545: <p>The <code class="filename">build.conf</code> file is the main
1.75 rillig 2546: configuration file for bulk builds. You can configure how your
2547: copy of pkgsrc is kept up to date, how the distfiles are
2548: downloaded, how the packages are built and how the report is
2549: generated. You can find an annotated example file in
1.76 rillig 2550: <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
2551: it, copy <code class="filename">build.conf-example</code> to
2552: <code class="filename">build.conf</code> and edit it, following the
1.75 rillig 2553: comments in that file.</p>
2554: </div>
2555: <div class="sect3" lang="en">
2556: <div class="titlepage"><div><div><h4 class="title">
2557: <a name="binary.mk.conf"></a>6.3.1.2. /etc/mk.conf</h4></div></div></div>
2558: <p>You may want to set variables in
1.76 rillig 2559: <code class="filename">/etc/mk.conf</code>.
2560: Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
1.75 rillig 2561: details of the default settings. You will want to ensure that
2562: <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
2563: As used in this example, <code class="varname">_ACCEPTABLE=yes</code>
2564: accepts <span class="emphasis"><em>all</em></span> licenses.</p>
2565: <pre class="programlisting">
2566: PACKAGES?= ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
2567: WRKOBJDIR?= /usr/tmp/pkgsrc # build here instead of in pkgsrc
2568: BSDSRCDIR= /usr/src
2569: BSDXSRCDIR= /usr/xsrc # for x11/xservers
2570: OBJHOSTNAME?= yes # use work.`hostname`
2571: FAILOVER_FETCH= yes # insist on the correct checksum
2572: PKG_DEVELOPER?= yes
2573: _ACCEPTABLE= yes
1.1 grant 2574: </pre>
1.75 rillig 2575: <p>Some options that are especially useful for bulk builds
2576: can be found at the top lines of the file
1.76 rillig 2577: <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
1.75 rillig 2578: options of these are briefly described here.</p>
2579: <div class="itemizedlist"><ul type="disc">
2580: <li><p>If you are on a slow machine, you may want to
2581: set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
2582: “<span class="quote">no</span>”.</p></li>
2583: <li><p>If you are doing bulk builds from a read-only
2584: copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
2585: to the directory where all log files are created. Otherwise the
2586: log files are created in the pkgsrc directory.</p></li>
2587: <li><p>Another important variable is
2588: <code class="varname">BULK_PREREQ</code>, which is a list of packages that
2589: should be always available while building other
2590: packages.</p></li>
2591: </ul></div>
2592: <p>Some other options are scattered in the pkgsrc
2593: infrastructure:</p>
2594: <div class="itemizedlist"><ul type="disc">
2595: <li><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
2596: should be set to <code class="literal">yes</code>. The purpose of the bulk
2597: builds is creating binary packages, no matter if they are
2598: vulnerable or not. When uploading the packages to a public
2599: server, the vulnerable packages will be put into a directory of
2600: their own. Leaving this variable unset would prevent the bulk
2601: build system from even trying to build them, so possible
2602: building errors would not show up.</p></li>
2603: <li><p><code class="varname">CHECK_FILES</code>
1.76 rillig 2604: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75 rillig 2605: “<span class="quote">yes</span>” to check that the installed set of files
1.76 rillig 2606: matches the <code class="filename">PLIST</code>.</p></li>
1.75 rillig 2607: <li><p><code class="varname">CHECK_INTERPRETER</code>
1.76 rillig 2608: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75 rillig 2609: “<span class="quote">yes</span>” to check that the installed
2610: “<span class="quote">#!</span>”-scripts will find their
2611: interpreter.</p></li>
2612: </ul></div>
2613: </div>
2614: <div class="sect3" lang="en">
2615: <div class="titlepage"><div><div><h4 class="title">
1.76 rillig 2616: <a name="pre-build.local"></a>6.3.1.3. <code class="filename">pre-build.local</code></h4></div></div></div>
1.75 rillig 2617: <p>It is possible to configure the bulk build to perform
2618: certain site-specific tasks at the end of the pre-build
2619: stage. If the file
1.76 rillig 2620: <code class="filename">pre-build.local</code> exists in
2621: <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
1.75 rillig 2622: (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
2623: stage. An example use of
1.76 rillig 2624: <code class="filename">pre-build.local</code> is to have the line:</p>
1.75 rillig 2625: <pre class="screen">echo "I do not have enough disk space to build this pig." \
2626: > misc/openoffice/$BROKENF</pre>
2627: <p>to prevent the system from trying to build a particular package
2628: which requires nearly 3 GB of disk space.</p>
2629: </div>
2630: </div>
2631: <div class="sect2" lang="en">
2632: <div class="titlepage"><div><div><h3 class="title">
2633: <a name="other-environmental-considerations"></a>6.3.2. Other environmental considerations</h3></div></div></div>
1.76 rillig 2634: <p>As <code class="filename">/usr/pkg</code> will be completely
1.75 rillig 2635: deleted at the start of bulk builds, make sure your login
2636: shell is placed somewhere else. Either drop it into
1.76 rillig 2637: <code class="filename">/usr/local/bin</code> (and adjust your login
1.75 rillig 2638: shell in the passwd file), or (re-)install it via
1.76 rillig 2639: <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 2640: you can login after a reboot (remember that your current
2641: process won't die if the package is removed, you just can't
2642: start any new instances of the shell any more). Also, if you
2643: use NetBSD earlier than 1.5, or you still want to use the pkgsrc
2644: version of ssh for some reason, be sure to install ssh before
1.76 rillig 2645: starting it from <code class="filename">rc.local</code>:</p>
1.75 rillig 2646: <pre class="programlisting">
2647: ( cd /usr/pkgsrc/security/ssh ; make bulk-install )
2648: if [ -f /usr/pkg/etc/rc.d/sshd ]; then
2649: /usr/pkg/etc/rc.d/sshd
2650: fi
1.1 grant 2651: </pre>
1.75 rillig 2652: <p>Not doing so will result in you being not able to log in
2653: via ssh after the bulk build is finished or if the machine
2654: gets rebooted or crashes. You have been warned! :)</p>
2655: </div>
2656: <div class="sect2" lang="en">
2657: <div class="titlepage"><div><div><h3 class="title">
2658: <a name="operation"></a>6.3.3. Operation</h3></div></div></div>
2659: <p>Make sure you don't need any of the packages still
2660: installed.
2661: </p>
2662: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
2663: <h3 class="title">Warning</h3>
2664: <p>During the bulk build, <span class="emphasis"><em>all packages will be
2665: removed!</em></span></p>
2666: </div>
2667: <p>Be sure to remove all other things that might
2668: interfere with builds, like some libs installed in
1.76 rillig 2669: <code class="filename">/usr/local</code>, etc. then become root and type:</p>
1.75 rillig 2670: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2671: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong></pre>
2672: <p>If for some reason your last build didn't complete (power
2673: failure, system panic, ...), you can continue it by
2674: running:</p>
2675: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
2676: <p>
2677: At the end of the bulk build, you will get a summary via mail,
2678: and find build logs in the directory specified by
1.76 rillig 2679: <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
1.75 rillig 2680: file.
2681: </p>
2682: </div>
2683: <div class="sect2" lang="en">
2684: <div class="titlepage"><div><div><h3 class="title">
2685: <a name="what-it-does"></a>6.3.4. What it does</h3></div></div></div>
2686: <p>The bulk builds consist of three steps:</p>
2687: <div class="variablelist"><dl>
2688: <dt><span class="term">1. pre-build</span></dt>
2689: <dd><p>
2690: The script updates your pkgsrc tree via (anon)cvs, then
2691: cleans out any broken distfiles, and removes all
2692: packages installed.</p></dd>
2693: <dt><span class="term">2. the bulk build</span></dt>
2694: <dd><p>
2695: This is basically “<span class="quote">make bulk-package</span>” with
2696: an optimised order in which packages will be
2697: built. Packages that don't require other packages will
2698: be built first, and packages with many dependencies will
2699: be built later.
2700: </p></dd>
2701: <dt><span class="term">3. post-build</span></dt>
2702: <dd><p>
2703: Generates a report that's placed in the directory
1.76 rillig 2704: specified in the <code class="filename">build.conf</code> file
2705: named <code class="filename">broken.html</code>, a short version
1.75 rillig 2706: of that report will also be mailed to the build's
2707: admin.</p></dd>
2708: </dl></div>
2709: <p>
2710: During the build, a list of broken packages will be compiled
1.76 rillig 2711: in <code class="filename">/usr/pkgsrc/.broken</code> (or
2712: <code class="filename">.../.broken.${MACHINE}</code> if
1.75 rillig 2713: <code class="varname">OBJMACHINE</code> is set), individual build logs
2714: of broken builds can be found in the package's
2715: directory. These files are used by the bulk-targets to mark
2716: broken builds to not waste time trying to rebuild them, and
2717: they can be used to debug these broken package builds
2718: later.
2719: </p>
2720: </div>
2721: <div class="sect2" lang="en">
2722: <div class="titlepage"><div><div><h3 class="title">
2723: <a name="disk-space-requirements"></a>6.3.5. Disk space requirements</h3></div></div></div>
2724: <p>Currently, roughly the following requirements are valid for
2725: NetBSD 2.0/i386:</p>
2726: <div class="itemizedlist"><ul type="disc">
2727: <li><p>
2728: 10 GB - distfiles (NFS ok)
2729: </p></li>
2730: <li><p>
2731: 8 GB - full set of all binaries (NFS ok)
2732: </p></li>
2733: <li><p>
2734: 5 GB - temp space for compiling (local disk recommended)
2735: </p></li>
2736: </ul></div>
2737: <p>
2738: Note that all pkgs will be de-installed as soon as they are
2739: turned into a binary package, and that sources are removed,
2740: so there is no excessively huge demand to disk
2741: space. Afterwards, if the package is needed again, it will
2742: 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
2743: there are no cycles wasted by recompiling.
2744: </p>
2745: </div>
2746: <div class="sect2" lang="en">
2747: <div class="titlepage"><div><div><h3 class="title">
2748: <a name="setting-up-a-sandbox"></a>6.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
2749: <p>
2750: If you don't want all the packages nuked from a machine
2751: (rendering it useless for anything but pkg compiling), there
2752: is the possibility of doing the package bulk build inside a
2753: chroot environment.
2754: </p>
2755: <p>
2756: The first step is to set up a chroot sandbox,
1.76 rillig 2757: e.g. <code class="filename">/usr/sandbox</code>. This can be done by
1.75 rillig 2758: using null mounts, or manually.
2759: </p>
2760: <p>
2761: There is a shell script called
1.76 rillig 2762: <code class="filename">pkgsrc/mk/bulk/mksandbox</code> which will set
1.75 rillig 2763: up the sandbox environment using null mounts. It will also
1.76 rillig 2764: create a script called <code class="filename">sandbox</code> in the
1.75 rillig 2765: root of the sandbox environment, which will allow the null
2766: mounts to be activated using the <span><strong class="command">sandbox
2767: mount</strong></span> command and deactivated using the
2768: <span><strong class="command">sandbox umount</strong></span> command.
2769: </p>
2770: <p>
2771: To set up a sandbox environment by hand, after extracting all
2772: the sets from a NetBSD installation or doing a <span><strong class="command">make
2773: distribution DESTDIR=/usr/sandbox</strong></span> in
1.76 rillig 2774: <code class="filename">/usr/src/etc</code>, be sure the following items
1.75 rillig 2775: are present and properly configured:
2776: </p>
2777: <div class="procedure"><ol type="1">
2778: <li>
2779: <p>Kernel</p>
2780: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
2781: </li>
2782: <li>
1.76 rillig 2783: <p><code class="filename">/dev/*</code></p>
1.75 rillig 2784: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
2785: </li>
2786: <li>
1.76 rillig 2787: <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 2788: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
2789: </li>
2790: <li>
2791: <p>Working(!) mail config (hostname, sendmail.cf):</p>
2792: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
2793: </li>
2794: <li>
1.76 rillig 2795: <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 2796: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
2797: </li>
2798: <li>
1.76 rillig 2799: <p><code class="filename">/usr/src</code> (system sources,
1.78 rillig 2800: 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 2801: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
2802: <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
2803: </li>
2804: <li>
1.76 rillig 2805: <p>Create <code class="filename">/var/db/pkg</code> (not part of default install):</p>
1.75 rillig 2806: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong></pre>
2807: </li>
2808: <li>
1.76 rillig 2809: <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
1.75 rillig 2810: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
2811: </li>
2812: <li>
2813: <p>Checkout pkgsrc via cvs into
1.76 rillig 2814: <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
1.75 rillig 2815: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
2816: <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong></pre>
2817: <p>Do not mount/link this to the copy of your pkgsrc tree
2818: you do development in, as this will likely cause problems!
2819: </p>
2820: </li>
2821: <li><p>Make
1.76 rillig 2822: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
2823: <code class="filename">.../distfiles</code> point somewhere
1.75 rillig 2824: appropriate. NFS- and/or nullfs-mounts may come in handy!
2825: </p></li>
1.76 rillig 2826: <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>
2827: <li><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
1.75 rillig 2828: </ol></div>
2829: <p>When the chroot sandbox is set up, you can start
2830: the build with the following steps:</p>
2831: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2832: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong></pre>
2833: <p>
2834: This will just jump inside the sandbox and start building. At
2835: the end of the build, mail will be sent with the results of
2836: the build. Created binary pkgs will be in
1.76 rillig 2837: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
1.75 rillig 2838: (wherever that points/mounts to/from).</p>
2839: </div>
2840: <div class="sect2" lang="en">
2841: <div class="titlepage"><div><div><h3 class="title">
2842: <a name="building-a-partial-set"></a>6.3.7. Building a partial set of packages</h3></div></div></div>
2843: <p> In addition to building a complete set of all packages in
1.76 rillig 2844: pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
1.75 rillig 2845: may be used to build a subset of the packages contained in
2846: pkgsrc. By setting <code class="varname">SPECIFIC_PKGS</code>
1.76 rillig 2847: in <code class="filename">/etc/mk.conf</code>, the variables</p>
1.75 rillig 2848: <div class="itemizedlist"><ul type="disc">
2849: <li><p>SITE_SPECIFIC_PKGS</p></li>
2850: <li><p>HOST_SPECIFIC_PKGS</p></li>
2851: <li><p>GROUP_SPECIFIC_PKGS</p></li>
2852: <li><p>USER_SPECIFIC_PKGS</p></li>
2853: </ul></div>
2854: <p> will define the set of packages which should be built.
2855: The bulk build code will also include any packages which are
2856: needed as dependencies for the explicitly listed packages.
2857: </p>
2858: <p> One use of this is to do a bulk build with
2859: <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
2860: periodically to have a complete set of the binary packages
2861: needed for your site available without the overhead of
2862: building extra packages that are not needed. </p>
2863: </div>
2864: <div class="sect2" lang="en">
2865: <div class="titlepage"><div><div><h3 class="title">
2866: <a name="bulk-upload"></a>6.3.8. Uploading results of a bulk build</h3></div></div></div>
2867: <p>
2868: This section describes how pkgsrc developers can upload binary
2869: pkgs built by bulk builds to ftp.NetBSD.org.
2870: </p>
2871: <p>
2872: If you would like to automatically create checksum files for the
2873: binary packages you intend to upload, remember to set
2874: <code class="varname">MKSUMS=yes</code> in your
1.76 rillig 2875: <code class="filename">mk/bulk/build.conf</code>.
1.75 rillig 2876: </p>
2877: <p>
2878: If you would like to PGP sign the checksum files (highly
2879: recommended!), remember to set
2880: <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
1.76 rillig 2881: <code class="filename">mk/bulk/build.conf</code>. This will prompt you for
1.75 rillig 2882: your GPG password to sign the files before uploading everything.
2883: </p>
2884: <p>
2885: Then, make sure that you have <code class="varname">RSYNC_DST</code>
1.76 rillig 2886: set properly in your <code class="filename">mk/bulk/build.conf</code>
1.75 rillig 2887: file, i.e. adjust it to something like one of the following:
2888: </p>
2889: <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
2890: <p>Please use appropriate values for "pkgsrc-200xQy",
2891: "NetBSD-a.b.c" and "arch" here. If your login on ftp.NetBSD.org
2892: is different from your local login, write your login directly
2893: into the variable, e.g. my local account is "feyrer", but for my
2894: login "hubertf", I use:</p>
2895: <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
2896: <p>
1.76 rillig 2897: A separate <code class="filename">upload</code> directory is used
1.75 rillig 2898: here to allow "closing" the directory during upload. To do
2899: so, run the following command on ftp.NetBSD.org next:
2900: </p>
2901: <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>
2902: <p>
1.76 rillig 2903: Please note that <code class="filename">/pub/NetBSD/packages</code> is
1.75 rillig 2904: only appropriate for packages for the NetBSD operating
2905: system. Binary packages for other operating systems should go
1.76 rillig 2906: into <code class="filename">/pub/pkgsrc</code>.
1.75 rillig 2907: </p>
2908: <p>
2909: Before uploading the binary pkgs, ssh authentication needs to
2910: be set up. This example shows how to set up temporary keys
2911: for the root account <span class="emphasis"><em>inside the sandbox</em></span>
2912: (assuming that no keys should be present there usually):
2913: </p>
2914: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
2915: chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
2916: chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t dsa</code></strong>
2917: chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong> </pre>
2918: <p>
1.76 rillig 2919: Now take the output of <code class="filename">id-dsa.pub</code> and
2920: append it to your <code class="filename">~/.ssh/authorized_keys</code>
1.75 rillig 2921: file on ftp.NetBSD.org. You can remove the key after the
2922: upload is done!
2923: </p>
2924: <p>
2925: Next, test if your ssh connection really works:
2926: </p>
2927: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
2928: <p>
2929: Use "-l yourNetBSDlogin" here as appropriate!
2930: </p>
2931: <p>
2932: Now after all this works, you can exit the sandbox and start
2933: the upload:
2934: </p>
2935: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
2936: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2937: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong> </pre>
2938: <p>
2939: 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
2940: <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
2941: upload. The upload script will take care of not uploading
2942: restricted packages and putting vulnerable packages into the
1.76 rillig 2943: <code class="filename">vulnerable</code> subdirectory.
1.75 rillig 2944: </p>
2945: <p>
2946: After the upload has ended, first thing is to revoke ssh access:
2947: </p>
2948: <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
2949: Gdd:x! </pre>
2950: <p>
2951: Use whatever is needed to remove the key you've entered
2952: before! Last, move the uploaded packages out of the
1.76 rillig 2953: <code class="filename">upload</code> directory to have them accessible
1.75 rillig 2954: to everyone:
2955: </p>
2956: <pre class="screen">nbftp% <strong class="userinput"><code>cd /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch</code></strong>
2957: nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
2958: nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
2959: nbftp% <strong class="userinput"><code>chmod 755 .</code></strong> </pre>
2960: </div>
2961: </div>
2962: <div class="sect1" lang="en">
2963: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2964: <a name="creating-cdroms"></a>6.4. Creating a multiple CD-ROM packages collection</h2></div></div></div>
2965: <p>
2966: After your pkgsrc bulk-build has completed, you may wish to
2967: create a CD-ROM set of the resulting binary packages to assist
2968: in installing packages on other machines. The
1.76 rillig 2969: <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 2970: a simple tool for creating the ISO 9660 images.
2971: <span><strong class="command">cdpack</strong></span> arranges the packages on the CD-ROMs in a
2972: way that keeps all the dependencies for a given package on the same
2973: CD as that package.
2974: </p>
2975: <div class="sect2" lang="en">
2976: <div class="titlepage"><div><div><h3 class="title">
2977: <a name="cdpack-example"></a>6.4.1. Example of cdpack</h3></div></div></div>
2978: <p>
2979: Complete documentation for cdpack is found in the cdpack(1)
2980: man page. The following short example assumes that the binary
2981: packages are left in
1.76 rillig 2982: <code class="filename">/usr/pkgsrc/packages/All</code> and that
2983: sufficient disk space exists in <code class="filename">/u2</code> to
1.75 rillig 2984: hold the ISO 9660 images.</p>
2985: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
2986: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
2987: <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong></pre>
2988: <p>
2989: If you wish to include a common set of files
1.76 rillig 2990: (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
1.75 rillig 2991: etc.) on each CD in the collection, then you need to create a
2992: directory which contains these files. e.g.
2993: </p>
2994: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
2995: <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" > /tmp/common/README</code></strong>
2996: <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" > /tmp/common/COPYING</code></strong>
2997: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
2998: <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" > /tmp/common/bin/myscript</code></strong>
2999: <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" >> /tmp/common/bin/myscript</code></strong>
3000: <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong></pre>
3001: <p>Now create the images:</p>
3002: <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 3003: <p>Each image will contain <code class="filename">README</code>,
3004: <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
1.75 rillig 3005: in their root directories.</p>
3006: </div>
3007: </div>
3008: </div>
3009: <div class="chapter" lang="en">
3010: <div class="titlepage"><div><div><h2 class="title">
3011: <a name="faq"></a>Chapter 7. Frequently Asked Questions</h2></div></div></div>
3012: <div class="toc">
3013: <p><b>Table of Contents</b></p>
3014: <dl>
3015: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
3016: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
3017: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
3018: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
3019: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
3020: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
3021: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
3022: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
3023: <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>
3024: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
3025: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
3026: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
3027: <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>
3028: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
3029: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
3030: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
3031: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
1.80 rillig 3032: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.75 rillig 3033: </dl>
3034: </div>
3035: <p>This section contains hints, tips & tricks on special things in
3036: pkgsrc that we didn't find a better place for in the previous chapters, and
3037: it contains items for both pkgsrc users and developers.</p>
3038: <div class="sect1" lang="en">
3039: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3040: <a name="mailing-list-pointers"></a>7.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
3041: <p>The following mailing lists may be of interest to pkgsrc users:</p>
3042: <div class="itemizedlist"><ul type="disc">
1.78 rillig 3043: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-users" target="_top">pkgsrc-users</a>:
3044: This is a general purpose list for most issues regarding
3045: pkgsrc, regardless of platform, e.g. soliciting user help
3046: for pkgsrc configuration, unexpected build failures, using
3047: particular packages, upgrading pkgsrc installations,
3048: questions regarding the pkgsrc release branches, etc. General announcements or
3049: proposals for changes that impact the pkgsrc user community,
3050: e.g. major infrastructure changes, new features, package
3051: removals, etc., may also be posted.</p></li>
1.75 rillig 3052: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
3053: A list where the results of pkgsrc bulk builds are sent and
3054: discussed.</p></li>
3055: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
3056: This list is for those who are interested in getting a
3057: commit message for every change committed to pkgsrc. It is
3058: also available in digest form, meaning one daily message
3059: containing all commit messages for changes to the package
3060: source tree in that 24 hour period.</p></li>
3061: </ul></div>
3062: <p>To subscribe, do:</p>
3063: <pre class="programlisting">
3064: <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
3065: </pre>
3066: <p>Archives for all these mailing lists are available from
3067: <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
3068: </div>
3069: <div class="sect1" lang="en">
3070: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3071: <a name="pkgviews-docs"></a>7.2. Where's the pkgviews documentation?</h2></div></div></div>
3072: <p>Pkgviews is tightly integrated with buildlink. You can find a
3073: pkgviews User's guide in
1.76 rillig 3074: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
1.75 rillig 3075: </div>
3076: <div class="sect1" lang="en">
3077: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3078: <a name="faq-pkgtools"></a>7.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.80 rillig 3079: <p>The directory <code class="filename">pkgsrc/pkgtools</code> contains
1.75 rillig 3080: a number of useful utilities for both users and developers of pkgsrc. This
3081: section attempts only to make the reader aware of the utilities and when
3082: they might be useful, and not to duplicate the documentation that comes
3083: with each package.</p>
3084: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
1.76 rillig 3085: <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 3086: Symlinks for use by buildlink.</p></li></ul></div>
3087: <p>OS tool augmentation (automatically installed when needed):</p>
3088: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3089: <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 3090: Calculates various kinds of checksums (including SHA1).</p></li>
1.76 rillig 3091: <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 3092: Compatibility library for pkgsrc tools.</p></li>
1.76 rillig 3093: <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 3094: non-BSD systems due to lack of native mtree.
3095: </p></li>
1.76 rillig 3096: <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 3097: Up-to-date replacement for
1.76 rillig 3098: <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
1.75 rillig 3099: systems where pkg_install is not present.</p></li>
3100: </ul></div>
3101: <p>Utilities used by pkgsrc (not automatically installed):</p>
3102: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3103: <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 3104: Create a binary package from an
3105: already-installed package. Used by <span><strong class="command">make replace</strong></span> to
3106: save the old package.</p></li>
1.76 rillig 3107: <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 3108: Adds extra functionality to pkgsrc, allowing it to fetch distfiles
3109: from multiple locations. It currently supports the following
3110: methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
1.76 rillig 3111: <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 3112: packages someplace else (enabled by default).</p></li>
1.76 rillig 3113: <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 3114: best compiler flags to optimise code for your current CPU and
3115: compiler.</p></li>
3116: </ul></div>
3117: <p>Utilities for keeping track of installed packages, being up to date,
3118: etc:</p>
3119: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3120: <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 3121: packages whose installed versions do not match the latest pkgsrc
3122: entries.</p></li>
1.76 rillig 3123: <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 3124: dependency graphs of packages, to aid in choosing a strategy for
3125: updating.</p></li>
1.76 rillig 3126: <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
3127: 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>
3128: <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 3129: pkglint(1) program checks a pkgsrc entry for errors, lintpkgsrc(1)
3130: does various checks on the complete pkgsrc system.</p></li>
1.76 rillig 3131: <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 3132: packages you have installed.</p></li>
3133: </ul></div>
3134: <p>Utilities for people maintaining or creating individual packages:</p>
3135: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3136: <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 3137: making and maintaining patches for a package (includes pkgdiff,
3138: pkgvi, mkpatches, etc.).</p></li>
1.76 rillig 3139: <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>,
3140: <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 3141: converting to pkgsrc.</p></li>
1.76 rillig 3142: <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 3143: pkgsrc to a Solaris package.</p></li>
3144: </ul></div>
3145: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
3146: utilities)</p>
3147: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3148: <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 3149: packages in a chrooted area.</p></li>
1.76 rillig 3150: <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 3151: kernel version for chrooted cross builds.</p></li>
3152: </ul></div>
3153: </div>
3154: <div class="sect1" lang="en">
3155: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3156: <a name="non-root-pkgsrc"></a>7.4. How to use pkgsrc as non-root</h2></div></div></div>
3157: <p>If you want to use pkgsrc as non-root user, you can set some
3158: variables to make pkgsrc work under these conditions. At the very least,
3159: you need to set <code class="varname">UNPRIVILEGED</code> to “<span class="quote">yes</span>”; this
3160: will turn on unprivileged mode and set multiple related variables to allow
3161: installation of packages as non-root.</p>
3162: <p>In case the defaults are not enough, you may want to tune some other
3163: variables used. For example, if the automatic user/group detection leads
3164: to incorrect values (or not the ones you would like to use), you can change
3165: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
3166: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
3167: <p>As regards bootstrapping, please note that the
3168: <span><strong class="command">bootstrap</strong></span> script will ease non-root configuration when
3169: given the “<span class="quote">--ignore-user-check</span>” flag, as it will choose and
1.76 rillig 3170: use multiple default directories under <code class="filename">~/pkg</code> as the
1.75 rillig 3171: installation targets. These directories can be overriden by the
3172: “<span class="quote">--prefix</span>” flag provided by the script, as well as some others
3173: that allow finer tuning of the tree layout.</p>
3174: </div>
3175: <div class="sect1" lang="en">
3176: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3177: <a name="resume-transfers"></a>7.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
3178: <p>By default, resuming transfers in pkgsrc is disabled, but you can
3179: enable this feature by adding the option
3180: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.76 rillig 3181: <code class="filename">/etc/mk.conf</code>. If, during a fetch step, an incomplete
1.75 rillig 3182: distfile is found, pkgsrc will try to resume it.</p>
3183: <p>You can also
3184: 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
3185: <code class="varname">FETCH_CMD</code> variable. Don't forget to set
3186: <code class="varname">FETCH_RESUME_ARGS</code> and
3187: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
3188: values.</p>
3189: <p>For example, if you want to use
1.76 rillig 3190: <code class="filename">wget</code> to resume downloads, you'll have to use something
1.75 rillig 3191: like:</p>
3192: <pre class="programlisting">
3193: FETCH_CMD= wget
3194: FETCH_BEFORE_ARGS= --passive-ftp
3195: FETCH_RESUME_ARGS= -c
3196: FETCH_OUTPUT_ARGS= -O
1.1 grant 3197: </pre>
1.75 rillig 3198: </div>
3199: <div class="sect1" lang="en">
3200: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3201: <a name="XFree86-from-pkgsrc"></a>7.6. How can I install/use XFree86 from pkgsrc?</h2></div></div></div>
3202: <p>If you want to use XFree86 from pkgsrc instead of your system's own
1.76 rillig 3203: X11 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>,
1.75 rillig 3204: ...), you will have to add the following line into
1.76 rillig 3205: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 3206: <pre class="programlisting">
3207: X11_TYPE=XFree86
1.1 grant 3208: </pre>
1.75 rillig 3209: </div>
3210: <div class="sect1" lang="en">
3211: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3212: <a name="x.org-from-pkgsrc"></a>7.7. How can I install/use X.org from pkgsrc?</h2></div></div></div>
3213: <p>If you want to use X.org from pkgsrc instead of your system's own X11
1.76 rillig 3214: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
1.75 rillig 3215: you will have to add the following line into
1.76 rillig 3216: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 3217: <pre class="programlisting">
3218: X11_TYPE=xorg
1.1 grant 3219: </pre>
1.75 rillig 3220: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
3221: <h3 class="title">Note</h3>
3222: <p>The DragonFly operating system defaults to using
3223: this X.org X11 implementation from pkgsrc.
3224: </p>
3225: </div>
3226: </div>
3227: <div class="sect1" lang="en">
3228: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3229: <a name="fetch-behind-firewall"></a>7.8. How to fetch files from behind a firewall</h2></div></div></div>
3230: <p>If you are sitting behind a firewall which does not allow direct
3231: connections to Internet hosts (i.e. non-NAT), you may specify the
3232: relevant proxy hosts. This is done using an environment variable in the
3233: form of a URL, e.g. in Amdahl, the machine
3234: “<span class="quote">orpheus.amdahl.com</span>” is one of the firewalls, and it uses
3235: port 80 as the proxy port number. So the proxy environment variables
3236: are:</p>
3237: <pre class="programlisting">
3238: ftp_proxy=ftp://orpheus.amdahl.com:80/
3239: http_proxy=http://orpheus.amdahl.com:80/
1.1 grant 3240: </pre>
1.75 rillig 3241: </div>
3242: <div class="sect1" lang="en">
3243: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3244: <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>
3245: <p>This depends on which utility is used to retrieve distfiles. From
1.76 rillig 3246: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
1.75 rillig 3247: the first available command from the following list:</p>
3248: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3249: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
3250: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
1.75 rillig 3251: </ul></div>
3252: <p>On a default NetBSD installation, this will be
1.76 rillig 3253: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
1.75 rillig 3254: connections first, and falls back to active connections if the server
3255: refuses to do passive. For the other tools, add the following to your
1.76 rillig 3256: <code class="filename">/etc/mk.conf</code> file:
1.75 rillig 3257: <code class="varname">PASSIVE_FETCH=1</code>.</p>
3258: <p>Having that option present will prevent
1.76 rillig 3259: <code class="filename">/usr/bin/ftp</code> from falling back to active
1.75 rillig 3260: transfers.</p>
3261: </div>
3262: <div class="sect1" lang="en">
3263: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3264: <a name="fetching-all-distfiles"></a>7.10. How to fetch all distfiles at once</h2></div></div></div>
3265: <p>You would like to download all the distfiles in a single batch from
3266: work or university, where you can't run a <span><strong class="command">make fetch</strong></span>.
3267: There is an archive of distfiles on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/" target="_top">ftp.NetBSD.org</a>,
3268: but downloading the entire directory may not be appropriate.</p>
3269: <p>The answer here is to do a <span><strong class="command">make fetch-list</strong></span> in
1.76 rillig 3270: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
1.75 rillig 3271: resulting list to your machine at work/school and use it there. If you
3272: 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
3273: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
3274: URL:</p>
3275: <p>At home:</p>
3276: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
3277: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh</code></strong>
3278: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
3279: <p>At work:</p>
3280: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
1.76 rillig 3281: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
1.75 rillig 3282: home.</p>
3283: <p>If you have a machine running NetBSD, and you want to get
3284: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your machine
3285: architecture), you can do so by using the above-mentioned <span><strong class="command">make
3286: fetch-list</strong></span> approach, or fetch the distfiles directly by
3287: running:</p>
3288: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
3289: <p>If you even decide to ignore
3290: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
3291: by running:</p>
3292: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
3293: </div>
3294: <div class="sect1" lang="en">
3295: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3296: <a name="tmac.andoc-missing"></a>7.11. What does “<span class="quote">Don't know how to make
3297: /usr/share/tmac/tmac.andoc</span>” mean?</h2></div></div></div>
1.76 rillig 3298: <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 3299: package, you get the error from make that it doesn't know how to make
1.76 rillig 3300: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
1.75 rillig 3301: you don't have installed the “<span class="quote">text</span>” set (nroff, ...) from
3302: the NetBSD base distribution on your machine. It is recommended to do
3303: that to format man pages.</p>
1.76 rillig 3304: <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 3305: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.76 rillig 3306: environment or in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 3307: </div>
3308: <div class="sect1" lang="en">
3309: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3310: <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 3311: <p> You didn't install the compiler set, <code class="filename">comp.tgz</code>,
1.75 rillig 3312: when you installed your NetBSD machine. Please get and install it, by
1.76 rillig 3313: extracting it in <code class="filename">/</code>:</p>
1.75 rillig 3314: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
3315: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
1.76 rillig 3316: <p><code class="filename">comp.tgz</code> is part of every NetBSD release. Get
1.75 rillig 3317: the one that corresponds to your release (determine via <span><strong class="command">uname
3318: -r</strong></span>).</p>
3319: </div>
3320: <div class="sect1" lang="en">
3321: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3322: <a name="using-sudo-with-pkgsrc"></a>7.13. Using 'sudo' with pkgsrc</h2></div></div></div>
3323: <p>When installing packages as non-root user and using the just-in-time
3324: <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
3325: password for each required package installed. To avoid this, the sudo
3326: package can be used, which does password caching over a limited time. To
3327: use it, install sudo (either as binary package or from
1.76 rillig 3328: <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
3329: into your <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 3330: <pre class="programlisting">
3331: .if exists(${LOCALBASE}/bin/sudo)
3332: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
3333: .endif
1.1 grant 3334: </pre>
1.75 rillig 3335: </div>
3336: <div class="sect1" lang="en">
3337: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3338: <a name="faq.conf"></a>7.14. How do I change the location of configuration files?</h2></div></div></div>
3339: <p>As the system administrator, you can choose where configuration files
3340: are installed. The default settings make all these files go into
1.76 rillig 3341: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
1.75 rillig 3342: be suboptimal depending on your expectations (e.g., a read-only,
3343: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
3344: configuration of the provided packages).</p>
3345: <p>In order to change the defaults, you can modify the
3346: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.76 rillig 3347: <code class="filename">/etc/mk.conf</code>) to point to your preferred configuration
3348: directory; some common examples include <code class="filename">/etc</code> or
3349: <code class="filename">/etc/pkg</code>.</p>
1.75 rillig 3350: <p>Furthermore, you can change this value on a per-package basis by
3351: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
3352: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
3353: package you would like to modify, that is, the contents of
3354: <code class="varname">PKGBASE</code>.</p>
3355: <p>Note that after changing these settings, you must rebuild and
3356: reinstall any affected packages.</p>
3357: </div>
3358: <div class="sect1" lang="en">
3359: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3360: <a name="audit-packages"></a>7.15. Automated security checks</h2></div></div></div>
3361: <p>Please be aware that there can often be bugs in third-party software,
3362: and some of these bugs can leave a machine vulnerable to exploitation by
3363: attackers. In an effort to lessen the exposure, the NetBSD packages team
3364: maintains a database of known-exploits to packages which have at one time
3365: been included in pkgsrc. The database can be downloaded automatically, and
3366: a security audit of all packages installed on a system can take place. To
1.76 rillig 3367: 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 3368: components:</p>
3369: <div class="orderedlist"><ol type="1">
3370: <li>
3371: <p><span><strong class="command">download-vulnerability-list</strong></span>, an easy way to
3372: download a list of the security vulnerabilities information. This list
3373: is kept up to date by the NetBSD security officer and the NetBSD
3374: packages team, and is distributed from the NetBSD ftp server:</p>
3375: <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>
3376: </li>
3377: <li><p><span><strong class="command">audit-packages</strong></span>, an easy way to audit the
3378: current machine, checking each vulnerability which is known. If a
3379: vulnerable package is installed, it will be shown by output to stdout,
3380: including a description of the type of vulnerability, and a URL
3381: containing more information.</p></li>
3382: </ol></div>
1.76 rillig 3383: <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 3384: package is strongly recommended! After
3385: “<span class="quote">audit-packages</span>” is installed, please read
3386: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
3387: audit-packages</code></strong>.</p>
3388: <p>If this package is installed, pkgsrc builds will use it to perform
3389: a security check before building any package. See
3390: <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.
3391: </p>
3392: </div>
3393: <div class="sect1" lang="en">
3394: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3395: <a name="ufaq-cflags"></a>7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
3396: <p>When you add your own preferences to the
3397: <code class="varname">CFLAGS</code> variable in your
1.76 rillig 3398: <code class="filename">mk.conf</code>, these flags are passed in
3399: environment variables to the <code class="filename">./configure</code>
1.75 rillig 3400: 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
3401: <code class="varname">CFLAGS</code> from the environment variable by
1.76 rillig 3402: overriding them in the <code class="filename">Makefile</code>s of their
1.75 rillig 3403: package.</p>
3404: <p>Currently there is no solution to this problem. If you
3405: really need the package to use your <code class="varname">CFLAGS</code>
3406: you should run <span><strong class="command">make patch</strong></span> in the package
1.76 rillig 3407: directory and then inspect any <code class="filename">Makefile</code> and
3408: <code class="filename">Makefile.in</code> for whether they define
1.75 rillig 3409: <code class="varname">CFLAGS</code> explicitly. Usually you can remove
3410: these lines. But be aware that some “<span class="quote">smart</span>”
3411: programmers write so bad code that it only works for the
3412: specific combination of <code class="varname">CFLAGS</code> they have
3413: chosen.</p>
3414: </div>
1.80 rillig 3415: <div class="sect1" lang="en">
3416: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3417: <a name="ufaq-fail"></a>7.17. A package does not build. What shall I do?</h2></div></div></div>
3418: <div class="procedure"><ol type="1">
3419: <li><p>Make sure that your copy of pkgsrc is consistent. A
3420: case that occurs often is that people only update pkgsrc in
3421: parts, because of performance reasons. Since pkgsrc is one large
3422: system, not a collection of many small systems, there are
3423: sometimes changes that only work when the whole pkgsrc tree is
3424: updated.</p></li>
3425: <li><p>Make sure that you don't have any CVS conflicts.
3426: Search for “<span class="quote"><<<<<<</span>” or
3427: “<span class="quote">>>>>>></span>” in all your pkgsrc
3428: files.</p></li>
3429: <li><p>Make sure that you don't have old copies of the packages
3430: extracted. Run <span><strong class="command">make clean clean-depends</strong></span> to
3431: verify this.</p></li>
3432: <li><p>If the problem still exists, write a mail to the
3433: <code class="literal">pkgsrc-users</code> mailing list.</p></li>
3434: </ol></div>
3435: </div>
1.75 rillig 3436: </div>
3437: </div>
3438: <div class="part" lang="en">
3439: <div class="titlepage"><div><div><h1 class="title">
3440: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
1.77 rillig 3441: <div class="partintro" lang="en">
3442: <div></div>
3443: <p>This part of the book deals with creating and
3444: modifying packages. It starts with a “<span class="quote">HOWTO</span>”-like
3445: guide on creating a new package. The remaining chapters are more
3446: like a reference manual for pkgsrc.</p>
1.75 rillig 3447: <div class="toc">
3448: <p><b>Table of Contents</b></p>
3449: <dl>
1.77 rillig 3450: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
3451: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75 rillig 3452: <dd><dl>
1.77 rillig 3453: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
3454: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
3455: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
3456: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
3457: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 3458: <dd><dl>
3459: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
3460: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
3461: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
3462: </dl></dd>
1.77 rillig 3463: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
3464: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
3465: </dl></dd>
3466: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
3467: <dd><dl>
3468: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
3469: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
3470: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
3471: <dd><dl>
3472: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
3473: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
3474: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
3475: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
3476: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
3477: </dl></dd>
3478: </dl></dd>
3479: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
3480: <dd><dl>
3481: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
3482: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
3483: <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>
3484: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
3485: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
3486: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
3487: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
3488: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
3489: </dl></dd>
3490: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
3491: <dd><dl>
3492: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
3493: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
3494: <dd><dl>
3495: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
3496: <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>
3497: </dl></dd>
3498: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
3499: <dd><dl>
3500: <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>
3501: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
3502: </dl></dd>
3503: </dl></dd>
3504: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
3505: <dd><dl>
3506: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
3507: <dd><dl>
3508: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
3509: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
3510: </dl></dd>
3511: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
3512: <dd><dl>
3513: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
3514: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
3515: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
3516: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
3517: </dl></dd>
3518: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
3519: <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>
3520: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
3521: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
3522: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
3523: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
3524: <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>
3525: </dl></dd>
3526: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
3527: <dd><dl>
3528: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
3529: <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>
3530: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
3531: </dl></dd>
3532: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
3533: <dd><dl>
3534: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
3535: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
3536: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
3537: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
3538: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
1.81 rillig 3539: <dd><dl>
3540: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
3541: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
3542: </dl></dd>
1.77 rillig 3543: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
3544: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
3545: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
3546: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
3547: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
3548: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
3549: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3550: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
3551: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3552: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
3553: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
3554: </dl></dd>
3555: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
3556: <dd><dl>
3557: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
3558: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
3559: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
3560: </dl></dd>
3561: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
3562: <dd><dl>
3563: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
3564: <dd><dl>
1.78 rillig 3565: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
3566: <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>
3567: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
3568: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
3569: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
3570: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
3571: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
3572: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
3573: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
3574: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
3575: <dt><span class="sect2"><a href="#bumping-pkgrevision">17.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
1.79 rillig 3576: <dt><span class="sect2"><a href="#fixes.subst">17.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
1.77 rillig 3577: </dl></dd>
3578: <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>
3579: <dd><dl>
3580: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
3581: <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>
3582: </dl></dd>
3583: <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>
3584: <dd><dl>
3585: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
3586: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
3587: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
3588: </dl></dd>
3589: <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>
3590: <dd><dl>
1.78 rillig 3591: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
3592: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
3593: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
3594: </dl></dd>
3595: <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>
3596: <dd><dl>
3597: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
3598: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
3599: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
3600: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
3601: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
3602: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
3603: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
3604: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
3605: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
3606: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
3607: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
3608: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
3609: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
3610: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
3611: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
3612: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
3613: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.77 rillig 3614: </dl></dd>
1.78 rillig 3615: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.77 rillig 3616: </dl></dd>
3617: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
3618: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
3619: <dd><dl>
3620: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
3621: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
3622: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
3623: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
3624: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
3625: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 3626: </dl></dd>
1.77 rillig 3627: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.75 rillig 3628: </dl>
3629: </div>
1.77 rillig 3630: </div>
3631: <div class="chapter" lang="en">
3632: <div class="titlepage"><div><div><h2 class="title">
3633: <a name="creating"></a>Chapter 8. Creating a new pkgsrc package from scratch</h2></div></div></div>
3634: <p>When you find a package that is not yet in pkgsrc, you
3635: most likely have a URL from where you can download the source
3636: code. Starting with this URL, creating a package involves only a
3637: few steps.</p>
3638: <div class="procedure"><ol type="1">
3639: <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>
3640: <li><p>Then, choose one of the top-level directories as the
3641: category in which you want to place your package. You can also
3642: create a directory of your own (maybe called
3643: <code class="filename">local</code>). In that category directory, create
3644: another directory for your package and change into
3645: it.</p></li>
3646: <li><p>Run the program <span><strong class="command">url2pkg</strong></span>, which
3647: will ask you for a URL. Enter the URL of the distribution file
3648: (in most cases a <code class="filename">.tar.gz</code> file) and watch
3649: how the basic ingredients of your package are created
3650: automatically. The distribution file is extracted automatically
3651: to fill in some details in the <code class="filename">Makefile</code>
3652: that would otherwise have to be done manually.</p></li>
3653: <li>
3654: <p>Examine the extracted files to determine the
3655: dependencies of your package. Ideally, this is mentioned in some
3656: <code class="filename">README</code> file, but things may differ. For
3657: each of these dependencies, look where it exists in pkgsrc, and
3658: if there is a file called <code class="filename">buildlink3.mk</code> in
3659: that directory, add a line to your package
3660: <code class="filename">Makefile</code> which includes that file just
3661: before the last line. If the <code class="filename">buildlink3.mk</code>
3662: file does not exist, add a <code class="varname">DEPENDS</code> line to
3663: the Makefile, which specifies the version of the dependency and
3664: where it can be found in pkgsrc. This line should be placed in
3665: the third paragraph. If the dependency is only needed for
3666: building the package, but not when using it, use
3667: <code class="varname">BUILD_DEPENDS</code> instead of
3668: <code class="varname">DEPENDS</code>. Your package may then look like
3669: this:</p>
3670: <pre class="programlisting">
3671: [...]
3672:
3673: BUILD_DEPENDS+= lua>=5.0:../../lang/lua
3674: DEPENDS+= screen-[0-9]*:../../misc/screen
3675: DEPENDS+= screen>=4.0:../../misc/screen
3676:
3677: [...]
3678:
3679: .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
3680: .include "../../devel/glib2/buildlink3.mk"
3681: .include "../../mk/bsd.pkg.mk"
3682: </pre>
3683: </li>
3684: <li><p>Run <span><strong class="command">pkglint</strong></span> to see what things
3685: still need to be done to make your package a “<span class="quote">good</span>”
3686: one. If you don't know what pkglint's warnings want to tell you,
3687: try <span><strong class="command">pkglint --explain</strong></span> or <span><strong class="command">pkglint
3688: -e</strong></span>, which outputs additional
3689: explanations.</p></li>
3690: <li><p>Now, run <span><strong class="command">bmake</strong></span> to build the
3691: package. For the various things that can go wrong in this phase,
3692: consult <a href="#fixes" title="Chapter 17. Making your package work">Chapter 17, <i>Making your package work</i></a>.</p></li>
3693: <li><p>When the package builds fine, the next step is to
3694: install the package. Run <span><strong class="command">bmake install</strong></span> and
3695: hope that everything works.</p></li>
3696: <li><p>Up to now, the file <code class="filename">PLIST</code>,
3697: which contains a list of the files that are installed by the
3698: package, is nearly empty. Run <span><strong class="command">bmake print-PLIST
3699: >PLIST</strong></span> to generate a probably correct list. Check
3700: the file using your preferred text editor to see if the list of
3701: files looks plausible.</p></li>
3702: <li><p>Run <span><strong class="command">pkglint</strong></span> again to see if the
3703: generated <code class="filename">PLIST</code> contains garbage or
3704: not.</p></li>
3705: <li><p>When you ran <span><strong class="command">bmake install</strong></span>, the
3706: package has been registered in the database of installed files,
3707: but with an empty list of files. To fix this, run <span><strong class="command">bmake
3708: deinstall</strong></span> and <span><strong class="command">bmake install</strong></span> again.
3709: Now the package is registered with the list of files from
3710: <code class="filename">PLIST</code>.</p></li>
3711: <li><p>Run <span><strong class="command">bmake package</strong></span> to create a
3712: binary package from the set of installed files.</p></li>
3713: </ol></div>
3714: </div>
1.75 rillig 3715: <div class="chapter" lang="en">
3716: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3717: <a name="components"></a>Chapter 9. Package components - files, directories and contents</h2></div></div></div>
1.75 rillig 3718: <div class="toc">
3719: <p><b>Table of Contents</b></p>
3720: <dl>
1.77 rillig 3721: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
3722: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
3723: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
3724: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
3725: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 3726: <dd><dl>
3727: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
3728: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
3729: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
3730: </dl></dd>
1.77 rillig 3731: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
3732: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
1.75 rillig 3733: </dl>
3734: </div>
3735: <p> Whenever you're preparing a package, there are a number of
3736: files involved which are described in the following
3737: sections. </p>
3738: <div class="sect1" lang="en">
3739: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3740: <a name="components.Makefile"></a>9.1. <code class="filename">Makefile</code></h2></div></div></div>
1.75 rillig 3741: <p>Building, installation and creation of a binary package are all
1.76 rillig 3742: controlled by the package's <code class="filename">Makefile</code>.
3743: The <code class="filename">Makefile</code> describes various things about
1.75 rillig 3744: a package, for example from where to get it, how to configure,
3745: build, and install it.
3746: </p>
1.76 rillig 3747: <p>A package <code class="filename">Makefile</code> contains several
1.75 rillig 3748: sections that describe the package.</p>
3749: <p>In the first section there are the following variables, which
1.81 rillig 3750: should appear exactly in the order given here. The ordering and
3751: grouping of variables is mostly historical and has no further
3752: meaning.</p>
1.75 rillig 3753: <div class="itemizedlist"><ul type="disc">
3754: <li><p><code class="varname">DISTNAME</code> is the basename of the
3755: distribution file to be downloaded from the package's
3756: website.</p></li>
3757: <li><p><code class="varname">PKGNAME</code> is the name of the
3758: package, as used by pkgsrc. You only need to provide it if it
3759: differs from <code class="varname">DISTNAME</code>. Usually it is the directory name together
3760: with the version number. It must match the regular expression
3761: <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
3762: starts with a letter or digit, and contains only letters, digits,
3763: dashes, underscores, dots and plus signs.</p></li>
3764: <li>
3765: <p><code class="varname">CATEGORIES</code> is a list of categories
3766: which the package fits in. You can choose any of the top-level
3767: directories of pkgsrc for it.</p>
3768: <p>Currently the following values are available for
3769: <code class="varname">CATEGORIES</code>. If more than
3770: one is used, they need to be separated by spaces:</p>
3771: <pre class="programlisting">
3772: archivers cross geography meta-pkgs security
3773: audio databases graphics misc shells
3774: benchmarks devel ham multimedia sysutils
3775: biology editors inputmethod net textproc
3776: cad emulators lang news time
3777: chat finance mail parallel wm
3778: comms fonts math pkgtools www
3779: converters games mbone print x11
1.1 grant 3780: </pre>
1.75 rillig 3781: </li>
1.81 rillig 3782: <li><p><code class="varname">MASTER_SITES</code>,
3783: <code class="varname">DYNAMIC_MASTER_SITES</code>,
3784: <code class="varname">DIST_SUBDIR</code>, <code class="varname">EXTRACT_SUFX</code>
3785: and <code class="varname">DISTFILES</code> are discussed in detail in
3786: <a href="#build.fetch" title="15.5. The fetch phase">Section 15.5, “The <span class="emphasis"><em>fetch</em></span> phase”</a>.</p></li>
1.75 rillig 3787: </ul></div>
3788: <p>The second section contains information about separately
3789: downloaded patches, if any.
3790: </p>
3791: <div class="itemizedlist"><ul type="disc">
3792: <li><p><code class="varname">PATCHFILES:</code>
3793: Name(s) of additional files that contain distribution patches.
3794: There is no default. pkgsrc will look for them at
3795: <code class="varname">PATCH_SITES</code>.
3796: They will automatically be uncompressed before patching if
1.76 rillig 3797: the names end with <code class="filename">.gz</code> or
3798: <code class="filename">.Z</code>.</p></li>
1.75 rillig 3799: <li><p><code class="varname">PATCH_SITES</code>:
3800: Primary location(s) for distribution patch files (see
3801: <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
3802: </ul></div>
3803: <p>
3804: </p>
3805: <p>The third section contains the following variables.
3806: </p>
3807: <div class="itemizedlist"><ul type="disc">
3808: <li><p><code class="varname">MAINTAINER</code> is the email address
3809: of the person who feels responsible for this package, and who is
3810: most likely to look at problems or questions regarding this
3811: 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
3812: developers should contact the <code class="varname">MAINTAINER</code> before
3813: making major changes to the package. When packaging a new program,
3814: set <code class="varname">MAINTAINER</code> to yourself. If you really can't
3815: maintain the package for future updates, set it to
3816: <code class="email"><<a href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>></code>.</p></li>
3817: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
3818: find more information about the package.</p></li>
3819: <li><p><code class="varname">COMMENT</code> is a one-line
3820: description of the package (should not include the package
3821: name).</p></li>
3822: </ul></div>
3823: <p>
3824: </p>
3825: <p>Other variables that affect the build:
3826: </p>
3827: <div class="itemizedlist"><ul type="disc"><li>
3828: <p><code class="varname">WRKSRC</code>: The directory where the
3829: interesting distribution files of the package are found. The
1.76 rillig 3830: default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
1.75 rillig 3831: works for most packages.</p>
3832: <p>If a package doesn't create a subdirectory for itself
3833: (most GNU software does, for instance), but extracts itself in
3834: the current directory, you should set <code class="varname">WRKSRC=
3835: ${WRKDIR}</code>.</p>
3836: <p>If a package doesn't create a subdirectory with the name
3837: of <code class="varname">DISTNAME</code> but some different name, set
3838: <code class="varname">WRKSRC</code> to point to the proper name in
1.76 rillig 3839: <code class="filename">${WRKDIR}</code>, for example <code class="varname">WRKSRC=
3840: ${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 3841: <p>The name of the working directory created by pkgsrc is
3842: taken from the <code class="varname">WRKDIR_BASENAME</code> variable. By
1.76 rillig 3843: default, its value is <code class="filename">work</code>. If you want
1.75 rillig 3844: to use the same pkgsrc tree for building different kinds of
3845: binary packages, you can change the variable according to your
3846: needs. Two other variables handle common cases of setting
3847: <code class="varname">WRKDIR_BASENAME</code> individually. If
3848: <code class="varname">OBJHOSTNAME</code> is defined in
1.76 rillig 3849: <code class="filename">/etc/mk.conf</code>, the first component of the
1.75 rillig 3850: host's name is attached to the directory name. If
3851: <code class="varname">OBJMACHINE</code> is defined, the platform name is
1.76 rillig 3852: attached, which might look like <code class="filename">work.i386</code>
3853: or <code class="filename">work.sparc</code>.</p>
1.75 rillig 3854: </li></ul></div>
3855: <p>
3856: </p>
3857: <p>Please pay attention to the following gotchas:</p>
3858: <div class="itemizedlist"><ul type="disc">
3859: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are installed in
3860: compressed form by the package; see comment in
1.76 rillig 3861: <code class="filename">bsd.pkg.mk</code>.</p></li>
3862: <li><p>Replace <code class="filename">/usr/local</code> with
1.75 rillig 3863: “<span class="quote">${PREFIX}</span>” in all files (see patches, below).</p></li>
3864: <li><p>If the package installs any info files, see
1.78 rillig 3865: <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 3866: </ul></div>
3867: </div>
3868: <div class="sect1" lang="en">
3869: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3870: <a name="components.distinfo"></a>9.2. <code class="filename">distinfo</code></h2></div></div></div>
1.76 rillig 3871: <p>The <code class="filename">distinfo</code> file contains the message
1.75 rillig 3872: digest, or checksum, of each distfile needed for the package. This
3873: ensures that the distfiles retrieved from the Internet have not been
3874: corrupted during transfer or altered by a malign force to introduce
3875: a security hole. Due to recent rumor about weaknesses of digest
3876: algorithms, all distfiles are protected using both SHA1 and RMD160
3877: message digests, as well as the file size.</p>
1.76 rillig 3878: <p>The <code class="filename">distinfo</code> file also contains the
1.75 rillig 3879: checksums for all the patches found in the
1.77 rillig 3880: <code class="filename">patches</code> directory (see <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a>).</p>
1.76 rillig 3881: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.75 rillig 3882: <span><strong class="command">make makedistinfo</strong></span> or <span><strong class="command">make mdi</strong></span>
3883: command.</p>
3884: <p>Some packages have different sets of distfiles depending on
1.76 rillig 3885: 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
3886: <code class="filename">distinfo</code> file and care should be taken when
1.75 rillig 3887: upgrading such a package to ensure distfile information is not
3888: lost.</p>
3889: </div>
3890: <div class="sect1" lang="en">
3891: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3892: <a name="components.patches"></a>9.3. patches/*</h2></div></div></div>
1.75 rillig 3893: <p>This directory contains files that are used by the
3894: <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
3895: modify the sources as distributed in the distribution file into a form
3896: that will compile and run perfectly on NetBSD. The files are applied
3897: successively in alphabetic order (as returned by a shell
3898: “<span class="quote">patches/patch-*</span>” glob expansion), so
1.76 rillig 3899: <code class="filename">patch-aa</code> is applied before
3900: <code class="filename">patch-ab</code>, etc.</p>
3901: <p>The <code class="filename">patch-*</code> files should be in
1.75 rillig 3902: <span><strong class="command">diff -bu</strong></span> format, and apply without a fuzz to avoid
3903: problems. (To force patches to apply
3904: with fuzz you can set <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>).
3905: Furthermore, do not put changes for more than one file into a single
3906: patch file, as this will make future modifications more difficult.</p>
3907: <p>Similar, a file should be patched at most once, not several times by
3908: several different patches. If a file needs several patches, they should
3909: be combined into one file.</p>
3910: <p>One important thing to mention is to pay attention that no RCS IDs
3911: get stored in the patch files, as these will cause problems when
3912: later checked into the NetBSD CVS tree. Use the
3913: <span><strong class="command">pkgdiff</strong></span> from the
1.76 rillig 3914: <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 3915: these problems.</p>
3916: <p>For even more automation, we recommend using <span><strong class="command">mkpatches</strong></span> from the same
3917: package to make a whole set of patches. You just have to backup files
1.76 rillig 3918: before you edit them to <code class="filename">filename.orig</code>, e.g. with
1.75 rillig 3919: <span><strong class="command">cp -p filename filename.orig</strong></span> or, easier, by using
3920: <span><strong class="command">pkgvi</strong></span> again from the same package. If you upgrade a package
3921: this way, you can easily compare the new set of patches with the
3922: previously existing one with <span><strong class="command">patchdiff</strong></span>.</p>
3923: <p>When you have finished a package, remember to generate the checksums
3924: for the patch files by using the <span><strong class="command">make makepatchsum</strong></span>
1.77 rillig 3925: command, see <a href="#components.distinfo" title="9.2. distinfo">Section 9.2, “<code class="filename">distinfo</code>”</a>.</p>
1.75 rillig 3926: <p>When adding a patch that corrects a problem in the distfile (rather
3927: than e.g. enforcing pkgsrc's view of where man pages should go), send
3928: the patch as a bug report to the maintainer. This benefits
3929: non-pkgsrc users of the package, and usually enables removing
3930: the patch in future version.</p>
3931: <p>Patch files that are distributed by the author or other
3932: maintainers can be listed in
3933: <code class="varname">$PATCHFILES</code>. </p>
3934: <p>If it is desired to store any patches that should not be committed into
3935: pkgsrc, they can be kept outside the pkgsrc tree in the
1.76 rillig 3936: <code class="filename">$LOCALPATCHES</code>
1.75 rillig 3937: directory. The directory tree there is expected to have the same
3938: “<span class="quote">category/package</span>” structure as pkgsrc, and patches are
3939: expected to be stored inside these dirs (also known as
1.76 rillig 3940: <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
1.75 rillig 3941: example, if you want to keep a private patch for
1.76 rillig 3942: <code class="filename">pkgsrc/graphics/png</code>, keep
3943: it in <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
1.75 rillig 3944: files in the named directory are expected to be patch files, and
3945: <span class="emphasis"><em>they are applied after pkgsrc patches are applied</em></span>.</p>
3946: </div>
3947: <div class="sect1" lang="en">
3948: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3949: <a name="other-mandatory-files"></a>9.4. Other mandatory files</h2></div></div></div>
1.75 rillig 3950: <div class="variablelist"><dl>
1.76 rillig 3951: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
1.75 rillig 3952: <dd><p>A multi-line description of the piece of software. This should include
3953: any credits where they are due. Please bear in mind that others do not
3954: share your sense of humour (or spelling idiosyncrasies), and that others
3955: will read everything that you write here.</p></dd>
1.76 rillig 3956: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
1.75 rillig 3957: <dd><p>
3958: This file governs the files that are installed on your system: all the
3959: binaries, manual pages, etc. There are other directives which may be
3960: entered in this file, to control the creation and deletion of
3961: directories, and the location of inserted files.
1.77 rillig 3962: See <a href="#plist" title="Chapter 11. PLIST issues">Chapter 11, <i>PLIST issues</i></a> for more information. </p></dd>
1.75 rillig 3963: </dl></div>
3964: </div>
3965: <div class="sect1" lang="en">
3966: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3967: <a name="components.optional"></a>9.5. Optional files</h2></div></div></div>
1.78 rillig 3968: <div class="sect2" lang="en">
3969: <div class="titlepage"><div><div><h3 class="title">
3970: <a name="components.optional.bin"></a>9.5.1. Files affecting the binary package</h3></div></div></div>
1.75 rillig 3971: <div class="variablelist"><dl>
1.76 rillig 3972: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.75 rillig 3973: <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>.
3974: First time after package
3975: extraction and before files are moved in place, the second time after
3976: the files to install are moved in place. This can be used to do any
3977: custom procedures not possible with @exec commands in
1.76 rillig 3978: <code class="filename">PLIST</code>. See
1.75 rillig 3979: <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 3980: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
1.75 rillig 3981: <dd><p>This script is executed before and after any files are removed. It is
3982: this script's responsibility to clean up any additional messy details
3983: around the package's installation, since all pkg_delete knows is how to
3984: delete the files created in the original distribution.
3985: 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>
3986: 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 3987: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
1.75 rillig 3988: <dd>
3989: <p>This file is displayed after installation of the package.
3990: Useful for things like legal notices on almost-free
3991: software and hints for updating config files after
3992: installing modules for apache, PHP etc.
3993: Please note that you can modify variables in it easily by using
3994: <code class="varname">MESSAGE_SUBST</code> in the package's
1.76 rillig 3995: <code class="filename">Makefile</code>:</p>
1.75 rillig 3996: <pre class="programlisting">
3997: MESSAGE_SUBST+= SOMEVAR="somevalue"
1.1 grant 3998: </pre>
1.75 rillig 3999: <p>replaces "${SOMEVAR}" with “<span class="quote">somevalue</span>” in
1.76 rillig 4000: <code class="filename">MESSAGE</code>.</p>
1.75 rillig 4001: </dd>
1.78 rillig 4002: <dt><span class="term"><code class="filename">ALTERNATIVES</code></span></dt>
4003: <dd><p>FIXME: There is no documentation on the
4004: alternatives framework.</p></dd>
4005: </dl></div>
4006: </div>
4007: <div class="sect2" lang="en">
4008: <div class="titlepage"><div><div><h3 class="title">
4009: <a name="components.optional.build"></a>9.5.2. Files affecting the build process</h3></div></div></div>
4010: <div class="variablelist"><dl>
4011: <dt><span class="term"><code class="filename">Makefile.common</code></span></dt>
4012: <dd><p>This file contains arbitrary things that could
4013: also go into a <code class="filename">Makefile</code>, but its purpose is
4014: to be used by more than one package. This file should only be
4015: used when the packages that will use the file are known in
4016: advance. For other purposes it is often better to write a
4017: <code class="filename">*.mk</code> file and give it a good name that
4018: describes what it does.</p></dd>
4019: <dt><span class="term"><code class="filename">buildlink3.mk</code></span></dt>
4020: <dd><p>This file contains the dependency information
4021: for the buildlink3 framework (see <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a>).</p></dd>
4022: <dt><span class="term"><code class="filename">hacks.mk</code></span></dt>
4023: <dd><p>This file contains workarounds for compiler bugs
4024: and similar things. It is included automatically by the pkgsrc
4025: infrastructure, so you don't need an extra
4026: <code class="literal">.include</code> line for
4027: it.</p></dd>
4028: <dt><span class="term"><code class="filename">options.mk</code></span></dt>
4029: <dd><p>This file contains the code for the
4030: package-specific options (see <a href="#options" title="Chapter 14. Options handling">Chapter 14, <i>Options handling</i></a>) that can be
4031: selected by the user. If a package has only one or two options,
4032: it is equally acceptable to put the code directly into the
4033: <code class="filename">Makefile</code>.</p></dd>
4034: </dl></div>
4035: </div>
4036: <div class="sect2" lang="en">
4037: <div class="titlepage"><div><div><h3 class="title">
4038: <a name="components.optional.none"></a>9.5.3. Files affecting nothing at all</h3></div></div></div>
4039: <div class="variablelist"><dl>
4040: <dt><span class="term"><code class="filename">README*</code></span></dt>
4041: <dd><p>These files do not take place in the creation of
4042: a package and thus are purely informative to the package
4043: developer.</p></dd>
4044: <dt><span class="term"><code class="filename">TODO</code></span></dt>
4045: <dd><p>This file contains things that need to be done
4046: to make the package even
4047: better.</p></dd>
1.75 rillig 4048: </dl></div>
4049: </div>
1.78 rillig 4050: </div>
1.75 rillig 4051: <div class="sect1" lang="en">
4052: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4053: <a name="work-dir"></a>9.6. <code class="filename">work*</code></h2></div></div></div>
1.75 rillig 4054: <p>When you type <span><strong class="command">make</strong></span>, the distribution files are
4055: unpacked into the directory denoted by
4056: <code class="varname">WRKDIR</code>. It can be removed by running
4057: <span><strong class="command">make clean</strong></span>. Besides the sources, this
4058: directory is also used to keep various timestamp files.
4059: The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
1.76 rillig 4060: The default is <code class="filename">${.CURDIR}/work</code>
4061: or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
1.75 rillig 4062: if <code class="varname">OBJMACHINE</code> is set.</p>
4063: </div>
4064: <div class="sect1" lang="en">
4065: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4066: <a name="files-dir"></a>9.7. <code class="filename">files/*</code></h2></div></div></div>
1.75 rillig 4067: <p>If you have any files that you wish to be placed in the package prior
4068: to configuration or building, you could place these files here and use
4069: a “<span class="quote">${CP}</span>” command in the
4070: “<span class="quote">pre-configure</span>” target to achieve
4071: this. Alternatively, you could simply diff the file against
1.76 rillig 4072: <code class="filename">/dev/null</code> and use the patch mechanism to manage
1.75 rillig 4073: the creation of this file.</p>
4074: </div>
4075: </div>
4076: <div class="chapter" lang="en">
4077: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4078: <a name="makefile"></a>Chapter 10. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.75 rillig 4079: <div class="toc">
4080: <p><b>Table of Contents</b></p>
4081: <dl>
1.77 rillig 4082: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
4083: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
4084: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
4085: <dd><dl>
4086: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
4087: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
4088: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
4089: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
4090: <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 4091: </dl></dd>
4092: </dl>
4093: </div>
1.76 rillig 4094: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
1.75 rillig 4095: each of which forms a well-defined part of the pkgsrc system. Using
4096: 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
4097: like pkgsrc requires some discipline to keep the code correct and
4098: understandable.</p>
1.76 rillig 4099: <p>The basic ingredients for <code class="filename">Makefile</code>
1.75 rillig 4100: programming are variables (which are actually macros) and shell
4101: commands. Among these shell commands may even be more complex ones
4102: 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
4103: as intended it is necessary to quote all variables correctly when they
4104: are used.</p>
4105: <p>This chapter describes some patterns, that appear quite often in
1.76 rillig 4106: <code class="filename">Makefile</code>s, including the pitfalls that come along
1.75 rillig 4107: with them.</p>
4108: <div class="sect1" lang="en">
4109: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4110: <a name="makefile.variables"></a>10.1. <code class="filename">Makefile</code> variables</h2></div></div></div>
1.76 rillig 4111: <p><code class="filename">Makefile</code> variables contain strings that
1.75 rillig 4112: can be processed using the five operators ``='', ``+='', ``?='',
4113: ``:='', 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
4114: page.</p>
4115: <p>When a variable's value is parsed from a
1.76 rillig 4116: <code class="filename">Makefile</code>, the hash character ``#'' and the
1.75 rillig 4117: backslash character ``\'' are handled specially. If a backslash is
4118: followed by a newline, any whitespace immediately in front of the
4119: backslash, the backslash, the newline, and any whitespace
4120: immediately behind the newline are replaced with a single space. A
4121: backslash character and an immediately following hash character are
4122: replaced with a single hash character. Otherwise, the backslash is
4123: passed as is. In a variable assignment, any hash character that is
4124: not preceded by a backslash starts a comment that continues upto the
4125: end of the logical line.</p>
4126: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
4127: the only way to create a variable consisting of a single backslash
4128: is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
4129: <p>So far for defining variables. The other thing you can do with
4130: variables is evaluating them. A variable is evaluated when it is
4131: part of the right side of the ``:='' or the ``!='' operator, or
4132: directly before executing a shell command which the variable is part
4133: 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
4134: is, variables are not evaluated until there's no other way. The
4135: ``modifiers'' mentioned in the man page also evaluate the
4136: variable.</p>
4137: <p>Some of the modifiers split the string into words and then
4138: operate on the words, others operate on the string as a whole. When
4139: a string is split into words, it is split as you would expect
4140: 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 4141: <p>No rule without exception—the <span><strong class="command">.for</strong></span>
1.75 rillig 4142: loop does not follow the shell quoting rules but splits at sequences
4143: of whitespace.</p>
4144: <p>There are several types of variables that should be handled
4145: differently. Strings and two types of lists.</p>
4146: <div class="itemizedlist"><ul type="disc">
4147: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
4148: characters. Nevertheless, you should restrict yourself to only
4149: using printable characters. Examples are
4150: <code class="varname">PREFIX</code> and
4151: <code class="varname">COMMENT</code>.</p></li>
4152: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
4153: are never exported to any shell command. Their elements are
4154: separated by whitespace. Therefore, the elements themselves cannot
4155: have embedded whitespace. Any other characters are allowed.
4156: Internal lists can be used in <span><strong class="command">.for</strong></span> loops.
4157: Examples are <code class="varname">DEPENDS</code> and
4158: <code class="varname">BUILD_DEPENDS</code>.</p></li>
4159: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
4160: may be exported to a shell command. Their elements can contain any
4161: characters, including whitespace. That's why they cannot be used
4162: in <span><strong class="command">.for</strong></span> loops. Examples are
4163: <code class="varname">DISTFILES</code> and
4164: <code class="varname">MASTER_SITES</code>.</p></li>
4165: </ul></div>
4166: <div class="sect2" lang="en">
4167: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4168: <a name="makefile.variables.names"></a>10.1.1. Naming conventions</h3></div></div></div>
1.75 rillig 4169: <div class="itemizedlist"><ul type="disc">
4170: <li><p>All variable names starting with an underscore
4171: are reserved for use by the pkgsrc infrastructure. They shall
4172: not be used by package
1.76 rillig 4173: <code class="filename">Makefile</code>s.</p></li>
1.75 rillig 4174: <li><p>In <span><strong class="command">.for</strong></span> loops you should use
4175: lowercase variable names for the iteration
4176: variables.</p></li>
4177: <li><p>All list variables should have a ``plural''
4178: name, e.g. <code class="varname">PKG_OPTIONS</code> or
4179: <code class="varname">DISTFILES</code>.</p></li>
4180: </ul></div>
4181: </div>
4182: </div>
4183: <div class="sect1" lang="en">
4184: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4185: <a name="makefile.code"></a>10.2. Code snippets</h2></div></div></div>
1.75 rillig 4186: <p>This section presents you with some code snippets you should
4187: use in your own code. If you don't find anything appropriate here,
4188: you should test your code and add it here.</p>
4189: <div class="sect2" lang="en">
4190: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4191: <a name="adding-to-list"></a>10.2.1. Adding things to a list</h3></div></div></div>
1.75 rillig 4192: <pre class="programlisting">
4193: STRING= foo * bar `date`
4194: INT_LIST= # empty
4195: ANOTHER_INT_LIST= apache-[0-9]*:../../www/apache
4196: EXT_LIST= # empty
4197: ANOTHER_EXT_LIST= a=b c=d
1.1 grant 4198:
1.75 rillig 4199: INT_LIST+= ${STRING} # 1
4200: INT_LIST+= ${ANOTHER_INT_LIST} # 2
4201: EXT_LIST+= ${STRING:Q} # 3
4202: EXT_LIST+= ${ANOTHER_EXT_LIST} # 4
1.1 grant 4203: </pre>
1.75 rillig 4204: <p>When you add a string to an external list (example 3), it
4205: must be quoted. In all other cases, you must not add a quoting
4206: level. You must not merge internal and external lists, unless you
4207: are sure that all entries are correctly interpreted in both
4208: lists.</p>
4209: </div>
4210: <div class="sect2" lang="en">
4211: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4212: <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 4213: <pre class="programlisting">
4214: EXT_LIST= # empty
4215: .for i in ${INT_LIST}
4216: EXT_LIST+= ${i:Q}""
4217: .endfor
1.1 grant 4218: </pre>
1.75 rillig 4219: <p>This code converts the internal list
4220: <code class="varname">INT_LIST</code> into the external list
4221: <code class="varname">EXT_LIST</code>. As the elements of an internal list
4222: are unquoted they must be quoted here. The reason for appending
4223: <code class="varname">""</code> is explained below.</p>
4224: </div>
4225: <div class="sect2" lang="en">
4226: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4227: <a name="passing-variable-to-shell"></a>10.2.3. Passing variables to a shell command</h3></div></div></div>
1.79 rillig 4228: <p>Sometimes you may want to print an arbitrary string. There
4229: are many ways to get it wrong and only few that can handle every
4230: nastiness.</p>
1.75 rillig 4231: <pre class="programlisting">
4232: STRING= foo bar < > * `date` $$HOME ' "
4233: EXT_LIST= string=${STRING:Q} x=second\ item
1.1 grant 4234:
1.75 rillig 4235: all:
4236: echo ${STRING} # 1
4237: echo "${STRING}" # 2
4238: echo "${STRING:Q}" # 3
4239: echo ${STRING:Q} # 4
4240: echo x${STRING:Q} | sed 1s,.,, # 5
1.79 rillig 4241: printf "%s\\n" ${STRING:Q}"" # 6
1.75 rillig 4242: env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
1.1 grant 4243: </pre>
1.75 rillig 4244: <p>Example 1 leads to a syntax error in the shell, as the
4245: characters are just copied.</p>
4246: <p>Example 2 leads to a syntax error too, and if you leave out
4247: the last " character from <code class="varname">${STRING}</code>,
4248: <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
4249: variable would be evaluated, too.</p>
4250: <p>Example 3 outputs each space character preceded by a
4251: backslash (or not), depending on the implementation of the
4252: <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>
4253: <p>Example 4 handles correctly every string that does not start
4254: with a dash. In that case, the result depends on the
4255: 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
4256: guarantee that your input does not start with a dash, this form is
4257: appropriate.</p>
4258: <p>Example 5 handles even the case of a leading dash
4259: correctly.</p>
1.79 rillig 4260: <p>Example 6 also works with every string and is the
4261: light-weight solution, since it does not involve a pipe, which has
4262: its own problems.</p>
1.75 rillig 4263: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
4264: because the quoting has already been done when adding elements to
4265: the list.</p>
4266: <p>As internal lists shall not be passed to the shell, there is
4267: no example for it.</p>
4268: </div>
4269: <div class="sect2" lang="en">
4270: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4271: <a name="quoting-guideline"></a>10.2.4. Quoting guideline</h3></div></div></div>
1.75 rillig 4272: <p>There are many possible sources of wrongly quoted variables.
4273: This section lists some of the commonly known ones.</p>
4274: <div class="itemizedlist"><ul type="disc">
4275: <li>
4276: <p>Whenever you use the value of a list, think
4277: about what happens to leading or trailing whitespace. If the
4278: list is a well-formed shell expression, you can apply the
4279: <code class="varname">:M*</code> modifier to strip leading and trailing
4280: whitespace from each word. The <code class="varname">:M</code> operator
4281: first splits its argument according to the rules of the shell,
4282: and then creates a new list consisting of all words that match
4283: the shell glob expression <code class="varname">*</code>, that is: all.
4284: One class of situations where this is needed is when adding a
4285: variable like <code class="varname">CPPFLAGS</code> to
4286: <code class="varname">CONFIGURE_ARGS</code>. If the configure script
4287: invokes other configure scripts, it strips the leading and
4288: trailing whitespace from the variable and then passes it to the
4289: other configure scripts. But these configure scripts expect the
4290: (child) <code class="varname">CPPFLAGS</code> variable to be the same as
4291: the parent <code class="varname">CPPFLAGS</code>. That's why we better
4292: pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
4293: here is how we do it:</p>
4294: <pre class="programlisting">
4295: CPPFLAGS= # empty
4296: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX:Q}\"
4297: CPPFLAGS+= ${MY_CPPFLAGS}
1.1 grant 4298:
1.75 rillig 4299: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
1.1 grant 4300:
1.75 rillig 4301: all:
4302: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
4303: echo x${CONFIGURE_ARGS}x # properly trimmed
1.1 grant 4304: </pre>
1.75 rillig 4305: </li>
4306: <li><p>The example above contains one bug: The
4307: <code class="varname">${PREFIX}</code> is a properly quoted shell
4308: expression, but there is the C compiler after it, which also
4309: expects a properly quoted string (this time in C syntax). The
4310: version above is therefore only correct if
4311: <code class="varname">${PREFIX}</code> does not have embedded backslashes
4312: or double quotes. If you want to allow these, you have to add
4313: another layer of quoting to each variable that is used as a C
4314: string literal. You cannot use the <code class="varname">:Q</code>
4315: operator for it, as this operator only works for the
4316: shell.</p></li>
4317: <li>
4318: <p>Whenever a variable can be empty, the
4319: <code class="varname">:Q</code> operator can have surprising results. Here
4320: are two completely different cases which can be solved with the
4321: same trick.</p>
4322: <pre class="programlisting">
4323: EMPTY= # empty
4324: empty_test:
4325: for i in a ${EMPTY:Q} c; do \
4326: echo "$$i"; \
4327: done
1.1 grant 4328:
1.75 rillig 4329: for_test:
4330: .for i in a:\ a:\test.txt
4331: echo ${i:Q}
4332: echo "foo"
4333: .endfor
1.1 grant 4334: </pre>
1.75 rillig 4335: <p>The first example will only print two of the three lines
4336: we might have expected. This is because
4337: <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
4338: the shell cannot see. The workaround is to write
4339: <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
4340: as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
4341: -f ${FNAME:Q}</code> (both of these are wrong).</p>
4342: <p>The second example will only print three lines instead of
4343: four. The first line looks like <code class="varname">a:\ echo foo</code>.
4344: This is because the backslash of the value
4345: <code class="varname">a:\</code> is interpreted as a line-continuation by
4346: <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
4347: <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
4348: <code class="varname">${i:Q}""</code>.</p>
4349: </li>
4350: </ul></div>
4351: </div>
4352: <div class="sect2" lang="en">
4353: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4354: <a name="bsd-make-bug-workaround"></a>10.2.5. Workaround for a bug in BSD Make</h3></div></div></div>
1.75 rillig 4355: <p>The pkgsrc bmake program does not handle the following
4356: assignment correctly. In case <code class="varname">_othervar_</code>
4357: contains a ``-'' character, one of the closing braces is included
4358: in <code class="varname">${VAR}</code> after this code executes.</p>
4359: <pre class="programlisting">
4360: VAR:= ${VAR:N${_othervar_:C/-//}}
1.1 grant 4361: </pre>
1.75 rillig 4362: <p>For a more complex code snippet and a workaround, see the
1.76 rillig 4363: 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 4364: <code class="varname">bug1</code>.</p>
4365: </div>
4366: </div>
4367: </div>
4368: <div class="chapter" lang="en">
4369: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4370: <a name="plist"></a>Chapter 11. PLIST issues</h2></div></div></div>
1.75 rillig 4371: <div class="toc">
4372: <p><b>Table of Contents</b></p>
4373: <dl>
1.77 rillig 4374: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
4375: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
4376: <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>
4377: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
4378: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
4379: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
4380: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
4381: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
1.75 rillig 4382: </dl>
4383: </div>
1.76 rillig 4384: <p> The <code class="filename">PLIST</code> file contains a package's
1.75 rillig 4385: “<span class="quote">packing list</span>”, i.e. a list of files that belong to
1.76 rillig 4386: the package (relative to the <code class="filename">${PREFIX}</code>
1.75 rillig 4387: directory it's been installed in) plus some additional statements
4388: - 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.
4389: This chapter addresses some issues that need attention when
1.76 rillig 4390: dealing with the <code class="filename">PLIST</code> file (or files, see
1.75 rillig 4391: below!).</p>
4392: <div class="sect1" lang="en">
4393: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4394: <a name="rcs-id"></a>11.1. RCS ID</h2></div></div></div>
1.75 rillig 4395: <p>
4396: Be sure to add a RCS ID line as the first thing in any
1.76 rillig 4397: <code class="filename">PLIST</code> file you write:
1.75 rillig 4398: </p>
4399: <pre class="programlisting">
4400: @comment $NetBSD$
1.55 rillig 4401: </pre>
1.75 rillig 4402: </div>
4403: <div class="sect1" lang="en">
4404: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4405: <a name="automatic-plist-generation"></a>11.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.75 rillig 4406: <p>You can use the <span><strong class="command">make print-PLIST</strong></span> command
4407: to output a PLIST that matches any new files since the package
1.77 rillig 4408: 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 4409: more information on this target.</p>
4410: </div>
4411: <div class="sect1" lang="en">
4412: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4413: <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 4414: <p> If you have used any of the *-dirs packages, as explained in
1.77 rillig 4415: <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 4416: <span><strong class="command">make print-PLIST</strong></span> outputs a set of
4417: <code class="varname">@comment</code>s instead of real
4418: <code class="varname">@dirrm</code> lines. You can also do this for
4419: specific directories and files, so that the results of that
4420: command are very close to reality. This helps <span class="emphasis"><em>a
4421: lot</em></span> during the update of packages. </p>
4422: <p> The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
4423: of AWK patterns and actions that are used to filter the output of
4424: print-PLIST. You can <span class="emphasis"><em>append</em></span> any chunk of AWK
4425: scripting you like to it, but be careful with quoting. </p>
4426: <p> For example, to get all files inside the
1.76 rillig 4427: <code class="filename">libdata/foo</code> directory removed from the
1.75 rillig 4428: resulting PLIST:</p>
4429: <pre class="programlisting">
4430: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
1.55 rillig 4431: </pre>
1.75 rillig 4432: <p> And to get all the <code class="varname">@dirrm</code> lines referring
4433: to a specific (shared) directory converted to
4434: <code class="varname">@comment</code>s: </p>
4435: <pre class="programlisting">
4436: PRINT_PLIST_AWK+= /^@dirrm share\/specific/ { print "@comment " $$0; next; }
1.51 rillig 4437: </pre>
1.75 rillig 4438: </div>
4439: <div class="sect1" lang="en">
4440: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4441: <a name="plist.misc"></a>11.4. Variable substitution in PLIST</h2></div></div></div>
1.75 rillig 4442: <p>
4443: A number of variables are substituted automatically in PLISTs
4444: when a package is installed on a system. This includes the
4445: following variables: </p>
4446: <div class="variablelist"><dl>
4447: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
4448: <dd>
4449: <p>Some packages like emacs and perl embed information
4450: about which architecture they were built on into the
4451: pathnames where they install their files. To handle this
4452: case, PLIST will be preprocessed before actually used, and
4453: the symbol
4454: “<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>” will be
4455: replaced by what <span><strong class="command">uname -p</strong></span> gives. The
4456: same is done if the string
4457: <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
4458: PLIST somewhere - use this on packages that have GNU
4459: autoconf-created configure scripts.</p>
4460: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
4461: <h3 class="title">Legacy note</h3>
4462: <p>There used to be a symbol
4463: “<span class="quote"><code class="varname">$ARCH</code></span>” that
4464: was replaced by the output of <span><strong class="command">uname
4465: -m</strong></span>, but that's no longer supported and has
4466: been removed.</p>
4467: </div>
4468: </dd>
4469: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
4470: <dd>
4471: <p>Some packages want to embed the OS name and version
4472: into some paths. To do this, use these variables in the
1.76 rillig 4473: <code class="filename">PLIST</code>:
1.75 rillig 4474: </p>
4475: <div class="itemizedlist"><ul type="disc">
4476: <li><p><code class="varname">${OPSYS}</code> - output of “<span class="quote"><span><strong class="command">uname -s</strong></span></span>”</p></li>
4477: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. “<span class="quote">solaris</span>”)</p></li>
4478: <li><p><code class="varname">${OS_VERSION}</code> - “<span class="quote"><span><strong class="command">uname -r</strong></span></span>”</p></li>
4479: </ul></div>
4480: </dd>
4481: </dl></div>
4482: <p> For a complete list of values which are replaced by
1.76 rillig 4483: default, please look in <code class="filename">bsd.pkg.mk</code> (and
1.75 rillig 4484: search for <span class="emphasis"><em>PLIST_SUBST</em></span>). </p>
4485: <p> If you want to change other variables not listed above, you
4486: can add variables and their expansions to this variable in the
1.77 rillig 4487: 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 4488: <pre class="programlisting">
4489: PLIST_SUBST+= SOMEVAR="somevalue"
1.1 grant 4490: </pre>
1.75 rillig 4491: <p>This replaces all occurrences of “<span class="quote">${SOMEVAR}</span>”
4492: in the PLIST with “<span class="quote">somevalue</span>”. </p>
4493: </div>
4494: <div class="sect1" lang="en">
4495: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4496: <a name="manpage-compression"></a>11.5. Man page compression</h2></div></div></div>
1.75 rillig 4497: <p>Man pages should be installed in compressed form if
1.76 rillig 4498: <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
1.75 rillig 4499: and uncompressed otherwise. To handle this in the
1.76 rillig 4500: <code class="filename">PLIST</code> file, the suffix “<span class="quote">.gz</span>” is
1.75 rillig 4501: appended/removed automatically for man pages according to
4502: <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
4503: or not, see above for details. This modification of the
1.76 rillig 4504: <code class="filename">PLIST</code> file is done on a copy of it, not
4505: <code class="filename">PLIST</code> itself.</p>
1.75 rillig 4506: </div>
4507: <div class="sect1" lang="en">
4508: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4509: <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 4510: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
1.75 rillig 4511: in generating the binary package, set the variable
4512: <code class="varname">PLIST_SRC</code> to the names of that file(s).
4513: 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
4514: important.</p>
4515: </div>
4516: <div class="sect1" lang="en">
4517: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4518: <a name="platform-specific-plist"></a>11.7. Platform-specific and differing PLISTs</h2></div></div></div>
1.75 rillig 4519: <p>Some packages decide to install a different set of files based on
4520: the operating system being used. These differences can be
4521: automatically handled by using the following files:</p>
4522: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4523: <li><p><code class="filename">PLIST.common</code></p></li>
4524: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
4525: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
4526: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
4527: <li><p><code class="filename">PLIST.common_end</code></p></li>
1.75 rillig 4528: </ul></div>
4529: </div>
4530: <div class="sect1" lang="en">
4531: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4532: <a name="faq.common-dirs"></a>11.8. Sharing directories between packages</h2></div></div></div>
1.75 rillig 4533: <p> A “<span class="quote">shared directory</span>” is a directory where
4534: multiple (and unrelated) packages install files. These
4535: directories are problematic because you have to add special tricks
4536: in the PLIST to conditionally remove them, or have some
4537: centralized package handle them. </p>
4538: <p> Within pkgsrc, you'll find both approaches. If a directory
4539: is shared by a few unrelated packages, it's often not worth to add
4540: an extra package to remove it. Therefore, one simply does:
4541: </p>
4542: <pre class="programlisting">
4543: @unexec ${RMDIR} %D/path/to/shared/directory 2>/dev/null || ${TRUE}
1.1 grant 4544: </pre>
1.75 rillig 4545: <p> in the PLISTs of all affected packages, instead of the
4546: regular "@dirrm" line. </p>
4547: <p> However, if the directory is shared across many packages, two
4548: different solutions are available: </p>
4549: <div class="orderedlist"><ol type="1">
4550: <li><p> If the packages have a common dependency, the directory
4551: can be removed in that. For example, see
1.76 rillig 4552: <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 4553: removes the shared directory
1.76 rillig 4554: <code class="filename">share/omf</code>. </p></li>
1.75 rillig 4555: <li><p> If the packages using the directory are not related at
4556: all (they have no common dependencies), a *-dirs package is
4557: used. </p></li>
4558: </ol></div>
4559: <p> From now on, we'll discuss the second solution. To get an
4560: idea of the *-dirs packages available, issue: </p>
4561: <pre class="programlisting">
4562: <code class="prompt">%</code> cd .../pkgsrc
4563: <code class="prompt">%</code> ls -d */*-dirs
1.1 grant 4564: </pre>
1.75 rillig 4565: <p> Their use from other packages is very simple. The
4566: <code class="varname">USE_DIRS</code> variable takes a list of package names
4567: (without the “<span class="quote">-dirs</span>” part) together with the required
4568: version number (always pick the latest one when writing new
4569: packages). </p>
4570: <p> For example, if a package installs files under
1.76 rillig 4571: <code class="filename">share/applications</code>, it should have the
1.75 rillig 4572: following line in it:
4573: </p>
4574: <pre class="programlisting">
4575: USE_DIRS+= xdg-1.1
1.1 grant 4576: </pre>
1.75 rillig 4577: <p> After regenerating the PLIST using <span><strong class="command">make
4578: print-PLIST</strong></span>, you should get the right (commented out)
4579: lines. </p>
4580: <p> Note that even if your package is using
1.76 rillig 4581: <code class="filename">$X11BASE</code>, it must not depend on the
1.75 rillig 4582: *-x11-dirs packages. Just specify the name without that part and
1.76 rillig 4583: pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
1.75 rillig 4584: care of it. </p>
4585: </div>
4586: </div>
4587: <div class="chapter" lang="en">
4588: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4589: <a name="buildlink"></a>Chapter 12. Buildlink methodology</h2></div></div></div>
1.75 rillig 4590: <div class="toc">
4591: <p><b>Table of Contents</b></p>
4592: <dl>
1.77 rillig 4593: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
4594: <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 4595: <dd><dl>
1.77 rillig 4596: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
4597: <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 4598: </dl></dd>
1.77 rillig 4599: <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 4600: <dd><dl>
1.77 rillig 4601: <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>
4602: <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 4603: </dl></dd>
4604: </dl>
4605: </div>
4606: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
4607: are seen by a package's configure and build processes. This is implemented
4608: in a two step process:</p>
4609: <div class="orderedlist"><ol type="1">
4610: <li><p>Symlink headers and libraries for dependencies into
4611: <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
4612: of <code class="varname">WRKDIR</code>.</p></li>
4613: <li><p>Create wrapper scripts that are used in place of the normal compiler
4614: tools that translate <code class="option">-I${LOCALBASE}/include</code> and
4615: <code class="option">-L${LOCALBASE}/lib</code> into references to
4616: <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
4617: native compiler on some operating systems look like GCC, so that
4618: packages that expect GCC won't require modifications to build with
4619: those native compilers.</p></li>
4620: </ol></div>
4621: <p>This normalizes the environment in which a package is built so that the
4622: package may be built consistently despite what other software may be
4623: installed. Please note that the normal system header and library paths,
1.76 rillig 4624: e.g. <code class="filename">/usr/include</code>,
4625: <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
1.75 rillig 4626: designed to insulate the package build from non-system-supplied
4627: software. </p>
4628: <div class="sect1" lang="en">
4629: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4630: <a name="converting-to-buildlink3"></a>12.1. Converting packages to use buildlink3</h2></div></div></div>
1.75 rillig 4631: <p>The process of converting packages to use the buildlink3
4632: framework (“<span class="quote">bl3ifying</span>”) is fairly straightforward.
4633: The things to keep in mind are:</p>
4634: <div class="orderedlist"><ol type="1">
4635: <li><p> Ensure that the build always calls the wrapper scripts
4636: instead of the actual toolchain. Some packages are tricky,
4637: and the only way to know for sure is the check
1.76 rillig 4638: <code class="filename">${WRKDIR}/.work.log</code> to see if the
1.75 rillig 4639: wrappers are being invoked. </p></li>
4640: <li><p> Don't override <code class="varname">PREFIX</code> from within
4641: the package Makefile, e.g. Java VMs, standalone shells,
4642: etc., because the code to symlink files into
1.76 rillig 4643: <code class="filename">${BUILDLINK_DIR}</code> looks for files
1.75 rillig 4644: relative to “<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>”.
4645: </p></li>
4646: <li><p> Remember that <span class="emphasis"><em>only</em></span> the
1.76 rillig 4647: <code class="filename">buildlink3.mk</code> files that you list in a
1.75 rillig 4648: package's Makefile are added as dependencies for that package.
4649: </p></li>
4650: </ol></div>
4651: <p> If a dependency on a particular package is required for its libraries and
4652: headers, then we replace: </p>
4653: <pre class="programlisting">
4654: DEPENDS+= foo>=1.1.0:../../category/foo
1.1 grant 4655: </pre>
1.75 rillig 4656: <p>with</p>
4657: <pre class="programlisting">
4658: .include "../../category/foo/buildlink3.mk"
1.1 grant 4659: </pre>
1.75 rillig 4660: <p>The buildlink3.mk files usually define the required dependencies.
4661: If you need a newer version of the dependency when using buildlink3.mk
4662: files, then you can define it in your Makefile; for example:
4663: </p>
4664: <pre class="programlisting">
4665: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
4666: .include "../../category/foo/buildlink3.mk"
1.1 grant 4667: </pre>
1.76 rillig 4668: <p>There are several <code class="filename">buildlink3.mk</code>
4669: files in <code class="filename">pkgsrc/mk</code>
1.75 rillig 4670: that handle special package issues:</p>
4671: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4672: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
1.75 rillig 4673: the native or a pkgsrc Berkeley DB implementation based on
4674: the values of <code class="varname">BDB_ACCEPTED</code> and
4675: <code class="varname">BDB_DEFAULT</code>.</p></li>
1.76 rillig 4676: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
1.75 rillig 4677: comes with neither Curses nor NCurses, this will take care
1.76 rillig 4678: 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>
4679: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
1.75 rillig 4680: of <code class="varname">KRB5_ACCEPTED</code> to choose between
4681: adding a dependency on Heimdal or MIT-krb5 for packages that
4682: require a Kerberos 5 implementation.</p></li>
1.76 rillig 4683: <li><p><code class="filename">motif.buildlink3.mk</code> checks
1.75 rillig 4684: for a system-provided
1.76 rillig 4685: 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
4686: <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>
4687: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
1.75 rillig 4688: variables that may be used by packages that use the
4689: Open Sound System (OSS) API.</p></li>
1.76 rillig 4690: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
1.75 rillig 4691: either Postgres 7.3 or 7.4, whichever is found installed. See
4692: the file for more information. </p></li>
1.76 rillig 4693: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
1.75 rillig 4694: <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
1.76 rillig 4695: 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>
4696: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
1.75 rillig 4697: <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
4698: library.</p></li>
4699: </ul></div>
1.76 rillig 4700: <p>The comments in those <code class="filename">buildlink3.mk</code>
1.75 rillig 4701: files provide a more complete
4702: description of how to use them properly.</p>
4703: </div>
4704: <div class="sect1" lang="en">
4705: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4706: <a name="creating-buildlink3.mk"></a>12.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
1.76 rillig 4707: <p> A package's <code class="filename">buildlink3.mk</code> file is
1.75 rillig 4708: included by Makefiles to indicate the need to compile and link
4709: against header files and libraries provided by the package. A
1.76 rillig 4710: <code class="filename">buildlink3.mk</code> file should always provide
1.75 rillig 4711: enough information to add the correct type of dependency
4712: relationship and include any other
1.76 rillig 4713: <code class="filename">buildlink3.mk</code> files that it needs to find
1.75 rillig 4714: headers and libraries that it needs in turn.</p>
1.76 rillig 4715: <p> To generate an initial <code class="filename">buildlink3.mk</code>
4716: 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 4717: package is highly recommended. For most packages, the following
4718: command will generate a good starting point for
1.76 rillig 4719: <code class="filename">buildlink3.mk</code> files:</p>
1.75 rillig 4720: <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>
4721: <code class="prompt">%</code> createbuildlink >buildlink3.mk</code></strong></pre>
4722: <div class="sect2" lang="en">
4723: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4724: <a name="anatomy-of-bl3"></a>12.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
1.75 rillig 4725: <p>The following real-life example
1.76 rillig 4726: <code class="filename">buildlink3.mk</code> is taken
4727: from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
1.75 rillig 4728: <pre class="programlisting">
4729: # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
1.1 grant 4730:
1.75 rillig 4731: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
4732: TIFF_BUILDLINK3_MK:= ${TIFF_BUILDLINK3_MK}+
1.1 grant 4733:
1.75 rillig 4734: .if !empty(BUILDLINK_DEPTH:M+)
4735: BUILDLINK_DEPENDS+= tiff
4736: .endif
1.1 grant 4737:
1.75 rillig 4738: BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Ntiff}
4739: BUILDLINK_PACKAGES+= tiff
1.1 grant 4740:
1.75 rillig 4741: .if !empty(TIFF_BUILDLINK3_MK:M+)
4742: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
4743: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
4744: .endif # TIFF_BUILDLINK3_MK
1.1 grant 4745:
1.75 rillig 4746: .include "../../devel/zlib/buildlink3.mk"
4747: .include "../../graphics/jpeg/buildlink3.mk"
1.1 grant 4748:
1.75 rillig 4749: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
1.1 grant 4750: </pre>
1.75 rillig 4751: <p> The header and footer manipulate
4752: <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
1.76 rillig 4753: <code class="filename">buildlink3.mk</code> files and is used to track
1.75 rillig 4754: at what depth we are including
1.76 rillig 4755: <code class="filename">buildlink3.mk</code> files.</p>
1.75 rillig 4756: <p> The first section controls if the dependency on
4757: <em class="replaceable"><code>pkg</code></em> is added.
4758: <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
4759: packages for which dependencies are added by
4760: buildlink3.</p>
4761: <p> The second section advises pkgsrc that the
1.76 rillig 4762: <code class="filename">buildlink3.mk</code> file for
1.75 rillig 4763: <em class="replaceable"><code>pkg</code></em> has been included at some point.
4764: <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
1.76 rillig 4765: packages for which <code class="filename">buildlink3.mk</code> files
1.75 rillig 4766: have been included. It must <span class="emphasis"><em>always</em></span> be
1.76 rillig 4767: appended to within a <code class="filename">buildlink3.mk</code>
1.75 rillig 4768: file. </p>
4769: <p> The third section is protected from multiple inclusion
4770: and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
4771: added. Several important variables are set in the section:
4772: </p>
4773: <div class="itemizedlist"><ul type="disc">
4774: <li><p> <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4775: is the actual dependency recorded in the installed
4776: package; this should always be set using
4777: <span><strong class="command">+=</strong></span> to ensure that
4778: we're appending to any pre-existing list of values. This
4779: variable should be set to the first version of the
4780: package that had an API change.
4781: </p></li>
4782: <li><p> <code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
4783: is the location of the <em class="replaceable"><code>pkg</code></em>
4784: pkgsrc directory.</p></li>
4785: <li><p>
4786: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
4787: (not shown above) controls whether we use
4788: <code class="varname">BUILD_DEPENDS</code> or
4789: <code class="varname">DEPENDS</code> to add the dependency on
4790: <em class="replaceable"><code>pkg</code></em>.
4791: The build dependency is selected by setting
4792: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
4793: to “<span class="quote">build</span>”. By default, the
4794: full dependency is used.
4795: </p></li>
4796: <li><p>
4797: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
4798: and
4799: <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
4800: (not shown above) are lists of subdirectories of
1.76 rillig 4801: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4802: to add to the header and library search paths. These
4803: default to “<span class="quote">include</span>” and “<span class="quote">lib</span>”
4804: respectively. </p></li>
4805: <li><p>
4806: <code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
4807: (not shown above) is the list of preprocessor flags to add
4808: to <code class="varname">CPPFLAGS</code>, which are passed on to the
4809: configure and build phases. The “<span class="quote">-I</span>” option
4810: should be avoided and instead be handled using
4811: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
4812: above.</p></li>
4813: </ul></div>
4814: <p> The following variables are all optionally defined within
4815: this second section (protected against multiple inclusion) and
4816: control which package files are symlinked into
1.76 rillig 4817: <code class="filename">${BUILDLINK_DIR}</code> and how their names are
1.75 rillig 4818: transformed during the symlinking: </p>
4819: <div class="itemizedlist"><ul type="disc">
4820: <li><p>
4821: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
4822: (not shown above) is a shell glob pattern relative to
1.76 rillig 4823: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4824: to be symlinked into
1.76 rillig 4825: <code class="filename">${BUILDLINK_DIR}</code>,
4826: e.g. <code class="filename">include/*.h</code>. </p></li>
1.75 rillig 4827: <li><p>
4828: <code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
4829: (not shown above) is a shell pipeline that
4830: outputs to stdout a list of files relative to
1.76 rillig 4831: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
1.75 rillig 4832: The resulting files are to be symlinked
1.76 rillig 4833: into <code class="filename">${BUILDLINK_DIR}</code>. By default,
4834: this takes the <code class="filename">+CONTENTS</code> of a
1.75 rillig 4835: <em class="replaceable"><code>pkg</code></em> and filters it through
4836: <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.
4837: </p></li>
4838: <li><p>
4839: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
4840: (not shown above) is a filter command that filters
1.76 rillig 4841: <code class="filename">+CONTENTS</code> input into a list of files
1.75 rillig 4842: relative to
1.76 rillig 4843: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 4844: on stdout. By default for overwrite packages,
4845: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.76 rillig 4846: outputs the contents of the <code class="filename">include</code>
4847: and <code class="filename">lib</code> directories in the package
4848: <code class="filename">+CONTENTS</code>, and for pkgviews packages,
1.75 rillig 4849: it outputs any libtool archives in
1.76 rillig 4850: <code class="filename">lib</code> directories.
1.75 rillig 4851: </p></li>
4852: <li><p>
4853: <code class="varname">BUILDLINK_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
4854: (not shown above) is a list of sed arguments used to
4855: transform the name of the source filename into a
4856: destination filename, e.g. <span><strong class="command">-e
4857: "s|/curses.h|/ncurses.h|g"</strong></span>.
4858: </p></li>
4859: </ul></div>
4860: <p> The last section includes any
1.76 rillig 4861: <code class="filename">buildlink3.mk</code> needed for
1.75 rillig 4862: <em class="replaceable"><code>pkg</code></em>'s library dependencies.
1.76 rillig 4863: Including these <code class="filename">buildlink3.mk</code> files
1.75 rillig 4864: means that the headers and libraries for these
4865: dependencies are also symlinked into
1.76 rillig 4866: <code class="filename">${BUILDLINK_DIR}</code>
1.75 rillig 4867: whenever the <em class="replaceable"><code>pkg</code></em>
1.76 rillig 4868: <code class="filename">buildlink3.mk</code>
1.75 rillig 4869: file is included.
4870: </p>
4871: </div>
4872: <div class="sect2" lang="en">
4873: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4874: <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 4875: <p>
4876: The situation that requires increasing the dependency listed in
4877: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4878: after a package update is when the API or interface to the
4879: header files change.</p>
4880: <p> In this case,
4881: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4882: should be adjusted to require at least the new package
4883: version. In some cases, the packages that depend on this new
4884: version may need their <code class="varname">PKGREVISION</code>s
1.76 rillig 4885: increased and, if they have <code class="filename">buildlink3.mk</code>
1.75 rillig 4886: files, their
4887: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4888: adjusted, too. This is needed so pkgsrc will require the
4889: correct package dependency and not settle for an older one
4890: when building the source.</p>
4891: <p>
4892: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4893: should be increased when the binary interface or sonames
4894: (major number of the library version) of any installed
4895: shared libraries change. This is needed so that binary
4896: packages made using it will require the correct package
4897: dependency and not settle for an older one which will not
4898: contain the necessary shared libraries. </p>
4899: <p>
1.78 rillig 4900: See <a href="#dependencies" title="17.1.6. Handling dependencies">Section 17.1.6, “Handling dependencies”</a> for
1.75 rillig 4901: more information about dependencies on other packages,
4902: including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
4903: <code class="varname">ABI_DEPENDS</code> definitions. </p>
4904: <p> Please take careful consideration before adjusting
4905: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4906: or
4907: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4908: as we don't want to cause unneeded package deletions and
4909: rebuilds. In many cases, new versions of packages work just
4910: fine with older dependencies.</p>
4911: <p>
4912: Also it is not needed to set
4913: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4914: when it is identical to
4915: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>. </p>
4916: </div>
4917: </div>
4918: <div class="sect1" lang="en">
4919: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4920: <a name="writing-builtin.mk"></a>12.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.75 rillig 4921: <p>
4922: Some packages in pkgsrc install headers and libraries that
4923: coincide with headers and libraries present in the base system.
1.76 rillig 4924: Aside from a <code class="filename">buildlink3.mk</code> file, these
4925: packages should also include a <code class="filename">builtin.mk</code>
1.75 rillig 4926: file that includes the necessary checks to decide whether using
4927: the built-in software or the pkgsrc software is
4928: appropriate. </p>
4929: <p> The only requirements of a builtin.mk file for
4930: <em class="replaceable"><code>pkg</code></em> are:
4931: </p>
4932: <div class="orderedlist"><ol type="1">
4933: <li><p> It should set
4934: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4935: to either “<span class="quote">yes</span>” or “<span class="quote">no</span>”
4936: after it is included.
4937: </p></li>
4938: <li><p> It should <span class="emphasis"><em>not</em></span> override any
4939: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4940: which is already set before the
1.76 rillig 4941: <code class="filename">builtin.mk</code> file is included.
1.75 rillig 4942: </p></li>
4943: <li><p> It should be written to allow multiple inclusion. This
4944: is <span class="emphasis"><em>very</em></span> important and takes careful
1.76 rillig 4945: attention to <code class="filename">Makefile</code> coding.
1.75 rillig 4946: </p></li>
4947: </ol></div>
4948: <div class="sect2" lang="en">
4949: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4950: <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 4951: <p>The following is the recommended template for builtin.mk
4952: files: </p>
4953: <pre class="programlisting">
4954: .if !defined(IS_BUILTIN.foo)
4955: #
4956: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
4957: # genuinely exists in the system or not.
4958: #
4959: IS_BUILTIN.foo?= no
1.1 grant 4960:
1.75 rillig 4961: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
4962: # version can be determined.
4963: #
4964: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
4965: BUILTIN_PKG.foo?= foo-1.0
4966: . endif
4967: .endif # IS_BUILTIN.foo
1.1 grant 4968:
1.75 rillig 4969: .if !defined(USE_BUILTIN.foo)
4970: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
4971: . if defined(BUILTIN_PKG.foo)
4972: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
4973: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
4974: USE_BUILTIN.foo!= \
4975: if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then \
4976: ${ECHO} "yes"; \
4977: else \
4978: ${ECHO} "no"; \
4979: fi
4980: . endif
4981: . endfor
4982: . endif
4983: .endif # USE_BUILTIN.foo
1.1 grant 4984:
1.75 rillig 4985: CHECK_BUILTIN.foo?= no
4986: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
4987: #
4988: # Here we place code that depends on whether USE_BUILTIN.foo is set to
4989: # "yes" or "no".
4990: #
4991: .endif # CHECK_BUILTIN.foo
1.1 grant 4992: </pre>
1.75 rillig 4993: <p> The first section sets
4994: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
4995: depending on if <em class="replaceable"><code>pkg</code></em> really exists
4996: in the base system. This should not be a base system software
4997: with similar functionality to <em class="replaceable"><code>pkg</code></em>;
4998: it should only be “<span class="quote">yes</span>” if the actual package is
4999: included as part of the base system. This variable is only
1.76 rillig 5000: used internally within the <code class="filename">builtin.mk</code>
1.75 rillig 5001: file. </p>
5002: <p> The second section sets
5003: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
5004: to the version of <em class="replaceable"><code>pkg</code></em> in the base
5005: system if it exists (if
5006: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5007: is “<span class="quote">yes</span>”). This variable is only used internally
1.76 rillig 5008: within the <code class="filename">builtin.mk</code> file. </p>
1.75 rillig 5009: <p> The third section sets
5010: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5011: and is <span class="emphasis"><em>required</em></span> in all
1.76 rillig 5012: <code class="filename">builtin.mk</code> files. The code in this
1.75 rillig 5013: section must make the determination whether the built-in
5014: software is adequate to satisfy the dependencies listed in
5015: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
5016: This is typically done by comparing
5017: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
5018: against each of the dependencies in
5019: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
5020: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5021: <span class="emphasis"><em>must</em></span> be set to the correct value by the
1.76 rillig 5022: end of the <code class="filename">builtin.mk</code> file. Note that
1.75 rillig 5023: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5024: may be “<span class="quote">yes</span>” even if
5025: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5026: is “<span class="quote">no</span>” because we may make the determination
5027: that the built-in version of the software is similar enough to
5028: be used as a replacement. </p>
5029: <p> The last section is guarded by
5030: <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
5031: and includes code that uses the value of
5032: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5033: set in the previous section. This typically includes, e.g.,
5034: adding additional dependency restrictions and listing
5035: additional files to symlink into
1.76 rillig 5036: <code class="filename">${BUILDLINK_DIR}</code> (via
1.75 rillig 5037: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).
5038: </p>
5039: </div>
5040: <div class="sect2" lang="en">
5041: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5042: <a name="native-or-pkgsrc-preference"></a>12.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
1.75 rillig 5043: <p>
5044: When building packages, it's possible to choose whether to set
5045: a global preference for using either the built-in (native)
5046: version or the pkgsrc version of software to satisfy a
5047: dependency. This is controlled by setting
5048: <code class="varname">PREFER_PKGSRC</code> and
5049: <code class="varname">PREFER_NATIVE</code>. These variables take values
5050: of either “<span class="quote">yes</span>”, “<span class="quote">no</span>”, or a list of
5051: packages. <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
5052: use the pkgsrc versions of software, while
5053: <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
5054: built-in versions. Preferences are determined by the most
5055: specific instance of the package in either
5056: <code class="varname">PREFER_PKGSRC</code> or
5057: <code class="varname">PREFER_NATIVE</code>. If a package is specified
5058: in neither or in both variables, then
5059: <code class="varname">PREFER_PKGSRC</code> has precedence over
5060: <code class="varname">PREFER_NATIVE</code>. For example, to require
5061: using pkgsrc versions of software for all but the most basic
5062: bits on a NetBSD system, you can set: </p>
5063: <pre class="programlisting">
5064: PREFER_PKGSRC= yes
5065: PREFER_NATIVE= getopt skey tcp_wrappers
1.1 grant 5066: </pre>
1.75 rillig 5067: <p> A package <span class="emphasis"><em>must</em></span> have a
1.76 rillig 5068: <code class="filename">builtin.mk</code>
1.75 rillig 5069: file to be listed in <code class="varname">PREFER_NATIVE</code>,
5070: otherwise it is simply ignored in that list.
5071: </p>
5072: </div>
5073: </div>
5074: </div>
5075: <div class="chapter" lang="en">
5076: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5077: <a name="pkginstall"></a>Chapter 13. The pkginstall framework</h2></div></div></div>
1.75 rillig 5078: <div class="toc">
5079: <p><b>Table of Contents</b></p>
5080: <dl>
1.77 rillig 5081: <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 5082: <dd><dl>
1.77 rillig 5083: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
5084: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
1.75 rillig 5085: </dl></dd>
1.77 rillig 5086: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
1.75 rillig 5087: <dd><dl>
1.77 rillig 5088: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
5089: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
5090: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
5091: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
5092: </dl></dd>
5093: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
5094: <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>
5095: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
5096: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
5097: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
5098: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
5099: <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 5100: </dl>
5101: </div>
5102: <p>This chapter describes the framework known as
5103: <code class="literal">pkginstall</code>, whose key features are:</p>
5104: <div class="itemizedlist"><ul type="disc">
5105: <li><p>Generic installation and manipulation of directories and files
5106: outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
5107: <li><p>Automatic handling of configuration files during installation,
5108: provided that packages are correctly designed.</p></li>
5109: <li><p>Generation and installation of system startup scripts.</p></li>
5110: <li><p>Registration of system users and groups.</p></li>
5111: <li><p>Registration of system shells.</p></li>
5112: <li><p>Automatic updating of fonts databases.</p></li>
5113: </ul></div>
5114: <p>The following sections inspect each of the above points in detail.</p>
5115: <p>You may be thinking that many of the things described here could be
5116: easily done with simple code in the package's post-installation target
5117: (<code class="literal">post-install</code>). <span class="emphasis"><em>This is incorrect</em></span>,
5118: as the code in them is only executed when building from source. Machines
5119: using binary packages could not benefit from it at all (as the code itself
5120: could be unavailable). Therefore, the only way to achieve any of the items
5121: described above is by means of the installation scripts, which are
5122: automatically generated by pkginstall.</p>
5123: <div class="sect1" lang="en">
5124: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5125: <a name="files-and-dirs-outside-prefix"></a>13.1. Files and directories outside the installation prefix</h2></div></div></div>
1.76 rillig 5126: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
1.75 rillig 5127: of files and directories that belong to a package. The names used in it
1.76 rillig 5128: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
1.75 rillig 5129: which means that it cannot register files outside this directory (absolute
5130: path names are not allowed). Despite this restriction, some packages need
5131: to install files outside this location; e.g., under
1.76 rillig 5132: <code class="filename">${VARBASE}</code> or
5133: <code class="filename">${PKG_SYSCONFDIR}</code>.</p>
1.75 rillig 5134: <p>The only way to achieve this is to create such files during
5135: installation time by using the installation scripts. These scripts can run
5136: arbitrary commands, so they have the potential to create and manage files
5137: anywhere in the file system. Here is where pkginstall comes into play: it
5138: provides generic scripts to abstract the manipulation of such files and
5139: directories based on variables set in the package's
1.76 rillig 5140: <code class="filename">Makefile</code>. The rest of this section describes these
1.75 rillig 5141: variables.</p>
5142: <div class="sect2" lang="en">
5143: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5144: <a name="dirs-outside-prefix"></a>13.1.1. Directory manipulation</h3></div></div></div>
1.75 rillig 5145: <p>The following variables can be set to request the creation of
5146: directories anywhere in the file system:</p>
5147: <div class="itemizedlist"><ul type="disc">
5148: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
5149: contain a list of directories that should be created and should attempt
5150: to be destroyed by the installation scripts. The difference between
5151: the two is that the latter prompts the administrator to remove any
5152: directories that may be left after deinstallation (because they were
5153: not empty), while the former does not.</p></li>
5154: <li>
5155: <p><code class="varname">MAKE_DIRS_PERMS</code> and
5156: <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
5157: which directories should be created and should attempt to be destroyed
5158: by the installation scripts. Each tuple holds the following values,
5159: separated by spaces: the directory name, its owner, its group and its
5160: numerical mode. For example:</p>
5161: <pre class="programlisting">
5162: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 5163: </pre>
1.75 rillig 5164: <p>The difference between the two is exactly the same as their
5165: non-<code class="varname">PERMS</code> counterparts.</p>
5166: </li>
5167: </ul></div>
5168: </div>
5169: <div class="sect2" lang="en">
5170: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5171: <a name="files-outside-prefix"></a>13.1.2. File manipulation</h3></div></div></div>
1.75 rillig 5172: <p>Creating non-empty files outside the installation prefix is tricky
1.76 rillig 5173: because the <code class="filename">PLIST</code> forces all files to be inside it.
1.75 rillig 5174: To overcome this problem, the only solution is to extract the file in the
5175: known place (i.e., inside the installation prefix) and copy it to the
5176: appropriate location during installation (done by the installation scripts
5177: generated by pkginstall). We will call the former the <span class="emphasis"><em>master
5178: file</em></span> in the following paragraphs, which describe the variables
5179: that can be used to automatically and consistently handle files outside the
5180: installation prefix:</p>
5181: <div class="itemizedlist"><ul type="disc">
5182: <li>
5183: <p><code class="varname">CONF_FILES</code> and
5184: <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
5185: During installation time, the master file is copied to the target one
5186: if and only if the latter does not exist. Upon deinstallation, the
5187: target file is removed provided that it was not modified by the
5188: installation.</p>
5189: <p>The difference between the two is that the latter prompts the
5190: administrator to remove any files that may be left after
5191: deinstallation (because they were not empty), while the former does
5192: not.</p>
5193: </li>
5194: <li>
5195: <p><code class="varname">CONF_FILES_PERMS</code> and
5196: <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
5197: files as well as their target locations. For each of them, it also
5198: specifies their owner, their group and their numeric permissions, in
5199: this order. For example:</p>
5200: <pre class="programlisting">
5201: SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 5202: </pre>
1.75 rillig 5203: <p>The difference between the two is exactly the same as their
5204: non-<code class="varname">PERMS</code> counterparts.</p>
5205: </li>
5206: </ul></div>
5207: </div>
5208: </div>
5209: <div class="sect1" lang="en">
5210: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5211: <a name="conf-files"></a>13.2. Configuration files</h2></div></div></div>
1.75 rillig 5212: <p>Configuration files are special in the sense that they are installed
5213: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
5214: need special treatment during installation (most of which is automated by
5215: pkginstall). The main concept you must bear in mind is that files marked
5216: as configuration files are automatically copied to the right place (somewhere
5217: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
5218: and only if</em></span> they didn't exist before. Similarly, they will not
5219: be removed if they have local modifications. This ensures that
5220: administrators never lose any custom changes they may have made.</p>
5221: <div class="sect2" lang="en">
5222: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5223: <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 5224: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
5225: specifies where configuration files shall be installed. Its contents are
5226: set based upon the following variables:</p>
5227: <div class="itemizedlist"><ul type="disc">
5228: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
1.76 rillig 5229: directory. Defaults to <code class="filename">${PREFIX}/etc</code> although it may
1.75 rillig 5230: be overridden by the user to point to his preferred location (e.g.,
1.76 rillig 5231: <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
1.75 rillig 5232: Packages must not use it directly.</p></li>
5233: <li>
5234: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
5235: <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
5236: for the package being built shall be installed. The definition of this
5237: variable only makes sense in the package's
1.76 rillig 5238: <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
1.75 rillig 5239: <p>As an example, consider the Apache package,
1.76 rillig 5240: <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 5241: configuration files under the
1.76 rillig 5242: <code class="filename">httpd/</code> subdirectory of
1.75 rillig 5243: <code class="varname">PKG_SYSCONFBASE</code>. This should be set in the package
5244: Makefile.</p>
5245: </li>
5246: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
5247: variable that holds this package's configuration directory (if
5248: different from <code class="varname">PKG_SYSCONFBASE</code>). It defaults to
5249: <code class="varname">PKGBASE</code>'s value, and is always prefixed with
5250: <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
5251: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
5252: directory where the configuration files for the package identified by
5253: <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
5254: </ul></div>
5255: <p>Based on the above variables, pkginstall determines the value of
5256: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
5257: variable that can be used within a package to refer to its configuration
5258: directory. The algorithm used to set its value is basically the
5259: following:</p>
5260: <div class="orderedlist"><ol type="1">
5261: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
5262: its value is used.</p></li>
5263: <li><p>If the previous variable is not defined but
5264: <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
1.76 rillig 5265: <code class="filename">Makefile</code>, the resulting value is
5266: <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
1.75 rillig 5267: <li><p>Otherwise, it is set to
1.76 rillig 5268: <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
1.75 rillig 5269: </ol></div>
1.76 rillig 5270: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
1.77 rillig 5271: 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 5272: </div>
5273: <div class="sect2" lang="en">
5274: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5275: <a name="conf-files-configure"></a>13.2.2. Telling the software where configuration files are</h3></div></div></div>
1.75 rillig 5276: <p>Given that pkgsrc (and users!) expect configuration files to be in a
5277: known place, you need to teach each package where it shall install its
5278: files. In some cases you will have to patch the package Makefiles to
5279: achieve it. If you are lucky, though, it may be as easy as passing an
5280: extra flag to the configuration script; this is the case of GNU Autoconf-
5281: generated files:</p>
5282: <pre class="programlisting">
5283: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1 grant 5284: </pre>
1.75 rillig 5285: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
5286: for</em></span> its configuration files, not where they will be originally
5287: installed (although the difference is never explicit,
5288: unfortunately).</p>
5289: </div>
5290: <div class="sect2" lang="en">
5291: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5292: <a name="conf-files-patching"></a>13.2.3. Patching installations</h3></div></div></div>
1.75 rillig 5293: <p>As said before, pkginstall automatically handles configuration files.
5294: This means that <span class="strong"><strong>the packages themselves must not
1.76 rillig 5295: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
1.75 rillig 5296: directly</strong></span>. Bad news is that many software installation scripts
5297: will, out of the box, mess with the contents of that directory. So what is
5298: the correct procedure to fix this issue?</p>
5299: <p>You must teach the package (usually by manually patching it) to
5300: install any configuration files under the examples hierarchy,
1.76 rillig 5301: <code class="filename">share/examples/${PKGBASE}/</code>. This way, the
5302: <code class="filename">PLIST</code> registers them and the administrator always
1.75 rillig 5303: has the original copies available.</p>
5304: <p>Once the required configuration files are in place (i.e., under the
5305: examples hierarchy), the pkginstall framework can use them as master copies
5306: during the package installation to update what is in
1.76 rillig 5307: <code class="filename">${PKG_SYSCONFDIR}</code>. To achieve this, the variables
1.75 rillig 5308: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
1.77 rillig 5309: 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 5310: about their syntax and their purpose. Here is an example, taken from the
1.76 rillig 5311: <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 5312: <pre class="programlisting">
5313: EGDIR= ${PREFIX}/share/doc/mutt/samples
5314: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1 grant 5315: </pre>
1.75 rillig 5316: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
5317: package and has no meaning outside it.</p>
5318: </div>
5319: <div class="sect2" lang="en">
5320: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5321: <a name="conf-files-disable"></a>13.2.4. Disabling handling of configuration files</h3></div></div></div>
1.75 rillig 5322: <p>The automatic copying of config files can be toggled by setting the
5323: environment variable <code class="varname">PKG_CONFIG</code> prior to package
5324: installation.</p>
5325: </div>
5326: </div>
5327: <div class="sect1" lang="en">
5328: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5329: <a name="rcd-scripts"></a>13.3. System startup scripts</h2></div></div></div>
1.75 rillig 5330: <p>System startup scripts are special files because they must be
5331: installed in a place known by the underlying OS, usually outside the
1.77 rillig 5332: 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 5333: can be used. However, pkginstall provides a special mechanism to handle
5334: these files.</p>
5335: <p>In order to provide system startup scripts, the package has
5336: to:</p>
5337: <div class="orderedlist"><ol type="1">
1.76 rillig 5338: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
1.75 rillig 5339: the <code class="literal">.sh</code> suffix appended. Considering the
1.76 rillig 5340: <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
5341: <code class="filename">cupsd.sh</code> in its files directory.</p></li>
1.75 rillig 5342: <li>
5343: <p>Tell pkginstall to handle it, appending the name of the script,
5344: without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
5345: Continuing the previous example:</p>
5346: <pre class="programlisting">
5347: RCD_SCRIPTS+= cupsd
1.1 grant 5348: </pre>
1.75 rillig 5349: </li>
5350: </ol></div>
5351: <p>Once this is done, pkginstall will do the following steps for each
5352: script in an automated fashion:</p>
5353: <div class="orderedlist"><ol type="1">
5354: <li><p>Process the file found in the files directory applying all the
1.76 rillig 5355: substitutions described in the <code class="filename">FILES_SUBST</code>
1.75 rillig 5356: variable.</p></li>
5357: <li><p>Copy the script from the files directory to the examples
1.76 rillig 5358: hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>. Note
1.75 rillig 5359: that this master file must be explicitly registered in the
1.76 rillig 5360: <code class="filename">PLIST</code>.</p></li>
1.75 rillig 5361: <li><p>Add code to the installation scripts to copy the startup script
5362: from the examples hierarchy into the system-wide startup scripts
5363: directory.</p></li>
5364: </ol></div>
5365: <div class="sect2" lang="en">
5366: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5367: <a name="rcd-scripts-disable"></a>13.3.1. Disabling handling of system startup scripts</h3></div></div></div>
1.75 rillig 5368: <p>The automatic copying of config files can be toggled by setting the
5369: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
5370: installation. Note that the scripts will be always copied inside the
1.76 rillig 5371: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
1.75 rillig 5372: matter what the value of this variable is.</p>
5373: </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="users-and-groups"></a>13.4. System users and groups</h2></div></div></div>
1.75 rillig 5378: <p>If a package needs to create special users and/or groups during
5379: installation, it can do so by using the pkginstall framework.</p>
5380: <p>Users can be created by adding entries to the
5381: <code class="varname">PKG_USERS</code> variable. Each entry has the following
5382: syntax:</p>
5383: <pre class="programlisting">
5384: user:group
1.1 grant 5385: </pre>
1.75 rillig 5386: <p>Further specification of user details may be done by setting per-user
5387: variables.
5388: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the numeric
5389: UID for the user.
5390: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the user's
5391: description or comment.
5392: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the user's
1.76 rillig 5393: home directory, and defaults to <code class="filename">/nonexistent</code> if not
1.75 rillig 5394: specified.
5395: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the user's
1.76 rillig 5396: shell, and defaults to <code class="filename">/sbinno/login</code> if not specified.
1.75 rillig 5397: </p>
5398: <p>Similarly, groups can be created by adding entries to the
5399: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
5400: <pre class="programlisting">
5401: group
1.1 grant 5402: </pre>
1.75 rillig 5403: <p>The numeric GID of the group may be set by defining
5404: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
5405: <p>If a package needs to create the users and groups at an earlier
5406: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
5407: either <code class="literal">configure</code> or <code class="literal">build</code> to
5408: indicate the phase before which the users and groups are created. In
5409: this case, the numeric UIDs and GIDs of the created users and groups
5410: are automatically hardcoded into the final installation scripts.</p>
5411: </div>
5412: <div class="sect1" lang="en">
5413: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5414: <a name="shells"></a>13.5. System shells</h2></div></div></div>
1.75 rillig 5415: <p>Packages that install system shells should register them in the shell
1.76 rillig 5416: database, <code class="filename">/etc/shells</code>, to make things easier to the
1.75 rillig 5417: administrator. This must be done from the installation scripts to keep
5418: binary packages working on any system. pkginstall provides an easy way to
5419: accomplish this task.</p>
5420: <p>When a package provides a shell interpreter, it has to set the
5421: <code class="varname">PKG_SHELL</code> variable to its absolute file name. This will
5422: add some hooks to the installation scripts to handle it. Consider the
1.76 rillig 5423: 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 5424: <pre class="programlisting">
5425: PKG_SHELL= ${PREFIX}/bin/zsh
1.1 grant 5426: </pre>
1.75 rillig 5427: <div class="sect2" lang="en">
5428: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5429: <a name="shells-disable"></a>13.5.1. Disabling shell registration</h3></div></div></div>
1.75 rillig 5430: <p>The automatic registration of shell interpreters can be disabled by
1.76 rillig 5431: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
1.75 rillig 5432: environment variable to <code class="literal">NO</code>.</p>
5433: </div>
5434: </div>
5435: <div class="sect1" lang="en">
5436: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5437: <a name="fonts"></a>13.6. Fonts</h2></div></div></div>
1.75 rillig 5438: <p>Packages that install X11 fonts should update the database files
5439: that index the fonts within each fonts directory. This can easily be
5440: accomplished within the pkginstall framework.</p>
5441: <p>When a package installs X11 fonts, it must list the directories in
5442: which fonts are installed in the
5443: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
5444: where <em class="replaceable"><code>type</code></em> can be one of “<span class="quote">ttf</span>”,
5445: “<span class="quote">type1</span>” or “<span class="quote">x11</span>”. This will add hooks to the
5446: installation scripts to run the appropriate commands to update the fonts
5447: database files within each of those directories. For convenience, if the
5448: directory path is relative, it is taken to be relative to the package's
1.76 rillig 5449: 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 5450: <pre class="programlisting">
5451: FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
1.1 grant 5452: </pre>
1.75 rillig 5453: <div class="sect2" lang="en">
5454: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5455: <a name="fonts-disable"></a>13.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
1.75 rillig 5456: <p>The automatic update of fonts databases can be disabled by
1.76 rillig 5457: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
1.75 rillig 5458: environment variable to <code class="literal">NO</code>.</p>
5459: </div>
5460: </div>
5461: </div>
5462: <div class="chapter" lang="en">
5463: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5464: <a name="options"></a>Chapter 14. Options handling</h2></div></div></div>
1.75 rillig 5465: <div class="toc">
5466: <p><b>Table of Contents</b></p>
5467: <dl>
1.77 rillig 5468: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
5469: <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>
5470: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
1.75 rillig 5471: </dl>
5472: </div>
5473: <p>Many packages have the ability to be built to support different
1.76 rillig 5474: sets of features. <code class="filename">bsd.options.mk</code> is a framework
1.75 rillig 5475: in pkgsrc that provides generic handling of those options that
5476: determine different ways in which the packages can be built. It's
5477: possible for the user to specify exactly which sets of options will be
5478: built into a package or to allow a set of global default options
5479: apply.</p>
5480: <div class="sect1" lang="en">
5481: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5482: <a name="global-default-options"></a>14.1. Global default options</h2></div></div></div>
1.75 rillig 5483: <p>Global default options are listed in
5484: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
5485: that should be built into every package if that option is supported.
1.76 rillig 5486: This variable should be set in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 5487: </div>
5488: <div class="sect1" lang="en">
5489: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5490: <a name="converting-to-options"></a>14.2. Converting packages to use <code class="filename">bsd.options.mk</code></h2></div></div></div>
1.75 rillig 5491: <p>The following example shows how
1.76 rillig 5492: <code class="filename">bsd.options.mk</code> should be used
1.75 rillig 5493: by the hypothetical ``wibble'' package, either in the package
1.76 rillig 5494: <code class="filename">Makefile</code>, or in a file,
5495: e.g. <code class="filename">options.mk</code>, that is included by the
5496: main package <code class="filename">Makefile</code>.</p>
1.75 rillig 5497: <pre class="programlisting">
5498: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
5499: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
5500: PKG_OPTIONS_OPTIONAL_GROUPS= database
5501: PKG_OPTIONS_GROUP.database= mysql pgsql
5502: PKG_SUGGESTED_OPTIONS= wibble-foo
5503: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
5504: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
1.1 grant 5505:
1.75 rillig 5506: .include "../../mk/bsd.prefs.mk"
1.69 rillig 5507:
1.75 rillig 5508: # this package was previously named wibble2
5509: .if defined(PKG_OPTIONS.wibble2)
5510: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
5511: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
1.78 rillig 5512: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
1.75 rillig 5513: .endif
1.69 rillig 5514:
1.75 rillig 5515: .include "../../mk/bsd.options.mk"
1.69 rillig 5516:
1.75 rillig 5517: # Package-specific option-handling
1.69 rillig 5518:
1.75 rillig 5519: ###
5520: ### FOO support
5521: ###
5522: .if !empty(PKG_OPTIONS:Mwibble-foo)
5523: CONFIGURE_ARGS+= --enable-foo
5524: .endif
1.69 rillig 5525:
1.75 rillig 5526: ###
5527: ### LDAP support
5528: ###
5529: .if !empty(PKG_OPTIONS:Mldap)
1.77 rillig 5530: . include "../../databases/openldap-client/buildlink3.mk"
5531: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
1.75 rillig 5532: .endif
1.69 rillig 5533:
1.75 rillig 5534: ###
5535: ### database support
5536: ###
5537: .if !empty(PKG_OPTIONS:Mmysql)
5538: . include "../../mk/mysql.buildlink3.mk"
5539: .endif
5540: .if !empty(PKG_OPTIONS:Mpgsql)
5541: . include "../../mk/pgsql.buildlink3.mk"
5542: .endif
5543: </pre>
5544: <p>The first section contains the information about which build
5545: options are supported by the package, and any default options settings
5546: if needed.</p>
5547: <div class="orderedlist"><ol type="1">
5548: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
5549: <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
5550: options. It should be set to
1.78 rillig 5551: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
5552: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is not defined
5553: at the point where the options are processed.</p></li>
1.75 rillig 5554: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
5555: build options supported by the package.</p></li>
5556: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
5557: list of names of groups of mutually exclusive options. The options in
5558: each group are listed in
5559: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
5560: The most specific setting of any option from the group takes
5561: precedence over all other options in the group. Options from the
5562: groups will be automatically added to
5563: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
5564: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
5565: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
5566: packages will fail if no option from the group is
5567: selected.</p></li>
5568: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
5569: of names of sets of options. At least one option from each set must
5570: be selected. The options in each set are listed in
5571: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
5572: Options from the sets will be automatically added to
5573: <code class="varname">PKG_SUPPORTED_OPTIONS</code>. Building the package will
5574: fail if no option from the set is selected.</p></li>
5575: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
5576: build options which are enabled by default.</p></li>
5577: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
5578: of
5579: “<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>”
1.76 rillig 5580: pairs that map legacy <code class="filename">/etc/mk.conf</code> variables to
1.75 rillig 5581: their option counterparts. Pairs should be added with
5582: “<span class="quote">+=</span>” to keep the listing of global legacy variables. A
5583: warning will be issued if the user uses a legacy
5584: variable.</p></li>
5585: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
5586: of
5587: “<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>”
5588: pairs that map options that have been renamed to their new
5589: counterparts. Pairs should be added with “<span class="quote">+=</span>” to keep
5590: the listing of global legacy options. A warning will be issued if
5591: the user uses a legacy option.</p></li>
5592: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
5593: options implied by deprecated variables used. This can be used for
5594: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
5595: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
5596: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
5597: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
5598: a list of warnings about deprecated variables or options used, and
5599: what to use instead.</p></li>
5600: </ol></div>
5601: <p>A package should never modify
5602: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
5603: <code class="varname">PKG_OPTIONS_VAR</code>. These are strictly user-settable.
5604: To suggest a default set of options, use
5605: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
5606: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
1.76 rillig 5607: including <code class="filename">bsd.options.mk</code>. If none of
1.75 rillig 5608: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
5609: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
5610: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
5611: happen with platform-specific options if none of them is supported on
5612: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
5613: empty list and the package is otherwise treated as not using the
5614: options framework.</p>
1.76 rillig 5615: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
1.75 rillig 5616: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
5617: build options, properly filtered to remove unsupported and duplicate
5618: options.</p>
5619: <p>The remaining sections contain the logic that is specific to
5620: each option. The correct way to check for an option is to check
5621: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
5622: <pre class="programlisting">
5623: .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
5624: </pre>
5625: </div>
5626: <div class="sect1" lang="en">
5627: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5628: <a name="option-names"></a>14.3. Option Names</h2></div></div></div>
1.75 rillig 5629: <p>Options that enable similar features in different packages (like
5630: optional support for a library) should use a common name in all
5631: packages that support it (like the name of the library). If another
5632: package already has an option with the same meaning, use the same
5633: name.</p>
5634: <p>Options that enable features specific to one package, where it's
5635: unlikely that another (unrelated) package has the same (or a similar)
5636: optional feature, should use a name prefixed with
5637: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
5638: <p>If a group of related packages share an optional feature
5639: specific to that group, prefix it with the name of the
5640: “<span class="quote">main</span>” package
5641: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
5642: <p>For new options, add a line to
1.76 rillig 5643: <code class="filename">mk/defaults/options.description</code>. Lines have two
1.75 rillig 5644: fields, separated by tab. The first field is the option name, the
5645: second its description. The description should be a whole sentence
5646: (starting with an uppercase letter and ending with a period) that
5647: describes what enabling the option does. E. g. “<span class="quote">Enable ispell
5648: support.</span>” The file is sorted by option names.</p>
5649: </div>
5650: </div>
5651: <div class="chapter" lang="en">
5652: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5653: <a name="build"></a>Chapter 15. The build process</h2></div></div></div>
1.75 rillig 5654: <div class="toc">
5655: <p><b>Table of Contents</b></p>
5656: <dl>
1.77 rillig 5657: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
5658: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
5659: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
5660: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
5661: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
1.81 rillig 5662: <dd><dl>
5663: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
5664: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
5665: </dl></dd>
1.77 rillig 5666: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
5667: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
5668: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
5669: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
5670: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
5671: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
5672: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
5673: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
5674: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
5675: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
5676: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
1.75 rillig 5677: </dl>
5678: </div>
5679: <div class="sect1" lang="en">
5680: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5681: <a name="build.intro"></a>15.1. Introduction</h2></div></div></div>
1.75 rillig 5682: <p>This chapter gives a detailed description on how a package is
5683: built. Building a package is separated into different
5684: <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
5685: <code class="varname">build</code>, <code class="varname">install</code>), all of which are
5686: described in the following sections. Each phase is splitted into
5687: so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
5688: containing phase, prefixed by one of <code class="varname">pre-</code>,
5689: <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
5690: <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
5691: of the actual work is done in the <code class="varname">do-*</code> stages.</p>
5692: <p>The basic steps for building a program are always the same. First
5693: the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
5694: the local system and then extracted. After any pkgsrc-specific patches
5695: to compile properly are applied, the software can be configured, then
5696: built (usually by compiling), and finally the generated binaries, etc.
5697: can be put into place on the system.</p>
5698: </div>
5699: <div class="sect1" lang="en">
5700: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5701: <a name="build.prefix"></a>15.2. Program location</h2></div></div></div>
1.75 rillig 5702: <p>Before outlining the process performed by the NetBSD package system in
5703: the next section, here's a brief discussion on where programs are
5704: installed, and which variables influence this.</p>
5705: <p>The automatic variable <code class="varname">PREFIX</code> indicates
5706: where all files of the final program shall be installed. It is
5707: usually set to <code class="varname">LOCALBASE</code>
1.76 rillig 5708: (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
1.75 rillig 5709: for pkgs in the “<span class="quote">cross</span>” category. The value of
5710: <code class="varname">PREFIX</code> needs to be put
5711: into the various places in the program's source where paths to
1.77 rillig 5712: 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 5713: <p>When choosing which of these variables to use,
5714: follow the following rules:</p>
5715: <div class="itemizedlist"><ul type="disc">
5716: <li><p><code class="varname">PREFIX</code> always points to the location where the current
5717: pkg will be installed. When referring to a pkg's own installation path,
5718: use “<span class="quote">${PREFIX}</span>”.</p></li>
5719: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs are installed.
5720: If you need to construct a -I or -L argument to the compiler to find
5721: includes and libraries installed by another non-X11 pkg, use
1.78 rillig 5722: “<span class="quote">${LOCALBASE}</span>”. The name
5723: <code class="varname">LOCALBASE</code> stems from FreeBSD, which
5724: installed all packages in <code class="filename">/usr/local</code>. As
5725: pkgsrc leaves <code class="filename">/usr/local</code> for the system
5726: administrator, this variable is a misnomer.</p></li>
1.75 rillig 5727: <li><p><code class="varname">X11BASE</code> is where the actual X11 distribution (from
5728: xsrc, etc.) is installed. When looking for
5729: <span class="emphasis"><em>standard</em></span> X11 includes (not
5730: those installed by a pkg), use “<span class="quote">${X11BASE}</span>”.</p></li>
5731: <li>
5732: <p>X11-based packages are special in that they may be installed in
5733: either <code class="varname">X11BASE</code> or <code class="varname">LOCALBASE</code>.</p>
5734: <p>Usually, X11 packages should be installed under
5735: <code class="varname">LOCALBASE</code> whenever possible. Note that you will
1.76 rillig 5736: need to include <code class="filename">../../mk/x11.buildlink3.mk</code>
1.75 rillig 5737: in them to request the
5738: presence of X11 and to get the right compilation flags.</p>
5739: <p>Even though, there are some packages that cannot be installed
5740: under <code class="varname">LOCALBASE</code>: those that come with app-defaults
5741: files. These packages are special and they must be placed under
5742: <code class="varname">X11BASE</code>. To accomplish this, set either
5743: <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
5744: your package.</p>
5745: <p>Some notes: If you need
5746: to find includes or libraries installed by a pkg that has
5747: <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
1.76 rillig 5748: its pkg <code class="filename">Makefile</code>, you need to look in
5749: <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
5750: <code class="filename">${LOCALBASE}</code>. To force installation of
1.75 rillig 5751: all X11 packages in <code class="varname">LOCALBASE</code>, the
1.76 rillig 5752: <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 5753: is enabled by default.</p>
5754: </li>
5755: <li><p><code class="varname">X11PREFIX</code> should be used to refer to the installed
5756: location of an X11 package. <code class="varname">X11PREFIX</code> will be set to
5757: <code class="varname">X11BASE</code> if xpkgwedge is not installed,
5758: and to <code class="varname">LOCALBASE</code> if xpkgwedge is installed.</p></li>
5759: <li>
5760: <p>If xpkgwedge is installed, it is possible to have some packages installed
5761: in <code class="varname">X11BASE</code> and some in <code class="varname">LOCALBASE</code>.
5762: To determine the prefix of an installed package, the
5763: <code class="varname">EVAL_PREFIX</code> definition can be used. It takes pairs in the
5764: 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
5765: <code class="varname">DIRNAME</code> will be set to the prefix of the installed
5766: package <package>, or “<span class="quote">${X11PREFIX}</span>” if the package is
5767: not installed.</p>
5768: <p>This is best illustrated by example.</p>
5769: <p>The following lines are taken from
1.76 rillig 5770: <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
1.75 rillig 5771: <pre class="programlisting">
5772: EVAL_PREFIX+= GTKDIR=gtk+
5773: CONFIGURE_ARGS+= --with-guile-prefix=${LOCALBASE:Q}
5774: CONFIGURE_ARGS+= --with-gtk-prefix=${GTKDIR:Q}
5775: CONFIGURE_ARGS+= --enable-multibyte
5776: </pre>
5777: <p>Specific defaults can be defined for the packages evaluated using
5778: <code class="varname">EVAL_PREFIX</code>, by using a definition of the form:</p>
5779: <pre class="programlisting">
5780: GTKDIR_DEFAULT= ${LOCALBASE}
5781: </pre>
5782: <p>where <code class="varname">GTKDIR</code> corresponds
5783: to the first definition in
5784: the <code class="varname">EVAL_PREFIX</code> pair.</p>
5785: </li>
1.76 rillig 5786: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.75 rillig 5787: 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 5788: manual pages go into <code class="filename">${PREFIX}/man</code>, not
5789: <code class="filename">${PREFIX}/share/man</code>.</p></li>
1.75 rillig 5790: </ul></div>
5791: </div>
5792: <div class="sect1" lang="en">
5793: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5794: <a name="build.builddirs"></a>15.3. Directories used during the build process</h2></div></div></div>
1.75 rillig 5795: <p>When building a package, a number of directories is used to store
5796: source files, temporary files, pkgsrc-internal files, and so on. These
5797: directories are explained here.</p>
5798: <p>Some of the directory variables contain relative pathnames. There
5799: are two common base directories for these relative directories:
5800: <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
5801: pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
5802: inside the package itself.</p>
5803: <div class="variablelist"><dl>
5804: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
5805: <dd><p>This is an absolute pathname that points to the pkgsrc
5806: root directory. Generally, you don't need
5807: it.</p></dd>
5808: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
5809: <dd><p>This is a pathname relative to
5810: <code class="varname">PKGSRCDIR</code> that points to the current
5811: package.</p></dd>
5812: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
5813: <dd><p>This is an absolute pathname pointing to the directory
5814: where all work takes place. The distfiles are extraced to this
5815: directory. It also contains temporary directories and log files used by
5816: the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
5817: the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
5818: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
5819: <dd><p>This is an absolute pathname pointing to the directory
5820: where the distfiles are extracted. It is usually a direct subdirectory
5821: of <code class="varname">WRKDIR</code>, and often it's the only directory entry
5822: that isn't hidden. This variable may be changed by a package
1.76 rillig 5823: <code class="filename">Makefile</code>.</p></dd>
1.75 rillig 5824: </dl></div>
5825: </div>
5826: <div class="sect1" lang="en">
5827: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5828: <a name="build.running"></a>15.4. Running a phase</h2></div></div></div>
1.75 rillig 5829: <p>You can run a particular phase by typing <span><strong class="command">make
5830: phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
5831: phase. This will automatically run all phases that are required for this
5832: phase. The default phase is <code class="varname">build</code>, that is, when you
5833: run <span><strong class="command">make</strong></span> without parameters in a package directory,
5834: the package will be built, but not installed.</p>
5835: </div>
5836: <div class="sect1" lang="en">
5837: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5838: <a name="build.fetch"></a>15.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.81 rillig 5839: <p>The first step in building a package is to fetch the
5840: distribution files (distfiles) from the sites that are providing
5841: them. This is the task of the <span class="emphasis"><em>fetch</em></span>
5842: phase.</p>
5843: <div class="sect2" lang="en">
5844: <div class="titlepage"><div><div><h3 class="title">
5845: <a name="build.fetch.what"></a>15.5.1. What to fetch and where to get it from</h3></div></div></div>
5846: <p>In simple cases, <code class="varname">MASTER_SITES</code> defines
5847: all URLs from where the distfile, whose name is derived from the
5848: <code class="varname">DISTNAME</code> variable, is fetched. The more
5849: complicated cases are described below.</p>
5850: <p>The variable <code class="varname">DISTFILES</code> specifies the
5851: list of distfiles that have to be fetched. Its value defaults to
5852: <code class="literal">${DISTNAME}${EXTRACT_SUFX}</code>, so that most
5853: packages don't need to define it at all.
5854: <code class="varname">EXTRACT_SUFX</code> is <code class="literal">.tar.gz</code> by
5855: default, but can be changed freely. Note that if your package
5856: requires additional distfiles to the default one, you cannot
5857: just append the additional filenames using the
5858: <code class="literal">+=</code> operator, but you have write for
5859: example:</p>
5860: <pre class="programlisting">
5861: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
5862: </pre>
5863: <p>Each of the distfiles is fetched from a list of sites,
5864: usually <code class="varname">MASTER_SITES</code>. If the package has
5865: multiple <code class="varname">DISTFILES</code> or multiple
5866: <code class="varname">PATCHFILES</code> from different sites, you can set
5867: <code class="varname">SITES.<em class="replaceable"><code>distfile</code></em></code> to
5868: the list of URLs where the file
5869: <code class="filename"><em class="replaceable"><code>distfile</code></em></code>
5870: (including the suffix) can be found.</p>
5871: <pre class="programlisting">
5872: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
5873: DISTFILES+= foo-file.tar.gz
5874: SITES.foo-file.tar.gz= \
5875: http://www.somewhere.com/somehow/ \
5876: http://www.somewhereelse.com/mirror/somehow/
5877: </pre>
5878: <p>When actually fetching the distfiles, each item from
5879: <code class="varname">MASTER_SITES</code> or <code class="varname">SITES.*</code>
5880: gets the name of each distfile appended to it, without an
5881: intermediate slash. Therefore, all site values have to end with
5882: a slash or other separator character. This allows for example to
5883: set <code class="varname">MASTER_SITES</code> to a URL of a CGI script
5884: that gets the name of the distfile as a parameter. In this case,
5885: the definition would look like:</p>
5886: <pre class="programlisting">
5887: MASTER_SITES= http://www.example.com/download.cgi?file=
5888: </pre>
5889: <p>There are some predefined values for
5890: <code class="varname">MASTER_SITES</code>, which can be used in packages.
5891: The names of the variables should speak for themselves.</p>
5892: <pre class="programlisting">
5893: ${MASTER_SITE_APACHE}
5894: ${MASTER_SITE_BACKUP}
5895: ${MASTER_SITE_CYGWIN}
5896: ${MASTER_SITE_DEBIAN}
5897: ${MASTER_SITE_FREEBSD}
5898: ${MASTER_SITE_FREEBSD_LOCAL}
5899: ${MASTER_SITE_GNOME}
5900: ${MASTER_SITE_GNU}
5901: ${MASTER_SITE_GNUSTEP}
5902: ${MASTER_SITE_IFARCHIVE}
5903: ${MASTER_SITE_KDE}
5904: ${MASTER_SITE_MOZILLA}
5905: ${MASTER_SITE_MYSQL}
5906: ${MASTER_SITE_OPENOFFICE}
5907: ${MASTER_SITE_PERL_CPAN}
5908: ${MASTER_SITE_PGSQL}
5909: ${MASTER_SITE_R_CRAN}
5910: ${MASTER_SITE_SOURCEFORGE}
5911: ${MASTER_SITE_SOURCEFORGE_JP}
5912: ${MASTER_SITE_SUNSITE}
5913: ${MASTER_SITE_SUSE}
5914: ${MASTER_SITE_TEX_CTAN}
5915: ${MASTER_SITE_XCONTRIB}
5916: ${MASTER_SITE_XEMACS}
5917: </pre>
5918: <p>If you choose one of these predefined sites, you may want
5919: to specify a subdirectory of that site. Since these macros may
5920: expand to more than one actual site, you
5921: <span class="emphasis"><em>must</em></span> use the following construct to specify
5922: a subdirectory:</p>
5923: <pre class="programlisting">
5924: MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
5925: MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
5926: </pre>
5927: <p>Note the trailing slash after the subdirectory
5928: name.</p>
5929: </div>
5930: <div class="sect2" lang="en">
5931: <div class="titlepage"><div><div><h3 class="title">
5932: <a name="build.fetch.how"></a>15.5.2. How are the files fetched?</h3></div></div></div>
5933: <p>The <span class="emphasis"><em>fetch</em></span> phase makes sure that all
5934: the distfiles exist in a local directory
5935: (<code class="varname">DISTDIR</code>), which can be set by the pkgsrc
5936: user). If the files do not exist, they are fetched using
5937: commands of the form
5938:
5939: </p>
1.75 rillig 5940: <pre class="programlisting">
5941: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
5942: </pre>
1.81 rillig 5943: <p>
5944:
5945: where <code class="literal">${site}</code> varies through several
5946: possibilities in turn: first,
5947: <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the sites
5948: specified in either <code class="varname">SITES.file</code> if defined,
5949: else <code class="varname">MASTER_SITES</code> or
5950: <code class="varname">PATCH_SITES</code>, as applies, then finally the
5951: value of <code class="varname">MASTER_SITE_BACKUP</code>. The order of all
5952: except the first can be optionally sorted by the user, via
5953: setting either <code class="varname">MASTER_SORT_AWK</code> or
5954: <code class="varname">MASTER_SORT_REGEX</code>.</p>
5955: </div>
1.75 rillig 5956: </div>
5957: <div class="sect1" lang="en">
5958: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5959: <a name="build.checksum"></a>15.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
1.75 rillig 5960: <p>After the distfile(s) are fetched, their checksum is generated and
5961: compared with the checksums stored in the distinfo file. If the
5962: checksums don't match, the build is aborted. This is to ensure the same
5963: distfile is used for building, and that the distfile wasn't changed,
5964: e.g. by some malign force, deliberately changed distfiles on the master
5965: distribution site or network lossage.</p>
5966: </div>
5967: <div class="sect1" lang="en">
5968: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5969: <a name="build.extract"></a>15.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
1.75 rillig 5970: <p>When the distfiles are present on the local system, they
5971: need to be extracted, as they usually come in the form of some
5972: compressed archive format.</p>
5973: <p>By default, all <code class="varname">DISTFILES</code> are
5974: extracted. If you only need some of them, you can set the
5975: <code class="varname">EXTRACT_ONLY</code> variable to the list of those
5976: files.</p>
5977: <p>Extracting the files is usually done by a little program,
1.76 rillig 5978: <code class="filename">mk/scripts/extract</code>, which already knows how
1.75 rillig 5979: to extract various archive formats, so most likely you will not
5980: need to change anything here. But if you need, the following
5981: variables may help you:</p>
5982: <div class="variablelist"><dl>
5983: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
5984: <dd><p>Use these variables to override the default
5985: options for an extract command, which are defined in
1.76 rillig 5986: <code class="filename">mk/scripts/extract</code>.</p></dd>
1.75 rillig 5987: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
5988: <dd><p>This variable can be set to
5989: <code class="literal">pax</code>, <code class="literal">tar</code> or an absolute
5990: pathname pointing to the command with which tar archives should
5991: be extracted.</p></dd>
5992: </dl></div>
1.76 rillig 5993: <p>If the <code class="filename">extract</code> program doesn't serve
1.75 rillig 5994: your needs, you can also override the
5995: <code class="varname">EXTRACT_CMD</code> variable, which holds the command
5996: used for extracting the files. This command is executed in the
1.76 rillig 5997: <code class="filename">${WRKSRC}</code> directory. During execution of
1.75 rillig 5998: this command, the shell variable <code class="varname">extract_file</code>
5999: holds the absolute pathname of the file that is going to be
6000: extracted.</p>
6001: <p>And if that still does not suffice, you can override the
6002: <code class="varname">do-extract</code> target in the package
6003: Makefile.</p>
6004: </div>
6005: <div class="sect1" lang="en">
6006: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6007: <a name="build.patch"></a>15.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
1.75 rillig 6008: <p>After extraction, all the patches named by the
6009: <code class="varname">PATCHFILES</code>, those present in the patches
6010: subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
1.76 rillig 6011: <code class="filename">/usr/local/patches/graphics/png</code>) are applied.
6012: Patchfiles ending in <code class="filename">.Z</code> or
6013: <code class="filename">.gz</code> are uncompressed before they are applied,
6014: files ending in <code class="filename">.orig</code> or
6015: <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 6016: can be handed in <code class="varname">PATCH_DIST_ARGS</code>.
1.77 rillig 6017: See <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a> for more details.</p>
1.75 rillig 6018: <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
6019: patches apply with some lines of fuzz. Please fix (regen) the patches
6020: so that they apply cleanly. The rationale behind this is that
6021: patches that don't apply cleanly may end up being applied in the wrong
6022: place, and cause severe harm there.</p>
6023: </div>
6024: <div class="sect1" lang="en">
6025: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6026: <a name="build.tools"></a>15.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
1.75 rillig 6027: <p>This is covered in
1.77 rillig 6028: <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 6029: </p>
6030: </div>
6031: <div class="sect1" lang="en">
6032: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6033: <a name="build.wrapper"></a>15.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
1.75 rillig 6034: <p>This phase creates wrapper programs for the compilers and
6035: linkers. The following variables can be used to tweak the
6036: wrappers.</p>
6037: <div class="variablelist"><dl>
6038: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
6039: <dd><p>The command used to print progress
6040: messages. Does nothing by default. Set to
6041: <code class="literal">${ECHO}</code> to see the progress
6042: messages.</p></dd>
6043: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
6044: <dd><p>This variable can be set to
6045: <code class="literal">yes</code> (default) or
6046: <code class="literal">no</code>, depending on whether you want
6047: additional information in the wrapper log
6048: file.</p></dd>
6049: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
6050: <dd><p>This variable can be set to
6051: <code class="literal">yes</code> or <code class="literal">no</code>,
6052: depending on whether the wrapper should use its cache,
6053: which will improve the speed. The default value is
6054: <code class="literal">yes</code>, but is forced to
6055: <code class="literal">no</code> if the platform does not support
6056: it.</p></dd>
6057: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
6058: <dd><p>A list of reordering commands. A
6059: reordering command has the form
6060: <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
6061: It ensures that that
6062: <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code>
6063: occurs before
6064: <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
6065: </p></dd>
6066: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
6067: <dd><p>A list of transformation commands. [TODO:
6068: investigate further]</p></dd>
6069: </dl></div>
6070: </div>
6071: <div class="sect1" lang="en">
6072: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6073: <a name="build.configure"></a>15.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.75 rillig 6074: <p>Most pieces of software need information on the header files,
6075: system calls, and library routines which are available on the platform
6076: they run on. The process of determining this information is known as
6077: configuration, and is usually automated. In most cases, a script is
6078: supplied with the distfiles, and its invocation results in generation of
6079: header files, Makefiles, etc.</p>
6080: <p>If the package contains a configure script, this can be invoked by
6081: setting <code class="varname">HAS_CONFIGURE</code> to “<span class="quote">yes</span>”. If the
6082: configure script is a GNU autoconf script, you should set
6083: <code class="varname">GNU_CONFIGURE</code> to “<span class="quote">yes</span>” instead. What
6084: happens in the <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
6085: <pre class="programlisting">
6086: .for d in ${CONFIGURE_DIRS}
6087: cd ${WRKSRC} && cd ${d} && env ${CONFIGURE_ENV} \
6088: ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
6089: .endfor
6090: </pre>
6091: <p><code class="varname">CONFIGURE_DIRS</code> (default: “<span class="quote">.</span>”) is a
6092: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
6093: these directories, the configure script is run with the environment
6094: <code class="varname">CONFIGURE_ENV</code> and arguments
6095: <code class="varname">CONFIGURE_ARGS</code>. The variables
6096: <code class="varname">CONFIGURE_ENV</code>, <code class="varname">CONFIGURE_SCRIPT</code>
6097: (default: “<span class="quote">./configure</span>”) and
6098: <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
6099: package.</p>
1.76 rillig 6100: <p>If the program uses an <code class="filename">Imakefile</code> for
1.75 rillig 6101: configuration, the appropriate steps can be invoked by setting
6102: <code class="varname">USE_IMAKE</code> to “<span class="quote">yes</span>”. (If you only want
6103: the package installed in <code class="varname">${X11PREFIX}</code> but xmkmf not
6104: being run, set <code class="varname">USE_X11BASE</code> instead.)</p>
6105: </div>
6106: <div class="sect1" lang="en">
6107: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6108: <a name="build.build"></a>15.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.75 rillig 6109: <p>For building a package, a rough equivalent of the following code
6110: is executed.</p>
6111: <pre class="programlisting">
6112: .for d in ${BUILD_DIRS}
6113: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
6114: ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
6115: -f ${MAKEFILE} ${BUILD_TARGET}
6116: .endfor
6117: </pre>
6118: <p><code class="varname">BUILD_DIRS</code> (default: “<span class="quote">.</span>”) is a
6119: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
6120: these directories, <code class="varname">MAKE_PROGRAM</code> is run with the
6121: environment <code class="varname">MAKE_ENV</code> and arguments
6122: <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
6123: <code class="varname">MAKE_ENV</code>, <code class="varname">BUILD_MAKE_FLAGS</code>,
6124: <code class="varname">MAKEFILE</code> and <code class="varname">BUILD_TARGET</code> may all
6125: be changed by the package.</p>
6126: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
6127: “<span class="quote">gmake</span>” if <code class="varname">USE_TOOLS</code> contains
6128: “<span class="quote">gmake</span>”, “<span class="quote">make</span>” otherwise. The default value
6129: of <code class="varname">MAKEFILE</code> is “<span class="quote">Makefile</span>”, and
6130: <code class="varname">BUILD_TARGET</code> defaults to “<span class="quote">all</span>”.</p>
6131: </div>
6132: <div class="sect1" lang="en">
6133: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6134: <a name="build.test"></a>15.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
1.75 rillig 6135: <p>[TODO]</p>
6136: </div>
6137: <div class="sect1" lang="en">
6138: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6139: <a name="build.install"></a>15.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75 rillig 6140: <p>Once the build stage has completed, the final step is to
6141: install the software in public directories, so users can access
6142: the programs and files.</p>
6143: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
6144: equivalent of the following code is executed. Additionally,
6145: before and after this code, much magic is performed to do
6146: consistency checks, registering the package, and so on.</p>
6147: <pre class="programlisting">
6148: .for d in ${INSTALL_DIRS}
6149: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
6150: ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
6151: -f ${MAKEFILE} ${BUILD_TARGET}
6152: .endfor
6153: </pre>
6154: <p>The variable's meanings are analogous to the ones in the
6155: <span class="emphasis"><em>build</em></span> phase.
6156: <code class="varname">INSTALL_DIRS</code> defaults to
6157: <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
6158: is “<span class="quote">install</span>” by default, plus
6159: “<span class="quote">install.man</span>” if <code class="varname">USE_IMAKE</code> is
6160: defined.</p>
6161: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
6162: variables are useful. They are all variations of the
6163: <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
6164: permissions preset. <code class="varname">INSTALL</code> is the plain
6165: install command. The specialized variants, together with their
6166: intended use, are:</p>
6167: <div class="variablelist"><dl>
6168: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
6169: <dd><p>directories that contain binaries</p></dd>
6170: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
6171: <dd><p>directories that contain scripts</p></dd>
6172: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
6173: <dd><p>directories that contain shared and static libraries</p></dd>
6174: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
6175: <dd><p>directories that contain data files</p></dd>
6176: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
6177: <dd><p>directories that contain man pages</p></dd>
6178: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
6179: <dd><p>binaries that can be stripped from debugging symbols</p></dd>
6180: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
6181: <dd><p>binaries that cannot be stripped</p></dd>
6182: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
6183: <dd><p>game binaries</p></dd>
6184: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
6185: <dd><p>shared and static libraries</p></dd>
6186: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
6187: <dd><p>data files</p></dd>
6188: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
6189: <dd><p>data files for games</p></dd>
6190: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
6191: <dd><p>man pages</p></dd>
6192: </dl></div>
6193: <p>Some other variables are:</p>
6194: <div class="variablelist"><dl>
6195: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
6196: <dd><p>A list of directories relative to
6197: <code class="varname">PREFIX</code> that are created by pkgsrc at
1.78 rillig 6198: the beginning of the <span class="emphasis"><em>install</em></span> phase.
6199: If this variable is set,
1.75 rillig 6200: <code class="varname">NO_MTREE</code>=“<span class="quote">yes</span>” is
6201: assumed, which means that the package claims to create
6202: all needed directories itself before installing files to
6203: it. Therefore this variable should only be set in
1.76 rillig 6204: <code class="filename">Makefile</code>s that are under control of
1.78 rillig 6205: the package's author. The directories are created with
6206: the correct ownership, depending on their
6207: name.</p></dd>
1.75 rillig 6208: </dl></div>
6209: </div>
6210: <div class="sect1" lang="en">
6211: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6212: <a name="build.package"></a>15.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
1.75 rillig 6213: <p>[TODO]</p>
6214: </div>
6215: <div class="sect1" lang="en">
6216: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6217: <a name="build.helpful-targets"></a>15.16. Other helpful targets</h2></div></div></div>
1.75 rillig 6218: <div class="variablelist"><dl>
6219: <dt><span class="term">pre/post-*</span></dt>
6220: <dd><p>For any of the main targets described in the previous section, two
6221: auxiliary targets exist with “<span class="quote">pre-</span>” and
6222: “<span class="quote">post-</span>” used as a prefix
6223: for the main target's name. These targets are invoked before and
6224: after the main target is called, allowing extra configuration or
6225: installation steps be performed from a package's Makefile, for
6226: example, which a program's configure script
6227: or install target omitted.</p></dd>
6228: <dt><span class="term">do-*</span></dt>
6229: <dd><p>Should one of the main targets do the wrong thing, and should there
6230: be no variable to fix this, you can redefine it with the do-*
6231: target. (Note that redefining the target itself instead of the
6232: do-* target is a bad idea, as the pre-* and post-* targets won't be
6233: called anymore, etc.) You will not usually need to do this.</p></dd>
6234: <dt><span class="term">reinstall</span></dt>
6235: <dd><p>If you did a <span><strong class="command">make install</strong></span> and you noticed some file
6236: was not installed properly, you can repeat the installation with this
6237: target, which will ignore the “<span class="quote">already installed</span>” flag.</p></dd>
6238: <dt><span class="term">deinstall</span></dt>
6239: <dd>
6240: <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,
6241: effectively de-installing the package. The following variables can
6242: be used to tune the behaviour:</p>
6243: <div class="variablelist"><dl>
6244: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
6245: <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>
6246: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
6247: <dd><p>Remove all packages that require (depend on) the given package.
6248: This can be used to remove any packages that may have been pulled in
6249: by a given package, e.g. if <span><strong class="command">make deinstall
6250: DEINSTALLDEPENDS=1</strong></span> is done in
1.76 rillig 6251: <code class="filename">pkgsrc/x11/kde</code>, this is likely to remove whole
1.75 rillig 6252: 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>
6253: </dl></div>
6254: </dd>
6255: <dt><span class="term">update</span></dt>
6256: <dd>
6257: <p>This target causes the current package to be updated to the latest
6258: version. The package and all depending packages first get de-installed,
6259: then current versions of the corresponding packages get compiled and
6260: installed. This is similar to manually noting which packages are
6261: currently installed, then performing a series of <span><strong class="command">make
6262: deinstall</strong></span> and <span><strong class="command">make install</strong></span> (or whatever
6263: <code class="varname">UPDATE_TARGET</code> is set to) for these packages.</p>
6264: <p>You can use the “<span class="quote">update</span>” target to resume package
6265: updating in case a previous <span><strong class="command">make update</strong></span> was interrupted
6266: for some reason. However, in this case, make sure you don't call
6267: <span><strong class="command">make clean</strong></span> or otherwise remove the list of dependent
6268: packages in <code class="varname">WRKDIR</code>. Otherwise, you lose the
6269: ability to automatically update the current package along with the
6270: dependent packages you have installed.</p>
6271: <p>Resuming an interrupted <span><strong class="command">make update</strong></span> will only work as
6272: long as the package tree remains unchanged. If the source code for
6273: one of the packages to be updated has been changed, resuming
6274: <span><strong class="command">make update</strong></span> will most certainly fail!</p>
6275: <p>The following variables can be used either on the command line or in
1.76 rillig 6276: <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75 rillig 6277: <span><strong class="command">make update</strong></span>:</p>
6278: <div class="variablelist"><dl>
6279: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
6280: <dd><p>Install target to recursively use for the updated package and the
6281: dependent packages. Defaults to <code class="varname">DEPENDS_TARGET</code> if set,
6282: “<span class="quote">install</span>” otherwise for <span><strong class="command">make update</strong></span>.
6283: e.g. <span><strong class="command">make update UPDATE_TARGET=package</strong></span></p></dd>
6284: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
6285: <dd><p>Don't clean up after updating. Useful if you want to leave the
6286: work sources of the updated packages around for inspection or
6287: other purposes. Be sure you eventually clean up the source
6288: tree (see the “<span class="quote">clean-update</span>” target below) or you may
6289: run into troubles with old source code still lying around on your
6290: next <span><strong class="command">make</strong></span> or <span><strong class="command">make update</strong></span>.</p></dd>
6291: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
6292: <dd><p>Deinstall each package before installing (making
6293: <code class="varname">DEPENDS_TARGET</code>). This may be necessary if the
6294: “<span class="quote">clean-update</span>” target (see below) was called after
6295: interrupting a running <span><strong class="command">make update</strong></span>.</p></dd>
6296: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
6297: <dd><p>Allows you to disable recursion and hardcode the target for
6298: packages. The default is “<span class="quote">update</span>” for the update target,
6299: facilitating a recursive update of prerequisite packages.
6300: Only set <code class="varname">DEPENDS_TARGET</code> if you want to disable
6301: recursive updates. Use <code class="varname">UPDATE_TARGET</code> instead to just
6302: set a specific target for each package to be installed during
6303: <span><strong class="command">make update</strong></span> (see above).</p></dd>
6304: </dl></div>
6305: </dd>
6306: <dt><span class="term">clean-update</span></dt>
6307: <dd>
6308: <p>Clean the source tree for all packages that would get updated if
6309: <span><strong class="command">make update</strong></span> was called from the current directory.
6310: This target should not be used if the current package (or any of its
6311: depending packages) have already been de-installed (e.g., after calling
6312: <span><strong class="command">make update</strong></span>) or you may lose some packages you intended
6313: to update. As a rule of thumb: only use this target
6314: <span class="emphasis"><em>before</em></span> the first time you run
6315: <span><strong class="command">make update</strong></span> and only if you have a dirty package tree
6316: (e.g., if you used <code class="varname">NOCLEAN</code>).</p>
6317: <p>If you are unsure about whether your tree is clean, you can either
6318: perform a <span><strong class="command">make clean</strong></span> at the top of the tree, or use
6319: the following sequence of commands from the directory of the package
6320: you want to update (<span class="emphasis"><em>before</em></span> running
6321: <span><strong class="command">make update</strong></span> for the first time, otherwise you lose
6322: all the packages you wanted to update!):</p>
6323: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
6324: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
6325: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong></pre>
6326: <p>The following variables can be used either on the command line or in
1.76 rillig 6327: <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75 rillig 6328: <span><strong class="command">make clean-update</strong></span>:</p>
6329: <div class="variablelist"><dl>
6330: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
6331: <dd><p>After <span><strong class="command">make clean</strong></span>, do not reconstruct the list of
6332: directories to update for this package. Only use this if <span><strong class="command">make
6333: update</strong></span> successfully installed all packages you wanted to
6334: update. Normally, this is done automatically on <span><strong class="command">make
6335: update</strong></span>, but may have been suppressed by the
6336: <code class="varname">NOCLEAN</code> variable (see above).</p></dd>
6337: </dl></div>
6338: </dd>
6339: <dt><span class="term">info</span></dt>
6340: <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
6341: package. You can use this to check which version of a package is
6342: installed.</p></dd>
6343: <dt><span class="term">readme</span></dt>
1.76 rillig 6344: <dd><p>This target generates a <code class="filename">README.html</code> file, which
1.75 rillig 6345: can be viewed using a browser such as
1.76 rillig 6346: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/mozilla/README.html" target="_top"><code class="filename">www/mozilla</code></a> or
6347: <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 6348: The generated files contain references to any
6349: packages which are in the <code class="varname">PACKAGES</code> directory on
6350: the local host. The generated files can be made to refer to URLs based on
6351: <code class="varname">FTP_PKG_URL_HOST</code> and
6352: <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I wanted to generate
1.76 rillig 6353: <code class="filename">README.html</code> files which pointed to binary packages
1.75 rillig 6354: on the local machine, in the directory
1.76 rillig 6355: <code class="filename">/usr/packages</code>, set
1.75 rillig 6356: <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
6357: <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
6358: <code class="varname">${PACKAGES}</code> directory and its subdirectories will be
6359: searched for all the binary packages.</p></dd>
6360: <dt><span class="term">readme-all</span></dt>
1.76 rillig 6361: <dd><p>Use this target to create a file <code class="filename">README-all.html</code>
1.75 rillig 6362: which contains a list of all packages currently available in the NetBSD
6363: Packages Collection, together with the category they belong to and a
6364: short description. This file is compiled from the
1.76 rillig 6365: <code class="filename">pkgsrc/*/README.html</code> files, so be sure to run
1.75 rillig 6366: this <span class="emphasis"><em>after</em></span> a <span><strong class="command">make readme</strong></span>.</p></dd>
6367: <dt><span class="term">cdrom-readme</span></dt>
6368: <dd><p>This is very much the same as the “<span class="quote">readme</span>” target (see
6369: above), but is to be used when generating a pkgsrc tree to be written
6370: to a CD-ROM. This target also produces
1.76 rillig 6371: <code class="filename">README.html</code> files, and can be made to refer
1.75 rillig 6372: to URLs based on <code class="varname">CDROM_PKG_URL_HOST</code> and
6373: <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
6374: <dt><span class="term">show-distfiles</span></dt>
6375: <dd><p>This target shows which distfiles and patchfiles are needed to build
6376: the package. (<code class="varname">DISTFILES</code> and
1.76 rillig 6377: <code class="varname">PATCHFILES</code>, but not <code class="filename">patches/*</code>)</p></dd>
1.75 rillig 6378: <dt><span class="term">show-downlevel</span></dt>
6379: <dd><p>This target shows nothing if the package is not installed. If a version
6380: of this package is installed, but is not the version provided in this
6381: version of pkgsrc, then a warning message is displayed. This target can
6382: be used to show which of your installed packages are downlevel, and so
6383: the old versions can be deleted, and the current ones added.</p></dd>
6384: <dt><span class="term">show-pkgsrc-dir</span></dt>
6385: <dd><p>This target shows the directory in the pkgsrc hierarchy from which the
6386: package can be built and installed. This may not be the same directory
6387: as the one from which the package was installed. This target is intended
6388: to be used by people who may wish to upgrade many packages on a single
6389: host, and can be invoked from the top-level pkgsrc Makefile by using the
6390: “<span class="quote">show-host-specific-pkgs</span>” target.</p></dd>
6391: <dt><span class="term">show-installed-depends</span></dt>
6392: <dd><p>This target shows which installed packages match the current package's
6393: <code class="varname">DEPENDS</code>. Useful if out of date dependencies are
6394: causing build problems.</p></dd>
6395: <dt><span class="term">check-shlibs</span></dt>
6396: <dd><p>After a package is installed, check all its binaries and (on ELF
6397: platforms) shared libraries to see if they find the shared libs they need.
6398: Run by default if <code class="varname">PKG_DEVELOPER</code> is set in
1.76 rillig 6399: <code class="filename">/etc/mk.conf</code>.</p></dd>
1.75 rillig 6400: <dt><span class="term">print-PLIST</span></dt>
6401: <dd>
6402: <p>After a “<span class="quote">make install</span>” from a new or
6403: upgraded pkg, this prints out an attempt to generate a new
1.76 rillig 6404: <code class="filename">PLIST</code> from a <span><strong class="command">find -newer
1.75 rillig 6405: work/.extract_done</strong></span>. An attempt is made to care
6406: for shared libs etc., but it is
6407: <span class="emphasis"><em>strongly</em></span> recommended to review the
6408: result before putting it into
1.76 rillig 6409: <code class="filename">PLIST</code>. On upgrades, it's useful to
1.75 rillig 6410: diff the output of this command against an already
1.76 rillig 6411: existing <code class="filename">PLIST</code> file.</p>
1.75 rillig 6412: <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
6413: methods that don't update file access times, be sure to
6414: add these files manually to your
1.76 rillig 6415: <code class="filename">PLIST</code>, as the “<span class="quote">find
1.75 rillig 6416: -newer</span>” command used by this target won't catch
6417: them!</p>
1.77 rillig 6418: <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 6419: information on this target.</p>
6420: </dd>
6421: <dt><span class="term">bulk-package</span></dt>
6422: <dd>
6423: <p>Used to do bulk builds. If an appropriate binary package already exists,
6424: no action is taken. If not, this target will compile, install and
6425: package it (and its depends, if <code class="varname">PKG_DEPENDS</code> is
6426: set properly. See <a href="#binary.configuration" title="6.3.1. Configuration">Section 6.3.1, “Configuration”</a>).
6427: After creating the binary
6428: package, the sources, the just-installed package and its required
6429: packages are removed, preserving free disk space.</p>
6430: <p><span class="emphasis"><em>Beware that this target may deinstall all
6431: packages installed on a system!</em></span></p>
6432: </dd>
6433: <dt><span class="term">bulk-install</span></dt>
6434: <dd>
6435: <p>Used during bulk-installs to install required packages. If an
6436: up-to-date binary package is available, it will be installed via
6437: <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,
6438: but the installed binary won't be removed. </p>
6439: <p> A binary package is considered “<span class="quote">up-to-date</span>” to be
6440: 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>
6441: <div class="itemizedlist"><ul type="disc">
1.76 rillig 6442: <li><p>None of the package's files (<code class="filename">Makefile</code>,
1.75 rillig 6443: ...) were modified since it was built.</p></li>
6444: <li><p>None of the package's required (binary) packages were
6445: modified since it was built.</p></li>
6446: </ul></div>
6447: <p><span class="emphasis"><em>Beware that this target may deinstall all
6448: packages installed on a system!</em></span></p>
6449: </dd>
6450: </dl></div>
6451: </div>
6452: </div>
6453: <div class="chapter" lang="en">
6454: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 6455: <a name="tools"></a>Chapter 16. Tools needed for building or running</h2></div></div></div>
1.75 rillig 6456: <div class="toc">
6457: <p><b>Table of Contents</b></p>
6458: <dl>
1.77 rillig 6459: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
6460: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
6461: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
1.75 rillig 6462: </dl>
6463: </div>
6464: <p>
6465: The <code class="varname">USE_TOOLS</code> definition is used both internally
6466: by pkgsrc and also for individual packages to define what commands
6467: are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
6468: or for later run-time of an installed packaged (such as
6469: <code class="varname">DEPENDS</code>).
6470: If the native system provides an adequate tool, then in many cases, a pkgsrc
6471: package will not be used.
6472: </p>
6473: <p>
6474: When building a package, the replacement tools are
6475: made available in a directory (as symlinks or wrapper scripts)
6476: that is early in the executable search path. Just like the buildlink
6477: system, this helps with consistent builds.
6478: </p>
6479: <p>
6480: A tool may be needed to help build a specific package. For example,
6481: perl, GNU make (gmake) or yacc may be needed.
6482: </p>
6483: <p>
6484: Also a tool may be needed, for example, because the native system's supplied
6485: tool may be inefficient for building a package with pkgsrc.
6486: For example, a package may need GNU awk, bison (instead of
6487: yacc) or a better sed.
6488: </p>
6489: <p>
6490: The tools used by a package can be listed by running
6491: <span><strong class="command">make show-tools</strong></span>.
6492: </p>
6493: <div class="sect1" lang="en">
6494: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6495: <a name="pkgsrc-tools"></a>16.1. Tools for pkgsrc builds</h2></div></div></div>
1.75 rillig 6496: <p>
6497: The default set of tools used by pkgsrc is defined in
1.76 rillig 6498: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.75 rillig 6499: such as: <span><strong class="command">cat</strong></span>, <span><strong class="command">awk</strong></span>,
6500: <span><strong class="command">chmod</strong></span>, <span><strong class="command">test</strong></span>, and so on.
6501: These can be seen by running:
6502: <span><strong class="command">make show-var VARNAME=USE_TOOLS</strong></span>.
6503: </p>
6504: <p>
6505: If a package needs a specific program to build
6506: then the <code class="varname">USE_TOOLS</code> variable can be used
6507: to define the tools needed.
6508: </p>
6509: </div>
6510: <div class="sect1" lang="en">
6511: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6512: <a name="package-tools"></a>16.2. Tools needed by packages</h2></div></div></div>
1.75 rillig 6513: <p>
6514: In the following examples, the :pkgsrc means to use the pkgsrc version
6515: and not the native version for a build dependency.
6516: And the :run means that it is used for a
6517: run-time dependencies also (and becomes a DEPENDS).
6518: The default is a build dependency which can be set with
6519: :build. (So in this example, it is the same as gmake:build
6520: and pkg-config:build.)
6521: </p>
6522: <pre class="programlisting">
6523: USE_TOOLS+= mktemp:pkgsrc
6524: USE_TOOLS+= gmake perl:run pkg-config
6525: </pre>
6526: <p>
6527: When using the tools framework, a
6528: <code class="varname">TOOLS_PATH.foo</code> variable is defined
6529: which contains the full path to the appropriate tool. For example,
6530: <code class="varname">TOOLS_PATH.bash</code> could be “<span class="quote">/bin/bash</span>”
6531: on Linux systems.
6532: </p>
6533: <p>
6534: If you always need a pkgsrc version of the
6535: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
6536:
6537: </p>
6538: </div>
6539: <div class="sect1" lang="en">
6540: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6541: <a name="platform-tools"></a>16.3. Tools provided by platforms</h2></div></div></div>
1.75 rillig 6542: <p>
6543: When improving or porting pkgsrc to a new platform, have a look
6544: at (or create) the corresponding platform specific make file fragment under
1.76 rillig 6545: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
1.75 rillig 6546: the name of the common tools. For example:</p>
6547: <pre class="programlisting">
6548: .if exists(/usr/bin/bzcat)
6549: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
6550: .elif exists(/usr/bin/bzip2)
6551: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
6552: .endif
1.69 rillig 6553:
1.75 rillig 6554: TOOLS_PLATFORM.true?= true # shell builtin
6555: </pre>
6556: </div>
6557: </div>
6558: <div class="chapter" lang="en">
6559: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 6560: <a name="fixes"></a>Chapter 17. Making your package work</h2></div></div></div>
1.75 rillig 6561: <div class="toc">
6562: <p><b>Table of Contents</b></p>
6563: <dl>
1.77 rillig 6564: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
1.75 rillig 6565: <dd><dl>
1.78 rillig 6566: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
6567: <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>
6568: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
6569: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
6570: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
6571: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
6572: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
6573: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
6574: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
6575: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
6576: <dt><span class="sect2"><a href="#bumping-pkgrevision">17.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
1.79 rillig 6577: <dt><span class="sect2"><a href="#fixes.subst">17.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
1.77 rillig 6578: </dl></dd>
6579: <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>
6580: <dd><dl>
6581: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
6582: <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>
6583: </dl></dd>
6584: <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>
6585: <dd><dl>
6586: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
6587: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
6588: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
6589: </dl></dd>
6590: <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>
6591: <dd><dl>
1.78 rillig 6592: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
6593: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
6594: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
6595: </dl></dd>
6596: <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>
6597: <dd><dl>
6598: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
6599: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
6600: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
6601: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
6602: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
6603: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
6604: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
6605: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
6606: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
6607: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
6608: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
6609: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
6610: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
6611: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
6612: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
6613: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
6614: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.75 rillig 6615: </dl></dd>
1.78 rillig 6616: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.75 rillig 6617: </dl>
6618: </div>
6619: <div class="sect1" lang="en">
6620: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6621: <a name="general-operation"></a>17.1. General operation</h2></div></div></div>
1.75 rillig 6622: <div class="sect2" lang="en">
6623: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6624: <a name="portability-of-packages"></a>17.1.1. Portability of packages</h3></div></div></div>
6625: <p>One appealing feature of pkgsrc is that it runs on many
6626: different platforms. As a result, it is important to ensure,
6627: where possible, that packages in pkgsrc are portable. This
6628: chapter mentions some particular details you should pay
6629: attention to while working on pkgsrc.</p>
6630: </div>
6631: <div class="sect2" lang="en">
6632: <div class="titlepage"><div><div><h3 class="title">
6633: <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>
6634: <p>The pkgsrc user can configure pkgsrc by overriding several
6635: variables in the file pointed to by <code class="varname">MAKECONF</code>,
6636: which is <code class="filename">/etc/mk.conf</code> by default. When you
6637: want to use those variables in the preprocessor directives of
6638: <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
6639: <code class="literal">.for</code>), you need to include the file
6640: <code class="filename">../../mk/bsd.prefs.mk</code> before, which in turn
6641: loads the user preferences.</p>
6642: <p>But note that some variables may not be completely defined
6643: after <code class="filename">../../mk/bsd.prefs.mk</code> has been
6644: included, as they may contain references to variables that are
6645: not yet defined. In shell commands this is no problem, since
6646: variables are actually macros, which are only expanded when they
6647: are used. But in the preprocessor directives mentioned above and
6648: in dependency lines (of the form <code class="literal">target:
6649: dependencies</code>) the variables are expanded at load
6650: time.</p>
6651: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
6652: <h3 class="title">Note</h3>
6653: <p>Currently there is no exhaustive list of all
6654: variables that tells you whether they can be used at load time
6655: or only at run time, but it is in preparation.</p>
6656: </div>
6657: </div>
6658: <div class="sect2" lang="en">
6659: <div class="titlepage"><div><div><h3 class="title">
6660: <a name="user-interaction"></a>17.1.3. User interaction</h3></div></div></div>
6661: <p>Occasionally, packages require interaction from the user, and this can be
6662: in a number of ways:</p>
6663: <div class="itemizedlist"><ul type="disc">
1.79 rillig 6664: <li><p>When fetching the distfiles, some packages require user
6665: interaction such as entering username/password or accepting a
6666: license on a web page.</p></li>
1.78 rillig 6667: <li><p>When extracting the distfiles, some packages may ask for passwords.</p></li>
6668: <li><p>help to configure the package before it is built</p></li>
6669: <li><p>help during the build process</p></li>
6670: <li><p>help during the installation of a package</p></li>
6671: </ul></div>
6672: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is provided to notify
6673: the pkgsrc mechanism of an interactive stage which will be needed, and
6674: this should be set in the package's <code class="filename">Makefile</code>, e.g.:</p>
1.75 rillig 6675: <pre class="programlisting">
1.78 rillig 6676: INTERACTIVE_STAGE= build
1.75 rillig 6677: </pre>
1.78 rillig 6678: <p>Multiple interactive stages can be specified:</p>
1.75 rillig 6679: <pre class="programlisting">
1.78 rillig 6680: INTERACTIVE_STAGE= configure install
1.75 rillig 6681: </pre>
6682: </div>
6683: <div class="sect2" lang="en">
6684: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6685: <a name="handling-licenses"></a>17.1.4. Handling licenses</h3></div></div></div>
6686: <p>A package may be covered by a license which the user has
6687: or has not agreed to accept. For these cases, pkgsrc contains
6688: a mechanism to note that a package is covered by a particular
6689: license, and the package cannot be built unless the user has
6690: accepted the license. (Installation of binary packages are
6691: not currently subject to this mechanism.) Packages with
6692: licenses that are either Open Source according to the Open
6693: Source Initiative or Free according to the Free Software
6694: Foundation will not be marked with a license tag. Packages
6695: with licenses that have not been determined to meet either
6696: definition will be marked with a license tag referring to the
6697: license. This will prevent building unless pkgsrc is informed
6698: that the license is acceptable, and enables displaying the
6699: license.</p>
6700: <p>The license tag mechanism is intended to address
6701: copyright-related issues surrounding building, installing and
6702: using a package, and not to address redistribution issues (see
6703: <code class="varname">RESTRICTED</code> and
6704: <code class="varname">NO_SRC_ON_FTP</code>, etc.). However, the above
6705: definition of licenses for which tags are not needed implies
6706: that packages with redistribution restrictions should have
6707: tags.</p>
6708: <p>
6709: Denoting that a package is covered by a particular license is
6710: done by placing the license in
6711: <code class="filename">pkgsrc/licenses</code> and setting the
6712: <code class="varname">LICENSE</code> variable to a string identifying
6713: the license, e.g. in
6714: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>: </p>
6715: <pre class="programlisting">
6716: LICENSE= xv-license
6717: </pre>
6718: <p>
6719: When trying to build, the user will get a notice that the
6720: package is covered by a license which has not been
6721: accepted:</p>
6722: <pre class="programlisting">
6723: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
6724: ===> xv-3.10anb9 has an unacceptable license: xv-license.
6725: ===> To view the license, enter "/usr/bin/make show-license".
6726: ===> To indicate acceptance, add this line to your /etc/mk.conf:
6727: ===> ACCEPTABLE_LICENSES+=xv-license
6728: *** Error code 1
6729: </pre>
6730: <p>The license can be viewed with <span><strong class="command">make
6731: show-license</strong></span>, and if it is considered appropriate,
6732: the line printed above can be added to
6733: <code class="filename">/etc/mk.conf</code> to indicate acceptance of
6734: the particular license:</p>
6735: <pre class="programlisting">
6736: ACCEPTABLE_LICENSES+=xv-license
6737: </pre>
6738: <p>When adding a package with a new license, the license
6739: text should be added to <code class="filename">pkgsrc/licenses</code>
6740: for displaying. A list of known licenses can be seen in this
6741: directory as well as by looking at the list of (commented
6742: out) <code class="varname">ACCEPTABLE_LICENSES</code> variable
6743: settings in
6744: <code class="filename">pkgsrc/mk/defaults/mk.conf</code>.</p>
6745: <p>The use of <code class="varname">LICENSE=shareware</code>,
6746: <code class="varname">LICENSE=no-commercial-use</code>, and similar
6747: language is deprecated because it does not crisply refer to
6748: a particular license text. Another problem with such usage
6749: is that it does not enable a user to denote acceptance of
6750: the license for a single package without accepting the same
6751: license text for another package. In particular, this can
6752: be inappropriate when e.g. one accepts a particular license to
6753: indicate to pkgsrc that a fee has been paid.</p>
1.75 rillig 6754: </div>
6755: <div class="sect2" lang="en">
6756: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6757: <a name="restricted-packages"></a>17.1.5. Restricted packages</h3></div></div></div>
1.75 rillig 6758: <p>Some licenses restrict how software may be re-distributed.
6759: In order to satisfy these restrictions, the package system
6760: defines five make variables that can be set to note these
6761: restrictions:</p>
6762: <div class="itemizedlist"><ul type="disc">
6763: <li>
6764: <p><code class="varname">RESTRICTED</code></p>
6765: <p>This variable should be set whenever a restriction
6766: exists (regardless of its kind). Set this variable to a
6767: string containing the reason for the restriction.</p>
6768: </li>
6769: <li>
6770: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
6771: <p>Binaries may not be placed on CD-ROM. Set this
6772: variable to <code class="varname">${RESTRICTED}</code> whenever a
6773: binary package may not be included on a CD-ROM.</p>
6774: </li>
6775: <li>
6776: <p><code class="varname">NO_BIN_ON_FTP</code></p>
6777: <p>Binaries may not be placed on an FTP server. Set
6778: this variable to <code class="varname">${RESTRICTED}</code>
6779: whenever a binary package may not not be made available
6780: on the Internet.</p>
6781: </li>
6782: <li>
6783: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
6784: <p>Distfiles may not be placed on CD-ROM. Set this
6785: variable to <code class="varname">${RESTRICTED}</code> if
6786: re-distribution of the source code or other distfile(s) is
6787: not allowed on CD-ROMs.</p>
6788: </li>
6789: <li>
6790: <p><code class="varname">NO_SRC_ON_FTP</code></p>
6791: <p>Distfiles may not be placed on FTP. Set this variable
6792: to <code class="varname">${RESTRICTED}</code> if re-distribution of
6793: the source code or other distfile(s) via the Internet is not
6794: allowed.</p>
6795: </li>
6796: </ul></div>
6797: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
6798: <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
6799: generic make variables to denote restrictions is deprecated,
6800: because they unconditionally prevent users from generating
6801: binary packages!</p>
6802: </div>
6803: <div class="sect2" lang="en">
6804: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6805: <a name="dependencies"></a>17.1.6. Handling dependencies</h3></div></div></div>
1.75 rillig 6806: <p>Your package may depend on some other package being present
6807: - and there are various ways of expressing this
6808: dependency. pkgsrc supports the <code class="varname">BUILD_DEPENDS</code>
6809: and <code class="varname">DEPENDS</code> definitions, the
6810: <code class="varname">USE_TOOLS</code> definition, as well as
1.76 rillig 6811: dependencies via <code class="filename">buildlink3.mk</code>, which is
1.75 rillig 6812: the preferred way to handle dependencies, and which uses the
1.77 rillig 6813: variables named above. See <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a> for more
1.75 rillig 6814: information.</p>
6815: <p>The basic difference between the two variables is as
6816: follows: The <code class="varname">DEPENDS</code> definition registers
6817: that pre-requisite in the binary package so it will be pulled in
6818: when the binary package is later installed, whilst the
6819: <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
6820: dependency that is only needed for building the package.
6821: </p>
6822: <p>This means that if you only need a package present whilst
6823: you are building, it should be noted as a
6824: <code class="varname">BUILD_DEPENDS</code>.</p>
6825: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
6826: <code class="varname">DEPENDS</code> definition is:</p>
6827: <pre class="programlisting">
6828: <pre-req-package-name>:../../<category>/<pre-req-package>
6829: </pre>
6830: <p>Please note that the “<span class="quote">pre-req-package-name</span>”
6831: may include any of the wildcard version numbers recognized by
6832: <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>
6833: <div class="orderedlist"><ol type="1">
6834: <li>
6835: <p>If your package needs another package's binaries or
6836: libraries to build or run, and if that package has a
1.76 rillig 6837: <code class="filename">buildlink3.mk</code> file available, use it:
1.75 rillig 6838: </p>
6839: <pre class="programlisting">
6840: .include "../../graphics/jpeg/buildlink3.mk"
6841: </pre>
6842: </li>
6843: <li>
6844: <p>If your package needs to use another package to build
1.76 rillig 6845: itself and there is no <code class="filename">buildlink3.mk</code>
1.75 rillig 6846: file available, use the <code class="varname">BUILD_DEPENDS</code>
6847: definition:</p>
6848: <pre class="programlisting">
6849: BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
6850: </pre>
6851: </li>
6852: <li>
6853: <p>If your package needs a library with which to link and
1.76 rillig 6854: again there is no <code class="filename">buildlink3.mk</code> file
1.75 rillig 6855: available, this is specified using the
6856: <code class="varname">DEPENDS</code> definition. For example:</p>
6857: <pre class="programlisting">
6858: DEPENDS+= xpm-3.4j:../../graphics/xpm
6859: </pre>
6860: <p>You can also use wildcards in package dependences:</p>
6861: <pre class="programlisting">
6862: DEPENDS+= xpm-[0-9]*:../../graphics/xpm
6863: </pre>
6864: <p>Note that such wildcard dependencies are retained when
6865: creating binary packages. The dependency is checked when
6866: installing the binary package and any package which matches
6867: the pattern will be used. Wildcard dependencies should be
6868: used with care.</p>
6869: <p>The “<span class="quote">-[0-9]*</span>” should be used instead of
6870: “<span class="quote">-*</span>” to avoid potentially ambiguous matches
6871: such as “<span class="quote">tk-postgresql</span>” matching a
6872: “<span class="quote">tk-*</span>” <code class="varname">DEPENDS</code>.</p>
6873: <p>Wildcards can also be used to specify that a package
6874: will only build against a certain minimum version of a
6875: pre-requisite:</p>
6876: <pre class="programlisting">
6877: DEPENDS+= tiff>=3.5.4:../../graphics/tiff
6878: </pre>
6879: <p>This means that the package will build against version
6880: 3.5.4 of the tiff library or newer. Such a dependency may
6881: be warranted if, for example, the API of the library has
6882: changed with version 3.5.4 and a package would not compile
6883: against an earlier version of tiff.</p>
6884: <p>Please note that such dependencies should only be
6885: updated if a package requires a newer pre-requisite, but
6886: not to denote recommendations such as
6887: ABI changes that do not prevent a package from building
6888: correctly. Such recommendations can be expressed using
6889: <code class="varname">ABI_DEPENDS</code>:</p>
6890: <pre class="programlisting">
6891: ABI_DEPENDS+= tiff>=3.6.1:../../graphics/tiff
6892: </pre>
6893: <p>In addition to the above <code class="varname">DEPENDS</code>
6894: line, this denotes that while a package will build against
6895: tiff>=3.5.4, at least version 3.6.1 is recommended.
6896: <code class="varname">ABI_DEPENDS</code> entries will be turned into
6897: dependencies unless explicitly ignored (in which case a
6898: warning will be printed).</p>
6899: <p>To ignore these ABI dependency recommendations and just
6900: use the required <code class="varname">DEPENDS</code>, set
6901: <code class="varname">USE_ABI_DEPENDS=NO</code>. This may make
6902: it easier and faster to update packages built using pkgsrc,
6903: since older compatible dependencies can continue to be
6904: used. This is useful for people who watch their rebuilds
6905: very carefully; it is not very good as a general-purpose
6906: hammer. If you use it, you need to be mindful of possible
6907: ABI changes, including those from the underlying OS.
6908: </p>
6909: <p>Packages that are built with recommendations ignored
6910: may not be uploaded to ftp.NetBSD.org by developers and
6911: should not be used across different systems that may have
6912: different versions of binary packages installed.</p>
6913: <p>For security fixes, please update the package
1.78 rillig 6914: 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 6915: information.</p>
6916: </li>
6917: <li>
6918: <p>If your package needs some executable to be able to run
6919: correctly and if there's no
1.76 rillig 6920: <code class="filename">buildlink3.mk</code> file, this is specified
1.75 rillig 6921: using the <code class="varname">DEPENDS</code> variable. The
1.76 rillig 6922: <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 6923: be able to execute the latex binary from the teTeX package
6924: when it runs, and that is specified:</p>
6925: <pre class="programlisting">
6926: DEPENDS+= teTeX-[0-9]*:../../print/teTeX
6927: </pre>
6928: <p>The comment about wildcard dependencies from previous
6929: paragraph applies here, too.</p>
6930: </li>
6931: </ol></div>
6932: <p>If your package needs files from another package to build,
6933: add the relevant distribution files to
6934: <code class="varname">DISTFILES</code>, so they will be extracted
1.76 rillig 6935: 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 6936: (It relies on the jpeg sources being present in source form
6937: during the build.)</p>
6938: <p>Please also note the <code class="varname">BUILD_USES_MSGFMT</code>
6939: and <code class="varname">BUILD_USES_GETTEXT_M4</code> definitions, which
6940: are provided as convenience definitions. The former works out
6941: 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 6942: 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 6943: The latter adds a build dependency on either an installed
6944: version of an older gettext package, or if it isn't, installs the
1.76 rillig 6945: <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 6946: </div>
6947: <div class="sect2" lang="en">
6948: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6949: <a name="conflicts"></a>17.1.7. Handling conflicts with other packages</h3></div></div></div>
1.75 rillig 6950: <p>Your package may conflict with other packages a user might
6951: already have installed on his system, e.g. if your package
6952: installs the same set of files like another package in our
6953: pkgsrc tree.</p>
6954: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
6955: space-separated list of packages (including version string) your
6956: package conflicts with.</p>
1.76 rillig 6957: <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>
6958: 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 6959: install the same shared library, thus you set in
1.76 rillig 6960: <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
1.75 rillig 6961: <pre class="programlisting">
6962: CONFLICTS= Xaw-Xpm-[0-9]*
6963: </pre>
1.76 rillig 6964: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:
1.75 rillig 6965: </p>
6966: <pre class="programlisting">
6967: CONFLICTS= Xaw3d-[0-9]*
6968: </pre>
6969: <p>Packages will automatically conflict with other packages
6970: with the name prefix and a different version
6971: string. “<span class="quote">Xaw3d-1.5</span>” e.g. will automatically
6972: conflict with the older version “<span class="quote">Xaw3d-1.3</span>”.
6973: </p>
6974: </div>
6975: <div class="sect2" lang="en">
6976: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6977: <a name="not-building-packages"></a>17.1.8. Packages that cannot or should not be built</h3></div></div></div>
1.75 rillig 6978: <p>There are several reasons why a package might be
6979: instructed to not build under certain circumstances. If the
6980: package builds and runs on most platforms, the exceptions
6981: should be noted with <code class="varname">NOT_FOR_PLATFORM</code>. If
6982: the package builds and runs on a small handful of platforms,
6983: set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
6984: Both <code class="varname">ONLY_FOR_PLATFORM</code> and
6985: <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
6986: (OS-version-platform) that can use glob-style
6987: wildcards.</p>
6988: <p>If the package should be skipped (for example, because it
6989: provides functionality already provided by the system), set
6990: <code class="varname">PKG_SKIP_REASON</code> to a descriptive message.
6991: If the package should fail because some preconditions are not
6992: met, set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
6993: message.</p>
6994: </div>
6995: <div class="sect2" lang="en">
6996: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6997: <a name="undeletable-packages"></a>17.1.9. Packages which should not be deleted, once installed</h3></div></div></div>
1.75 rillig 6998: <p>To ensure that a package may not be deleted, once it has been
6999: installed, the <code class="varname">PKG_PRESERVE</code> definition should
7000: be set in the package Makefile. This will be carried into any
7001: binary package that is made from this pkgsrc entry. A
7002: “<span class="quote">preserved</span>” package will
7003: 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
7004: “<span class="quote">-f</span>” option is used.</p>
7005: </div>
7006: <div class="sect2" lang="en">
7007: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7008: <a name="security-handling"></a>17.1.10. Handling packages with security problems</h3></div></div></div>
1.75 rillig 7009: <p>When a vulnerability is found, this should be noted in
1.76 rillig 7010: <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
1.75 rillig 7011: and after committing that file, use <span><strong class="command">make upload</strong></span>
7012: in the same directory to update the file on ftp.NetBSD.org.</p>
7013: <p>After fixing the vulnerability by a patch, its
7014: <code class="varname">PKGREVISION</code> should be increased (this
7015: is of course not necessary if the problem is fixed by using
7016: a newer release of the software).</p>
7017: <p>Also, if the fix should be applied to the stable pkgsrc
7018: branch, be sure to submit a pullup request!</p>
7019: <p>Binary packages already on ftp.NetBSD.org will be handled
7020: semi-automatically by a weekly cron job.</p>
7021: </div>
7022: <div class="sect2" lang="en">
7023: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7024: <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 7025: <p>When making fixes to an existing package it can be useful
7026: to change the version number in <code class="varname">PKGNAME</code>. To
7027: avoid conflicting with future versions by the original author, a
7028: “<span class="quote">nb1</span>”, “<span class="quote">nb2</span>”, ... suffix can be used
7029: on package versions by setting <code class="varname">PKGREVISION=1</code>
7030: (2, ...). The “<span class="quote">nb</span>” is treated like a
7031: “<span class="quote">.</span>” by the pkg tools. e.g.</p>
7032: <pre class="programlisting">
7033: DISTNAME= foo-17.42
7034: PKGREVISION= 9
7035: </pre>
7036: <p>will result in a <code class="varname">PKGNAME</code> of
7037: “<span class="quote">foo-17.42nb9</span>”.</p>
7038: <p>When a new release of the package is released, the
7039: <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
7040: minor release of the above package, things should be like:</p>
7041: <pre class="programlisting">
7042: DISTNAME= foo-17.43
7043: </pre>
1.78 rillig 7044: <p>PKGREVISION should be incremented for any non-trivial change in the
7045: resulting binary package. Without a PKGREVISION bump, someone with
7046: the previous version installed has no way of knowing that their
7047: package is out of date. Thus, changes without increasing PKGREVISION
7048: are essentially labeled "this is so trivial that no reasonable person
7049: would want to upgrade", and this is the rough test for when increasing
7050: PKGREVISION is appropriate. Examples of changes that do not merit
7051: increasing PKGREVISION are:</p>
7052: <pre class="programlisting">
7053: Changing HOMEPAGE, MAINTAINER, or comments in Makefile.
7054: Changing build variables if the resulting binary package is the same.
7055: Changing DESCR.
7056: Adding PKG_OPTIONS if the default options don't change.
7057: </pre>
7058: <p>Examples of changes that do merit an increase to PKGREVISION
7059: include:</p>
7060: <pre class="programlisting">
7061: Security fixes
7062: Changes or additions to a patch file
7063: Changes to the PLIST
1.75 rillig 7064: </pre>
1.78 rillig 7065: <p>PKGREVISION must also be incremented when dependencies have ABI
7066: changes.</p>
1.75 rillig 7067: </div>
1.79 rillig 7068: <div class="sect2" lang="en">
7069: <div class="titlepage"><div><div><h3 class="title">
7070: <a name="fixes.subst"></a>17.1.12. Substituting variable text in the package files (the SUBST framework)</h3></div></div></div>
7071: <p>When you want to replace the same text in multiple files
7072: or when the replacement text varies, patches alone cannot help.
7073: This is where the SUBST framework comes in. It provides an
7074: easy-to-use interface for replacing text in files.
7075: Example:</p>
7076: <pre class="programlisting">
7077: SUBST_CLASSES+= fix-paths
7078: SUBST_STAGE.fix-paths= pre-configure
7079: SUBST_MESSAGE.fix-paths= Fixing absolute paths.
7080: SUBST_FILES.fix-paths= src/*.c
7081: SUBST_FILES.fix-paths+= scripts/*.sh
7082: SUBST_SED.fix-paths= -e 's,"/usr/local,"${PREFIX},g'
7083: SUBST_SED.fix-paths+= -e 's,"/var/log,"${VARBASE}/log,g'
7084: </pre>
7085: <p><code class="varname">SUBST_CLASSES</code> is a list of identifiers
7086: that are used to identify the different SUBST blocks that are
7087: defined. The SUBST framework is heavily used by pkgsrc, so it is
7088: important to always use the <code class="literal">+=</code> operator with
7089: this variable. Otherwise some substitutions may be
7090: skipped.</p>
7091: <p>The remaining variables of each SUBST block are
7092: parameterized with the identifier from the first line
7093: (<code class="literal">fix-paths</code> in this case.) They can be seen as
7094: parameters to a function call.</p>
7095: <p><code class="varname">SUBST_STAGE.*</code> specifies the stage at
7096: which the replacement will take place. All combinations of
7097: <code class="literal">pre-</code>, <code class="literal">do-</code> and
7098: <code class="literal">post-</code> together with a phase name are
7099: possible, though only few are actually used. Most commonly used
7100: are <code class="literal">post-patch</code> and
7101: <code class="literal">pre-configure</code>. Of these two,
7102: <code class="literal">pre-configure</code> should be preferred because
7103: then it is possible to run <span><strong class="command">bmake patch</strong></span> and
7104: have the state after applying the patches but before making any
7105: other changes. This is especially useful when you are debugging
7106: a package in order to create new patches for it. Similarly,
7107: <code class="literal">post-build</code> is preferred over
7108: <code class="literal">pre-install</code>, because the install phase should
7109: generally be kept as simple as possible. When you use
7110: <code class="literal">post-build</code>, you have the same files in the
7111: working directory that will be installed later, so you can check
7112: if the substitution has succeeded.</p>
7113: <p><code class="varname">SUBST_MESSAGE.*</code> is an optional text
7114: that is printed just before the substitution is done.</p>
7115: <p><code class="varname">SUBST_FILES.*</code> is the list of shell
7116: globbing patterns that specifies the files in which the
7117: substitution will take place. The patterns are interpreted
7118: relatively to the <code class="varname">WRKSRC</code> directory.</p>
7119: <p><code class="varname">SUBST_SED.*</code> is a list of arguments to
7120: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?sed+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">sed</span>(1)</span></a> that specify the actual substitution. Every sed
7121: command should be prefixed with <code class="literal">-e</code>, so that
7122: all SUBST blocks look uniform.</p>
7123: <p>There are some more variables, but they are so seldomly
7124: used that they are only documented in the
1.80 rillig 7125: <code class="filename">mk/subst.mk</code> file.</p>
1.79 rillig 7126: </div>
1.75 rillig 7127: </div>
7128: <div class="sect1" lang="en">
7129: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7130: <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 7131: <div class="sect2" lang="en">
7132: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7133: <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 7134: <p>If you need to download from a dynamic URL you can set
7135: <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span><strong class="command">make
1.76 rillig 7136: fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
1.75 rillig 7137: with the name of each file to download as an argument, expecting
7138: it to output the URL of the directory from which to download
1.76 rillig 7139: it. <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/ns-cult3d/README.html" target="_top"><code class="filename">graphics/ns-cult3d</code></a> is an
1.79 rillig 7140: example of this usage.</p>
1.75 rillig 7141: <p>If the download can't be automated, because the user must
7142: submit personal information to apply for a password, or must pay
7143: for the source, or whatever, you can set
7144: <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
7145: displayed to the user before aborting the build. Example:</p>
7146: <pre class="programlisting">
7147: FETCH_MESSAGE= "Please download the files"
7148: FETCH_MESSAGE+= " "${DISTFILES:Q}
7149: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
7150: </pre>
7151: </div>
7152: <div class="sect2" lang="en">
7153: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7154: <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 7155: <p>Sometimes authors of a software package make some
7156: modifications after the software was released, and they put up a
7157: new distfile without changing the package's version number. If a
7158: package is already in pkgsrc at that time, the checksum will
7159: no longer match. The contents of the new distfile should be
7160: compared against the old one before changing anything, to make
7161: sure the distfile was really updated on purpose, and that
7162: no trojan horse or so crept in.
7163: Then, the correct way to work around this is to
7164: set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
7165: usually based on <code class="varname">PKGNAME_NOREV</code>. In case this
7166: happens more often, <code class="varname">PKGNAME</code> can be used (thus
1.76 rillig 7167: including the <code class="filename">nbX</code> suffix) or a date stamp
1.75 rillig 7168: can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
1.76 rillig 7169: Do not forget regenerating the <code class="filename">distinfo</code> file
1.75 rillig 7170: after that, since it contains the <code class="varname">DIST_SUBDIR</code>
7171: path in the filenames.
7172: Furthermore, a mail to the package's authors seems appropriate
7173: telling them that changing distfiles after releases without
7174: changing the file names is not good practice.</p>
7175: </div>
7176: </div>
7177: <div class="sect1" lang="en">
7178: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7179: <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 7180: <div class="sect2" lang="en">
7181: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7182: <a name="fixes.libtool"></a>17.3.1. Shared libraries - libtool</h3></div></div></div>
1.75 rillig 7183: <p>pkgsrc supports many different machines, with different
7184: object formats like a.out and ELF, and varying abilities to do
7185: shared library and dynamic loading at all. To accompany this,
7186: varying commands and options have to be passed to the
7187: compiler, linker, etc. to get the Right Thing, which can be
7188: pretty annoying especially if you don't have all the machines
7189: at your hand to test things. The
1.76 rillig 7190: <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 7191: can help here, as it just “<span class="quote">knows</span>” how to build
7192: both static and dynamic libraries from a set of source files,
7193: thus being platform-independent.</p>
7194: <p>Here's how to use libtool in a pkg in seven simple
7195: steps:</p>
7196: <div class="orderedlist"><ol type="1">
7197: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
7198: Makefile.</p></li>
7199: <li><p>For library objects, use “<span class="quote">${LIBTOOL} --mode=compile
7200: ${CC}</span>” in place of “<span class="quote">${CC}</span>”. You could even
7201: add it to the definition of <code class="varname">CC</code>, if only
7202: libraries are being built in a given Makefile. This one command
7203: will build both PIC and non-PIC library objects, so you need not
7204: have separate shared and non-shared library rules.</p></li>
7205: <li>
7206: <p>For the linking of the library, remove any
7207: “<span class="quote">ar</span>”, “<span class="quote">ranlib</span>”, and “<span class="quote">ld
7208: -Bshareable</span>” commands, and instead use:</p>
7209: <pre class="programlisting">
7210: ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
7211: -rpath ${PREFIX}/lib -version-info major:minor
7212: </pre>
7213: <p>Note that the library is changed to have a
1.76 rillig 7214: <code class="filename">.la</code> extension, and the objects are
7215: changed to have a <code class="filename">.lo</code>
1.75 rillig 7216: extension. Change <code class="varname">OBJS</code> as
7217: necessary. This automatically creates all of the
1.76 rillig 7218: <code class="filename">.a</code>,
7219: <code class="filename">.so.major.minor</code>, and ELF symlinks (if
1.75 rillig 7220: necessary) in the build directory. Be sure to include
7221: “<span class="quote">-version-info</span>”, especially when major and
7222: minor are zero, as libtool will otherwise strip off the
7223: shared library version.</p>
7224: <p>From the libtool manual:</p>
7225: <pre class="programlisting">
7226: So, libtool library versions are described by three integers:
1.69 rillig 7227:
1.75 rillig 7228: CURRENT
7229: The most recent interface number that this library implements.
1.69 rillig 7230:
1.75 rillig 7231: REVISION
7232: The implementation number of the CURRENT interface.
1.69 rillig 7233:
1.75 rillig 7234: AGE
7235: The difference between the newest and oldest interfaces that
7236: this library implements. In other words, the library implements
7237: all the interface numbers in the range from number `CURRENT -
7238: AGE' to `CURRENT'.
1.1 grant 7239:
1.75 rillig 7240: If two libraries have identical CURRENT and AGE numbers, then the
7241: dynamic linker chooses the library with the greater REVISION number.
7242: </pre>
7243: <p>The “<span class="quote">-release</span>” option will produce
7244: different results for a.out and ELF (excluding symlinks)
7245: in only one case. An ELF library of the form
7246: “<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
7247: will have a symlink of
7248: “<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
7249: on an a.out platform. This is handled
7250: automatically.</p>
7251: <p>The “<span class="quote">-rpath argument</span>” is the install
7252: directory of the library being built.</p>
1.76 rillig 7253: <p>In the <code class="filename">PLIST</code>, include only the
7254: <code class="filename">.la</code> file, the other files will be
1.75 rillig 7255: added automatically.</p>
7256: </li>
7257: <li>
1.76 rillig 7258: <p>When linking shared object (<code class="filename">.so</code>)
1.75 rillig 7259: 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
7260: shared libraries, use “<span class="quote">-module
7261: -avoid-version</span>” to prevent them getting version
7262: tacked on.</p>
1.76 rillig 7263: <p>The <code class="filename">PLIST</code> file gets the
7264: <code class="filename">foo.so</code> entry.</p>
1.75 rillig 7265: </li>
7266: <li>
7267: <p>When linking programs that depend on these libraries
7268: <span class="emphasis"><em>before</em></span> they are installed, preface
7269: 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}
7270: --mode=link</span>”, and it will find the correct
7271: libraries (static or shared), but please be aware that
7272: libtool will not allow you to specify a relative path in
7273: -L (such as “<span class="quote">-L../somelib</span>”), because it
7274: expects you to change that argument to be the
1.76 rillig 7275: <code class="filename">.la</code> file. e.g.</p>
1.75 rillig 7276: <pre class="programlisting">
7277: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
7278: </pre>
7279: <p>should be changed to:</p>
7280: <pre class="programlisting">
7281: ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
7282: </pre>
7283: <p>and it will do the right thing with the libraries.</p>
7284: </li>
7285: <li>
7286: <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>
7287: 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}
7288: --mode=install</span>”, and change the library name to
1.76 rillig 7289: <code class="filename">.la</code>. e.g.</p>
1.75 rillig 7290: <pre class="programlisting">
7291: ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
7292: </pre>
1.76 rillig 7293: <p>This will install the static <code class="filename">.a</code>,
1.75 rillig 7294: shared library, any needed symlinks, and run
7295: <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>
7296: </li>
1.76 rillig 7297: <li><p>In your <code class="filename">PLIST</code>, include only
7298: the <code class="filename">.la</code>
1.75 rillig 7299: file (this is a change from previous behaviour).</p></li>
7300: </ol></div>
7301: </div>
7302: <div class="sect2" lang="en">
7303: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7304: <a name="using-libtool"></a>17.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
1.75 rillig 7305: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
7306: package Makefile. This will override the package's own libtool
7307: in most cases. For older libtool using packages, libtool is
7308: made by ltconfig script during the do-configure step; you can
7309: check the libtool script location by doing <span><strong class="command">make
7310: configure; find work*/ -name libtool</strong></span>.</p>
7311: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
7312: scripts, relative to <code class="varname">WRKSRC</code>, to override. By
7313: default, it is set to “<span class="quote">libtool */libtool
7314: */*/libtool</span>”. If this does not match the location of the
7315: package's libtool script(s), set it as appropriate.</p>
1.76 rillig 7316: <p>If you do not need <code class="filename">*.a</code> static
1.75 rillig 7317: libraries built and installed, then use
7318: <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
7319: <p>If your package makes use of the platform-independent library
7320: for loading dynamic shared objects, that comes with libtool
7321: (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
7322: <p>Some packages use libtool incorrectly so that the package may not work or
7323: build in some circumstances. Some of the more common errors are:</p>
7324: <div class="itemizedlist"><ul type="disc">
7325: <li>
7326: <p>The inclusion of a shared object (-module) as a dependent library in an
7327: executable or library. This in itself isn't a problem if one of two things
7328: has been done:</p>
7329: <div class="orderedlist"><ol type="1">
7330: <li><p>The shared object is named correctly, i.e.
1.76 rillig 7331: <code class="filename">libfoo.la</code>, not
7332: <code class="filename">foo.la</code></p></li>
1.75 rillig 7333: <li><p>The -dlopen option is used when linking an executable.</p></li>
7334: </ol></div>
7335: </li>
7336: <li><p>The use of libltdl without the correct calls to initialisation routines.
7337: The function lt_dlinit() should be called and the macro
7338: <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
7339: executables.</p></li>
7340: </ul></div>
7341: </div>
7342: <div class="sect2" lang="en">
7343: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7344: <a name="autoconf-automake"></a>17.3.3. GNU Autoconf/Automake</h3></div></div></div>
1.75 rillig 7345: <p>If a package needs GNU autoconf or automake to be executed
7346: to regenerate the configure script and Makefile.in makefile
7347: templates, then they should be executed in a pre-configure
7348: target.</p>
7349: <p>For packages that need only autoconf:</p>
7350: <pre class="programlisting">
7351: AUTOCONF_REQD= 2.50 # if default version is not good enough
7352: USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
7353: ...
1.1 grant 7354:
1.75 rillig 7355: pre-configure:
7356: cd ${WRKSRC}; autoconf
1.1 grant 7357:
1.75 rillig 7358: ...
7359: </pre>
7360: <p>and for packages that need automake and autoconf:</p>
7361: <pre class="programlisting">
7362: AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
7363: USE_TOOLS+= automake # use "automake14" for automake-1.4
7364: ...
1.1 grant 7365:
1.75 rillig 7366: pre-configure:
7367: cd ${WRKSRC}; \
7368: aclocal; autoheader; \
7369: automake -a --foreign -i; autoconf
1.1 grant 7370:
1.75 rillig 7371: ...
7372: </pre>
7373: <p>Packages which use GNU Automake will almost certainly
7374: require GNU Make.</p>
7375: <p>There are times when the configure process makes
7376: additional changes to the generated files, which then causes
7377: the build process to try to re-execute the automake sequence.
7378: This is prevented by touching various files in the configure
7379: stage. If this causes problems with your package you can set
7380: <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
7381: Makefile.</p>
7382: </div>
7383: </div>
7384: <div class="sect1" lang="en">
7385: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7386: <a name="fixes.build"></a>17.4. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
7387: <p>The most common failures when building a package are that
7388: some platforms do not provide certain header files, functions or
7389: libraries, or they provide the functions in a library that the
7390: original package author didn't know. To work around this, you
7391: can rewrite the source code in most cases so that it does not
7392: use the missing functions or provides a replacement function.</p>
7393: <div class="sect2" lang="en">
7394: <div class="titlepage"><div><div><h3 class="title">
7395: <a name="fixes.build.cpp"></a>17.4.1. Compiling C and C++ code conditionally</h3></div></div></div>
7396: <p>If a package already comes with a GNU configure script, the
7397: preferred way to fix the build failure is to change the
7398: configure script, not the code. In the other cases, you can
7399: utilize the C preprocessor, which defines certain macros
7400: depending on the operating system and hardware architecture it
7401: compiles for. These macros can be queried using for example
7402: <code class="varname">#if defined(__i386)</code>. Almost every operating
7403: system, hardware architecture and compiler has its own macro.
7404: For example, if the macros <code class="varname">__GNUC__</code>,
7405: <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
7406: are all defined, you know that you are using NetBSD on an i386
7407: compatible CPU, and your compiler is GCC.</p>
7408: <p>The list of the following macros for hardware and
7409: operating system depends on the compiler that is used. For
7410: example, if you want to conditionally compile code on Solaris,
7411: don't use <code class="varname">__sun__</code>, as the SunPro compiler
7412: does not define it. Use <code class="varname">__sun</code> instead.</p>
1.75 rillig 7413: <div class="sect3" lang="en">
7414: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 7415: <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 7416: <p>To distinguish between 4.4 BSD-derived systems and the
7417: rest of the world, you should use the following code.</p>
7418: <pre class="programlisting">
7419: #include <sys/param.h>
7420: #if (defined(BSD) && BSD >= 199306)
7421: /* BSD-specific code goes here */
7422: #else
7423: /* non-BSD-specific code goes here */
7424: #endif
7425: </pre>
1.77 rillig 7426: <p>If this distinction is not fine enough, you can also test
7427: for the following macros.</p>
1.75 rillig 7428: <pre class="programlisting">
7429: FreeBSD __FreeBSD__
7430: DragonFly __DragonFly__
7431: Interix __INTERIX
7432: Linux linux, __linux, __linux__
7433: NetBSD __NetBSD__
7434: OpenBSD __OpenBSD__
7435: Solaris sun, __sun
7436: </pre>
7437: </div>
7438: <div class="sect3" lang="en">
7439: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 7440: <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 7441: <pre class="programlisting">
7442: i386 i386, __i386, __i386__
7443: MIPS __mips
7444: SPARC sparc, __sparc
7445: </pre>
7446: </div>
7447: <div class="sect3" lang="en">
7448: <div class="titlepage"><div><div><h4 class="title">
1.77 rillig 7449: <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 7450: <pre class="programlisting">
7451: GCC __GNUC__ (major version), __GNUC_MINOR__
7452: SunPro __SUNPRO_C (0x570 for version 5.7)
1.81 rillig 7453: SunPro C++ __SUNPRO_CC (0x580 for version 5.8)
1.75 rillig 7454: </pre>
7455: </div>
7456: </div>
1.78 rillig 7457: <div class="sect2" lang="en">
7458: <div class="titlepage"><div><div><h3 class="title">
7459: <a name="compiler-bugs"></a>17.4.2. How to handle compiler bugs</h3></div></div></div>
7460: <p>Some source files trigger bugs in the compiler, based on
7461: combinations of compiler version and architecture and almost
7462: always relation to optimisation being enabled. Common symptoms
7463: are gcc internal errors or never finishing compiling a
7464: file.</p>
7465: <p>Typically, a workaround involves testing the
7466: <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
7467: optimisation for that combination of file,
7468: <code class="varname">MACHINE_ARCH</code> and compiler, and documenting it
7469: in <code class="filename">pkgsrc/doc/HACKS</code>. See that file for a
7470: number of examples.</p>
7471: </div>
7472: <div class="sect2" lang="en">
7473: <div class="titlepage"><div><div><h3 class="title">
7474: <a name="undefined-reference"></a>17.4.3. Undefined reference to “<span class="quote">...</span>”</h3></div></div></div>
7475: <p>This compiler error often means that a package did not
7476: link to a shared library it needs. The following functions are
7477: known to cause this error message over and over.</p>
7478: <div class="informaltable">
7479: <a name="undefined-reference-functions"></a><table border="1">
7480: <colgroup>
7481: <col>
7482: <col>
7483: <col>
7484: </colgroup>
7485: <thead><tr>
7486: <th>Function</th>
7487: <th>Library</th>
7488: <th>Affected platforms</th>
7489: </tr></thead>
7490: <tbody>
7491: <tr>
7492: <td>accept, bind, connect</td>
7493: <td>-lsocket</td>
7494: <td>Solaris</td>
7495: </tr>
7496: <tr>
7497: <td>crypt</td>
7498: <td>-lcrypt</td>
7499: <td>DragonFly, NetBSD</td>
7500: </tr>
7501: <tr>
7502: <td>dlopen, dlsym</td>
7503: <td>-ldl</td>
7504: <td>Linux</td>
7505: </tr>
7506: <tr>
7507: <td>gethost*</td>
7508: <td>-lnsl</td>
7509: <td>Solaris</td>
7510: </tr>
7511: <tr>
7512: <td>inet_aton</td>
7513: <td>-lresolv</td>
7514: <td>Solaris</td>
7515: </tr>
7516: <tr>
7517: <td>nanosleep, sem_*, timer_*</td>
7518: <td>-lrt</td>
7519: <td>Solaris</td>
7520: </tr>
7521: <tr>
7522: <td>openpty</td>
7523: <td>-lutil</td>
7524: <td>Linux</td>
7525: </tr>
7526: </tbody>
7527: </table>
7528: </div>
7529: <p>To fix these linker errors, it is often sufficient to say
7530: <code class="literal">LIBS.<em class="replaceable"><code>OperatingSystem</code></em>+=
7531: -l<em class="replaceable"><code>foo</code></em></code> to the package
7532: <code class="filename">Makefile</code> and then say <span><strong class="command">bmake clean;
7533: bmake</strong></span>.</p>
7534: </div>
1.75 rillig 7535: </div>
7536: <div class="sect1" lang="en">
7537: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 7538: <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 7539: <div class="sect2" lang="en">
7540: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7541: <a name="install-scripts"></a>17.5.1. Creating needed directories</h3></div></div></div>
7542: <p>The BSD-compatible <span><strong class="command">install</strong></span> supplied
7543: with some operating systems cannot create more than one
7544: directory at a time. As such, you should call
7545: <code class="literal">${INSTALL_*_DIR}</code> like this:</p>
1.75 rillig 7546: <pre class="programlisting">
1.78 rillig 7547: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
7548: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
1.75 rillig 7549: </pre>
1.78 rillig 7550: <p>You can also just append “<span class="quote"><code class="literal">dir1
7551: dir2</code></span>” to the
7552: <code class="varname">INSTALLATION_DIRS</code> variable, which will
7553: automatically do the right thing.</p>
1.75 rillig 7554: </div>
7555: <div class="sect2" lang="en">
7556: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7557: <a name="where-to-install-documentation"></a>17.5.2. Where to install documentation</h3></div></div></div>
7558: <p>Documentation should be installed into
7559: <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
7560: <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the latter
7561: includes the version number of the package).</p>
1.75 rillig 7562: </div>
7563: <div class="sect2" lang="en">
7564: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7565: <a name="installing-score-files"></a>17.5.3. Installing score files</h3></div></div></div>
1.75 rillig 7566: <p>Certain packages, most of them in the games category, install
7567: a score file that allows all users on the system to record their
7568: highscores. In order for this to work, the binaries need to be
7569: installed setgid and the score files owned by the appropriate
7570: group and/or owner (traditionally the "games" user/group). The
7571: following variables, documented in more detail in
1.76 rillig 7572: <code class="filename">mk/defaults/mk.conf</code>, control this
1.75 rillig 7573: behaviour: <code class="varname">SETGIDGAME</code>,
7574: <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
7575: <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
7576: <p>Note that per default, setgid installation of games is
7577: disabled; setting <code class="varname">SETGIDGAME=YES</code> will set all
7578: the other variables accordingly.</p>
7579: <p>A package should therefor never hard code file ownership or
7580: access permissions but rely on <code class="varname">INSTALL_GAME</code> and
7581: <code class="varname">INSTALL_GAME_DATA</code> to set these
7582: correctly.</p>
7583: </div>
7584: <div class="sect2" lang="en">
7585: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7586: <a name="perl-scripts"></a>17.5.4. Packages containing perl scripts</h3></div></div></div>
1.75 rillig 7587: <p>
7588: If your package contains interpreted perl scripts, set
7589: <code class="varname">REPLACE_PERL</code> to ensure that the proper
7590: interpreter path is set. <code class="varname">REPLACE_PERL</code> should
7591: contain a list of scripts, relative to
7592: <code class="varname">WRKSRC</code>, that you want adjusted.</p>
7593: </div>
7594: <div class="sect2" lang="en">
7595: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7596: <a name="hardcoded-paths"></a>17.5.5. Packages with hardcoded paths to other interpreters</h3></div></div></div>
1.75 rillig 7597: <p>
7598: Your package may also contain scripts with hardcoded paths to
7599: other interpreters besides (or as well as) perl. To correct the
7600: full pathname to the script interpreter, you need to set the
1.76 rillig 7601: following definitions in your <code class="filename">Makefile</code> (we
1.75 rillig 7602: shall use <span><strong class="command">tclsh</strong></span> in this example):</p>
7603: <pre class="programlisting">
7604: REPLACE_INTERPRETER+= tcl
7605: REPLACE.tcl.old= .*/bin/tclsh
7606: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
7607: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
7608: # relative to ${WRKSRC}, just as in REPLACE_PERL
7609: </pre>
7610: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7611: <h3 class="title">Note</h3>
7612: <p>Before March 2006, these variables were called
7613: <code class="varname">_REPLACE.*</code> and
7614: <code class="varname">_REPLACE_FILES.*</code>.</p>
7615: </div>
7616: </div>
7617: <div class="sect2" lang="en">
7618: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7619: <a name="perl-modules"></a>17.5.6. Packages installing perl modules</h3></div></div></div>
1.75 rillig 7620: <p>Makefiles of packages providing perl5 modules should include
7621: the Makefile fragment
1.76 rillig 7622: <code class="filename">../../lang/perl5/module.mk</code>. It provides a
1.75 rillig 7623: <span><strong class="command">do-configure</strong></span> target for the standard perl
7624: configuration for such modules as well as various hooks to tune
7625: this configuration. See comments in this file for
7626: details.</p>
7627: <p>Perl5 modules will install into different places depending
7628: on the version of perl used during the build process. To
7629: address this, pkgsrc will append lines to the
1.76 rillig 7630: <code class="filename">PLIST</code> corresponding to the files listed in
7631: the installed <code class="filename">.packlist</code> file generated by
1.75 rillig 7632: most perl5 modules. This is invoked by defining
7633: <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
7634: paths to packlist files, e.g.:</p>
7635: <pre class="programlisting">
7636: PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
7637: </pre>
7638: <p>The variables <code class="varname">PERL5_SITELIB</code>,
7639: <code class="varname">PERL5_SITEARCH</code>, and
7640: <code class="varname">PERL5_ARCHLIB</code> represent the three locations
7641: in which perl5 modules may be installed, and may be used by
7642: perl5 packages that don't have a packlist. These three
7643: variables are also substituted for in the
1.76 rillig 7644: <code class="filename">PLIST</code>.</p>
1.75 rillig 7645: </div>
7646: <div class="sect2" lang="en">
7647: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7648: <a name="faq.info-files"></a>17.5.7. Packages installing info files</h3></div></div></div>
1.75 rillig 7649: <p>Some packages install info files or use the
7650: “<span class="quote">makeinfo</span>” or “<span class="quote">install-info</span>”
7651: commands. <code class="varname">INFO_FILES</code> should be defined in
1.76 rillig 7652: the package Makefile so that <code class="filename">INSTALL</code> and
7653: <code class="filename">DEINSTALL</code> scripts will be generated to
1.75 rillig 7654: handle registration of the info files in the Info directory
7655: file. The “<span class="quote">install-info</span>” command used for the info
7656: files registration is either provided by the system, or by a
7657: special purpose package automatically added as dependency if
7658: needed.</p>
7659: <p><code class="varname">PKGINFODIR</code> is the directory under
1.76 rillig 7660: <code class="filename">${PREFIX}</code> where info files are primarily
1.75 rillig 7661: located. <code class="varname">PKGINFODIR</code> defaults to
7662: “<span class="quote">info</span>” and can be overridden by the user.</p>
7663: <p>The info files for the package should be listed in the
1.76 rillig 7664: package <code class="filename">PLIST</code>; however any split info files
1.75 rillig 7665: need not be listed.</p>
7666: <p>A package which needs the “<span class="quote">makeinfo</span>” command
7667: at build time must add “<span class="quote">makeinfo</span>” to
7668: <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
7669: version of the “<span class="quote">makeinfo</span>” command is needed it
7670: should be noted with the <code class="varname">TEXINFO_REQD</code>
1.76 rillig 7671: variable in the package <code class="filename">Makefile</code>. By
1.75 rillig 7672: default, a minimum version of 3.12 is required. If the system
7673: does not provide a <span><strong class="command">makeinfo</strong></span> command or if it
7674: does not match the required minimum, a build dependency on the
1.76 rillig 7675: <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 7676: be added automatically.</p>
7677: <p>The build and installation process of the software provided
7678: by the package should not use the
7679: <span><strong class="command">install-info</strong></span> command as the registration of
7680: info files is the task of the package
1.76 rillig 7681: <code class="filename">INSTALL</code> script, and it must use the
1.75 rillig 7682: appropriate <span><strong class="command">makeinfo</strong></span> command.</p>
7683: <p>To achieve this goal, the pkgsrc infrastructure creates
7684: overriding scripts for the <span><strong class="command">install-info</strong></span> and
7685: <span><strong class="command">makeinfo</strong></span> commands in a directory listed early
7686: in <code class="varname">PATH</code>.</p>
7687: <p>The script overriding <span><strong class="command">install-info</strong></span> has
7688: no effect except the logging of a message. The script overriding
7689: <span><strong class="command">makeinfo</strong></span> logs a message and according to the
7690: value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
7691: <span><strong class="command">makeinfo</strong></span> command or exit on error.</p>
7692: </div>
7693: <div class="sect2" lang="en">
7694: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7695: <a name="manpages"></a>17.5.8. Packages installing man pages</h3></div></div></div>
1.81 rillig 7696: <p>All packages that install manual pages should install them
7697: into the same directory, so that there is one common place to
7698: look for them. In pkgsrc, this place is
7699: <code class="literal">${PREFIX}/${PKGMANDIR}</code>, and this expression
7700: should be used in packages. The default for
7701: <code class="varname">PKGMANDIR</code> is
7702: “<span class="quote"><code class="filename">man</code></span>”. Another often-used
7703: value is “<span class="quote"><code class="filename">share/man</code></span>”.</p>
1.75 rillig 7704: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7705: <h3 class="title">Note</h3>
1.81 rillig 7706: <p>The support for a custom
7707: <code class="varname">PKGMANDIR</code> is far from complete.</p>
1.75 rillig 7708: </div>
1.81 rillig 7709: <p>The <code class="filename">PLIST</code> files can just use
7710: <code class="filename">man/</code> as the top level directory for the man
7711: page file entries, and the pkgsrc framework will convert as
7712: needed. In all other places, the correct
7713: <code class="varname">PKGMANDIR</code> must be used.</p>
1.75 rillig 7714: <p> Packages that are
7715: configured with <code class="varname">GNU_CONFIGURE</code> set as
7716: “<span class="quote">yes</span>”, by default will use the
1.76 rillig 7717: <code class="filename">./configure</code>
1.75 rillig 7718: --mandir switch to set where the man pages should be installed.
7719: The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
7720: to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.
7721: </p>
7722: <p>
7723: Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
7724: use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
7725: to “<span class="quote">no</span>”.
1.76 rillig 7726: Or if the <code class="filename">./configure</code> script uses
1.75 rillig 7727: a non-standard use of --mandir, you can set
7728: <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.
7729: </p>
1.77 rillig 7730: <p>See <a href="#manpage-compression" title="11.5. Man page compression">Section 11.5, “Man page compression”</a> for
1.75 rillig 7731: information on installation of compressed manual pages.
7732: </p>
7733: </div>
7734: <div class="sect2" lang="en">
7735: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7736: <a name="gconf2-data-files"></a>17.5.9. Packages installing GConf2 data files</h3></div></div></div>
1.75 rillig 7737: <p>
1.76 rillig 7738: If a package installs <code class="filename">.schemas</code> or
7739: <code class="filename">.entries</code> files, used by GConf2,
1.75 rillig 7740: you need to take some extra steps to make sure they get registered
7741: in the database:
7742: </p>
7743: <div class="orderedlist"><ol type="1">
1.76 rillig 7744: <li><p>Include <code class="filename">../../devel/GConf2/schemas.mk</code>
7745: instead of its <code class="filename">buildlink3.mk</code> file. This
1.75 rillig 7746: takes care of rebuilding the GConf2 database at installation and
7747: deinstallation time, and tells the package where to install
7748: GConf2 data files using some standard configure arguments. It
7749: also disallows any access to the database directly from the
7750: package.</p></li>
7751: <li><p>Ensure that the package installs its
1.76 rillig 7752: <code class="filename">.schemas</code> files under
7753: <code class="filename">${PREFIX}/share/gconf/schemas</code>. If they get
7754: installed under <code class="filename">${PREFIX}/etc</code>, you will
1.75 rillig 7755: need to manually patch the package.</p></li>
7756: <li><p>Check the PLIST and remove any entries under the etc/gconf
7757: directory, as they will be handled automatically. See
7758: <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>
7759: <li><p>Define the <code class="varname">GCONF2_SCHEMAS</code> variable in
1.76 rillig 7760: your <code class="filename">Makefile</code> with a list of all
7761: <code class="filename">.schemas</code> files installed by the package, if
1.75 rillig 7762: any. Names must not contain any directories in them.</p></li>
7763: <li><p>Define the <code class="varname">GCONF2_ENTRIES</code> variable in
1.76 rillig 7764: your <code class="filename">Makefile</code> with a
7765: list of all <code class="filename">.entries</code> files installed by the
1.75 rillig 7766: package, if any. Names must not contain any directories in
7767: them.</p></li>
7768: </ol></div>
7769: </div>
7770: <div class="sect2" lang="en">
7771: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7772: <a name="scrollkeeper-data-files"></a>17.5.10. Packages installing scrollkeeper data files</h3></div></div></div>
1.75 rillig 7773: <p>
1.76 rillig 7774: If a package installs <code class="filename">.omf</code> files, used by
1.75 rillig 7775: scrollkeeper, you need to take some extra steps to make sure they
7776: get registered in the database:
7777: </p>
7778: <div class="orderedlist"><ol type="1">
7779: <li><p>Include
1.76 rillig 7780: <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
7781: instead of its <code class="filename">buildlink3.mk</code> file. This
1.75 rillig 7782: takes care of rebuilding the scrollkeeper database at
7783: installation and deinstallation time, and disallows any access
7784: to it directly from the package.
7785: </p></li>
7786: <li><p>Check the PLIST and remove any entries under the
1.76 rillig 7787: <code class="filename">libdata/scrollkeeper</code> directory, as they
1.75 rillig 7788: will be handled automatically.</p></li>
1.76 rillig 7789: <li><p>Remove the <code class="filename">share/omf</code> directory from
1.75 rillig 7790: the PLIST. It will be handled by scrollkeeper.</p></li>
7791: </ol></div>
7792: </div>
7793: <div class="sect2" lang="en">
7794: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7795: <a name="x11-fonts"></a>17.5.11. Packages installing X11 fonts</h3></div></div></div>
1.75 rillig 7796: <p>If a package installs font files, you will need to rebuild
7797: the fonts database in the directory where they get installed at
7798: installation and deinstallation time. This can be automatically
7799: done by using the pkginstall framework.</p>
7800: <p>You can list the directories where fonts are installed in the
7801: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
7802: variables, where <em class="replaceable"><code>type</code></em> can be one of
7803: “<span class="quote">ttf</span>”, “<span class="quote">type1</span>” or “<span class="quote">x11</span>”.
7804: Also make sure that the database file
1.76 rillig 7805: <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
1.75 rillig 7806: <p>Note that you should not create new directories for fonts;
7807: instead use the standard ones to avoid that the user needs to
7808: manually configure his X server to find them.</p>
7809: </div>
7810: <div class="sect2" lang="en">
7811: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7812: <a name="gtk2-modules"></a>17.5.12. Packages installing GTK2 modules</h3></div></div></div>
1.75 rillig 7813: <p>If a package installs GTK2 immodules or loaders, you need to
7814: take some extra steps to get them registered in the GTK2 database
7815: properly:</p>
7816: <div class="orderedlist"><ol type="1">
7817: <li><p>Include
1.76 rillig 7818: <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
7819: <code class="filename">buildlink3.mk</code> file. This takes care of
1.75 rillig 7820: rebuilding the database at installation and deinstallation time.
7821: </p></li>
7822: <li><p>
7823: Set <code class="varname">GTK2_IMMODULES=YES</code> if
7824: your package installs GTK2 immodules.</p></li>
7825: <li><p>
7826: Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
7827: GTK2 loaders.</p></li>
7828: <li>
7829: <p>
7830: Patch the package to not touch any of the GTK2 databases directly.
7831: These are:
7832:
7833: </p>
7834: <div class="itemizedlist"><ul type="disc">
1.76 rillig 7835: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
7836: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
1.75 rillig 7837: </ul></div>
7838: <p>
7839: </p>
7840: </li>
7841: <li><p>
7842: Check the PLIST and remove any entries under the
1.76 rillig 7843: <code class="filename">libdata/gtk-2.0</code> directory, as they will be
1.75 rillig 7844: handled automatically.</p></li>
7845: </ol></div>
7846: </div>
7847: <div class="sect2" lang="en">
7848: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7849: <a name="sgml-xml-data"></a>17.5.13. Packages installing SGML or XML data</h3></div></div></div>
1.75 rillig 7850: <p>If a package installs SGML or XML data files that need to be
7851: registered in system-wide catalogs (like DTDs, sub-catalogs,
7852: etc.), you need to take some extra steps:
7853: </p>
7854: <div class="orderedlist"><ol type="1">
7855: <li><p>Include
1.76 rillig 7856: <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
7857: your <code class="filename">Makefile</code>, which takes care of
1.75 rillig 7858: registering those files in system-wide catalogs at
7859: installation and deinstallation time.</p></li>
7860: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
7861: any SGML catalogs installed by the package.</p></li>
7862: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
7863: any XML catalogs installed by the package.</p></li>
7864: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
7865: to be added to the SGML catalog. These come in groups of
7866: three strings; see xmlcatmgr(1) for more information
7867: (specifically, arguments recognized by the 'add' action).
7868: Note that you will normally not use this variable.</p></li>
7869: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
7870: to be added to the XML catalog. These come in groups of three
7871: strings; see xmlcatmgr(1) for more information (specifically,
7872: arguments recognized by the 'add' action). Note that you will
7873: normally not use this variable.
7874: </p></li>
7875: </ol></div>
7876: </div>
7877: <div class="sect2" lang="en">
7878: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7879: <a name="mime-database"></a>17.5.14. Packages installing extensions to the MIME database</h3></div></div></div>
1.75 rillig 7880: <p>If a package provides extensions to the MIME database by
1.76 rillig 7881: installing <code class="filename">.xml</code> files inside
7882: <code class="filename">${PREFIX}/share/mime/packages</code>, you
1.75 rillig 7883: need to take some extra steps to ensure that the database is kept
7884: consistent with respect to these new files:
7885: </p>
7886: <div class="orderedlist"><ol type="1">
7887: <li><p>Include
1.76 rillig 7888: <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
7889: (avoid using the <code class="filename">buildlink3.mk</code> file from
1.75 rillig 7890: this same directory, which is reserved for inclusion from
1.76 rillig 7891: other <code class="filename">buildlink3.mk</code> files). It takes
1.75 rillig 7892: care of rebuilding the MIME database at installation and
7893: deinstallation time, and disallows any access to it directly
7894: from the package.</p></li>
7895: <li><p>Check the PLIST and remove any entries under the
1.76 rillig 7896: <code class="filename">share/mime</code> directory,
1.75 rillig 7897: <span class="emphasis"><em>except</em></span> for files saved under
1.76 rillig 7898: <code class="filename">share/mime/packages</code>. The former are
1.75 rillig 7899: handled automatically by
7900: the update-mime-database program, but the latter are
7901: package-dependent and must be removed by the package that
7902: installed them in the first place.</p></li>
1.76 rillig 7903: <li><p>Remove any <code class="filename">share/mime/*</code> directories
1.75 rillig 7904: from the PLIST. They will be handled by the shared-mime-info
7905: package.</p></li>
7906: </ol></div>
7907: </div>
7908: <div class="sect2" lang="en">
7909: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7910: <a name="intltool"></a>17.5.15. Packages using intltool</h3></div></div></div>
1.75 rillig 7911: <p>If a package uses intltool during its build, include the
1.76 rillig 7912: <code class="filename">../../textproc/intltool/buildlink3.mk</code> file,
1.75 rillig 7913: which forces it to use the intltool package provided by pkgsrc,
7914: instead of the one bundled with the distribution file.
7915: </p>
7916: <p>This tracks intltool's build-time dependencies and uses the
7917: latest available version; this way, the package benefits of any
7918: bug fixes that may have appeared since it was released.
7919: </p>
7920: </div>
7921: <div class="sect2" lang="en">
7922: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7923: <a name="startup-scripts"></a>17.5.16. Packages installing startup scripts</h3></div></div></div>
1.75 rillig 7924: <p>If a package contains a rc.d script, it won't be copied into
7925: the startup directory by default, but you can enable it, by adding
7926: the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
1.76 rillig 7927: <code class="filename">/etc/mk.conf</code>. This option will copy the scripts
7928: into <code class="filename">/etc/rc.d</code> when a package is installed, and
1.75 rillig 7929: it will automatically remove the scripts when the package is
7930: deinstalled.</p>
7931: </div>
7932: <div class="sect2" lang="en">
7933: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7934: <a name="tex-packages"></a>17.5.17. Packages installing TeX modules</h3></div></div></div>
1.75 rillig 7935: <p>If a package installs TeX packages into the texmf tree,
1.76 rillig 7936: the <code class="filename">ls-R</code> database of the tree needs to be
1.75 rillig 7937: updated.</p>
7938: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7939: <h3 class="title">Note</h3>
7940: <p>Except the main TeX packages such as teTeX-texmf,
7941: packages should install files
7942: into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
7943: not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
7944: </div>
7945: <div class="orderedlist"><ol type="1">
7946: <li><p>Include
1.76 rillig 7947: <code class="filename">../../print/teTeX/module.mk</code> instead
7948: of <code class="filename">../../mk/tex.buildlink3.mk</code>. This
7949: takes care of rebuilding the <code class="filename">ls-R</code>
1.75 rillig 7950: database at installation and deinstallation time.</p></li>
7951: <li>
7952: <p>If your package installs files into a texmf
7953: tree other than the one
7954: at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
7955: set <code class="varname">TEXMFDIRS</code> to the list of all texmf
7956: trees that need database update.</p>
7957: <p>If your package also installs font map files that need
7958: to be registered using <span><strong class="command">updmap</strong></span>,
7959: set <code class="varname">TEX_FONTMAPS</code> to the list of all
7960: such font map files. Then <span><strong class="command">updmap</strong></span> will
7961: be run automatically at installation/deinstallation to
7962: enable/disable font map files for TeX output
7963: drivers.</p>
7964: </li>
1.76 rillig 7965: <li><p>Make sure that none of <code class="filename">ls-R</code>
7966: databases are included in <code class="filename">PLIST</code>, as
1.75 rillig 7967: they will be removed only by the teTeX-bin package.</p></li>
7968: </ol></div>
7969: </div>
7970: </div>
7971: <div class="sect1" lang="en">
7972: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 7973: <a name="feedback-to-author"></a>17.6. Feedback to the author</h2></div></div></div>
1.75 rillig 7974: <p>If you have found any bugs in the package you make available,
7975: if you had to do special steps to make it run under NetBSD or
7976: if you enhanced the software in various other ways, be sure
7977: to report these changes back to the original author of the
7978: program! With that kind of support, the next release of the
7979: program can incorporate these fixes, and people not using the
7980: NetBSD packages system can win from your efforts.</p>
7981: <p>Support the idea of free software!</p>
7982: </div>
7983: </div>
7984: <div class="chapter" lang="en">
7985: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 7986: <a name="debug"></a>Chapter 18. Debugging</h2></div></div></div>
1.75 rillig 7987: <p>To check out all the gotchas when building a package, here are the steps
7988: that I do in order to get a package working. Please note this is basically
7989: the same as what was explained in the previous sections, only with some
7990: debugging aids.</p>
7991: <div class="itemizedlist"><ul type="disc">
7992: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=1</code>
1.76 rillig 7993: in <code class="filename">/etc/mk.conf</code></p></li>
1.75 rillig 7994: <li>
1.76 rillig 7995: <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 7996: create a directory for a new package, change into it, then run
7997: <span><strong class="command">url2pkg</strong></span>:</p>
7998: <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>
7999: <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>
8000: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
8001: </li>
1.76 rillig 8002: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
8003: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.75 rillig 8004: <li><p>Run <span><strong class="command">make configure</strong></span>
8005: </p></li>
8006: <li><p>Add any dependencies glimpsed from documentation and the
8007: configure step to the package's
1.76 rillig 8008: <code class="filename">Makefile</code>.</p></li>
1.75 rillig 8009: <li>
8010: <p>Make the package compile, doing multiple rounds of</p>
8011: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
8012: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
8013: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
8014: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
8015: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
8016: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
8017: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
8018: <p>Doing as non-root user will ensure that no files are modified that
8019: shouldn't be, especially during the build
8020: phase. <span><strong class="command">mkpatches</strong></span>,
8021: <span><strong class="command">patchdiff</strong></span> and <span><strong class="command">pkgvi</strong></span> are
1.76 rillig 8022: 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 8023: package. </p>
8024: </li>
1.76 rillig 8025: <li><p>Look at the <code class="filename">Makefile</code>, fix if necessary;
1.77 rillig 8026: see <a href="#components.Makefile" title="9.1. Makefile">Section 9.1, “<code class="filename">Makefile</code>”</a>.</p></li>
1.75 rillig 8027: <li>
1.76 rillig 8028: <p>Generate a <code class="filename">PLIST</code>:</p>
1.75 rillig 8029: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
8030: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST >PLIST</code></strong>
8031: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
8032: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
8033: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
1.76 rillig 8034: <p>You usually need to be <code class="username">root</code> to do this.
1.75 rillig 8035: Look if there are any files left:</p>
8036: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
8037: <p>If this reveals any files that are missing in
1.76 rillig 8038: <code class="filename">PLIST</code>, add them.</p>
1.75 rillig 8039: </li>
8040: <li>
1.76 rillig 8041: <p>Now that the <code class="filename">PLIST</code> is OK,
1.75 rillig 8042: install the package again and make a binary package:</p>
8043: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
8044: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
8045: </li>
8046: <li>
8047: <p>Delete the installed package:</p>
8048: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete blub</code></strong></pre>
8049: </li>
8050: <li>
8051: <p>Repeat the above <span><strong class="command">make print-PLIST</strong></span> command,
8052: which shouldn't find anything now:</p>
8053: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
8054: </li>
8055: <li>
8056: <p>Reinstall the binary package:</p>
8057: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkgadd .../blub.tgz</code></strong></pre>
8058: </li>
8059: <li><p>Play with it. Make sure everything works.</p></li>
8060: <li>
8061: <p>Run <span><strong class="command">pkglint</strong></span> from
1.76 rillig 8062: <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 8063: and fix the problems it reports:</p>
8064: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
8065: </li>
8066: <li><p>Submit (or commit, if you have cvs access);
1.77 rillig 8067: see <a href="#submit" title="Chapter 19. Submitting and Committing">Chapter 19, <i>Submitting and Committing</i></a>.</p></li>
1.75 rillig 8068: </ul></div>
8069: </div>
8070: <div class="chapter" lang="en">
8071: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8072: <a name="submit"></a>Chapter 19. Submitting and Committing</h2></div></div></div>
1.75 rillig 8073: <div class="toc">
8074: <p><b>Table of Contents</b></p>
8075: <dl>
1.77 rillig 8076: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
8077: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
8078: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
8079: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
8080: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
8081: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 8082: </dl>
8083: </div>
8084: <div class="sect1" lang="en">
8085: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8086: <a name="submitting-binary-packages"></a>19.1. Submitting binary packages</h2></div></div></div>
1.75 rillig 8087: <p>Our policy is that we accept binaries only from pkgsrc
8088: developers to guarantee that the packages don't contain any
8089: trojan horses etc. This is not to annoy anyone but rather to
8090: protect our users! You're still free to put up your home-made
8091: binary packages and tell the world where to get them. NetBSD
8092: developers doing bulk builds and wanting to upload them please
8093: 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>
8094: </div>
8095: <div class="sect1" lang="en">
8096: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8097: <a name="submitting-your-package"></a>19.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
1.75 rillig 8098: <p>First, check that your package is complete, compiles and
1.77 rillig 8099: runs well; see <a href="#debug" title="Chapter 18. Debugging">Chapter 18, <i>Debugging</i></a> and the rest of this
1.75 rillig 8100: 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>
1.82 ! rillig 8101: archive that contains all files that make up the package.
1.75 rillig 8102: Finally, <span><strong class="command">send-pr</strong></span> with category
8103: “<span class="quote">pkg</span>”, a synopsis which includes the package name
8104: and version number, a short description of your package
8105: (contents of the COMMENT variable or DESCR file are OK) and
8106: attach the archive to your PR.</p>
8107: <p>If you want to submit several packages, please send a
8108: separate PR for each one, it's easier for us to track things
8109: that way.</p>
8110: <p>Alternatively, you can also import new packages into
8111: pkgsrc-wip (“<span class="quote">pkgsrc work-in-progress</span>”); see the
8112: homepage at <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
8113: for details.</p>
8114: </div>
8115: <div class="sect1" lang="en">
8116: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8117: <a name="general-notes-for-changes"></a>19.3. General notes when adding, updating, or removing packages</h2></div></div></div>
1.75 rillig 8118: <p>Please note all package additions, updates, moves, and
1.76 rillig 8119: removals in <code class="filename">pkgsrc/doc/CHANGES</code>. It's very
1.75 rillig 8120: important to keep this file up to date and conforming to the
8121: existing format, because it will be used by scripts to
8122: automatically update pages on <a href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
8123: sites. Additionally, check the
1.76 rillig 8124: <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
1.75 rillig 8125: for the package you updated or removed, in case it was mentioned
8126: there.</p>
8127: <p>When the <code class="varname">PKGREVISION</code> of a package is
8128: bumped, the change should appear in
1.76 rillig 8129: <code class="filename">pkgsrc/doc/CHANGES</code> if it is security
1.75 rillig 8130: related or otherwise relevant. Mass bumps that result from a
8131: dependency being updated should not be mentioned. In all other
8132: cases it's the developer's decision.</p>
8133: <p>There is a make target that helps in creating proper
1.76 rillig 8134: <code class="filename">CHANGES</code> entries: <span><strong class="command">make
1.75 rillig 8135: changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
8136: and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
1.76 rillig 8137: usage is to first make sure that your <code class="filename">CHANGES</code>
1.75 rillig 8138: file is up-to-date (to avoid having to resolve conflicts later-on)
8139: and then to <span><strong class="command">cd</strong></span> to the package directory. For
8140: package updates, <span><strong class="command">make changes-entry</strong></span> is enough.
8141: For new packages, or package moves or removals, set the
8142: <code class="varname">CTYPE</code> variable on the command line to "Added",
8143: "Moved", or "Removed". You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.76 rillig 8144: in <code class="filename">/etc/mk.conf</code> if your local login name is
1.75 rillig 8145: not the same as your NetBSD login name. Don't forget to commit
1.76 rillig 8146: the changes to <code class="filename">pkgsrc/doc/CHANGES</code>!</p>
1.75 rillig 8147: </div>
8148: <div class="sect1" lang="en">
8149: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8150: <a name="committing-importing"></a>19.4. Committing: Importing a package into CVS</h2></div></div></div>
1.75 rillig 8151: <p>
8152: This section is only of interest for pkgsrc developers with write
8153: access to the pkgsrc repository. Please remember that cvs
8154: imports files relative to the current working directory, and that
8155: the pathname that you
8156: give the <span><strong class="command">cvs import</strong></span> command is so that it knows where
8157: to place the files in the repository. Newly created packages should be
8158: imported with a vendor tag of “<span class="quote">TNF</span>” and a release tag of
8159: “<span class="quote">pkgsrc-base</span>”, e.g:
8160: </p>
8161: <pre class="programlisting">
8162: <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
8163: <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
8164: </pre>
8165: <p>
8166: Remember to move the directory from which you imported out of
8167: the way, or cvs will complain the next time you “<span class="quote">cvs
8168: update</span>” your source tree. Also don't forget to add the new
1.76 rillig 8169: package to the category's <code class="filename">Makefile</code>.
1.75 rillig 8170: </p>
8171: <p>
8172: The commit message of the initial import should include part of the
1.76 rillig 8173: <code class="filename">DESCR</code> file, so people reading the mailing lists know
1.75 rillig 8174: what the package is/does.
8175: </p>
8176: <p>
8177: For new packages, “<span class="quote">cvs import</span>” is preferred to “<span class="quote">cvs
8178: add</span>” because the former gets everything with a single command,
8179: and provides a consistent tag.
8180: </p>
8181: </div>
8182: <div class="sect1" lang="en">
8183: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8184: <a name="updating-package"></a>19.5. Updating a package to a newer version</h2></div></div></div>
1.75 rillig 8185: <p>
8186: Please always put a concise, appropriate and relevant summary of the
8187: changes between old and new versions into the commit log when updating
8188: a package. There are various reasons for this:
8189: </p>
8190: <div class="itemizedlist"><ul type="disc">
8191: <li><p>
8192: A URL is volatile, and can change over time. It may go away completely
8193: or its information may be overwritten by newer information.
8194: </p></li>
8195: <li><p>
8196: Having the change information between old and new versions in our CVS
8197: repository is very useful for people who use either cvs or anoncvs.
8198: </p></li>
8199: <li><p>
8200: Having the change information between old and new versions in our CVS
8201: repository is very useful for people who read the pkgsrc-changes mailing
8202: list, so that they can make tactical decisions about when to upgrade
8203: the package.
8204: </p></li>
8205: </ul></div>
8206: <p>
8207: Please also recognize that, just because a new version of a package
8208: has been released, it should not automatically be upgraded in the CVS
8209: repository. We prefer to be conservative in the packages that are
8210: included in pkgsrc - development or beta packages are not really the
8211: best thing for most places in which pkgsrc is used. Please use your
8212: judgement about what should go into pkgsrc, and bear in mind that
8213: stability is to be preferred above new and possibly untested features.
8214: </p>
8215: </div>
8216: <div class="sect1" lang="en">
8217: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8218: <a name="moving-package"></a>19.6. Moving a package in pkgsrc</h2></div></div></div>
1.75 rillig 8219: <div class="orderedlist"><ol type="1">
8220: <li><p>Make a copy of the directory somewhere else.</p></li>
8221: <li>
8222: <p>Remove all CVS dirs.</p>
8223: <p>
8224: Alternatively to the first two steps you can also do:
8225: </p>
8226: <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>
8227: <p>
8228: and use that for further work.
8229: </p>
8230: </li>
8231: <li><p>Fix <code class="varname">CATEGORIES</code> and any
8232: <code class="varname">DEPENDS</code> paths that just did “<span class="quote">../package</span>”
8233: instead of “<span class="quote">../../category/package</span>”.</p></li>
8234: <li><p><span><strong class="command">cvs import</strong></span> the modified package in the new
8235: place.</p></li>
8236: <li>
8237: <p>Check if any package depends on it:
8238: </p>
8239: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
8240: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
8241: <p>
8242: </p>
8243: </li>
8244: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
8245: <li><p><span><strong class="command">cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.76 rillig 8246: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
8247: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
1.75 rillig 8248: <li>
8249: <p>Commit the changed and removed files:</p>
8250: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong></pre>
8251: <p>
8252: (and any packages from step 5, of course).
8253: </p>
8254: </li>
8255: </ol></div>
8256: </div>
8257: </div>
8258: <div class="chapter" lang="en">
8259: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8260: <a name="devfaq"></a>Chapter 20. Frequently Asked Questions</h2></div></div></div>
1.75 rillig 8261: <p>This section contains the answers to questions that may
8262: arise when you are writing a package. If you don't find your
8263: question answered here, first have a look in the other chapters,
8264: and if you still don't have the answer, ask on the
8265: <code class="literal">pkgsrc-users</code> mailing list.</p>
8266: <div class="qandaset">
8267: <dl>
1.82 ! rillig 8268: <dt>20.1. <a href="#id2656363">What is the difference between
1.75 rillig 8269: MAKEFLAGS, .MAKEFLAGS and
8270: MAKE_FLAGS?</a>
8271: </dt>
1.82 ! rillig 8272: <dt>20.2. <a href="#id2656400">What is the difference between
1.75 rillig 8273: MAKE, GMAKE and
8274: MAKE_PROGRAM?</a>
8275: </dt>
1.82 ! rillig 8276: <dt>20.3. <a href="#id2656438">What is the difference between
1.75 rillig 8277: CC, PKG_CC and
8278: PKGSRC_COMPILER?</a>
8279: </dt>
1.82 ! rillig 8280: <dt>20.4. <a href="#id2656475">What is the difference between
1.75 rillig 8281: BUILDLINK_LDFLAGS,
8282: BUILDLINK_LDADD and
8283: BUILDLINK_LIBS?</a>
8284: </dt>
1.82 ! rillig 8285: <dt>20.5. <a href="#id2656493">Why does make show-var
1.75 rillig 8286: VARNAME=BUILDLINK_PREFIX.foo
8287: say it's empty?</a>
8288: </dt>
1.82 ! rillig 8289: <dt>20.6. <a href="#id2656521">What does
1.78 rillig 8290: ${MASTER_SITE_SOURCEFORGE:=package/} mean? I
8291: don't understand the := inside
8292: it.</a>
8293: </dt>
1.82 ! rillig 8294: <dt>20.7. <a href="#id2656664">Which mailing lists are there for package
1.78 rillig 8295: developers?</a>
8296: </dt>
1.82 ! rillig 8297: <dt>20.8. <a href="#id2656837">Where is the pkgsrc
1.80 rillig 8298: documentation?</a>
8299: </dt>
1.75 rillig 8300: </dl>
8301: <table border="0" summary="Q and A Set">
8302: <col align="left" width="1%">
8303: <tbody>
8304: <tr class="question">
8305: <td align="left" valign="top">
1.82 ! rillig 8306: <a name="id2656363"></a><a name="id2656364"></a><b>20.1.</b>
1.75 rillig 8307: </td>
8308: <td align="left" valign="top"><p>What is the difference between
8309: <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
8310: <code class="varname">MAKE_FLAGS</code>?</p></td>
8311: </tr>
8312: <tr class="answer">
8313: <td align="left" valign="top"><b></b></td>
8314: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
8315: 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
8316: <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
8317: the <code class="varname">MAKE_PROGRAM</code> when building the
8318: package. [FIXME: What is .MAKEFLAGS for?]</p></td>
8319: </tr>
8320: <tr class="question">
8321: <td align="left" valign="top">
1.82 ! rillig 8322: <a name="id2656400"></a><a name="id2656401"></a><b>20.2.</b>
1.75 rillig 8323: </td>
8324: <td align="left" valign="top"><p>What is the difference between
8325: <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
8326: <code class="varname">MAKE_PROGRAM</code>?</p></td>
8327: </tr>
8328: <tr class="answer">
8329: <td align="left" valign="top"><b></b></td>
8330: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
8331: <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
8332: infrastructure. <code class="varname">GMAKE</code> is the path to GNU
8333: Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
8334: use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
8335: Make program that is used for building the
8336: package.</p></td>
8337: </tr>
8338: <tr class="question">
8339: <td align="left" valign="top">
1.82 ! rillig 8340: <a name="id2656438"></a><a name="id2656439"></a><b>20.3.</b>
1.75 rillig 8341: </td>
8342: <td align="left" valign="top"><p>What is the difference between
8343: <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
8344: <code class="varname">PKGSRC_COMPILER</code>?</p></td>
8345: </tr>
8346: <tr class="answer">
8347: <td align="left" valign="top"><b></b></td>
8348: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
8349: compiler, which can be configured by the pkgsrc user.
8350: <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
8351: <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
8352: path to a compiler, but the type of compiler that should be
1.76 rillig 8353: used. See <code class="filename">mk/compiler.mk</code> for more
1.75 rillig 8354: information about the latter variable.</p></td>
8355: </tr>
8356: <tr class="question">
8357: <td align="left" valign="top">
1.82 ! rillig 8358: <a name="id2656475"></a><a name="id2656476"></a><b>20.4.</b>
1.75 rillig 8359: </td>
8360: <td align="left" valign="top"><p>What is the difference between
8361: <code class="varname">BUILDLINK_LDFLAGS</code>,
8362: <code class="varname">BUILDLINK_LDADD</code> and
8363: <code class="varname">BUILDLINK_LIBS</code>?</p></td>
8364: </tr>
8365: <tr class="answer">
8366: <td align="left" valign="top"><b></b></td>
8367: <td align="left" valign="top"><p>[FIXME]</p></td>
8368: </tr>
8369: <tr class="question">
8370: <td align="left" valign="top">
1.82 ! rillig 8371: <a name="id2656493"></a><a name="id2656494"></a><b>20.5.</b>
1.75 rillig 8372: </td>
8373: <td align="left" valign="top"><p>Why does <span><strong class="command">make show-var
8374: VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
8375: say it's empty?</p></td>
8376: </tr>
8377: <tr class="answer">
8378: <td align="left" valign="top"><b></b></td>
8379: <td align="left" valign="top"><p>For optimization reasons, some variables are only
8380: available in the “<span class="quote">wrapper</span>” phase and later. To
8381: “<span class="quote">simulate</span>” the wrapper phase, append
8382: <span><strong class="command">PKG_PHASE=wrapper</strong></span> to the above
8383: command.</p></td>
8384: </tr>
1.78 rillig 8385: <tr class="question">
8386: <td align="left" valign="top">
1.82 ! rillig 8387: <a name="id2656521"></a><a name="id2656522"></a><b>20.6.</b>
1.78 rillig 8388: </td>
8389: <td align="left" valign="top"><p>What does
8390: <code class="literal">${MASTER_SITE_SOURCEFORGE:=package/}</code> mean? I
8391: don't understand the <code class="literal">:=</code> inside
8392: it.</p></td>
8393: </tr>
8394: <tr class="answer">
8395: <td align="left" valign="top"><b></b></td>
8396: <td align="left" valign="top"><p>The <code class="literal">:=</code> is not really an
8397: assignment operator, like you might expect at first sight.
8398: Instead, it is a degenerate form of
8399: <code class="literal">${LIST:<em class="replaceable"><code>old_string</code></em>=<em class="replaceable"><code>new_string</code></em>}</code>,
8400: 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
8401: may have seen as in <code class="literal">${SRCS:.c=.o}</code>. In the
8402: case of <code class="varname">MASTER_SITE_*</code>,
8403: <em class="replaceable"><code>old_string</code></em> is the empty string and
8404: <em class="replaceable"><code>new_string</code></em> is
8405: <code class="literal">package/</code>. That's where the
8406: <code class="literal">:</code> and the <code class="literal">=</code> fall
8407: together.</p></td>
8408: </tr>
8409: <tr class="question">
8410: <td align="left" valign="top">
1.82 ! rillig 8411: <a name="id2656664"></a><a name="id2656802"></a><b>20.7.</b>
1.78 rillig 8412: </td>
8413: <td align="left" valign="top"><p>Which mailing lists are there for package
8414: developers?</p></td>
8415: </tr>
8416: <tr class="answer">
8417: <td align="left" valign="top"><b></b></td>
8418: <td align="left" valign="top"><div class="variablelist"><dl>
8419: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">tech-pkg</a></span></dt>
8420: <dd><p>This is a list for technical discussions related
8421: to pkgsrc development, e.g. soliciting feedback for changes to
8422: pkgsrc infrastructure, proposed new features, questions related
8423: to porting pkgsrc to a new platform, advice for maintaining a
8424: package, patches that affect many packages, help requests moved
8425: from pkgsrc-users when an infrastructure bug is found,
8426: etc.</p></dd>
8427: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a></span></dt>
8428: <dd><p>All bug reports in category "pkg" sent with
8429: <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
8430: directly; use one of the other mailing
8431: lists.</p></dd>
8432: </dl></div></td>
8433: </tr>
1.80 rillig 8434: <tr class="question">
8435: <td align="left" valign="top">
1.82 ! rillig 8436: <a name="id2656837"></a><a name="id2656838"></a><b>20.8.</b>
1.80 rillig 8437: </td>
8438: <td align="left" valign="top"><p>Where is the pkgsrc
8439: documentation?</p></td>
8440: </tr>
8441: <tr class="answer">
8442: <td align="left" valign="top"><b></b></td>
8443: <td align="left" valign="top">
8444: <p>There are many places where you can find
8445: documentation about pkgsrc:</p>
8446: <div class="itemizedlist"><ul type="disc">
8447: <li><p>The pkgsrc guide (this document) is a collection
8448: of chapters that explain large parts of pkgsrc, but some
8449: chapters tend to be outdated. Which ones they are is hard to
8450: say.</p></li>
8451: <li><p>On the mailing list archives (see <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>), you can find discussions
8452: about certain features, announcements of new parts of the pkgsrc
8453: infrastructure and sometimes even announcements that a certain
8454: feature has been marked as obsolete. The benefit here is that
8455: each message has a date appended to it.</p></li>
8456: <li><p>Many of the files in the
8457: <code class="filename">mk/</code> directory start with a comment that
8458: describes the purpose of the file and how it can be used by the
8459: pkgsrc user and package authors.</p></li>
8460: <li><p>The CVS log messages are a rich source of
8461: information, but they tend to be highly abbreviated, especially
8462: for actions that occur often. Some contain a detailed
8463: description of what has changed, but they are geared towards the
8464: other pkgsrc developers, not towards an average pkgsrc user.
8465: They also only document <span class="emphasis"><em>changes</em></span>, so if you
8466: don't know what has been before, these messages may not be worth
8467: too much to you.</p></li>
8468: <li><p>Some parts of pkgsrc are only “<span class="quote">implicitly
8469: documented</span>”, that is the documentation exists only in the
8470: mind of the developer who wrote the code. To get this
8471: information, use the the <span><strong class="command">cvs annotate</strong></span> command
8472: to see who has written it and ask on the
8473: <code class="literal">tech-pkg</code> mailing list, so that others can
8474: find your questions later (see above). To be sure that the
8475: developer in charge reads the mail, you may CC him or
8476: her.</p></li>
8477: </ul></div>
8478: </td>
8479: </tr>
1.75 rillig 8480: </tbody>
8481: </table>
8482: </div>
8483: </div>
8484: </div>
8485: <div class="part" lang="en">
8486: <div class="titlepage"><div><div><h1 class="title">
8487: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
8488: <div class="partintro" lang="en">
8489: <div></div>
8490: <p>This part of the guide deals with everything
8491: from the infrastructure that is behind the interfaces described
8492: in the developer's guide. A casual package maintainer should not
8493: need anything from this part.</p>
8494: <div class="toc">
8495: <p><b>Table of Contents</b></p>
8496: <dl>
1.77 rillig 8497: <dt><span class="chapter"><a href="#infr.design">21. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 8498: <dd><dl>
1.81 rillig 8499: <dt><span class="sect1"><a href="#infr.vardef">21.1. The meaning of variable definitions</a></span></dt>
8500: <dt><span class="sect1"><a href="#infr.vardef.problems">21.2. Avoiding problems before they arise</a></span></dt>
8501: <dt><span class="sect1"><a href="#infr.var">21.3. Variable evaluation</a></span></dt>
1.75 rillig 8502: <dd><dl>
1.81 rillig 8503: <dt><span class="sect2"><a href="#infr.var.load">21.3.1. At load time</a></span></dt>
8504: <dt><span class="sect2"><a href="#infr.var.run">21.3.2. At runtime</a></span></dt>
1.75 rillig 8505: </dl></dd>
1.81 rillig 8506: <dt><span class="sect1"><a href="#infr.varspec">21.4. How can variables be specified?</a></span></dt>
8507: <dt><span class="sect1"><a href="#infr.design.intf">21.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 8508: <dd><dl>
1.81 rillig 8509: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.5.1. Procedures with parameters</a></span></dt>
8510: <dt><span class="sect2"><a href="#infr.design.intf.action">21.5.2. Actions taken on behalf of parameters</a></span></dt>
8511: </dl></dd>
8512: <dt><span class="sect1"><a href="#infr.order">21.6. The order in which files are loaded</a></span></dt>
8513: <dd><dl>
8514: <dt><span class="sect2"><a href="#infr.order.prefs">21.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
8515: <dt><span class="sect2"><a href="#infr.order.pkg">21.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75 rillig 8516: </dl></dd>
8517: </dl></dd>
1.77 rillig 8518: <dt><span class="chapter"><a href="#regression">22. Regression tests</a></span></dt>
1.75 rillig 8519: <dd><dl>
1.77 rillig 8520: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
8521: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
8522: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 8523: <dd><dl>
1.77 rillig 8524: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
8525: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 8526: </dl></dd>
8527: </dl></dd>
1.80 rillig 8528: <dt><span class="chapter"><a href="#porting">23. Porting pkgsrc</a></span></dt>
1.75 rillig 8529: <dd><dl>
1.80 rillig 8530: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
8531: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 8532: </dl></dd>
8533: </dl>
8534: </div>
8535: </div>
8536: <div class="chapter" lang="en">
8537: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8538: <a name="infr.design"></a>Chapter 21. Design of the pkgsrc infrastructure</h2></div></div></div>
1.75 rillig 8539: <div class="toc">
8540: <p><b>Table of Contents</b></p>
8541: <dl>
1.81 rillig 8542: <dt><span class="sect1"><a href="#infr.vardef">21.1. The meaning of variable definitions</a></span></dt>
8543: <dt><span class="sect1"><a href="#infr.vardef.problems">21.2. Avoiding problems before they arise</a></span></dt>
8544: <dt><span class="sect1"><a href="#infr.var">21.3. Variable evaluation</a></span></dt>
8545: <dd><dl>
8546: <dt><span class="sect2"><a href="#infr.var.load">21.3.1. At load time</a></span></dt>
8547: <dt><span class="sect2"><a href="#infr.var.run">21.3.2. At runtime</a></span></dt>
8548: </dl></dd>
8549: <dt><span class="sect1"><a href="#infr.varspec">21.4. How can variables be specified?</a></span></dt>
8550: <dt><span class="sect1"><a href="#infr.design.intf">21.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 8551: <dd><dl>
1.81 rillig 8552: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.5.1. Procedures with parameters</a></span></dt>
8553: <dt><span class="sect2"><a href="#infr.design.intf.action">21.5.2. Actions taken on behalf of parameters</a></span></dt>
1.75 rillig 8554: </dl></dd>
1.81 rillig 8555: <dt><span class="sect1"><a href="#infr.order">21.6. The order in which files are loaded</a></span></dt>
1.75 rillig 8556: <dd><dl>
1.81 rillig 8557: <dt><span class="sect2"><a href="#infr.order.prefs">21.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
8558: <dt><span class="sect2"><a href="#infr.order.pkg">21.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75 rillig 8559: </dl></dd>
8560: </dl>
8561: </div>
8562: <p>The pkgsrc infrastructure consists of many small Makefile
8563: fragments. Each such fragment needs a properly specified
8564: interface. This chapter explains how such an interface looks
8565: like.</p>
8566: <div class="sect1" lang="en">
8567: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.81 rillig 8568: <a name="infr.vardef"></a>21.1. The meaning of variable definitions</h2></div></div></div>
8569: <p>Whenever a variable is defined in the pkgsrc
8570: infrastructure, the location and the way of definition provide
8571: much information about the intended use of that variable.
8572: Additionally, more documentation may be found in a header
8573: comment or in this pkgsrc guide.</p>
8574: <p>A special file is
8575: <code class="filename">mk/defaults/mk.conf</code>, which lists all
8576: variables that are intended to be user-defined. They are either
8577: defined using the <code class="literal">?=</code> operator or they are
8578: left undefined because defining them to anything would
8579: effectively mean “<span class="quote">yes</span>”. All these variables may be
8580: overridden by the pkgsrc user in the <code class="varname">MAKECONF</code>
8581: file.</p>
8582: <p>Outside this file, the following conventions apply:
8583: Variables that are defined using the <code class="literal">?=</code>
8584: operator may be overridden by a package.</p>
8585: <p>Variables that are defined using the <code class="literal">=</code>
8586: operator may be used read-only at run-time.</p>
8587: <p>Variables whose name starts with an underscore must not be
8588: accessed outside the pkgsrc infrastructure at all. They may
8589: change without further notice.</p>
8590: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
8591: <h3 class="title">Note</h3>
8592: <p>These conventions are currently not applied
8593: consistently to the complete pkgsrc
8594: infrastructure.</p>
8595: </div>
8596: </div>
8597: <div class="sect1" lang="en">
8598: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8599: <a name="infr.vardef.problems"></a>21.2. Avoiding problems before they arise</h2></div></div></div>
8600: <p>All variables that contain lists of things should default
8601: to being empty. Two examples that do not follow this rule are
8602: <code class="varname">USE_LANGUAGES</code> and
8603: <code class="varname">DISTFILES</code>. These variables cannot simply be
8604: modified using the <code class="literal">+=</code> operator in package
8605: <code class="filename">Makefile</code>s (or other files included by
8606: them), since there is no guarantee whether the variable is
8607: already set or not, and what its value is. In the case of
8608: <code class="varname">DISTFILES</code>, the packages “<span class="quote">know</span>”
8609: the default value and just define it as in the following
8610: example.</p>
8611: <pre class="programlisting">
8612: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
8613: </pre>
8614: <p>Because of the selection of this default value, the same
8615: value appears in many package Makefiles. Similarly for
8616: <code class="varname">USE_LANGUAGES</code>, but in this case the default
8617: value (“<span class="quote"><code class="literal">c</code></span>”) is so short that it
8618: doesn't stand out. Nevertheless it is mentioned in many
8619: files.</p>
8620: </div>
8621: <div class="sect1" lang="en">
8622: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8623: <a name="infr.var"></a>21.3. Variable evaluation</h2></div></div></div>
1.75 rillig 8624: <div class="sect2" lang="en">
8625: <div class="titlepage"><div><div><h3 class="title">
1.81 rillig 8626: <a name="infr.var.load"></a>21.3.1. At load time</h3></div></div></div>
1.75 rillig 8627: <p>Variable evaluation takes place either at load time or at
8628: runtime, depending on the context in which they occur. The
8629: contexts where variables are evaluated at load time are:</p>
8630: <div class="itemizedlist"><ul type="disc">
8631: <li><p>The right hand side of the <code class="literal">:=</code>
8632: and <code class="literal">!=</code> operators,</p></li>
8633: <li><p>Make directives like <code class="literal">.if</code> or
8634: <code class="literal">.for</code>,</p></li>
8635: <li><p>Dependency lines.</p></li>
8636: </ul></div>
8637: <p>A special exception are references to the iteration
8638: variables of <code class="literal">.for</code> loops, which are expanded
8639: inline, no matter in which context they appear.</p>
8640: <p>As the values of variables may change during load time,
8641: care must be taken not to evaluate them by accident. Typical
8642: examples for variables that should not be evaluated at load time
8643: are <code class="varname">DEPENDS</code> and
8644: <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
8645: clear, here is an example:</p>
8646: <pre class="programlisting">
8647: CONFIGURE_ARGS= # none
8648: CFLAGS= -O
8649: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
1.1 grant 8650:
1.75 rillig 8651: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
1.1 grant 8652:
1.75 rillig 8653: CFLAGS+= -Wall
8654: </pre>
8655: <p>This code shows how the use of the <code class="literal">:=</code>
8656: operator can quickly lead to unexpected results. The first
8657: paragraph is fairly common code. The second paragraph evaluates
8658: the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
8659: <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
8660: <code class="literal">-Wall</code> is appended to the
8661: <code class="varname">CFLAGS</code>, but this addition will not appear in
8662: <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
8663: paragraphs from above typically occur in completely unrelated
8664: files.</p>
8665: </div>
8666: <div class="sect2" lang="en">
8667: <div class="titlepage"><div><div><h3 class="title">
1.81 rillig 8668: <a name="infr.var.run"></a>21.3.2. At runtime</h3></div></div></div>
1.75 rillig 8669: <p>After all the files have been loaded, the values of the
8670: variables cannot be changed anymore. Variables that are used in
8671: the shell commands are expanded at this point.</p>
8672: </div>
8673: </div>
8674: <div class="sect1" lang="en">
8675: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.81 rillig 8676: <a name="infr.varspec"></a>21.4. How can variables be specified?</h2></div></div></div>
1.78 rillig 8677: <p>There are many ways in which the definition and use of a
8678: variable can be restricted in order to detect bugs and
8679: violations of the (mostly unwritten) policies. See the
8680: <code class="literal">pkglint</code> developer's documentation for further
8681: details.</p>
8682: </div>
8683: <div class="sect1" lang="en">
8684: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.81 rillig 8685: <a name="infr.design.intf"></a>21.5. Designing interfaces for Makefile fragments</h2></div></div></div>
1.76 rillig 8686: <p>Most of the <code class="filename">.mk</code> files fall into one
1.75 rillig 8687: of the following classes. Cases where a file falls into more
8688: than one class should be avoided as it often leads to subtle
8689: bugs.</p>
8690: <div class="sect2" lang="en">
8691: <div class="titlepage"><div><div><h3 class="title">
1.81 rillig 8692: <a name="infr.design.intf.proc"></a>21.5.1. Procedures with parameters</h3></div></div></div>
1.75 rillig 8693: <p>In a traditional imperative programming language some of
1.76 rillig 8694: the <code class="filename">.mk</code> files could be described as
1.78 rillig 8695: procedures. They take some input parameters and—after
8696: inclusion—provide a result in output parameters. Since all
1.76 rillig 8697: variables in <code class="filename">Makefile</code>s have global scope
1.75 rillig 8698: care must be taken not to use parameter names that have already
8699: another meaning. For example, <code class="varname">PKGNAME</code> is a
8700: bad choice for a parameter name.</p>
8701: <p>Procedures are completely evaluated at preprocessing time.
8702: That is, when calling a procedure all input parameters must be
8703: completely resolvable. For example,
8704: <code class="varname">CONFIGURE_ARGS</code> should never be an input
8705: parameter since it is very likely that further text will be
8706: added after calling the procedure, which would effectively apply
8707: the procedure to only a part of the variable. Also, references
8708: to other variables wit will be modified after calling the
8709: procedure.</p>
8710: <p>A procedure can declare its output parameters either as
8711: suitable for use in preprocessing directives or as only
8712: available at runtime. The latter alternative is for variables
8713: that contain references to other runtime variables.</p>
8714: <p>Procedures shall be written such that it is possible to
8715: call the procedure more than once. That is, the file must not
8716: contain multiple-inclusion guards.</p>
8717: <p>Examples for procedures are
1.76 rillig 8718: <code class="filename">mk/bsd.options.mk</code> and
8719: <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
1.75 rillig 8720: that the parameters are evaluated at load time, they should be
8721: assigned using the <code class="literal">:=</code> operator, which should
8722: be used only for this purpose.</p>
8723: </div>
8724: <div class="sect2" lang="en">
8725: <div class="titlepage"><div><div><h3 class="title">
1.81 rillig 8726: <a name="infr.design.intf.action"></a>21.5.2. Actions taken on behalf of parameters</h3></div></div></div>
1.75 rillig 8727: <p>Action files take some input parameters and may define
8728: runtime variables. They shall not define loadtime variables.
8729: There are action files that are included implicitly by the
8730: pkgsrc infrastructure, while other must be included
8731: explicitly.</p>
8732: <p>An example for action files is
1.76 rillig 8733: <code class="filename">mk/subst.mk</code>.</p>
1.75 rillig 8734: </div>
8735: </div>
1.81 rillig 8736: <div class="sect1" lang="en">
8737: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8738: <a name="infr.order"></a>21.6. The order in which files are loaded</h2></div></div></div>
8739: <p>Package <code class="filename">Makefile</code>s usually consist of
8740: a set of variable definitions, and include the file
8741: <code class="filename">../../mk/bsd.pkg.mk</code> in the very last line.
8742: Before that, they may also include various other
8743: <code class="filename">*.mk</code> files if they need to query the
8744: availability of certain features like the type of compiler or
8745: the X11 implementation. Due to the heavy use of preprocessor
8746: directives like <code class="literal">.if</code> and
8747: <code class="literal">.for</code>, the order in which the files are loaded
8748: matters.</p>
8749: <p>This section describes at which point the various files
8750: are loaded and gives reasons for that order.</p>
8751: <div class="sect2" lang="en">
8752: <div class="titlepage"><div><div><h3 class="title">
8753: <a name="infr.order.prefs"></a>21.6.1. The order in <code class="filename">bsd.prefs.mk</code></h3></div></div></div>
8754: <p>The very first action in <code class="filename">bsd.pkg.mk</code>
8755: is to define some essential variables like
8756: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code> and
8757: <code class="varname">MACHINE_ARCH</code>.</p>
8758: <p>Then, the user settings are loaded from the file specified
8759: in <code class="varname">MAKECONF</code>. If the bmake command from pkgsrc
8760: is used, <code class="varname">MAKECONF</code> defaults to
8761: <code class="filename"><em class="replaceable"><code>${prefix}</code></em>/etc/mk.conf</code>.
8762: With the native <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> command on NetBSD, it defaults to
8763: <code class="filename">/etc/mk.conf</code>. After that, those variables
8764: that have not been overridden by the user are loaded from
8765: <code class="filename">mk/defaults/mk.conf</code>.</p>
8766: <p>After the user settings, the system settings and platform
8767: settings are loaded, which may override the user
8768: settings.</p>
8769: <p>Then, the tool definitions are loaded. The tool wrappers
8770: are not yet in effect. This only happens when building a
8771: package, so the proper variables must be used instead of the
8772: direct tool names.</p>
8773: <p>As the last steps, some essential variables from the
8774: wrapper and the package system flavor are loaded, as well as the
8775: variables that have been cached in earlier phases of a package
8776: build.</p>
8777: </div>
8778: <div class="sect2" lang="en">
8779: <div class="titlepage"><div><div><h3 class="title">
8780: <a name="infr.order.pkg"></a>21.6.2. The order in <code class="filename">bsd.pkg.mk</code></h3></div></div></div>
8781: <p>First, <code class="filename">bsd.prefs.mk</code> is loaded.</p>
8782: <p>Then, the various <code class="filename">*-vars.mk</code> files are
8783: loaded, which fill default values for those variables that have
8784: not been defined by the the package. These variables may later
8785: be used even in unrelated files.</p>
8786: <p>Then, the file <code class="filename">bsd.pkg.error.mk</code>
8787: provides the target <code class="literal">error-check</code> that is added
8788: as a special dependency to all other targets that use
8789: <code class="varname">DELAYED_ERROR_MSG</code> or
8790: <code class="varname">DELAYED_WARNING_MSG</code>.</p>
8791: <p>Then, the package-specific hacks from
8792: <code class="filename">hacks.mk</code> are included.</p>
8793: <p>Then, various other files follow. Most of them don't have
8794: any dependencies on what they need to have included before or
8795: after them, though some do.</p>
8796: <p>The code to check <code class="varname">PKG_FAIL_REASON</code> and
8797: <code class="varname">PKG_SKIP_REASON</code> is then executed, which
8798: restricts the use of these variables to all the files that have
8799: been included before. Appearances in later files will be
8800: silently ignored.</p>
8801: <p>Then, the files for the main targets are included, in the
8802: order of later execution, though the actual order should not
8803: matter.</p>
8804: <p>At last, some more files are included that don't set any
8805: interesting variables but rather just define make targets to be
8806: executed.</p>
8807: </div>
8808: </div>
1.75 rillig 8809: </div>
8810: <div class="chapter" lang="en">
8811: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8812: <a name="regression"></a>Chapter 22. Regression tests</h2></div></div></div>
1.75 rillig 8813: <div class="toc">
8814: <p><b>Table of Contents</b></p>
8815: <dl>
1.77 rillig 8816: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
8817: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
8818: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75 rillig 8819: <dd><dl>
1.77 rillig 8820: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
8821: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75 rillig 8822: </dl></dd>
8823: </dl>
8824: </div>
8825: <p>The pkgsrc infrastructure consists of a large codebase,
8826: and there are many corners where every little bit of a file is
8827: well thought out, making pkgsrc likely to fail as soon as
8828: anything is changed near those parts. To prevent most changes
8829: from breaking anything, a suite of regression tests should go
8830: along with every important part of the pkgsrc infrastructure.
8831: This chapter describes how regression tests work in pkgsrc and
8832: how you can add new tests.</p>
8833: <div class="sect1" lang="en">
8834: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8835: <a name="regression.descr"></a>22.1. The regression tests framework</h2></div></div></div>
1.75 rillig 8836: <p></p>
8837: </div>
8838: <div class="sect1" lang="en">
8839: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8840: <a name="regression.run"></a>22.2. Running the regression tests</h2></div></div></div>
1.76 rillig 8841: <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 8842: provides the <span><strong class="command">pkg_regress</strong></span> command. Then you
8843: can simply run that command, which will run all tests in the
1.76 rillig 8844: <code class="filename">regress</code> category.</p>
1.75 rillig 8845: </div>
8846: <div class="sect1" lang="en">
8847: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8848: <a name="regression.new"></a>22.3. Adding a new regression test</h2></div></div></div>
1.76 rillig 8849: <p>Every directory in the <code class="filename">regress</code>
8850: category that contains a file called <code class="filename">spec</code>
1.75 rillig 8851: is considered a regression test. This file is a shell program
8852: that is included by the <span><strong class="command">pkg_regress</strong></span> command.
8853: The following functions can be overridden to suit your
8854: needs.</p>
8855: <div class="sect2" lang="en">
8856: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 8857: <a name="regression.fun.override"></a>22.3.1. Overridable functions</h3></div></div></div>
1.75 rillig 8858: <p>These functions do not take any parameters. They are all
8859: called in “<span class="quote">set -e</span>” mode, so you should be careful
8860: to check the exitcodes of any commands you run in the
8861: test.</p>
8862: <div class="variablelist"><dl>
8863: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
8864: <dd><p>This function prepares the environment for the
8865: test. By default it does nothing.</p></dd>
8866: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
8867: <dd><p>This function runs the actual test. By default,
8868: it calls <code class="varname">TEST_MAKE</code> with the arguments
8869: <code class="varname">MAKEARGS_TEST</code> and writes its output including
8870: error messages into the file
8871: <code class="varname">TEST_OUTFILE</code>.</p></dd>
8872: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
8873: <dd><p>This function is run after the test and is
8874: typically used to compare the actual output from the one that is
8875: expected. It can make use of the various helper functions from
8876: the next section.</p></dd>
8877: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
8878: <dd><p>This function cleans everything up after the
8879: test has been run. By default it does nothing.</p></dd>
8880: </dl></div>
8881: </div>
8882: <div class="sect2" lang="en">
8883: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 8884: <a name="regression.fun.helper"></a>22.3.2. Helper functions</h3></div></div></div>
1.75 rillig 8885: <div class="variablelist"><dl>
8886: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
8887: <dd><p>This function compares the exitcode of the
8888: <span><strong class="command">do_test()</strong></span> function with its first parameter.
8889: If they differ, the test will fail.</p></dd>
8890: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
8891: <dd><p>This function checks for each of its parameters
8892: if the output from <span><strong class="command">do_test()</strong></span> matches the
8893: extended regular expression. If it does not, the test will
8894: fail.</p></dd>
8895: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
8896: <dd><p>This function checks for each of its parameters
8897: if the output from <span><strong class="command">do_test()</strong></span> does
8898: <span class="emphasis"><em>not</em></span> match the extended regular expression.
8899: If any of the regular expressions matches, the test will
8900: fail.</p></dd>
8901: </dl></div>
8902: </div>
8903: </div>
8904: </div>
8905: <div class="chapter" lang="en">
8906: <div class="titlepage"><div><div><h2 class="title">
1.80 rillig 8907: <a name="porting"></a>Chapter 23. Porting pkgsrc</h2></div></div></div>
1.75 rillig 8908: <div class="toc">
8909: <p><b>Table of Contents</b></p>
8910: <dl>
1.80 rillig 8911: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
8912: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 8913: </dl>
8914: </div>
8915: <p>The pkgsrc system has already been ported to many
8916: operating systems, hardware architectures and compilers. This
8917: chapter explains the necessary steps to make pkgsrc even more
8918: portable.</p>
8919: <div class="sect1" lang="en">
8920: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.80 rillig 8921: <a name="porting.opsys"></a>23.1. Porting pkgsrc to a new operating system</h2></div></div></div>
1.75 rillig 8922: <p>To port pkgsrc to a new operating system (called
8923: <code class="literal">MyOS</code> in this example), you need to touch the
8924: following files:</p>
8925: <div class="variablelist"><dl>
1.76 rillig 8926: <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 8927: <dd><p>This file contains some basic definitions, for
8928: example the name of the C
8929: compiler.</p></dd>
1.76 rillig 8930: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
1.75 rillig 8931: <dd><p>Insert code that defines the variables
8932: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
8933: <code class="varname">LOWER_OS_VERSION</code>,
8934: <code class="varname">LOWER_VENDOR</code>,
8935: <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
8936: <code class="varname">APPEND_ELF</code>, and the other variables that
8937: appear in this file.</p></dd>
1.76 rillig 8938: <dt><span class="term"><code class="filename">mk/platform/MyOS.mk</code></span></dt>
1.75 rillig 8939: <dd><p>This file contains the platform-specific
8940: definitions that are used by pkgsrc. Start by copying one of the
8941: other files and edit it to your
8942: needs.</p></dd>
1.76 rillig 8943: <dt><span class="term"><code class="filename">mk/platform/MyOS.pkg.dist</code></span></dt>
1.75 rillig 8944: <dd><p>This file contains a list of directories,
8945: together with their permission bits and ownership. These
8946: directories will be created automatically with every package
8947: that does not explicitly set <code class="varname">NO_MTREE</code>. There
8948: have been some discussions about whether this file is needed at
8949: all, but with no result.</p></dd>
1.76 rillig 8950: <dt><span class="term"><code class="filename">mk/platform/MyOS.x11.dist</code></span></dt>
1.75 rillig 8951: <dd><p>Just copy one of the pre-existing x11.dist files
8952: to your
1.76 rillig 8953: <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
8954: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
1.75 rillig 8955: <dd><p>On some operating systems, the tools that are
8956: provided with the base system are not good enough for pkgsrc.
8957: 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
8958: narrow limit on the line length they can process. Therefore
8959: pkgsrc brings its own tools, which can be enabled
8960: here.</p></dd>
1.76 rillig 8961: <dt><span class="term"><code class="filename">mk/tools/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
1.75 rillig 8962: <dd><p>This file defines the paths to all the tools
8963: that are needed by one or the other package in pkgsrc, as well
8964: as by pkgsrc itself. Find out where these tools are on your
8965: platform and add them.</p></dd>
8966: </dl></div>
8967: <p>Now, you should be able to build some basic packages, like
1.76 rillig 8968: <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 8969: </div>
8970: <div class="sect1" lang="en">
8971: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.80 rillig 8972: <a name="porting.compiler"></a>23.2. Adding support for a new compiler</h2></div></div></div>
1.75 rillig 8973: <p>TODO</p>
8974: </div>
8975: </div>
8976: </div>
8977: <div class="appendix" lang="en">
8978: <div class="titlepage"><div><div><h2 class="title">
8979: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
8980: <div class="toc">
8981: <p><b>Table of Contents</b></p>
8982: <dl>
8983: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
8984: <dd><dl>
8985: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
8986: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
8987: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
8988: <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>
8989: </dl></dd>
8990: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
8991: </dl>
8992: </div>
8993: <p>We checked to find a piece of software that wasn't in the packages
8994: collection, and picked GNU bison. Quite why someone would want to have
8995: <span><strong class="command">bison</strong></span> when Berkeley <span><strong class="command">yacc</strong></span> is already
8996: present in the tree is beyond us, but it's useful for the purposes of
8997: this exercise.</p>
8998: <div class="sect1" lang="en">
8999: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9000: <a name="example-files"></a>A.1. files</h2></div></div></div>
9001: <div class="sect2" lang="en">
9002: <div class="titlepage"><div><div><h3 class="title">
9003: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
9004: <pre class="programlisting">
1.51 rillig 9005: # $NetBSD$
9006: #
1.1 grant 9007:
1.51 rillig 9008: DISTNAME= bison-1.25
9009: CATEGORIES= devel
9010: MASTER_SITES= ${MASTER_SITE_GNU}
1.1 grant 9011:
1.51 rillig 9012: MAINTAINER= thorpej@NetBSD.org
9013: HOMEPAGE= http://www.gnu.org/software/bison/bison.html
9014: COMMENT= GNU yacc clone
1.1 grant 9015:
1.51 rillig 9016: GNU_CONFIGURE= yes
9017: INFO_FILES= bison.info
1.1 grant 9018:
1.51 rillig 9019: .include "../../mk/bsd.pkg.mk"
1.1 grant 9020: </pre>
1.75 rillig 9021: </div>
9022: <div class="sect2" lang="en">
9023: <div class="titlepage"><div><div><h3 class="title">
9024: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
9025: <pre class="programlisting">
1.51 rillig 9026: GNU version of yacc. Can make re-entrant parsers, and numerous other
1.75 rillig 9027: 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 9028: of the NetBSD source tree is beyond me.
1.1 grant 9029: </pre>
1.75 rillig 9030: </div>
9031: <div class="sect2" lang="en">
9032: <div class="titlepage"><div><div><h3 class="title">
9033: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
9034: <pre class="programlisting">
1.51 rillig 9035: @comment $NetBSD$
9036: bin/bison
9037: man/man1/bison.1.gz
9038: share/bison.simple
9039: share/bison.hairy
1.1 grant 9040: </pre>
1.75 rillig 9041: </div>
9042: <div class="sect2" lang="en">
9043: <div class="titlepage"><div><div><h3 class="title">
9044: <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>
9045: <p>The NetBSD package system comes with
1.76 rillig 9046: <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 9047: which helps to check the contents of these
9048: files. After installation it is quite easy to use, just change to the
9049: directory of the package you wish to examine and execute
9050: <span><strong class="command">pkglint</strong></span>:</p>
9051: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
9052: looks fine.</pre>
9053: <p>Depending on the supplied command line arguments (see pkglint(1)),
9054: more checks will be performed. Use e.g. <span><strong class="command">pkglint -Call
9055: -Wall</strong></span> for a very thorough check.</p>
9056: </div>
9057: </div>
9058: <div class="sect1" lang="en">
9059: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9060: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
9061: <p>Create the directory where the package lives,
9062: plus any auxiliary directories:</p>
9063: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
9064: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
9065: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
9066: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
1.76 rillig 9067: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.77 rillig 9068: <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 9069: then continue with fetching the distfile:</p>
9070: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
1.1 grant 9071: >> bison-1.25.tar.gz doesn't seem to exist on this system.
9072: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
9073: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
9074: ftp: Error retrieving file: 500 Internal error
9075:
9076: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
9077: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
9078: ftp: Error retrieving file: 500 Internal error
9079:
9080: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
9081: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
1.75 rillig 9082: Successfully retrieved file.</pre>
9083: <p>Generate the checksum of the distfile into
1.76 rillig 9084: <code class="filename">distinfo</code>:</p>
1.75 rillig 9085: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makesum</code></strong></pre>
9086: <p>Now compile:</p>
9087: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 9088: >> Checksum OK for bison-1.25.tar.gz.
9089: ===> Extracting for bison-1.25
9090: ===> Patching for bison-1.25
9091: ===> Ignoring empty patch directory
9092: ===> Configuring for bison-1.25
9093: creating cache ./config.cache
9094: checking for gcc... cc
9095: checking whether we are using GNU C... yes
9096: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
9097: checking how to run the C preprocessor... cc -E
9098: checking for minix/config.h... no
9099: checking for POSIXized ISC... no
9100: checking whether cross-compiling... no
9101: checking for ANSI C header files... yes
9102: checking for string.h... yes
9103: checking for stdlib.h... yes
9104: checking for memory.h... yes
9105: checking for working const... yes
9106: checking for working alloca.h... no
9107: checking for alloca... yes
9108: checking for strerror... yes
9109: updating cache ./config.cache
9110: creating ./config.status
9111: creating Makefile
9112: ===> Building for bison-1.25
9113: 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
9114: 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
9115: 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
9116: 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
9117: 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 9118: 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 9119: 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
9120: 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
9121: 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
9122: 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
9123: 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
9124: 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
9125: 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
9126: 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
9127: 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
9128: 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
9129: 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
9130: 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
9131: 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
9132: 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
9133: 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
9134: 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
9135: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
9136: rm -f bison.s1
1.75 rillig 9137: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1</pre>
9138: <p>Everything seems OK, so install the files:</p>
9139: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 9140: >> Checksum OK for bison-1.25.tar.gz.
9141: ===> Installing for bison-1.25
9142: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
9143: rm -f /usr/pkg/bin/bison
9144: cd /usr/pkg/share; rm -f bison.simple bison.hairy
9145: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
9146: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
9147: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
9148: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
9149: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
9150: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
1.75 rillig 9151: ===> Registering installation for bison-1.25</pre>
9152: <p>You can now use bison, and also - if you decide so - remove it with
9153: <span><strong class="command">pkg_delete bison</strong></span>. Should you decide that you want a
9154: binary package, do this now:</p>
9155: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 9156: >> Checksum OK for bison-1.25.tar.gz.
9157: ===> Building package for bison-1.25
9158: Creating package bison-1.25.tgz
9159: Registering depends:.
1.75 rillig 9160: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
9161: <p>Now that you don't need the source and object files
9162: any more, clean up:</p>
9163: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
9164: ===> Cleaning for bison-1.25</pre>
9165: </div>
9166: </div>
9167: <div class="appendix" lang="en">
9168: <div class="titlepage"><div><div><h2 class="title">
9169: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
9170: <div class="toc">
9171: <p><b>Table of Contents</b></p>
9172: <dl>
9173: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
9174: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
9175: </dl>
9176: </div>
9177: <div class="sect1" lang="en">
9178: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9179: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
9180: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 9181: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9182: => figlet221.tar.gz doesn't seem to exist on this system.
9183: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
9184: => [172219 bytes]
9185: Connected to ftp.plig.net.
9186: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
9187: 331 Guest login ok, send your complete e-mail address as password.
9188: 230-You are user #5 of 500 simultaneous users allowed.
9189: 230-
1.68 rillig 9190: 230- ___ _ _ _
9191: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
1.1 grant 9192: 230- | _| _| . |_| . | | | . |_| . | _| . |
9193: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
9194: 230- |_| |_| |___| |___|
9195: 230-
9196: 230-** Welcome to ftp.plig.org **
9197: 230-
9198: 230-Please note that all transfers from this FTP site are logged. If you
9199: 230-do not like this, please disconnect now.
9200: 230-
9201: 230-This arhive is available via
9202: 230-
9203: 230-HTTP: http://ftp.plig.org/
9204: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
9205: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
9206: 230-
9207: 230-Please email comments, bug reports and requests for packages to be
1.68 rillig 9208: 230-mirrored to ftp-admin@plig.org.
1.1 grant 9209: 230-
9210: 230-
9211: 230 Logged in anonymously.
9212: Remote system type is UNIX.
9213: Using binary mode to transfer files.
9214: 200 Type okay.
9215: 250 "/pub" is new cwd.
9216: 250-"/pub/figlet" is new cwd.
9217: 250-
9218: 250-Welcome to the figlet archive at ftp.figlet.org
1.68 rillig 9219: 250-
1.75 rillig 9220: 250- ftp://ftp.figlet.org/pub/figlet/
1.1 grant 9221: 250-
9222: 250-The official FIGlet web page is:
1.75 rillig 9223: 250- http://www.figlet.org/
1.1 grant 9224: 250-
9225: 250-If you have questions, please mailto:info@figlet.org. If you want to
9226: 250-contribute a font or something else, you can email us.
1.68 rillig 9227: 250
1.1 grant 9228: 250 "/pub/figlet/program" is new cwd.
9229: 250 "/pub/figlet/program/unix" is new cwd.
9230: local: figlet221.tar.gz remote: figlet221.tar.gz
9231: 502 Unimplemented command.
9232: 227 Entering Passive Mode (195,40,6,41,246,104)
9233: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
9234: 38% |************** | 65800 64.16 KB/s 00:01 ETA
9235: 226 Transfer completed.
9236: 172219 bytes received in 00:02 (75.99 KB/s)
9237: 221 Goodbye.
9238: => Checksum OK for figlet221.tar.gz.
9239: ===> Extracting for figlet-2.2.1nb2
9240: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
9241: ===> Patching for figlet-2.2.1nb2
9242: ===> Applying pkgsrc patches for figlet-2.2.1nb2
9243: ===> Overriding tools for figlet-2.2.1nb2
9244: ===> Creating toolchain wrappers for figlet-2.2.1nb2
9245: ===> Configuring for figlet-2.2.1nb2
9246: ===> Building for figlet-2.2.1nb2
9247: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
9248: chmod a+x figlet
9249: gcc -O2 -o chkfont chkfont.c
9250: => Unwrapping files-to-be-installed.
1.14 xtraeme 9251: <code class="prompt">#</code>
1.75 rillig 9252: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 9253: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9254: ===> Installing for figlet-2.2.1nb2
9255: install -d -o root -g wheel -m 755 /usr/pkg/bin
9256: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
9257: mkdir -p /usr/pkg/share/figlet
9258: cp figlet /usr/pkg/bin
9259: cp chkfont /usr/pkg/bin
9260: chmod 555 figlist showfigfonts
9261: cp figlist /usr/pkg/bin
9262: cp showfigfonts /usr/pkg/bin
9263: cp fonts/*.flf /usr/pkg/share/figlet
9264: cp fonts/*.flc /usr/pkg/share/figlet
9265: cp figlet.6 /usr/pkg/man/man6
9266: ===> Registering installation for figlet-2.2.1nb2
1.75 rillig 9267: <code class="prompt">#</code></pre>
9268: </div>
9269: <div class="sect1" lang="en">
9270: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9271: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
9272: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 9273: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9274: ===> Packaging figlet-2.2.1nb2
9275: ===> Building binary package for figlet-2.2.1nb2
9276: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
9277: Using SrcDir value of /usr/pkg
1.68 rillig 9278: Registering depends:.
1.75 rillig 9279: <code class="prompt">#</code></pre>
9280: </div>
9281: </div>
9282: <div class="appendix" lang="en">
9283: <div class="titlepage"><div><div><h2 class="title">
1.76 rillig 9284: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
9285: <div class="toc">
9286: <p><b>Table of Contents</b></p>
9287: <dl>
9288: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
9289: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
9290: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
9291: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
9292: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
9293: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
9294: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
9295: source packages</a></span></dt>
9296: </dl>
9297: </div>
9298: <p>As in other big projects, the directory layout of pkgsrc
9299: is quite complex for newbies. This chapter explains where you
9300: find things on the FTP server. The base directory on
9301: <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>.
9302: This directory contains some subdirectories, which are explained
9303: below.</p>
9304: <div class="sect1" lang="en">
9305: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9306: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
9307: <p>For those who only want to manage binary packages on
9308: systems other than NetBSD, we provide the package management
9309: tools in a separate, small tar file.</p>
9310: </div>
9311: <div class="sect1" lang="en">
9312: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9313: <a name="ftp-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
9314: <p>The directory <code class="filename">distfiles</code> contains lots
9315: of archive files from all pkgsrc packages, which are mirrored
9316: here. The subdirectories are called after their package names
9317: and are used when the distributed files have names that don't
9318: explicitly contain a version number or are otherwise too generic
9319: (for example <code class="filename">release.tar.gz</code>).</p>
9320: </div>
9321: <div class="sect1" lang="en">
9322: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9323: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
9324: <p>This directory is currently not in use.</p>
9325: </div>
9326: <div class="sect1" lang="en">
9327: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9328: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
9329: <p>This directory contains things that individual pkgsrc
9330: developers find worth publishing.</p>
9331: </div>
9332: <div class="sect1" lang="en">
9333: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9334: <a name="ftp-packages"></a>C.5. <code class="filename">packages*</code>: Binary packages</h2></div></div></div>
9335: <p>These directories contain binary packages. Those
9336: directories that have a branch name
9337: (200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>)
9338: contain packages from that particular branch. The directory
9339: <code class="filename">packages</code> contains binary packages from
9340: pkgsrc-current. (However, this does not necessarily mean that
9341: the packages are still current anymore.)</p>
9342: <p>Below the <code class="filename">packages*</code> directories are
9343: directories that distinguish the packages by operating system
9344: and version, the next directory level specifies the hardware
9345: architecture.</p>
9346: <p>In each of the platform-specific directories, there is a
9347: whole binary packages collection. It has a directory called
9348: <code class="filename">All</code> which contains all binary packages.
9349: Besides that, there are various category directories that
9350: contain symbolic links to the real binary packages.</p>
9351: </div>
9352: <div class="sect1" lang="en">
9353: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9354: <a name="ftp-source"></a>C.6. <code class="filename">current</code>,
9355: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
9356: source packages</h2></div></div></div>
9357: <p>These directories contain the “<span class="quote">real</span>” pkgsrc,
9358: that is the files that define how to create binary packages from
9359: source archives.</p>
9360: <p>The directory <code class="filename">pkgsrc</code> contains a
9361: snapshot of the CVS repository, which is updated on a regularly
9362: basis. The file <code class="filename">pkgsrc.tar.gz</code> contains the
9363: same as the directory, ready to be downloaded as a whole.</p>
9364: <p>In the directories for the quarterly branches, there is an
9365: additional file called
9366: <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
9367: which contains the state of pkgsrc when it was branched.</p>
9368: </div>
1.75 rillig 9369: </div>
9370: <div class="appendix" lang="en">
9371: <div class="titlepage"><div><div><h2 class="title">
9372: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
9373: <div class="toc">
9374: <p><b>Table of Contents</b></p>
9375: <dl>
1.79 rillig 9376: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75 rillig 9377: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
9378: </dl>
9379: </div>
1.79 rillig 9380: <p>This section contains information on editing the pkgsrc
9381: guide itself.</p>
1.75 rillig 9382: <div class="sect1" lang="en">
9383: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.79 rillig 9384: <a name="targets"></a>D.1. Make targets</h2></div></div></div>
9385: <p>The pkgsrc guide's source code is stored in
9386: <code class="filename">pkgsrc/doc/guide/files</code>, and several files
9387: are created from it:</p>
9388: <div class="itemizedlist"><ul type="disc">
9389: <li><p><code class="filename">pkgsrc/doc/pkgsrc.txt</code></p></li>
9390: <li><p><code class="filename">pkgsrc/doc/pkgsrc.html</code></p></li>
9391: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/</a></p></li>
9392: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</a>:
9393: The PDF version of the pkgsrc guide.</p></li>
9394: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</a>:
9395: PostScript version of the pkgsrc guide.</p></li>
1.75 rillig 9396: </ul></div>
9397: </div>
9398: <div class="sect1" lang="en">
9399: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9400: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
1.79 rillig 9401: <p>The procedure to edit the pkgsrc guide is:</p>
9402: <div class="procedure"><ol type="1">
9403: <li><p>Make sure you have the packages needed to
9404: re-generate the pkgsrc guide (and other XML-based NetBSD
9405: documentation) installed. These are <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/netbsd-doc/README.html" target="_top"><code class="filename">meta-pkgs/netbsd-doc</code></a> for creating the
9406: ASCII and HTML versions, and <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/netbsd-doc-print/README.html" target="_top"><code class="filename">meta-pkgs/netbsd-doc-print</code></a> for the
9407: PostScript and PDF versions. You will need both packages
9408: installed, to make sure documentation is consistent across all
9409: formats.</p></li>
9410: <li><p>Run <span><strong class="command">cd doc/guide</strong></span> to get to the
9411: right directory. All further steps will take place
9412: here.</p></li>
9413: <li><p>Edit the XML file(s) in
9414: <code class="filename">files/</code>.</p></li>
9415: <li><p>Run <span><strong class="command">bmake</strong></span> to check the pkgsrc
9416: guide for valid XML and to build the final output files. If you
9417: get any errors at this stage, you can just edit the files, as
9418: there are only symbolic links in the working directory, pointing
9419: to the files in <code class="filename">files/</code>.</p></li>
9420: <li><p><span><strong class="command">(cd files && cvs
9421: commit)</strong></span></p></li>
9422: <li><p>Run <span><strong class="command">bmake clean && bmake</strong></span> to
9423: regenerate the output files with the proper RCS
9424: Ids.</p></li>
9425: <li><p>Run <span><strong class="command">(cd .. && cvs update pkgsrc.*)
9426: && bmake install-doc</strong></span> to put the generated
9427: files into <code class="filename">pkgsrc/doc</code>.</p></li>
9428: <li><p>Run <span><strong class="command">(cd .. && cvs commit -m
9429: "regenerated." pkgsrc.{html,txt})</strong></span> to commit the
9430: generated documentation.</p></li>
9431: <li><p>Run <span><strong class="command">(cd
9432: ../../../htdocs/Documentation/pkgsrc && cvs update)
9433: && bmake install-htdocs</strong></span> to generate all the
9434: files for the web server.</p></li>
9435: <li><p>Run <span><strong class="command">(cd
9436: ../../../htdocs/Documentation/pkgsrc && cvs commit -m
9437: "regenerated.")</strong></span> to update the files on the web server.
9438: If you have added a chapter, don't forget to run <span><strong class="command">cvs
9439: add *.html</strong></span> before you commit the files.</p></li>
9440: </ol></div>
1.75 rillig 9441: </div>
9442: </div>
9443: </div></body>
1.1 grant 9444: </html>
CVSweb <webmaster@jp.NetBSD.org>