Annotation of pkgsrc/doc/pkgsrc.html, revision 1.88
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">
1.83 wiz 8: <meta name="description" content="pkgsrc is a centralized package management system for Unix-like operating systems. This guide provides information for users and developers of pkgsrc. It covers installation of binary and source packages, creation of binary and source packages and a high-level overview about the infrastructure.">
1.75 rillig 9: </head>
10: <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" lang="en">
11: <div class="titlepage">
12: <div>
13: <div><h1 class="title">
14: <a name="the-pkgsrc-guide"></a>The pkgsrc guide</h1></div>
15: <div><h2 class="subtitle">Documentation on the NetBSD packages system</h2></div>
16: <div><div class="authorgroup">
17: <div class="author">
18: <h3 class="author">
19: <span class="firstname">Alistair</span> <span class="surname">Crooks</span>
20: </h3>
21: <div class="affiliation"><div class="address"><p><code class="email"><<a href="mailto:agc@NetBSD.org">agc@NetBSD.org</a>></code></p></div></div>
22: </div>
23: <div class="author">
24: <h3 class="author">
25: <span class="firstname">Hubert</span> <span class="surname">Feyrer</span>
26: </h3>
27: <div class="affiliation"><div class="address"><p><code class="email"><<a href="mailto:hubertf@NetBSD.org">hubertf@NetBSD.org</a>></code></p></div></div>
28: </div>
29: <h3 class="corpauthor">
30: The pkgsrc Developers
31: </h3>
32: </div></div>
33: <div><p class="copyright">Copyright © 1994-2006 The NetBSD Foundation, Inc</p></div>
1.85 jmmv 34: <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.22 2006/09/01 16:35:39 jmmv Exp $</p></div>
1.76 rillig 35: <div><div class="abstract">
1.75 rillig 36: <p class="title"><b>Abstract</b></p>
37: <p>pkgsrc is a centralized package management system for
38: Unix-like operating systems. This guide provides information for
39: users and developers of pkgsrc. It covers installation of binary
40: and source packages, creation of binary and source packages and
41: a high-level overview about the infrastructure.</p>
42: </div></div>
43: </div>
44: <hr>
45: </div>
46: <div class="toc">
47: <p><b>Table of Contents</b></p>
48: <dl>
49: <dt><span class="chapter"><a href="#introduction">1. What is pkgsrc?</a></span></dt>
50: <dd><dl>
51: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
1.82 rillig 52: <dd><dl>
53: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
54: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
55: </dl></dd>
1.75 rillig 56: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
57: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.88 ! wiz 58: <dd><dl><dt><span class="sect2"><a href="#term.roles">1.3.1. Roles involved in pkgsrc</a></span></dt></dl></dd>
1.75 rillig 59: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
60: </dl></dd>
61: <dt><span class="part"><a href="#users-guide">I. The pkgsrc user's guide</a></span></dt>
62: <dd><dl>
63: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
64: <dd><dl>
65: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
66: <dd><dl>
67: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
68: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
69: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
70: </dl></dd>
71: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
72: <dd><dl>
73: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
74: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
75: </dl></dd>
76: </dl></dd>
77: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
78: <dd><dl>
1.82 rillig 79: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
80: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
81: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
82: <dd><dl>
83: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
84: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
85: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
86: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
87: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
88: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
89: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75 rillig 90: </dl></dd>
91: </dl></dd>
92: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
93: <dd><dl>
94: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
95: <dd><dl>
96: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
97: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82 rillig 98: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
99: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
100: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
101: <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>
102: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
103: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75 rillig 104: </dl></dd>
105: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
106: <dd><dl>
107: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
108: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
109: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
110: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
111: </dl></dd>
112: </dl></dd>
113: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
114: <dd><dl>
115: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
116: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 117: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
1.88 ! wiz 118: <dd><dl>
! 119: <dt><span class="sect2"><a href="#conf.cflags">5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
! 120: <dt><span class="sect2"><a href="#conf.ldflags">5.3.2. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
! 121: </dl></dd>
1.78 rillig 122: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
123: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 124: </dl></dd>
125: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
126: <dd><dl>
127: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
128: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
129: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
130: <dd><dl>
131: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
132: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
133: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
134: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
135: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
136: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
137: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
138: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
139: </dl></dd>
140: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
141: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
142: </dl></dd>
143: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
144: <dd><dl>
145: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
146: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
147: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
148: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
149: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
150: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
151: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
152: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
153: <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>
154: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
155: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
156: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
157: <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>
158: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
159: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
160: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
161: <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.88 ! wiz 162: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
! 163: <dt><span class="sect1"><a href="#too-much-time">7.18. I have a little time to kill. What shall I do?</a></span></dt>
1.75 rillig 164: </dl></dd>
165: </dl></dd>
166: <dt><span class="part"><a href="#developers-guide">II. The pkgsrc developer's guide</a></span></dt>
167: <dd><dl>
1.77 rillig 168: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
169: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75 rillig 170: <dd><dl>
1.77 rillig 171: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
172: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
173: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
1.85 jmmv 174: <dd><dl>
175: <dt><span class="sect2"><a href="#components.patches.guidelines">9.3.1. Patching guidelines</a></span></dt>
176: <dt><span class="sect2"><a href="#components.patches.feedback">9.3.2. Feedback to the author</a></span></dt>
177: </dl></dd>
1.77 rillig 178: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
179: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 180: <dd><dl>
181: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
182: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
183: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
184: </dl></dd>
1.77 rillig 185: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
186: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
187: </dl></dd>
188: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
189: <dd><dl>
190: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
191: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
192: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
193: <dd><dl>
194: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
195: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
196: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
197: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
198: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
199: </dl></dd>
200: </dl></dd>
201: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
202: <dd><dl>
203: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
204: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
205: <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>
206: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
207: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
208: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
209: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
210: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
211: </dl></dd>
212: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
213: <dd><dl>
214: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
215: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
216: <dd><dl>
217: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
218: <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>
219: </dl></dd>
220: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
221: <dd><dl>
222: <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>
223: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
224: </dl></dd>
225: </dl></dd>
226: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
227: <dd><dl>
228: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
229: <dd><dl>
230: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
231: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
232: </dl></dd>
233: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
234: <dd><dl>
235: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
236: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
237: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
238: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
239: </dl></dd>
240: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
241: <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>
242: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
243: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
244: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
245: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
246: <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>
247: </dl></dd>
248: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
249: <dd><dl>
250: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
251: <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>
252: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
253: </dl></dd>
254: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
255: <dd><dl>
256: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
257: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
258: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
259: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
260: <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 261: <dd><dl>
262: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
263: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
264: </dl></dd>
1.77 rillig 265: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
266: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
267: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
268: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
269: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
270: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
271: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
272: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
273: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
274: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
1.88 ! wiz 275: <dt><span class="sect1"><a href="#build.clean">15.16. Cleaning up</a></span></dt>
! 276: <dt><span class="sect1"><a href="#build.helpful-targets">15.17. Other helpful targets</a></span></dt>
1.77 rillig 277: </dl></dd>
278: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
279: <dd><dl>
280: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
281: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
282: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
283: </dl></dd>
284: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
285: <dd><dl>
286: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
287: <dd><dl>
1.78 rillig 288: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
289: <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>
290: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
291: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
292: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
293: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
294: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
295: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
296: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
297: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
298: <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 299: <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 300: </dl></dd>
301: <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>
302: <dd><dl>
303: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
304: <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>
305: </dl></dd>
306: <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>
307: <dd><dl>
308: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
309: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
310: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
311: </dl></dd>
1.87 wiz 312: <dt><span class="sect1"><a href="#programming-languages">17.4. Programming languages</a></span></dt>
1.77 rillig 313: <dd><dl>
1.87 wiz 314: <dt><span class="sect2"><a href="#basic-programming-languages">17.4.1. C, C++, and Fortran</a></span></dt>
315: <dt><span class="sect2"><a href="#java-programming-language">17.4.2. Java</a></span></dt>
316: <dt><span class="sect2"><a href="#perl-scripts">17.4.3. Packages containing perl scripts</a></span></dt>
317: <dt><span class="sect2"><a href="#other-programming-languages">17.4.4. Other programming languages</a></span></dt>
318: </dl></dd>
319: <dt><span class="sect1"><a href="#fixes.build">17.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
320: <dd><dl>
321: <dt><span class="sect2"><a href="#fixes.build.cpp">17.5.1. Compiling C and C++ code conditionally</a></span></dt>
322: <dt><span class="sect2"><a href="#compiler-bugs">17.5.2. How to handle compiler bugs</a></span></dt>
323: <dt><span class="sect2"><a href="#undefined-reference">17.5.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
324: <dt><span class="sect2"><a href="#out-of-memory">17.5.4. Running out of memory</a></span></dt>
325: </dl></dd>
326: <dt><span class="sect1"><a href="#fixes.install">17.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
327: <dd><dl>
328: <dt><span class="sect2"><a href="#install-scripts">17.6.1. Creating needed directories</a></span></dt>
329: <dt><span class="sect2"><a href="#where-to-install-documentation">17.6.2. Where to install documentation</a></span></dt>
330: <dt><span class="sect2"><a href="#installing-score-files">17.6.3. Installing score files</a></span></dt>
331: <dt><span class="sect2"><a href="#hardcoded-paths">17.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
332: <dt><span class="sect2"><a href="#perl-modules">17.6.5. Packages installing perl modules</a></span></dt>
333: <dt><span class="sect2"><a href="#faq.info-files">17.6.6. Packages installing info files</a></span></dt>
334: <dt><span class="sect2"><a href="#manpages">17.6.7. Packages installing man pages</a></span></dt>
335: <dt><span class="sect2"><a href="#gconf2-data-files">17.6.8. Packages installing GConf2 data files</a></span></dt>
336: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.6.9. Packages installing scrollkeeper data files</a></span></dt>
337: <dt><span class="sect2"><a href="#x11-fonts">17.6.10. Packages installing X11 fonts</a></span></dt>
338: <dt><span class="sect2"><a href="#gtk2-modules">17.6.11. Packages installing GTK2 modules</a></span></dt>
339: <dt><span class="sect2"><a href="#sgml-xml-data">17.6.12. Packages installing SGML or XML data</a></span></dt>
340: <dt><span class="sect2"><a href="#mime-database">17.6.13. Packages installing extensions to the MIME database</a></span></dt>
341: <dt><span class="sect2"><a href="#intltool">17.6.14. Packages using intltool</a></span></dt>
342: <dt><span class="sect2"><a href="#startup-scripts">17.6.15. Packages installing startup scripts</a></span></dt>
343: <dt><span class="sect2"><a href="#tex-packages">17.6.16. Packages installing TeX modules</a></span></dt>
344: <dt><span class="sect2"><a href="#emulation-packages">17.6.17. Packages supporting running binaries in
345: emulation</a></span></dt>
346: <dt><span class="sect2"><a href="#hicolor-theme">17.6.18. Packages installing hicolor theme icons</a></span></dt>
347: <dt><span class="sect2"><a href="#desktop-files">17.6.19. Packages installing desktop files</a></span></dt>
1.77 rillig 348: </dl></dd>
1.87 wiz 349: <dt><span class="sect1"><a href="#punting">17.7. Marking packages as having problems</a></span></dt>
1.77 rillig 350: </dl></dd>
351: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
352: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
353: <dd><dl>
354: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
355: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
356: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
357: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
358: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
359: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 360: </dl></dd>
1.77 rillig 361: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.85 jmmv 362: <dt><span class="chapter"><a href="#gnome">21. GNOME packaging and porting</a></span></dt>
363: <dd><dl>
364: <dt><span class="sect1"><a href="#meta-packages">21.1. Meta packages</a></span></dt>
365: <dt><span class="sect1"><a href="#new-package">21.2. Packaging a GNOME application</a></span></dt>
366: <dt><span class="sect1"><a href="#full-update">21.3. Updating GNOME to a newer version</a></span></dt>
367: <dt><span class="sect1"><a href="#patching">21.4. Patching guidelines</a></span></dt>
368: </dl></dd>
1.75 rillig 369: </dl></dd>
370: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
371: <dd><dl>
1.85 jmmv 372: <dt><span class="chapter"><a href="#infr.design">22. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 373: <dd><dl>
1.85 jmmv 374: <dt><span class="sect1"><a href="#infr.vardef">22.1. The meaning of variable definitions</a></span></dt>
375: <dt><span class="sect1"><a href="#infr.vardef.problems">22.2. Avoiding problems before they arise</a></span></dt>
376: <dt><span class="sect1"><a href="#infr.var">22.3. Variable evaluation</a></span></dt>
1.81 rillig 377: <dd><dl>
1.85 jmmv 378: <dt><span class="sect2"><a href="#infr.var.load">22.3.1. At load time</a></span></dt>
379: <dt><span class="sect2"><a href="#infr.var.run">22.3.2. At runtime</a></span></dt>
1.81 rillig 380: </dl></dd>
1.85 jmmv 381: <dt><span class="sect1"><a href="#infr.varspec">22.4. How can variables be specified?</a></span></dt>
382: <dt><span class="sect1"><a href="#infr.design.intf">22.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 383: <dd><dl>
1.85 jmmv 384: <dt><span class="sect2"><a href="#infr.design.intf.proc">22.5.1. Procedures with parameters</a></span></dt>
385: <dt><span class="sect2"><a href="#infr.design.intf.action">22.5.2. Actions taken on behalf of parameters</a></span></dt>
1.75 rillig 386: </dl></dd>
1.85 jmmv 387: <dt><span class="sect1"><a href="#infr.order">22.6. The order in which files are loaded</a></span></dt>
1.75 rillig 388: <dd><dl>
1.85 jmmv 389: <dt><span class="sect2"><a href="#infr.order.prefs">22.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
390: <dt><span class="sect2"><a href="#infr.order.pkg">22.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75 rillig 391: </dl></dd>
392: </dl></dd>
1.85 jmmv 393: <dt><span class="chapter"><a href="#regression">23. Regression tests</a></span></dt>
1.75 rillig 394: <dd><dl>
1.85 jmmv 395: <dt><span class="sect1"><a href="#regression.descr">23.1. The regression tests framework</a></span></dt>
396: <dt><span class="sect1"><a href="#regression.run">23.2. Running the regression tests</a></span></dt>
397: <dt><span class="sect1"><a href="#regression.new">23.3. Adding a new regression test</a></span></dt>
1.75 rillig 398: <dd><dl>
1.85 jmmv 399: <dt><span class="sect2"><a href="#regression.fun.override">23.3.1. Overridable functions</a></span></dt>
400: <dt><span class="sect2"><a href="#regression.fun.helper">23.3.2. Helper functions</a></span></dt>
1.75 rillig 401: </dl></dd>
402: </dl></dd>
1.85 jmmv 403: <dt><span class="chapter"><a href="#porting">24. Porting pkgsrc</a></span></dt>
1.75 rillig 404: <dd><dl>
1.85 jmmv 405: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
406: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 407: </dl></dd>
408: </dl></dd>
409: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
410: <dd><dl>
411: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
412: <dd><dl>
413: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
414: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
415: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
416: <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>
417: </dl></dd>
418: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
419: </dl></dd>
420: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
421: <dd><dl>
422: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
423: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
424: </dl></dd>
1.76 rillig 425: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
426: <dd><dl>
427: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
428: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
429: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
430: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
431: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
432: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
433: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
434: source packages</a></span></dt>
435: </dl></dd>
1.75 rillig 436: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
437: <dd><dl>
1.79 rillig 438: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75 rillig 439: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
440: </dl></dd>
441: </dl>
442: </div>
1.82 rillig 443: <div class="list-of-tables">
444: <p><b>List of Tables</b></p>
445: <dl>
446: <dt>1.1. <a href="#supported-platforms">Platforms supported by pkgsrc</a>
447: </dt>
448: <dt>3.1. <a href="#binary-kits">Binary kits and available packages</a>
449: </dt>
1.85 jmmv 450: <dt>9.1. <a href="#patch-examples">Patching examples</a>
451: </dt>
452: <dt>21.1. <a href="#plist-handling">PLIST handling for GNOME packages</a>
453: </dt>
1.82 rillig 454: </dl>
455: </div>
1.75 rillig 456: <div class="chapter" lang="en">
457: <div class="titlepage"><div><div><h2 class="title">
458: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
459: <div class="toc">
460: <p><b>Table of Contents</b></p>
461: <dl>
462: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
1.82 rillig 463: <dd><dl>
464: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
465: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
466: </dl></dd>
1.75 rillig 467: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
468: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.88 ! wiz 469: <dd><dl><dt><span class="sect2"><a href="#term.roles">1.3.1. Roles involved in pkgsrc</a></span></dt></dl></dd>
1.75 rillig 470: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
471: </dl>
472: </div>
473: <div class="sect1" lang="en">
474: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
475: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
1.82 rillig 476: <p>There is a lot of software freely available for Unix-based
477: systems, which is usually available in form of the source code. Before
478: such software can be used, it needs to be configured to the local
479: system, compiled and installed, and this is exactly what The NetBSD
480: Packages Collection (pkgsrc) does. pkgsrc also has some basic commands
481: to handle binary packages, so that not every user has to build the
482: packages for himself, which is a time-costly task.</p>
1.75 rillig 483: <p>pkgsrc currently contains several thousand packages,
484: including:</p>
485: <div class="itemizedlist"><ul type="disc">
1.76 rillig 486: <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 487: web server</p></li>
1.83 wiz 488: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a> - The Firefox
1.75 rillig 489: web browser</p></li>
1.76 rillig 490: <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 491: Desktop Environment</p></li>
1.76 rillig 492: <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 493: Desktop Environment</p></li>
494: </ul></div>
495: <p>...just to name a few.</p>
496: <p>pkgsrc has built-in support for handling varying dependencies,
497: such as pthreads and X11, and extended features such as IPv6 support on
498: a range of platforms.</p>
1.82 rillig 499: <div class="sect2" lang="en">
500: <div class="titlepage"><div><div><h3 class="title">
501: <a name="why-pkgsrc"></a>1.1.1. Why pkgsrc?</h3></div></div></div>
502: <p>
503: pkgsrc provides the following key features:
504: </p>
505: <div class="itemizedlist"><ul type="disc">
506: <li><p>Easy building of software from source as well as the creation
507: and installation of binary packages. The source and latest
508: patches are retrieved from a master or mirror download site, checksum
509: verified, then built on your system. Support for binary-only
510: distributions is available for both native platforms and NetBSD
511: emulated platforms.</p></li>
512: <li><p>All packages are installed in a consistent directory tree,
513: including binaries, libraries, man pages and other
514: documentation.</p></li>
515: <li><p>Package dependencies, including when performing package updates,
516: are handled automatically. The configuration files of various
517: packages are handled automatically during updates, so local changes
518: are preserved.</p></li>
519: <li><p>Like NetBSD, pkgsrc is designed with portability in mind and
520: consists of highly portable code. This allows the greatest speed of
521: development when porting to new a platform. This portability also
522: ensures that pkgsrc is <span class="emphasis"><em>consistent across all
523: platforms</em></span>.</p></li>
524: <li><p>The installation prefix, acceptable software licenses,
525: international encryption requirements and build-time options for a
526: large number of packages are all set in a simple, central
527: configuration file.</p></li>
528: <li><p>The entire source (not including the distribution files) is
529: freely available under a BSD license, so you may extend and adapt
530: pkgsrc to your needs. Support for local packages and patches is
531: available right out of the box, so you can configure it specifically
532: for your environment.</p></li>
533: </ul></div>
534: </div>
535: <div class="sect2" lang="en">
536: <div class="titlepage"><div><div><h3 class="title">
537: <a name="intro.platforms"></a>1.1.2. Supported platforms</h3></div></div></div>
538: <p>pkgsrc consists of both a source distribution and a binary
539: distribution for these operating systems. After retrieving the required
540: source or binaries, you can be up and running with pkgsrc in just
541: minutes!</p>
1.75 rillig 542: <p>pkgsrc was derived from FreeBSD's ports system, and
543: initially developed for NetBSD only. Since then, pkgsrc has
544: grown a lot, and now supports the following platforms:</p>
1.82 rillig 545: <div class="table">
546: <a name="supported-platforms"></a><p class="title"><b>Table 1.1. Platforms supported by pkgsrc</b></p>
1.83 wiz 547: <div class="table-contents"><table summary="Platforms supported by pkgsrc" border="1">
1.82 rillig 548: <colgroup>
549: <col>
550: <col>
551: </colgroup>
552: <thead><tr>
553: <th>Platform</th>
554: <th>Date Support Added</th>
555: </tr></thead>
556: <tbody>
557: <tr>
558: <td><a href="http://www.NetBSD.org/" target="_top">NetBSD</a></td>
559: <td align="center">Aug 1997</td>
560: </tr>
561: <tr>
562: <td><a href="http://wwws.sun.com/software/solaris/" target="_top">Solaris</a></td>
563: <td align="center">Mar 1999</td>
564: </tr>
565: <tr>
566: <td><a href="http://www.kernel.org/" target="_top">Linux</a></td>
567: <td align="center">Jun 1999</td>
568: </tr>
569: <tr>
570: <td>
571: <a href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
572: (<a href="http://developer.apple.com/macosx/" target="_top">Mac OS X</a>)
573: </td>
574: <td align="center">Oct 2001</td>
575: </tr>
576: <tr>
577: <td><a href="http://www.freebsd.org/" target="_top">FreeBSD</a></td>
578: <td align="center">Nov 2002</td>
579: </tr>
580: <tr>
581: <td><a href="http://www.openbsd.org/" target="_top">OpenBSD</a></td>
582: <td align="center">Nov 2002</td>
583: </tr>
584: <tr>
585: <td><a href="http://www.sgi.com/software/irix/" target="_top">IRIX</a></td>
586: <td align="center">Dec 2002</td>
587: </tr>
588: <tr>
589: <td>BSD/OS</td>
590: <td align="center">Dec 2003</td>
591: </tr>
592: <tr>
593: <td><a href="http://www-1.ibm.com/servers/aix/" target="_top">AIX</a></td>
594: <td align="center">Dec 2003</td>
595: </tr>
596: <tr>
597: <td>
598: <a href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a>
599: (Microsoft Windows Services for Unix)
600: </td>
601: <td align="center">Mar 2004</td>
602: </tr>
603: <tr>
604: <td><a href="http://www.dragonflybsd.org/" target="_top">DragonFlyBSD</a></td>
605: <td align="center">Oct 2004</td>
606: </tr>
607: <tr>
608: <td><a href="http://www.tru64.org/" target="_top">OSF/1</a></td>
609: <td align="center">Nov 2004</td>
610: </tr>
611: </tbody>
1.83 wiz 612: </table></div>
1.82 rillig 613: </div>
1.83 wiz 614: <br class="table-break">
1.82 rillig 615: </div>
1.75 rillig 616: </div>
617: <div class="sect1" lang="en">
618: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
619: <a name="overview"></a>1.2. Overview</h2></div></div></div>
620: <p>This document is divided into three parts. The first,
621: <a href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
622: describes how one can use one of the packages in the Package
623: Collection, either by installing a precompiled binary package,
624: or by building one's own copy using the NetBSD package system.
625: 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
626: package so it can be easily built by other NetBSD users without
627: knowing about the package's building details. The third part,
628: <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
629: is intended for those who want to understand how pkgsrc is
630: implemented.</p>
631: <p>This document is available in various formats:
632: <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>
633: </div>
634: <div class="sect1" lang="en">
635: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
636: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
637: <p>There has been a lot of talk about “<span class="quote">ports</span>”,
638: “<span class="quote">packages</span>”, etc. so far. Here is a description of all the
639: terminology used within this document.</p>
640: <div class="variablelist"><dl>
641: <dt><span class="term">Package</span></dt>
642: <dd><p>A set of files and building instructions
643: that describe what's necessary
644: to build a certain piece of software using
645: pkgsrc. Packages are traditionally stored under
1.76 rillig 646: <code class="filename">/usr/pkgsrc</code>.</p></dd>
1.75 rillig 647: <dt><span class="term">The NetBSD package system</span></dt>
1.87 wiz 648: <dd><p>This is the former name of “<span class="quote">pkgsrc</span>”. It
649: is part of the NetBSD operating system and can be bootstrapped
650: to run on non-NetBSD operating systems as well. It handles
651: building (compiling), installing, and removing of
652: packages.</p></dd>
1.75 rillig 653: <dt><span class="term">Distfile</span></dt>
654: <dd><p>This term describes the file or files that are
655: provided by the author of the piece of software to
656: distribute his work. All the changes necessary to build on
657: NetBSD are reflected in the corresponding package. Usually
658: the distfile is in the form of a compressed tar-archive,
659: but other types are possible, too. Distfiles are usually
660: stored below
1.76 rillig 661: <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
1.75 rillig 662: <dt><span class="term">Port</span></dt>
663: <dd><p>This is the term used by FreeBSD and OpenBSD people
664: for what we call a package.
665: In NetBSD terminology, “<span class="quote">port</span>” refers to a different
666: architecture.</p></dd>
667: <dt><span class="term">Precompiled/binary package</span></dt>
668: <dd>
669: <p>A set of binaries built with pkgsrc from a distfile
1.76 rillig 670: and stuffed together in a single <code class="filename">.tgz</code>
1.75 rillig 671: file so it can be installed on machines of the same
672: machine architecture without the need to
673: recompile. Packages are usually generated in
1.76 rillig 674: <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.75 rillig 675: an archive on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
676: <p>Sometimes, this is referred to by the term “<span class="quote">package</span>” too,
677: especially in the context of precompiled packages.</p>
678: </dd>
679: <dt><span class="term">Program</span></dt>
1.88 ! wiz 680: <dd><p>The piece of software to be installed which will be
! 681: constructed from all the files in the distfile by the
! 682: actions defined in the corresponding package.</p></dd>
1.75 rillig 683: </dl></div>
684: <div class="sect2" lang="en">
685: <div class="titlepage"><div><div><h3 class="title">
1.88 ! wiz 686: <a name="term.roles"></a>1.3.1. Roles involved in pkgsrc</h3></div></div></div>
1.75 rillig 687: <div class="variablelist"><dl>
688: <dt><span class="term">pkgsrc users</span></dt>
689: <dd>
690: <p>The
691: pkgsrc users are people who use the packages provided by pkgsrc.
692: Typically they are system administrators. The people using the
693: software that is inside the packages (maybe called “<span class="quote">end
694: users</span>”) are not covered by the pkgsrc guide.</p>
695: <p>There are two kinds of pkgsrc users: Some only want to
696: install pre-built binary packages. Others build the pkgsrc
697: packages from source, either for installing them directly or for
698: 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
699: documentation.</p>
700: </dd>
701: <dt><span class="term">package maintainers</span></dt>
702: <dd><p>A
703: 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>
704: <dt><span class="term">infrastructure developers</span></dt>
705: <dd><p>These people are involved in all those files
1.76 rillig 706: that live in the <code class="filename">mk/</code> directory and below.
1.75 rillig 707: 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,
708: too.</p></dd>
709: </dl></div>
710: </div>
711: </div>
712: <div class="sect1" lang="en">
713: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
714: <a name="typography"></a>1.4. Typography</h2></div></div></div>
715: <p>When giving examples for commands, shell prompts are used to
716: show if the command should/can be issued as root, or if
717: “<span class="quote">normal</span>” user privileges are sufficient. We use a
718: <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
719: shell prompt, assuming they use the C-shell or tcsh.</p>
720: </div>
721: </div>
722: <div class="part" lang="en">
723: <div class="titlepage"><div><div><h1 class="title">
724: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
725: <div class="toc">
726: <p><b>Table of Contents</b></p>
727: <dl>
728: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
729: <dd><dl>
730: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
731: <dd><dl>
732: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
733: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
734: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
735: </dl></dd>
736: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
737: <dd><dl>
738: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
739: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
740: </dl></dd>
741: </dl></dd>
742: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
743: <dd><dl>
1.82 rillig 744: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
745: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
746: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
747: <dd><dl>
748: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
749: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
750: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
751: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
752: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
753: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
754: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75 rillig 755: </dl></dd>
756: </dl></dd>
757: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
758: <dd><dl>
759: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
760: <dd><dl>
761: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
762: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82 rillig 763: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
764: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
765: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
766: <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>
767: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
768: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75 rillig 769: </dl></dd>
770: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
771: <dd><dl>
772: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
773: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
774: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
775: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
776: </dl></dd>
777: </dl></dd>
778: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
779: <dd><dl>
780: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
781: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 782: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
1.88 ! wiz 783: <dd><dl>
! 784: <dt><span class="sect2"><a href="#conf.cflags">5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
! 785: <dt><span class="sect2"><a href="#conf.ldflags">5.3.2. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
! 786: </dl></dd>
1.78 rillig 787: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
788: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 789: </dl></dd>
790: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
791: <dd><dl>
792: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
793: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
794: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
795: <dd><dl>
796: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
797: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
798: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
799: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
800: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
801: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
802: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
803: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
804: </dl></dd>
805: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
806: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
807: </dl></dd>
808: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
809: <dd><dl>
810: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
811: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
812: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
813: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
814: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
815: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
816: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
817: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
818: <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>
819: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
820: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
821: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
822: <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>
823: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
824: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
825: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
826: <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.88 ! wiz 827: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
! 828: <dt><span class="sect1"><a href="#too-much-time">7.18. I have a little time to kill. What shall I do?</a></span></dt>
1.75 rillig 829: </dl></dd>
830: </dl>
831: </div>
832: <div class="chapter" lang="en">
833: <div class="titlepage"><div><div><h2 class="title">
834: <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
835: <div class="toc">
836: <p><b>Table of Contents</b></p>
837: <dl>
838: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
839: <dd><dl>
840: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
841: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
842: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
843: </dl></dd>
844: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
845: <dd><dl>
846: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
847: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
848: </dl></dd>
849: </dl>
850: </div>
851: <p>The most common location where pkgsrc is installed is
1.76 rillig 852: <code class="filename">/usr/pkgsrc</code> for the “<span class="quote">package
853: sources</span>” and <code class="filename">/usr/pkg</code> for the
1.75 rillig 854: installed binary packages. You are though free to install the
855: sources and binary packages wherever you want in your
856: filesystem, provided that both paths do not contain white-space
857: or other characters that are interpreted specially by the shell
858: and some other programs. A safe bet is to use only letters,
859: digits, underscores and dashes in the names.</p>
860: <div class="sect1" lang="en">
861: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
862: <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
863: <p>Before you download any pkgsrc files, you should decide
864: whether you want the <span class="emphasis"><em>current</em></span> branch or the
865: <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
866: quarterly basis from the current branch and only gets modified
867: for security updates. The names of the stable branches are built
868: from the year and the quarter, for example
869: <code class="literal">2006Q1</code>.</p>
870: <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
871: want to download pkgsrc. You can get it as a tar file, via SUP,
872: or via CVS. All three ways are described here.</p>
873: <div class="sect2" lang="en">
874: <div class="titlepage"><div><div><h3 class="title">
875: <a name="getting-via-tar"></a>2.1.1. As tar file</h3></div></div></div>
876: <p>The primary download location for all pkgsrc files is
877: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>. There are a
878: number of subdirectories for different purposes, which are
1.76 rillig 879: 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 880: <p>The tar file for the current branch is in the directory
1.76 rillig 881: <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 882: It is autogenerated daily.</p>
883: <p>The tar file for the stable branch 2006Q1 is in the
1.76 rillig 884: 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 885: <p>After downloading the tar file, change to the directory
886: where you want to have pkgsrc. This is usually
1.76 rillig 887: <code class="filename">/usr</code>. Then, run <span><strong class="command">tar xfz
1.75 rillig 888: pkgsrc.tar.gz</strong></span> to extract the files.</p>
889: </div>
890: <div class="sect2" lang="en">
891: <div class="titlepage"><div><div><h3 class="title">
892: <a name="getting-via-sup"></a>2.1.2. Via SUP</h3></div></div></div>
893: <p>As an alternative to the tar file, you can get pkgsrc via
894: the Software Update Protocol, SUP. To do so, make sure your
895: supfile has a line
1.1 grant 896:
1.75 rillig 897: </p>
898: <pre class="programlisting">
1.51 rillig 899: release=pkgsrc
1.1 grant 900: </pre>
1.75 rillig 901: <p>
1.1 grant 902:
1.75 rillig 903: in it, see the examples in
1.76 rillig 904: <code class="filename">/usr/share/examples/supfiles</code>, and that the
905: <code class="filename">/usr/pkgsrc</code> directory exists. Then, simply
1.75 rillig 906: run <span><strong class="command">sup -v
907: <em class="replaceable"><code>/path/to/your/supfile</code></em></strong></span>.</p>
908: </div>
909: <div class="sect2" lang="en">
910: <div class="titlepage"><div><div><h3 class="title">
911: <a name="getting-via-cvs"></a>2.1.3. Via CVS</h3></div></div></div>
912: <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>
913: installed. To do an initial (full) checkout of pkgsrc, you first
914: have to set some environment variables. For the C-Shell,
915: type:</p>
916: <pre class="screen">
917: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
918: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVS_RSH ssh</code></strong>
919: </pre>
920: <p>Or, the same for the bourne shell:</p>
921: <pre class="screen">
922: <code class="prompt">$</code> <strong class="userinput"><code>CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"</code></strong>
923: <code class="prompt">$</code> <strong class="userinput"><code>CVS_RSH="ssh"</code></strong>
924: <code class="prompt">$</code> <strong class="userinput"><code>export CVSROOT CVS_RSH</code></strong>
925: </pre>
926: <p>Then, you change to the directory where you want to have
927: your copy of pkgsrc. In most cases this is
1.76 rillig 928: <code class="filename">/usr</code>. In that directory you run the
1.75 rillig 929: checkout command, which is <span><strong class="command">cvs -q checkout -P
930: pkgsrc</strong></span> for the current branch and <span><strong class="command">cvs -q
931: checkout -rpkgsrc-2006Q1 -P pkgsrc</strong></span> for the stable
932: branch. This command will create a directory called
1.76 rillig 933: <code class="filename">pkgsrc</code> with all the pkgsrc files in
1.75 rillig 934: it.</p>
935: </div>
936: </div>
937: <div class="sect1" lang="en">
938: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
939: <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
940: <p>The preferred way to keep pkgsrc up-to-date is via CVS
941: (which also works if you have first installed it via a tar
942: file). It saves bandwidth and hard disk activity, compared to
943: downloading the tar file again.</p>
944: <div class="sect2" lang="en">
945: <div class="titlepage"><div><div><h3 class="title">
946: <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
947: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
948: <h3 class="title">Warning</h3>
1.77 rillig 949: <p>When updating from a tar file, you first need to
950: completely remove the old pkgsrc directory. Otherwise those
951: files that have been removed from pkgsrc in the mean time will
952: not be removed on your local disk, resulting in inconsistencies.
953: When removing the old files, any changes that you have done to
954: the pkgsrc files will be lost after updating. Therefore updating
955: via CVS is strongly recommended.</p>
1.75 rillig 956: </div>
1.82 rillig 957: <p>Note that by default the distfiles and the binary packages
958: are saved in the pkgsrc tree, so don't forget to rescue them
959: before updating. You can also configure pkgsrc to use other than
960: the default directories by setting the
961: <code class="varname">DISTDIR</code> and <code class="varname">PACKAGES</code>
962: variables. See <a href="#configuring" title="Chapter 5. Configuring pkgsrc">Chapter 5, <i>Configuring pkgsrc</i></a> for the details.</p>
1.75 rillig 963: <p>To update pkgsrc from a tar file, download the tar file as
964: explained above. Then, make sure that you have not made any
965: changes to the files in the pkgsrc directory. Remove the pkgsrc
966: directory and extract the new tar file. Done.</p>
967: </div>
968: <div class="sect2" lang="en">
969: <div class="titlepage"><div><div><h3 class="title">
970: <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
971: <p>To update pkgsrc via CVS, make sure the environment
972: variable <code class="varname">CVS_RSH</code> is set as above. Then,
973: change to the pkgsrc directory and run <span><strong class="command">cvs -q update
1.77 rillig 974: -dP</strong></span>.</p>
1.75 rillig 975: <div class="sect3" lang="en">
976: <div class="titlepage"><div><div><h4 class="title">
977: <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
978: <p>When updating pkgsrc, the CVS program keeps track of the
979: branch you selected. But if you, for whatever reason, want to
980: switch from the stable branch to the current one, you can do it
981: by adding the option “<span class="quote">-A</span>” after the
982: “<span class="quote">update</span>” keyword. To switch from the current branch
983: back to the stable branch, add the
984: “<span class="quote">-rpkgsrc-2006Q1</span>” option.</p>
985: </div>
986: <div class="sect3" lang="en">
987: <div class="titlepage"><div><div><h4 class="title">
988: <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
989: <p>When you update pkgsrc, the CVS program will only touch
990: those files that are registered in the CVS repository. That
991: means that any packages that you created on your own will stay
992: unmodified. If you change files that are managed by CVS, later
993: updates will try to merge your changes with those that have been
994: done by others. See the CVS manual, chapter
995: “<span class="quote">update</span>” for details.</p>
996: </div>
997: </div>
998: </div>
999: </div>
1000: <div class="chapter" lang="en">
1001: <div class="titlepage"><div><div><h2 class="title">
1002: <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
1003: <div class="toc">
1004: <p><b>Table of Contents</b></p>
1005: <dl>
1.82 rillig 1006: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
1007: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
1008: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
1009: <dd><dl>
1010: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
1011: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
1012: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
1013: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
1014: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
1015: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
1016: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75 rillig 1017: </dl></dd>
1018: </dl>
1019: </div>
1020: <div class="sect1" lang="en">
1021: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82 rillig 1022: <a name="binarydist"></a>3.1. Binary distribution</h2></div></div></div>
1023: <p>
1024: We provide a bootstrap kit in both source and binary form for other
1025: platforms than NetBSD, consisting of the pkg administration tools and other
1026: tools required to use pkgsrc and build packages.
1027: </p>
1028: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1029: <h3 class="title">Note</h3>
1030: <p>
1031: Older binary snapshots are available in the
1032: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/archive/" target="_top">bootstrap-pkgsrc/archive</a>
1033: directory on ftp.NetBSD.org.</p>
1034: </div>
1035: <div class="table">
1036: <a name="binary-kits"></a><p class="title"><b>Table 3.1. Binary kits and available packages</b></p>
1.83 wiz 1037: <div class="table-contents"><table summary="Binary kits and available packages" border="1">
1.82 rillig 1038: <colgroup>
1039: <col>
1040: <col>
1041: <col>
1042: <col>
1043: </colgroup>
1044: <thead><tr>
1045: <th>Platform</th>
1046: <th>Latest snapshot</th>
1047: <th>Binary kit</th>
1048: <th>Binary packages</th>
1049: </tr></thead>
1050: <tbody>
1051: <tr>
1052: <td class="osname">Darwin 5.5/powerpc (Mac OS X 10.1.5)</td>
1053: <td class="date">20021209</td>
1054: <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>
1055: <td class="binary-pkgs-url"> </td>
1056: </tr>
1057: <tr>
1058: <td class="osname">Darwin 6.6/powerpc (Mac OS X 10.2.6)</td>
1059: <td class="date">20030623</td>
1060: <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>
1061: <td class="binary-pkgs-url"> </td>
1062: </tr>
1063: <tr>
1064: <td class="osname">Darwin 7.6/powerpc (Mac OS X 10.3.6)</td>
1065: <td class="date">20041219</td>
1066: <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>
1067: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/Darwin-7.6/" target="_top">binary packages</a></td>
1068: </tr>
1069: <tr>
1070: <td class="osname">Darwin 7.8/powerpc (Mac OS X 10.3.8)</td>
1071: <td class="date">20050320</td>
1072: <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>
1073: <td class="binary-pkgs-url"> </td>
1074: </tr>
1075: <tr>
1076: <td class="osname">Darwin 8.1/powerpc (Mac OS X 10.4.1)</td>
1077: <td class="date">20050625</td>
1078: <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>
1079: <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>
1080: </tr>
1081: <tr>
1082: <td class="osname">Debian GNU Linux/i386</td>
1083: <td class="date">20031023</td>
1084: <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>
1085: <td class="binary-pkgs-url"> </td>
1086: </tr>
1087: <tr>
1088: <td class="osname">Fedora Core 2 Linux/i386</td>
1089: <td class="date">20050618</td>
1090: <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>
1091: <td class="binary-pkgs-url"> </td>
1092: </tr>
1093: <tr>
1094: <td class="osname">Fedora Core 4 Linux/i386</td>
1095: <td class="date">20060105</td>
1096: <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>
1097: <td class="binary-pkgs-url"> </td>
1098: </tr>
1099: <tr>
1100: <td class="osname">FreeBSD 3.5/i386</td>
1101: <td class="date">20030411</td>
1102: <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>
1103: <td class="binary-pkgs-url"> </td>
1104: </tr>
1105: <tr>
1106: <td class="osname">FreeBSD 4.7/i386</td>
1107: <td class="date">20021211</td>
1108: <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>
1109: <td class="binary-pkgs-url"> </td>
1110: </tr>
1111: <tr>
1112: <td class="osname">FreeBSD 5.0/i386</td>
1113: <td class="date">20030411</td>
1114: <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>
1115: <td class="binary-pkgs-url"> </td>
1116: </tr>
1117: <tr>
1118: <td class="osname">FreeBSD 5.1/i386</td>
1119: <td class="date">20030630</td>
1120: <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>
1121: <td class="binary-pkgs-url"> </td>
1122: </tr>
1123: <tr>
1124: <td class="osname">FreeBSD 5.2.1/i386</td>
1125: <td class="date">20040227</td>
1126: <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>
1127: <td class="binary-pkgs-url"> </td>
1128: </tr>
1129: <tr>
1130: <td class="osname">FreeBSD 5.3/i386</td>
1131: <td class="date">20050119</td>
1132: <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>
1133: <td class="binary-pkgs-url"> </td>
1134: </tr>
1135: <tr>
1136: <td class="osname">Interix 3.5</td>
1137: <td class="date">20051010</td>
1138: <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>
1139: <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>
1140: </tr>
1141: <tr>
1142: <td class="osname">IRIX 6.5 n32-bit ABI</td>
1143: <td class="date">20040911</td>
1144: <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>
1145: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/n32/" target="_top">binary packages</a></td>
1146: </tr>
1147: <tr>
1148: <td class="osname">IRIX 6.5 64-bit ABI</td>
1149: <td class="date">20040912</td>
1150: <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>
1151: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/64/" target="_top">binary packages</a></td>
1152: </tr>
1153: <tr>
1154: <td class="osname">OpenBSD 3.2/i386</td>
1155: <td class="date">20030420</td>
1156: <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>
1157: <td class="binary-pkgs-url"> </td>
1158: </tr>
1159: <tr>
1160: <td class="osname">OpenBSD 3.3/i386</td>
1161: <td class="date">20030503</td>
1162: <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>
1163: <td class="binary-pkgs-url"> </td>
1164: </tr>
1165: <tr>
1166: <td class="osname">OpenBSD 3.5/i386</td>
1167: <td class="date">20040507</td>
1168: <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>
1169: <td class="binary-pkgs-url"> </td>
1170: </tr>
1171: <tr>
1172: <td class="osname">Slackware Linux 8.1/i386</td>
1173: <td class="date">20030417</td>
1174: <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>
1175: <td class="binary-pkgs-url"> </td>
1176: </tr>
1177: <tr>
1178: <td class="osname">Slackware Linux 9/i386</td>
1179: <td class="date">20031023</td>
1180: <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>
1181: <td class="binary-pkgs-url"> </td>
1182: </tr>
1183: <tr>
1184: <td class="osname">Solaris 8/sparc</td>
1185: <td class="date">20050220</td>
1186: <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>
1187: <td class="binary-pkgs-url"> </td>
1188: </tr>
1189: <tr>
1190: <td class="osname">Solaris 8/i386</td>
1191: <td class="date">20050220</td>
1192: <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>
1193: <td class="binary-pkgs-url"> </td>
1194: </tr>
1195: <tr>
1196: <td class="osname">Solaris 9/sparc</td>
1197: <td class="date">20041208</td>
1198: <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>
1199: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/SunOS-5.9/sparc/" target="_top">binary packages</a></td>
1200: </tr>
1201: <tr>
1202: <td class="osname">Solaris 9/i386</td>
1203: <td class="date">20030411</td>
1204: <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>
1205: <td class="binary-pkgs-url"> </td>
1206: </tr>
1207: </tbody>
1.83 wiz 1208: </table></div>
1.82 rillig 1209: </div>
1.83 wiz 1210: <br class="table-break"><p>
1.82 rillig 1211: Simply download the binary kit for your platform, and extract it into
1212: <code class="filename">/</code> e.g.
1213: </p>
1214: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
1215: <code class="prompt">#</code> <strong class="userinput"><code>gzip -c -d /tmp/bootstrap-pkgsrc-SunOS-5.9-sparc-20031023.tar.gz \
1216: | tar -xpf -</code></strong></pre>
1217: <p>
1218: Of course, as with any binary distributions, you should verify the
1219: checksum against the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/SUM" target="_top">SUM</a>
1220: or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/CKSUM" target="_top">CKSUM</a>
1221: file and inspect the contents before extracting it.
1222: </p>
1223: </div>
1224: <div class="sect1" lang="en">
1225: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1226: <a name="bootstrapping-pkgsrc"></a>3.2. Bootstrapping pkgsrc</h2></div></div></div>
1227: <p>Installing the bootstrap kit from source should be as simple as:</p>
1.75 rillig 1228: <pre class="screen">
1229: <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
1230: <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1.87 wiz 1231: <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong>
1232: </pre>
1.75 rillig 1233: <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
1.87 wiz 1234: pkgsrc before bootstrapping. The given
1235: <span><strong class="command">bootstrap</strong></span> command will use the defaults of
1236: <code class="filename">/usr/pkg</code> for the
1237: <span class="emphasis"><em>prefix</em></span> where programs will be installed in,
1238: and <code class="filename">/var/db/pkg</code> for the package database
1239: directory where pkgsrc will do its internal bookkeeping.
1240: However, these can also be set using command-line
1241: arguments.</p>
1.75 rillig 1242: <p>Binary packages for the pkgsrc tools and an initial set of packages is
1.87 wiz 1243: available for supported platforms. An up-to-date list of these can be
1244: found on <a href="http://www.pkgsrc.org/" target="_top">www.pkgsrc.org</a>.
1245: Note that this only works for privileged builds that install
1246: into <code class="filename">/usr/pkg</code>.</p>
1.75 rillig 1247: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1248: <h3 class="title">Note</h3>
1249: <p>The bootstrap installs a <span><strong class="command">bmake</strong></span> tool.
1.87 wiz 1250: Use this <span><strong class="command">bmake</strong></span> when building via pkgsrc.
1251: For examples in this guide, use <span><strong class="command">bmake</strong></span>
1252: instead of “<span class="quote">make</span>”.</p>
1.75 rillig 1253: </div>
1254: </div>
1255: <div class="sect1" lang="en">
1256: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82 rillig 1257: <a name="platform-specific-notes"></a>3.3. Platform-specific notes</h2></div></div></div>
1.75 rillig 1258: <p>Here are some platform-specific notes you should be aware of.</p>
1259: <div class="sect2" lang="en">
1260: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1261: <a name="darwin"></a>3.3.1. Darwin (Mac OS X)</h3></div></div></div>
1.85 jmmv 1262: <p>Darwin 5.x and up are supported. There are two methods of using
1.82 rillig 1263: pkgsrc on Mac OS X, by using a <a href="#platform.osx-image" title="3.3.1.1. Using a disk image">disk
1264: image</a>, or a <a href="#platform.osx-ufs" title="3.3.1.2. Using a UFS partition">UFS
1.75 rillig 1265: partition</a>.</p>
1266: <p>Before you start, you will need to download and install the Mac OS X Developer
1.87 wiz 1267: Tools from Apple's Developer Connection. See <a href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
1268: for details. Also, make sure you install X11 for Mac OS X and the X11 SDK
1269: from <a href="http://www.apple.com/macosx/x11/download/" target="_top">http://www.apple.com/macosx/x11/download/</a>
1270: if you intend to build packages that use the X11 Window System.</p>
1.75 rillig 1271: <p>If you already have a UFS partition, or have a spare partition
1.87 wiz 1272: that you can format as UFS, it is recommended to use that instead of
1273: the disk image. It'll be somewhat faster and will mount automatically
1274: at boot time, where you must manually mount a disk image.</p>
1.75 rillig 1275: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1276: <h3 class="title">Note</h3>
1.85 jmmv 1277: <p>You cannot use an ordinary HFS+ file system for pkgsrc, because pkgsrc currently
1278: requires the file system to be case-sensitive. You can, however, use a case-sensitive HFS+ file system as found in Darwin 7.0 and newer.</p>
1.75 rillig 1279: </div>
1280: <div class="sect3" lang="en">
1281: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1282: <a name="platform.osx-image"></a>3.3.1.1. Using a disk image</h4></div></div></div>
1.75 rillig 1283: <p>Create the disk image:</p>
1284: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1.85 jmmv 1285: <code class="prompt">#</code> <strong class="userinput"><code>./darwindiskimage create ~/Documents/NetBSD 512</code></strong> # megabytes - season to taste
1286: <code class="prompt">#</code> <strong class="userinput"><code>./darwindiskimage mount ~/Documents/NetBSD</code></strong>
1.75 rillig 1287: <code class="prompt">#</code> <strong class="userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong></pre>
1.85 jmmv 1288: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1289: <h3 class="title">Note</h3>
1290: <p>darwindiskimage will mount the filesystem nosuid, which will cause problems for packages that depend on setgid. It will also mount the filesystem asynchronous, which is somewhat dangerous according to the mount(8) man page.</p>
1291: </div>
1292: <p>Allow suid and synchronous writes:</p>
1293: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sudo mount -u -o suid,sync /Volumes/NetBSD</code></strong></pre>
1.75 rillig 1294: </div>
1295: <div class="sect3" lang="en">
1296: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1297: <a name="platform.osx-ufs"></a>3.3.1.2. Using a UFS partition</h4></div></div></div>
1.76 rillig 1298: <p>By default, <code class="filename">/usr</code> will be on your root file
1.87 wiz 1299: system, normally HFS+. It is possible to use the default
1300: <span class="emphasis"><em>prefix</em></span> of <code class="filename">/usr/pkg</code>
1301: by symlinking <code class="filename">/usr/pkg</code> to a directory on a UFS
1302: file system. Obviously, another symlink is required if you want to
1303: place the package database directory outside the
1304: <span class="emphasis"><em>prefix</em></span>. e.g.</p>
1.75 rillig 1305: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb</code></strong></pre>
1306: <p>If you created your partitions at the time of installing Mac OS X
1.87 wiz 1307: and formatted the target partition as UFS, it should automatically
1308: mount on <code class="filename">/Volumes/<volume name></code> when the
1309: machine boots. If you are (re)formatting a partition as UFS, you need
1310: to ensure that the partition map correctly reflects
1311: “<span class="quote">Apple_UFS</span>” and not “<span class="quote">Apple_HFS</span>”.</p>
1.75 rillig 1312: <p>The problem is that none of the disk tools will let you touch a
1.87 wiz 1313: disk that is booted from. You can unmount the partition, but even if
1314: you newfs it, the partition type will be incorrect and the
1315: automounter won't mount it. It can be mounted manually, but it won't
1316: appear in Finder.</p>
1.75 rillig 1317: <p>You'll need to boot off of the OS X Installation (User) CD. When
1.87 wiz 1318: the Installation program starts, go up to the menu and select Disk
1319: Utility. Now, you will be able to select the partition you want
1320: to be UFS, and Format it Apple UFS. Quit the Disk Utility, quit the
1321: installer which will reboot your machine. The new UFS file system
1322: will appear in Finder.</p>
1.75 rillig 1323: <p>Be aware that the permissions on the new file system will be writable
1.87 wiz 1324: by root only.</p>
1.75 rillig 1325: <p>This note is as of 10.2 (Jaguar) and applies to earlier versions.
1.87 wiz 1326: Hopefully Apple will fix Disk Utility in 10.3 (Panther).</p>
1.75 rillig 1327: </div>
1328: </div>
1329: <div class="sect2" lang="en">
1330: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1331: <a name="freebsd"></a>3.3.2. FreeBSD</h3></div></div></div>
1.87 wiz 1332: <p>FreeBSD 4.7 and 5.0 have been tested and are supported,
1333: other versions may work.</p>
1.75 rillig 1334: <p>Care should be taken so that the tools that this kit installs do not conflict
1.87 wiz 1335: with the FreeBSD userland tools. There are several steps:</p>
1.75 rillig 1336: <div class="orderedlist"><ol type="1">
1337: <li><p>FreeBSD stores its ports pkg database in
1.87 wiz 1338: <code class="filename">/var/db/pkg</code>. It is therefore
1339: recommended that you choose a different location (e.g.
1340: <code class="filename">/usr/pkgdb</code>) by
1341: using the --pkgdbdir option to the bootstrap script.</p></li>
1.75 rillig 1342: <li>
1343: <p>If you do not intend to use the FreeBSD ports tools, it's probably a
1.87 wiz 1344: good idea to move them out of the way to avoid confusion, e.g.</p>
1345: <pre class="screen">
1346: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1.75 rillig 1347: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1348: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1349: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1.87 wiz 1350: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong>
1351: </pre>
1.75 rillig 1352: </li>
1.76 rillig 1353: <li><p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1.87 wiz 1354: <code class="filename">/etc/mk.conf.example</code> file
1355: when you use the bootstrap script.</p></li>
1.75 rillig 1356: </ol></div>
1357: </div>
1358: <div class="sect2" lang="en">
1359: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1360: <a name="interix"></a>3.3.3. Interix</h3></div></div></div>
1.75 rillig 1361: <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
1.87 wiz 1362: providing a Unix-like environment with a tighter kernel integration than
1363: available with Cygwin. It is part of the Windows Services for Unix
1364: package, available for free for any licensed copy of Windows 2000, XP
1365: (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>
1.75 rillig 1366: <p>Services for Unix 3.5, current as of this writing, has been tested. 3.0
1.87 wiz 1367: or 3.1 may work, but are not officially supported. (The main difference
1368: in 3.0/3.1 is lack of pthreads.)</p>
1.75 rillig 1369: <div class="sect3" lang="en">
1370: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1371: <a name="platform.interix-sfu-install"></a>3.3.3.1. When installing Interix/SFU</h4></div></div></div>
1.75 rillig 1372: <p>At an absolute minimum, the following packages must be installed from
1.87 wiz 1373: the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
1.75 rillig 1374: <div class="itemizedlist"><ul type="disc">
1375: <li><p>Utilities -> Base Utilities</p></li>
1376: <li><p>Interix GNU Components -> (all)</p></li>
1377: <li><p>Remote Connectivity</p></li>
1378: <li><p>Interix SDK</p></li>
1379: </ul></div>
1380: <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
1.87 wiz 1381: "UNIX Perl". That is Perl 5.6 without shared module support, installed to
1382: /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
1383: pkgsrc (or from a binary package).</p>
1.75 rillig 1384: <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
1.87 wiz 1385: not need to be installed, but Remote Connectivity itself should be
1386: installed in order to have a working inetd.</p>
1.75 rillig 1387: <p>During installation you may be asked whether to enable setuid
1.87 wiz 1388: behavior for Interix programs, and whether to make pathnames default to
1389: case-sensitive. Setuid should be enabled, and case-sensitivity MUST be
1390: enabled. (Without case-sensitivity, a large number of packages including
1391: perl will not build.)</p>
1.75 rillig 1392: <p>NOTE: Newer Windows service packs change the way binary execution
1.87 wiz 1393: works (via the Data Execution Prevention feature). In order to use
1394: pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
1395: POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
1396: must be installed. Hotfixes are available from Microsoft through a
1397: support contract; however, a NetBSD developer has made most Interix
1398: 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>
1.75 rillig 1399: </div>
1400: <div class="sect3" lang="en">
1401: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1402: <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 1403: <p>If SFU is already installed and you wish to alter these settings to work
1.87 wiz 1404: with pkgsrc, note the following things.</p>
1.75 rillig 1405: <div class="itemizedlist"><ul type="disc">
1406: <li><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
1.87 wiz 1407: Windows Services for UNIX, then click Change. In the installer, choose
1408: Add or Remove, then uncheck Utilities->UNIX Perl.</p></li>
1.75 rillig 1409: <li>
1410: <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
1.87 wiz 1411: change the following registry key:</p>
1.75 rillig 1412: <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
1413: <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
1414: </li>
1415: <li>
1416: <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
1.87 wiz 1417: following registry key:</p>
1.75 rillig 1418: <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
1419: <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
1420: </li>
1421: </ul></div>
1422: </div>
1423: <div class="sect3" lang="en">
1424: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1425: <a name="platform.interix-notes"></a>3.3.3.3. Important notes for using pkgsrc</h4></div></div></div>
1.75 rillig 1426: <p>The package manager (either the pkgsrc "su" user, or the user
1.87 wiz 1427: running "pkg_add") must be a member of the local Administrators
1428: group. Such a user must also be used to run the bootstrap. This is
1429: slightly relaxed from the normal pkgsrc requirement of "root".</p>
1.75 rillig 1430: <p>The package manager should use a umask of 002. "make install" will
1.87 wiz 1431: automatically complain if this is not the case. This ensures that
1432: directories written in /var/db/pkg are Administrators-group writeable.</p>
1.75 rillig 1433: <p>The popular Interix binary packages from http://www.interopsystems.com/
1.87 wiz 1434: use an older version of pkgsrc's pkg_* tools. Ideally, these should
1435: NOT be used in conjunction with pkgsrc. If you choose to use them at
1436: the same time as the pkgsrc packages, ensure that you use the proper
1437: pkg_* tools for each type of binary package.</p>
1.75 rillig 1438: <p>The TERM setting used for DOS-type console windows (including those
1.87 wiz 1439: invoked by the csh and ksh startup shortcuts) is "interix". Most systems
1440: don't have a termcap/terminfo entry for it, but the following .termcap
1441: entry provides adequate emulation in most cases:</p>
1.75 rillig 1442: <pre class="programlisting">
1.87 wiz 1443: interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
1444: </pre>
1.75 rillig 1445: </div>
1446: <div class="sect3" lang="en">
1447: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1448: <a name="platform.interix-limits"></a>3.3.3.4. Limitations of the Interix platform</h4></div></div></div>
1.75 rillig 1449: <p>Though Interix suffices as a familiar and flexible substitute
1.87 wiz 1450: for a full Unix-like platform, it has some drawbacks that should
1451: be noted for those desiring to make the most of Interix.</p>
1.75 rillig 1452: <div class="itemizedlist"><ul type="disc">
1453: <li>
1454: <p><span class="strong"><strong>X11:</strong></span></p>
1455: <p>Interix comes with the standard set of X11R6 client libraries,
1.87 wiz 1456: and can run X11 based applications, but it does
1457: <span class="emphasis"><em>not</em></span> come with an X server. Some options are
1458: <a href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
1459: <a href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
1460: (available in a trimmed version for Interix from Interop Systems as the
1461: <a href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
1462: and the free X11 server included with
1463: <a href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
1.75 rillig 1464: <p>Also, StarNet Communications has graciously provided a free
1.87 wiz 1465: version of their X-Win32 product that accepts connections only
1466: from localhost:
1467: <a href="http://www.starnet.com/xwin32LX/get_xwin32LX.htm" target="_top">X-Win32 LX</a>,
1468: recommended by the maintainer of Interix pkgsrc support.</p>
1.75 rillig 1469: </li>
1470: <li>
1471: <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
1472: <p>Because Interix runs in a completely different NT subsystem from
1.87 wiz 1473: Win32 applications, it does not currently support various X11
1474: protocol extensions for acceleration (such as MIT-SHM or DGA).
1475: Most interactive applications to a local X server will run
1476: reasonably fast, but full motion video and other graphics
1477: intensive applications may require a faster-than-expected CPU.</p>
1.75 rillig 1478: </li>
1479: <li>
1480: <p><span class="strong"><strong>Audio:</strong></span></p>
1481: <p>Interix has no native support for audio output. For audio
1.87 wiz 1482: support, pkgsrc uses the <span><strong class="command">esound</strong></span> client/server
1483: audio system on Interix. Unlike on most platforms, the
1484: <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
1485: <span class="emphasis"><em>not</em></span> contain the <span><strong class="command">esd</strong></span>
1486: server component. To output audio via an Interix host, the
1487: <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
1488: must also be installed.</p>
1.75 rillig 1489: </li>
1490: <li>
1491: <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
1492: <p>Direct device access is not currently supported in Interix, so it
1.87 wiz 1493: is not currently possible to access CD/DVD drives, USB devices,
1494: or SCSI devices through non-filesystem means. Among other things,
1495: this makes it impossible to use Interix directly for CD/DVD
1496: burning.</p>
1.75 rillig 1497: </li>
1498: <li>
1499: <p><span class="strong"><strong>Tape drives:</strong></span></p>
1500: <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
1.87 wiz 1501: drives are also not directly accessible in Interix. However,
1502: support is in work to make tape drive access possible by using
1503: Cygwin as a bridge (similarly to audio bridged via Cygwin's
1504: esound server).</p>
1.75 rillig 1505: </li>
1506: </ul></div>
1507: </div>
1508: <div class="sect3" lang="en">
1509: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1510: <a name="platform.interix-knownissues"></a>3.3.3.5. Known issues for pkgsrc on Interix</h4></div></div></div>
1.75 rillig 1511: <p>It is not necessary, in general, to have a "root" user on the
1.87 wiz 1512: Windows system; any member of the local Administrators group will
1513: suffice. However, some packages currently assume that the user
1514: named "root" is the privileged user. To accommodate these, you
1515: may create such a user; make sure it is in the local group
1516: Administrators (or your language equivalent).</p>
1517: <p><span><strong class="command">pkg_add</strong></span> creates directories of mode
1518: 0755, not 0775, in <code class="filename">$PKG_DBDIR</code>. For the
1519: time being, install packages as the local Administrator (or
1520: your language equivalent), or run the following command after
1521: installing a package to work around the issue:</p>
1.75 rillig 1522: <pre class="screen">
1.87 wiz 1523: <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong>
1524: </pre>
1.75 rillig 1525: </div>
1526: </div>
1527: <div class="sect2" lang="en">
1528: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1529: <a name="irix"></a>3.3.4. IRIX</h3></div></div></div>
1.75 rillig 1530: <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
1.87 wiz 1531: compiler (cc/c89). Please set the <code class="varname">CC</code> environment variable
1532: according to your preference. If you do not have a license for the MIPSpro
1533: compiler suite, you can download a gcc tardist file from <a href="http://freeware.sgi.com/" target="_top">http://freeware.sgi.com/</a>.</p>
1.75 rillig 1534: <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
1.87 wiz 1535: 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>,
1536: etc.</p>
1.86 schwarz 1537: <p>At this point in time, pkgsrc only supports one ABI at a time. That is, you cannot
1.75 rillig 1538: switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI. If
1539: you start out using "abi=n32", that's what all your packages will be built
1540: with.</p>
1541: <p>Therefore, please make sure that you have no conflicting
1.87 wiz 1542: <code class="varname">CFLAGS</code> in your environment or the
1543: <code class="filename">/etc/mk.conf</code>. Particularly, make sure that you do not
1544: try to link n32 object files with lib64 or vice versa. Check your
1545: <code class="filename">/etc/compiler.defaults</code>!</p>
1.75 rillig 1546: <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
1.87 wiz 1547: please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
1548: as it appears that IRIX linker occasionally runs into issues when trying to
1549: link over a network-mounted file system.</p>
1.75 rillig 1550: <p>The bootstrapping process should set all the right options for programs such
1.87 wiz 1551: as imake(1), but you may want to set some options depending on your local
1552: setup. Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
1553: course, your compiler's man pages for details.</p>
1.75 rillig 1554: <p>If you are using SGI's MIPSPro compiler, please set
1.1 grant 1555:
1.87 wiz 1556: </p>
1.75 rillig 1557: <pre class="programlisting">
1.87 wiz 1558: PKGSRC_COMPILER= mipspro
1559: </pre>
1.75 rillig 1560: <p>
1.1 grant 1561:
1.87 wiz 1562: in <code class="filename">/etc/mk.conf</code>. Otherwise, pkgsrc will assume you
1563: are using gcc and may end up passing invalid flags to the compiler. Note that
1564: bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
1565: default.</p>
1.75 rillig 1566: <p>If you have both the MIPSPro compiler chain installed as well as gcc,
1.87 wiz 1567: but want to make sure that MIPRPro is used, please set your <code class="varname">PATH</code>
1568: to <span class="emphasis"><em>not</em></span> include the location of gcc (often
1569: <code class="filename">/usr/freeware/bin</code>), and (important) pass the
1570: '--preserve-path' flag.</p>
1.75 rillig 1571: </div>
1572: <div class="sect2" lang="en">
1573: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1574: <a name="linux"></a>3.3.5. Linux</h3></div></div></div>
1.87 wiz 1575: <p>Some versions of Linux (for example Debian GNU/Linux) need
1576: either libtermcap or libcurses (libncurses). Installing the
1577: distributions libncurses-dev package (or equivalent) should fix
1578: the problem.</p>
1579: <p>pkgsrc supports both gcc (GNU Compiler Collection) and icc
1580: (Intel C++ Compiler). gcc is the default. icc 8.0 and 8.1 on
1581: i386 have been tested.</p>
1.75 rillig 1582: <p>To bootstrap using icc, assuming the default icc installation
1.87 wiz 1583: directory:</p>
1.75 rillig 1584: <pre class="programlisting">
1.87 wiz 1585: env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
1586: ac_cv___attribute__=yes ./bootstrap
1587: </pre>
1.75 rillig 1588: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1589: <h3 class="title">Note</h3>
1590: <p>icc 8.1 needs the `-i-static' argument instead of -static-libcxa.</p>
1591: </div>
1592: <p>icc supports __attribute__, but the GNU configure test uses a nested
1.87 wiz 1593: function, which icc does not support. #undef'ing __attribute__ has the
1594: unfortunate side-effect of breaking many of the Linux header files, which
1595: cannot be compiled properly without __attribute__. The test must be
1596: overridden so that __attribute__ is assumed supported by the
1597: compiler.</p>
1.75 rillig 1598: <p>After bootstrapping, you should set <code class="varname">PKGSRC_COMPILER</code>
1.87 wiz 1599: in <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1600: <pre class="programlisting">
1.87 wiz 1601: PKGSRC_COMPILER= icc
1602: </pre>
1.75 rillig 1603: <p>The default installation directory for icc is
1.87 wiz 1604: <code class="filename">/opt/intel_cc_80</code>, which
1605: is also the pkgsrc default. If you have installed it into a different
1606: directory, set <code class="varname">ICCBASE</code> in
1607: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1608: <pre class="programlisting">
1.87 wiz 1609: ICCBASE= /opt/icc
1610: </pre>
1.75 rillig 1611: <p>pkgsrc uses the static linking method of the runtime libraries
1.87 wiz 1612: provided by icc, so binaries can be run on other systems which do not
1613: have the shared libraries installed.</p>
1614: <p>Libtool, however, extracts a list of libraries from the
1615: <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> command run when linking a C++ shared library and
1616: records it, throwing away the -Bstatic and -Bdynamic options
1617: interspersed between the libraries. This means that
1618: libtool-linked C++ shared libraries will have a runtime
1619: dependency on the icc libraries until this is fixed in
1620: libtool.</p>
1.75 rillig 1621: </div>
1622: <div class="sect2" lang="en">
1623: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1624: <a name="openbsd"></a>3.3.6. OpenBSD</h3></div></div></div>
1.75 rillig 1625: <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
1626: <p>Care should be taken so that the tools that this kit installs do not conflict
1.87 wiz 1627: with the OpenBSD userland tools. There are several steps:</p>
1.75 rillig 1628: <div class="orderedlist"><ol type="1">
1629: <li><p>OpenBSD stores its ports pkg database in
1.87 wiz 1630: <code class="filename">/var/db/pkg</code>. It is therefore
1631: recommended that you choose a different location (e.g.
1632: <code class="filename">/usr/pkgdb</code>) by
1633: using the --pkgdbdir option to the bootstrap script.</p></li>
1.75 rillig 1634: <li>
1635: <p>If you do not intend to use the OpenBSD ports tools, it's probably a
1.87 wiz 1636: good idea to move them out of the way to avoid confusion, e.g.</p>
1637: <pre class="screen">
1638: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1.75 rillig 1639: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1640: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1641: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1.87 wiz 1642: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong>
1643: </pre>
1.75 rillig 1644: </li>
1645: <li>
1.76 rillig 1646: <p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1.87 wiz 1647: <code class="filename">/etc/mk.conf.example</code> file
1648: when you use the bootstrap script. OpenBSD's make program uses
1649: <code class="filename">/etc/mk.conf</code>
1650: as well. You can work around this by enclosing all the pkgsrc-specific parts
1651: of the file with:</p>
1652: <pre class="programlisting">
1653: .ifdef BSD_PKG_MK
1654: # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
1655: .else
1656: # OpenBSD stuff
1657: .endif
1658: </pre>
1.75 rillig 1659: </li>
1660: </ol></div>
1661: </div>
1662: <div class="sect2" lang="en">
1663: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1664: <a name="solaris"></a>3.3.7. Solaris</h3></div></div></div>
1.75 rillig 1665: <p>Solaris 2.6 through 9 are supported on both x86 and sparc.
1.87 wiz 1666: You will need a working C compiler. Both gcc 2.95.3 and
1667: Sun WorkShop 5 have been tested.</p>
1.75 rillig 1668: <p>The following packages are required on Solaris 8 for the bootstrap
1.87 wiz 1669: process and to build packages.</p>
1.75 rillig 1670: <div class="itemizedlist"><ul type="disc">
1671: <li><p>SUNWsprot</p></li>
1672: <li><p>SUNWarc</p></li>
1673: <li><p>SUNWbtool</p></li>
1674: <li><p>SUNWtoo</p></li>
1675: <li><p>SUNWlibm</p></li>
1676: </ul></div>
1.78 rillig 1677: <p>Please note that the use of GNU binutils on Solaris is
1.87 wiz 1678: <span class="emphasis"><em>not</em></span> supported, as of June 2006.</p>
1.75 rillig 1679: <p>Whichever compiler you use, please ensure the compiler tools and
1.87 wiz 1680: your $prefix are in your <code class="varname">PATH</code>. This includes
1681: <code class="filename">/usr/ccs/{bin,lib}</code>
1682: and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1.75 rillig 1683: <div class="sect3" lang="en">
1684: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1685: <a name="solaris-gcc-note"></a>3.3.7.1. If you are using gcc</h4></div></div></div>
1.75 rillig 1686: <p>It makes life much simpler if you only use the same gcc consistently
1.87 wiz 1687: for building all packages.</p>
1.75 rillig 1688: <p>It is recommended that an external gcc be used only for bootstrapping,
1.87 wiz 1689: then either build gcc from
1690: <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
1691: package, then remove gcc used during bootstrapping.</p>
1.75 rillig 1692: <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>
1693: </div>
1694: <div class="sect3" lang="en">
1695: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1696: <a name="solaris-sun-workshop-note"></a>3.3.7.2. If you are using Sun WorkShop</h4></div></div></div>
1.75 rillig 1697: <p>You will need at least the following packages installed (from WorkShop
1.87 wiz 1698: 5.0)</p>
1.75 rillig 1699: <div class="itemizedlist"><ul type="disc">
1700: <li><p>SPROcc
1.87 wiz 1701: - Sun WorkShop Compiler C 5.0</p></li>
1.75 rillig 1702: <li><p>SPROcpl
1.87 wiz 1703: - Sun WorkShop Compiler C++ 5.0</p></li>
1.75 rillig 1704: <li><p>SPROild
1.87 wiz 1705: - Sun WorkShop Incremental Linker</p></li>
1.75 rillig 1706: <li><p>SPROlang
1.87 wiz 1707: - Sun WorkShop Compilers common components</p></li>
1.75 rillig 1708: </ul></div>
1709: <p>You should set <code class="varname">CC</code>, <code class="varname">CXX</code> and
1.87 wiz 1710: optionally, <code class="varname">CPP</code> in <code class="filename">/etc/mk.conf</code>,
1711: e.g.:</p>
1.75 rillig 1712: <pre class="programlisting">
1.87 wiz 1713: CC= cc
1714: CXX= CC
1715: CPP= /usr/ccs/lib/cpp
1716: </pre>
1.75 rillig 1717: </div>
1718: <div class="sect3" lang="en">
1719: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1720: <a name="solaris-sunpro-64"></a>3.3.7.3. Buildling 64-bit binaries with SunPro</h4></div></div></div>
1.75 rillig 1721: <p>Building 64-bit binaries is a little trickier. First, you
1722: need to bootstrap pkgsrc in 64-bit mode. One problem here is
1723: that while building one of the programs in the bootstrap kit
1.76 rillig 1724: (<code class="filename">bmake</code>), the <code class="varname">CFLAGS</code>
1.75 rillig 1725: variable is not honored, even if it is set in the environment.
1726: To work around this bug, you can create a simple shell script
1.76 rillig 1727: called <code class="filename">cc64</code> and put it somewhere in the
1.75 rillig 1728: <code class="varname">PATH</code>:</p>
1729: <pre class="programlisting">
1.87 wiz 1730: #! /bin/sh
1731: exec /opt/SUNWspro/bin/cc -xtarget=ultra -xarch=v9 ${1+"$@"}
1732: </pre>
1.75 rillig 1733: <p>Then, pass the definition for <code class="varname">CC</code> in the
1734: environment of the <span><strong class="command">bootstrap</strong></span> command:</p>
1735: <pre class="programlisting">
1.87 wiz 1736: <code class="prompt">$</code> <strong class="userinput"><code>cd bootstrap</code></strong>
1737: <code class="prompt">$</code> <strong class="userinput"><code>CC=cc64 ./bootstrap</code></strong>
1738: </pre>
1.75 rillig 1739: <p>After bootstrapping, there are two alternative ways,
1740: depending on whether you want to find bugs in packages or get
1741: your system ready quickly. If you just want a running system,
1.76 rillig 1742: add the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1743: file:</p>
1744: <pre class="programlisting">
1.87 wiz 1745: CC= cc64
1746: CXX= CC64
1747: PKGSRC_COMPILER= sunpro
1748: </pre>
1.75 rillig 1749: <p>This way, all calls to the compiler will be intercepted by
1750: the above wrapper and therefore get the necessary ABI options
1751: automatically. (Don't forget to create the shell script
1.76 rillig 1752: <code class="filename">CC64</code>, too.)</p>
1.75 rillig 1753: <p>To find packages that ignore the user-specified
1754: <code class="varname">CFLAGS</code> and <code class="varname">CXXFLAGS</code>, add
1.76 rillig 1755: the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1756: file:</p>
1757: <pre class="programlisting">
1.87 wiz 1758: CC= cc
1759: CXX= CC
1760: PKGSRC_COMPILER= sunpro
1761: CFLAGS= -xtarget=ultra -xarch=v9
1762: CXXFLAGS= -xtarget=ultra -xarch=v9
1763: LDFLAGS= -xtarget=ultra -xarch=v9
1764: </pre>
1.75 rillig 1765: <p>Packages that don't use the flags provided in the
1766: configuration file will try to build 32-bit binaries and fail
1767: during linking. Detecting this is useful to prevent bugs on
1768: other platforms where the error would not show up but pass
1769: silently.</p>
1770: </div>
1771: <div class="sect3" lang="en">
1772: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1773: <a name="plat.sunos.problems"></a>3.3.7.4. Common problems</h4></div></div></div>
1.75 rillig 1774: <p>Sometimes, when using <span><strong class="command">libtool</strong></span>,
1.87 wiz 1775: <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
1776: The workaround is to use another shell for the configure
1777: 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
1778: to your <code class="filename">mk.conf</code>:</p>
1779: <pre class="programlisting">
1780: CONFIG_SHELL= ${LOCALBASE}/bin/bash
1781: WRAPPER_SHELL= ${LOCALBASE}/bin/bash
1782: </pre>
1.76 rillig 1783: <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 1784: </div>
1785: </div>
1786: </div>
1787: </div>
1788: <div class="chapter" lang="en">
1789: <div class="titlepage"><div><div><h2 class="title">
1790: <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
1791: <div class="toc">
1792: <p><b>Table of Contents</b></p>
1793: <dl>
1794: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
1795: <dd><dl>
1796: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
1797: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82 rillig 1798: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
1799: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
1800: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
1801: <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>
1802: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
1803: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75 rillig 1804: </dl></dd>
1805: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
1806: <dd><dl>
1807: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
1808: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
1809: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
1810: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
1811: </dl></dd>
1812: </dl>
1813: </div>
1814: <p>Basically, there are two ways of using pkgsrc. The first
1.88 ! wiz 1815: is to only install the package tools and to use binary packages
! 1816: that someone else has prepared. This is the “<span class="quote">pkg</span>”
! 1817: in pkgsrc. The second way is to install the “<span class="quote">src</span>”
! 1818: of pkgsrc, too. Then you are able to build your own packages,
! 1819: and you can still use binary packages from someone else.</p>
1.75 rillig 1820: <div class="sect1" lang="en">
1821: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1822: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
1823: <p>To use binary packages, you need some tools to manage
1.88 ! wiz 1824: them. On NetBSD, these tools are already installed. On all other
! 1825: operating systems, you need to install them first. For the
! 1826: following platforms, prebuilt versions of the package tools
! 1827: are available and can simply be downloaded and unpacked in the
! 1828: <code class="filename">/</code> directory:</p>
1.75 rillig 1829: <div class="informaltable">
1830: <a name="binary-bootstrap-kits"></a><table border="1">
1831: <colgroup>
1832: <col>
1833: <col>
1834: </colgroup>
1835: <thead><tr>
1836: <th>Platform</th>
1837: <th>URL</th>
1838: </tr></thead>
1839: <tbody>
1840: <tr>
1841: <td>Solaris 9</td>
1.76 rillig 1842: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1843: </tr>
1844: <tr>
1845: <td>Solaris 10</td>
1.76 rillig 1846: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1847: </tr>
1848: </tbody>
1849: </table>
1850: </div>
1.82 rillig 1851: <p>These pre-built package tools use
1.88 ! wiz 1852: <code class="filename">/usr/pkg</code> for the base directory, and
! 1853: <code class="filename">/var/db/pkg</code> for the database of installed
! 1854: packages. If you cannot use these directories for whatever
! 1855: reasons (maybe because you're not root), you have to build the
! 1856: 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 1857: <div class="sect2" lang="en">
1858: <div class="titlepage"><div><div><h3 class="title">
1859: <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
1860: <p>To install binary packages, you first need to know from
1.88 ! wiz 1861: where to get them. You can get them on CD-ROMs, DVDs, or via FTP
! 1862: or HTTP.</p>
1.81 rillig 1863: <p>The binary packages can be found at the following
1.88 ! wiz 1864: locations.</p>
1.75 rillig 1865: <div class="informaltable">
1866: <a name="binary-packages"></a><table border="1">
1867: <colgroup>
1868: <col>
1869: <col>
1870: </colgroup>
1871: <thead><tr>
1872: <th>Platform</th>
1873: <th>URL</th>
1874: </tr></thead>
1875: <tbody>
1876: <tr>
1.81 rillig 1877: <td>NetBSD</td>
1878: <td><code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/</code></td>
1879: </tr>
1880: <tr>
1.75 rillig 1881: <td>Solaris 9</td>
1.76 rillig 1882: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/</code></td>
1.75 rillig 1883: </tr>
1884: <tr>
1885: <td>Solaris 10</td>
1.76 rillig 1886: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/</code></td>
1.75 rillig 1887: </tr>
1888: </tbody>
1889: </table>
1890: </div>
1.81 rillig 1891: <p>Most of these directories contain binary packages for
1.88 ! wiz 1892: multiple platforms. Select the appropriate subdirectories,
! 1893: according to your machine architecture and operating system,
! 1894: until you find a directory called <code class="filename">All</code>. This
! 1895: directory contains all the binary packages. Further, there are
! 1896: subdirectories for categories that contain symbolic links that
! 1897: point to the actual binary package in
! 1898: <code class="filename">../All</code>. This directory layout is used for
! 1899: all package repositories, no matter if they are accessed via
! 1900: HTTP, FTP, NFS, CD-ROM, or the local filesystem.</p>
1.75 rillig 1901: </div>
1902: <div class="sect2" lang="en">
1903: <div class="titlepage"><div><div><h3 class="title">
1904: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
1.87 wiz 1905: <p>If you have the files on a CD-ROM or downloaded them to
1.88 ! wiz 1906: your hard disk, you can install them with the following command
! 1907: (be sure to <span><strong class="command">su</strong></span> to root first):</p>
1.75 rillig 1908: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add /path/to/package.tgz</code></strong></pre>
1.87 wiz 1909: <p>If you have FTP access and you don't want to download the
1.88 ! wiz 1910: packages via FTP prior to installation, you can do this
! 1911: automatically by giving <span><strong class="command">pkg_add</strong></span> an FTP URL:</p>
1.82 rillig 1912: <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 1913: <p>Note that any prerequisite packages needed to run the
1.88 ! wiz 1914: package in question will be installed, too, assuming they are
! 1915: present where you install from.</p>
1.75 rillig 1916: <p>To save some typing, you can set the
1.88 ! wiz 1917: <code class="varname">PKG_PATH</code> environment variable to a semicolon-separated
! 1918: list of paths (including remote URLs); trailing slashes are not allowed.
! 1919: </p>
1.76 rillig 1920: <p>Additionally to the <code class="filename">All</code> directory
1.88 ! wiz 1921: there exists a <code class="filename">vulnerable</code> directory to
! 1922: which binary packages with known vulnerabilities are
! 1923: moved, since removing them could cause missing dependencies. To
! 1924: use these packages, add the <code class="filename">vulnerable</code>
! 1925: directory to your <code class="varname">PKG_PATH</code>. However, you should run
! 1926: <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,
! 1927: especially after installing new packages, and verify that the
! 1928: vulnerabilities are acceptable for your configuration. An example
! 1929: <code class="varname">PKG_PATH</code> would be:
! 1930: <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/<OSVERSION>/<ARCH>/All;ftp://ftp.NetBSD.org/pub/NetBSD/packages/<OSVERSION>/<ARCH>/vulnerable</code>
! 1931: Please note that semicolon (';') is a shell meta-character, so
! 1932: you'll probably have to quote it.</p>
1.75 rillig 1933: <p>After you've installed packages, be sure to have
1.88 ! wiz 1934: <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
! 1935: <code class="varname">PATH</code> so you can actually start the just
! 1936: installed program.</p>
1.75 rillig 1937: </div>
1938: <div class="sect2" lang="en">
1939: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1940: <a name="using.pkg_delete"></a>4.1.3. Deinstalling packages</h3></div></div></div>
1941: <p>To deinstall a package, it does not matter whether it was
1.88 ! wiz 1942: installed from source code or from a binary package. The
! 1943: <span><strong class="command">pkg_delete</strong></span> command does not know it anyway.
! 1944: To delete a package, you can just run <span><strong class="command">pkg_delete
! 1945: <em class="replaceable"><code>package-name</code></em></strong></span>. The package
! 1946: name can be given with or without version number. Wildcards can
! 1947: also be used to deinstall a set of packages, for example
! 1948: <code class="literal">*emacs*</code>. Be sure to include them in quotes,
! 1949: so that the shell does not expand them before
! 1950: <code class="literal">pkg_delete</code> sees them.</p>
1.82 rillig 1951: <p>The <code class="option">-r</code> option is very powerful: it
1.88 ! wiz 1952: removes all the packages that require the package in question
! 1953: and then removes the package itself. For example:
1.82 rillig 1954:
1.88 ! wiz 1955: </p>
1.82 rillig 1956: <pre class="screen">
1.88 ! wiz 1957: <code class="prompt">#</code> <strong class="userinput"><code>pkg_delete -r jpeg</code></strong>
! 1958: </pre>
1.82 rillig 1959: <p>
1960:
1.88 ! wiz 1961: will remove jpeg and all the packages that used it; this allows
! 1962: upgrading the jpeg package.</p>
1.82 rillig 1963: </div>
1964: <div class="sect2" lang="en">
1965: <div class="titlepage"><div><div><h3 class="title">
1966: <a name="using.pkg_info"></a>4.1.4. Getting information about installed packages</h3></div></div></div>
1967: <p>The <span><strong class="command">pkg_info</strong></span> shows information about
1.88 ! wiz 1968: installed packages or binary package files.</p>
1.82 rillig 1969: </div>
1970: <div class="sect2" lang="en">
1971: <div class="titlepage"><div><div><h3 class="title">
1972: <a name="vulnerabilities"></a>4.1.5. Checking for security vulnerabilities in installed packages</h3></div></div></div>
1973: <p>
1.88 ! wiz 1974: The NetBSD Security-Officer and Packages Groups maintain a list of
! 1975: known security vulnerabilities to packages which are (or have been)
! 1976: included in pkgsrc. The list is available from the NetBSD
! 1977: FTP site at <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities</a>.
! 1978: </p>
1.82 rillig 1979: <p>
1.88 ! wiz 1980: 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>,
! 1981: this list can be downloaded
! 1982: automatically, and a security audit of all packages installed on a system
! 1983: can take place.
! 1984: </p>
1.82 rillig 1985: <p>
1.88 ! wiz 1986: There are two components to
! 1987: <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
! 1988: component, “<span class="quote">download-vulnerability-list</span>”, is for downloading
! 1989: the list of vulnerabilities from the NetBSD FTP site. The second
! 1990: component, “<span class="quote">audit-packages</span>”, checks to see if any of your
! 1991: installed packages are vulnerable. If a package is vulnerable, you
! 1992: will see output similar to the following:
! 1993: </p>
1.82 rillig 1994: <pre class="screen">Package samba-2.0.9 has a local-root-shell vulnerability, see
1.88 ! wiz 1995: http://www.samba.org/samba/whatsnew/macroexploit.html</pre>
1.82 rillig 1996: <p>
1.88 ! wiz 1997: 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
! 1998: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">vulnerabilities</a>
! 1999: file daily, and include a package audit in the daily security script.
! 2000: 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>
! 2001: 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>.
! 2002: </p>
1.82 rillig 2003: </div>
2004: <div class="sect2" lang="en">
2005: <div class="titlepage"><div><div><h3 class="title">
2006: <a name="pkg_versions"></a>4.1.6. Finding if newer versions of your installed packages are in pkgsrc</h3></div></div></div>
2007: <p>
1.88 ! wiz 2008: 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
! 2009: <span><strong class="command">lintpkgsrc</strong></span> with the “<span class="quote">-i</span>”
! 2010: argument to check if your packages are up-to-date, e.g.
! 2011: </p>
! 2012: <pre class="screen">
! 2013: <code class="prompt">%</code> <strong class="userinput"><code>lintpkgsrc -i</code></strong>
1.82 rillig 2014: ...
1.88 ! wiz 2015: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
! 2016: </pre>
1.82 rillig 2017: <p>You can then use <span><strong class="command">make update</strong></span> to update the
1.88 ! wiz 2018: package on your system and rebuild any dependencies.
! 2019: </p>
1.82 rillig 2020: </div>
2021: <div class="sect2" lang="en">
2022: <div class="titlepage"><div><div><h3 class="title">
2023: <a name="using.pkg_admin"></a>4.1.7. Other administrative functions</h3></div></div></div>
2024: <p>The <span><strong class="command">pkg_admin</strong></span> executes various
1.88 ! wiz 2025: administrative functions on the package system.</p>
1.82 rillig 2026: </div>
2027: <div class="sect2" lang="en">
2028: <div class="titlepage"><div><div><h3 class="title">
2029: <a name="a-word-of-warning"></a>4.1.8. A word of warning</h3></div></div></div>
1.75 rillig 2030: <p>Please pay very careful attention to the warnings
1.88 ! wiz 2031: 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
! 2032: inherent dangers of installing binary packages which you did
! 2033: not create yourself, and the security holes that can be
! 2034: introduced onto your system by indiscriminate adding of such
! 2035: files.</p>
1.75 rillig 2036: <p>The same warning of course applies to every package you
1.88 ! wiz 2037: install from source when you haven't completely read and
! 2038: understood the source code of the package, the compiler that
! 2039: is used to build the package and all the other tools that are
! 2040: involved.</p>
1.75 rillig 2041: </div>
2042: </div>
2043: <div class="sect1" lang="en">
2044: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2045: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
1.88 ! wiz 2046: <p>After obtaining pkgsrc, the <code class="filename">pkgsrc</code>
! 2047: directory now contains a set of packages, organized into
! 2048: categories. You can browse the online index of packages, or run
! 2049: <span><strong class="command">make readme</strong></span> from the <code class="filename">pkgsrc</code>
! 2050: directory to build local <code class="filename">README.html</code> files for
! 2051: all packages, viewable with any web browser such as <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/lynx/README.html" target="_top"><code class="filename">www/lynx</code></a> or <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a>.</p>
! 2052: <p>The default <span class="emphasis"><em>prefix</em></span> for installed packages
! 2053: is <code class="filename">/usr/pkg</code>. If you wish to change this, you
! 2054: should do so by setting <code class="varname">LOCALBASE</code> in
! 2055: <code class="filename">mk.conf</code>. You should not try to use multiple
! 2056: different <code class="varname">LOCALBASE</code> definitions on the same
! 2057: system (inside a chroot is an exception). </p>
! 2058: <p>The rest of this chapter assumes that the package is already
! 2059: in pkgsrc. If it is not, see <a href="#developers-guide" title="Part II. The pkgsrc developer's guide">Part II, “The pkgsrc developer's guide”</a> for
! 2060: instructions how to create your own packages.</p>
1.75 rillig 2061: <div class="sect2" lang="en">
2062: <div class="titlepage"><div><div><h3 class="title">
2063: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
1.82 rillig 2064: <p>To build packages from source, you need a working C
1.88 ! wiz 2065: compiler. On NetBSD, you need to install the
! 2066: “<span class="quote">comp</span>” and the “<span class="quote">text</span>” distribution
! 2067: sets. If you want to build X11-related packages, the
! 2068: “<span class="quote">xbase</span>” and “<span class="quote">xcomp</span>” distribution
! 2069: sets are required, too.</p>
1.75 rillig 2070: </div>
2071: <div class="sect2" lang="en">
2072: <div class="titlepage"><div><div><h3 class="title">
2073: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
2074: <p>The first step for building a package is downloading the
1.88 ! wiz 2075: distfiles (i.e. the unmodified source). If they have not yet been
! 2076: downloaded, pkgsrc will fetch them automatically.</p>
! 2077: <p>If you have all files that you need in the
! 2078: <code class="filename">distfiles</code> directory,
! 2079: you don't need to connect. If the distfiles are on CD-ROM, you can
! 2080: mount the CD-ROM on <code class="filename">/cdrom</code> and add:
! 2081: </p>
1.82 rillig 2082: <pre class="screen">DISTDIR=/cdrom/pkgsrc/distfiles</pre>
2083: <p>
1.88 ! wiz 2084: to your <code class="filename">mk.conf</code>.</p>
! 2085: <p>You can overwrite some of the major distribution sites to
! 2086: fit to sites that are close to your own. By setting one or two
! 2087: variables you can modify the order in which the master sites are
! 2088: accessed. <code class="varname">MASTER_SORT</code> contains a whitespace
! 2089: delimited list of domain suffixes.
! 2090: <code class="varname">MASTER_SORT_REGEX</code> is even more flexible, it
! 2091: contains a whitespace delimited list of regular expressions. It
! 2092: has higher priority than <code class="varname">MASTER_SORT</code>. Have a
! 2093: look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find
! 2094: some examples. This may save some of your bandwidth and
! 2095: time.</p>
1.75 rillig 2096: <p>You can change these settings either in your shell's environment, or,
1.88 ! wiz 2097: if you want to keep the settings, by editing the
! 2098: <code class="filename">/etc/mk.conf</code> file,
! 2099: and adding the definitions there.</p>
1.82 rillig 2100: <p>
1.88 ! wiz 2101: If a package depends on many other packages (such as
! 2102: <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
! 2103: alternate between periods of
! 2104: downloading source, and compiling. To ensure you have all the source
! 2105: downloaded initially you can run the command:
! 2106: </p>
1.82 rillig 2107: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch-list | sh</code></strong></pre>
2108: <p>
1.88 ! wiz 2109: which will output and run a set of shell commands to fetch the
! 2110: necessary files into the <code class="filename">distfiles</code> directory. You can
! 2111: also choose to download the files manually.
! 2112: </p>
1.75 rillig 2113: </div>
2114: <div class="sect2" lang="en">
2115: <div class="titlepage"><div><div><h3 class="title">
2116: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
1.82 rillig 2117: <p>
1.88 ! wiz 2118: Once the software has downloaded, any patches will be applied, then it
! 2119: will be compiled for you. This may take some time depending on your
! 2120: computer, and how many other packages the software depends on and their
! 2121: compile time.
! 2122: </p>
1.75 rillig 2123: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
2124: <h3 class="title">Note</h3>
2125: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
1.88 ! wiz 2126: use the pkgsrc <span><strong class="command">bmake</strong></span> command instead of
! 2127: “<span class="quote">make</span>” in the examples in this guide.</p>
1.75 rillig 2128: </div>
1.87 wiz 2129: <p>For example, type</p>
1.88 ! wiz 2130: <pre class="screen">
! 2131: <code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
! 2132: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
! 2133: </pre>
1.75 rillig 2134: <p>at the shell prompt to build the various components of the
1.88 ! wiz 2135: package.</p>
1.82 rillig 2136: <p>The next stage is to actually install the newly compiled
1.88 ! wiz 2137: program onto your system. Do this by entering:
1.82 rillig 2138:
1.88 ! wiz 2139: </p>
1.82 rillig 2140: <pre class="screen">
1.88 ! wiz 2141: <code class="prompt">%</code> <strong class="userinput"><code>make install</code></strong>
! 2142: </pre>
1.82 rillig 2143: <p>
2144:
1.88 ! wiz 2145: while you are still in the directory for whatever package you
! 2146: are installing.</p>
1.82 rillig 2147: <p>Installing the package on your system may require you to
1.88 ! wiz 2148: be root. However, pkgsrc has a
! 2149: <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
! 2150: to only become root for the actual installation step.</p>
1.82 rillig 2151: <p>That's it, the software should now be installed and setup for use.
1.88 ! wiz 2152: You can now enter:
1.82 rillig 2153:
1.88 ! wiz 2154: </p>
1.82 rillig 2155: <pre class="screen">
1.88 ! wiz 2156: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong>
! 2157: </pre>
1.82 rillig 2158: <p>
2159:
1.88 ! wiz 2160: to remove the compiled files in the work directory, as you shouldn't need
! 2161: them any more. If other packages were also added to your system
! 2162: (dependencies) to allow your program to compile, you can tidy these up
! 2163: also with the command:</p>
1.82 rillig 2164: <pre class="screen">
1.88 ! wiz 2165: <code class="prompt">%</code> <strong class="userinput"><code>make clean-depends</code></strong>
! 2166: </pre>
1.75 rillig 2167: <p>Taking the figlet utility as an example, we can install it on our
1.88 ! wiz 2168: system by building as shown in <a href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
! 2169: <p>The program is installed under the default root of the
! 2170: packages tree - <code class="filename">/usr/pkg</code>. Should this not
! 2171: conform to your tastes, set the <code class="varname">LOCALBASE</code>
! 2172: variable in your environment, and it will use that value as the
! 2173: root of your packages tree. So, to use
! 2174: <code class="filename">/usr/local</code>, set
! 2175: <code class="varname">LOCALBASE=/usr/local</code> in your environment.
! 2176: Please note that you should use a directory which is dedicated to
! 2177: packages and not shared with other programs (i.e., do not try and
! 2178: use <code class="varname">LOCALBASE=/usr</code>). Also, you should not try
! 2179: to add any of your own files or directories (such as
! 2180: <code class="filename">src/</code>, <code class="filename">obj/</code>, or
! 2181: <code class="filename">pkgsrc/</code>) below the
! 2182: <code class="varname">LOCALBASE</code> tree. This is to prevent possible
! 2183: conflicts between programs and other files installed by the
! 2184: package system and whatever else may have been installed
! 2185: there.</p>
! 2186: <p>Some packages look in <code class="filename">/etc/mk.conf</code> to
! 2187: alter some configuration options at build time. Have a look at
! 2188: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to get an overview
! 2189: of what will be set there by default. Environment variables such
! 2190: as <code class="varname">LOCALBASE</code> can be set in
! 2191: <code class="filename">/etc/mk.conf</code> to save having to remember to
! 2192: set them each time you want to use pkgsrc.</p>
! 2193: <p>Occasionally, people want to “<span class="quote">look under the
! 2194: covers</span>” to see what is going on when a package is building
! 2195: or being installed. This may be for debugging purposes, or out of
! 2196: simple curiosity. A number of utility values have been added to
! 2197: help with this.</p>
1.75 rillig 2198: <div class="orderedlist"><ol type="1">
2199: <li>
1.88 ! wiz 2200: <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
! 2201: <code class="varname">PKG_DEBUG_LEVEL=2</code>, then a huge amount of
! 2202: information will be displayed. For example,</p>
1.75 rillig 2203: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
1.88 ! wiz 2204: <p>will show all the commands that are invoked, up to and
! 2205: including the “<span class="quote">patch</span>” stage.</p>
1.75 rillig 2206: </li>
2207: <li>
1.88 ! wiz 2208: <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>
! 2209: definition, then the <code class="varname">VARNAME</code> definition
! 2210: should be used, in conjunction with the show-var
! 2211: 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>
! 2212: variable <code class="varname">LOCALBASE</code>:</p>
! 2213: <pre class="screen">
! 2214: <code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
1.75 rillig 2215: /usr/pkg
2216: <code class="prompt">%</code>
1.88 ! wiz 2217: </pre>
1.75 rillig 2218: </li>
2219: </ol></div>
2220: <p>If you want to install a binary package that you've either
1.88 ! wiz 2221: created yourself (see next section), that you put into
! 2222: pkgsrc/packages manually or that is located on a remote FTP
! 2223: server, you can use the "bin-install" target. This target will
! 2224: install a binary package - if available - 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>,
! 2225: else do a <span><strong class="command">make package</strong></span>. The list of remote FTP
! 2226: sites searched is kept in the variable
! 2227: <code class="varname">BINPKG_SITES</code>, which defaults to
! 2228: 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>
! 2229: can be put into <code class="varname">BIN_INSTALL_FLAGS</code>. See
! 2230: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more
! 2231: details.</p>
! 2232: <p>A final word of warning: If you set up a system that has a
! 2233: non-standard setting for <code class="varname">LOCALBASE</code>, be sure to
! 2234: set that before any packages are installed, as you cannot use
! 2235: several directories for the same purpose. Doing so will result in
! 2236: pkgsrc not being able to properly detect your installed packages,
! 2237: and fail miserably. Note also that precompiled binary packages are
! 2238: usually built with the default <code class="varname">LOCALBASE</code> of
! 2239: <code class="filename">/usr/pkg</code>, and that you should
! 2240: <span class="emphasis"><em>not</em></span> install any if you use a non-standard
! 2241: <code class="varname">LOCALBASE</code>.</p>
1.75 rillig 2242: </div>
2243: <div class="sect2" lang="en">
2244: <div class="titlepage"><div><div><h3 class="title">
2245: <a name="selecting-the-compiler"></a>4.2.4. Selecting the compiler</h3></div></div></div>
2246: <p>By default, pkgsrc will use GCC to build packages. This may be
1.88 ! wiz 2247: overridden by setting the following variables in /etc/mk.conf:</p>
1.75 rillig 2248: <div class="variablelist"><dl>
2249: <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
2250: <dd>
1.87 wiz 2251: <p>This is a list of values specifying the chain of
1.88 ! wiz 2252: compilers to invoke when building packages. Valid values
! 2253: are:</p>
1.75 rillig 2254: <div class="itemizedlist"><ul type="disc">
2255: <li><p><code class="varname">distcc</code>:
1.88 ! wiz 2256: distributed C/C++ (chainable)</p></li>
1.75 rillig 2257: <li><p><code class="varname">ccache</code>:
1.88 ! wiz 2258: compiler cache (chainable)</p></li>
1.75 rillig 2259: <li><p><code class="varname">gcc</code>:
1.88 ! wiz 2260: GNU C/C++ Compiler</p></li>
1.75 rillig 2261: <li><p><code class="varname">mipspro</code>:
1.88 ! wiz 2262: Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
1.75 rillig 2263: <li><p><code class="varname">mipspro</code>:
1.88 ! wiz 2264: Silicon Graphics, Inc. MIPSpro (o32)</p></li>
1.75 rillig 2265: <li><p><code class="varname">sunpro</code>:
1.88 ! wiz 2266: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
1.75 rillig 2267: </ul></div>
1.87 wiz 2268: <p>The default is
1.88 ! wiz 2269: “<span class="quote"><code class="varname">gcc</code></span>”. You can use
! 2270: <code class="varname">ccache</code> and/or
! 2271: <code class="varname">distcc</code> with an appropriate
! 2272: <code class="varname">PKGSRC_COMPILER</code> setting,
! 2273: e.g. “<span class="quote"><code class="varname">ccache gcc</code></span>”. This
! 2274: variable should always be
! 2275: terminated with a value for a real compiler.</p>
1.75 rillig 2276: </dd>
2277: <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
1.87 wiz 2278: <dd><p>This specifies the minimum version of GCC to use
1.88 ! wiz 2279: when building packages. If the system GCC doesn't
! 2280: satisfy this requirement, then pkgsrc will build and
! 2281: install one of the GCC packages to use instead.</p></dd>
1.75 rillig 2282: </dl></div>
2283: </div>
2284: </div>
2285: </div>
2286: <div class="chapter" lang="en">
2287: <div class="titlepage"><div><div><h2 class="title">
2288: <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
2289: <div class="toc">
2290: <p><b>Table of Contents</b></p>
2291: <dl>
2292: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
2293: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 2294: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
1.88 ! wiz 2295: <dd><dl>
! 2296: <dt><span class="sect2"><a href="#conf.cflags">5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
! 2297: <dt><span class="sect2"><a href="#conf.ldflags">5.3.2. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
! 2298: </dl></dd>
1.78 rillig 2299: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
2300: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 2301: </dl>
2302: </div>
2303: <div class="sect1" lang="en">
2304: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2305: <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
2306: <p>In this section, you can find some variables that apply to all
1.82 rillig 2307: pkgsrc packages. The preferred method of setting these variables is
2308: by setting them in <code class="filename">/etc/mk.conf</code>. A complete
2309: list of the variables that can be configured by the user is
2310: available in <code class="filename">mk/defaults/mk.conf</code>, together with
2311: some comments that describe the variable's intent.</p>
1.75 rillig 2312: <div class="itemizedlist"><ul type="disc">
2313: <li><p><code class="varname">LOCALBASE</code>: Where
2314: packages will be installed. The default is
1.76 rillig 2315: <code class="filename">/usr/pkg</code>. Do not mix binary packages
1.75 rillig 2316: with different <code class="varname">LOCALBASE</code>s!</p></li>
2317: <li><p><code class="varname">CROSSBASE</code>: Where
2318: “<span class="quote">cross</span>” category packages will be
2319: installed. The default is
1.76 rillig 2320: <code class="filename">${LOCALBASE}/cross</code>.</p></li>
1.75 rillig 2321: <li><p><code class="varname">X11BASE</code>: Where
2322: X11 is installed on the system. The default is
1.76 rillig 2323: <code class="filename">/usr/X11R6</code>.</p></li>
1.75 rillig 2324: <li><p><code class="varname">DISTDIR</code>: Where to store the
2325: downloaded copies of the original source distributions used
2326: for building pkgsrc packages. The default is
1.76 rillig 2327: <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
1.75 rillig 2328: <li><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
2329: If set, override the packages'
2330: <code class="varname">MASTER_SITES</code> with this value.</p></li>
2331: <li><p><code class="varname">MASTER_SITE_BACKUP</code>:
2332: Backup location(s) for distribution files and patch files
2333: if not found locally or in
1.76 rillig 2334: <code class="filename">${MASTER_SITES}</code> or
2335: <code class="filename">${PATCH_SITES}</code> respectively.
1.75 rillig 2336: The defaults are
1.76 rillig 2337: <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
1.75 rillig 2338: and
1.76 rillig 2339: <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
1.75 rillig 2340: <li><p><code class="varname">BINPKG_SITES</code>:
2341: List of sites carrying binary pkgs.</p></li>
1.82 rillig 2342: <li><p><code class="varname">ACCEPTABLE_LICENSES</code>:
2343: List of acceptable licenses. Whenever you try to build a package
2344: whose license is not in this list, you will get an error message
2345: that includes instructions on how to change this variable.</p></li>
1.75 rillig 2346: </ul></div>
2347: </div>
2348: <div class="sect1" lang="en">
2349: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2350: <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
2351: <p>XXX
2352: </p>
2353: <div class="itemizedlist"><ul type="disc">
2354: <li><p><code class="varname">PACKAGES</code>: The top level
2355: directory for the binary packages. The default is
1.76 rillig 2356: <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
1.75 rillig 2357: <li><p><code class="varname">WRKOBJDIR</code>:
2358: The top level directory where, if defined, the separate
2359: working directories will get created, and symbolically
1.76 rillig 2360: linked to from <code class="filename">${WRKDIR}</code> (see below).
1.75 rillig 2361: This is useful for building packages on several
1.76 rillig 2362: architectures, then <code class="filename">${PKGSRCDIR}</code>
2363: can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
1.75 rillig 2364: is local to every architecture. (It should be noted that
2365: <code class="varname">PKGSRCDIR</code> should not be set by the user
1.87 wiz 2366: — it is an internal definition which refers to the
1.75 rillig 2367: root of the pkgsrc tree. It is possible to have many
2368: pkgsrc tree instances.)</p></li>
2369: <li><p><code class="varname">LOCALPATCHES</code>:
2370: Directory for local patches that aren't part of pkgsrc.
1.77 rillig 2371: See <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a> for more
1.75 rillig 2372: information. <em class="replaceable"><code>rel</code></em> and
2373: <em class="replaceable"><code>arch</code></em> are replaced with OS
2374: release (“<span class="quote">2.0</span>”, etc.) and architecture
2375: (“<span class="quote">mipsel</span>”, etc.).</p></li>
2376: <li><p><code class="varname">PKGMAKECONF</code>: Location of
1.76 rillig 2377: the <code class="filename">mk.conf</code> file used by a package's
1.75 rillig 2378: BSD-style Makefile. If this is not set,
2379: <code class="varname">MAKECONF</code> is set to
1.76 rillig 2380: <code class="filename">/dev/null</code> to avoid picking up
2381: settings used by builds in <code class="filename">/usr/src</code>.</p></li>
1.82 rillig 2382: <li><p><code class="varname">DEPENDS_TARGET</code>:
2383: By default, dependencies are only installed, and no binary
2384: package is created for them. You can set this variable to
2385: <code class="literal">package</code> to automatically create binary
2386: packages after installing dependencies.</p></li>
1.75 rillig 2387: </ul></div>
2388: </div>
2389: <div class="sect1" lang="en">
2390: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 2391: <a name="conf.compiler"></a>5.3. Selecting and configuring the compiler</h2></div></div></div>
2392: <div class="sect2" lang="en">
2393: <div class="titlepage"><div><div><h3 class="title">
2394: <a name="conf.cflags"></a>5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</h3></div></div></div>
2395: <p>If you wish to set the <code class="varname">CFLAGS</code> variable,
2396: please make sure to use the <code class="literal">+=</code> operator
2397: instead of the <code class="literal">=</code> operator:</p>
2398: <pre class="programlisting">
2399: CFLAGS+= -your -flags
2400: </pre>
2401: <p>Using <code class="varname">CFLAGS=</code> (i.e. without the
2402: “<span class="quote">+</span>”) may lead to problems with packages that need
2403: to add their own flags. Also, you may want to take a look at
2404: 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
2405: you're interested in optimization for the current CPU.</p>
2406: </div>
1.88 ! wiz 2407: <div class="sect2" lang="en">
! 2408: <div class="titlepage"><div><div><h3 class="title">
! 2409: <a name="conf.ldflags"></a>5.3.2. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</h3></div></div></div>
! 2410: <p>If you want to pass flags to the linker, both in the configure
! 2411: step and the build step, you can do this in two ways. Either set
! 2412: <code class="varname">LDFLAGS</code> or <code class="varname">LIBS</code>. The difference
! 2413: between the two is that <code class="varname">LIBS</code> will be appended to
! 2414: the command line, while <code class="varname">LDFLAGS</code> come earlier.
! 2415: <code class="varname">LDFLAGS</code> is pre-loaded with rpath settings for ELF
! 2416: machines depending on the setting of <code class="varname">USE_IMAKE</code> or
! 2417: the inclusion of <code class="filename">mk/x11.buildlink3.mk</code>. As with
! 2418: <code class="varname">CFLAGS</code>, if you do not wish to override these
! 2419: settings, use the <code class="literal">+=</code> operator:</p>
! 2420: <pre class="programlisting">
! 2421: LDFLAGS+= -your -linkerflags
! 2422: </pre>
! 2423: <p>See also <a href="#undefined-reference" title="17.5.3. Undefined reference to “...”">Section 17.5.3, “Undefined reference to “<span class="quote">...</span>””</a>.</p>
! 2424: </div>
1.78 rillig 2425: </div>
2426: <div class="sect1" lang="en">
2427: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2428: <a name="developer-advanced-settings"></a>5.4. Developer/advanced settings</h2></div></div></div>
1.75 rillig 2429: <p>XXX
2430: </p>
2431: <div class="itemizedlist"><ul type="disc">
2432: <li>
2433: <p><code class="varname">PKG_DEVELOPER</code>:
2434: Run some sanity checks that package developers want:
2435: </p>
2436: <div class="itemizedlist"><ul type="circle">
1.88 ! wiz 2437: <li><p>make sure patches apply with zero
! 2438: fuzz</p></li>
! 2439: <li><p>run check-shlibs to see that all
! 2440: binaries will find their shared libs.</p></li>
1.75 rillig 2441: </ul></div>
2442: <p>
1.87 wiz 2443: </p>
1.75 rillig 2444: </li>
1.88 ! wiz 2445: <li><p><code class="varname">PKG_DEBUG_LEVEL</code>: The level
! 2446: of debugging output which is displayed whilst making and
! 2447: installing the package. The default value for this is 0,
! 2448: which will not display the commands as they are executed
! 2449: (normal, default, quiet operation); the value 1 will display
! 2450: all shell commands before their invocation, and the value 2
! 2451: will display both the shell commands before their invocation,
! 2452: and their actual execution progress with <span><strong class="command">set
! 2453: -x</strong></span> will be displayed.</p></li>
1.75 rillig 2454: </ul></div>
2455: <p>
2456: </p>
2457: </div>
2458: <div class="sect1" lang="en">
2459: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 2460: <a name="selecting-build-options"></a>5.5. Selecting Build Options</h2></div></div></div>
1.88 ! wiz 2461: <p>Some packages have build time options, usually to select
! 2462: between different dependencies, enable optional support for big
! 2463: dependencies or enable experimental features.</p>
1.75 rillig 2464: <p>To see which options, if any, a package supports, and which
1.88 ! wiz 2465: options are mutually exclusive, run <span><strong class="command">make
! 2466: show-options</strong></span>, for example:</p>
1.75 rillig 2467: <pre class="programlisting">
2468: The following options are supported by this package:
2469: ssl Enable SSL support.
2470: Exactly one of the following gecko options is required:
2471: firefox Use firefox as gecko rendering engine.
2472: mozilla Use mozilla as gecko rendering engine.
2473: At most one of the following database options may be selected:
2474: mysql Enable support for MySQL database.
2475: pgsql Enable support for PostgreSQL database.
1.1 grant 2476:
1.75 rillig 2477: These options are enabled by default: firefox
2478: These options are currently enabled: mozilla ssl
1.1 grant 2479: </pre>
1.75 rillig 2480: <p>The following variables can be defined in
1.88 ! wiz 2481: <code class="filename">/etc/mk.conf</code> to select which options to
! 2482: enable for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>,
! 2483: which can be used to select or disable options for all packages
! 2484: that support them, and
! 2485: <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
! 2486: which can be used to select or disable options specifically for
! 2487: package <em class="replaceable"><code>pkgbase</code></em>. Options listed in
! 2488: these variables are selected, options preceded by “<span class="quote">-</span>”
! 2489: are disabled. A few examples:</p>
1.75 rillig 2490: <pre class="screen">
2491: <code class="prompt">$</code> <span><strong class="command">grep "PKG.*OPTION" /etc/mk.conf</strong></span>
2492: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
2493: PKG_OPTIONS.kdebase= debug -sasl
2494: PKG_OPTIONS.apache= suexec </pre>
1.88 ! wiz 2495: <p>The following settings are consulted in the order given, and
! 2496: the last setting that selects or disables an option is
! 2497: used:</p>
1.75 rillig 2498: <div class="orderedlist"><ol type="1">
2499: <li><p>the default options as suggested by the package
1.88 ! wiz 2500: maintainer</p></li>
1.75 rillig 2501: <li><p>the options implied by the settings of legacy
1.88 ! wiz 2502: variables (see below)</p></li>
1.75 rillig 2503: <li><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
2504: <li><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
2505: </ol></div>
2506: <p>For groups of mutually exclusive options, the last option
1.88 ! wiz 2507: selected is used, all others are automatically disabled. If an
! 2508: option of the group is explicitly disabled, the previously
! 2509: selected option, if any, is used. It is an error if no option
! 2510: from a required group of options is selected, and building the
! 2511: package will fail.</p>
! 2512: <p>Before the options framework was introduced, build options
! 2513: were selected by setting a variable (often named
! 2514: <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
! 2515: <code class="filename">/etc/mk.conf</code> for each option. To ease
! 2516: transition to the options framework for the user, these legacy
! 2517: variables are converted to the appropriate options setting
! 2518: (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
! 2519: automatically. A warning is issued to prompt the user to update
! 2520: <code class="filename">/etc/mk.conf</code> to use the options framework
! 2521: directly. Support for the legacy variables will be removed
! 2522: eventually.</p>
1.75 rillig 2523: </div>
2524: </div>
2525: <div class="chapter" lang="en">
2526: <div class="titlepage"><div><div><h2 class="title">
2527: <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
2528: <div class="toc">
2529: <p><b>Table of Contents</b></p>
2530: <dl>
2531: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
2532: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
2533: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
2534: <dd><dl>
2535: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
2536: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
2537: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
2538: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
2539: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
2540: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
2541: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
2542: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
2543: </dl></dd>
2544: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
2545: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
2546: </dl>
2547: </div>
2548: <div class="sect1" lang="en">
2549: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2550: <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
1.87 wiz 2551: <p>Once you have built and installed a package, you can create
2552: a <span class="emphasis"><em>binary package</em></span> which can be installed on
2553: 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
2554: the same package on a group of hosts and wasting CPU time. It also
2555: provides a simple means for others to install your package, should
2556: you distribute it.</p>
2557: <p>To create a binary package, change into the appropriate
2558: directory in pkgsrc, and run <span><strong class="command">make
2559: package</strong></span>:</p>
2560: <pre class="screen">
2561: <code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
2562: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
2563: </pre>
2564: <p>This will build and install your package (if not already done),
2565: and then build a binary package from what was installed. You can
2566: then use the <span><strong class="command">pkg_*</strong></span> tools to manipulate
2567: it. Binary packages are created by default in
2568: <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
2569: gzipped tar file. See <a href="#logs.package" title="B.2. Packaging figlet">Section B.2, “Packaging figlet”</a> for a
2570: 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>
2571: <p>See <a href="#submit" title="Chapter 19. Submitting and Committing">Chapter 19, <i>Submitting and Committing</i></a> for information on how to submit
2572: such a binary package.</p>
1.75 rillig 2573: </div>
2574: <div class="sect1" lang="en">
2575: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2576: <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
1.88 ! wiz 2577: <p>See <a href="#build.helpful-targets" title="15.17. Other helpful targets">Section 15.17, “Other helpful targets”</a>.</p>
1.75 rillig 2578: </div>
2579: <div class="sect1" lang="en">
2580: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2581: <a name="bulkbuild"></a>6.3. Doing a bulk build of all packages</h2></div></div></div>
2582: <p>If you want to get a full set of precompiled binary
1.87 wiz 2583: packages, this section describes how to get them. Beware that
2584: the bulk build will remove all currently installed packages from
2585: your system!</p>
1.75 rillig 2586: <p>Having an FTP server configured either on the
1.87 wiz 2587: machine doing the bulk builds or on a nearby NFS server can help
2588: to make the packages available to other machines that can then
2589: 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
2590: more information. If you use a remote NFS server's storage, be
2591: sure to not actually compile on NFS storage, as this slows
2592: things down a lot.</p>
1.75 rillig 2593: <div class="sect2" lang="en">
2594: <div class="titlepage"><div><div><h3 class="title">
2595: <a name="binary.configuration"></a>6.3.1. Configuration</h3></div></div></div>
2596: <div class="sect3" lang="en">
2597: <div class="titlepage"><div><div><h4 class="title">
1.76 rillig 2598: <a name="binary.bulk.build.conf"></a>6.3.1.1. <code class="filename">build.conf</code></h4></div></div></div>
2599: <p>The <code class="filename">build.conf</code> file is the main
1.87 wiz 2600: configuration file for bulk builds. You can configure how your
2601: copy of pkgsrc is kept up to date, how the distfiles are
2602: downloaded, how the packages are built and how the report is
2603: generated. You can find an annotated example file in
2604: <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
2605: it, copy <code class="filename">build.conf-example</code> to
2606: <code class="filename">build.conf</code> and edit it, following the
2607: comments in that file.</p>
1.75 rillig 2608: </div>
2609: <div class="sect3" lang="en">
2610: <div class="titlepage"><div><div><h4 class="title">
2611: <a name="binary.mk.conf"></a>6.3.1.2. /etc/mk.conf</h4></div></div></div>
2612: <p>You may want to set variables in
1.87 wiz 2613: <code class="filename">/etc/mk.conf</code>.
2614: Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
2615: details of the default settings. You will want to ensure that
2616: <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
2617: As used in this example, <code class="varname">_ACCEPTABLE=yes</code>
2618: accepts <span class="emphasis"><em>all</em></span> licenses.</p>
2619: <pre class="programlisting">
2620: PACKAGES?= ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
2621: WRKOBJDIR?= /usr/tmp/pkgsrc # build here instead of in pkgsrc
2622: BSDSRCDIR= /usr/src
2623: BSDXSRCDIR= /usr/xsrc # for x11/xservers
2624: OBJHOSTNAME?= yes # use work.`hostname`
2625: FAILOVER_FETCH= yes # insist on the correct checksum
2626: PKG_DEVELOPER?= yes
2627: _ACCEPTABLE= yes
2628: </pre>
1.75 rillig 2629: <p>Some options that are especially useful for bulk builds
2630: can be found at the top lines of the file
1.76 rillig 2631: <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
1.75 rillig 2632: options of these are briefly described here.</p>
2633: <div class="itemizedlist"><ul type="disc">
2634: <li><p>If you are on a slow machine, you may want to
1.87 wiz 2635: set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
2636: “<span class="quote">no</span>”.</p></li>
1.75 rillig 2637: <li><p>If you are doing bulk builds from a read-only
1.87 wiz 2638: copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
2639: to the directory where all log files are created. Otherwise the
2640: log files are created in the pkgsrc directory.</p></li>
1.75 rillig 2641: <li><p>Another important variable is
1.87 wiz 2642: <code class="varname">BULK_PREREQ</code>, which is a list of packages that
2643: should be always available while building other
2644: packages.</p></li>
1.75 rillig 2645: </ul></div>
2646: <p>Some other options are scattered in the pkgsrc
2647: infrastructure:</p>
2648: <div class="itemizedlist"><ul type="disc">
2649: <li><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
1.87 wiz 2650: should be set to <code class="literal">yes</code>. The purpose of the bulk
2651: builds is creating binary packages, no matter if they are
2652: vulnerable or not. When uploading the packages to a public
2653: server, the vulnerable packages will be put into a directory of
2654: their own. Leaving this variable unset would prevent the bulk
2655: build system from even trying to build them, so possible
2656: building errors would not show up.</p></li>
1.75 rillig 2657: <li><p><code class="varname">CHECK_FILES</code>
1.87 wiz 2658: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
2659: “<span class="quote">yes</span>” to check that the installed set of files
2660: matches the <code class="filename">PLIST</code>.</p></li>
1.75 rillig 2661: <li><p><code class="varname">CHECK_INTERPRETER</code>
1.87 wiz 2662: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
2663: “<span class="quote">yes</span>” to check that the installed
2664: “<span class="quote">#!</span>”-scripts will find their
2665: interpreter.</p></li>
1.75 rillig 2666: </ul></div>
2667: </div>
2668: <div class="sect3" lang="en">
2669: <div class="titlepage"><div><div><h4 class="title">
1.76 rillig 2670: <a name="pre-build.local"></a>6.3.1.3. <code class="filename">pre-build.local</code></h4></div></div></div>
1.75 rillig 2671: <p>It is possible to configure the bulk build to perform
1.87 wiz 2672: certain site-specific tasks at the end of the pre-build
2673: stage. If the file
2674: <code class="filename">pre-build.local</code> exists in
2675: <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
2676: (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
2677: stage. An example use of
2678: <code class="filename">pre-build.local</code> is to have the line:</p>
1.75 rillig 2679: <pre class="screen">echo "I do not have enough disk space to build this pig." \
1.87 wiz 2680: > misc/openoffice/$BROKENF</pre>
1.75 rillig 2681: <p>to prevent the system from trying to build a particular package
1.87 wiz 2682: which requires nearly 3 GB of disk space.</p>
1.75 rillig 2683: </div>
2684: </div>
2685: <div class="sect2" lang="en">
2686: <div class="titlepage"><div><div><h3 class="title">
2687: <a name="other-environmental-considerations"></a>6.3.2. Other environmental considerations</h3></div></div></div>
1.76 rillig 2688: <p>As <code class="filename">/usr/pkg</code> will be completely
1.87 wiz 2689: deleted at the start of bulk builds, make sure your login
2690: shell is placed somewhere else. Either drop it into
2691: <code class="filename">/usr/local/bin</code> (and adjust your login
2692: shell in the passwd file), or (re-)install it via
2693: <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
2694: you can login after a reboot (remember that your current
2695: process won't die if the package is removed, you just can't
2696: start any new instances of the shell any more). Also, if you
2697: use NetBSD earlier than 1.5, or you still want to use the pkgsrc
2698: version of ssh for some reason, be sure to install ssh before
2699: starting it from <code class="filename">rc.local</code>:</p>
2700: <pre class="programlisting">
2701: ( cd /usr/pkgsrc/security/ssh ; make bulk-install )
2702: if [ -f /usr/pkg/etc/rc.d/sshd ]; then
2703: /usr/pkg/etc/rc.d/sshd
2704: fi
2705: </pre>
1.75 rillig 2706: <p>Not doing so will result in you being not able to log in
1.87 wiz 2707: via ssh after the bulk build is finished or if the machine
2708: gets rebooted or crashes. You have been warned! :)</p>
1.75 rillig 2709: </div>
2710: <div class="sect2" lang="en">
2711: <div class="titlepage"><div><div><h3 class="title">
2712: <a name="operation"></a>6.3.3. Operation</h3></div></div></div>
2713: <p>Make sure you don't need any of the packages still
1.87 wiz 2714: installed.</p>
1.75 rillig 2715: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
2716: <h3 class="title">Warning</h3>
2717: <p>During the bulk build, <span class="emphasis"><em>all packages will be
1.87 wiz 2718: removed!</em></span></p>
1.75 rillig 2719: </div>
2720: <p>Be sure to remove all other things that might
1.87 wiz 2721: interfere with builds, like some libs installed in
2722: <code class="filename">/usr/local</code>, etc. then become root and type:</p>
2723: <pre class="screen">
2724: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2725: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong>
2726: </pre>
1.75 rillig 2727: <p>If for some reason your last build didn't complete (power
1.87 wiz 2728: failure, system panic, ...), you can continue it by
2729: running:</p>
1.75 rillig 2730: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
1.87 wiz 2731: <p>At the end of the bulk build, you will get a summary via mail,
2732: and find build logs in the directory specified by
2733: <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
2734: file.</p>
1.75 rillig 2735: </div>
2736: <div class="sect2" lang="en">
2737: <div class="titlepage"><div><div><h3 class="title">
2738: <a name="what-it-does"></a>6.3.4. What it does</h3></div></div></div>
2739: <p>The bulk builds consist of three steps:</p>
2740: <div class="variablelist"><dl>
2741: <dt><span class="term">1. pre-build</span></dt>
1.87 wiz 2742: <dd><p>The script updates your pkgsrc tree via (anon)cvs, then
2743: cleans out any broken distfiles, and removes all
2744: packages installed.</p></dd>
1.75 rillig 2745: <dt><span class="term">2. the bulk build</span></dt>
1.87 wiz 2746: <dd><p>This is basically “<span class="quote">make bulk-package</span>” with
2747: an optimised order in which packages will be
2748: built. Packages that don't require other packages will
2749: be built first, and packages with many dependencies will
2750: be built later.</p></dd>
1.75 rillig 2751: <dt><span class="term">3. post-build</span></dt>
1.87 wiz 2752: <dd><p>Generates a report that's placed in the directory
2753: specified in the <code class="filename">build.conf</code> file
2754: named <code class="filename">broken.html</code>, a short version
2755: of that report will also be mailed to the build's
2756: admin.</p></dd>
1.75 rillig 2757: </dl></div>
1.87 wiz 2758: <p>During the build, a list of broken packages will be compiled
2759: in <code class="filename">/usr/pkgsrc/.broken</code> (or
2760: <code class="filename">.../.broken.${MACHINE}</code> if
2761: <code class="varname">OBJMACHINE</code> is set), individual build logs
2762: of broken builds can be found in the package's
2763: directory. These files are used by the bulk-targets to mark
2764: broken builds to not waste time trying to rebuild them, and
2765: they can be used to debug these broken package builds
2766: later.</p>
1.75 rillig 2767: </div>
2768: <div class="sect2" lang="en">
2769: <div class="titlepage"><div><div><h3 class="title">
2770: <a name="disk-space-requirements"></a>6.3.5. Disk space requirements</h3></div></div></div>
2771: <p>Currently, roughly the following requirements are valid for
1.87 wiz 2772: NetBSD 2.0/i386:</p>
1.75 rillig 2773: <div class="itemizedlist"><ul type="disc">
1.87 wiz 2774: <li><p>10 GB - distfiles (NFS ok)</p></li>
2775: <li><p>8 GB - full set of all binaries (NFS ok)</p></li>
2776: <li><p>5 GB - temp space for compiling (local disk recommended)</p></li>
2777: </ul></div>
2778: <p>Note that all pkgs will be de-installed as soon as they are
2779: turned into a binary package, and that sources are removed,
2780: so there is no excessively huge demand to disk
2781: space. Afterwards, if the package is needed again, it will
2782: 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
2783: there are no cycles wasted by recompiling.</p>
1.75 rillig 2784: </div>
2785: <div class="sect2" lang="en">
2786: <div class="titlepage"><div><div><h3 class="title">
2787: <a name="setting-up-a-sandbox"></a>6.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
1.87 wiz 2788: <p>If you don't want all the packages nuked from a machine
2789: (rendering it useless for anything but pkg compiling), there
2790: is the possibility of doing the package bulk build inside a
2791: chroot environment.</p>
2792: <p>The first step is to set up a chroot sandbox,
2793: e.g. <code class="filename">/usr/sandbox</code>. This can be done by
2794: using null mounts, or manually.</p>
2795: <p>There is a shell script called
2796: <code class="filename">pkgsrc/mk/bulk/mksandbox</code> which will set
2797: up the sandbox environment using null mounts. It will also
2798: create a script called <code class="filename">sandbox</code> in the
2799: root of the sandbox environment, which will allow the null
2800: mounts to be activated using the <span><strong class="command">sandbox
2801: mount</strong></span> command and deactivated using the
2802: <span><strong class="command">sandbox umount</strong></span> command.</p>
2803: <p>To set up a sandbox environment by hand, after extracting all
2804: the sets from a NetBSD installation or doing a <span><strong class="command">make
2805: distribution DESTDIR=/usr/sandbox</strong></span> in
2806: <code class="filename">/usr/src/etc</code>, be sure the following items
2807: are present and properly configured:</p>
1.75 rillig 2808: <div class="procedure"><ol type="1">
2809: <li>
2810: <p>Kernel</p>
2811: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
2812: </li>
2813: <li>
1.76 rillig 2814: <p><code class="filename">/dev/*</code></p>
1.75 rillig 2815: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
2816: </li>
2817: <li>
1.76 rillig 2818: <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 2819: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
2820: </li>
2821: <li>
2822: <p>Working(!) mail config (hostname, sendmail.cf):</p>
2823: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
2824: </li>
2825: <li>
1.76 rillig 2826: <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 2827: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
2828: </li>
2829: <li>
1.76 rillig 2830: <p><code class="filename">/usr/src</code> (system sources,
1.87 wiz 2831: 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 2832: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
1.87 wiz 2833: <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
1.75 rillig 2834: </li>
2835: <li>
1.76 rillig 2836: <p>Create <code class="filename">/var/db/pkg</code> (not part of default install):</p>
1.75 rillig 2837: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong></pre>
2838: </li>
2839: <li>
1.76 rillig 2840: <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
1.75 rillig 2841: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
2842: </li>
2843: <li>
2844: <p>Checkout pkgsrc via cvs into
1.87 wiz 2845: <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
2846: <pre class="screen">
2847: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
2848: <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong>
2849: </pre>
1.75 rillig 2850: <p>Do not mount/link this to the copy of your pkgsrc tree
1.87 wiz 2851: you do development in, as this will likely cause problems!</p>
1.75 rillig 2852: </li>
2853: <li><p>Make
1.87 wiz 2854: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
2855: <code class="filename">.../distfiles</code> point somewhere
2856: appropriate. NFS- and/or nullfs-mounts may come in handy!</p></li>
1.76 rillig 2857: <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>
2858: <li><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
1.75 rillig 2859: </ol></div>
2860: <p>When the chroot sandbox is set up, you can start
1.87 wiz 2861: the build with the following steps:</p>
2862: <pre class="screen">
2863: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2864: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong>
2865: </pre>
2866: <p>This will just jump inside the sandbox and start building. At
2867: the end of the build, mail will be sent with the results of
2868: the build. Created binary pkgs will be in
2869: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
2870: (wherever that points/mounts to/from).</p>
1.75 rillig 2871: </div>
2872: <div class="sect2" lang="en">
2873: <div class="titlepage"><div><div><h3 class="title">
2874: <a name="building-a-partial-set"></a>6.3.7. Building a partial set of packages</h3></div></div></div>
1.87 wiz 2875: <p>In addition to building a complete set of all packages in
2876: pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
2877: may be used to build a subset of the packages contained in
2878: pkgsrc. By setting <code class="varname">SPECIFIC_PKGS</code>
2879: in <code class="filename">/etc/mk.conf</code>, the variables</p>
1.75 rillig 2880: <div class="itemizedlist"><ul type="disc">
2881: <li><p>SITE_SPECIFIC_PKGS</p></li>
2882: <li><p>HOST_SPECIFIC_PKGS</p></li>
2883: <li><p>GROUP_SPECIFIC_PKGS</p></li>
2884: <li><p>USER_SPECIFIC_PKGS</p></li>
2885: </ul></div>
1.87 wiz 2886: <p>will define the set of packages which should be built.
2887: The bulk build code will also include any packages which are
2888: needed as dependencies for the explicitly listed packages.</p>
2889: <p>One use of this is to do a bulk build with
2890: <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
2891: periodically to have a complete set of the binary packages
2892: needed for your site available without the overhead of
2893: building extra packages that are not needed.</p>
1.75 rillig 2894: </div>
2895: <div class="sect2" lang="en">
2896: <div class="titlepage"><div><div><h3 class="title">
2897: <a name="bulk-upload"></a>6.3.8. Uploading results of a bulk build</h3></div></div></div>
1.87 wiz 2898: <p>This section describes how pkgsrc developers can upload binary
2899: pkgs built by bulk builds to ftp.NetBSD.org.</p>
2900: <p>If you would like to automatically create checksum files for the
2901: binary packages you intend to upload, remember to set
2902: <code class="varname">MKSUMS=yes</code> in your
2903: <code class="filename">mk/bulk/build.conf</code>.</p>
2904: <p>If you would like to PGP sign the checksum files (highly
2905: recommended!), remember to set
2906: <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
2907: <code class="filename">mk/bulk/build.conf</code>. This will prompt you for
2908: your GPG password to sign the files before uploading everything.</p>
2909: <p>Then, make sure that you have <code class="varname">RSYNC_DST</code>
2910: set properly in your <code class="filename">mk/bulk/build.conf</code>
2911: file, i.e. adjust it to something like one of the following:</p>
1.75 rillig 2912: <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
2913: <p>Please use appropriate values for "pkgsrc-200xQy",
1.87 wiz 2914: "NetBSD-a.b.c" and "arch" here. If your login on ftp.NetBSD.org
2915: is different from your local login, write your login directly
2916: into the variable, e.g. my local account is "feyrer", but for my
2917: login "hubertf", I use:</p>
2918: <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload</pre>
2919: <p>A separate <code class="filename">upload</code> directory is used
2920: here to allow "closing" the directory during upload. To do
2921: so, run the following command on ftp.NetBSD.org next:</p>
1.75 rillig 2922: <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>
1.87 wiz 2923: <p>Please note that <code class="filename">/pub/NetBSD/packages</code> is
2924: only appropriate for packages for the NetBSD operating
2925: system. Binary packages for other operating systems should go
2926: into <code class="filename">/pub/pkgsrc</code>.</p>
2927: <p>Before uploading the binary pkgs, ssh authentication needs
2928: to be set up. This example shows how to set up temporary keys
2929: for the root account <span class="emphasis"><em>inside the sandbox</em></span>
2930: (assuming that no keys should be present there usually):</p>
2931: <pre class="screen">
2932: <code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
1.75 rillig 2933: chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
2934: chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t dsa</code></strong>
1.87 wiz 2935: chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong>
2936: </pre>
2937: <p>Now take the output of <code class="filename">id-dsa.pub</code> and
2938: append it to your <code class="filename">~/.ssh/authorized_keys</code>
2939: file on ftp.NetBSD.org. You can remove the key after the
2940: upload is done!</p>
2941: <p>Next, test if your ssh connection really works:</p>
1.75 rillig 2942: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
1.87 wiz 2943: <p>Use "-l yourNetBSDlogin" here as appropriate!</p>
2944: <p>Now after all this works, you can exit the sandbox and start
2945: the upload:</p>
2946: <pre class="screen">
2947: chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
1.75 rillig 2948: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
1.87 wiz 2949: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong>
2950: </pre>
2951: <p>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
2952: <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
2953: upload. The upload script will take care of not uploading
2954: restricted packages and putting vulnerable packages into the
2955: <code class="filename">vulnerable</code> subdirectory.</p>
2956: <p>After the upload has ended, first thing is to revoke ssh access:</p>
1.75 rillig 2957: <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
1.87 wiz 2958: Gdd:x! </pre>
2959: <p>Use whatever is needed to remove the key you've entered
2960: before! Last, move the uploaded packages out of the
2961: <code class="filename">upload</code> directory to have them accessible
2962: to everyone:</p>
2963: <pre class="screen">
2964: nbftp% <strong class="userinput"><code>cd /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch</code></strong>
1.75 rillig 2965: nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
2966: nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
1.87 wiz 2967: nbftp% <strong class="userinput"><code>chmod 755 .</code></strong>
2968: </pre>
1.75 rillig 2969: </div>
2970: </div>
2971: <div class="sect1" lang="en">
2972: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2973: <a name="creating-cdroms"></a>6.4. Creating a multiple CD-ROM packages collection</h2></div></div></div>
1.87 wiz 2974: <p>After your pkgsrc bulk-build has completed, you may wish to
2975: create a CD-ROM set of the resulting binary packages to assist
2976: in installing packages on other machines. The
2977: <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
2978: a simple tool for creating the ISO 9660 images.
2979: <span><strong class="command">cdpack</strong></span> arranges the packages on the CD-ROMs in a
2980: way that keeps all the dependencies for a given package on the same
2981: CD as that package.</p>
1.75 rillig 2982: <div class="sect2" lang="en">
2983: <div class="titlepage"><div><div><h3 class="title">
2984: <a name="cdpack-example"></a>6.4.1. Example of cdpack</h3></div></div></div>
1.87 wiz 2985: <p>Complete documentation for cdpack is found in the cdpack(1)
2986: man page. The following short example assumes that the binary
2987: packages are left in
2988: <code class="filename">/usr/pkgsrc/packages/All</code> and that
2989: sufficient disk space exists in <code class="filename">/u2</code> to
2990: hold the ISO 9660 images.</p>
2991: <pre class="screen">
2992: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
1.75 rillig 2993: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
1.87 wiz 2994: <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong>
2995: </pre>
2996: <p>If you wish to include a common set of files
2997: (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
2998: etc.) on each CD in the collection, then you need to create a
2999: directory which contains these files. e.g.</p>
3000: <pre class="screen">
3001: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
1.75 rillig 3002: <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" > /tmp/common/README</code></strong>
3003: <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" > /tmp/common/COPYING</code></strong>
3004: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
3005: <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" > /tmp/common/bin/myscript</code></strong>
3006: <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" >> /tmp/common/bin/myscript</code></strong>
1.87 wiz 3007: <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong>
3008: </pre>
1.75 rillig 3009: <p>Now create the images:</p>
3010: <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 3011: <p>Each image will contain <code class="filename">README</code>,
1.87 wiz 3012: <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
3013: in their root directories.</p>
1.75 rillig 3014: </div>
3015: </div>
3016: </div>
3017: <div class="chapter" lang="en">
3018: <div class="titlepage"><div><div><h2 class="title">
3019: <a name="faq"></a>Chapter 7. Frequently Asked Questions</h2></div></div></div>
3020: <div class="toc">
3021: <p><b>Table of Contents</b></p>
3022: <dl>
3023: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
3024: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
3025: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
3026: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
3027: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
3028: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
3029: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
3030: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
3031: <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>
3032: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
3033: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
3034: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
3035: <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>
3036: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
3037: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
3038: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
3039: <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.88 ! wiz 3040: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
! 3041: <dt><span class="sect1"><a href="#too-much-time">7.18. I have a little time to kill. What shall I do?</a></span></dt>
1.75 rillig 3042: </dl>
3043: </div>
3044: <p>This section contains hints, tips & tricks on special things in
3045: pkgsrc that we didn't find a better place for in the previous chapters, and
3046: it contains items for both pkgsrc users and developers.</p>
3047: <div class="sect1" lang="en">
3048: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3049: <a name="mailing-list-pointers"></a>7.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
3050: <p>The following mailing lists may be of interest to pkgsrc users:</p>
3051: <div class="itemizedlist"><ul type="disc">
1.78 rillig 3052: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-users" target="_top">pkgsrc-users</a>:
3053: This is a general purpose list for most issues regarding
3054: pkgsrc, regardless of platform, e.g. soliciting user help
3055: for pkgsrc configuration, unexpected build failures, using
3056: particular packages, upgrading pkgsrc installations,
3057: questions regarding the pkgsrc release branches, etc. General announcements or
3058: proposals for changes that impact the pkgsrc user community,
3059: e.g. major infrastructure changes, new features, package
3060: removals, etc., may also be posted.</p></li>
1.75 rillig 3061: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
3062: A list where the results of pkgsrc bulk builds are sent and
3063: discussed.</p></li>
3064: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
3065: This list is for those who are interested in getting a
3066: commit message for every change committed to pkgsrc. It is
3067: also available in digest form, meaning one daily message
3068: containing all commit messages for changes to the package
3069: source tree in that 24 hour period.</p></li>
3070: </ul></div>
3071: <p>To subscribe, do:</p>
3072: <pre class="programlisting">
3073: <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
3074: </pre>
3075: <p>Archives for all these mailing lists are available from
3076: <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
3077: </div>
3078: <div class="sect1" lang="en">
3079: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3080: <a name="pkgviews-docs"></a>7.2. Where's the pkgviews documentation?</h2></div></div></div>
3081: <p>Pkgviews is tightly integrated with buildlink. You can find a
3082: pkgviews User's guide in
1.76 rillig 3083: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
1.75 rillig 3084: </div>
3085: <div class="sect1" lang="en">
3086: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3087: <a name="faq-pkgtools"></a>7.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.80 rillig 3088: <p>The directory <code class="filename">pkgsrc/pkgtools</code> contains
1.75 rillig 3089: a number of useful utilities for both users and developers of pkgsrc. This
3090: section attempts only to make the reader aware of the utilities and when
3091: they might be useful, and not to duplicate the documentation that comes
3092: with each package.</p>
3093: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
1.76 rillig 3094: <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 3095: Symlinks for use by buildlink.</p></li></ul></div>
3096: <p>OS tool augmentation (automatically installed when needed):</p>
3097: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3098: <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 3099: Calculates various kinds of checksums (including SHA1).</p></li>
1.76 rillig 3100: <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 3101: Compatibility library for pkgsrc tools.</p></li>
1.76 rillig 3102: <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.87 wiz 3103: non-BSD systems due to lack of native mtree.</p></li>
1.76 rillig 3104: <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 3105: Up-to-date replacement for
1.76 rillig 3106: <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
1.75 rillig 3107: systems where pkg_install is not present.</p></li>
3108: </ul></div>
3109: <p>Utilities used by pkgsrc (not automatically installed):</p>
3110: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3111: <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 3112: Create a binary package from an
3113: already-installed package. Used by <span><strong class="command">make replace</strong></span> to
3114: save the old package.</p></li>
1.76 rillig 3115: <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 3116: Adds extra functionality to pkgsrc, allowing it to fetch distfiles
3117: from multiple locations. It currently supports the following
3118: methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
1.76 rillig 3119: <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 3120: packages someplace else (enabled by default).</p></li>
1.76 rillig 3121: <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 3122: best compiler flags to optimise code for your current CPU and
3123: compiler.</p></li>
3124: </ul></div>
3125: <p>Utilities for keeping track of installed packages, being up to date,
3126: etc:</p>
3127: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3128: <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 3129: packages whose installed versions do not match the latest pkgsrc
3130: entries.</p></li>
1.76 rillig 3131: <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 3132: dependency graphs of packages, to aid in choosing a strategy for
3133: updating.</p></li>
1.76 rillig 3134: <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
3135: 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>
3136: <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 3137: pkglint(1) program checks a pkgsrc entry for errors, lintpkgsrc(1)
3138: does various checks on the complete pkgsrc system.</p></li>
1.76 rillig 3139: <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 3140: packages you have installed.</p></li>
3141: </ul></div>
3142: <p>Utilities for people maintaining or creating individual packages:</p>
3143: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3144: <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 3145: making and maintaining patches for a package (includes pkgdiff,
3146: pkgvi, mkpatches, etc.).</p></li>
1.76 rillig 3147: <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>,
3148: <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 3149: converting to pkgsrc.</p></li>
1.76 rillig 3150: <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 3151: pkgsrc to a Solaris package.</p></li>
3152: </ul></div>
3153: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
3154: utilities)</p>
3155: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3156: <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 3157: packages in a chrooted area.</p></li>
1.76 rillig 3158: <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 3159: kernel version for chrooted cross builds.</p></li>
3160: </ul></div>
3161: </div>
3162: <div class="sect1" lang="en">
3163: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3164: <a name="non-root-pkgsrc"></a>7.4. How to use pkgsrc as non-root</h2></div></div></div>
3165: <p>If you want to use pkgsrc as non-root user, you can set some
3166: variables to make pkgsrc work under these conditions. At the very least,
3167: you need to set <code class="varname">UNPRIVILEGED</code> to “<span class="quote">yes</span>”; this
3168: will turn on unprivileged mode and set multiple related variables to allow
3169: installation of packages as non-root.</p>
3170: <p>In case the defaults are not enough, you may want to tune some other
3171: variables used. For example, if the automatic user/group detection leads
3172: to incorrect values (or not the ones you would like to use), you can change
3173: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
3174: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
3175: <p>As regards bootstrapping, please note that the
3176: <span><strong class="command">bootstrap</strong></span> script will ease non-root configuration when
3177: given the “<span class="quote">--ignore-user-check</span>” flag, as it will choose and
1.76 rillig 3178: use multiple default directories under <code class="filename">~/pkg</code> as the
1.75 rillig 3179: installation targets. These directories can be overriden by the
3180: “<span class="quote">--prefix</span>” flag provided by the script, as well as some others
3181: that allow finer tuning of the tree layout.</p>
3182: </div>
3183: <div class="sect1" lang="en">
3184: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3185: <a name="resume-transfers"></a>7.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
3186: <p>By default, resuming transfers in pkgsrc is disabled, but you can
3187: enable this feature by adding the option
3188: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.76 rillig 3189: <code class="filename">/etc/mk.conf</code>. If, during a fetch step, an incomplete
1.75 rillig 3190: distfile is found, pkgsrc will try to resume it.</p>
3191: <p>You can also
3192: 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
3193: <code class="varname">FETCH_CMD</code> variable. Don't forget to set
3194: <code class="varname">FETCH_RESUME_ARGS</code> and
3195: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
3196: values.</p>
3197: <p>For example, if you want to use
1.76 rillig 3198: <code class="filename">wget</code> to resume downloads, you'll have to use something
1.75 rillig 3199: like:</p>
3200: <pre class="programlisting">
3201: FETCH_CMD= wget
3202: FETCH_BEFORE_ARGS= --passive-ftp
3203: FETCH_RESUME_ARGS= -c
3204: FETCH_OUTPUT_ARGS= -O
1.1 grant 3205: </pre>
1.75 rillig 3206: </div>
3207: <div class="sect1" lang="en">
3208: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3209: <a name="XFree86-from-pkgsrc"></a>7.6. How can I install/use XFree86 from pkgsrc?</h2></div></div></div>
3210: <p>If you want to use XFree86 from pkgsrc instead of your system's own
1.76 rillig 3211: X11 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>,
1.75 rillig 3212: ...), you will have to add the following line into
1.76 rillig 3213: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 3214: <pre class="programlisting">
3215: X11_TYPE=XFree86
1.1 grant 3216: </pre>
1.75 rillig 3217: </div>
3218: <div class="sect1" lang="en">
3219: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3220: <a name="x.org-from-pkgsrc"></a>7.7. How can I install/use X.org from pkgsrc?</h2></div></div></div>
3221: <p>If you want to use X.org from pkgsrc instead of your system's own X11
1.76 rillig 3222: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
1.75 rillig 3223: you will have to add the following line into
1.76 rillig 3224: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 3225: <pre class="programlisting">
3226: X11_TYPE=xorg
1.1 grant 3227: </pre>
1.75 rillig 3228: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
3229: <h3 class="title">Note</h3>
3230: <p>The DragonFly operating system defaults to using
1.87 wiz 3231: this X.org X11 implementation from pkgsrc.</p>
1.75 rillig 3232: </div>
3233: </div>
3234: <div class="sect1" lang="en">
3235: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3236: <a name="fetch-behind-firewall"></a>7.8. How to fetch files from behind a firewall</h2></div></div></div>
3237: <p>If you are sitting behind a firewall which does not allow direct
3238: connections to Internet hosts (i.e. non-NAT), you may specify the
3239: relevant proxy hosts. This is done using an environment variable in the
3240: form of a URL, e.g. in Amdahl, the machine
3241: “<span class="quote">orpheus.amdahl.com</span>” is one of the firewalls, and it uses
3242: port 80 as the proxy port number. So the proxy environment variables
3243: are:</p>
3244: <pre class="programlisting">
3245: ftp_proxy=ftp://orpheus.amdahl.com:80/
3246: http_proxy=http://orpheus.amdahl.com:80/
1.1 grant 3247: </pre>
1.75 rillig 3248: </div>
3249: <div class="sect1" lang="en">
3250: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3251: <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>
3252: <p>This depends on which utility is used to retrieve distfiles. From
1.76 rillig 3253: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
1.75 rillig 3254: the first available command from the following list:</p>
3255: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3256: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
3257: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
1.75 rillig 3258: </ul></div>
3259: <p>On a default NetBSD installation, this will be
1.76 rillig 3260: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
1.75 rillig 3261: connections first, and falls back to active connections if the server
3262: refuses to do passive. For the other tools, add the following to your
1.76 rillig 3263: <code class="filename">/etc/mk.conf</code> file:
1.75 rillig 3264: <code class="varname">PASSIVE_FETCH=1</code>.</p>
3265: <p>Having that option present will prevent
1.76 rillig 3266: <code class="filename">/usr/bin/ftp</code> from falling back to active
1.75 rillig 3267: transfers.</p>
3268: </div>
3269: <div class="sect1" lang="en">
3270: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3271: <a name="fetching-all-distfiles"></a>7.10. How to fetch all distfiles at once</h2></div></div></div>
1.88 ! wiz 3272: <p>You would like to download all the distfiles in a single batch
! 3273: from work or university, where you can't run a <span><strong class="command">make
! 3274: fetch</strong></span>. There is an archive of distfiles on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/" target="_top">ftp.NetBSD.org</a>,
1.75 rillig 3275: but downloading the entire directory may not be appropriate.</p>
3276: <p>The answer here is to do a <span><strong class="command">make fetch-list</strong></span> in
1.76 rillig 3277: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
1.75 rillig 3278: resulting list to your machine at work/school and use it there. If you
3279: 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
3280: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
3281: URL:</p>
3282: <p>At home:</p>
3283: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
3284: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh</code></strong>
3285: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
3286: <p>At work:</p>
3287: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
1.76 rillig 3288: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
1.75 rillig 3289: home.</p>
3290: <p>If you have a machine running NetBSD, and you want to get
1.88 ! wiz 3291: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your
! 3292: machine architecture), you can do so by using the above-mentioned
! 3293: <span><strong class="command">make fetch-list</strong></span> approach, or fetch the distfiles
! 3294: directly by running:</p>
1.75 rillig 3295: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
3296: <p>If you even decide to ignore
3297: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
3298: by running:</p>
3299: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
3300: </div>
3301: <div class="sect1" lang="en">
3302: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3303: <a name="tmac.andoc-missing"></a>7.11. What does “<span class="quote">Don't know how to make
3304: /usr/share/tmac/tmac.andoc</span>” mean?</h2></div></div></div>
1.76 rillig 3305: <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 3306: package, you get the error from make that it doesn't know how to make
1.76 rillig 3307: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
1.75 rillig 3308: you don't have installed the “<span class="quote">text</span>” set (nroff, ...) from
3309: the NetBSD base distribution on your machine. It is recommended to do
3310: that to format man pages.</p>
1.76 rillig 3311: <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 3312: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.76 rillig 3313: environment or in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 3314: </div>
3315: <div class="sect1" lang="en">
3316: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3317: <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.87 wiz 3318: <p>You didn't install the compiler set, <code class="filename">comp.tgz</code>,
1.75 rillig 3319: when you installed your NetBSD machine. Please get and install it, by
1.76 rillig 3320: extracting it in <code class="filename">/</code>:</p>
1.75 rillig 3321: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
3322: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
1.76 rillig 3323: <p><code class="filename">comp.tgz</code> is part of every NetBSD release. Get
1.75 rillig 3324: the one that corresponds to your release (determine via <span><strong class="command">uname
3325: -r</strong></span>).</p>
3326: </div>
3327: <div class="sect1" lang="en">
3328: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3329: <a name="using-sudo-with-pkgsrc"></a>7.13. Using 'sudo' with pkgsrc</h2></div></div></div>
3330: <p>When installing packages as non-root user and using the just-in-time
3331: <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
3332: password for each required package installed. To avoid this, the sudo
3333: package can be used, which does password caching over a limited time. To
3334: use it, install sudo (either as binary package or from
1.76 rillig 3335: <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
3336: into your <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 3337: <pre class="programlisting">
3338: .if exists(${LOCALBASE}/bin/sudo)
3339: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
3340: .endif
1.1 grant 3341: </pre>
1.75 rillig 3342: </div>
3343: <div class="sect1" lang="en">
3344: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3345: <a name="faq.conf"></a>7.14. How do I change the location of configuration files?</h2></div></div></div>
3346: <p>As the system administrator, you can choose where configuration files
3347: are installed. The default settings make all these files go into
1.76 rillig 3348: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
1.75 rillig 3349: be suboptimal depending on your expectations (e.g., a read-only,
3350: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
3351: configuration of the provided packages).</p>
3352: <p>In order to change the defaults, you can modify the
3353: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.76 rillig 3354: <code class="filename">/etc/mk.conf</code>) to point to your preferred configuration
3355: directory; some common examples include <code class="filename">/etc</code> or
3356: <code class="filename">/etc/pkg</code>.</p>
1.75 rillig 3357: <p>Furthermore, you can change this value on a per-package basis by
3358: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
3359: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
3360: package you would like to modify, that is, the contents of
3361: <code class="varname">PKGBASE</code>.</p>
3362: <p>Note that after changing these settings, you must rebuild and
3363: reinstall any affected packages.</p>
3364: </div>
3365: <div class="sect1" lang="en">
3366: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3367: <a name="audit-packages"></a>7.15. Automated security checks</h2></div></div></div>
3368: <p>Please be aware that there can often be bugs in third-party software,
3369: and some of these bugs can leave a machine vulnerable to exploitation by
3370: attackers. In an effort to lessen the exposure, the NetBSD packages team
3371: maintains a database of known-exploits to packages which have at one time
3372: been included in pkgsrc. The database can be downloaded automatically, and
3373: a security audit of all packages installed on a system can take place. To
1.76 rillig 3374: 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 3375: components:</p>
3376: <div class="orderedlist"><ol type="1">
3377: <li>
3378: <p><span><strong class="command">download-vulnerability-list</strong></span>, an easy way to
3379: download a list of the security vulnerabilities information. This list
3380: is kept up to date by the NetBSD security officer and the NetBSD
3381: packages team, and is distributed from the NetBSD ftp server:</p>
3382: <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>
3383: </li>
3384: <li><p><span><strong class="command">audit-packages</strong></span>, an easy way to audit the
3385: current machine, checking each vulnerability which is known. If a
3386: vulnerable package is installed, it will be shown by output to stdout,
3387: including a description of the type of vulnerability, and a URL
3388: containing more information.</p></li>
3389: </ol></div>
1.76 rillig 3390: <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 3391: package is strongly recommended! After
3392: “<span class="quote">audit-packages</span>” is installed, please read
3393: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
3394: audit-packages</code></strong>.</p>
1.87 wiz 3395: <p>If this package is installed, pkgsrc builds will use it to
3396: perform a security check before building any package. See <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
3397: check.</p>
1.75 rillig 3398: </div>
3399: <div class="sect1" lang="en">
3400: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3401: <a name="ufaq-cflags"></a>7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
3402: <p>When you add your own preferences to the
3403: <code class="varname">CFLAGS</code> variable in your
1.76 rillig 3404: <code class="filename">mk.conf</code>, these flags are passed in
3405: environment variables to the <code class="filename">./configure</code>
1.75 rillig 3406: 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
3407: <code class="varname">CFLAGS</code> from the environment variable by
1.76 rillig 3408: overriding them in the <code class="filename">Makefile</code>s of their
1.75 rillig 3409: package.</p>
3410: <p>Currently there is no solution to this problem. If you
3411: really need the package to use your <code class="varname">CFLAGS</code>
3412: you should run <span><strong class="command">make patch</strong></span> in the package
1.76 rillig 3413: directory and then inspect any <code class="filename">Makefile</code> and
3414: <code class="filename">Makefile.in</code> for whether they define
1.75 rillig 3415: <code class="varname">CFLAGS</code> explicitly. Usually you can remove
3416: these lines. But be aware that some “<span class="quote">smart</span>”
3417: programmers write so bad code that it only works for the
3418: specific combination of <code class="varname">CFLAGS</code> they have
3419: chosen.</p>
3420: </div>
1.80 rillig 3421: <div class="sect1" lang="en">
3422: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.88 ! wiz 3423: <a name="ufaq-fail"></a>7.17. A package does not build. What shall I do?</h2></div></div></div>
1.80 rillig 3424: <div class="procedure"><ol type="1">
3425: <li><p>Make sure that your copy of pkgsrc is consistent. A
3426: case that occurs often is that people only update pkgsrc in
3427: parts, because of performance reasons. Since pkgsrc is one large
3428: system, not a collection of many small systems, there are
3429: sometimes changes that only work when the whole pkgsrc tree is
3430: updated.</p></li>
3431: <li><p>Make sure that you don't have any CVS conflicts.
3432: Search for “<span class="quote"><<<<<<</span>” or
3433: “<span class="quote">>>>>>></span>” in all your pkgsrc
3434: files.</p></li>
3435: <li><p>Make sure that you don't have old copies of the packages
3436: extracted. Run <span><strong class="command">make clean clean-depends</strong></span> to
3437: verify this.</p></li>
3438: <li><p>If the problem still exists, write a mail to the
3439: <code class="literal">pkgsrc-users</code> mailing list.</p></li>
3440: </ol></div>
3441: </div>
1.88 ! wiz 3442: <div class="sect1" lang="en">
! 3443: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 3444: <a name="too-much-time"></a>7.18. I have a little time to kill. What shall I do?</h2></div></div></div>
! 3445: <p>This is not really an FAQ yet, but here's the answer
! 3446: anyway.</p>
! 3447: <div class="itemizedlist"><ul type="disc">
! 3448: <li><p>Run <span><strong class="command">pkg_chk -N</strong></span> (from the
! 3449: <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> package). It
! 3450: will tell you about newer versions of installed packages that are
! 3451: available, but not yet updated in pkgsrc.</p></li>
! 3452: <li><p>Browse <code class="filename">pkgsrc/doc/TODO</code>
! 3453: — it contains a list of suggested new packages and a list of
! 3454: cleanups and enhancements for pkgsrc that would be nice to
! 3455: have.</p></li>
! 3456: <li><p>Review packages for which review was requested on
! 3457: the <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">pkgsrc-wip</a> review
! 3458: mailing list.</p></li>
! 3459: </ul></div>
! 3460: </div>
1.75 rillig 3461: </div>
3462: </div>
3463: <div class="part" lang="en">
3464: <div class="titlepage"><div><div><h1 class="title">
3465: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
1.77 rillig 3466: <div class="partintro" lang="en">
3467: <div></div>
3468: <p>This part of the book deals with creating and
3469: modifying packages. It starts with a “<span class="quote">HOWTO</span>”-like
3470: guide on creating a new package. The remaining chapters are more
3471: like a reference manual for pkgsrc.</p>
1.75 rillig 3472: <div class="toc">
3473: <p><b>Table of Contents</b></p>
3474: <dl>
1.77 rillig 3475: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
3476: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75 rillig 3477: <dd><dl>
1.77 rillig 3478: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
3479: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
3480: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
1.85 jmmv 3481: <dd><dl>
3482: <dt><span class="sect2"><a href="#components.patches.guidelines">9.3.1. Patching guidelines</a></span></dt>
3483: <dt><span class="sect2"><a href="#components.patches.feedback">9.3.2. Feedback to the author</a></span></dt>
3484: </dl></dd>
1.77 rillig 3485: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
3486: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 3487: <dd><dl>
3488: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
3489: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
3490: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
3491: </dl></dd>
1.77 rillig 3492: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
3493: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
3494: </dl></dd>
3495: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
3496: <dd><dl>
3497: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
3498: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
3499: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
3500: <dd><dl>
3501: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
3502: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
3503: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
3504: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
3505: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
3506: </dl></dd>
3507: </dl></dd>
3508: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
3509: <dd><dl>
3510: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
3511: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
3512: <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>
3513: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
3514: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
3515: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
3516: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
3517: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
3518: </dl></dd>
3519: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
3520: <dd><dl>
3521: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
3522: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
3523: <dd><dl>
3524: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
3525: <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>
3526: </dl></dd>
3527: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
3528: <dd><dl>
3529: <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>
3530: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
3531: </dl></dd>
3532: </dl></dd>
3533: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
3534: <dd><dl>
3535: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
3536: <dd><dl>
3537: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
3538: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
3539: </dl></dd>
3540: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
3541: <dd><dl>
3542: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
3543: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
3544: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
3545: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
3546: </dl></dd>
3547: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
3548: <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>
3549: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
3550: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
3551: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
3552: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
3553: <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>
3554: </dl></dd>
3555: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
3556: <dd><dl>
3557: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
3558: <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>
3559: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
3560: </dl></dd>
3561: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
3562: <dd><dl>
3563: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
3564: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
3565: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
3566: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
3567: <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 3568: <dd><dl>
3569: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
3570: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
3571: </dl></dd>
1.77 rillig 3572: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
3573: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
3574: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
3575: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
3576: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
3577: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
3578: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3579: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
3580: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3581: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
1.88 ! wiz 3582: <dt><span class="sect1"><a href="#build.clean">15.16. Cleaning up</a></span></dt>
! 3583: <dt><span class="sect1"><a href="#build.helpful-targets">15.17. Other helpful targets</a></span></dt>
1.77 rillig 3584: </dl></dd>
3585: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
3586: <dd><dl>
3587: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
3588: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
3589: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
3590: </dl></dd>
3591: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
3592: <dd><dl>
3593: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
3594: <dd><dl>
1.78 rillig 3595: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
3596: <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>
3597: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
3598: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
3599: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
3600: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
3601: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
3602: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
3603: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
3604: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
3605: <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 3606: <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 3607: </dl></dd>
3608: <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>
3609: <dd><dl>
3610: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
3611: <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>
3612: </dl></dd>
3613: <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>
3614: <dd><dl>
3615: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
3616: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
3617: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
3618: </dl></dd>
1.87 wiz 3619: <dt><span class="sect1"><a href="#programming-languages">17.4. Programming languages</a></span></dt>
1.77 rillig 3620: <dd><dl>
1.87 wiz 3621: <dt><span class="sect2"><a href="#basic-programming-languages">17.4.1. C, C++, and Fortran</a></span></dt>
3622: <dt><span class="sect2"><a href="#java-programming-language">17.4.2. Java</a></span></dt>
3623: <dt><span class="sect2"><a href="#perl-scripts">17.4.3. Packages containing perl scripts</a></span></dt>
3624: <dt><span class="sect2"><a href="#other-programming-languages">17.4.4. Other programming languages</a></span></dt>
3625: </dl></dd>
3626: <dt><span class="sect1"><a href="#fixes.build">17.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3627: <dd><dl>
3628: <dt><span class="sect2"><a href="#fixes.build.cpp">17.5.1. Compiling C and C++ code conditionally</a></span></dt>
3629: <dt><span class="sect2"><a href="#compiler-bugs">17.5.2. How to handle compiler bugs</a></span></dt>
3630: <dt><span class="sect2"><a href="#undefined-reference">17.5.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
3631: <dt><span class="sect2"><a href="#out-of-memory">17.5.4. Running out of memory</a></span></dt>
3632: </dl></dd>
3633: <dt><span class="sect1"><a href="#fixes.install">17.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3634: <dd><dl>
3635: <dt><span class="sect2"><a href="#install-scripts">17.6.1. Creating needed directories</a></span></dt>
3636: <dt><span class="sect2"><a href="#where-to-install-documentation">17.6.2. Where to install documentation</a></span></dt>
3637: <dt><span class="sect2"><a href="#installing-score-files">17.6.3. Installing score files</a></span></dt>
3638: <dt><span class="sect2"><a href="#hardcoded-paths">17.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
3639: <dt><span class="sect2"><a href="#perl-modules">17.6.5. Packages installing perl modules</a></span></dt>
3640: <dt><span class="sect2"><a href="#faq.info-files">17.6.6. Packages installing info files</a></span></dt>
3641: <dt><span class="sect2"><a href="#manpages">17.6.7. Packages installing man pages</a></span></dt>
3642: <dt><span class="sect2"><a href="#gconf2-data-files">17.6.8. Packages installing GConf2 data files</a></span></dt>
3643: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.6.9. Packages installing scrollkeeper data files</a></span></dt>
3644: <dt><span class="sect2"><a href="#x11-fonts">17.6.10. Packages installing X11 fonts</a></span></dt>
3645: <dt><span class="sect2"><a href="#gtk2-modules">17.6.11. Packages installing GTK2 modules</a></span></dt>
3646: <dt><span class="sect2"><a href="#sgml-xml-data">17.6.12. Packages installing SGML or XML data</a></span></dt>
3647: <dt><span class="sect2"><a href="#mime-database">17.6.13. Packages installing extensions to the MIME database</a></span></dt>
3648: <dt><span class="sect2"><a href="#intltool">17.6.14. Packages using intltool</a></span></dt>
3649: <dt><span class="sect2"><a href="#startup-scripts">17.6.15. Packages installing startup scripts</a></span></dt>
3650: <dt><span class="sect2"><a href="#tex-packages">17.6.16. Packages installing TeX modules</a></span></dt>
3651: <dt><span class="sect2"><a href="#emulation-packages">17.6.17. Packages supporting running binaries in
3652: emulation</a></span></dt>
3653: <dt><span class="sect2"><a href="#hicolor-theme">17.6.18. Packages installing hicolor theme icons</a></span></dt>
3654: <dt><span class="sect2"><a href="#desktop-files">17.6.19. Packages installing desktop files</a></span></dt>
1.77 rillig 3655: </dl></dd>
1.87 wiz 3656: <dt><span class="sect1"><a href="#punting">17.7. Marking packages as having problems</a></span></dt>
1.77 rillig 3657: </dl></dd>
3658: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
3659: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
3660: <dd><dl>
3661: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
3662: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
3663: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
3664: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
3665: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
3666: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 3667: </dl></dd>
1.77 rillig 3668: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.85 jmmv 3669: <dt><span class="chapter"><a href="#gnome">21. GNOME packaging and porting</a></span></dt>
3670: <dd><dl>
3671: <dt><span class="sect1"><a href="#meta-packages">21.1. Meta packages</a></span></dt>
3672: <dt><span class="sect1"><a href="#new-package">21.2. Packaging a GNOME application</a></span></dt>
3673: <dt><span class="sect1"><a href="#full-update">21.3. Updating GNOME to a newer version</a></span></dt>
3674: <dt><span class="sect1"><a href="#patching">21.4. Patching guidelines</a></span></dt>
3675: </dl></dd>
1.75 rillig 3676: </dl>
3677: </div>
1.77 rillig 3678: </div>
3679: <div class="chapter" lang="en">
3680: <div class="titlepage"><div><div><h2 class="title">
3681: <a name="creating"></a>Chapter 8. Creating a new pkgsrc package from scratch</h2></div></div></div>
3682: <p>When you find a package that is not yet in pkgsrc, you
3683: most likely have a URL from where you can download the source
3684: code. Starting with this URL, creating a package involves only a
3685: few steps.</p>
3686: <div class="procedure"><ol type="1">
3687: <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>
3688: <li><p>Then, choose one of the top-level directories as the
3689: category in which you want to place your package. You can also
3690: create a directory of your own (maybe called
3691: <code class="filename">local</code>). In that category directory, create
3692: another directory for your package and change into
3693: it.</p></li>
3694: <li><p>Run the program <span><strong class="command">url2pkg</strong></span>, which
3695: will ask you for a URL. Enter the URL of the distribution file
3696: (in most cases a <code class="filename">.tar.gz</code> file) and watch
3697: how the basic ingredients of your package are created
3698: automatically. The distribution file is extracted automatically
3699: to fill in some details in the <code class="filename">Makefile</code>
3700: that would otherwise have to be done manually.</p></li>
3701: <li>
3702: <p>Examine the extracted files to determine the
3703: dependencies of your package. Ideally, this is mentioned in some
3704: <code class="filename">README</code> file, but things may differ. For
3705: each of these dependencies, look where it exists in pkgsrc, and
3706: if there is a file called <code class="filename">buildlink3.mk</code> in
3707: that directory, add a line to your package
3708: <code class="filename">Makefile</code> which includes that file just
3709: before the last line. If the <code class="filename">buildlink3.mk</code>
3710: file does not exist, add a <code class="varname">DEPENDS</code> line to
3711: the Makefile, which specifies the version of the dependency and
3712: where it can be found in pkgsrc. This line should be placed in
3713: the third paragraph. If the dependency is only needed for
3714: building the package, but not when using it, use
3715: <code class="varname">BUILD_DEPENDS</code> instead of
3716: <code class="varname">DEPENDS</code>. Your package may then look like
3717: this:</p>
3718: <pre class="programlisting">
3719: [...]
3720:
3721: BUILD_DEPENDS+= lua>=5.0:../../lang/lua
3722: DEPENDS+= screen-[0-9]*:../../misc/screen
3723: DEPENDS+= screen>=4.0:../../misc/screen
3724:
3725: [...]
3726:
3727: .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
3728: .include "../../devel/glib2/buildlink3.mk"
3729: .include "../../mk/bsd.pkg.mk"
3730: </pre>
3731: </li>
3732: <li><p>Run <span><strong class="command">pkglint</strong></span> to see what things
3733: still need to be done to make your package a “<span class="quote">good</span>”
3734: one. If you don't know what pkglint's warnings want to tell you,
3735: try <span><strong class="command">pkglint --explain</strong></span> or <span><strong class="command">pkglint
3736: -e</strong></span>, which outputs additional
3737: explanations.</p></li>
3738: <li><p>Now, run <span><strong class="command">bmake</strong></span> to build the
3739: package. For the various things that can go wrong in this phase,
3740: consult <a href="#fixes" title="Chapter 17. Making your package work">Chapter 17, <i>Making your package work</i></a>.</p></li>
3741: <li><p>When the package builds fine, the next step is to
3742: install the package. Run <span><strong class="command">bmake install</strong></span> and
3743: hope that everything works.</p></li>
3744: <li><p>Up to now, the file <code class="filename">PLIST</code>,
3745: which contains a list of the files that are installed by the
3746: package, is nearly empty. Run <span><strong class="command">bmake print-PLIST
3747: >PLIST</strong></span> to generate a probably correct list. Check
3748: the file using your preferred text editor to see if the list of
3749: files looks plausible.</p></li>
3750: <li><p>Run <span><strong class="command">pkglint</strong></span> again to see if the
3751: generated <code class="filename">PLIST</code> contains garbage or
3752: not.</p></li>
3753: <li><p>When you ran <span><strong class="command">bmake install</strong></span>, the
3754: package has been registered in the database of installed files,
3755: but with an empty list of files. To fix this, run <span><strong class="command">bmake
3756: deinstall</strong></span> and <span><strong class="command">bmake install</strong></span> again.
3757: Now the package is registered with the list of files from
3758: <code class="filename">PLIST</code>.</p></li>
3759: <li><p>Run <span><strong class="command">bmake package</strong></span> to create a
3760: binary package from the set of installed files.</p></li>
3761: </ol></div>
3762: </div>
1.75 rillig 3763: <div class="chapter" lang="en">
3764: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3765: <a name="components"></a>Chapter 9. Package components - files, directories and contents</h2></div></div></div>
1.75 rillig 3766: <div class="toc">
3767: <p><b>Table of Contents</b></p>
3768: <dl>
1.77 rillig 3769: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
3770: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
3771: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
1.85 jmmv 3772: <dd><dl>
3773: <dt><span class="sect2"><a href="#components.patches.guidelines">9.3.1. Patching guidelines</a></span></dt>
3774: <dt><span class="sect2"><a href="#components.patches.feedback">9.3.2. Feedback to the author</a></span></dt>
3775: </dl></dd>
1.77 rillig 3776: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
3777: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 3778: <dd><dl>
3779: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
3780: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
3781: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
3782: </dl></dd>
1.77 rillig 3783: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
3784: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
1.75 rillig 3785: </dl>
3786: </div>
1.87 wiz 3787: <p>Whenever you're preparing a package, there are a number of
3788: files involved which are described in the following
3789: sections.</p>
1.75 rillig 3790: <div class="sect1" lang="en">
3791: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3792: <a name="components.Makefile"></a>9.1. <code class="filename">Makefile</code></h2></div></div></div>
1.75 rillig 3793: <p>Building, installation and creation of a binary package are all
1.87 wiz 3794: controlled by the package's <code class="filename">Makefile</code>.
3795: The <code class="filename">Makefile</code> describes various things about
3796: a package, for example from where to get it, how to configure,
3797: build, and install it.</p>
1.76 rillig 3798: <p>A package <code class="filename">Makefile</code> contains several
1.87 wiz 3799: sections that describe the package.</p>
1.75 rillig 3800: <p>In the first section there are the following variables, which
1.87 wiz 3801: should appear exactly in the order given here. The order and
3802: grouping of the variables is mostly historical and has no further
3803: meaning.</p>
1.75 rillig 3804: <div class="itemizedlist"><ul type="disc">
3805: <li><p><code class="varname">DISTNAME</code> is the basename of the
1.87 wiz 3806: distribution file to be downloaded from the package's
3807: website.</p></li>
1.75 rillig 3808: <li><p><code class="varname">PKGNAME</code> is the name of the
1.87 wiz 3809: package, as used by pkgsrc. You only need to provide it if
3810: <code class="varname">DISTNAME</code> (which is the default) is not a good
3811: name for the package in pkgsrc. Usually it is the pkgsrc
3812: directory name together with the version number. It must match the
3813: regular expression
3814: <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
3815: starts with a letter or digit, and contains only letters, digits,
3816: dashes, underscores, dots and plus signs.</p></li>
3817: <li><p><code class="varname">SVR4_PKGNAME</code> is the name of
3818: the package file to create if the <code class="varname">PKGNAME</code>
3819: isn't unique on a SVR4 system. The default is
3820: <code class="varname">PKGNAME</code>, which may be shortened when you use
3821: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/gensolpkg/README.html" target="_top"><code class="filename">pkgtools/gensolpkg</code></a>. Only add
3822: <code class="varname">SVR4_PKGNAME</code> if <code class="varname">PKGNAME</code>
3823: does not produce an unique package name on a SVR4 system.
3824: The length of <code class="varname">SVR4_PKGNAME</code> is limited to 5
3825: characters.</p></li>
1.75 rillig 3826: <li>
3827: <p><code class="varname">CATEGORIES</code> is a list of categories
1.87 wiz 3828: which the package fits in. You can choose any of the top-level
3829: directories of pkgsrc for it.</p>
1.75 rillig 3830: <p>Currently the following values are available for
1.87 wiz 3831: <code class="varname">CATEGORIES</code>. If more than
3832: one is used, they need to be separated by spaces:</p>
1.75 rillig 3833: <pre class="programlisting">
1.87 wiz 3834: archivers cross geography meta-pkgs security
3835: audio databases graphics misc shells
3836: benchmarks devel ham multimedia sysutils
3837: biology editors inputmethod net textproc
3838: cad emulators lang news time
3839: chat finance mail parallel wm
3840: comms fonts math pkgtools www
3841: converters games mbone print x11
3842: </pre>
1.75 rillig 3843: </li>
1.81 rillig 3844: <li><p><code class="varname">MASTER_SITES</code>,
1.87 wiz 3845: <code class="varname">DYNAMIC_MASTER_SITES</code>,
3846: <code class="varname">DIST_SUBDIR</code>, <code class="varname">EXTRACT_SUFX</code>
3847: and <code class="varname">DISTFILES</code> are discussed in detail in
3848: <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 3849: </ul></div>
3850: <p>The second section contains information about separately
1.87 wiz 3851: downloaded patches, if any.
3852: </p>
1.75 rillig 3853: <div class="itemizedlist"><ul type="disc">
3854: <li><p><code class="varname">PATCHFILES:</code>
1.87 wiz 3855: Name(s) of additional files that contain distribution patches.
3856: There is no default. pkgsrc will look for them at
3857: <code class="varname">PATCH_SITES</code>.
3858: They will automatically be uncompressed before patching if
3859: the names end with <code class="filename">.gz</code> or
3860: <code class="filename">.Z</code>.</p></li>
1.75 rillig 3861: <li><p><code class="varname">PATCH_SITES</code>:
1.87 wiz 3862: Primary location(s) for distribution patch files (see
3863: <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
1.75 rillig 3864: </ul></div>
3865: <p>The third section contains the following variables.
1.87 wiz 3866: </p>
1.75 rillig 3867: <div class="itemizedlist"><ul type="disc">
3868: <li><p><code class="varname">MAINTAINER</code> is the email address
1.87 wiz 3869: of the person who feels responsible for this package, and who is
3870: most likely to look at problems or questions regarding this
3871: 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
3872: developers should contact the <code class="varname">MAINTAINER</code> before
3873: making major changes to the package. When packaging a new program,
3874: set <code class="varname">MAINTAINER</code> to yourself. If you really can't
3875: maintain the package for future updates, set it to
3876: <code class="email"><<a href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>></code>.</p></li>
1.75 rillig 3877: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
1.87 wiz 3878: find more information about the package.</p></li>
1.75 rillig 3879: <li><p><code class="varname">COMMENT</code> is a one-line
1.87 wiz 3880: description of the package (should not include the package
3881: name).</p></li>
1.75 rillig 3882: </ul></div>
3883: <p>Other variables that affect the build:
1.87 wiz 3884: </p>
1.75 rillig 3885: <div class="itemizedlist"><ul type="disc"><li>
3886: <p><code class="varname">WRKSRC</code>: The directory where the
1.87 wiz 3887: interesting distribution files of the package are found. The
3888: default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
3889: works for most packages.</p>
1.75 rillig 3890: <p>If a package doesn't create a subdirectory for itself
1.87 wiz 3891: (most GNU software does, for instance), but extracts itself in
3892: the current directory, you should set
3893: <code class="varname">WRKSRC=${WRKDIR}</code>.</p>
3894: <p>If a package doesn't create a subdirectory with the
3895: name of <code class="varname">DISTNAME</code> but some different name,
3896: set <code class="varname">WRKSRC</code> to point to the proper name in
3897: <code class="filename">${WRKDIR}</code>, for example
3898: <code class="varname">WRKSRC=${WRKDIR}/${DISTNAME}/unix</code>. See
3899: <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 3900: <p>The name of the working directory created by pkgsrc is
1.87 wiz 3901: taken from the <code class="varname">WRKDIR_BASENAME</code>
3902: variable. By default, its value is
3903: <code class="filename">work</code>. If you want to use the same
3904: pkgsrc tree for building different kinds of binary packages,
3905: you can change the variable according to your needs. Two
3906: other variables handle common cases of setting
3907: <code class="varname">WRKDIR_BASENAME</code> individually. If
3908: <code class="varname">OBJHOSTNAME</code> is defined in
3909: <code class="filename">/etc/mk.conf</code>, the first component of
3910: the host's name is attached to the directory name. If
3911: <code class="varname">OBJMACHINE</code> is defined, the platform name
3912: is attached, which might look like
3913: <code class="filename">work.i386</code> or
3914: <code class="filename">work.sparc</code>.</p>
1.75 rillig 3915: </li></ul></div>
3916: <p>Please pay attention to the following gotchas:</p>
3917: <div class="itemizedlist"><ul type="disc">
1.87 wiz 3918: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are
1.88 ! wiz 3919: installed in compressed form by the package. For packages using
! 3920: BSD-style makefiles which honor MANZ, there is
! 3921: <code class="varname">MANCOMPRESSED_IF_MANZ</code>.</p></li>
1.76 rillig 3922: <li><p>Replace <code class="filename">/usr/local</code> with
1.88 ! wiz 3923: “<span class="quote">${PREFIX}</span>” in all files (see patches,
! 3924: below).</p></li>
! 3925: <li><p>If the package installs any info files, see <a href="#faq.info-files" title="17.6.6. Packages installing info files">Section 17.6.6, “Packages installing info files”</a>.</p></li>
1.75 rillig 3926: </ul></div>
3927: </div>
3928: <div class="sect1" lang="en">
3929: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3930: <a name="components.distinfo"></a>9.2. <code class="filename">distinfo</code></h2></div></div></div>
1.76 rillig 3931: <p>The <code class="filename">distinfo</code> file contains the message
1.87 wiz 3932: digest, or checksum, of each distfile needed for the package. This
3933: ensures that the distfiles retrieved from the Internet have not been
3934: corrupted during transfer or altered by a malign force to introduce
3935: a security hole. Due to recent rumor about weaknesses of digest
3936: algorithms, all distfiles are protected using both SHA1 and RMD160
3937: message digests, as well as the file size.</p>
1.76 rillig 3938: <p>The <code class="filename">distinfo</code> file also contains the
1.87 wiz 3939: checksums for all the patches found in the
3940: <code class="filename">patches</code> directory (see <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a>).</p>
1.76 rillig 3941: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.87 wiz 3942: <span><strong class="command">make makedistinfo</strong></span> or <span><strong class="command">make mdi</strong></span>
3943: command.</p>
1.75 rillig 3944: <p>Some packages have different sets of distfiles depending on
1.87 wiz 3945: 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
3946: <code class="filename">distinfo</code> file and care should be taken when
3947: upgrading such a package to ensure distfile information is not
3948: lost.</p>
1.75 rillig 3949: </div>
3950: <div class="sect1" lang="en">
3951: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3952: <a name="components.patches"></a>9.3. patches/*</h2></div></div></div>
1.75 rillig 3953: <p>This directory contains files that are used by the
1.87 wiz 3954: <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
3955: modify the sources as distributed in the distribution file into a form
3956: that will compile and run perfectly on NetBSD. The files are applied
3957: successively in alphabetic order (as returned by a shell
3958: “<span class="quote">patches/patch-*</span>” glob expansion), so
3959: <code class="filename">patch-aa</code> is applied before
3960: <code class="filename">patch-ab</code>, etc.</p>
1.76 rillig 3961: <p>The <code class="filename">patch-*</code> files should be in
1.87 wiz 3962: <span><strong class="command">diff -bu</strong></span> format, and apply without a fuzz to avoid
3963: problems. (To force patches to apply
3964: with fuzz you can set <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>).
3965: Furthermore, do not put changes for more than one file into a single
3966: patch file, as this will make future modifications more difficult.</p>
1.75 rillig 3967: <p>Similar, a file should be patched at most once, not several times by
1.87 wiz 3968: several different patches. If a file needs several patches, they should
3969: be combined into one file.</p>
1.75 rillig 3970: <p>One important thing to mention is to pay attention that no RCS IDs
1.87 wiz 3971: get stored in the patch files, as these will cause problems when
3972: later checked into the NetBSD CVS tree. Use the
3973: <span><strong class="command">pkgdiff</strong></span> from the
3974: <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
3975: these problems.</p>
3976: <p>For even more automation, we recommend using
3977: <span><strong class="command">mkpatches</strong></span> from the same package to make a
3978: whole set of patches. You just have to backup files before you
3979: edit them to <code class="filename">filename.orig</code>, e.g. with
3980: <span><strong class="command">cp -p filename filename.orig</strong></span> or, easier, by
3981: using <span><strong class="command">pkgvi</strong></span> again from the same package. If
3982: you upgrade a package this way, you can easily compare the new
3983: set of patches with the previously existing one with
3984: <span><strong class="command">patchdiff</strong></span>. Copy the patches you want to use
3985: or update from the <code class="filename">work/.newpatches</code>
3986: directory to <code class="filename">patches/</code>.</p>
3987: <p>When you have finished a package, remember to generate
3988: the checksums for the patch files by using the <span><strong class="command">make
3989: makepatchsum</strong></span> command, see <a href="#components.distinfo" title="9.2. distinfo">Section 9.2, “<code class="filename">distinfo</code>”</a>.</p>
3990: <p>When adding a patch that corrects a problem in the
3991: distfile (rather than e.g. enforcing pkgsrc's view of where
3992: man pages should go), send the patch as a bug report to the
3993: maintainer. This benefits non-pkgsrc users of the package,
3994: and usually makes it possible to remove the patch in future
3995: version.</p>
3996: <p>If you want to share patches between multiple packages
3997: in pkgsrc, e.g. because they use the same distfiles, set
3998: <code class="varname">PATCHDIR</code> to the path where the patch files
3999: can be found, e.g.:</p>
4000: <pre class="programlisting">
4001: PATCHDIR= ${.CURDIR}/../xemacs/patches
4002: </pre>
1.75 rillig 4003: <p>Patch files that are distributed by the author or other
1.87 wiz 4004: maintainers can be listed in
4005: <code class="varname">PATCHFILES</code>.</p>
4006: <p>If it is desired to store any patches that should not be
4007: committed into pkgsrc, they can be kept outside the pkgsrc
4008: tree in the <code class="filename">$LOCALPATCHES</code> directory. The
4009: directory tree there is expected to have the same
4010: “<span class="quote">category/package</span>” structure as pkgsrc, and
4011: patches are expected to be stored inside these dirs (also
4012: known as <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
4013: example, if you want to keep a private patch for
4014: <code class="filename">pkgsrc/graphics/png</code>, keep it in
4015: <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
4016: files in the named directory are expected to be patch files,
4017: and <span class="emphasis"><em>they are applied after pkgsrc patches are
4018: applied</em></span>.</p>
1.85 jmmv 4019: <div class="sect2" lang="en">
4020: <div class="titlepage"><div><div><h3 class="title">
4021: <a name="components.patches.guidelines"></a>9.3.1. Patching guidelines</h3></div></div></div>
4022: <p>When fixing a portability issue in the code do not use
4023: preprocessor magic to check for the current operating system nor
4024: platform. Doing so hurts portability to other platforms because
4025: the OS-specific details are not abstracted appropriately.</p>
4026: <p>The general rule to follow is: instead of checking for the
4027: operating system the application is being built on, check for the
4028: specific <span class="emphasis"><em>features</em></span> you need. For example,
4029: instead of assuming that kqueue is available under NetBSD and
4030: using the <code class="varname">__NetBSD__</code> macro to conditionalize
1.87 wiz 4031: kqueue support, add a check that detects kqueue itself —
1.85 jmmv 4032: yes, this generally involves patching the
4033: <span><strong class="command">configure</strong></span> script. There is absolutely nothing
4034: that prevents some OSes from adopting interfaces from other OSes
4035: (e.g. Linux implementing kqueue), something that the above checks
4036: cannot take into account.</p>
4037: <p>Of course, checking for features generally involves more
4038: work on the developer's side, but the resulting changes are
1.87 wiz 4039: cleaner and there are chances they will work on many other
1.85 jmmv 4040: platforms. Not to mention that there are higher chances of being
4041: later integrated into the mainstream sources. Remember:
4042: <span class="emphasis"><em>It doesn't work unless it is right!</em></span></p>
4043: <p>Some typical examples:</p>
4044: <div class="table">
4045: <a name="patch-examples"></a><p class="title"><b>Table 9.1. Patching examples</b></p>
4046: <div class="table-contents"><table summary="Patching examples" border="1">
4047: <colgroup>
4048: <col>
4049: <col>
4050: <col>
4051: </colgroup>
4052: <thead><tr>
4053: <th>Where</th>
4054: <th>Incorrect</th>
4055: <th>Correct</th>
4056: </tr></thead>
4057: <tbody>
4058: <tr>
4059: <td>configure script</td>
4060: <td>
4061: <pre class="programlisting">case ${target_os} in
1.87 wiz 4062: netbsd*) have_kvm=yes ;;
4063: *) have_kvm=no ;;
4064: esac</pre>
1.85 jmmv 4065: </td>
4066: <td>
4067: <pre class="programlisting">AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)</pre>
4068: </td>
4069: </tr>
4070: <tr>
4071: <td>C source file</td>
4072: <td>
4073: <pre class="programlisting">#if defined(__NetBSD__)
1.87 wiz 4074: # include <sys/event.h>
4075: #endif</pre>
1.85 jmmv 4076: </td>
4077: <td>
4078: <pre class="programlisting">#if defined(HAVE_SYS_EVENT_H)
1.87 wiz 4079: # include <sys/event.h>
4080: #endif</pre>
1.85 jmmv 4081: </td>
4082: </tr>
4083: <tr>
4084: <td>C source file</td>
4085: <td>
4086: <pre class="programlisting">int
1.87 wiz 4087: monitor_file(...)
4088: {
4089: #if defined(__NetBSD__)
4090: int fd = kqueue();
4091: ...
4092: #else
4093: ...
4094: #endif
4095: }</pre>
1.85 jmmv 4096: </td>
4097: <td>
4098: <pre class="programlisting">int
1.87 wiz 4099: monitor_file(...)
4100: {
4101: #if defined(HAVE_KQUEUE)
4102: int fd = kqueue();
4103: ...
4104: #else
4105: ...
4106: #endif
4107: }</pre>
1.85 jmmv 4108: </td>
4109: </tr>
4110: </tbody>
4111: </table></div>
4112: </div>
4113: <br class="table-break"><p>For more information, please read the <span class="emphasis"><em>Making
4114: packager-friendly software</em></span> article (<a href="http://www.onlamp.com/pub/a/onlamp/2005/03/31/packaging.html" target="_top">part
4115: 1</a>, <a href="http://www.oreillynet.com/pub/a/onlamp/2005/04/28/packaging2.html" target="_top">part
4116: 2</a>). It summarizes multiple details on how to make
4117: software easier to package; all the suggestions in it were
4118: collected from our experience in pkgsrc work, so they are possibly
4119: helpful when creating patches too.</p>
4120: </div>
4121: <div class="sect2" lang="en">
4122: <div class="titlepage"><div><div><h3 class="title">
4123: <a name="components.patches.feedback"></a>9.3.2. Feedback to the author</h3></div></div></div>
4124: <p>Always, always, <span class="strong"><strong>always</strong></span>
4125: feed back any <span class="emphasis"><em>portability fixes</em></span> or
4126: improvements you do to a package to the mainstream developers.
4127: This is the only way to get their attention on portability issues
4128: and to ensure that future versions can be built out-of-the box on
4129: NetBSD. Furthermore, any user that gets newer distfiles will get
4130: the fixes straight from the packaged code.</p>
4131: <p>This generally involves cleaning up the patches as described
4132: in the following section (because sometimes the patches that are
4133: added to pkgsrc are quick hacks), filling bug reports in the
4134: appropriate trackers for the projects and working with the
4135: mainstream authors to accept your changes. It is
4136: <span class="emphasis"><em>extremely important</em></span> that you do it so that
4137: the packages in pkgsrc are kept simple and thus further changes
4138: can be done without much hassle.</p>
4139: <p>Support the idea of free software!</p>
4140: </div>
1.75 rillig 4141: </div>
4142: <div class="sect1" lang="en">
4143: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4144: <a name="other-mandatory-files"></a>9.4. Other mandatory files</h2></div></div></div>
1.75 rillig 4145: <div class="variablelist"><dl>
1.76 rillig 4146: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
1.75 rillig 4147: <dd><p>A multi-line description of the piece of software. This should include
1.87 wiz 4148: any credits where they are due. Please bear in mind that others do not
4149: share your sense of humour (or spelling idiosyncrasies), and that others
4150: will read everything that you write here.</p></dd>
1.76 rillig 4151: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
1.87 wiz 4152: <dd><p>This file governs the files that are installed on your
4153: system: all the binaries, manual pages, etc. There are other
4154: directives which may be entered in this file, to control the
4155: creation and deletion of directories, and the location of
4156: inserted files. See <a href="#plist" title="Chapter 11. PLIST issues">Chapter 11, <i>PLIST issues</i></a> for more
4157: information.</p></dd>
1.75 rillig 4158: </dl></div>
4159: </div>
4160: <div class="sect1" lang="en">
4161: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4162: <a name="components.optional"></a>9.5. Optional files</h2></div></div></div>
1.78 rillig 4163: <div class="sect2" lang="en">
4164: <div class="titlepage"><div><div><h3 class="title">
4165: <a name="components.optional.bin"></a>9.5.1. Files affecting the binary package</h3></div></div></div>
1.75 rillig 4166: <div class="variablelist"><dl>
1.76 rillig 4167: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.75 rillig 4168: <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>.
1.87 wiz 4169: First time after package extraction and before files are
4170: moved in place, the second time after the files to install
4171: are moved in place. This can be used to do any custom
4172: procedures not possible with @exec commands in
4173: <code class="filename">PLIST</code>. See <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
4174: <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. See also <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>.</p></dd>
1.76 rillig 4175: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
1.75 rillig 4176: <dd><p>This script is executed before and after any files are removed. It is
1.87 wiz 4177: this script's responsibility to clean up any additional messy details
4178: around the package's installation, since all pkg_delete knows is how to
4179: delete the files created in the original distribution.
4180: 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>
4181: 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 4182: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
1.75 rillig 4183: <dd>
4184: <p>This file is displayed after installation of the package.
1.87 wiz 4185: Useful for things like legal notices on almost-free
4186: software and hints for updating config files after
4187: installing modules for apache, PHP etc.
4188: Please note that you can modify variables in it easily by using
4189: <code class="varname">MESSAGE_SUBST</code> in the package's
4190: <code class="filename">Makefile</code>:</p>
1.75 rillig 4191: <pre class="programlisting">
1.87 wiz 4192: MESSAGE_SUBST+= SOMEVAR="somevalue"
4193: </pre>
1.75 rillig 4194: <p>replaces "${SOMEVAR}" with “<span class="quote">somevalue</span>” in
1.87 wiz 4195: <code class="filename">MESSAGE</code>. By default, substitution is
4196: performed for <code class="varname">PKGNAME</code>,
4197: <code class="varname">PKGBASE</code>, <code class="varname">PREFIX</code>,
4198: <code class="varname">LOCALBASE</code>, <code class="varname">X11PREFIX</code>,
4199: <code class="varname">X11BASE</code>,
4200: <code class="varname">PKG_SYSCONFDIR</code>,
4201: <code class="varname">ROOT_GROUP</code>, and
4202: <code class="varname">ROOT_GROUP</code>.</p>
4203: <p>You can display a different or additional files by
4204: setting the <code class="varname">MESSAGE_SRC</code> variable. Its
4205: default is <code class="filename">MESSAGE</code>, if the file
4206: exists.</p>
1.75 rillig 4207: </dd>
1.78 rillig 4208: <dt><span class="term"><code class="filename">ALTERNATIVES</code></span></dt>
4209: <dd><p>FIXME: There is no documentation on the
4210: alternatives framework.</p></dd>
4211: </dl></div>
4212: </div>
4213: <div class="sect2" lang="en">
4214: <div class="titlepage"><div><div><h3 class="title">
4215: <a name="components.optional.build"></a>9.5.2. Files affecting the build process</h3></div></div></div>
4216: <div class="variablelist"><dl>
4217: <dt><span class="term"><code class="filename">Makefile.common</code></span></dt>
4218: <dd><p>This file contains arbitrary things that could
4219: also go into a <code class="filename">Makefile</code>, but its purpose is
4220: to be used by more than one package. This file should only be
4221: used when the packages that will use the file are known in
4222: advance. For other purposes it is often better to write a
4223: <code class="filename">*.mk</code> file and give it a good name that
4224: describes what it does.</p></dd>
4225: <dt><span class="term"><code class="filename">buildlink3.mk</code></span></dt>
4226: <dd><p>This file contains the dependency information
4227: for the buildlink3 framework (see <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a>).</p></dd>
4228: <dt><span class="term"><code class="filename">hacks.mk</code></span></dt>
4229: <dd><p>This file contains workarounds for compiler bugs
4230: and similar things. It is included automatically by the pkgsrc
4231: infrastructure, so you don't need an extra
4232: <code class="literal">.include</code> line for
4233: it.</p></dd>
4234: <dt><span class="term"><code class="filename">options.mk</code></span></dt>
4235: <dd><p>This file contains the code for the
4236: package-specific options (see <a href="#options" title="Chapter 14. Options handling">Chapter 14, <i>Options handling</i></a>) that can be
4237: selected by the user. If a package has only one or two options,
4238: it is equally acceptable to put the code directly into the
4239: <code class="filename">Makefile</code>.</p></dd>
4240: </dl></div>
4241: </div>
4242: <div class="sect2" lang="en">
4243: <div class="titlepage"><div><div><h3 class="title">
4244: <a name="components.optional.none"></a>9.5.3. Files affecting nothing at all</h3></div></div></div>
4245: <div class="variablelist"><dl>
4246: <dt><span class="term"><code class="filename">README*</code></span></dt>
4247: <dd><p>These files do not take place in the creation of
4248: a package and thus are purely informative to the package
4249: developer.</p></dd>
4250: <dt><span class="term"><code class="filename">TODO</code></span></dt>
4251: <dd><p>This file contains things that need to be done
4252: to make the package even
4253: better.</p></dd>
1.75 rillig 4254: </dl></div>
4255: </div>
1.78 rillig 4256: </div>
1.75 rillig 4257: <div class="sect1" lang="en">
4258: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4259: <a name="work-dir"></a>9.6. <code class="filename">work*</code></h2></div></div></div>
1.75 rillig 4260: <p>When you type <span><strong class="command">make</strong></span>, the distribution files are
1.87 wiz 4261: unpacked into the directory denoted by
4262: <code class="varname">WRKDIR</code>. It can be removed by running
4263: <span><strong class="command">make clean</strong></span>. Besides the sources, this
4264: directory is also used to keep various timestamp files.
4265: The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
4266: The default is <code class="filename">${.CURDIR}/work</code>
4267: or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
4268: if <code class="varname">OBJMACHINE</code> is set.</p>
1.75 rillig 4269: </div>
4270: <div class="sect1" lang="en">
4271: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4272: <a name="files-dir"></a>9.7. <code class="filename">files/*</code></h2></div></div></div>
1.75 rillig 4273: <p>If you have any files that you wish to be placed in the package prior
1.87 wiz 4274: to configuration or building, you could place these files here and use
4275: a <span><strong class="command">${CP}</strong></span> command in the
4276: “<span class="quote">pre-configure</span>” target to achieve
4277: this. Alternatively, you could simply diff the file against
4278: <code class="filename">/dev/null</code> and use the patch mechanism to manage
4279: the creation of this file.</p>
4280: <p>If you want to share files in this way with other
4281: packages, set the <code class="varname">FILESDIR</code> variable to point
4282: to the other package's <code class="filename">files</code> directory,
4283: e.g.:</p>
4284: <pre class="programlisting">
4285: FILESDIR=${.CURDIR}/../xemacs/files
4286: </pre>
1.75 rillig 4287: </div>
4288: </div>
4289: <div class="chapter" lang="en">
4290: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4291: <a name="makefile"></a>Chapter 10. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.75 rillig 4292: <div class="toc">
4293: <p><b>Table of Contents</b></p>
4294: <dl>
1.77 rillig 4295: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
4296: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
4297: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
4298: <dd><dl>
4299: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
4300: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
4301: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
4302: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
4303: <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 4304: </dl></dd>
4305: </dl>
4306: </div>
1.76 rillig 4307: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
1.75 rillig 4308: each of which forms a well-defined part of the pkgsrc system. Using
4309: 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
4310: like pkgsrc requires some discipline to keep the code correct and
4311: understandable.</p>
1.76 rillig 4312: <p>The basic ingredients for <code class="filename">Makefile</code>
1.75 rillig 4313: programming are variables (which are actually macros) and shell
4314: commands. Among these shell commands may even be more complex ones
4315: 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
4316: as intended it is necessary to quote all variables correctly when they
4317: are used.</p>
4318: <p>This chapter describes some patterns, that appear quite often in
1.76 rillig 4319: <code class="filename">Makefile</code>s, including the pitfalls that come along
1.75 rillig 4320: with them.</p>
4321: <div class="sect1" lang="en">
4322: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4323: <a name="makefile.variables"></a>10.1. <code class="filename">Makefile</code> variables</h2></div></div></div>
1.76 rillig 4324: <p><code class="filename">Makefile</code> variables contain strings that
1.75 rillig 4325: can be processed using the five operators ``='', ``+='', ``?='',
4326: ``:='', 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
4327: page.</p>
4328: <p>When a variable's value is parsed from a
1.76 rillig 4329: <code class="filename">Makefile</code>, the hash character ``#'' and the
1.75 rillig 4330: backslash character ``\'' are handled specially. If a backslash is
4331: followed by a newline, any whitespace immediately in front of the
4332: backslash, the backslash, the newline, and any whitespace
4333: immediately behind the newline are replaced with a single space. A
4334: backslash character and an immediately following hash character are
4335: replaced with a single hash character. Otherwise, the backslash is
4336: passed as is. In a variable assignment, any hash character that is
4337: not preceded by a backslash starts a comment that continues upto the
4338: end of the logical line.</p>
4339: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
4340: the only way to create a variable consisting of a single backslash
4341: is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
4342: <p>So far for defining variables. The other thing you can do with
4343: variables is evaluating them. A variable is evaluated when it is
4344: part of the right side of the ``:='' or the ``!='' operator, or
4345: directly before executing a shell command which the variable is part
4346: 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
4347: is, variables are not evaluated until there's no other way. The
4348: ``modifiers'' mentioned in the man page also evaluate the
4349: variable.</p>
4350: <p>Some of the modifiers split the string into words and then
4351: operate on the words, others operate on the string as a whole. When
4352: a string is split into words, it is split as you would expect
4353: 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.87 wiz 4354: <p>No rule without exception—the <span><strong class="command">.for</strong></span>
1.75 rillig 4355: loop does not follow the shell quoting rules but splits at sequences
4356: of whitespace.</p>
4357: <p>There are several types of variables that should be handled
4358: differently. Strings and two types of lists.</p>
4359: <div class="itemizedlist"><ul type="disc">
4360: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
4361: characters. Nevertheless, you should restrict yourself to only
4362: using printable characters. Examples are
4363: <code class="varname">PREFIX</code> and
4364: <code class="varname">COMMENT</code>.</p></li>
4365: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
4366: are never exported to any shell command. Their elements are
4367: separated by whitespace. Therefore, the elements themselves cannot
4368: have embedded whitespace. Any other characters are allowed.
4369: Internal lists can be used in <span><strong class="command">.for</strong></span> loops.
4370: Examples are <code class="varname">DEPENDS</code> and
4371: <code class="varname">BUILD_DEPENDS</code>.</p></li>
4372: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
4373: may be exported to a shell command. Their elements can contain any
4374: characters, including whitespace. That's why they cannot be used
4375: in <span><strong class="command">.for</strong></span> loops. Examples are
4376: <code class="varname">DISTFILES</code> and
4377: <code class="varname">MASTER_SITES</code>.</p></li>
4378: </ul></div>
4379: <div class="sect2" lang="en">
4380: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4381: <a name="makefile.variables.names"></a>10.1.1. Naming conventions</h3></div></div></div>
1.75 rillig 4382: <div class="itemizedlist"><ul type="disc">
4383: <li><p>All variable names starting with an underscore
4384: are reserved for use by the pkgsrc infrastructure. They shall
4385: not be used by package
1.76 rillig 4386: <code class="filename">Makefile</code>s.</p></li>
1.75 rillig 4387: <li><p>In <span><strong class="command">.for</strong></span> loops you should use
4388: lowercase variable names for the iteration
4389: variables.</p></li>
4390: <li><p>All list variables should have a ``plural''
4391: name, e.g. <code class="varname">PKG_OPTIONS</code> or
4392: <code class="varname">DISTFILES</code>.</p></li>
4393: </ul></div>
4394: </div>
4395: </div>
4396: <div class="sect1" lang="en">
4397: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4398: <a name="makefile.code"></a>10.2. Code snippets</h2></div></div></div>
1.75 rillig 4399: <p>This section presents you with some code snippets you should
4400: use in your own code. If you don't find anything appropriate here,
4401: you should test your code and add it here.</p>
4402: <div class="sect2" lang="en">
4403: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4404: <a name="adding-to-list"></a>10.2.1. Adding things to a list</h3></div></div></div>
1.75 rillig 4405: <pre class="programlisting">
4406: STRING= foo * bar `date`
4407: INT_LIST= # empty
4408: ANOTHER_INT_LIST= apache-[0-9]*:../../www/apache
4409: EXT_LIST= # empty
4410: ANOTHER_EXT_LIST= a=b c=d
1.1 grant 4411:
1.75 rillig 4412: INT_LIST+= ${STRING} # 1
4413: INT_LIST+= ${ANOTHER_INT_LIST} # 2
4414: EXT_LIST+= ${STRING:Q} # 3
4415: EXT_LIST+= ${ANOTHER_EXT_LIST} # 4
1.1 grant 4416: </pre>
1.75 rillig 4417: <p>When you add a string to an external list (example 3), it
4418: must be quoted. In all other cases, you must not add a quoting
4419: level. You must not merge internal and external lists, unless you
4420: are sure that all entries are correctly interpreted in both
4421: lists.</p>
4422: </div>
4423: <div class="sect2" lang="en">
4424: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4425: <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 4426: <pre class="programlisting">
4427: EXT_LIST= # empty
4428: .for i in ${INT_LIST}
4429: EXT_LIST+= ${i:Q}""
4430: .endfor
1.1 grant 4431: </pre>
1.75 rillig 4432: <p>This code converts the internal list
4433: <code class="varname">INT_LIST</code> into the external list
4434: <code class="varname">EXT_LIST</code>. As the elements of an internal list
4435: are unquoted they must be quoted here. The reason for appending
4436: <code class="varname">""</code> is explained below.</p>
4437: </div>
4438: <div class="sect2" lang="en">
4439: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4440: <a name="passing-variable-to-shell"></a>10.2.3. Passing variables to a shell command</h3></div></div></div>
1.79 rillig 4441: <p>Sometimes you may want to print an arbitrary string. There
4442: are many ways to get it wrong and only few that can handle every
4443: nastiness.</p>
1.75 rillig 4444: <pre class="programlisting">
4445: STRING= foo bar < > * `date` $$HOME ' "
4446: EXT_LIST= string=${STRING:Q} x=second\ item
1.1 grant 4447:
1.75 rillig 4448: all:
4449: echo ${STRING} # 1
4450: echo "${STRING}" # 2
4451: echo "${STRING:Q}" # 3
4452: echo ${STRING:Q} # 4
4453: echo x${STRING:Q} | sed 1s,.,, # 5
1.79 rillig 4454: printf "%s\\n" ${STRING:Q}"" # 6
1.75 rillig 4455: env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
1.1 grant 4456: </pre>
1.75 rillig 4457: <p>Example 1 leads to a syntax error in the shell, as the
4458: characters are just copied.</p>
4459: <p>Example 2 leads to a syntax error too, and if you leave out
4460: the last " character from <code class="varname">${STRING}</code>,
4461: <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
4462: variable would be evaluated, too.</p>
4463: <p>Example 3 outputs each space character preceded by a
4464: backslash (or not), depending on the implementation of the
4465: <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>
4466: <p>Example 4 handles correctly every string that does not start
4467: with a dash. In that case, the result depends on the
4468: 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
4469: guarantee that your input does not start with a dash, this form is
4470: appropriate.</p>
4471: <p>Example 5 handles even the case of a leading dash
4472: correctly.</p>
1.79 rillig 4473: <p>Example 6 also works with every string and is the
4474: light-weight solution, since it does not involve a pipe, which has
4475: its own problems.</p>
1.75 rillig 4476: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
4477: because the quoting has already been done when adding elements to
4478: the list.</p>
4479: <p>As internal lists shall not be passed to the shell, there is
4480: no example for it.</p>
4481: </div>
4482: <div class="sect2" lang="en">
4483: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4484: <a name="quoting-guideline"></a>10.2.4. Quoting guideline</h3></div></div></div>
1.75 rillig 4485: <p>There are many possible sources of wrongly quoted variables.
4486: This section lists some of the commonly known ones.</p>
4487: <div class="itemizedlist"><ul type="disc">
4488: <li>
4489: <p>Whenever you use the value of a list, think
4490: about what happens to leading or trailing whitespace. If the
4491: list is a well-formed shell expression, you can apply the
4492: <code class="varname">:M*</code> modifier to strip leading and trailing
4493: whitespace from each word. The <code class="varname">:M</code> operator
4494: first splits its argument according to the rules of the shell,
4495: and then creates a new list consisting of all words that match
4496: the shell glob expression <code class="varname">*</code>, that is: all.
4497: One class of situations where this is needed is when adding a
4498: variable like <code class="varname">CPPFLAGS</code> to
4499: <code class="varname">CONFIGURE_ARGS</code>. If the configure script
4500: invokes other configure scripts, it strips the leading and
4501: trailing whitespace from the variable and then passes it to the
4502: other configure scripts. But these configure scripts expect the
4503: (child) <code class="varname">CPPFLAGS</code> variable to be the same as
4504: the parent <code class="varname">CPPFLAGS</code>. That's why we better
4505: pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
4506: here is how we do it:</p>
4507: <pre class="programlisting">
4508: CPPFLAGS= # empty
4509: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX:Q}\"
4510: CPPFLAGS+= ${MY_CPPFLAGS}
1.1 grant 4511:
1.75 rillig 4512: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
1.1 grant 4513:
1.75 rillig 4514: all:
4515: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
4516: echo x${CONFIGURE_ARGS}x # properly trimmed
1.1 grant 4517: </pre>
1.75 rillig 4518: </li>
4519: <li><p>The example above contains one bug: The
4520: <code class="varname">${PREFIX}</code> is a properly quoted shell
4521: expression, but there is the C compiler after it, which also
4522: expects a properly quoted string (this time in C syntax). The
4523: version above is therefore only correct if
4524: <code class="varname">${PREFIX}</code> does not have embedded backslashes
4525: or double quotes. If you want to allow these, you have to add
4526: another layer of quoting to each variable that is used as a C
4527: string literal. You cannot use the <code class="varname">:Q</code>
4528: operator for it, as this operator only works for the
4529: shell.</p></li>
4530: <li>
4531: <p>Whenever a variable can be empty, the
4532: <code class="varname">:Q</code> operator can have surprising results. Here
4533: are two completely different cases which can be solved with the
4534: same trick.</p>
4535: <pre class="programlisting">
4536: EMPTY= # empty
4537: empty_test:
4538: for i in a ${EMPTY:Q} c; do \
4539: echo "$$i"; \
4540: done
1.1 grant 4541:
1.75 rillig 4542: for_test:
4543: .for i in a:\ a:\test.txt
4544: echo ${i:Q}
4545: echo "foo"
4546: .endfor
1.1 grant 4547: </pre>
1.75 rillig 4548: <p>The first example will only print two of the three lines
4549: we might have expected. This is because
4550: <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
4551: the shell cannot see. The workaround is to write
4552: <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
4553: as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
4554: -f ${FNAME:Q}</code> (both of these are wrong).</p>
4555: <p>The second example will only print three lines instead of
4556: four. The first line looks like <code class="varname">a:\ echo foo</code>.
4557: This is because the backslash of the value
4558: <code class="varname">a:\</code> is interpreted as a line-continuation by
4559: <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
4560: <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
4561: <code class="varname">${i:Q}""</code>.</p>
4562: </li>
4563: </ul></div>
4564: </div>
4565: <div class="sect2" lang="en">
4566: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4567: <a name="bsd-make-bug-workaround"></a>10.2.5. Workaround for a bug in BSD Make</h3></div></div></div>
1.75 rillig 4568: <p>The pkgsrc bmake program does not handle the following
4569: assignment correctly. In case <code class="varname">_othervar_</code>
4570: contains a ``-'' character, one of the closing braces is included
4571: in <code class="varname">${VAR}</code> after this code executes.</p>
4572: <pre class="programlisting">
4573: VAR:= ${VAR:N${_othervar_:C/-//}}
1.1 grant 4574: </pre>
1.75 rillig 4575: <p>For a more complex code snippet and a workaround, see the
1.76 rillig 4576: 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 4577: <code class="varname">bug1</code>.</p>
4578: </div>
4579: </div>
4580: </div>
4581: <div class="chapter" lang="en">
4582: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4583: <a name="plist"></a>Chapter 11. PLIST issues</h2></div></div></div>
1.75 rillig 4584: <div class="toc">
4585: <p><b>Table of Contents</b></p>
4586: <dl>
1.77 rillig 4587: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
4588: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
4589: <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>
4590: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
4591: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
4592: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
4593: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
4594: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
1.75 rillig 4595: </dl>
4596: </div>
1.87 wiz 4597: <p>The <code class="filename">PLIST</code> file contains a package's
4598: “<span class="quote">packing list</span>”, i.e. a list of files that belong to
4599: the package (relative to the <code class="filename">${PREFIX}</code>
4600: directory it's been installed in) plus some additional statements
4601: - 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.
4602: This chapter addresses some issues that need attention when
4603: dealing with the <code class="filename">PLIST</code> file (or files, see
4604: below!).</p>
1.75 rillig 4605: <div class="sect1" lang="en">
4606: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4607: <a name="rcs-id"></a>11.1. RCS ID</h2></div></div></div>
1.87 wiz 4608: <p>Be sure to add a RCS ID line as the first thing in any
4609: <code class="filename">PLIST</code> file you write:</p>
1.75 rillig 4610: <pre class="programlisting">
1.87 wiz 4611: @comment $NetBSD$
4612: </pre>
1.75 rillig 4613: </div>
4614: <div class="sect1" lang="en">
4615: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4616: <a name="automatic-plist-generation"></a>11.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.75 rillig 4617: <p>You can use the <span><strong class="command">make print-PLIST</strong></span> command
1.87 wiz 4618: to output a PLIST that matches any new files since the package
1.88 ! wiz 4619: was extracted. See <a href="#build.helpful-targets" title="15.17. Other helpful targets">Section 15.17, “Other helpful targets”</a> for
1.87 wiz 4620: more information on this target.</p>
1.75 rillig 4621: </div>
4622: <div class="sect1" lang="en">
4623: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4624: <a name="print-PLIST"></a>11.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></h2></div></div></div>
1.87 wiz 4625: <p>If you have used any of the *-dirs packages, as explained in
4626: <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
4627: <span><strong class="command">make print-PLIST</strong></span> outputs a set of
4628: <code class="varname">@comment</code>s instead of real
4629: <code class="varname">@dirrm</code> lines. You can also do this for
4630: specific directories and files, so that the results of that
4631: command are very close to reality. This helps <span class="emphasis"><em>a
4632: lot</em></span> during the update of packages.</p>
4633: <p>The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
4634: of AWK patterns and actions that are used to filter the output of
4635: print-PLIST. You can <span class="emphasis"><em>append</em></span> any chunk of AWK
4636: scripting you like to it, but be careful with quoting.</p>
4637: <p>For example, to get all files inside the
4638: <code class="filename">libdata/foo</code> directory removed from the
4639: resulting PLIST:</p>
4640: <pre class="programlisting">
4641: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
4642: </pre>
4643: <p>And to get all the <code class="varname">@dirrm</code> lines referring
4644: to a specific (shared) directory converted to
4645: <code class="varname">@comment</code>s:</p>
1.75 rillig 4646: <pre class="programlisting">
1.87 wiz 4647: PRINT_PLIST_AWK+= /^@dirrm share\/specific/ { print "@comment " $$0; next; }
4648: </pre>
1.75 rillig 4649: </div>
4650: <div class="sect1" lang="en">
4651: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4652: <a name="plist.misc"></a>11.4. Variable substitution in PLIST</h2></div></div></div>
1.87 wiz 4653: <p>A number of variables are substituted automatically in
4654: PLISTs when a package is installed on a system. This includes the
4655: following variables:</p>
1.75 rillig 4656: <div class="variablelist"><dl>
4657: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
4658: <dd>
4659: <p>Some packages like emacs and perl embed information
1.87 wiz 4660: about which architecture they were built on into the
4661: pathnames where they install their files. To handle this
4662: case, PLIST will be preprocessed before actually used, and
4663: the symbol
4664: “<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>” will be
4665: replaced by what <span><strong class="command">uname -p</strong></span> gives. The
4666: same is done if the string
4667: <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
4668: PLIST somewhere - use this on packages that have GNU
4669: autoconf-created configure scripts.</p>
1.75 rillig 4670: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
4671: <h3 class="title">Legacy note</h3>
4672: <p>There used to be a symbol
1.87 wiz 4673: “<span class="quote"><code class="varname">$ARCH</code></span>” that
4674: was replaced by the output of <span><strong class="command">uname
4675: -m</strong></span>, but that's no longer supported and has
4676: been removed.</p>
1.75 rillig 4677: </div>
4678: </dd>
4679: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
4680: <dd>
4681: <p>Some packages want to embed the OS name and version
1.87 wiz 4682: into some paths. To do this, use these variables in the
4683: <code class="filename">PLIST</code>:
4684: </p>
1.75 rillig 4685: <div class="itemizedlist"><ul type="disc">
4686: <li><p><code class="varname">${OPSYS}</code> - output of “<span class="quote"><span><strong class="command">uname -s</strong></span></span>”</p></li>
4687: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. “<span class="quote">solaris</span>”)</p></li>
4688: <li><p><code class="varname">${OS_VERSION}</code> - “<span class="quote"><span><strong class="command">uname -r</strong></span></span>”</p></li>
4689: </ul></div>
4690: </dd>
4691: </dl></div>
1.87 wiz 4692: <p>For a complete list of values which are replaced by
4693: default, please look in <code class="filename">bsd.pkg.mk</code> (and
4694: search for <code class="varname">PLIST_SUBST</code>).</p>
4695: <p>If you want to change other variables not listed above, you
4696: can add variables and their expansions to this variable in the
4697: 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 4698: <pre class="programlisting">
1.87 wiz 4699: PLIST_SUBST+= SOMEVAR="somevalue"
4700: </pre>
1.75 rillig 4701: <p>This replaces all occurrences of “<span class="quote">${SOMEVAR}</span>”
1.87 wiz 4702: in the <code class="filename">PLIST</code> with
4703: “<span class="quote">somevalue</span>”.</p>
1.75 rillig 4704: </div>
4705: <div class="sect1" lang="en">
4706: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4707: <a name="manpage-compression"></a>11.5. Man page compression</h2></div></div></div>
1.75 rillig 4708: <p>Man pages should be installed in compressed form if
1.87 wiz 4709: <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
4710: and uncompressed otherwise. To handle this in the
4711: <code class="filename">PLIST</code> file, the suffix “<span class="quote">.gz</span>” is
4712: appended/removed automatically for man pages according to
4713: <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
4714: or not, see above for details. This modification of the
4715: <code class="filename">PLIST</code> file is done on a copy of it, not
4716: <code class="filename">PLIST</code> itself.</p>
1.75 rillig 4717: </div>
4718: <div class="sect1" lang="en">
4719: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4720: <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 4721: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
1.87 wiz 4722: in generating the binary package, set the variable
4723: <code class="varname">PLIST_SRC</code> to the names of that file(s).
4724: 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 the order of things is
4725: important. The default for <code class="varname">PLIST_SRC</code> is
4726: <code class="filename">${PKGDIR}/PLIST</code>.</p>
1.75 rillig 4727: </div>
4728: <div class="sect1" lang="en">
4729: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4730: <a name="platform-specific-plist"></a>11.7. Platform-specific and differing PLISTs</h2></div></div></div>
1.75 rillig 4731: <p>Some packages decide to install a different set of files based on
1.87 wiz 4732: the operating system being used. These differences can be
4733: automatically handled by using the following files:</p>
1.75 rillig 4734: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4735: <li><p><code class="filename">PLIST.common</code></p></li>
4736: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
4737: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
4738: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
4739: <li><p><code class="filename">PLIST.common_end</code></p></li>
1.75 rillig 4740: </ul></div>
4741: </div>
4742: <div class="sect1" lang="en">
4743: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4744: <a name="faq.common-dirs"></a>11.8. Sharing directories between packages</h2></div></div></div>
1.87 wiz 4745: <p>A “<span class="quote">shared directory</span>” is a directory where
4746: multiple (and unrelated) packages install files. These
4747: directories are problematic because you have to add special tricks
4748: in the PLIST to conditionally remove them, or have some
4749: centralized package handle them.</p>
4750: <p>Within pkgsrc, you'll find both approaches. If a directory
4751: is shared by a few unrelated packages, it's often not worth to add
4752: an extra package to remove it. Therefore, one simply does:</p>
4753: <pre class="programlisting">
4754: @unexec ${RMDIR} %D/path/to/shared/directory 2>/dev/null || ${TRUE}
4755: </pre>
4756: <p>in the PLISTs of all affected packages, instead of the
4757: regular "@dirrm" line.</p>
4758: <p>However, if the directory is shared across many packages, two
4759: different solutions are available:</p>
1.75 rillig 4760: <div class="orderedlist"><ol type="1">
1.87 wiz 4761: <li><p>If the packages have a common dependency, the directory
4762: can be removed in that. For example, see
4763: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/textproc/scrollkeeper/README.html" target="_top"><code class="filename">textproc/scrollkeeper</code></a>, which
4764: removes the shared directory
4765: <code class="filename">share/omf</code>.</p></li>
4766: <li><p>If the packages using the directory are not related at
4767: all (they have no common dependencies), a *-dirs package is
4768: used.</p></li>
1.75 rillig 4769: </ol></div>
1.87 wiz 4770: <p>From now on, we'll discuss the second solution. To get an
4771: idea of the *-dirs packages available, issue:</p>
1.75 rillig 4772: <pre class="programlisting">
1.87 wiz 4773: <code class="prompt">%</code> cd .../pkgsrc
4774: <code class="prompt">%</code> ls -d */*-dirs
4775: </pre>
4776: <p>Their use from other packages is very simple. The
4777: <code class="varname">USE_DIRS</code> variable takes a list of package names
4778: (without the “<span class="quote">-dirs</span>” part) together with the required
4779: version number (always pick the latest one when writing new
4780: packages).</p>
4781: <p>For example, if a package installs files under
4782: <code class="filename">share/applications</code>, it should have the
4783: following line in it:</p>
4784: <pre class="programlisting">
4785: USE_DIRS+= xdg-1.1
4786: </pre>
4787: <p>After regenerating the PLIST using <span><strong class="command">make
4788: print-PLIST</strong></span>, you should get the right (commented out)
4789: lines.</p>
4790: <p>Note that even if your package is using
4791: <code class="filename">$X11BASE</code>, it must not depend on the
4792: *-x11-dirs packages. Just specify the name without that part and
4793: pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
4794: care of it.</p>
1.75 rillig 4795: </div>
4796: </div>
4797: <div class="chapter" lang="en">
4798: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4799: <a name="buildlink"></a>Chapter 12. Buildlink methodology</h2></div></div></div>
1.75 rillig 4800: <div class="toc">
4801: <p><b>Table of Contents</b></p>
4802: <dl>
1.77 rillig 4803: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
4804: <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 4805: <dd><dl>
1.77 rillig 4806: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
4807: <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 4808: </dl></dd>
1.77 rillig 4809: <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 4810: <dd><dl>
1.77 rillig 4811: <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>
4812: <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 4813: </dl></dd>
4814: </dl>
4815: </div>
4816: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
1.87 wiz 4817: are seen by a package's configure and build processes. This is implemented
4818: in a two step process:</p>
1.75 rillig 4819: <div class="orderedlist"><ol type="1">
4820: <li><p>Symlink headers and libraries for dependencies into
1.87 wiz 4821: <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
4822: of <code class="varname">WRKDIR</code>.</p></li>
1.75 rillig 4823: <li><p>Create wrapper scripts that are used in place of the normal compiler
1.87 wiz 4824: tools that translate <code class="option">-I${LOCALBASE}/include</code> and
4825: <code class="option">-L${LOCALBASE}/lib</code> into references to
4826: <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
4827: native compiler on some operating systems look like GCC, so that
4828: packages that expect GCC won't require modifications to build with
4829: those native compilers.</p></li>
1.75 rillig 4830: </ol></div>
4831: <p>This normalizes the environment in which a package is built so that the
1.87 wiz 4832: package may be built consistently despite what other software may be
4833: installed. Please note that the normal system header and library paths,
4834: e.g. <code class="filename">/usr/include</code>,
4835: <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
4836: designed to insulate the package build from non-system-supplied
4837: software.</p>
1.75 rillig 4838: <div class="sect1" lang="en">
4839: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4840: <a name="converting-to-buildlink3"></a>12.1. Converting packages to use buildlink3</h2></div></div></div>
1.75 rillig 4841: <p>The process of converting packages to use the buildlink3
1.87 wiz 4842: framework (“<span class="quote">bl3ifying</span>”) is fairly straightforward.
4843: The things to keep in mind are:</p>
1.75 rillig 4844: <div class="orderedlist"><ol type="1">
1.87 wiz 4845: <li><p>Ensure that the build always calls the wrapper scripts
4846: instead of the actual toolchain. Some packages are tricky,
4847: and the only way to know for sure is the check
4848: <code class="filename">${WRKDIR}/.work.log</code> to see if the
4849: wrappers are being invoked.</p></li>
4850: <li><p>Don't override <code class="varname">PREFIX</code> from within
4851: the package Makefile, e.g. Java VMs, standalone shells,
4852: etc., because the code to symlink files into
4853: <code class="filename">${BUILDLINK_DIR}</code> looks for files
4854: relative to “<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>”.
4855: </p></li>
4856: <li><p>Remember that <span class="emphasis"><em>only</em></span> the
4857: <code class="filename">buildlink3.mk</code> files that you list in a
4858: package's Makefile are added as dependencies for that package.
4859: </p></li>
1.75 rillig 4860: </ol></div>
1.87 wiz 4861: <p>If a dependency on a particular package is required for its libraries and
4862: headers, then we replace:</p>
1.75 rillig 4863: <pre class="programlisting">
1.87 wiz 4864: DEPENDS+= foo>=1.1.0:../../category/foo
4865: </pre>
1.75 rillig 4866: <p>with</p>
4867: <pre class="programlisting">
1.87 wiz 4868: .include "../../category/foo/buildlink3.mk"
4869: </pre>
1.75 rillig 4870: <p>The buildlink3.mk files usually define the required dependencies.
4871: If you need a newer version of the dependency when using buildlink3.mk
1.87 wiz 4872: files, then you can define it in your Makefile; for example:</p>
1.75 rillig 4873: <pre class="programlisting">
1.87 wiz 4874: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
4875: .include "../../category/foo/buildlink3.mk"
4876: </pre>
1.76 rillig 4877: <p>There are several <code class="filename">buildlink3.mk</code>
1.87 wiz 4878: files in <code class="filename">pkgsrc/mk</code>
4879: that handle special package issues:</p>
1.75 rillig 4880: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4881: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
1.87 wiz 4882: the native or a pkgsrc Berkeley DB implementation based on
4883: the values of <code class="varname">BDB_ACCEPTED</code> and
4884: <code class="varname">BDB_DEFAULT</code>.</p></li>
1.76 rillig 4885: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
1.87 wiz 4886: comes with neither Curses nor NCurses, this will take care
4887: 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>
1.76 rillig 4888: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
1.87 wiz 4889: of <code class="varname">KRB5_ACCEPTED</code> to choose between
4890: adding a dependency on Heimdal or MIT-krb5 for packages that
4891: require a Kerberos 5 implementation.</p></li>
1.88 ! wiz 4892: <li><p><code class="filename">motif.buildlink3.mk</code> checks for a
! 4893: system-provided Motif installation or adds a dependency on
! 4894: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/lesstif/README.html" target="_top"><code class="filename">x11/lesstif</code></a> or <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/openmotif/README.html" target="_top"><code class="filename">x11/openmotif</code></a>. The user can set
! 4895: <code class="varname">MOTIF_TYPE</code> to “<span class="quote">dt</span>”,
! 4896: “<span class="quote">lesstif</span>”, or “<span class="quote">openmotif</span>” to choose
! 4897: which Motif version will be used.</p></li>
1.76 rillig 4898: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
1.87 wiz 4899: variables that may be used by packages that use the
4900: Open Sound System (OSS) API.</p></li>
1.76 rillig 4901: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
1.87 wiz 4902: either Postgres 7.3 or 7.4, whichever is found installed. See
4903: the file for more information.</p></li>
1.76 rillig 4904: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
1.87 wiz 4905: <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
4906: 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>
1.76 rillig 4907: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
1.87 wiz 4908: <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
4909: library.</p></li>
1.75 rillig 4910: </ul></div>
1.76 rillig 4911: <p>The comments in those <code class="filename">buildlink3.mk</code>
1.87 wiz 4912: files provide a more complete
4913: description of how to use them properly.</p>
1.75 rillig 4914: </div>
4915: <div class="sect1" lang="en">
4916: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4917: <a name="creating-buildlink3.mk"></a>12.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
1.87 wiz 4918: <p>A package's <code class="filename">buildlink3.mk</code> file is
4919: included by Makefiles to indicate the need to compile and link
4920: against header files and libraries provided by the package. A
4921: <code class="filename">buildlink3.mk</code> file should always provide
4922: enough information to add the correct type of dependency
4923: relationship and include any other
4924: <code class="filename">buildlink3.mk</code> files that it needs to find
4925: headers and libraries that it needs in turn.</p>
4926: <p>To generate an initial <code class="filename">buildlink3.mk</code>
4927: 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>
4928: package is highly recommended. For most packages, the following
4929: command will generate a good starting point for
4930: <code class="filename">buildlink3.mk</code> files:</p>
4931: <pre class="screen">
4932: <code class="prompt">%</code> <strong class="userinput"><code>cd pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>pkgdir</code></em>
4933: <code class="prompt">%</code> createbuildlink >buildlink3.mk</code></strong>
4934: </pre>
1.75 rillig 4935: <div class="sect2" lang="en">
4936: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4937: <a name="anatomy-of-bl3"></a>12.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
1.75 rillig 4938: <p>The following real-life example
1.87 wiz 4939: <code class="filename">buildlink3.mk</code> is taken
4940: from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
1.75 rillig 4941: <pre class="programlisting">
1.87 wiz 4942: # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
1.1 grant 4943:
1.87 wiz 4944: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
4945: TIFF_BUILDLINK3_MK:= ${TIFF_BUILDLINK3_MK}+
1.1 grant 4946:
1.87 wiz 4947: .if !empty(BUILDLINK_DEPTH:M+)
4948: BUILDLINK_DEPENDS+= tiff
4949: .endif
4950:
4951: BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Ntiff}
4952: BUILDLINK_PACKAGES+= tiff
4953:
4954: .if !empty(TIFF_BUILDLINK3_MK:M+)
4955: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
4956: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
4957: .endif # TIFF_BUILDLINK3_MK
4958:
4959: .include "../../devel/zlib/buildlink3.mk"
4960: .include "../../graphics/jpeg/buildlink3.mk"
4961:
4962: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
4963: </pre>
4964: <p>The header and footer manipulate
4965: <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
4966: <code class="filename">buildlink3.mk</code> files and is used to track
4967: at what depth we are including
4968: <code class="filename">buildlink3.mk</code> files.</p>
4969: <p>The first section controls if the dependency on
4970: <em class="replaceable"><code>pkg</code></em> is added.
4971: <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
4972: packages for which dependencies are added by
4973: buildlink3.</p>
4974: <p>The second section advises pkgsrc that the
4975: <code class="filename">buildlink3.mk</code> file for
4976: <em class="replaceable"><code>pkg</code></em> has been included at some point.
4977: <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
4978: packages for which <code class="filename">buildlink3.mk</code> files
4979: have been included. It must <span class="emphasis"><em>always</em></span> be
4980: appended to within a <code class="filename">buildlink3.mk</code>
4981: file.</p>
4982: <p>The third section is protected from multiple inclusion
4983: and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
4984: added. Several important variables are set in the section:</p>
4985: <div class="itemizedlist"><ul type="disc">
4986: <li><p><code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
4987: is the actual dependency recorded in the installed
4988: package; this should always be set using
4989: <span><strong class="command">+=</strong></span> to ensure that
4990: we're appending to any pre-existing list of values. This
4991: variable should be set to the first version of the
4992: package that had an API change.
4993: </p></li>
4994: <li><p><code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
4995: is the location of the <em class="replaceable"><code>pkg</code></em>
4996: pkgsrc directory.</p></li>
4997: <li><p><code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
4998: (not shown above) controls whether we use
4999: <code class="varname">BUILD_DEPENDS</code> or
5000: <code class="varname">DEPENDS</code> to add the dependency on
5001: <em class="replaceable"><code>pkg</code></em>. The build dependency is
5002: selected by setting
5003: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
5004: to “<span class="quote">build</span>”. By default, the full dependency is
5005: used.</p></li>
5006: <li><p><code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5007: and
5008: <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
5009: (not shown above) are lists of subdirectories of
1.76 rillig 5010: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 5011: to add to the header and library search paths. These
5012: default to “<span class="quote">include</span>” and “<span class="quote">lib</span>”
1.87 wiz 5013: respectively.</p></li>
5014: <li><p><code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5015: (not shown above) is the list of preprocessor flags to add
5016: to <code class="varname">CPPFLAGS</code>, which are passed on to the
5017: configure and build phases. The “<span class="quote">-I</span>” option
5018: should be avoided and instead be handled using
5019: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
1.87 wiz 5020: above.</p></li>
1.75 rillig 5021: </ul></div>
1.87 wiz 5022: <p>The following variables are all optionally defined within
5023: this second section (protected against multiple inclusion) and
5024: control which package files are symlinked into
5025: <code class="filename">${BUILDLINK_DIR}</code> and how their names are
5026: transformed during the symlinking:</p>
1.75 rillig 5027: <div class="itemizedlist"><ul type="disc">
1.87 wiz 5028: <li><p><code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5029: (not shown above) is a shell glob pattern relative to
1.76 rillig 5030: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 5031: to be symlinked into
1.76 rillig 5032: <code class="filename">${BUILDLINK_DIR}</code>,
1.87 wiz 5033: e.g. <code class="filename">include/*.h</code>.</p></li>
5034: <li><p><code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
5035: (not shown above) is a shell pipeline that
5036: outputs to stdout a list of files relative to
5037: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
5038: The resulting files are to be symlinked
5039: into <code class="filename">${BUILDLINK_DIR}</code>. By default,
5040: this takes the <code class="filename">+CONTENTS</code> of a
5041: <em class="replaceable"><code>pkg</code></em> and filters it through
5042: <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.</p></li>
5043: <li><p><code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5044: (not shown above) is a filter command that filters
1.76 rillig 5045: <code class="filename">+CONTENTS</code> input into a list of files
1.75 rillig 5046: relative to
1.76 rillig 5047: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 5048: on stdout. By default for overwrite packages,
5049: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.76 rillig 5050: outputs the contents of the <code class="filename">include</code>
5051: and <code class="filename">lib</code> directories in the package
5052: <code class="filename">+CONTENTS</code>, and for pkgviews packages,
1.75 rillig 5053: it outputs any libtool archives in
1.87 wiz 5054: <code class="filename">lib</code> directories.</p></li>
5055: <li><p><code class="varname">BUILDLINK_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5056: (not shown above) is a list of sed arguments used to
5057: transform the name of the source filename into a
5058: destination filename, e.g. <span><strong class="command">-e
1.87 wiz 5059: "s|/curses.h|/ncurses.h|g"</strong></span>.</p></li>
1.75 rillig 5060: </ul></div>
1.87 wiz 5061: <p>The last section includes any
5062: <code class="filename">buildlink3.mk</code> needed for
5063: <em class="replaceable"><code>pkg</code></em>'s library dependencies.
5064: Including these <code class="filename">buildlink3.mk</code> files
5065: means that the headers and libraries for these
5066: dependencies are also symlinked into
5067: <code class="filename">${BUILDLINK_DIR}</code>
5068: whenever the <em class="replaceable"><code>pkg</code></em>
5069: <code class="filename">buildlink3.mk</code>
5070: file is included.</p>
1.75 rillig 5071: </div>
5072: <div class="sect2" lang="en">
5073: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5074: <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.87 wiz 5075: <p>The situation that requires increasing the dependency listed in
1.75 rillig 5076: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5077: after a package update is when the API or interface to the
1.87 wiz 5078: header files change.</p>
5079: <p>In this case,
5080: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5081: should be adjusted to require at least the new package
5082: version. In some cases, the packages that depend on this new
5083: version may need their <code class="varname">PKGREVISION</code>s
5084: increased and, if they have <code class="filename">buildlink3.mk</code>
5085: files, their
5086: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5087: adjusted, too. This is needed so pkgsrc will require the
5088: correct package dependency and not settle for an older one
5089: when building the source.</p>
5090: <p><code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5091: should be increased when the binary interface or sonames
5092: (major number of the library version) of any installed
5093: shared libraries change. This is needed so that binary
5094: packages made using it will require the correct package
5095: dependency and not settle for an older one which will not
1.87 wiz 5096: contain the necessary shared libraries.</p>
5097: <p>See <a href="#dependencies" title="17.1.6. Handling dependencies">Section 17.1.6, “Handling dependencies”</a> for
1.75 rillig 5098: more information about dependencies on other packages,
5099: including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
1.87 wiz 5100: <code class="varname">ABI_DEPENDS</code> definitions.</p>
5101: <p>Please take careful consideration before adjusting
5102: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5103: or
5104: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5105: as we don't want to cause unneeded package deletions and
5106: rebuilds. In many cases, new versions of packages work just
5107: fine with older dependencies.</p>
5108: <p>Also it is not needed to set
1.75 rillig 5109: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5110: when it is identical to
1.87 wiz 5111: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>. </p>
1.75 rillig 5112: </div>
5113: </div>
5114: <div class="sect1" lang="en">
5115: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5116: <a name="writing-builtin.mk"></a>12.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.87 wiz 5117: <p>Some packages in pkgsrc install headers and libraries that
1.75 rillig 5118: coincide with headers and libraries present in the base system.
1.76 rillig 5119: Aside from a <code class="filename">buildlink3.mk</code> file, these
5120: packages should also include a <code class="filename">builtin.mk</code>
1.75 rillig 5121: file that includes the necessary checks to decide whether using
5122: the built-in software or the pkgsrc software is
1.87 wiz 5123: appropriate.</p>
5124: <p>The only requirements of a builtin.mk file for
5125: <em class="replaceable"><code>pkg</code></em> are:</p>
1.75 rillig 5126: <div class="orderedlist"><ol type="1">
1.87 wiz 5127: <li><p>It should set
5128: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5129: to either “<span class="quote">yes</span>” or “<span class="quote">no</span>”
5130: after it is included.</p></li>
5131: <li><p>It should <span class="emphasis"><em>not</em></span> override any
5132: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5133: which is already set before the
5134: <code class="filename">builtin.mk</code> file is included.</p></li>
5135: <li><p>It should be written to allow multiple inclusion. This
5136: is <span class="emphasis"><em>very</em></span> important and takes careful
5137: attention to <code class="filename">Makefile</code> coding.</p></li>
1.75 rillig 5138: </ol></div>
5139: <div class="sect2" lang="en">
5140: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5141: <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 5142: <p>The following is the recommended template for builtin.mk
1.87 wiz 5143: files:</p>
1.75 rillig 5144: <pre class="programlisting">
1.87 wiz 5145: .if !defined(IS_BUILTIN.foo)
5146: #
5147: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
5148: # genuinely exists in the system or not.
5149: #
5150: IS_BUILTIN.foo?= no
5151:
5152: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
5153: # version can be determined.
5154: #
5155: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
5156: BUILTIN_PKG.foo?= foo-1.0
5157: . endif
5158: .endif # IS_BUILTIN.foo
5159:
5160: .if !defined(USE_BUILTIN.foo)
5161: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
5162: . if defined(BUILTIN_PKG.foo)
5163: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
5164: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
5165: USE_BUILTIN.foo!= \
5166: if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then \
5167: ${ECHO} "yes"; \
5168: else \
5169: ${ECHO} "no"; \
5170: fi
5171: . endif
5172: . endfor
5173: . endif
5174: .endif # USE_BUILTIN.foo
5175:
5176: CHECK_BUILTIN.foo?= no
5177: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
5178: #
5179: # Here we place code that depends on whether USE_BUILTIN.foo is set to
5180: # "yes" or "no".
5181: #
5182: .endif # CHECK_BUILTIN.foo
5183: </pre>
5184: <p>The first section sets
5185: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5186: depending on if <em class="replaceable"><code>pkg</code></em> really exists
5187: in the base system. This should not be a base system software
5188: with similar functionality to <em class="replaceable"><code>pkg</code></em>;
5189: it should only be “<span class="quote">yes</span>” if the actual package is
5190: included as part of the base system. This variable is only
5191: used internally within the <code class="filename">builtin.mk</code>
5192: file.</p>
5193: <p>The second section sets
5194: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
5195: to the version of <em class="replaceable"><code>pkg</code></em> in the base
5196: system if it exists (if
5197: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5198: is “<span class="quote">yes</span>”). This variable is only used internally
5199: within the <code class="filename">builtin.mk</code> file.</p>
5200: <p>The third section sets
5201: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5202: and is <span class="emphasis"><em>required</em></span> in all
5203: <code class="filename">builtin.mk</code> files. The code in this
5204: section must make the determination whether the built-in
5205: software is adequate to satisfy the dependencies listed in
5206: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
5207: This is typically done by comparing
5208: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
5209: against each of the dependencies in
5210: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
5211: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5212: <span class="emphasis"><em>must</em></span> be set to the correct value by the
5213: end of the <code class="filename">builtin.mk</code> file. Note that
5214: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5215: may be “<span class="quote">yes</span>” even if
5216: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5217: is “<span class="quote">no</span>” because we may make the determination
5218: that the built-in version of the software is similar enough to
5219: be used as a replacement.</p>
5220: <p>The last section is guarded by
5221: <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
5222: and includes code that uses the value of
5223: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5224: set in the previous section. This typically includes, e.g.,
5225: adding additional dependency restrictions and listing additional
5226: files to symlink into <code class="filename">${BUILDLINK_DIR}</code> (via
5227: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).</p>
1.75 rillig 5228: </div>
5229: <div class="sect2" lang="en">
5230: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5231: <a name="native-or-pkgsrc-preference"></a>12.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
1.87 wiz 5232: <p>When building packages, it's possible to choose whether to set
5233: a global preference for using either the built-in (native)
5234: version or the pkgsrc version of software to satisfy a
5235: dependency. This is controlled by setting
5236: <code class="varname">PREFER_PKGSRC</code> and
5237: <code class="varname">PREFER_NATIVE</code>. These variables take values
5238: of either “<span class="quote">yes</span>”, “<span class="quote">no</span>”, or a list of
5239: packages. <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
5240: use the pkgsrc versions of software, while
5241: <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
5242: built-in versions. Preferences are determined by the most
5243: specific instance of the package in either
5244: <code class="varname">PREFER_PKGSRC</code> or
5245: <code class="varname">PREFER_NATIVE</code>. If a package is specified
5246: in neither or in both variables, then
5247: <code class="varname">PREFER_PKGSRC</code> has precedence over
5248: <code class="varname">PREFER_NATIVE</code>. For example, to require
5249: using pkgsrc versions of software for all but the most basic
5250: bits on a NetBSD system, you can set:</p>
5251: <pre class="programlisting">
5252: PREFER_PKGSRC= yes
5253: PREFER_NATIVE= getopt skey tcp_wrappers
5254: </pre>
5255: <p>A package <span class="emphasis"><em>must</em></span> have a
5256: <code class="filename">builtin.mk</code>
5257: file to be listed in <code class="varname">PREFER_NATIVE</code>,
5258: otherwise it is simply ignored in that list.</p>
1.75 rillig 5259: </div>
5260: </div>
5261: </div>
5262: <div class="chapter" lang="en">
5263: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5264: <a name="pkginstall"></a>Chapter 13. The pkginstall framework</h2></div></div></div>
1.75 rillig 5265: <div class="toc">
5266: <p><b>Table of Contents</b></p>
5267: <dl>
1.77 rillig 5268: <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 5269: <dd><dl>
1.77 rillig 5270: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
5271: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
1.75 rillig 5272: </dl></dd>
1.77 rillig 5273: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
1.75 rillig 5274: <dd><dl>
1.77 rillig 5275: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
5276: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
5277: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
5278: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
5279: </dl></dd>
5280: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
5281: <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>
5282: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
5283: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
5284: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
5285: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
5286: <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 5287: </dl>
5288: </div>
5289: <p>This chapter describes the framework known as
5290: <code class="literal">pkginstall</code>, whose key features are:</p>
5291: <div class="itemizedlist"><ul type="disc">
5292: <li><p>Generic installation and manipulation of directories and files
5293: outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
5294: <li><p>Automatic handling of configuration files during installation,
5295: provided that packages are correctly designed.</p></li>
5296: <li><p>Generation and installation of system startup scripts.</p></li>
5297: <li><p>Registration of system users and groups.</p></li>
5298: <li><p>Registration of system shells.</p></li>
5299: <li><p>Automatic updating of fonts databases.</p></li>
5300: </ul></div>
5301: <p>The following sections inspect each of the above points in detail.</p>
5302: <p>You may be thinking that many of the things described here could be
5303: easily done with simple code in the package's post-installation target
5304: (<code class="literal">post-install</code>). <span class="emphasis"><em>This is incorrect</em></span>,
5305: as the code in them is only executed when building from source. Machines
5306: using binary packages could not benefit from it at all (as the code itself
5307: could be unavailable). Therefore, the only way to achieve any of the items
5308: described above is by means of the installation scripts, which are
5309: automatically generated by pkginstall.</p>
5310: <div class="sect1" lang="en">
5311: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5312: <a name="files-and-dirs-outside-prefix"></a>13.1. Files and directories outside the installation prefix</h2></div></div></div>
1.76 rillig 5313: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
1.75 rillig 5314: of files and directories that belong to a package. The names used in it
1.76 rillig 5315: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
1.75 rillig 5316: which means that it cannot register files outside this directory (absolute
5317: path names are not allowed). Despite this restriction, some packages need
5318: to install files outside this location; e.g., under
1.76 rillig 5319: <code class="filename">${VARBASE}</code> or
1.87 wiz 5320: <code class="filename">${PKG_SYSCONFDIR}</code>. The only way to achieve this
5321: is to create such files during installation time by using
5322: installation scripts.</p>
5323: <p>The generic installation scripts are shell scripts that can
5324: contain arbitrary code. The list of scripts to execute is taken from
5325: the <code class="varname">INSTALL_FILE</code> variable, which defaults to
5326: <code class="filename">INSTALL</code>. A similar variable exists for package
5327: removal (<code class="varname">DEINSTALL_FILE</code>, whose default is
5328: <code class="filename">DEINSTALL</code>). These scripts can run arbitrary
5329: commands, so they have the potential to create and manage files
5330: anywhere in the file system.</p>
5331: <p>Using these general installation files is not recommended, but
5332: may be needed in some special cases. One reason for avoiding them is
5333: that the user has to trust the packager that there is no unwanted or
5334: simply erroneous code included in the installation script. Also,
5335: previously there were many similar scripts for the same functionality,
5336: and fixing a common error involved finding and changing all of
5337: them.</p>
5338: <p>The pkginstall framework offers another, standardized way. It
5339: provides generic scripts to abstract the manipulation of such files
5340: and directories based on variables set in the package's
5341: <code class="filename">Makefile</code>. The rest of this section describes
5342: these variables.</p>
1.75 rillig 5343: <div class="sect2" lang="en">
5344: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5345: <a name="dirs-outside-prefix"></a>13.1.1. Directory manipulation</h3></div></div></div>
1.75 rillig 5346: <p>The following variables can be set to request the creation of
5347: directories anywhere in the file system:</p>
5348: <div class="itemizedlist"><ul type="disc">
5349: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
5350: contain a list of directories that should be created and should attempt
5351: to be destroyed by the installation scripts. The difference between
5352: the two is that the latter prompts the administrator to remove any
5353: directories that may be left after deinstallation (because they were
5354: not empty), while the former does not.</p></li>
5355: <li>
5356: <p><code class="varname">MAKE_DIRS_PERMS</code> and
5357: <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
5358: which directories should be created and should attempt to be destroyed
5359: by the installation scripts. Each tuple holds the following values,
5360: separated by spaces: the directory name, its owner, its group and its
5361: numerical mode. For example:</p>
5362: <pre class="programlisting">
5363: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 5364: </pre>
1.75 rillig 5365: <p>The difference between the two is exactly the same as their
5366: non-<code class="varname">PERMS</code> counterparts.</p>
5367: </li>
5368: </ul></div>
5369: </div>
5370: <div class="sect2" lang="en">
5371: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5372: <a name="files-outside-prefix"></a>13.1.2. File manipulation</h3></div></div></div>
1.75 rillig 5373: <p>Creating non-empty files outside the installation prefix is tricky
1.76 rillig 5374: because the <code class="filename">PLIST</code> forces all files to be inside it.
1.75 rillig 5375: To overcome this problem, the only solution is to extract the file in the
5376: known place (i.e., inside the installation prefix) and copy it to the
5377: appropriate location during installation (done by the installation scripts
5378: generated by pkginstall). We will call the former the <span class="emphasis"><em>master
5379: file</em></span> in the following paragraphs, which describe the variables
5380: that can be used to automatically and consistently handle files outside the
5381: installation prefix:</p>
5382: <div class="itemizedlist"><ul type="disc">
5383: <li>
5384: <p><code class="varname">CONF_FILES</code> and
5385: <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
5386: During installation time, the master file is copied to the target one
5387: if and only if the latter does not exist. Upon deinstallation, the
5388: target file is removed provided that it was not modified by the
5389: installation.</p>
5390: <p>The difference between the two is that the latter prompts the
5391: administrator to remove any files that may be left after
5392: deinstallation (because they were not empty), while the former does
5393: not.</p>
5394: </li>
5395: <li>
5396: <p><code class="varname">CONF_FILES_PERMS</code> and
5397: <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
5398: files as well as their target locations. For each of them, it also
5399: specifies their owner, their group and their numeric permissions, in
5400: this order. For example:</p>
5401: <pre class="programlisting">
5402: SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 5403: </pre>
1.75 rillig 5404: <p>The difference between the two is exactly the same as their
5405: non-<code class="varname">PERMS</code> counterparts.</p>
5406: </li>
5407: </ul></div>
5408: </div>
5409: </div>
5410: <div class="sect1" lang="en">
5411: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5412: <a name="conf-files"></a>13.2. Configuration files</h2></div></div></div>
1.75 rillig 5413: <p>Configuration files are special in the sense that they are installed
5414: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
5415: need special treatment during installation (most of which is automated by
5416: pkginstall). The main concept you must bear in mind is that files marked
5417: as configuration files are automatically copied to the right place (somewhere
5418: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
5419: and only if</em></span> they didn't exist before. Similarly, they will not
5420: be removed if they have local modifications. This ensures that
5421: administrators never lose any custom changes they may have made.</p>
5422: <div class="sect2" lang="en">
5423: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5424: <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 5425: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
5426: specifies where configuration files shall be installed. Its contents are
5427: set based upon the following variables:</p>
5428: <div class="itemizedlist"><ul type="disc">
5429: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
1.76 rillig 5430: directory. Defaults to <code class="filename">${PREFIX}/etc</code> although it may
1.75 rillig 5431: be overridden by the user to point to his preferred location (e.g.,
1.76 rillig 5432: <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
1.75 rillig 5433: Packages must not use it directly.</p></li>
5434: <li>
5435: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
5436: <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
5437: for the package being built shall be installed. The definition of this
5438: variable only makes sense in the package's
1.76 rillig 5439: <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
1.75 rillig 5440: <p>As an example, consider the Apache package,
1.76 rillig 5441: <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 5442: configuration files under the
1.76 rillig 5443: <code class="filename">httpd/</code> subdirectory of
1.75 rillig 5444: <code class="varname">PKG_SYSCONFBASE</code>. This should be set in the package
5445: Makefile.</p>
5446: </li>
5447: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
5448: variable that holds this package's configuration directory (if
5449: different from <code class="varname">PKG_SYSCONFBASE</code>). It defaults to
5450: <code class="varname">PKGBASE</code>'s value, and is always prefixed with
5451: <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
5452: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
5453: directory where the configuration files for the package identified by
5454: <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
5455: </ul></div>
5456: <p>Based on the above variables, pkginstall determines the value of
5457: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
5458: variable that can be used within a package to refer to its configuration
5459: directory. The algorithm used to set its value is basically the
5460: following:</p>
5461: <div class="orderedlist"><ol type="1">
5462: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
5463: its value is used.</p></li>
5464: <li><p>If the previous variable is not defined but
5465: <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
1.76 rillig 5466: <code class="filename">Makefile</code>, the resulting value is
5467: <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
1.75 rillig 5468: <li><p>Otherwise, it is set to
1.76 rillig 5469: <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
1.75 rillig 5470: </ol></div>
1.76 rillig 5471: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
1.77 rillig 5472: 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 5473: </div>
5474: <div class="sect2" lang="en">
5475: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5476: <a name="conf-files-configure"></a>13.2.2. Telling the software where configuration files are</h3></div></div></div>
1.75 rillig 5477: <p>Given that pkgsrc (and users!) expect configuration files to be in a
5478: known place, you need to teach each package where it shall install its
5479: files. In some cases you will have to patch the package Makefiles to
5480: achieve it. If you are lucky, though, it may be as easy as passing an
5481: extra flag to the configuration script; this is the case of GNU Autoconf-
5482: generated files:</p>
5483: <pre class="programlisting">
5484: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1 grant 5485: </pre>
1.75 rillig 5486: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
5487: for</em></span> its configuration files, not where they will be originally
5488: installed (although the difference is never explicit,
5489: unfortunately).</p>
5490: </div>
5491: <div class="sect2" lang="en">
5492: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5493: <a name="conf-files-patching"></a>13.2.3. Patching installations</h3></div></div></div>
1.75 rillig 5494: <p>As said before, pkginstall automatically handles configuration files.
5495: This means that <span class="strong"><strong>the packages themselves must not
1.76 rillig 5496: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
1.75 rillig 5497: directly</strong></span>. Bad news is that many software installation scripts
5498: will, out of the box, mess with the contents of that directory. So what is
5499: the correct procedure to fix this issue?</p>
5500: <p>You must teach the package (usually by manually patching it) to
5501: install any configuration files under the examples hierarchy,
1.76 rillig 5502: <code class="filename">share/examples/${PKGBASE}/</code>. This way, the
5503: <code class="filename">PLIST</code> registers them and the administrator always
1.75 rillig 5504: has the original copies available.</p>
5505: <p>Once the required configuration files are in place (i.e., under the
5506: examples hierarchy), the pkginstall framework can use them as master copies
5507: during the package installation to update what is in
1.76 rillig 5508: <code class="filename">${PKG_SYSCONFDIR}</code>. To achieve this, the variables
1.75 rillig 5509: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
1.77 rillig 5510: 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 5511: about their syntax and their purpose. Here is an example, taken from the
1.76 rillig 5512: <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 5513: <pre class="programlisting">
5514: EGDIR= ${PREFIX}/share/doc/mutt/samples
5515: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1 grant 5516: </pre>
1.75 rillig 5517: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
5518: package and has no meaning outside it.</p>
5519: </div>
5520: <div class="sect2" lang="en">
5521: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5522: <a name="conf-files-disable"></a>13.2.4. Disabling handling of configuration files</h3></div></div></div>
1.75 rillig 5523: <p>The automatic copying of config files can be toggled by setting the
5524: environment variable <code class="varname">PKG_CONFIG</code> prior to package
5525: installation.</p>
5526: </div>
5527: </div>
5528: <div class="sect1" lang="en">
5529: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5530: <a name="rcd-scripts"></a>13.3. System startup scripts</h2></div></div></div>
1.75 rillig 5531: <p>System startup scripts are special files because they must be
5532: installed in a place known by the underlying OS, usually outside the
1.77 rillig 5533: 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 5534: can be used. However, pkginstall provides a special mechanism to handle
5535: these files.</p>
5536: <p>In order to provide system startup scripts, the package has
5537: to:</p>
5538: <div class="orderedlist"><ol type="1">
1.76 rillig 5539: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
1.75 rillig 5540: the <code class="literal">.sh</code> suffix appended. Considering the
1.76 rillig 5541: <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
5542: <code class="filename">cupsd.sh</code> in its files directory.</p></li>
1.75 rillig 5543: <li>
5544: <p>Tell pkginstall to handle it, appending the name of the script,
5545: without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
5546: Continuing the previous example:</p>
5547: <pre class="programlisting">
5548: RCD_SCRIPTS+= cupsd
1.1 grant 5549: </pre>
1.75 rillig 5550: </li>
5551: </ol></div>
5552: <p>Once this is done, pkginstall will do the following steps for each
5553: script in an automated fashion:</p>
5554: <div class="orderedlist"><ol type="1">
5555: <li><p>Process the file found in the files directory applying all the
1.76 rillig 5556: substitutions described in the <code class="filename">FILES_SUBST</code>
1.75 rillig 5557: variable.</p></li>
5558: <li><p>Copy the script from the files directory to the examples
1.76 rillig 5559: hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>. Note
1.75 rillig 5560: that this master file must be explicitly registered in the
1.76 rillig 5561: <code class="filename">PLIST</code>.</p></li>
1.75 rillig 5562: <li><p>Add code to the installation scripts to copy the startup script
5563: from the examples hierarchy into the system-wide startup scripts
5564: directory.</p></li>
5565: </ol></div>
5566: <div class="sect2" lang="en">
5567: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5568: <a name="rcd-scripts-disable"></a>13.3.1. Disabling handling of system startup scripts</h3></div></div></div>
1.75 rillig 5569: <p>The automatic copying of config files can be toggled by setting the
5570: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
5571: installation. Note that the scripts will be always copied inside the
1.76 rillig 5572: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
1.75 rillig 5573: matter what the value of this variable is.</p>
5574: </div>
5575: </div>
5576: <div class="sect1" lang="en">
5577: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5578: <a name="users-and-groups"></a>13.4. System users and groups</h2></div></div></div>
1.75 rillig 5579: <p>If a package needs to create special users and/or groups during
5580: installation, it can do so by using the pkginstall framework.</p>
5581: <p>Users can be created by adding entries to the
5582: <code class="varname">PKG_USERS</code> variable. Each entry has the following
5583: syntax:</p>
5584: <pre class="programlisting">
5585: user:group
1.1 grant 5586: </pre>
1.87 wiz 5587: <p>Further specification of user details may be done by setting
5588: per-user variables.
5589: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the
5590: numeric UID for the user.
5591: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the
5592: user's description or comment.
5593: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the
5594: user's home directory, and defaults to
5595: <code class="filename">/nonexistent</code> if not specified.
5596: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the
5597: user's shell, and defaults to <code class="filename">/sbinno/login</code> if
5598: not specified.</p>
1.75 rillig 5599: <p>Similarly, groups can be created by adding entries to the
5600: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
5601: <pre class="programlisting">
5602: group
1.1 grant 5603: </pre>
1.75 rillig 5604: <p>The numeric GID of the group may be set by defining
5605: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
5606: <p>If a package needs to create the users and groups at an earlier
5607: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
5608: either <code class="literal">configure</code> or <code class="literal">build</code> to
5609: indicate the phase before which the users and groups are created. In
5610: this case, the numeric UIDs and GIDs of the created users and groups
5611: are automatically hardcoded into the final installation scripts.</p>
5612: </div>
5613: <div class="sect1" lang="en">
5614: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5615: <a name="shells"></a>13.5. System shells</h2></div></div></div>
1.75 rillig 5616: <p>Packages that install system shells should register them in the shell
1.76 rillig 5617: database, <code class="filename">/etc/shells</code>, to make things easier to the
1.75 rillig 5618: administrator. This must be done from the installation scripts to keep
5619: binary packages working on any system. pkginstall provides an easy way to
5620: accomplish this task.</p>
5621: <p>When a package provides a shell interpreter, it has to set the
5622: <code class="varname">PKG_SHELL</code> variable to its absolute file name. This will
5623: add some hooks to the installation scripts to handle it. Consider the
1.76 rillig 5624: 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 5625: <pre class="programlisting">
5626: PKG_SHELL= ${PREFIX}/bin/zsh
1.1 grant 5627: </pre>
1.75 rillig 5628: <div class="sect2" lang="en">
5629: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5630: <a name="shells-disable"></a>13.5.1. Disabling shell registration</h3></div></div></div>
1.75 rillig 5631: <p>The automatic registration of shell interpreters can be disabled by
1.76 rillig 5632: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
1.75 rillig 5633: environment variable to <code class="literal">NO</code>.</p>
5634: </div>
5635: </div>
5636: <div class="sect1" lang="en">
5637: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5638: <a name="fonts"></a>13.6. Fonts</h2></div></div></div>
1.75 rillig 5639: <p>Packages that install X11 fonts should update the database files
5640: that index the fonts within each fonts directory. This can easily be
5641: accomplished within the pkginstall framework.</p>
5642: <p>When a package installs X11 fonts, it must list the directories in
5643: which fonts are installed in the
5644: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
5645: where <em class="replaceable"><code>type</code></em> can be one of “<span class="quote">ttf</span>”,
5646: “<span class="quote">type1</span>” or “<span class="quote">x11</span>”. This will add hooks to the
5647: installation scripts to run the appropriate commands to update the fonts
5648: database files within each of those directories. For convenience, if the
5649: directory path is relative, it is taken to be relative to the package's
1.76 rillig 5650: 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 5651: <pre class="programlisting">
5652: FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
1.1 grant 5653: </pre>
1.75 rillig 5654: <div class="sect2" lang="en">
5655: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5656: <a name="fonts-disable"></a>13.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
1.75 rillig 5657: <p>The automatic update of fonts databases can be disabled by
1.76 rillig 5658: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
1.75 rillig 5659: environment variable to <code class="literal">NO</code>.</p>
5660: </div>
5661: </div>
5662: </div>
5663: <div class="chapter" lang="en">
5664: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5665: <a name="options"></a>Chapter 14. Options handling</h2></div></div></div>
1.75 rillig 5666: <div class="toc">
5667: <p><b>Table of Contents</b></p>
5668: <dl>
1.77 rillig 5669: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
5670: <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>
5671: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
1.75 rillig 5672: </dl>
5673: </div>
5674: <p>Many packages have the ability to be built to support different
1.76 rillig 5675: sets of features. <code class="filename">bsd.options.mk</code> is a framework
1.75 rillig 5676: in pkgsrc that provides generic handling of those options that
5677: determine different ways in which the packages can be built. It's
5678: possible for the user to specify exactly which sets of options will be
5679: built into a package or to allow a set of global default options
5680: apply.</p>
5681: <div class="sect1" lang="en">
5682: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5683: <a name="global-default-options"></a>14.1. Global default options</h2></div></div></div>
1.75 rillig 5684: <p>Global default options are listed in
5685: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
5686: that should be built into every package if that option is supported.
1.76 rillig 5687: This variable should be set in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 5688: </div>
5689: <div class="sect1" lang="en">
5690: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5691: <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 5692: <p>The following example shows how
1.76 rillig 5693: <code class="filename">bsd.options.mk</code> should be used
1.75 rillig 5694: by the hypothetical ``wibble'' package, either in the package
1.76 rillig 5695: <code class="filename">Makefile</code>, or in a file,
5696: e.g. <code class="filename">options.mk</code>, that is included by the
5697: main package <code class="filename">Makefile</code>.</p>
1.75 rillig 5698: <pre class="programlisting">
5699: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
5700: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
5701: PKG_OPTIONS_OPTIONAL_GROUPS= database
5702: PKG_OPTIONS_GROUP.database= mysql pgsql
5703: PKG_SUGGESTED_OPTIONS= wibble-foo
5704: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
5705: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
1.1 grant 5706:
1.75 rillig 5707: .include "../../mk/bsd.prefs.mk"
1.69 rillig 5708:
1.75 rillig 5709: # this package was previously named wibble2
5710: .if defined(PKG_OPTIONS.wibble2)
5711: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
5712: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
1.78 rillig 5713: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
1.75 rillig 5714: .endif
1.69 rillig 5715:
1.75 rillig 5716: .include "../../mk/bsd.options.mk"
1.69 rillig 5717:
1.75 rillig 5718: # Package-specific option-handling
1.69 rillig 5719:
1.75 rillig 5720: ###
5721: ### FOO support
5722: ###
5723: .if !empty(PKG_OPTIONS:Mwibble-foo)
5724: CONFIGURE_ARGS+= --enable-foo
5725: .endif
1.69 rillig 5726:
1.75 rillig 5727: ###
5728: ### LDAP support
5729: ###
5730: .if !empty(PKG_OPTIONS:Mldap)
1.77 rillig 5731: . include "../../databases/openldap-client/buildlink3.mk"
5732: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
1.75 rillig 5733: .endif
1.69 rillig 5734:
1.75 rillig 5735: ###
5736: ### database support
5737: ###
5738: .if !empty(PKG_OPTIONS:Mmysql)
5739: . include "../../mk/mysql.buildlink3.mk"
5740: .endif
5741: .if !empty(PKG_OPTIONS:Mpgsql)
5742: . include "../../mk/pgsql.buildlink3.mk"
5743: .endif
5744: </pre>
5745: <p>The first section contains the information about which build
5746: options are supported by the package, and any default options settings
5747: if needed.</p>
5748: <div class="orderedlist"><ol type="1">
5749: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
5750: <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
5751: options. It should be set to
1.78 rillig 5752: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
5753: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is not defined
5754: at the point where the options are processed.</p></li>
1.75 rillig 5755: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
5756: build options supported by the package.</p></li>
5757: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
5758: list of names of groups of mutually exclusive options. The options in
5759: each group are listed in
5760: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
5761: The most specific setting of any option from the group takes
5762: precedence over all other options in the group. Options from the
5763: groups will be automatically added to
5764: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
5765: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
5766: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
5767: packages will fail if no option from the group is
5768: selected.</p></li>
5769: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
5770: of names of sets of options. At least one option from each set must
5771: be selected. The options in each set are listed in
5772: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
5773: Options from the sets will be automatically added to
5774: <code class="varname">PKG_SUPPORTED_OPTIONS</code>. Building the package will
5775: fail if no option from the set is selected.</p></li>
5776: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
5777: build options which are enabled by default.</p></li>
5778: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
5779: of
5780: “<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>”
1.76 rillig 5781: pairs that map legacy <code class="filename">/etc/mk.conf</code> variables to
1.75 rillig 5782: their option counterparts. Pairs should be added with
5783: “<span class="quote">+=</span>” to keep the listing of global legacy variables. A
5784: warning will be issued if the user uses a legacy
5785: variable.</p></li>
5786: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
5787: of
5788: “<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>”
5789: pairs that map options that have been renamed to their new
5790: counterparts. Pairs should be added with “<span class="quote">+=</span>” to keep
5791: the listing of global legacy options. A warning will be issued if
5792: the user uses a legacy option.</p></li>
5793: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
5794: options implied by deprecated variables used. This can be used for
5795: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
5796: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
5797: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
5798: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
5799: a list of warnings about deprecated variables or options used, and
5800: what to use instead.</p></li>
5801: </ol></div>
5802: <p>A package should never modify
5803: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
5804: <code class="varname">PKG_OPTIONS_VAR</code>. These are strictly user-settable.
5805: To suggest a default set of options, use
5806: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
5807: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
1.76 rillig 5808: including <code class="filename">bsd.options.mk</code>. If none of
1.75 rillig 5809: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
5810: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
5811: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
5812: happen with platform-specific options if none of them is supported on
5813: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
5814: empty list and the package is otherwise treated as not using the
5815: options framework.</p>
1.76 rillig 5816: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
1.75 rillig 5817: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
5818: build options, properly filtered to remove unsupported and duplicate
5819: options.</p>
5820: <p>The remaining sections contain the logic that is specific to
5821: each option. The correct way to check for an option is to check
5822: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
5823: <pre class="programlisting">
5824: .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
5825: </pre>
5826: </div>
5827: <div class="sect1" lang="en">
5828: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5829: <a name="option-names"></a>14.3. Option Names</h2></div></div></div>
1.75 rillig 5830: <p>Options that enable similar features in different packages (like
5831: optional support for a library) should use a common name in all
5832: packages that support it (like the name of the library). If another
5833: package already has an option with the same meaning, use the same
5834: name.</p>
5835: <p>Options that enable features specific to one package, where it's
5836: unlikely that another (unrelated) package has the same (or a similar)
5837: optional feature, should use a name prefixed with
5838: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
5839: <p>If a group of related packages share an optional feature
5840: specific to that group, prefix it with the name of the
5841: “<span class="quote">main</span>” package
5842: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
5843: <p>For new options, add a line to
1.76 rillig 5844: <code class="filename">mk/defaults/options.description</code>. Lines have two
1.75 rillig 5845: fields, separated by tab. The first field is the option name, the
5846: second its description. The description should be a whole sentence
5847: (starting with an uppercase letter and ending with a period) that
5848: describes what enabling the option does. E. g. “<span class="quote">Enable ispell
5849: support.</span>” The file is sorted by option names.</p>
5850: </div>
5851: </div>
5852: <div class="chapter" lang="en">
5853: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5854: <a name="build"></a>Chapter 15. The build process</h2></div></div></div>
1.75 rillig 5855: <div class="toc">
5856: <p><b>Table of Contents</b></p>
5857: <dl>
1.77 rillig 5858: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
5859: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
5860: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
5861: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
5862: <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 5863: <dd><dl>
5864: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
5865: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
5866: </dl></dd>
1.77 rillig 5867: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
5868: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
5869: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
5870: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
5871: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
5872: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
5873: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
5874: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
5875: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
5876: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
1.88 ! wiz 5877: <dt><span class="sect1"><a href="#build.clean">15.16. Cleaning up</a></span></dt>
! 5878: <dt><span class="sect1"><a href="#build.helpful-targets">15.17. Other helpful targets</a></span></dt>
1.75 rillig 5879: </dl>
5880: </div>
5881: <div class="sect1" lang="en">
5882: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5883: <a name="build.intro"></a>15.1. Introduction</h2></div></div></div>
1.75 rillig 5884: <p>This chapter gives a detailed description on how a package is
1.87 wiz 5885: built. Building a package is separated into different
5886: <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
5887: <code class="varname">build</code>, <code class="varname">install</code>), all of which are
5888: described in the following sections. Each phase is splitted into
5889: so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
5890: containing phase, prefixed by one of <code class="varname">pre-</code>,
5891: <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
5892: <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
5893: of the actual work is done in the <code class="varname">do-*</code> stages.</p>
1.75 rillig 5894: <p>The basic steps for building a program are always the same. First
1.87 wiz 5895: the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
5896: the local system and then extracted. After any pkgsrc-specific patches
5897: to compile properly are applied, the software can be configured, then
5898: built (usually by compiling), and finally the generated binaries, etc.
5899: can be put into place on the system.</p>
1.75 rillig 5900: </div>
5901: <div class="sect1" lang="en">
5902: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5903: <a name="build.prefix"></a>15.2. Program location</h2></div></div></div>
1.75 rillig 5904: <p>Before outlining the process performed by the NetBSD package system in
1.87 wiz 5905: the next section, here's a brief discussion on where programs are
5906: installed, and which variables influence this.</p>
1.75 rillig 5907: <p>The automatic variable <code class="varname">PREFIX</code> indicates
1.87 wiz 5908: where all files of the final program shall be installed. It is
5909: usually set to <code class="varname">LOCALBASE</code>
5910: (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
1.88 ! wiz 5911: for pkgs in the <code class="filename">cross</code> category. The value of
1.87 wiz 5912: <code class="varname">PREFIX</code> needs to be put
5913: into the various places in the program's source where paths to
5914: 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 5915: <p>When choosing which of these variables to use,
1.87 wiz 5916: follow the following rules:</p>
1.75 rillig 5917: <div class="itemizedlist"><ul type="disc">
1.88 ! wiz 5918: <li><p><code class="varname">PREFIX</code> always points to the location
! 5919: where the current pkg will be installed. When referring to a
! 5920: pkg's own installation path, use
! 5921: “<span class="quote">${PREFIX}</span>”.</p></li>
! 5922: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs
! 5923: are installed. If you need to construct a -I or -L argument
! 5924: to the compiler to find includes and libraries installed by
! 5925: another non-X11 pkg, use “<span class="quote">${LOCALBASE}</span>”. The name
1.87 wiz 5926: <code class="varname">LOCALBASE</code> stems from FreeBSD, which
5927: installed all packages in <code class="filename">/usr/local</code>. As
5928: pkgsrc leaves <code class="filename">/usr/local</code> for the system
5929: administrator, this variable is a misnomer.</p></li>
1.88 ! wiz 5930: <li><p><code class="varname">X11BASE</code> is where the actual X11
! 5931: distribution (from xsrc, etc.) is installed. When looking for
! 5932: <span class="emphasis"><em>standard</em></span> X11 includes (not those
! 5933: installed by a package), use “<span class="quote">${X11BASE}</span>”.</p></li>
! 5934: <li>
! 5935: <p>X11-based packages are special in that they may be
! 5936: installed in either <code class="varname">X11BASE</code> or
! 5937: <code class="varname">LOCALBASE</code>.</p>
1.75 rillig 5938: <p>Usually, X11 packages should be installed under
1.88 ! wiz 5939: <code class="varname">LOCALBASE</code> whenever possible. Note that you
! 5940: will need to include
! 5941: <code class="filename">../../mk/x11.buildlink3.mk</code> in them to
! 5942: request the presence of X11 and to get the right compilation
! 5943: flags.</p>
1.75 rillig 5944: <p>Even though, there are some packages that cannot be installed
1.87 wiz 5945: under <code class="varname">LOCALBASE</code>: those that come with app-defaults
5946: files. These packages are special and they must be placed under
5947: <code class="varname">X11BASE</code>. To accomplish this, set either
5948: <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
5949: your package.</p>
1.75 rillig 5950: <p>Some notes: If you need
1.87 wiz 5951: to find includes or libraries installed by a pkg that has
5952: <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
5953: its pkg <code class="filename">Makefile</code>, you need to look in
5954: <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
5955: <code class="filename">${LOCALBASE}</code>. To force installation of
5956: all X11 packages in <code class="varname">LOCALBASE</code>, the
5957: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a> package
5958: is enabled by default.</p>
1.75 rillig 5959: </li>
1.88 ! wiz 5960: <li><p><code class="varname">X11PREFIX</code> should be used to refer to
! 5961: the installed location of an X11
! 5962: package. <code class="varname">X11PREFIX</code> will be set to
! 5963: <code class="varname">X11BASE</code> if xpkgwedge is not installed, and
! 5964: to <code class="varname">LOCALBASE</code> if xpkgwedge is
! 5965: installed.</p></li>
! 5966: <li>
! 5967: <p>If xpkgwedge is installed, it is possible to have some
! 5968: packages installed in <code class="varname">X11BASE</code> and some in
! 5969: <code class="varname">LOCALBASE</code>. To determine the prefix of an
! 5970: installed package, the <code class="varname">EVAL_PREFIX</code>
! 5971: definition can be used. It takes pairs in the format
! 5972: “<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>
! 5973: variable <code class="varname">DIRNAME</code> will be set to the prefix
! 5974: of the installed package <package>, or
! 5975: “<span class="quote">${X11PREFIX}</span>” if the package is not
! 5976: installed.</p>
1.75 rillig 5977: <p>This is best illustrated by example.</p>
5978: <p>The following lines are taken from
1.87 wiz 5979: <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
1.75 rillig 5980: <pre class="programlisting">
1.87 wiz 5981: EVAL_PREFIX+= GTKDIR=gtk+
5982: CONFIGURE_ARGS+= --with-guile-prefix=${LOCALBASE:Q}
5983: CONFIGURE_ARGS+= --with-gtk-prefix=${GTKDIR:Q}
5984: CONFIGURE_ARGS+= --enable-multibyte
5985: </pre>
1.88 ! wiz 5986: <p>Specific defaults can be defined for the packages
! 5987: evaluated using <code class="varname">EVAL_PREFIX</code>, by using a
! 5988: definition of the form:</p>
1.75 rillig 5989: <pre class="programlisting">
1.87 wiz 5990: GTKDIR_DEFAULT= ${LOCALBASE}
5991: </pre>
1.75 rillig 5992: <p>where <code class="varname">GTKDIR</code> corresponds
1.87 wiz 5993: to the first definition in
5994: the <code class="varname">EVAL_PREFIX</code> pair.</p>
1.75 rillig 5995: </li>
1.76 rillig 5996: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.87 wiz 5997: 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
5998: manual pages go into <code class="filename">${PREFIX}/man</code>, not
5999: <code class="filename">${PREFIX}/share/man</code>.</p></li>
1.75 rillig 6000: </ul></div>
6001: </div>
6002: <div class="sect1" lang="en">
6003: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6004: <a name="build.builddirs"></a>15.3. Directories used during the build process</h2></div></div></div>
1.75 rillig 6005: <p>When building a package, a number of directories is used to store
1.87 wiz 6006: source files, temporary files, pkgsrc-internal files, and so on. These
6007: directories are explained here.</p>
1.75 rillig 6008: <p>Some of the directory variables contain relative pathnames. There
1.87 wiz 6009: are two common base directories for these relative directories:
6010: <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
6011: pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
6012: inside the package itself.</p>
1.75 rillig 6013: <div class="variablelist"><dl>
6014: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
6015: <dd><p>This is an absolute pathname that points to the pkgsrc
1.87 wiz 6016: root directory. Generally, you don't need
6017: it.</p></dd>
1.75 rillig 6018: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
6019: <dd><p>This is a pathname relative to
1.87 wiz 6020: <code class="varname">PKGSRCDIR</code> that points to the current
6021: package.</p></dd>
1.75 rillig 6022: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
6023: <dd><p>This is an absolute pathname pointing to the directory
1.87 wiz 6024: where all work takes place. The distfiles are extraced to this
6025: directory. It also contains temporary directories and log files used by
6026: the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
6027: the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
1.75 rillig 6028: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
6029: <dd><p>This is an absolute pathname pointing to the directory
1.87 wiz 6030: where the distfiles are extracted. It is usually a direct subdirectory
6031: of <code class="varname">WRKDIR</code>, and often it's the only directory entry
6032: that isn't hidden. This variable may be changed by a package
6033: <code class="filename">Makefile</code>.</p></dd>
1.75 rillig 6034: </dl></div>
6035: </div>
6036: <div class="sect1" lang="en">
6037: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6038: <a name="build.running"></a>15.4. Running a phase</h2></div></div></div>
1.75 rillig 6039: <p>You can run a particular phase by typing <span><strong class="command">make
1.87 wiz 6040: phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
6041: phase. This will automatically run all phases that are required for this
6042: phase. The default phase is <code class="varname">build</code>, that is, when you
6043: run <span><strong class="command">make</strong></span> without parameters in a package directory,
6044: the package will be built, but not installed.</p>
1.75 rillig 6045: </div>
6046: <div class="sect1" lang="en">
6047: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6048: <a name="build.fetch"></a>15.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.81 rillig 6049: <p>The first step in building a package is to fetch the
1.88 ! wiz 6050: distribution files (distfiles) from the sites that are providing
! 6051: them. This is the task of the <span class="emphasis"><em>fetch</em></span>
! 6052: phase.</p>
1.81 rillig 6053: <div class="sect2" lang="en">
6054: <div class="titlepage"><div><div><h3 class="title">
6055: <a name="build.fetch.what"></a>15.5.1. What to fetch and where to get it from</h3></div></div></div>
1.88 ! wiz 6056: <p>In simple cases, <code class="varname">MASTER_SITES</code>
! 6057: defines all URLs from where the distfile, whose name is
! 6058: derived from the <code class="varname">DISTNAME</code> variable, is
! 6059: fetched. The more complicated cases are described
! 6060: below.</p>
! 6061: <p>The variable <code class="varname">DISTFILES</code> specifies
! 6062: the list of distfiles that have to be fetched. Its value
! 6063: defaults to <code class="literal">${DISTNAME}${EXTRACT_SUFX}</code>,
! 6064: so that most packages don't need to define it at all.
! 6065: <code class="varname">EXTRACT_SUFX</code> is
! 6066: <code class="literal">.tar.gz</code> by default, but can be changed
! 6067: freely. Note that if your package requires additional
! 6068: distfiles to the default one, you cannot just append the
! 6069: additional filenames using the <code class="literal">+=</code>
! 6070: operator, but you have write for example:</p>
1.81 rillig 6071: <pre class="programlisting">
1.88 ! wiz 6072: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
! 6073: </pre>
! 6074: <p>Each distfile is fetched from a list of sites, usually
! 6075: <code class="varname">MASTER_SITES</code>. If the package has multiple
! 6076: <code class="varname">DISTFILES</code> or multiple
! 6077: <code class="varname">PATCHFILES</code> from different sites, you can
! 6078: set
! 6079: <code class="varname">SITES.<em class="replaceable"><code>distfile</code></em></code>
! 6080: to the list of URLs where the file
! 6081: <code class="filename"><em class="replaceable"><code>distfile</code></em></code>
! 6082: (including the suffix) can be found.</p>
! 6083: <pre class="programlisting">
! 6084: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
! 6085: DISTFILES+= foo-file.tar.gz
! 6086: SITES.foo-file.tar.gz= \
! 6087: http://www.somewhere.com/somehow/ \
! 6088: http://www.somewhereelse.com/mirror/somehow/
! 6089: </pre>
1.81 rillig 6090: <p>When actually fetching the distfiles, each item from
1.88 ! wiz 6091: <code class="varname">MASTER_SITES</code> or
! 6092: <code class="varname">SITES.*</code> gets the name of each distfile
! 6093: appended to it, without an intermediate slash. Therefore,
! 6094: all site values have to end with a slash or other separator
! 6095: character. This allows for example to set
! 6096: <code class="varname">MASTER_SITES</code> to a URL of a CGI script
! 6097: that gets the name of the distfile as a parameter. In this
! 6098: case, the definition would look like:</p>
1.81 rillig 6099: <pre class="programlisting">
1.88 ! wiz 6100: MASTER_SITES= http://www.example.com/download.cgi?file=
! 6101: </pre>
1.81 rillig 6102: <p>There are some predefined values for
1.88 ! wiz 6103: <code class="varname">MASTER_SITES</code>, which can be used in
! 6104: packages. The names of the variables should speak for
! 6105: themselves.</p>
! 6106: <pre class="programlisting">
! 6107: ${MASTER_SITE_APACHE}
! 6108: ${MASTER_SITE_BACKUP}
! 6109: ${MASTER_SITE_CYGWIN}
! 6110: ${MASTER_SITE_DEBIAN}
! 6111: ${MASTER_SITE_FREEBSD}
! 6112: ${MASTER_SITE_FREEBSD_LOCAL}
! 6113: ${MASTER_SITE_GNOME}
! 6114: ${MASTER_SITE_GNU}
! 6115: ${MASTER_SITE_GNUSTEP}
! 6116: ${MASTER_SITE_IFARCHIVE}
! 6117: ${MASTER_SITE_KDE}
! 6118: ${MASTER_SITE_MOZILLA}
! 6119: ${MASTER_SITE_MYSQL}
! 6120: ${MASTER_SITE_OPENOFFICE}
! 6121: ${MASTER_SITE_PERL_CPAN}
! 6122: ${MASTER_SITE_PGSQL}
! 6123: ${MASTER_SITE_R_CRAN}
! 6124: ${MASTER_SITE_SOURCEFORGE}
! 6125: ${MASTER_SITE_SOURCEFORGE_JP}
! 6126: ${MASTER_SITE_SUNSITE}
! 6127: ${MASTER_SITE_SUSE}
! 6128: ${MASTER_SITE_TEX_CTAN}
! 6129: ${MASTER_SITE_XCONTRIB}
! 6130: ${MASTER_SITE_XEMACS}
! 6131: </pre>
! 6132: <p>Some explanations for the less self-explaining ones:
! 6133: <code class="varname">MASTER_SITE_BACKUP</code> contains backup sites
! 6134: for packages that are maintained in <a href="ftp://ftp.NetBSD.org:/pub/NetBSD/packages/distfiles/%24%7BDIST_SUBDIR%7D" target="_top">ftp://ftp.NetBSD.org:/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}</a>. <code class="varname">MASTER_SITE_LOCAL</code> contains local
! 6135: package source distributions that are maintained in <a href="ftp://ftp.NetBSD.org:/pub/NetBSD/packages/distfiles/LOCAL_PORTS/" target="_top">ftp://ftp.NetBSD.org:/pub/NetBSD/packages/distfiles/LOCAL_PORTS/</a>.</p>
! 6136: <p>If you choose one of these predefined sites, you may
! 6137: want to specify a subdirectory of that site. Since these
! 6138: macros may expand to more than one actual site, you
! 6139: <span class="emphasis"><em>must</em></span> use the following construct to
! 6140: specify a subdirectory:</p>
1.81 rillig 6141: <pre class="programlisting">
1.88 ! wiz 6142: MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
! 6143: MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
! 6144: </pre>
1.81 rillig 6145: <p>Note the trailing slash after the subdirectory
1.88 ! wiz 6146: name.</p>
1.81 rillig 6147: </div>
6148: <div class="sect2" lang="en">
6149: <div class="titlepage"><div><div><h3 class="title">
6150: <a name="build.fetch.how"></a>15.5.2. How are the files fetched?</h3></div></div></div>
1.88 ! wiz 6151: <p>The <span class="emphasis"><em>fetch</em></span> phase makes sure that
! 6152: all the distfiles exist in a local directory
! 6153: (<code class="varname">DISTDIR</code>), which can be set by the pkgsrc
! 6154: user). If the files do not exist, they are fetched using
! 6155: commands of the form</p>
1.75 rillig 6156: <pre class="programlisting">
1.88 ! wiz 6157: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
! 6158: </pre>
! 6159: <p>where <code class="literal">${site}</code> varies through
! 6160: several possibilities in turn: first,
! 6161: <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the
! 6162: sites specified in either <code class="varname">SITES.file</code> if
! 6163: defined, else <code class="varname">MASTER_SITES</code> or
! 6164: <code class="varname">PATCH_SITES</code>, as applies, then finally the
! 6165: value of <code class="varname">MASTER_SITE_BACKUP</code>. The order of
! 6166: all except the first can be optionally sorted by the user,
! 6167: via setting either <code class="varname">MASTER_SORT_AWK</code> or
! 6168: <code class="varname">MASTER_SORT_REGEX</code>.</p>
1.81 rillig 6169: </div>
1.75 rillig 6170: </div>
6171: <div class="sect1" lang="en">
6172: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6173: <a name="build.checksum"></a>15.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
1.88 ! wiz 6174: <p>After the distfile(s) are fetched, their checksum is
! 6175: generated and compared with the checksums stored in the
! 6176: distinfo file. If the checksums don't match, the build is
! 6177: aborted. This is to ensure the same distfile is used for
! 6178: building, and that the distfile wasn't changed, e.g. by some
! 6179: malign force, deliberately changed distfiles on the master
! 6180: distribution site or network lossage.</p>
1.75 rillig 6181: </div>
6182: <div class="sect1" lang="en">
6183: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6184: <a name="build.extract"></a>15.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
1.75 rillig 6185: <p>When the distfiles are present on the local system, they
1.88 ! wiz 6186: need to be extracted, as they usually come in the form of some
! 6187: compressed archive format.</p>
1.75 rillig 6188: <p>By default, all <code class="varname">DISTFILES</code> are
1.88 ! wiz 6189: extracted. If you only need some of them, you can set the
! 6190: <code class="varname">EXTRACT_ONLY</code> variable to the list of those
! 6191: files.</p>
! 6192: <p>Extracting the files is usually done by a little
! 6193: program, <code class="filename">mk/scripts/extract</code>, which
! 6194: already knows how to extract various archive formats, so most
! 6195: likely you will not need to change anything here. But if you
! 6196: need, the following variables may help you:</p>
1.75 rillig 6197: <div class="variablelist"><dl>
6198: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
6199: <dd><p>Use these variables to override the default
1.88 ! wiz 6200: options for an extract command, which are defined in
! 6201: <code class="filename">mk/scripts/extract</code>.</p></dd>
1.75 rillig 6202: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
6203: <dd><p>This variable can be set to
1.88 ! wiz 6204: <code class="literal">pax</code>, <code class="literal">tar</code> or an
! 6205: absolute pathname pointing to the command with which tar
! 6206: archives should be
! 6207: extracted.</p></dd>
1.75 rillig 6208: </dl></div>
1.88 ! wiz 6209: <p>If the <code class="filename">extract</code> program doesn't
! 6210: serve your needs, you can also override the
! 6211: <code class="varname">EXTRACT_CMD</code> variable, which holds the
! 6212: command used for extracting the files. This command is
! 6213: executed in the <code class="filename">${WRKSRC}</code>
! 6214: directory. During execution of this command, the shell
! 6215: variable <code class="varname">extract_file</code> holds the absolute
! 6216: pathname of the file that is going to be extracted.</p>
1.75 rillig 6217: <p>And if that still does not suffice, you can override the
1.88 ! wiz 6218: <code class="varname">do-extract</code> target in the package
! 6219: Makefile.</p>
1.75 rillig 6220: </div>
6221: <div class="sect1" lang="en">
6222: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6223: <a name="build.patch"></a>15.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
1.75 rillig 6224: <p>After extraction, all the patches named by the
1.88 ! wiz 6225: <code class="varname">PATCHFILES</code>, those present in the patches
! 6226: subdirectory of the package as well as in
! 6227: $LOCALPATCHES/$PKGPATH (e.g.
! 6228: <code class="filename">/usr/local/patches/graphics/png</code>) are
! 6229: applied. Patchfiles ending in <code class="filename">.Z</code> or
! 6230: <code class="filename">.gz</code> are uncompressed before they are
! 6231: applied, files ending in <code class="filename">.orig</code> or
! 6232: <code class="filename">.rej</code> are ignored. Any special options to
! 6233: <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> can be handed in
! 6234: <code class="varname">PATCH_DIST_ARGS</code>. See <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a> for more details.</p>
! 6235: <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
! 6236: it fail if the patches apply with some lines of fuzz. Please
! 6237: fix (regen) the patches so that they apply cleanly. The
! 6238: rationale behind this is that patches that don't apply cleanly
! 6239: may end up being applied in the wrong place, and cause severe
! 6240: harm there.</p>
1.75 rillig 6241: </div>
6242: <div class="sect1" lang="en">
6243: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6244: <a name="build.tools"></a>15.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
1.88 ! wiz 6245: <p>This is covered in <a href="#tools" title="Chapter 16. Tools needed for building or running">Chapter 16, <i>Tools needed for building or running</i></a>.
! 6246: </p>
1.75 rillig 6247: </div>
6248: <div class="sect1" lang="en">
6249: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6250: <a name="build.wrapper"></a>15.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
1.75 rillig 6251: <p>This phase creates wrapper programs for the compilers and
1.88 ! wiz 6252: linkers. The following variables can be used to tweak the
! 6253: wrappers.</p>
1.75 rillig 6254: <div class="variablelist"><dl>
6255: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
6256: <dd><p>The command used to print progress
1.88 ! wiz 6257: messages. Does nothing by default. Set to
! 6258: <code class="literal">${ECHO}</code> to see the progress
! 6259: messages.</p></dd>
1.75 rillig 6260: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
6261: <dd><p>This variable can be set to
1.88 ! wiz 6262: <code class="literal">yes</code> (default) or <code class="literal">no</code>,
! 6263: depending on whether you want additional information in the
! 6264: wrapper log file.</p></dd>
1.75 rillig 6265: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
6266: <dd><p>This variable can be set to
1.88 ! wiz 6267: <code class="literal">yes</code> or <code class="literal">no</code>, depending
! 6268: on whether the wrapper should use its cache, which will
! 6269: improve the speed. The default value is
! 6270: <code class="literal">yes</code>, but is forced to
! 6271: <code class="literal">no</code> if the platform does not support
! 6272: it.</p></dd>
1.75 rillig 6273: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
1.88 ! wiz 6274: <dd><p>A list of reordering commands. A reordering
! 6275: command has the form
! 6276: <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
! 6277: It ensures that that
! 6278: <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code> occurs
! 6279: before <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
! 6280: </p></dd>
1.75 rillig 6281: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
6282: <dd><p>A list of transformation commands. [TODO:
1.88 ! wiz 6283: investigate further]</p></dd>
1.75 rillig 6284: </dl></div>
6285: </div>
6286: <div class="sect1" lang="en">
6287: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6288: <a name="build.configure"></a>15.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.88 ! wiz 6289: <p>Most pieces of software need information on the header
! 6290: files, system calls, and library routines which are available
! 6291: on the platform they run on. The process of determining this
! 6292: information is known as configuration, and is usually
! 6293: automated. In most cases, a script is supplied with the
! 6294: distfiles, and its invocation results in generation of header
! 6295: files, Makefiles, etc.</p>
! 6296: <p>If the package contains a configure script, this can be
! 6297: invoked by setting <code class="varname">HAS_CONFIGURE</code> to
! 6298: “<span class="quote">yes</span>”. If the configure script is a GNU autoconf
! 6299: script, you should set <code class="varname">GNU_CONFIGURE</code> to
! 6300: “<span class="quote">yes</span>” instead. What happens in the
! 6301: <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
! 6302: <pre class="programlisting">
! 6303: .for d in ${CONFIGURE_DIRS}
! 6304: cd ${WRKSRC} && cd ${d} && env ${CONFIGURE_ENV} \
! 6305: ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
! 6306: .endfor
! 6307: </pre>
! 6308: <p><code class="varname">CONFIGURE_DIRS</code> (default:
! 6309: “<span class="quote">.</span>”) is a list of pathnames relative to
! 6310: <code class="varname">WRKSRC</code>. In each of these directories, the
! 6311: configure script is run with the environment
! 6312: <code class="varname">CONFIGURE_ENV</code> and arguments
! 6313: <code class="varname">CONFIGURE_ARGS</code>. The variables
! 6314: <code class="varname">CONFIGURE_ENV</code>,
! 6315: <code class="varname">CONFIGURE_SCRIPT</code> (default:
! 6316: “<span class="quote">./configure</span>”) and
! 6317: <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
! 6318: package.</p>
! 6319: <p>If the program uses an <code class="filename">Imakefile</code>
! 6320: for configuration, the appropriate steps can be invoked by
! 6321: setting <code class="varname">USE_IMAKE</code> to
! 6322: “<span class="quote">yes</span>”. (If you only want the package installed in
! 6323: <code class="varname">${X11PREFIX}</code> but xmkmf not being run, set
! 6324: <code class="varname">USE_X11BASE</code> instead.)</p>
1.75 rillig 6325: </div>
6326: <div class="sect1" lang="en">
6327: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6328: <a name="build.build"></a>15.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.88 ! wiz 6329: <p>For building a package, a rough equivalent of the
! 6330: following code is executed.</p>
1.75 rillig 6331: <pre class="programlisting">
1.88 ! wiz 6332: .for d in ${BUILD_DIRS}
! 6333: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
! 6334: ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
! 6335: -f ${MAKE_FILE} ${BUILD_TARGET}
! 6336: .endfor
! 6337: </pre>
! 6338: <p><code class="varname">BUILD_DIRS</code> (default:
! 6339: “<span class="quote">.</span>”) is a list of pathnames relative to
! 6340: <code class="varname">WRKSRC</code>. In each of these directories,
! 6341: <code class="varname">MAKE_PROGRAM</code> is run with the environment
! 6342: <code class="varname">MAKE_ENV</code> and arguments
! 6343: <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
! 6344: <code class="varname">MAKE_ENV</code>,
! 6345: <code class="varname">BUILD_MAKE_FLAGS</code>,
! 6346: <code class="varname">MAKE_FILE</code> and
! 6347: <code class="varname">BUILD_TARGET</code> may all be changed by the
! 6348: package.</p>
1.75 rillig 6349: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
1.88 ! wiz 6350: “<span class="quote">gmake</span>” if <code class="varname">USE_TOOLS</code> contains
! 6351: “<span class="quote">gmake</span>”, “<span class="quote">make</span>” otherwise. The
! 6352: default value of <code class="varname">MAKE_FILE</code> is
! 6353: “<span class="quote">Makefile</span>”, and <code class="varname">BUILD_TARGET</code>
! 6354: defaults to “<span class="quote">all</span>”.</p>
1.75 rillig 6355: </div>
6356: <div class="sect1" lang="en">
6357: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6358: <a name="build.test"></a>15.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
1.75 rillig 6359: <p>[TODO]</p>
6360: </div>
6361: <div class="sect1" lang="en">
6362: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6363: <a name="build.install"></a>15.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75 rillig 6364: <p>Once the build stage has completed, the final step is to
1.88 ! wiz 6365: install the software in public directories, so users can
! 6366: access the programs and files.</p>
1.75 rillig 6367: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
1.88 ! wiz 6368: equivalent of the following code is executed. Additionally,
! 6369: before and after this code, much magic is performed to do
! 6370: consistency checks, registering the package, and so on.</p>
! 6371: <pre class="programlisting">
! 6372: .for d in ${INSTALL_DIRS}
! 6373: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
! 6374: ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
! 6375: -f ${MAKE_FILE} ${BUILD_TARGET}
! 6376: .endfor
! 6377: </pre>
1.75 rillig 6378: <p>The variable's meanings are analogous to the ones in the
1.88 ! wiz 6379: <span class="emphasis"><em>build</em></span> phase.
! 6380: <code class="varname">INSTALL_DIRS</code> defaults to
! 6381: <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
! 6382: is “<span class="quote">install</span>” by default, plus
! 6383: “<span class="quote">install.man</span>” if <code class="varname">USE_IMAKE</code> is
! 6384: defined and <code class="varname">NO_INSTALL_MANPAGES</code> is not
! 6385: defined.</p>
1.75 rillig 6386: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
1.88 ! wiz 6387: variables are useful. They are all variations of the
! 6388: <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
! 6389: permissions preset. <code class="varname">INSTALL</code> is the plain
! 6390: install command. The specialized variants, together with their
! 6391: intended use, are:</p>
1.75 rillig 6392: <div class="variablelist"><dl>
6393: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
1.88 ! wiz 6394: <dd><p>directories that contain
! 6395: binaries</p></dd>
1.75 rillig 6396: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
1.88 ! wiz 6397: <dd><p>directories that contain
! 6398: scripts</p></dd>
1.75 rillig 6399: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
1.88 ! wiz 6400: <dd><p>directories that contain shared and static
! 6401: libraries</p></dd>
1.75 rillig 6402: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
1.88 ! wiz 6403: <dd><p>directories that contain data
! 6404: files</p></dd>
1.75 rillig 6405: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
1.88 ! wiz 6406: <dd><p>directories that contain man
! 6407: pages</p></dd>
1.75 rillig 6408: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
1.88 ! wiz 6409: <dd><p>binaries that can be stripped from debugging
! 6410: symbols</p></dd>
1.75 rillig 6411: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
1.88 ! wiz 6412: <dd><p>binaries that cannot be
! 6413: stripped</p></dd>
1.75 rillig 6414: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
1.88 ! wiz 6415: <dd><p>game
! 6416: binaries</p></dd>
1.75 rillig 6417: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
1.88 ! wiz 6418: <dd><p>shared and static
! 6419: libraries</p></dd>
1.75 rillig 6420: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
6421: <dd><p>data files</p></dd>
6422: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
1.88 ! wiz 6423: <dd><p>data files for
! 6424: games</p></dd>
1.75 rillig 6425: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
6426: <dd><p>man pages</p></dd>
6427: </dl></div>
6428: <p>Some other variables are:</p>
6429: <div class="variablelist"><dl>
6430: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
6431: <dd><p>A list of directories relative to
1.88 ! wiz 6432: <code class="varname">PREFIX</code> that are created by pkgsrc at the
! 6433: beginning of the <span class="emphasis"><em>install</em></span> phase. If
! 6434: this variable is set,
! 6435: <code class="varname">NO_MTREE</code>=“<span class="quote">yes</span>” is assumed,
! 6436: which means that the package claims to create all needed
! 6437: directories itself before installing files to it. Therefore
! 6438: this variable should only be set in
! 6439: <code class="filename">Makefile</code>s that are under control of the
! 6440: package's author. The directories are created with the
! 6441: correct ownership, depending on their
! 6442: name.</p></dd>
1.75 rillig 6443: </dl></div>
6444: </div>
6445: <div class="sect1" lang="en">
6446: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6447: <a name="build.package"></a>15.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
1.88 ! wiz 6448: <p>Once the install stage has completed, a binary package of
! 6449: the installed files can be built. These binary packages can be
! 6450: used for quick installation without previous compilation, e.g. by
! 6451: the <span><strong class="command">make bin-install</strong></span> or by using
! 6452: <span><strong class="command">pkg_add</strong></span>.</p>
! 6453: <p>By default, the binary packages are created in
! 6454: <code class="filename">${PACKAGES}/All</code> and symlinks are created in
! 6455: <code class="filename">${PACKAGES}/<em class="replaceable"><code>category</code></em></code>,
! 6456: one for each category in the <code class="varname">CATEGORIES</code>
! 6457: variable. <code class="varname">PACKAGES</code> defaults to
! 6458: <code class="filename">pkgsrc/packages</code>.</p>
! 6459: </div>
! 6460: <div class="sect1" lang="en">
! 6461: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 6462: <a name="build.clean"></a>15.16. Cleaning up</h2></div></div></div>
! 6463: <p>Once you're finished with a package, you can clean the work
! 6464: directory by running <span><strong class="command">make clean</strong></span>. If you want
! 6465: to clean the work directories of all dependencies too, use
! 6466: <span><strong class="command">make clean-depends</strong></span>.</p>
1.75 rillig 6467: </div>
6468: <div class="sect1" lang="en">
6469: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.88 ! wiz 6470: <a name="build.helpful-targets"></a>15.17. Other helpful targets</h2></div></div></div>
1.75 rillig 6471: <div class="variablelist"><dl>
6472: <dt><span class="term">pre/post-*</span></dt>
1.88 ! wiz 6473: <dd><p>For any of the main targets described in the
! 6474: previous section, two auxiliary targets exist with
1.87 wiz 6475: “<span class="quote">pre-</span>” and “<span class="quote">post-</span>” used as a
6476: prefix for the main target's name. These targets are
1.88 ! wiz 6477: invoked before and after the main target is called,
! 6478: allowing extra configuration or installation steps be
! 6479: performed from a package's Makefile, for example, which
! 6480: a program's configure script or install target
! 6481: omitted.</p></dd>
1.75 rillig 6482: <dt><span class="term">do-*</span></dt>
1.88 ! wiz 6483: <dd><p>Should one of the main targets do the wrong thing,
! 6484: and should there be no variable to fix this, you can
! 6485: redefine it with the do-* target. (Note that redefining
! 6486: the target itself instead of the do-* target is a bad
! 6487: idea, as the pre-* and post-* targets won't be called
! 6488: anymore, etc.) You will not usually need to do
! 6489: this.</p></dd>
1.75 rillig 6490: <dt><span class="term">reinstall</span></dt>
1.88 ! wiz 6491: <dd>
! 6492: <p>If you did a <span><strong class="command">make install</strong></span> and
! 6493: you noticed some file was not installed properly, you
! 6494: can repeat the installation with this target, which will
! 6495: ignore the “<span class="quote">already installed</span>” flag.</p>
! 6496: <p>This is the default value of
! 6497: <code class="varname">DEPENDS_TARGET</code> except in the case of
! 6498: <span><strong class="command">make update</strong></span> and <span><strong class="command">make
! 6499: package</strong></span>, where the defaults are
! 6500: “<span class="quote">package</span>” and “<span class="quote">update</span>”,
! 6501: respectively.</p>
! 6502: </dd>
1.75 rillig 6503: <dt><span class="term">deinstall</span></dt>
6504: <dd>
1.88 ! wiz 6505: <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
! 6506: current directory, effectively de-installing the
! 6507: package. The following variables can be used to tune the
! 6508: behaviour:</p>
1.75 rillig 6509: <div class="variablelist"><dl>
6510: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
6511: <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>
6512: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
1.88 ! wiz 6513: <dd><p>Remove all packages that require (depend on)
! 6514: the given package. This can be used to remove any
! 6515: packages that may have been pulled in by a given
! 6516: package, e.g. if <span><strong class="command">make deinstall
1.87 wiz 6517: DEINSTALLDEPENDS=1</strong></span> is done in
1.88 ! wiz 6518: <code class="filename">pkgsrc/x11/kde</code>, this is
! 6519: likely to remove whole KDE. Works by adding
! 6520: “<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>
! 6521: command line.</p></dd>
1.75 rillig 6522: </dl></div>
6523: </dd>
1.88 ! wiz 6524: <dt><span class="term">bin-install</span></dt>
! 6525: <dd><p>Install a binary package from local disk and via FTP
! 6526: from a list of sites (see the
! 6527: <code class="varname">BINPKG_SITES</code> variable), and do a
! 6528: <span><strong class="command">make package</strong></span> if no binary package is
! 6529: available anywhere. The arguments given to
! 6530: <span><strong class="command">pkg_add</strong></span> can be set via
! 6531: <code class="varname">BIN_INSTALL_FLAGS</code> e.g., to do verbose
! 6532: operation, etc.</p></dd>
1.75 rillig 6533: <dt><span class="term">update</span></dt>
6534: <dd>
1.88 ! wiz 6535: <p>This target causes the current package to be
! 6536: updated to the latest version. The package and all
! 6537: depending packages first get de-installed, then current
! 6538: versions of the corresponding packages get compiled and
! 6539: installed. This is similar to manually noting which
! 6540: packages are currently installed, then performing a
! 6541: series of <span><strong class="command">make deinstall</strong></span> and
! 6542: <span><strong class="command">make install</strong></span> (or whatever
! 6543: <code class="varname">UPDATE_TARGET</code> is set to) for these
! 6544: packages.</p>
! 6545: <p>You can use the “<span class="quote">update</span>” target to
! 6546: resume package updating in case a previous <span><strong class="command">make
! 6547: update</strong></span> was interrupted for some reason.
! 6548: However, in this case, make sure you don't call
! 6549: <span><strong class="command">make clean</strong></span> or otherwise remove the
! 6550: list of dependent packages in <code class="varname">WRKDIR</code>.
! 6551: Otherwise, you lose the ability to automatically update
! 6552: the current package along with the dependent packages
! 6553: you have installed.</p>
! 6554: <p>Resuming an interrupted <span><strong class="command">make
! 6555: update</strong></span> will only work as long as the package
! 6556: tree remains unchanged. If the source code for one of
! 6557: the packages to be updated has been changed, resuming
! 6558: <span><strong class="command">make update</strong></span> will most certainly
! 6559: fail!</p>
! 6560: <p>The following variables can be used either on the
! 6561: command line or in <code class="filename">/etc/mk.conf</code> to
! 6562: alter the behaviour of <span><strong class="command">make
! 6563: update</strong></span>:</p>
1.75 rillig 6564: <div class="variablelist"><dl>
6565: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
1.88 ! wiz 6566: <dd><p>Install target to recursively use for the
! 6567: updated package and the dependent packages.
! 6568: Defaults to <code class="varname">DEPENDS_TARGET</code> if
! 6569: set, “<span class="quote">install</span>” otherwise for
! 6570: <span><strong class="command">make update</strong></span>. Other good
! 6571: targets are “<span class="quote">package</span>” or
! 6572: “<span class="quote">bin-install</span>”. Do not set this to
! 6573: “<span class="quote">update</span>” or you will get stuck in an
! 6574: endless loop!</p></dd>
1.75 rillig 6575: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
1.88 ! wiz 6576: <dd><p>Don't clean up after updating. Useful if
! 6577: you want to leave the work sources of the updated
! 6578: packages around for inspection or other purposes.
! 6579: Be sure you eventually clean up the source tree
! 6580: (see the “<span class="quote">clean-update</span>” target below)
! 6581: or you may run into troubles with old source code
! 6582: still lying around on your next
! 6583: <span><strong class="command">make</strong></span> or <span><strong class="command">make
! 6584: update</strong></span>.</p></dd>
1.75 rillig 6585: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
1.88 ! wiz 6586: <dd><p>Deinstall each package before installing
! 6587: (making <code class="varname">DEPENDS_TARGET</code>). This
! 6588: may be necessary if the
! 6589: “<span class="quote">clean-update</span>” target (see below) was
! 6590: called after interrupting a running <span><strong class="command">make
! 6591: update</strong></span>.</p></dd>
1.75 rillig 6592: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
1.88 ! wiz 6593: <dd><p>Allows you to disable recursion and hardcode
! 6594: the target for packages. The default is
! 6595: “<span class="quote">update</span>” for the update target,
! 6596: facilitating a recursive update of prerequisite
! 6597: packages. Only set
! 6598: <code class="varname">DEPENDS_TARGET</code> if you want to
! 6599: disable recursive updates. Use
! 6600: <code class="varname">UPDATE_TARGET</code> instead to just
! 6601: set a specific target for each package to be
! 6602: installed during <span><strong class="command">make update</strong></span>
! 6603: (see above).</p></dd>
1.75 rillig 6604: </dl></div>
6605: </dd>
6606: <dt><span class="term">clean-update</span></dt>
6607: <dd>
1.88 ! wiz 6608: <p>Clean the source tree for all packages that would
! 6609: get updated if <span><strong class="command">make update</strong></span> was called
! 6610: from the current directory. This target should not be
! 6611: used if the current package (or any of its depending
! 6612: packages) have already been de-installed (e.g., after
! 6613: calling <span><strong class="command">make update</strong></span>) or you may lose
! 6614: some packages you intended to update. As a rule of
! 6615: thumb: only use this target <span class="emphasis"><em>before</em></span>
! 6616: the first time you run <span><strong class="command">make update</strong></span>
! 6617: and only if you have a dirty package tree (e.g., if you
! 6618: used <code class="varname">NOCLEAN</code>).</p>
! 6619: <p>If you are unsure about whether your tree is
! 6620: clean, you can either perform a <span><strong class="command">make
! 6621: clean</strong></span> at the top of the tree, or use the
! 6622: following sequence of commands from the directory of the
! 6623: package you want to update (<span class="emphasis"><em>before</em></span>
! 6624: running <span><strong class="command">make update</strong></span> for the first
! 6625: time, otherwise you lose all the packages you wanted to
! 6626: update!):</p>
1.87 wiz 6627: <pre class="screen">
6628: <code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
1.75 rillig 6629: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
1.87 wiz 6630: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong>
6631: </pre>
1.88 ! wiz 6632: <p>The following variables can be used either on the
! 6633: command line or in <code class="filename">/etc/mk.conf</code> to
! 6634: alter the behaviour of <span><strong class="command">make
! 6635: clean-update</strong></span>:</p>
1.75 rillig 6636: <div class="variablelist"><dl>
6637: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
1.88 ! wiz 6638: <dd><p>After <span><strong class="command">make clean</strong></span>, do not
! 6639: reconstruct the list of directories to update for
! 6640: this package. Only use this if <span><strong class="command">make
! 6641: update</strong></span> successfully installed all
! 6642: packages you wanted to update. Normally, this is
! 6643: done automatically on <span><strong class="command">make
! 6644: update</strong></span>, but may have been suppressed by
! 6645: the <code class="varname">NOCLEAN</code> variable (see
! 6646: above).</p></dd>
1.75 rillig 6647: </dl></div>
6648: </dd>
1.88 ! wiz 6649: <dt><span class="term">replace</span></dt>
! 6650: <dd>
! 6651: <p>Update the installation of the current package. This
! 6652: differs from update in that it does not replace dependent
! 6653: packages. You will need to install <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgsrc/pkgtools/pkg_tarup/README.html" target="_top"><code class="filename">pkgsrc/pkgtools/pkg_tarup</code></a> for this
! 6654: target to work.</p>
! 6655: <p><span class="emphasis"><em>Be careful when using this
! 6656: target!</em></span> There are no guarantees that dependent
! 6657: packages will still work, in particular they will most
! 6658: certainly break if you <span><strong class="command">make replace</strong></span> a
! 6659: library package whose shared library major version changed
! 6660: between your installed version and the new one. For this
! 6661: reason, this target is not officially supported and only
! 6662: recommended for advanced users.</p>
! 6663: </dd>
1.75 rillig 6664: <dt><span class="term">info</span></dt>
6665: <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
1.88 ! wiz 6666: package. You can use this to check which version of a
! 6667: package is installed.</p></dd>
! 6668: <dt><span class="term">index</span></dt>
! 6669: <dd>
! 6670: <p>This is a top-level command, i.e. it should be used in
! 6671: the <code class="filename">pkgsrc</code> directory. It creates a
! 6672: database of all packages in the local pkgsrc tree, including
! 6673: dependencies, comment, maintainer, and some other useful
! 6674: information. Individual entries are created by running
! 6675: <span><strong class="command">make describe</strong></span> in the packages'
! 6676: directories. This index file is saved as
! 6677: <code class="filename">pkgsrc/INDEX</code>. It can be displayed in
! 6678: verbose format by running <span><strong class="command">make
! 6679: print-index</strong></span>. You can search in it with
! 6680: <span><strong class="command">make search
! 6681: key=<em class="replaceable"><code>something</code></em></strong></span>. You can
! 6682: extract a list of all packages that depend on a particular
! 6683: one by running <span><strong class="command">make show-deps
! 6684: PKG=<em class="replaceable"><code>somepackage</code></em></strong></span>.</p>
! 6685: <p>Running this command takes a very long time, some
! 6686: hours even on fast machines!</p>
! 6687: </dd>
1.75 rillig 6688: <dt><span class="term">readme</span></dt>
1.88 ! wiz 6689: <dd>
! 6690: <p>This target generates a
! 6691: <code class="filename">README.html</code> file, which can be
! 6692: viewed using a browser such as <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a> or <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/links/README.html" target="_top"><code class="filename">www/links</code></a>. The generated files
! 6693: contain references to any packages which are in the
! 6694: <code class="varname">PACKAGES</code> directory on the local
! 6695: host. The generated files can be made to refer to URLs
! 6696: based on <code class="varname">FTP_PKG_URL_HOST</code> and
! 6697: <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I
! 6698: wanted to generate <code class="filename">README.html</code>
! 6699: files which pointed to binary packages on the local
! 6700: machine, in the directory
! 6701: <code class="filename">/usr/packages</code>, set
! 6702: <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
! 6703: <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
! 6704: <code class="varname">${PACKAGES}</code> directory and its
! 6705: subdirectories will be searched for all the binary
! 6706: packages.</p>
! 6707: <p>The target can be run at the toplevel or in category
! 6708: directories, in which case it descends recursively.</p>
! 6709: </dd>
1.75 rillig 6710: <dt><span class="term">readme-all</span></dt>
1.88 ! wiz 6711: <dd><p>This is a top-level command, run it in
! 6712: <code class="filename">pkgsrc</code>. Use this target to create a
! 6713: file <code class="filename">README-all.html</code> which contains a
! 6714: list of all packages currently available in the NetBSD
! 6715: Packages Collection, together with the category they belong
! 6716: to and a short description. This file is compiled from the
! 6717: <code class="filename">pkgsrc/*/README.html</code> files, so be sure
! 6718: to run this <span class="emphasis"><em>after</em></span> a <span><strong class="command">make
! 6719: readme</strong></span>.</p></dd>
1.75 rillig 6720: <dt><span class="term">cdrom-readme</span></dt>
1.88 ! wiz 6721: <dd><p>This is very much the same as the
! 6722: “<span class="quote">readme</span>” target (see above), but is to be
! 6723: used when generating a pkgsrc tree to be written to a
! 6724: CD-ROM. This target also produces
! 6725: <code class="filename">README.html</code> files, and can be made
! 6726: to refer to URLs based on
! 6727: <code class="varname">CDROM_PKG_URL_HOST</code> and
1.87 wiz 6728: <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
1.75 rillig 6729: <dt><span class="term">show-distfiles</span></dt>
1.88 ! wiz 6730: <dd><p>This target shows which distfiles and patchfiles
! 6731: are needed to build the package
! 6732: (<code class="varname">ALLFILES</code>, which contains all
! 6733: <code class="varname">DISTFILES</code> and
1.87 wiz 6734: <code class="varname">PATCHFILES</code>, but not
6735: <code class="filename">patches/*</code>).</p></dd>
1.75 rillig 6736: <dt><span class="term">show-downlevel</span></dt>
1.88 ! wiz 6737: <dd><p>This target shows nothing if the package is not
! 6738: installed. If a version of this package is installed,
! 6739: but is not the version provided in this version of
! 6740: pkgsrc, then a warning message is displayed. This target
! 6741: can be used to show which of your installed packages are
! 6742: downlevel, and so the old versions can be deleted, and
! 6743: the current ones added.</p></dd>
1.75 rillig 6744: <dt><span class="term">show-pkgsrc-dir</span></dt>
1.88 ! wiz 6745: <dd><p>This target shows the directory in the pkgsrc
! 6746: hierarchy from which the package can be built and
! 6747: installed. This may not be the same directory as the one
! 6748: from which the package was installed. This target is
! 6749: intended to be used by people who may wish to upgrade
! 6750: many packages on a single host, and can be invoked from
! 6751: the top-level pkgsrc Makefile by using the
1.87 wiz 6752: “<span class="quote">show-host-specific-pkgs</span>” target.</p></dd>
1.75 rillig 6753: <dt><span class="term">show-installed-depends</span></dt>
1.88 ! wiz 6754: <dd><p>This target shows which installed packages match
! 6755: the current package's <code class="varname">DEPENDS</code>. Useful
! 6756: if out of date dependencies are causing build
! 6757: problems.</p></dd>
1.75 rillig 6758: <dt><span class="term">check-shlibs</span></dt>
1.88 ! wiz 6759: <dd><p>After a package is installed, check all its
! 6760: binaries and (on ELF platforms) shared libraries to see
! 6761: if they find the shared libs they need. Run by default
! 6762: if <code class="varname">PKG_DEVELOPER</code> is set in
1.87 wiz 6763: <code class="filename">/etc/mk.conf</code>.</p></dd>
1.75 rillig 6764: <dt><span class="term">print-PLIST</span></dt>
6765: <dd>
6766: <p>After a “<span class="quote">make install</span>” from a new or
1.88 ! wiz 6767: upgraded pkg, this prints out an attempt to generate a
! 6768: new <code class="filename">PLIST</code> from a <span><strong class="command">find
! 6769: -newer work/.extract_done</strong></span>. An attempt is made
! 6770: to care for shared libs etc., but it is
1.87 wiz 6771: <span class="emphasis"><em>strongly</em></span> recommended to review the
6772: result before putting it into
6773: <code class="filename">PLIST</code>. On upgrades, it's useful to
6774: diff the output of this command against an already
6775: existing <code class="filename">PLIST</code> file.</p>
1.88 ! wiz 6776: <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
! 6777: other methods that don't update file access times, be
! 6778: sure to add these files manually to your
1.87 wiz 6779: <code class="filename">PLIST</code>, as the “<span class="quote">find
6780: -newer</span>” command used by this target won't catch
6781: them!</p>
6782: <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
6783: information on this target.</p>
1.75 rillig 6784: </dd>
6785: <dt><span class="term">bulk-package</span></dt>
6786: <dd>
1.88 ! wiz 6787: <p>Used to do bulk builds. If an appropriate binary
! 6788: package already exists, no action is taken. If not, this
! 6789: target will compile, install and package it (and its
! 6790: depends, if <code class="varname">PKG_DEPENDS</code> is set
! 6791: properly. See <a href="#binary.configuration" title="6.3.1. Configuration">Section 6.3.1, “Configuration”</a>).
! 6792: After creating the binary package, the sources, the
! 6793: just-installed package and its required packages are
! 6794: removed, preserving free disk space.</p>
! 6795: <p><span class="emphasis"><em>Beware that this target may deinstall
! 6796: all packages installed on a system!</em></span></p>
1.75 rillig 6797: </dd>
6798: <dt><span class="term">bulk-install</span></dt>
6799: <dd>
1.88 ! wiz 6800: <p>Used during bulk-installs to install required
! 6801: packages. If an up-to-date binary package is available,
! 6802: it will 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>. If not,
! 6803: <span><strong class="command">make bulk-package</strong></span> will be executed,
1.87 wiz 6804: but the installed binary won't be removed.</p>
1.88 ! wiz 6805: <p>A binary package is considered
! 6806: “<span class="quote">up-to-date</span>” to be installed via
! 6807: <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>
! 6808: <div class="itemizedlist"><ul type="disc">
! 6809: <li><p>None of the package's files
! 6810: (<code class="filename">Makefile</code>, ...) were modified
! 6811: since it was built.</p></li>
! 6812: <li><p>None of the package's required (binary)
! 6813: packages were modified since it was built.</p></li>
1.75 rillig 6814: </ul></div>
1.88 ! wiz 6815: <p><span class="emphasis"><em>Beware that this target may deinstall
! 6816: all packages installed on a system!</em></span></p>
1.75 rillig 6817: </dd>
6818: </dl></div>
6819: </div>
6820: </div>
6821: <div class="chapter" lang="en">
6822: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 6823: <a name="tools"></a>Chapter 16. Tools needed for building or running</h2></div></div></div>
1.75 rillig 6824: <div class="toc">
6825: <p><b>Table of Contents</b></p>
6826: <dl>
1.77 rillig 6827: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
6828: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
6829: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
1.75 rillig 6830: </dl>
6831: </div>
1.87 wiz 6832: <p>The <code class="varname">USE_TOOLS</code> definition is used both internally
1.75 rillig 6833: by pkgsrc and also for individual packages to define what commands
6834: are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
6835: or for later run-time of an installed packaged (such as
6836: <code class="varname">DEPENDS</code>).
6837: If the native system provides an adequate tool, then in many cases, a pkgsrc
1.87 wiz 6838: package will not be used.</p>
6839: <p>When building a package, the replacement tools are
1.75 rillig 6840: made available in a directory (as symlinks or wrapper scripts)
6841: that is early in the executable search path. Just like the buildlink
1.87 wiz 6842: system, this helps with consistent builds.</p>
6843: <p>A tool may be needed to help build a specific package. For example,
6844: perl, GNU make (gmake) or yacc may be needed.</p>
6845: <p>Also a tool may be needed, for example, because the native system's supplied
1.75 rillig 6846: tool may be inefficient for building a package with pkgsrc.
6847: For example, a package may need GNU awk, bison (instead of
1.87 wiz 6848: yacc) or a better sed.</p>
6849: <p>The tools used by a package can be listed by running
6850: <span><strong class="command">make show-tools</strong></span>.</p>
1.75 rillig 6851: <div class="sect1" lang="en">
6852: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6853: <a name="pkgsrc-tools"></a>16.1. Tools for pkgsrc builds</h2></div></div></div>
1.87 wiz 6854: <p>The default set of tools used by pkgsrc is defined in
1.76 rillig 6855: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.75 rillig 6856: such as: <span><strong class="command">cat</strong></span>, <span><strong class="command">awk</strong></span>,
6857: <span><strong class="command">chmod</strong></span>, <span><strong class="command">test</strong></span>, and so on.
6858: These can be seen by running:
1.87 wiz 6859: <span><strong class="command">make show-var VARNAME=USE_TOOLS</strong></span>.</p>
6860: <p>If a package needs a specific program to build
1.75 rillig 6861: then the <code class="varname">USE_TOOLS</code> variable can be used
1.87 wiz 6862: to define the tools needed.</p>
1.75 rillig 6863: </div>
6864: <div class="sect1" lang="en">
6865: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6866: <a name="package-tools"></a>16.2. Tools needed by packages</h2></div></div></div>
1.87 wiz 6867: <p>In the following examples, the :pkgsrc means to use the pkgsrc version
1.75 rillig 6868: and not the native version for a build dependency.
6869: And the :run means that it is used for a
6870: run-time dependencies also (and becomes a DEPENDS).
6871: The default is a build dependency which can be set with
6872: :build. (So in this example, it is the same as gmake:build
1.87 wiz 6873: and pkg-config:build.)</p>
1.75 rillig 6874: <pre class="programlisting">
6875: USE_TOOLS+= mktemp:pkgsrc
6876: USE_TOOLS+= gmake perl:run pkg-config
6877: </pre>
1.87 wiz 6878: <p>When using the tools framework, a
1.75 rillig 6879: <code class="varname">TOOLS_PATH.foo</code> variable is defined
6880: which contains the full path to the appropriate tool. For example,
6881: <code class="varname">TOOLS_PATH.bash</code> could be “<span class="quote">/bin/bash</span>”
1.87 wiz 6882: on Linux systems.</p>
6883: <p>If you always need a pkgsrc version of the
1.75 rillig 6884: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
6885: </p>
6886: </div>
6887: <div class="sect1" lang="en">
6888: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6889: <a name="platform-tools"></a>16.3. Tools provided by platforms</h2></div></div></div>
1.87 wiz 6890: <p>When improving or porting pkgsrc to a new platform, have a look
1.75 rillig 6891: at (or create) the corresponding platform specific make file fragment under
1.76 rillig 6892: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
1.75 rillig 6893: the name of the common tools. For example:</p>
6894: <pre class="programlisting">
6895: .if exists(/usr/bin/bzcat)
6896: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
6897: .elif exists(/usr/bin/bzip2)
6898: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
6899: .endif
1.69 rillig 6900:
1.75 rillig 6901: TOOLS_PLATFORM.true?= true # shell builtin
6902: </pre>
6903: </div>
6904: </div>
6905: <div class="chapter" lang="en">
6906: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 6907: <a name="fixes"></a>Chapter 17. Making your package work</h2></div></div></div>
1.75 rillig 6908: <div class="toc">
6909: <p><b>Table of Contents</b></p>
6910: <dl>
1.77 rillig 6911: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
1.75 rillig 6912: <dd><dl>
1.78 rillig 6913: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
6914: <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>
6915: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
6916: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
6917: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
6918: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
6919: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
6920: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
6921: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
6922: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
6923: <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 6924: <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 6925: </dl></dd>
6926: <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>
6927: <dd><dl>
6928: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
6929: <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>
6930: </dl></dd>
6931: <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>
6932: <dd><dl>
6933: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
6934: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
6935: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
6936: </dl></dd>
1.87 wiz 6937: <dt><span class="sect1"><a href="#programming-languages">17.4. Programming languages</a></span></dt>
1.77 rillig 6938: <dd><dl>
1.87 wiz 6939: <dt><span class="sect2"><a href="#basic-programming-languages">17.4.1. C, C++, and Fortran</a></span></dt>
6940: <dt><span class="sect2"><a href="#java-programming-language">17.4.2. Java</a></span></dt>
6941: <dt><span class="sect2"><a href="#perl-scripts">17.4.3. Packages containing perl scripts</a></span></dt>
6942: <dt><span class="sect2"><a href="#other-programming-languages">17.4.4. Other programming languages</a></span></dt>
6943: </dl></dd>
6944: <dt><span class="sect1"><a href="#fixes.build">17.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
6945: <dd><dl>
6946: <dt><span class="sect2"><a href="#fixes.build.cpp">17.5.1. Compiling C and C++ code conditionally</a></span></dt>
6947: <dt><span class="sect2"><a href="#compiler-bugs">17.5.2. How to handle compiler bugs</a></span></dt>
6948: <dt><span class="sect2"><a href="#undefined-reference">17.5.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
6949: <dt><span class="sect2"><a href="#out-of-memory">17.5.4. Running out of memory</a></span></dt>
6950: </dl></dd>
6951: <dt><span class="sect1"><a href="#fixes.install">17.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
6952: <dd><dl>
6953: <dt><span class="sect2"><a href="#install-scripts">17.6.1. Creating needed directories</a></span></dt>
6954: <dt><span class="sect2"><a href="#where-to-install-documentation">17.6.2. Where to install documentation</a></span></dt>
6955: <dt><span class="sect2"><a href="#installing-score-files">17.6.3. Installing score files</a></span></dt>
6956: <dt><span class="sect2"><a href="#hardcoded-paths">17.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
6957: <dt><span class="sect2"><a href="#perl-modules">17.6.5. Packages installing perl modules</a></span></dt>
6958: <dt><span class="sect2"><a href="#faq.info-files">17.6.6. Packages installing info files</a></span></dt>
6959: <dt><span class="sect2"><a href="#manpages">17.6.7. Packages installing man pages</a></span></dt>
6960: <dt><span class="sect2"><a href="#gconf2-data-files">17.6.8. Packages installing GConf2 data files</a></span></dt>
6961: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.6.9. Packages installing scrollkeeper data files</a></span></dt>
6962: <dt><span class="sect2"><a href="#x11-fonts">17.6.10. Packages installing X11 fonts</a></span></dt>
6963: <dt><span class="sect2"><a href="#gtk2-modules">17.6.11. Packages installing GTK2 modules</a></span></dt>
6964: <dt><span class="sect2"><a href="#sgml-xml-data">17.6.12. Packages installing SGML or XML data</a></span></dt>
6965: <dt><span class="sect2"><a href="#mime-database">17.6.13. Packages installing extensions to the MIME database</a></span></dt>
6966: <dt><span class="sect2"><a href="#intltool">17.6.14. Packages using intltool</a></span></dt>
6967: <dt><span class="sect2"><a href="#startup-scripts">17.6.15. Packages installing startup scripts</a></span></dt>
6968: <dt><span class="sect2"><a href="#tex-packages">17.6.16. Packages installing TeX modules</a></span></dt>
6969: <dt><span class="sect2"><a href="#emulation-packages">17.6.17. Packages supporting running binaries in
6970: emulation</a></span></dt>
6971: <dt><span class="sect2"><a href="#hicolor-theme">17.6.18. Packages installing hicolor theme icons</a></span></dt>
6972: <dt><span class="sect2"><a href="#desktop-files">17.6.19. Packages installing desktop files</a></span></dt>
1.75 rillig 6973: </dl></dd>
1.87 wiz 6974: <dt><span class="sect1"><a href="#punting">17.7. Marking packages as having problems</a></span></dt>
1.75 rillig 6975: </dl>
6976: </div>
6977: <div class="sect1" lang="en">
6978: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6979: <a name="general-operation"></a>17.1. General operation</h2></div></div></div>
1.75 rillig 6980: <div class="sect2" lang="en">
6981: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 6982: <a name="portability-of-packages"></a>17.1.1. Portability of packages</h3></div></div></div>
6983: <p>One appealing feature of pkgsrc is that it runs on many
1.87 wiz 6984: different platforms. As a result, it is important to ensure,
6985: where possible, that packages in pkgsrc are portable. This
6986: chapter mentions some particular details you should pay
6987: attention to while working on pkgsrc.</p>
1.78 rillig 6988: </div>
6989: <div class="sect2" lang="en">
6990: <div class="titlepage"><div><div><h3 class="title">
6991: <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>
6992: <p>The pkgsrc user can configure pkgsrc by overriding several
1.87 wiz 6993: variables in the file pointed to by <code class="varname">MAKECONF</code>,
6994: which is <code class="filename">/etc/mk.conf</code> by default. When you
6995: want to use those variables in the preprocessor directives of
6996: <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
6997: <code class="literal">.for</code>), you need to include the file
6998: <code class="filename">../../mk/bsd.prefs.mk</code> before, which in turn
6999: loads the user preferences.</p>
1.78 rillig 7000: <p>But note that some variables may not be completely defined
1.87 wiz 7001: after <code class="filename">../../mk/bsd.prefs.mk</code> has been
7002: included, as they may contain references to variables that are
7003: not yet defined. In shell commands this is no problem, since
7004: variables are actually macros, which are only expanded when they
7005: are used. But in the preprocessor directives mentioned above and
7006: in dependency lines (of the form <code class="literal">target:
7007: dependencies</code>) the variables are expanded at load
7008: time.</p>
1.78 rillig 7009: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7010: <h3 class="title">Note</h3>
7011: <p>Currently there is no exhaustive list of all
1.87 wiz 7012: variables that tells you whether they can be used at load time
7013: or only at run time, but it is in preparation.</p>
1.78 rillig 7014: </div>
7015: </div>
7016: <div class="sect2" lang="en">
7017: <div class="titlepage"><div><div><h3 class="title">
7018: <a name="user-interaction"></a>17.1.3. User interaction</h3></div></div></div>
1.88 ! wiz 7019: <p>Occasionally, packages require interaction from the user,
! 7020: and this can be in a number of ways:</p>
1.78 rillig 7021: <div class="itemizedlist"><ul type="disc">
1.79 rillig 7022: <li><p>When fetching the distfiles, some packages require user
1.87 wiz 7023: interaction such as entering username/password or accepting a
7024: license on a web page.</p></li>
1.88 ! wiz 7025: <li><p>When extracting the distfiles, some packages may ask for
! 7026: passwords.</p></li>
1.78 rillig 7027: <li><p>help to configure the package before it is built</p></li>
7028: <li><p>help during the build process</p></li>
7029: <li><p>help during the installation of a package</p></li>
7030: </ul></div>
1.88 ! wiz 7031: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is
! 7032: provided to notify the pkgsrc mechanism of an interactive stage
! 7033: which will be needed, and this should be set in the package's
! 7034: <code class="filename">Makefile</code>, e.g.:</p>
1.75 rillig 7035: <pre class="programlisting">
1.87 wiz 7036: INTERACTIVE_STAGE= build
7037: </pre>
1.78 rillig 7038: <p>Multiple interactive stages can be specified:</p>
1.75 rillig 7039: <pre class="programlisting">
1.87 wiz 7040: INTERACTIVE_STAGE= configure install
7041: </pre>
1.88 ! wiz 7042: <p>The user can then decide to skip this package by setting the
! 7043: <code class="varname">BATCH</code> variable.</p>
1.75 rillig 7044: </div>
7045: <div class="sect2" lang="en">
7046: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7047: <a name="handling-licenses"></a>17.1.4. Handling licenses</h3></div></div></div>
7048: <p>A package may be covered by a license which the user has
1.87 wiz 7049: or has not agreed to accept. For these cases, pkgsrc contains
7050: a mechanism to note that a package is covered by a particular
7051: license, and the package cannot be built unless the user has
7052: accepted the license. (Installation of binary packages are
7053: not currently subject to this mechanism.) Packages with
7054: licenses that are either Open Source according to the Open
7055: Source Initiative or Free according to the Free Software
7056: Foundation will not be marked with a license tag. Packages
7057: with licenses that have not been determined to meet either
7058: definition will be marked with a license tag referring to the
7059: license. This will prevent building unless pkgsrc is informed
7060: that the license is acceptable, and enables displaying the
7061: license.</p>
1.78 rillig 7062: <p>The license tag mechanism is intended to address
1.87 wiz 7063: copyright-related issues surrounding building, installing and
7064: using a package, and not to address redistribution issues (see
7065: <code class="varname">RESTRICTED</code> and
7066: <code class="varname">NO_SRC_ON_FTP</code>, etc.). However, the above
7067: definition of licenses for which tags are not needed implies
7068: that packages with redistribution restrictions should have
7069: tags.</p>
7070: <p>Denoting that a package is covered by a particular license
7071: is done by placing the license in
7072: <code class="filename">pkgsrc/licenses</code> and setting the
7073: <code class="varname">LICENSE</code> variable to a string identifying the
7074: license, e.g. in <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>:</p>
7075: <pre class="programlisting">
7076: LICENSE= xv-license
7077: </pre>
7078: <p>When trying to build, the user will get a notice that the
7079: package is covered by a license which has not been
7080: accepted:</p>
7081: <pre class="programlisting">
7082: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
7083: ===> xv-3.10anb9 has an unacceptable license: xv-license.
7084: ===> To view the license, enter "/usr/bin/make show-license".
7085: ===> To indicate acceptance, add this line to your /etc/mk.conf:
7086: ===> ACCEPTABLE_LICENSES+=xv-license
7087: *** Error code 1
7088: </pre>
1.78 rillig 7089: <p>The license can be viewed with <span><strong class="command">make
1.87 wiz 7090: show-license</strong></span>, and if it is considered appropriate,
7091: the line printed above can be added to
7092: <code class="filename">/etc/mk.conf</code> to indicate acceptance of
7093: the particular license:</p>
1.78 rillig 7094: <pre class="programlisting">
1.87 wiz 7095: ACCEPTABLE_LICENSES+=xv-license
7096: </pre>
1.78 rillig 7097: <p>When adding a package with a new license, the license
1.87 wiz 7098: text should be added to <code class="filename">pkgsrc/licenses</code>
7099: for displaying. A list of known licenses can be seen in this
7100: directory as well as by looking at the list of (commented
7101: out) <code class="varname">ACCEPTABLE_LICENSES</code> variable
7102: settings in
7103: <code class="filename">pkgsrc/mk/defaults/mk.conf</code>.</p>
1.78 rillig 7104: <p>The use of <code class="varname">LICENSE=shareware</code>,
1.87 wiz 7105: <code class="varname">LICENSE=no-commercial-use</code>, and similar
7106: language is deprecated because it does not crisply refer to
7107: a particular license text. Another problem with such usage
7108: is that it does not enable a user to denote acceptance of
7109: the license for a single package without accepting the same
7110: license text for another package. In particular, this can
7111: be inappropriate when e.g. one accepts a particular license to
7112: indicate to pkgsrc that a fee has been paid.</p>
1.75 rillig 7113: </div>
7114: <div class="sect2" lang="en">
7115: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7116: <a name="restricted-packages"></a>17.1.5. Restricted packages</h3></div></div></div>
1.75 rillig 7117: <p>Some licenses restrict how software may be re-distributed.
1.87 wiz 7118: In order to satisfy these restrictions, the package system
7119: defines five make variables that can be set to note these
7120: restrictions:</p>
1.75 rillig 7121: <div class="itemizedlist"><ul type="disc">
7122: <li>
7123: <p><code class="varname">RESTRICTED</code></p>
7124: <p>This variable should be set whenever a restriction
1.87 wiz 7125: exists (regardless of its kind). Set this variable to a
7126: string containing the reason for the restriction.</p>
1.75 rillig 7127: </li>
7128: <li>
7129: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
7130: <p>Binaries may not be placed on CD-ROM. Set this
1.87 wiz 7131: variable to <code class="varname">${RESTRICTED}</code> whenever a
7132: binary package may not be included on a CD-ROM.</p>
1.75 rillig 7133: </li>
7134: <li>
7135: <p><code class="varname">NO_BIN_ON_FTP</code></p>
7136: <p>Binaries may not be placed on an FTP server. Set
1.87 wiz 7137: this variable to <code class="varname">${RESTRICTED}</code>
7138: whenever a binary package may not not be made available
7139: on the Internet.</p>
1.75 rillig 7140: </li>
7141: <li>
7142: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
7143: <p>Distfiles may not be placed on CD-ROM. Set this
1.87 wiz 7144: variable to <code class="varname">${RESTRICTED}</code> if
7145: re-distribution of the source code or other distfile(s) is
7146: not allowed on CD-ROMs.</p>
1.75 rillig 7147: </li>
7148: <li>
7149: <p><code class="varname">NO_SRC_ON_FTP</code></p>
7150: <p>Distfiles may not be placed on FTP. Set this variable
1.87 wiz 7151: to <code class="varname">${RESTRICTED}</code> if re-distribution of
7152: the source code or other distfile(s) via the Internet is not
7153: allowed. If this variable is not set, the distfile(s) will
7154: be mirrored on ftp.NetBSD.org.</p>
1.75 rillig 7155: </li>
7156: </ul></div>
7157: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
1.87 wiz 7158: <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
7159: generic make variables to denote restrictions is deprecated,
7160: because they unconditionally prevent users from generating
7161: binary packages!</p>
1.75 rillig 7162: </div>
7163: <div class="sect2" lang="en">
7164: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7165: <a name="dependencies"></a>17.1.6. Handling dependencies</h3></div></div></div>
1.75 rillig 7166: <p>Your package may depend on some other package being present
1.88 ! wiz 7167: - and there are various ways of expressing this dependency.
! 7168: pkgsrc supports the <code class="varname">BUILD_DEPENDS</code> and
! 7169: <code class="varname">DEPENDS</code> definitions, the
! 7170: <code class="varname">USE_TOOLS</code> definition, as well as dependencies
! 7171: via <code class="filename">buildlink3.mk</code>, which is the preferred way
! 7172: to handle dependencies, and which uses the variables named above.
! 7173: See <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a> for more information.</p>
1.75 rillig 7174: <p>The basic difference between the two variables is as
1.87 wiz 7175: follows: The <code class="varname">DEPENDS</code> definition registers
7176: that pre-requisite in the binary package so it will be pulled in
7177: when the binary package is later installed, whilst the
7178: <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
7179: dependency that is only needed for building the package.</p>
1.75 rillig 7180: <p>This means that if you only need a package present whilst
1.87 wiz 7181: you are building, it should be noted as a
7182: <code class="varname">BUILD_DEPENDS</code>.</p>
1.75 rillig 7183: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
1.87 wiz 7184: <code class="varname">DEPENDS</code> definition is:</p>
1.75 rillig 7185: <pre class="programlisting">
1.87 wiz 7186: <pre-req-package-name>:../../<category>/<pre-req-package>
7187: </pre>
1.75 rillig 7188: <p>Please note that the “<span class="quote">pre-req-package-name</span>”
1.87 wiz 7189: may include any of the wildcard version numbers recognized by
7190: <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>
1.75 rillig 7191: <div class="orderedlist"><ol type="1">
7192: <li>
7193: <p>If your package needs another package's binaries or
1.87 wiz 7194: libraries to build or run, and if that package has a
7195: <code class="filename">buildlink3.mk</code> file available, use it:</p>
1.75 rillig 7196: <pre class="programlisting">
1.87 wiz 7197: .include "../../graphics/jpeg/buildlink3.mk"
7198: </pre>
1.75 rillig 7199: </li>
7200: <li>
7201: <p>If your package needs to use another package to build
1.87 wiz 7202: itself and there is no <code class="filename">buildlink3.mk</code>
7203: file available, use the <code class="varname">BUILD_DEPENDS</code>
7204: definition:</p>
1.75 rillig 7205: <pre class="programlisting">
1.87 wiz 7206: BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
7207: </pre>
1.75 rillig 7208: </li>
7209: <li>
7210: <p>If your package needs a library with which to link and
1.76 rillig 7211: again there is no <code class="filename">buildlink3.mk</code> file
1.87 wiz 7212: available, this is specified using the
7213: <code class="varname">DEPENDS</code> definition. For example:</p>
1.75 rillig 7214: <pre class="programlisting">
1.87 wiz 7215: DEPENDS+= xpm-3.4j:../../graphics/xpm
7216: </pre>
1.75 rillig 7217: <p>You can also use wildcards in package dependences:</p>
7218: <pre class="programlisting">
1.87 wiz 7219: DEPENDS+= xpm-[0-9]*:../../graphics/xpm
7220: </pre>
1.75 rillig 7221: <p>Note that such wildcard dependencies are retained when
1.87 wiz 7222: creating binary packages. The dependency is checked when
7223: installing the binary package and any package which matches
7224: the pattern will be used. Wildcard dependencies should be
7225: used with care.</p>
1.75 rillig 7226: <p>The “<span class="quote">-[0-9]*</span>” should be used instead of
1.87 wiz 7227: “<span class="quote">-*</span>” to avoid potentially ambiguous matches
7228: such as “<span class="quote">tk-postgresql</span>” matching a
7229: “<span class="quote">tk-*</span>” <code class="varname">DEPENDS</code>.</p>
1.75 rillig 7230: <p>Wildcards can also be used to specify that a package
1.87 wiz 7231: will only build against a certain minimum version of a
7232: pre-requisite:</p>
1.75 rillig 7233: <pre class="programlisting">
1.87 wiz 7234: DEPENDS+= tiff>=3.5.4:../../graphics/tiff
7235: </pre>
1.75 rillig 7236: <p>This means that the package will build against version
1.87 wiz 7237: 3.5.4 of the tiff library or newer. Such a dependency may
7238: be warranted if, for example, the API of the library has
7239: changed with version 3.5.4 and a package would not compile
7240: against an earlier version of tiff.</p>
1.75 rillig 7241: <p>Please note that such dependencies should only be
1.87 wiz 7242: updated if a package requires a newer pre-requisite, but
7243: not to denote recommendations such as
7244: ABI changes that do not prevent a package from building
7245: correctly. Such recommendations can be expressed using
7246: <code class="varname">ABI_DEPENDS</code>:</p>
1.75 rillig 7247: <pre class="programlisting">
1.87 wiz 7248: ABI_DEPENDS+= tiff>=3.6.1:../../graphics/tiff
7249: </pre>
1.75 rillig 7250: <p>In addition to the above <code class="varname">DEPENDS</code>
1.87 wiz 7251: line, this denotes that while a package will build against
7252: tiff>=3.5.4, at least version 3.6.1 is recommended.
7253: <code class="varname">ABI_DEPENDS</code> entries will be turned into
7254: dependencies unless explicitly ignored (in which case a
7255: warning will be printed).</p>
1.75 rillig 7256: <p>To ignore these ABI dependency recommendations and just
1.87 wiz 7257: use the required <code class="varname">DEPENDS</code>, set
7258: <code class="varname">USE_ABI_DEPENDS=NO</code>. This may make
7259: it easier and faster to update packages built using pkgsrc,
7260: since older compatible dependencies can continue to be
7261: used. This is useful for people who watch their rebuilds
7262: very carefully; it is not very good as a general-purpose
7263: hammer. If you use it, you need to be mindful of possible
7264: ABI changes, including those from the underlying OS.</p>
1.75 rillig 7265: <p>Packages that are built with recommendations ignored
1.87 wiz 7266: may not be uploaded to ftp.NetBSD.org by developers and
7267: should not be used across different systems that may have
7268: different versions of binary packages installed.</p>
1.75 rillig 7269: <p>For security fixes, please update the package
1.87 wiz 7270: 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
7271: information.</p>
1.75 rillig 7272: </li>
7273: <li>
7274: <p>If your package needs some executable to be able to run
1.87 wiz 7275: correctly and if there's no
7276: <code class="filename">buildlink3.mk</code> file, this is specified
7277: using the <code class="varname">DEPENDS</code> variable. The
7278: <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
7279: be able to execute the latex binary from the teTeX package
7280: when it runs, and that is specified:</p>
1.75 rillig 7281: <pre class="programlisting">
1.87 wiz 7282: DEPENDS+= teTeX-[0-9]*:../../print/teTeX
7283: </pre>
1.75 rillig 7284: <p>The comment about wildcard dependencies from previous
1.87 wiz 7285: paragraph applies here, too.</p>
1.75 rillig 7286: </li>
7287: </ol></div>
7288: <p>If your package needs files from another package to build,
1.87 wiz 7289: add the relevant distribution files to
7290: <code class="varname">DISTFILES</code>, so they will be extracted
7291: 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.
7292: (It relies on the jpeg sources being present in source form
7293: during the build.)</p>
1.88 ! wiz 7294: <p>Please also note the
! 7295: <code class="varname">BUILD_USES_GETTEXT_M4</code> definition, which is
! 7296: provided as convenience definition. It adds a build dependency on
! 7297: either an installed version of an older gettext package, or if it
! 7298: isn't, installs the <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 7299: </div>
7300: <div class="sect2" lang="en">
7301: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7302: <a name="conflicts"></a>17.1.7. Handling conflicts with other packages</h3></div></div></div>
1.75 rillig 7303: <p>Your package may conflict with other packages a user might
1.87 wiz 7304: already have installed on his system, e.g. if your package
1.88 ! wiz 7305: installs the same set of files as another package in the pkgsrc
! 7306: tree.</p>
1.75 rillig 7307: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
1.87 wiz 7308: space-separated list of packages (including version string) your
7309: package conflicts with.</p>
1.76 rillig 7310: <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>
1.87 wiz 7311: 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>
7312: install the same shared library, thus you set in
7313: <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
7314: <pre class="programlisting">
7315: CONFLICTS= Xaw-Xpm-[0-9]*
7316: </pre>
7317: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:</p>
1.75 rillig 7318: <pre class="programlisting">
1.87 wiz 7319: CONFLICTS= Xaw3d-[0-9]*
7320: </pre>
1.75 rillig 7321: <p>Packages will automatically conflict with other packages
1.87 wiz 7322: with the name prefix and a different version
7323: string. “<span class="quote">Xaw3d-1.5</span>” e.g. will automatically
7324: conflict with the older version “<span class="quote">Xaw3d-1.3</span>”.</p>
1.75 rillig 7325: </div>
7326: <div class="sect2" lang="en">
7327: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7328: <a name="not-building-packages"></a>17.1.8. Packages that cannot or should not be built</h3></div></div></div>
1.75 rillig 7329: <p>There are several reasons why a package might be
1.88 ! wiz 7330: instructed to not build under certain circumstances. If the
1.87 wiz 7331: package builds and runs on most platforms, the exceptions
7332: should be noted with <code class="varname">NOT_FOR_PLATFORM</code>. If
7333: the package builds and runs on a small handful of platforms,
7334: set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
7335: Both <code class="varname">ONLY_FOR_PLATFORM</code> and
7336: <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
7337: (OS-version-platform) that can use glob-style
7338: wildcards.</p>
1.88 ! wiz 7339: <p>Some packages are tightly bound to a specific version of an
! 7340: operating system, e.g. LKMs or <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/sysutils/lsof/README.html" target="_top"><code class="filename">sysutils/lsof</code></a>. Such binary packages are not
! 7341: backwards compatible with other versions of the OS, and should be
! 7342: uploaded to a version specific directory on the FTP server. Mark
! 7343: these packages by setting <code class="varname">OSVERSION_SPECIFIC</code> to
! 7344: “<span class="quote">yes</span>”. This variable is not currently used by any of
! 7345: the package system internals, but may be used in the
! 7346: future.</p>
1.75 rillig 7347: <p>If the package should be skipped (for example, because it
1.87 wiz 7348: provides functionality already provided by the system), set
1.88 ! wiz 7349: <code class="varname">PKG_SKIP_REASON</code> to a descriptive message. If
! 7350: the package should fail because some preconditions are not met,
! 7351: set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
1.87 wiz 7352: message.</p>
1.75 rillig 7353: </div>
7354: <div class="sect2" lang="en">
7355: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7356: <a name="undeletable-packages"></a>17.1.9. Packages which should not be deleted, once installed</h3></div></div></div>
1.75 rillig 7357: <p>To ensure that a package may not be deleted, once it has been
1.87 wiz 7358: installed, the <code class="varname">PKG_PRESERVE</code> definition should
7359: be set in the package Makefile. This will be carried into any
7360: binary package that is made from this pkgsrc entry. A
7361: “<span class="quote">preserved</span>” package will
7362: 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
7363: “<span class="quote">-f</span>” option is used.</p>
1.75 rillig 7364: </div>
7365: <div class="sect2" lang="en">
7366: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7367: <a name="security-handling"></a>17.1.10. Handling packages with security problems</h3></div></div></div>
1.75 rillig 7368: <p>When a vulnerability is found, this should be noted in
1.87 wiz 7369: <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
7370: and after committing that file, use <span><strong class="command">make upload</strong></span>
7371: in the same directory to update the file on ftp.NetBSD.org.</p>
1.75 rillig 7372: <p>After fixing the vulnerability by a patch, its
1.87 wiz 7373: <code class="varname">PKGREVISION</code> should be increased (this
7374: is of course not necessary if the problem is fixed by using
7375: a newer release of the software).</p>
1.75 rillig 7376: <p>Also, if the fix should be applied to the stable pkgsrc
1.87 wiz 7377: branch, be sure to submit a pullup request!</p>
1.75 rillig 7378: <p>Binary packages already on ftp.NetBSD.org will be handled
1.87 wiz 7379: semi-automatically by a weekly cron job.</p>
1.75 rillig 7380: </div>
7381: <div class="sect2" lang="en">
7382: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7383: <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 7384: <p>When making fixes to an existing package it can be useful
1.87 wiz 7385: to change the version number in <code class="varname">PKGNAME</code>. To
7386: avoid conflicting with future versions by the original author, a
7387: “<span class="quote">nb1</span>”, “<span class="quote">nb2</span>”, ... suffix can be used
7388: on package versions by setting <code class="varname">PKGREVISION=1</code>
7389: (2, ...). The “<span class="quote">nb</span>” is treated like a
7390: “<span class="quote">.</span>” by the package tools. e.g.</p>
7391: <pre class="programlisting">
7392: DISTNAME= foo-17.42
7393: PKGREVISION= 9
7394: </pre>
1.75 rillig 7395: <p>will result in a <code class="varname">PKGNAME</code> of
1.87 wiz 7396: “<span class="quote">foo-17.42nb9</span>”. If you want to use the original
7397: value of <code class="varname">PKGNAME</code> without the “<span class="quote">nbX</span>”
7398: suffix, e.g. for setting <code class="varname">DIST_SUBDIR</code>, use
7399: <code class="varname">PKGNAME_NOREV</code>.</p>
1.75 rillig 7400: <p>When a new release of the package is released, the
1.87 wiz 7401: <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
7402: minor release of the above package, things should be like:</p>
1.75 rillig 7403: <pre class="programlisting">
1.87 wiz 7404: DISTNAME= foo-17.43
7405: </pre>
7406: <p><code class="varname">PKGREVISION</code> should be incremented for any
7407: non-trivial change in the resulting binary package. Without a
7408: <code class="varname">PKGREVISION</code> bump, someone with the previous
7409: version installed has no way of knowing that their package is out
7410: of date. Thus, changes without increasing
7411: <code class="varname">PKGREVISION</code> are essentially labeled "this is so
7412: trivial that no reasonable person would want to upgrade", and this
7413: is the rough test for when increasing
7414: <code class="varname">PKGREVISION</code> is appropriate. Examples of
7415: changes that do not merit increasing
7416: <code class="varname">PKGREVISION</code> are:</p>
7417: <pre class="programlisting">
7418: Changing <code class="varname">HOMEPAGE</code>, <code class="varname">MAINTAINER</code>,
7419: or comments in Makefile.
7420: Changing build variables if the resulting binary package is the same.
7421: Changing <code class="filename">DESCR</code>.
7422: Adding <code class="varname">PKG_OPTIONS</code> if the default options don't change.
7423: </pre>
7424: <p>Examples of changes that do merit an increase to
7425: <code class="varname">PKGREVISION</code> include:</p>
7426: <pre class="programlisting">
7427: Security fixes
7428: Changes or additions to a patch file
7429: Changes to the <code class="filename">PLIST</code>
7430: </pre>
1.78 rillig 7431: <p>PKGREVISION must also be incremented when dependencies have ABI
7432: changes.</p>
1.75 rillig 7433: </div>
1.79 rillig 7434: <div class="sect2" lang="en">
7435: <div class="titlepage"><div><div><h3 class="title">
7436: <a name="fixes.subst"></a>17.1.12. Substituting variable text in the package files (the SUBST framework)</h3></div></div></div>
7437: <p>When you want to replace the same text in multiple files
1.87 wiz 7438: or when the replacement text varies, patches alone cannot help.
7439: This is where the SUBST framework comes in. It provides an
7440: easy-to-use interface for replacing text in files.
7441: Example:</p>
7442: <pre class="programlisting">
7443: SUBST_CLASSES+= fix-paths
7444: SUBST_STAGE.fix-paths= pre-configure
7445: SUBST_MESSAGE.fix-paths= Fixing absolute paths.
7446: SUBST_FILES.fix-paths= src/*.c
7447: SUBST_FILES.fix-paths+= scripts/*.sh
7448: SUBST_SED.fix-paths= -e 's,"/usr/local,"${PREFIX},g'
7449: SUBST_SED.fix-paths+= -e 's,"/var/log,"${VARBASE}/log,g'
7450: </pre>
1.79 rillig 7451: <p><code class="varname">SUBST_CLASSES</code> is a list of identifiers
1.87 wiz 7452: that are used to identify the different SUBST blocks that are
7453: defined. The SUBST framework is heavily used by pkgsrc, so it is
7454: important to always use the <code class="literal">+=</code> operator with
7455: this variable. Otherwise some substitutions may be
7456: skipped.</p>
1.79 rillig 7457: <p>The remaining variables of each SUBST block are
1.87 wiz 7458: parameterized with the identifier from the first line
7459: (<code class="literal">fix-paths</code> in this case.) They can be seen as
7460: parameters to a function call.</p>
1.79 rillig 7461: <p><code class="varname">SUBST_STAGE.*</code> specifies the stage at
1.87 wiz 7462: which the replacement will take place. All combinations of
7463: <code class="literal">pre-</code>, <code class="literal">do-</code> and
7464: <code class="literal">post-</code> together with a phase name are
7465: possible, though only few are actually used. Most commonly used
7466: are <code class="literal">post-patch</code> and
7467: <code class="literal">pre-configure</code>. Of these two,
7468: <code class="literal">pre-configure</code> should be preferred because
7469: then it is possible to run <span><strong class="command">bmake patch</strong></span> and
7470: have the state after applying the patches but before making any
7471: other changes. This is especially useful when you are debugging
7472: a package in order to create new patches for it. Similarly,
7473: <code class="literal">post-build</code> is preferred over
7474: <code class="literal">pre-install</code>, because the install phase should
7475: generally be kept as simple as possible. When you use
7476: <code class="literal">post-build</code>, you have the same files in the
7477: working directory that will be installed later, so you can check
7478: if the substitution has succeeded.</p>
1.79 rillig 7479: <p><code class="varname">SUBST_MESSAGE.*</code> is an optional text
1.87 wiz 7480: that is printed just before the substitution is done.</p>
1.79 rillig 7481: <p><code class="varname">SUBST_FILES.*</code> is the list of shell
1.87 wiz 7482: globbing patterns that specifies the files in which the
7483: substitution will take place. The patterns are interpreted
7484: relatively to the <code class="varname">WRKSRC</code> directory.</p>
1.79 rillig 7485: <p><code class="varname">SUBST_SED.*</code> is a list of arguments to
1.87 wiz 7486: <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
7487: command should be prefixed with <code class="literal">-e</code>, so that
7488: all SUBST blocks look uniform.</p>
1.79 rillig 7489: <p>There are some more variables, but they are so seldomly
1.87 wiz 7490: used that they are only documented in the
7491: <code class="filename">mk/subst.mk</code> file.</p>
1.79 rillig 7492: </div>
1.75 rillig 7493: </div>
7494: <div class="sect1" lang="en">
7495: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7496: <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 7497: <div class="sect2" lang="en">
7498: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7499: <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 7500: <p>If you need to download from a dynamic URL you can set
1.87 wiz 7501: <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span><strong class="command">make
7502: fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
7503: with the name of each file to download as an argument, expecting
7504: it to output the URL of the directory from which to download
7505: 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
7506: example of this usage.</p>
1.75 rillig 7507: <p>If the download can't be automated, because the user must
1.87 wiz 7508: submit personal information to apply for a password, or must pay
7509: for the source, or whatever, you can set
7510: <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
7511: displayed to the user before aborting the build. Example:</p>
7512: <pre class="programlisting">
7513: FETCH_MESSAGE= "Please download the files"
7514: FETCH_MESSAGE+= " "${DISTFILES:Q}
7515: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
7516: </pre>
1.75 rillig 7517: </div>
7518: <div class="sect2" lang="en">
7519: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7520: <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 7521: <p>Sometimes authors of a software package make some
1.87 wiz 7522: modifications after the software was released, and they put up a
7523: new distfile without changing the package's version number. If a
7524: package is already in pkgsrc at that time, the checksum will
7525: no longer match. The contents of the new distfile should be
7526: compared against the old one before changing anything, to make
7527: sure the distfile was really updated on purpose, and that
7528: no trojan horse or so crept in.
7529: Then, the correct way to work around this is to
7530: set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
7531: usually based on <code class="varname">PKGNAME_NOREV</code>. All
7532: <code class="varname">DISTFILES</code> and
7533: <code class="varname">PATCHFILES</code> for this package will be put in that
7534: subdirectory of the local distfiles directory. In case this
7535: happens more often, <code class="varname">PKGNAME</code> can be used (thus
7536: including the <code class="filename">nbX</code> suffix) or a date stamp
7537: can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
7538: Do not forget regenerating the <code class="filename">distinfo</code> file
7539: after that, since it contains the <code class="varname">DIST_SUBDIR</code>
7540: path in the filenames.
7541: Furthermore, a mail to the package's authors seems appropriate
7542: telling them that changing distfiles after releases without
7543: changing the file names is not good practice.</p>
1.75 rillig 7544: </div>
7545: </div>
7546: <div class="sect1" lang="en">
7547: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7548: <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 7549: <div class="sect2" lang="en">
7550: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7551: <a name="fixes.libtool"></a>17.3.1. Shared libraries - libtool</h3></div></div></div>
1.75 rillig 7552: <p>pkgsrc supports many different machines, with different
1.87 wiz 7553: object formats like a.out and ELF, and varying abilities to do
7554: shared library and dynamic loading at all. To accompany this,
7555: varying commands and options have to be passed to the
7556: compiler, linker, etc. to get the Right Thing, which can be
7557: pretty annoying especially if you don't have all the machines
7558: at your hand to test things. The
7559: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/libtool/README.html" target="_top"><code class="filename">devel/libtool</code></a> pkg
7560: can help here, as it just “<span class="quote">knows</span>” how to build
7561: both static and dynamic libraries from a set of source files,
7562: thus being platform-independent.</p>
7563: <p>Here's how to use libtool in a package in seven simple
7564: steps:</p>
1.75 rillig 7565: <div class="orderedlist"><ol type="1">
7566: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
1.87 wiz 7567: Makefile.</p></li>
1.75 rillig 7568: <li><p>For library objects, use “<span class="quote">${LIBTOOL} --mode=compile
1.87 wiz 7569: ${CC}</span>” in place of “<span class="quote">${CC}</span>”. You could even
7570: add it to the definition of <code class="varname">CC</code>, if only
7571: libraries are being built in a given Makefile. This one command
7572: will build both PIC and non-PIC library objects, so you need not
7573: have separate shared and non-shared library rules.</p></li>
1.75 rillig 7574: <li>
7575: <p>For the linking of the library, remove any
1.87 wiz 7576: “<span class="quote">ar</span>”, “<span class="quote">ranlib</span>”, and “<span class="quote">ld
7577: -Bshareable</span>” commands, and instead use:</p>
1.75 rillig 7578: <pre class="programlisting">
1.87 wiz 7579: ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
7580: -rpath ${PREFIX}/lib -version-info major:minor
7581: </pre>
1.75 rillig 7582: <p>Note that the library is changed to have a
1.87 wiz 7583: <code class="filename">.la</code> extension, and the objects are
7584: changed to have a <code class="filename">.lo</code>
7585: extension. Change <code class="varname">OBJS</code> as
7586: necessary. This automatically creates all of the
7587: <code class="filename">.a</code>,
7588: <code class="filename">.so.major.minor</code>, and ELF symlinks (if
7589: necessary) in the build directory. Be sure to include
7590: “<span class="quote">-version-info</span>”, especially when major and
7591: minor are zero, as libtool will otherwise strip off the
7592: shared library version.</p>
1.75 rillig 7593: <p>From the libtool manual:</p>
7594: <pre class="programlisting">
1.87 wiz 7595: So, libtool library versions are described by three integers:
1.69 rillig 7596:
1.87 wiz 7597: CURRENT
7598: The most recent interface number that this library implements.
1.69 rillig 7599:
1.87 wiz 7600: REVISION
7601: The implementation number of the CURRENT interface.
1.69 rillig 7602:
1.87 wiz 7603: AGE
7604: The difference between the newest and oldest interfaces that
7605: this library implements. In other words, the library implements
7606: all the interface numbers in the range from number `CURRENT -
7607: AGE' to `CURRENT'.
1.1 grant 7608:
1.87 wiz 7609: If two libraries have identical CURRENT and AGE numbers, then the
7610: dynamic linker chooses the library with the greater REVISION number.
7611: </pre>
1.75 rillig 7612: <p>The “<span class="quote">-release</span>” option will produce
1.87 wiz 7613: different results for a.out and ELF (excluding symlinks)
7614: in only one case. An ELF library of the form
7615: “<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
7616: will have a symlink of
7617: “<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
7618: on an a.out platform. This is handled
7619: automatically.</p>
1.75 rillig 7620: <p>The “<span class="quote">-rpath argument</span>” is the install
1.87 wiz 7621: directory of the library being built.</p>
1.76 rillig 7622: <p>In the <code class="filename">PLIST</code>, include only the
1.87 wiz 7623: <code class="filename">.la</code> file, the other files will be
7624: added automatically.</p>
1.75 rillig 7625: </li>
7626: <li>
1.76 rillig 7627: <p>When linking shared object (<code class="filename">.so</code>)
1.87 wiz 7628: 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
7629: shared libraries, use “<span class="quote">-module
7630: -avoid-version</span>” to prevent them getting version
7631: tacked on.</p>
1.76 rillig 7632: <p>The <code class="filename">PLIST</code> file gets the
1.87 wiz 7633: <code class="filename">foo.so</code> entry.</p>
1.75 rillig 7634: </li>
7635: <li>
7636: <p>When linking programs that depend on these libraries
1.87 wiz 7637: <span class="emphasis"><em>before</em></span> they are installed, preface
7638: 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}
7639: --mode=link</span>”, and it will find the correct
7640: libraries (static or shared), but please be aware that
7641: libtool will not allow you to specify a relative path in
7642: -L (such as “<span class="quote">-L../somelib</span>”), because it
7643: expects you to change that argument to be the
7644: <code class="filename">.la</code> file. e.g.</p>
1.75 rillig 7645: <pre class="programlisting">
1.87 wiz 7646: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
7647: </pre>
1.75 rillig 7648: <p>should be changed to:</p>
7649: <pre class="programlisting">
1.87 wiz 7650: ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
7651: </pre>
1.75 rillig 7652: <p>and it will do the right thing with the libraries.</p>
7653: </li>
7654: <li>
7655: <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>
1.87 wiz 7656: 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}
7657: --mode=install</span>”, and change the library name to
7658: <code class="filename">.la</code>. e.g.</p>
1.75 rillig 7659: <pre class="programlisting">
1.87 wiz 7660: ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
7661: </pre>
1.76 rillig 7662: <p>This will install the static <code class="filename">.a</code>,
1.87 wiz 7663: shared library, any needed symlinks, and run
7664: <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>
1.75 rillig 7665: </li>
1.76 rillig 7666: <li><p>In your <code class="filename">PLIST</code>, include only
1.87 wiz 7667: the <code class="filename">.la</code>
7668: file (this is a change from previous behaviour).</p></li>
1.75 rillig 7669: </ol></div>
7670: </div>
7671: <div class="sect2" lang="en">
7672: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7673: <a name="using-libtool"></a>17.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
1.75 rillig 7674: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
1.87 wiz 7675: package Makefile. This will override the package's own libtool
7676: in most cases. For older libtool using packages, libtool is
7677: made by ltconfig script during the do-configure step; you can
7678: check the libtool script location by doing <span><strong class="command">make
7679: configure; find work*/ -name libtool</strong></span>.</p>
1.75 rillig 7680: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
1.87 wiz 7681: scripts, relative to <code class="varname">WRKSRC</code>, to override. By
7682: default, it is set to “<span class="quote">libtool */libtool
7683: */*/libtool</span>”. If this does not match the location of the
7684: package's libtool script(s), set it as appropriate.</p>
1.76 rillig 7685: <p>If you do not need <code class="filename">*.a</code> static
1.87 wiz 7686: libraries built and installed, then use
7687: <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
1.75 rillig 7688: <p>If your package makes use of the platform-independent library
1.87 wiz 7689: for loading dynamic shared objects, that comes with libtool
7690: (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
7691: <p>Some packages use libtool incorrectly so that the package
7692: may not work or build in some circumstances. Some of the more
7693: common errors are:</p>
1.75 rillig 7694: <div class="itemizedlist"><ul type="disc">
7695: <li>
7696: <p>The inclusion of a shared object (-module) as a dependent library in an
1.87 wiz 7697: executable or library. This in itself isn't a problem if one of two things
7698: has been done:</p>
1.75 rillig 7699: <div class="orderedlist"><ol type="1">
7700: <li><p>The shared object is named correctly, i.e.
1.87 wiz 7701: <code class="filename">libfoo.la</code>, not
7702: <code class="filename">foo.la</code></p></li>
1.75 rillig 7703: <li><p>The -dlopen option is used when linking an executable.</p></li>
7704: </ol></div>
7705: </li>
7706: <li><p>The use of libltdl without the correct calls to initialisation routines.
1.87 wiz 7707: The function lt_dlinit() should be called and the macro
7708: <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
7709: executables.</p></li>
1.75 rillig 7710: </ul></div>
7711: </div>
7712: <div class="sect2" lang="en">
7713: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7714: <a name="autoconf-automake"></a>17.3.3. GNU Autoconf/Automake</h3></div></div></div>
1.75 rillig 7715: <p>If a package needs GNU autoconf or automake to be executed
1.87 wiz 7716: to regenerate the configure script and Makefile.in makefile
7717: templates, then they should be executed in a pre-configure
7718: target.</p>
1.75 rillig 7719: <p>For packages that need only autoconf:</p>
7720: <pre class="programlisting">
1.87 wiz 7721: AUTOCONF_REQD= 2.50 # if default version is not good enough
7722: USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
7723: ...
1.1 grant 7724:
1.87 wiz 7725: pre-configure:
7726: cd ${WRKSRC}; autoconf
1.1 grant 7727:
1.87 wiz 7728: ...
7729: </pre>
1.75 rillig 7730: <p>and for packages that need automake and autoconf:</p>
7731: <pre class="programlisting">
1.87 wiz 7732: AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
7733: USE_TOOLS+= automake # use "automake14" for automake-1.4
7734: ...
7735:
7736: pre-configure:
7737: cd ${WRKSRC}; \
7738: aclocal; autoheader; \
7739: automake -a --foreign -i; autoconf
1.1 grant 7740:
1.87 wiz 7741: ...
7742: </pre>
1.75 rillig 7743: <p>Packages which use GNU Automake will almost certainly
1.87 wiz 7744: require GNU Make.</p>
1.75 rillig 7745: <p>There are times when the configure process makes
1.87 wiz 7746: additional changes to the generated files, which then causes
7747: the build process to try to re-execute the automake sequence.
7748: This is prevented by touching various files in the configure
7749: stage. If this causes problems with your package you can set
7750: <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
7751: Makefile.</p>
1.75 rillig 7752: </div>
7753: </div>
7754: <div class="sect1" lang="en">
7755: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.87 wiz 7756: <a name="programming-languages"></a>17.4. Programming languages</h2></div></div></div>
7757: <div class="sect2" lang="en">
7758: <div class="titlepage"><div><div><h3 class="title">
7759: <a name="basic-programming-languages"></a>17.4.1. C, C++, and Fortran</h3></div></div></div>
7760: <p>Compilers for the C, C++, and Fortran languages comes with
7761: the NetBSD base system. By default, pkgsrc assumes that a package
7762: is written in C and will hide all other compilers (via the wrapper
7763: framework, see <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a>).</p>
7764: <p>To declare which language's compiler a package needs, set
7765: the <code class="varname">USE_LANGUAGES</code> variable. Allowed values
7766: currently are “<span class="quote">c</span>”, “<span class="quote">c++</span>”, and
7767: “<span class="quote">fortran</span>” (and any combination). The default is
7768: “<span class="quote">c</span>”. Packages using GNU configure scripts, even if
7769: written in C++, usually need a C compiler for the configure
7770: phase.</p>
7771: </div>
7772: <div class="sect2" lang="en">
7773: <div class="titlepage"><div><div><h3 class="title">
7774: <a name="java-programming-language"></a>17.4.2. Java</h3></div></div></div>
7775: <p>If a program is written in Java, use the Java framework in
7776: pkgsrc. The package must include
7777: <code class="filename">../../mk/java-vm.mk</code>. This Makefile fragment
7778: provides the following variables:</p>
7779: <div class="itemizedlist"><ul type="disc">
7780: <li><p><code class="varname">USE_JAVA</code> defines if a build
7781: dependency on the JDK is added. If
7782: <code class="varname">USE_JAVA</code> is set to “<span class="quote">run</span>”, then
7783: there is only a runtime dependency on the JDK. The default is
7784: “<span class="quote">yes</span>”, which also adds a build dependency on the
7785: JDK.</p></li>
7786: <li><p>Set <code class="varname">USE_JAVA2</code> to declare that
7787: a package needs a Java2 implementation. The supported values
7788: are “<span class="quote">yes</span>”, “<span class="quote">1.4</span>”, and
7789: “<span class="quote">1.5</span>”. “<span class="quote">yes</span>” accepts any Java2
7790: implementation, “<span class="quote">1.4</span>” insists on versions 1.4 or
7791: above, and “<span class="quote">1.5</span>” only accepts versions 1.5 or
7792: above. This variable is not set by default.</p></li>
7793: </ul></div>
7794: </div>
7795: <div class="sect2" lang="en">
7796: <div class="titlepage"><div><div><h3 class="title">
7797: <a name="perl-scripts"></a>17.4.3. Packages containing perl scripts</h3></div></div></div>
7798: <p>If your package contains interpreted perl scripts, add
7799: “<span class="quote">perl</span>” to the <code class="varname">USE_TOOLS</code> variable
7800: and set <code class="varname">REPLACE_PERL</code> to ensure that the proper
7801: interpreter path is set. <code class="varname">REPLACE_PERL</code> should
7802: contain a list of scripts, relative to <code class="varname">WRKSRC</code>,
7803: that you want adjusted. Every occurrence of
7804: <code class="filename">*/bin/perl</code> will be replaced with the full
7805: path to the perl executable.</p>
7806: <p>If a particular version of perl is needed, set the
7807: <code class="varname">PERL5_REQD</code> variable to the version number. The
7808: default is “<span class="quote">5.0</span>”.</p>
7809: <p>See <a href="#perl-modules" title="17.6.5. Packages installing perl modules">Section 17.6.5, “Packages installing perl modules”</a> for information
7810: about handling perl modules.</p>
7811: </div>
7812: <div class="sect2" lang="en">
7813: <div class="titlepage"><div><div><h3 class="title">
7814: <a name="other-programming-languages"></a>17.4.4. Other programming languages</h3></div></div></div>
7815: <p>Currently, there is no special handling for other languages
7816: in pkgsrc. If a compiler package provides a
7817: <code class="filename">buildlink3.mk</code> file, include that, otherwise
7818: just add a (build) dependency on the appropriate compiler
7819: package.</p>
7820: </div>
7821: </div>
7822: <div class="sect1" lang="en">
7823: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7824: <a name="fixes.build"></a>17.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.77 rillig 7825: <p>The most common failures when building a package are that
7826: some platforms do not provide certain header files, functions or
7827: libraries, or they provide the functions in a library that the
7828: original package author didn't know. To work around this, you
7829: can rewrite the source code in most cases so that it does not
7830: use the missing functions or provides a replacement function.</p>
7831: <div class="sect2" lang="en">
7832: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 7833: <a name="fixes.build.cpp"></a>17.5.1. Compiling C and C++ code conditionally</h3></div></div></div>
1.77 rillig 7834: <p>If a package already comes with a GNU configure script, the
7835: preferred way to fix the build failure is to change the
7836: configure script, not the code. In the other cases, you can
7837: utilize the C preprocessor, which defines certain macros
7838: depending on the operating system and hardware architecture it
7839: compiles for. These macros can be queried using for example
7840: <code class="varname">#if defined(__i386)</code>. Almost every operating
7841: system, hardware architecture and compiler has its own macro.
7842: For example, if the macros <code class="varname">__GNUC__</code>,
7843: <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
7844: are all defined, you know that you are using NetBSD on an i386
7845: compatible CPU, and your compiler is GCC.</p>
7846: <p>The list of the following macros for hardware and
7847: operating system depends on the compiler that is used. For
7848: example, if you want to conditionally compile code on Solaris,
7849: don't use <code class="varname">__sun__</code>, as the SunPro compiler
7850: does not define it. Use <code class="varname">__sun</code> instead.</p>
1.75 rillig 7851: <div class="sect3" lang="en">
7852: <div class="titlepage"><div><div><h4 class="title">
1.87 wiz 7853: <a name="fixes.build.cpp.os"></a>17.5.1.1. C preprocessor macros to identify the operating system</h4></div></div></div>
1.75 rillig 7854: <p>To distinguish between 4.4 BSD-derived systems and the
7855: rest of the world, you should use the following code.</p>
7856: <pre class="programlisting">
7857: #include <sys/param.h>
7858: #if (defined(BSD) && BSD >= 199306)
7859: /* BSD-specific code goes here */
7860: #else
7861: /* non-BSD-specific code goes here */
7862: #endif
7863: </pre>
1.77 rillig 7864: <p>If this distinction is not fine enough, you can also test
7865: for the following macros.</p>
1.75 rillig 7866: <pre class="programlisting">
7867: FreeBSD __FreeBSD__
7868: DragonFly __DragonFly__
7869: Interix __INTERIX
7870: Linux linux, __linux, __linux__
7871: NetBSD __NetBSD__
7872: OpenBSD __OpenBSD__
7873: Solaris sun, __sun
7874: </pre>
7875: </div>
7876: <div class="sect3" lang="en">
7877: <div class="titlepage"><div><div><h4 class="title">
1.87 wiz 7878: <a name="fixes.build.cpp.arch"></a>17.5.1.2. C preprocessor macros to identify the hardware architecture</h4></div></div></div>
1.75 rillig 7879: <pre class="programlisting">
7880: i386 i386, __i386, __i386__
7881: MIPS __mips
7882: SPARC sparc, __sparc
7883: </pre>
7884: </div>
7885: <div class="sect3" lang="en">
7886: <div class="titlepage"><div><div><h4 class="title">
1.87 wiz 7887: <a name="fixes.build.cpp.compiler"></a>17.5.1.3. C preprocessor macros to identify the compiler</h4></div></div></div>
1.75 rillig 7888: <pre class="programlisting">
7889: GCC __GNUC__ (major version), __GNUC_MINOR__
7890: SunPro __SUNPRO_C (0x570 for version 5.7)
1.81 rillig 7891: SunPro C++ __SUNPRO_CC (0x580 for version 5.8)
1.75 rillig 7892: </pre>
7893: </div>
7894: </div>
1.78 rillig 7895: <div class="sect2" lang="en">
7896: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 7897: <a name="compiler-bugs"></a>17.5.2. How to handle compiler bugs</h3></div></div></div>
1.78 rillig 7898: <p>Some source files trigger bugs in the compiler, based on
1.87 wiz 7899: combinations of compiler version and architecture and almost
7900: always relation to optimisation being enabled. Common symptoms
7901: are gcc internal errors or never finishing compiling a
1.78 rillig 7902: file.</p>
7903: <p>Typically, a workaround involves testing the
7904: <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
7905: optimisation for that combination of file,
7906: <code class="varname">MACHINE_ARCH</code> and compiler, and documenting it
1.87 wiz 7907: in <code class="filename">pkgsrc/doc/HACKS</code>. See that file for a
1.78 rillig 7908: number of examples.</p>
7909: </div>
7910: <div class="sect2" lang="en">
7911: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 7912: <a name="undefined-reference"></a>17.5.3. Undefined reference to “<span class="quote">...</span>”</h3></div></div></div>
1.78 rillig 7913: <p>This compiler error often means that a package did not
7914: link to a shared library it needs. The following functions are
7915: known to cause this error message over and over.</p>
7916: <div class="informaltable">
7917: <a name="undefined-reference-functions"></a><table border="1">
7918: <colgroup>
7919: <col>
7920: <col>
7921: <col>
7922: </colgroup>
7923: <thead><tr>
7924: <th>Function</th>
7925: <th>Library</th>
7926: <th>Affected platforms</th>
7927: </tr></thead>
7928: <tbody>
7929: <tr>
7930: <td>accept, bind, connect</td>
7931: <td>-lsocket</td>
7932: <td>Solaris</td>
7933: </tr>
7934: <tr>
7935: <td>crypt</td>
7936: <td>-lcrypt</td>
7937: <td>DragonFly, NetBSD</td>
7938: </tr>
7939: <tr>
7940: <td>dlopen, dlsym</td>
7941: <td>-ldl</td>
7942: <td>Linux</td>
7943: </tr>
7944: <tr>
7945: <td>gethost*</td>
7946: <td>-lnsl</td>
7947: <td>Solaris</td>
7948: </tr>
7949: <tr>
7950: <td>inet_aton</td>
7951: <td>-lresolv</td>
7952: <td>Solaris</td>
7953: </tr>
7954: <tr>
7955: <td>nanosleep, sem_*, timer_*</td>
7956: <td>-lrt</td>
7957: <td>Solaris</td>
7958: </tr>
7959: <tr>
7960: <td>openpty</td>
7961: <td>-lutil</td>
7962: <td>Linux</td>
7963: </tr>
7964: </tbody>
7965: </table>
7966: </div>
7967: <p>To fix these linker errors, it is often sufficient to say
1.87 wiz 7968: <code class="literal">LIBS.<em class="replaceable"><code>OperatingSystem</code></em>+=
7969: -l<em class="replaceable"><code>foo</code></em></code> to the package
7970: <code class="filename">Makefile</code> and then say <span><strong class="command">bmake clean;
7971: bmake</strong></span>.</p>
7972: </div>
7973: <div class="sect2" lang="en">
7974: <div class="titlepage"><div><div><h3 class="title">
7975: <a name="out-of-memory"></a>17.5.4. Running out of memory</h3></div></div></div>
7976: <p>Sometimes packages fail to build because the compiler runs
7977: into an operating system specific soft limit. With the
7978: <code class="varname">UNLIMIT_RESOURCES</code> variable pkgsrc can be told
7979: to unlimit the resources. Currently, the allowed values are
7980: “<span class="quote">datasize</span>” and “<span class="quote">stacksize</span>” (or both).
7981: Setting this variable is similar to running the shell builtin
7982: <span><strong class="command">ulimit</strong></span> command to raise the maximum data
7983: segment size or maximum stack size of a process, respectively, to
7984: their hard limits.</p>
1.78 rillig 7985: </div>
1.75 rillig 7986: </div>
7987: <div class="sect1" lang="en">
7988: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.87 wiz 7989: <a name="fixes.install"></a>17.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75 rillig 7990: <div class="sect2" lang="en">
7991: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 7992: <a name="install-scripts"></a>17.6.1. Creating needed directories</h3></div></div></div>
1.78 rillig 7993: <p>The BSD-compatible <span><strong class="command">install</strong></span> supplied
1.87 wiz 7994: with some operating systems cannot create more than one
7995: directory at a time. As such, you should call
7996: <code class="literal">${INSTALL_*_DIR}</code> like this:</p>
7997: <pre class="programlisting">
7998: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
7999: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
8000: </pre>
1.78 rillig 8001: <p>You can also just append “<span class="quote"><code class="literal">dir1
1.87 wiz 8002: dir2</code></span>” to the
8003: <code class="varname">INSTALLATION_DIRS</code> variable, which will
8004: automatically do the right thing.</p>
1.75 rillig 8005: </div>
8006: <div class="sect2" lang="en">
8007: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8008: <a name="where-to-install-documentation"></a>17.6.2. Where to install documentation</h3></div></div></div>
1.83 wiz 8009: <p>In general, documentation should be installed into
1.87 wiz 8010: <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
8011: <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the latter
8012: includes the version number of the package).</p>
1.84 wiz 8013: <p>Many modern packages using GNU autoconf allow to set the
1.87 wiz 8014: directory where HTML documentation is installed with the
8015: “<span class="quote">--with-html-dir</span>” option. Sometimes using this flag
8016: is needed because otherwise the documentation ends up in
8017: <code class="filename">${PREFIX}/share/doc/html</code> or other
8018: places.</p>
8019: <p>An exception to the above is that library API documentation
8020: generated with the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/textproc/gtk-doc/README.html" target="_top"><code class="filename">textproc/gtk-doc</code></a> tools, for use by special
8021: browsers (devhelp) should be left at their default location, which
8022: is <code class="filename">${PREFIX}/share/gtk-doc</code>. Such
8023: documentation can be recognized from files ending in
8024: <code class="filename">.devhelp</code> or <code class="filename">.devhelp2</code>.
8025: (It is also acceptable to install such files in
8026: <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
8027: <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code>; the
8028: <code class="filename">.devhelp*</code> file must be directly in that
8029: directory then, no additional subdirectory level is allowed in
8030: this case. This is usually achieved by using
8031: “<span class="quote">--with-html-dir=${PREFIX}/share/doc</span>”.
8032: <code class="filename">${PREFIX}/share/gtk-doc</code> is preferred
8033: though.)</p>
1.75 rillig 8034: </div>
8035: <div class="sect2" lang="en">
8036: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8037: <a name="installing-score-files"></a>17.6.3. Installing score files</h3></div></div></div>
1.75 rillig 8038: <p>Certain packages, most of them in the games category, install
1.87 wiz 8039: a score file that allows all users on the system to record their
8040: highscores. In order for this to work, the binaries need to be
8041: installed setgid and the score files owned by the appropriate
8042: group and/or owner (traditionally the "games" user/group). The
8043: following variables, documented in more detail in
8044: <code class="filename">mk/defaults/mk.conf</code>, control this
8045: behaviour: <code class="varname">SETGIDGAME</code>,
8046: <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
8047: <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
1.75 rillig 8048: <p>Note that per default, setgid installation of games is
1.87 wiz 8049: disabled; setting <code class="varname">SETGIDGAME=YES</code> will set all
8050: the other variables accordingly.</p>
1.75 rillig 8051: <p>A package should therefor never hard code file ownership or
1.87 wiz 8052: access permissions but rely on <code class="varname">INSTALL_GAME</code> and
8053: <code class="varname">INSTALL_GAME_DATA</code> to set these
8054: correctly.</p>
1.75 rillig 8055: </div>
8056: <div class="sect2" lang="en">
8057: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8058: <a name="hardcoded-paths"></a>17.6.4. Packages with hardcoded paths to other interpreters</h3></div></div></div>
8059: <p>Your package may also contain scripts with hardcoded paths to
8060: other interpreters besides (or as well as) perl. To correct the
8061: full pathname to the script interpreter, you need to set the
8062: following definitions in your <code class="filename">Makefile</code> (we
8063: shall use <span><strong class="command">tclsh</strong></span> in this example):</p>
8064: <pre class="programlisting">
8065: REPLACE_INTERPRETER+= tcl
8066: REPLACE.tcl.old= .*/bin/tclsh
8067: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
8068: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
8069: # relative to ${WRKSRC}, just as in REPLACE_PERL
8070: </pre>
1.75 rillig 8071: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
8072: <h3 class="title">Note</h3>
8073: <p>Before March 2006, these variables were called
1.87 wiz 8074: <code class="varname">_REPLACE.*</code> and
8075: <code class="varname">_REPLACE_FILES.*</code>.</p>
1.75 rillig 8076: </div>
8077: </div>
8078: <div class="sect2" lang="en">
8079: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8080: <a name="perl-modules"></a>17.6.5. Packages installing perl modules</h3></div></div></div>
1.75 rillig 8081: <p>Makefiles of packages providing perl5 modules should include
1.87 wiz 8082: the Makefile fragment
8083: <code class="filename">../../lang/perl5/module.mk</code>. It provides a
8084: <span><strong class="command">do-configure</strong></span> target for the standard perl
8085: configuration for such modules as well as various hooks to tune
8086: this configuration. See comments in this file for
8087: details.</p>
1.75 rillig 8088: <p>Perl5 modules will install into different places depending
1.87 wiz 8089: on the version of perl used during the build process. To
8090: address this, pkgsrc will append lines to the
8091: <code class="filename">PLIST</code> corresponding to the files listed in
8092: the installed <code class="filename">.packlist</code> file generated by
8093: most perl5 modules. This is invoked by defining
8094: <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
8095: paths to packlist files, e.g.:</p>
1.75 rillig 8096: <pre class="programlisting">
1.87 wiz 8097: PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
8098: </pre>
1.75 rillig 8099: <p>The variables <code class="varname">PERL5_SITELIB</code>,
1.87 wiz 8100: <code class="varname">PERL5_SITEARCH</code>, and
8101: <code class="varname">PERL5_ARCHLIB</code> represent the three locations
8102: in which perl5 modules may be installed, and may be used by
8103: perl5 packages that don't have a packlist. These three
8104: variables are also substituted for in the
8105: <code class="filename">PLIST</code>.</p>
1.75 rillig 8106: </div>
8107: <div class="sect2" lang="en">
8108: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8109: <a name="faq.info-files"></a>17.6.6. Packages installing info files</h3></div></div></div>
1.75 rillig 8110: <p>Some packages install info files or use the
1.87 wiz 8111: “<span class="quote">makeinfo</span>” or “<span class="quote">install-info</span>”
8112: commands. <code class="varname">INFO_FILES</code> should be defined in
8113: the package Makefile so that <code class="filename">INSTALL</code> and
8114: <code class="filename">DEINSTALL</code> scripts will be generated to
8115: handle registration of the info files in the Info directory
8116: file. The “<span class="quote">install-info</span>” command used for the info
8117: files registration is either provided by the system, or by a
8118: special purpose package automatically added as dependency if
8119: needed.</p>
1.75 rillig 8120: <p><code class="varname">PKGINFODIR</code> is the directory under
1.87 wiz 8121: <code class="filename">${PREFIX}</code> where info files are primarily
8122: located. <code class="varname">PKGINFODIR</code> defaults to
8123: “<span class="quote">info</span>” and can be overridden by the user.</p>
1.75 rillig 8124: <p>The info files for the package should be listed in the
1.87 wiz 8125: package <code class="filename">PLIST</code>; however any split info files
8126: need not be listed.</p>
1.75 rillig 8127: <p>A package which needs the “<span class="quote">makeinfo</span>” command
1.87 wiz 8128: at build time must add “<span class="quote">makeinfo</span>” to
8129: <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
8130: version of the “<span class="quote">makeinfo</span>” command is needed it
8131: should be noted with the <code class="varname">TEXINFO_REQD</code>
8132: variable in the package <code class="filename">Makefile</code>. By
8133: default, a minimum version of 3.12 is required. If the system
8134: does not provide a <span><strong class="command">makeinfo</strong></span> command or if it
8135: does not match the required minimum, a build dependency on the
8136: <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
8137: be added automatically.</p>
1.75 rillig 8138: <p>The build and installation process of the software provided
1.87 wiz 8139: by the package should not use the
8140: <span><strong class="command">install-info</strong></span> command as the registration of
8141: info files is the task of the package
8142: <code class="filename">INSTALL</code> script, and it must use the
8143: appropriate <span><strong class="command">makeinfo</strong></span> command.</p>
1.75 rillig 8144: <p>To achieve this goal, the pkgsrc infrastructure creates
1.87 wiz 8145: overriding scripts for the <span><strong class="command">install-info</strong></span> and
8146: <span><strong class="command">makeinfo</strong></span> commands in a directory listed early
8147: in <code class="varname">PATH</code>.</p>
1.75 rillig 8148: <p>The script overriding <span><strong class="command">install-info</strong></span> has
1.87 wiz 8149: no effect except the logging of a message. The script overriding
8150: <span><strong class="command">makeinfo</strong></span> logs a message and according to the
8151: value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
8152: <span><strong class="command">makeinfo</strong></span> command or exit on error.</p>
1.75 rillig 8153: </div>
8154: <div class="sect2" lang="en">
8155: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8156: <a name="manpages"></a>17.6.7. Packages installing man pages</h3></div></div></div>
1.81 rillig 8157: <p>All packages that install manual pages should install them
1.87 wiz 8158: into the same directory, so that there is one common place to look
8159: for them. In pkgsrc, this place is
8160: <code class="literal">${PREFIX}/${PKGMANDIR}</code>, and this expression
8161: should be used in packages. The default for
8162: <code class="varname">PKGMANDIR</code> is
8163: “<span class="quote"><code class="filename">man</code></span>”. Another often-used value
8164: is “<span class="quote"><code class="filename">share/man</code></span>”.</p>
1.75 rillig 8165: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
8166: <h3 class="title">Note</h3>
1.87 wiz 8167: <p>The support for a custom <code class="varname">PKGMANDIR</code>
8168: is far from complete.</p>
1.75 rillig 8169: </div>
1.81 rillig 8170: <p>The <code class="filename">PLIST</code> files can just use
1.87 wiz 8171: <code class="filename">man/</code> as the top level directory for the man
8172: page file entries, and the pkgsrc framework will convert as
8173: needed. In all other places, the correct
8174: <code class="varname">PKGMANDIR</code> must be used.</p>
8175: <p>Packages that are
8176: configured with <code class="varname">GNU_CONFIGURE</code> set as
8177: “<span class="quote">yes</span>”, by default will use the
8178: <code class="filename">./configure</code>
8179: --mandir switch to set where the man pages should be installed.
8180: The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
8181: to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.</p>
8182: <p>Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
8183: use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
8184: to “<span class="quote">no</span>”.
8185: Or if the <code class="filename">./configure</code> script uses
8186: a non-standard use of --mandir, you can set
8187: <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.</p>
1.77 rillig 8188: <p>See <a href="#manpage-compression" title="11.5. Man page compression">Section 11.5, “Man page compression”</a> for
1.87 wiz 8189: information on installation of compressed manual pages.</p>
1.75 rillig 8190: </div>
8191: <div class="sect2" lang="en">
8192: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8193: <a name="gconf2-data-files"></a>17.6.8. Packages installing GConf2 data files</h3></div></div></div>
8194: <p>If a package installs <code class="filename">.schemas</code> or
8195: <code class="filename">.entries</code> files, used by GConf2,
8196: you need to take some extra steps to make sure they get registered
8197: in the database:</p>
1.75 rillig 8198: <div class="orderedlist"><ol type="1">
1.76 rillig 8199: <li><p>Include <code class="filename">../../devel/GConf2/schemas.mk</code>
1.87 wiz 8200: instead of its <code class="filename">buildlink3.mk</code> file. This
8201: takes care of rebuilding the GConf2 database at installation and
8202: deinstallation time, and tells the package where to install
8203: GConf2 data files using some standard configure arguments. It
8204: also disallows any access to the database directly from the
8205: package.</p></li>
1.75 rillig 8206: <li><p>Ensure that the package installs its
1.87 wiz 8207: <code class="filename">.schemas</code> files under
8208: <code class="filename">${PREFIX}/share/gconf/schemas</code>. If they get
8209: installed under <code class="filename">${PREFIX}/etc</code>, you will
8210: need to manually patch the package.</p></li>
1.75 rillig 8211: <li><p>Check the PLIST and remove any entries under the etc/gconf
1.87 wiz 8212: directory, as they will be handled automatically. See
8213: <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>
1.75 rillig 8214: <li><p>Define the <code class="varname">GCONF2_SCHEMAS</code> variable in
1.87 wiz 8215: your <code class="filename">Makefile</code> with a list of all
8216: <code class="filename">.schemas</code> files installed by the package, if
8217: any. Names must not contain any directories in them.</p></li>
1.75 rillig 8218: <li><p>Define the <code class="varname">GCONF2_ENTRIES</code> variable in
1.87 wiz 8219: your <code class="filename">Makefile</code> with a
8220: list of all <code class="filename">.entries</code> files installed by the
8221: package, if any. Names must not contain any directories in
8222: them.</p></li>
1.75 rillig 8223: </ol></div>
8224: </div>
8225: <div class="sect2" lang="en">
8226: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8227: <a name="scrollkeeper-data-files"></a>17.6.9. Packages installing scrollkeeper data files</h3></div></div></div>
8228: <p>If a package installs <code class="filename">.omf</code> files, used by
8229: scrollkeeper, you need to take some extra steps to make sure they
8230: get registered in the database:</p>
1.75 rillig 8231: <div class="orderedlist"><ol type="1">
8232: <li><p>Include
1.87 wiz 8233: <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
8234: instead of its <code class="filename">buildlink3.mk</code> file. This
8235: takes care of rebuilding the scrollkeeper database at
8236: installation and deinstallation time, and disallows any access
8237: to it directly from the package.</p></li>
1.75 rillig 8238: <li><p>Check the PLIST and remove any entries under the
1.87 wiz 8239: <code class="filename">libdata/scrollkeeper</code> directory, as they
8240: will be handled automatically.</p></li>
1.76 rillig 8241: <li><p>Remove the <code class="filename">share/omf</code> directory from
1.87 wiz 8242: the PLIST. It will be handled by scrollkeeper.</p></li>
1.75 rillig 8243: </ol></div>
8244: </div>
8245: <div class="sect2" lang="en">
8246: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8247: <a name="x11-fonts"></a>17.6.10. Packages installing X11 fonts</h3></div></div></div>
1.75 rillig 8248: <p>If a package installs font files, you will need to rebuild
1.87 wiz 8249: the fonts database in the directory where they get installed at
8250: installation and deinstallation time. This can be automatically
8251: done by using the pkginstall framework.</p>
1.75 rillig 8252: <p>You can list the directories where fonts are installed in the
1.87 wiz 8253: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
8254: variables, where <em class="replaceable"><code>type</code></em> can be one of
8255: “<span class="quote">ttf</span>”, “<span class="quote">type1</span>” or “<span class="quote">x11</span>”.
8256: Also make sure that the database file
8257: <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
1.75 rillig 8258: <p>Note that you should not create new directories for fonts;
1.87 wiz 8259: instead use the standard ones to avoid that the user needs to
8260: manually configure his X server to find them.</p>
1.75 rillig 8261: </div>
8262: <div class="sect2" lang="en">
8263: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8264: <a name="gtk2-modules"></a>17.6.11. Packages installing GTK2 modules</h3></div></div></div>
1.75 rillig 8265: <p>If a package installs GTK2 immodules or loaders, you need to
1.87 wiz 8266: take some extra steps to get them registered in the GTK2 database
8267: properly:</p>
1.75 rillig 8268: <div class="orderedlist"><ol type="1">
8269: <li><p>Include
1.87 wiz 8270: <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
8271: <code class="filename">buildlink3.mk</code> file. This takes care of
8272: rebuilding the database at installation and deinstallation time.</p></li>
8273: <li><p>Set <code class="varname">GTK2_IMMODULES=YES</code> if
8274: your package installs GTK2 immodules.</p></li>
8275: <li><p>Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
8276: GTK2 loaders.</p></li>
1.75 rillig 8277: <li>
1.87 wiz 8278: <p>Patch the package to not touch any of the GTK2
8279: databases directly. These are:</p>
1.75 rillig 8280: <div class="itemizedlist"><ul type="disc">
1.76 rillig 8281: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
8282: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
1.75 rillig 8283: </ul></div>
8284: </li>
1.87 wiz 8285: <li><p>Check the <code class="filename">PLIST</code> and remove
8286: any entries under the <code class="filename">libdata/gtk-2.0</code>
8287: directory, as they will be handled automatically.</p></li>
1.75 rillig 8288: </ol></div>
8289: </div>
8290: <div class="sect2" lang="en">
8291: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8292: <a name="sgml-xml-data"></a>17.6.12. Packages installing SGML or XML data</h3></div></div></div>
1.75 rillig 8293: <p>If a package installs SGML or XML data files that need to be
1.87 wiz 8294: registered in system-wide catalogs (like DTDs, sub-catalogs,
8295: etc.), you need to take some extra steps:</p>
1.75 rillig 8296: <div class="orderedlist"><ol type="1">
8297: <li><p>Include
1.87 wiz 8298: <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
8299: your <code class="filename">Makefile</code>, which takes care of
8300: registering those files in system-wide catalogs at
8301: installation and deinstallation time.</p></li>
1.75 rillig 8302: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
1.87 wiz 8303: any SGML catalogs installed by the package.</p></li>
1.75 rillig 8304: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
1.87 wiz 8305: any XML catalogs installed by the package.</p></li>
1.75 rillig 8306: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
1.87 wiz 8307: to be added to the SGML catalog. These come in groups of
8308: three strings; see xmlcatmgr(1) for more information
8309: (specifically, arguments recognized by the 'add' action).
8310: Note that you will normally not use this variable.</p></li>
1.75 rillig 8311: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
1.87 wiz 8312: to be added to the XML catalog. These come in groups of three
8313: strings; see xmlcatmgr(1) for more information (specifically,
8314: arguments recognized by the 'add' action). Note that you will
8315: normally not use this variable.</p></li>
1.75 rillig 8316: </ol></div>
8317: </div>
8318: <div class="sect2" lang="en">
8319: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8320: <a name="mime-database"></a>17.6.13. Packages installing extensions to the MIME database</h3></div></div></div>
1.75 rillig 8321: <p>If a package provides extensions to the MIME database by
1.87 wiz 8322: installing <code class="filename">.xml</code> files inside
8323: <code class="filename">${PREFIX}/share/mime/packages</code>, you
8324: need to take some extra steps to ensure that the database is kept
8325: consistent with respect to these new files:</p>
1.75 rillig 8326: <div class="orderedlist"><ol type="1">
8327: <li><p>Include
1.87 wiz 8328: <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
8329: (avoid using the <code class="filename">buildlink3.mk</code> file from
8330: this same directory, which is reserved for inclusion from
8331: other <code class="filename">buildlink3.mk</code> files). It takes
8332: care of rebuilding the MIME database at installation and
8333: deinstallation time, and disallows any access to it directly
8334: from the package.</p></li>
1.75 rillig 8335: <li><p>Check the PLIST and remove any entries under the
1.87 wiz 8336: <code class="filename">share/mime</code> directory,
8337: <span class="emphasis"><em>except</em></span> for files saved under
8338: <code class="filename">share/mime/packages</code>. The former are
8339: handled automatically by
8340: the update-mime-database program, but the latter are
8341: package-dependent and must be removed by the package that
8342: installed them in the first place.</p></li>
1.76 rillig 8343: <li><p>Remove any <code class="filename">share/mime/*</code> directories
1.87 wiz 8344: from the PLIST. They will be handled by the shared-mime-info
8345: package.</p></li>
1.75 rillig 8346: </ol></div>
8347: </div>
8348: <div class="sect2" lang="en">
8349: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8350: <a name="intltool"></a>17.6.14. Packages using intltool</h3></div></div></div>
1.75 rillig 8351: <p>If a package uses intltool during its build, include the
1.87 wiz 8352: <code class="filename">../../textproc/intltool/buildlink3.mk</code> file,
8353: which forces it to use the intltool package provided by pkgsrc,
8354: instead of the one bundled with the distribution file.</p>
1.75 rillig 8355: <p>This tracks intltool's build-time dependencies and uses the
1.87 wiz 8356: latest available version; this way, the package benefits of any
8357: bug fixes that may have appeared since it was released.</p>
1.75 rillig 8358: </div>
8359: <div class="sect2" lang="en">
8360: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8361: <a name="startup-scripts"></a>17.6.15. Packages installing startup scripts</h3></div></div></div>
1.75 rillig 8362: <p>If a package contains a rc.d script, it won't be copied into
1.87 wiz 8363: the startup directory by default, but you can enable it, by adding
8364: the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
8365: <code class="filename">/etc/mk.conf</code>. This option will copy the scripts
8366: into <code class="filename">/etc/rc.d</code> when a package is installed, and
8367: it will automatically remove the scripts when the package is
8368: deinstalled.</p>
1.75 rillig 8369: </div>
8370: <div class="sect2" lang="en">
8371: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8372: <a name="tex-packages"></a>17.6.16. Packages installing TeX modules</h3></div></div></div>
1.75 rillig 8373: <p>If a package installs TeX packages into the texmf tree,
1.87 wiz 8374: the <code class="filename">ls-R</code> database of the tree needs to be
8375: updated.</p>
1.75 rillig 8376: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
8377: <h3 class="title">Note</h3>
8378: <p>Except the main TeX packages such as teTeX-texmf,
1.87 wiz 8379: packages should install files
8380: into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
8381: not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
1.75 rillig 8382: </div>
8383: <div class="orderedlist"><ol type="1">
8384: <li><p>Include
1.87 wiz 8385: <code class="filename">../../print/teTeX/module.mk</code> instead
8386: of <code class="filename">../../mk/tex.buildlink3.mk</code>. This
8387: takes care of rebuilding the <code class="filename">ls-R</code>
8388: database at installation and deinstallation time.</p></li>
1.75 rillig 8389: <li>
8390: <p>If your package installs files into a texmf
1.87 wiz 8391: tree other than the one
8392: at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
8393: set <code class="varname">TEXMFDIRS</code> to the list of all texmf
8394: trees that need database update.</p>
1.75 rillig 8395: <p>If your package also installs font map files that need
1.87 wiz 8396: to be registered using <span><strong class="command">updmap</strong></span>,
8397: set <code class="varname">TEX_FONTMAPS</code> to the list of all
8398: such font map files. Then <span><strong class="command">updmap</strong></span> will
8399: be run automatically at installation/deinstallation to
8400: enable/disable font map files for TeX output
8401: drivers.</p>
1.75 rillig 8402: </li>
1.76 rillig 8403: <li><p>Make sure that none of <code class="filename">ls-R</code>
1.87 wiz 8404: databases are included in <code class="filename">PLIST</code>, as
8405: they will be removed only by the teTeX-bin package.</p></li>
1.75 rillig 8406: </ol></div>
8407: </div>
1.85 jmmv 8408: <div class="sect2" lang="en">
8409: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8410: <a name="emulation-packages"></a>17.6.17. Packages supporting running binaries in
8411: emulation</h3></div></div></div>
8412: <p>There are some packages that provide libraries and
8413: executables for running binaries from a one operating system
8414: on a different one (if the latter supports it). One example
8415: is running Linux binaries on NetBSD.</p>
8416: <p>The <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/rpm2pkg/README.html" target="_top"><code class="filename">pkgtools/rpm2pkg</code></a>
8417: helps in extracting and packaging Linux rpm packages.</p>
8418: <p>The <code class="varname">CHECK_SHLIBS</code> can be set to no to
8419: avoid the <span><strong class="command">check-shlibs</strong></span> target, which tests
8420: if all libraries for each installed executable can be found by
8421: the dynamic linker. Since the standard dynamic linker is run,
8422: this fails for emulation packages, because the libraries used
8423: by the emulation are not in the standard directories.</p>
8424: </div>
8425: <div class="sect2" lang="en">
8426: <div class="titlepage"><div><div><h3 class="title">
8427: <a name="hicolor-theme"></a>17.6.18. Packages installing hicolor theme icons</h3></div></div></div>
1.85 jmmv 8428: <p>If a package installs images under the
1.87 wiz 8429: <code class="filename">share/icons/hicolor</code> and/or updates the
8430: <code class="filename">share/icons/hicolor/icon-theme.cache</code>
8431: database, you need to take some extra steps to make sure that the
8432: shared theme directory is handled appropriately and that the cache
8433: database is rebuilt:</p>
1.85 jmmv 8434: <div class="orderedlist"><ol type="1">
8435: <li><p>Include
1.87 wiz 8436: <code class="filename">../../graphics/hicolor-icon-theme/buildlink3.mk</code>.</p></li>
8437: <li><p>Check the <code class="filename">PLIST</code> and remove the
8438: entry that refers to the theme cache.</p></li>
1.85 jmmv 8439: <li><p>Ensure that the PLIST does not remove the shared icon
8440: directories from the <code class="filename">share/icons/hicolor</code>
8441: hierarchy because they will be handled automatically.</p></li>
8442: </ol></div>
8443: <p>The best way to verify that the PLIST is correct with
8444: respect to the last two points is to regenerate it using
8445: <span><strong class="command">make print-PLIST</strong></span>.</p>
8446: </div>
8447: <div class="sect2" lang="en">
8448: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8449: <a name="desktop-files"></a>17.6.19. Packages installing desktop files</h3></div></div></div>
1.85 jmmv 8450: <p>If a package installs <code class="filename">.desktop</code> files
8451: under <code class="filename">share/applications</code> and these include
8452: MIME information, you need to take extra steps to ensure that they
8453: are registered into the MIME database:</p>
8454: <div class="orderedlist"><ol type="1">
8455: <li><p>Include
8456: <code class="filename">../../sysutils/desktop-file-utils/desktopdb.mk</code>.</p></li>
8457: <li><p>Check the PLIST and remove the entry that refers to the
8458: <code class="filename">share/applications/mimeinfo.cache</code> file.
8459: It will be handled automatically.</p></li>
8460: </ol></div>
8461: <p>The best way to verify that the PLIST is correct with
8462: respect to the last point is to regenerate it using <span><strong class="command">make
8463: print-PLIST</strong></span>.</p>
1.75 rillig 8464: </div>
8465: </div>
1.87 wiz 8466: <div class="sect1" lang="en">
8467: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8468: <a name="punting"></a>17.7. Marking packages as having problems</h2></div></div></div>
8469: <p>In some cases one does not have the time to solve a problem
8470: immediately. There are currently two ways to declare that one knows
8471: that a package has problems.</p>
8472: <div class="itemizedlist"><ul type="disc">
8473: <li><p>The first way is to plainly mark it as broken. For
8474: this, one just sets the variable <code class="varname">BROKEN</code> to the
8475: reason why the package is broken (similar to the
8476: <code class="varname">RESTRICTED</code> variable). A user trying to build
8477: the package will immediately be shown this message, and the build
8478: will not be even tried.</p></li>
8479: <li><p>After each pkgsrc freeze period (a time when the
8480: tree is stabilized and a new pkgsrc branch is cut), the packages
8481: that were not building in the official branch build on the latest
8482: NetBSD release will be marked as broken on that branch. This is
8483: done by setting the <code class="varname">BROKEN_IN</code> variable to the
8484: branch name (or appending the branch name to it). If a user tries
8485: to build such a package and the build fails, the user gets a
8486: message that says that the package was broken on the respective
8487: branch(es).</p></li>
8488: </ul></div>
8489: <p>Both types of packages are removed from pkgsrc in irregular
8490: intervals.</p>
8491: </div>
1.75 rillig 8492: </div>
8493: <div class="chapter" lang="en">
8494: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8495: <a name="debug"></a>Chapter 18. Debugging</h2></div></div></div>
1.88 ! wiz 8496: <p>To check out all the gotchas when building a package, here are
! 8497: the steps that I do in order to get a package working. Please note
! 8498: this is basically the same as what was explained in the previous
! 8499: sections, only with some debugging aids.</p>
1.75 rillig 8500: <div class="itemizedlist"><ul type="disc">
1.88 ! wiz 8501: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=1</code> in
! 8502: <code class="filename">/etc/mk.conf</code></p></li>
1.75 rillig 8503: <li>
1.76 rillig 8504: <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.88 ! wiz 8505: create a directory for a new package, change into it, then run
! 8506: <span><strong class="command">url2pkg</strong></span>:</p>
1.75 rillig 8507: <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>
8508: <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>
8509: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
8510: </li>
1.76 rillig 8511: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
8512: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.87 wiz 8513: <li><p>Run <span><strong class="command">make configure</strong></span></p></li>
1.75 rillig 8514: <li><p>Add any dependencies glimpsed from documentation and the
1.88 ! wiz 8515: configure step to the package's
! 8516: <code class="filename">Makefile</code>.</p></li>
1.75 rillig 8517: <li>
8518: <p>Make the package compile, doing multiple rounds of</p>
8519: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
8520: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
8521: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
8522: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
8523: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
8524: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
8525: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
1.88 ! wiz 8526: <p>Doing this step as non-root user will ensure that no files
! 8527: are modified that shouldn't be, especially during the build
! 8528: phase. <span><strong class="command">mkpatches</strong></span>,
! 8529: <span><strong class="command">patchdiff</strong></span> and <span><strong class="command">pkgvi</strong></span> are
! 8530: 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>
! 8531: package.</p>
1.75 rillig 8532: </li>
1.88 ! wiz 8533: <li><p>Look at the <code class="filename">Makefile</code>, fix if
! 8534: necessary; see <a href="#components.Makefile" title="9.1. Makefile">Section 9.1, “<code class="filename">Makefile</code>”</a>.</p></li>
1.75 rillig 8535: <li>
1.76 rillig 8536: <p>Generate a <code class="filename">PLIST</code>:</p>
1.75 rillig 8537: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
8538: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST >PLIST</code></strong>
8539: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
8540: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
8541: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
1.88 ! wiz 8542: <p>You usually need to be <code class="username">root</code> to do
! 8543: this. Look if there are any files left:</p>
1.75 rillig 8544: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
8545: <p>If this reveals any files that are missing in
1.88 ! wiz 8546: <code class="filename">PLIST</code>, add them.</p>
1.75 rillig 8547: </li>
8548: <li>
1.88 ! wiz 8549: <p>Now that the <code class="filename">PLIST</code> is OK, install the
! 8550: package again and make a binary package:</p>
1.75 rillig 8551: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
8552: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
8553: </li>
8554: <li>
8555: <p>Delete the installed package:</p>
1.88 ! wiz 8556: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete <em class="replaceable"><code>examplepkg</code></em></code></strong></pre>
1.75 rillig 8557: </li>
8558: <li>
1.88 ! wiz 8559: <p>Repeat the above <span><strong class="command">make print-PLIST</strong></span>
! 8560: command, which shouldn't find anything now:</p>
1.75 rillig 8561: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
8562: </li>
8563: <li>
8564: <p>Reinstall the binary package:</p>
1.88 ! wiz 8565: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkgadd .../<em class="replaceable"><code>examplepkg</code></em>.tgz</code></strong></pre>
1.75 rillig 8566: </li>
1.88 ! wiz 8567: <li><p>Play with it. Make sure everything works.</p></li>
1.75 rillig 8568: <li>
1.88 ! wiz 8569: <p>Run <span><strong class="command">pkglint</strong></span> from <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>, and fix the problems it
! 8570: reports:</p>
1.75 rillig 8571: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
8572: </li>
1.88 ! wiz 8573: <li><p>Submit (or commit, if you have cvs access); see <a href="#submit" title="Chapter 19. Submitting and Committing">Chapter 19, <i>Submitting and Committing</i></a>.</p></li>
1.75 rillig 8574: </ul></div>
8575: </div>
8576: <div class="chapter" lang="en">
8577: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8578: <a name="submit"></a>Chapter 19. Submitting and Committing</h2></div></div></div>
1.75 rillig 8579: <div class="toc">
8580: <p><b>Table of Contents</b></p>
8581: <dl>
1.77 rillig 8582: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
8583: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
8584: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
8585: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
8586: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
8587: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 8588: </dl>
8589: </div>
8590: <div class="sect1" lang="en">
8591: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8592: <a name="submitting-binary-packages"></a>19.1. Submitting binary packages</h2></div></div></div>
1.75 rillig 8593: <p>Our policy is that we accept binaries only from pkgsrc
8594: developers to guarantee that the packages don't contain any
8595: trojan horses etc. This is not to annoy anyone but rather to
8596: protect our users! You're still free to put up your home-made
8597: binary packages and tell the world where to get them. NetBSD
8598: developers doing bulk builds and wanting to upload them please
8599: 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>
8600: </div>
8601: <div class="sect1" lang="en">
8602: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8603: <a name="submitting-your-package"></a>19.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
1.75 rillig 8604: <p>First, check that your package is complete, compiles and
1.77 rillig 8605: runs well; see <a href="#debug" title="Chapter 18. Debugging">Chapter 18, <i>Debugging</i></a> and the rest of this
1.75 rillig 8606: 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 8607: archive that contains all files that make up the package.
1.87 wiz 8608: Finally, send this package to the pkgsrc bug tracking system,
8609: either with the <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> command, or if you don't have
8610: that, go to the web page
8611: <a href="http://www.NetBSD.org/Misc/send-pr.html" target="_top">http://www.NetBSD.org/Misc/send-pr.html</a>,
8612: which contains some instructions and a link to a form, where you
8613: can submit packages.</p>
8614: <p>In the form of the problem report, the category should be
8615: “<span class="quote">pkg</span>”, the synopsis should include the package name
8616: and version number, and the description field should contain a
8617: short description of your package (contents of the COMMENT
8618: variable or DESCR file are OK). The uuencoded package data should
8619: go into the “<span class="quote">fix</span>” field.</p>
1.75 rillig 8620: <p>If you want to submit several packages, please send a
8621: separate PR for each one, it's easier for us to track things
8622: that way.</p>
8623: <p>Alternatively, you can also import new packages into
8624: pkgsrc-wip (“<span class="quote">pkgsrc work-in-progress</span>”); see the
8625: homepage at <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
8626: for details.</p>
8627: </div>
8628: <div class="sect1" lang="en">
8629: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8630: <a name="general-notes-for-changes"></a>19.3. General notes when adding, updating, or removing packages</h2></div></div></div>
1.75 rillig 8631: <p>Please note all package additions, updates, moves, and
1.76 rillig 8632: removals in <code class="filename">pkgsrc/doc/CHANGES</code>. It's very
1.75 rillig 8633: important to keep this file up to date and conforming to the
8634: existing format, because it will be used by scripts to
8635: automatically update pages on <a href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
8636: sites. Additionally, check the
1.76 rillig 8637: <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
1.75 rillig 8638: for the package you updated or removed, in case it was mentioned
8639: there.</p>
8640: <p>When the <code class="varname">PKGREVISION</code> of a package is
8641: bumped, the change should appear in
1.76 rillig 8642: <code class="filename">pkgsrc/doc/CHANGES</code> if it is security
1.75 rillig 8643: related or otherwise relevant. Mass bumps that result from a
8644: dependency being updated should not be mentioned. In all other
8645: cases it's the developer's decision.</p>
8646: <p>There is a make target that helps in creating proper
1.76 rillig 8647: <code class="filename">CHANGES</code> entries: <span><strong class="command">make
1.75 rillig 8648: changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
8649: and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
1.76 rillig 8650: usage is to first make sure that your <code class="filename">CHANGES</code>
1.75 rillig 8651: file is up-to-date (to avoid having to resolve conflicts later-on)
8652: and then to <span><strong class="command">cd</strong></span> to the package directory. For
8653: package updates, <span><strong class="command">make changes-entry</strong></span> is enough.
8654: For new packages, or package moves or removals, set the
8655: <code class="varname">CTYPE</code> variable on the command line to "Added",
8656: "Moved", or "Removed". You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.76 rillig 8657: in <code class="filename">/etc/mk.conf</code> if your local login name is
1.75 rillig 8658: not the same as your NetBSD login name. Don't forget to commit
1.76 rillig 8659: the changes to <code class="filename">pkgsrc/doc/CHANGES</code>!</p>
1.75 rillig 8660: </div>
8661: <div class="sect1" lang="en">
8662: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8663: <a name="committing-importing"></a>19.4. Committing: Importing a package into CVS</h2></div></div></div>
1.87 wiz 8664: <p>This section is only of interest for pkgsrc developers with write
1.75 rillig 8665: access to the pkgsrc repository. Please remember that cvs
8666: imports files relative to the current working directory, and that
8667: the pathname that you
8668: give the <span><strong class="command">cvs import</strong></span> command is so that it knows where
8669: to place the files in the repository. Newly created packages should be
8670: imported with a vendor tag of “<span class="quote">TNF</span>” and a release tag of
1.87 wiz 8671: “<span class="quote">pkgsrc-base</span>”, e.g:</p>
1.75 rillig 8672: <pre class="programlisting">
8673: <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
8674: <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
8675: </pre>
1.87 wiz 8676: <p>Remember to move the directory from which you imported out of
1.75 rillig 8677: the way, or cvs will complain the next time you “<span class="quote">cvs
8678: update</span>” your source tree. Also don't forget to add the new
1.87 wiz 8679: package to the category's <code class="filename">Makefile</code>.</p>
8680: <p>The commit message of the initial import should include part of the
1.76 rillig 8681: <code class="filename">DESCR</code> file, so people reading the mailing lists know
1.87 wiz 8682: what the package is/does.</p>
8683: <p>For new packages, “<span class="quote">cvs import</span>” is preferred to “<span class="quote">cvs
1.75 rillig 8684: add</span>” because the former gets everything with a single command,
1.87 wiz 8685: and provides a consistent tag.</p>
1.75 rillig 8686: </div>
8687: <div class="sect1" lang="en">
8688: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8689: <a name="updating-package"></a>19.5. Updating a package to a newer version</h2></div></div></div>
1.87 wiz 8690: <p>Please always put a concise, appropriate and relevant summary of the
1.75 rillig 8691: changes between old and new versions into the commit log when updating
1.87 wiz 8692: a package. There are various reasons for this:</p>
1.75 rillig 8693: <div class="itemizedlist"><ul type="disc">
1.87 wiz 8694: <li><p>A URL is volatile, and can change over time. It may go away completely
8695: or its information may be overwritten by newer information.</p></li>
8696: <li><p>Having the change information between old and new versions in our CVS
8697: repository is very useful for people who use either cvs or anoncvs.</p></li>
8698: <li><p>Having the change information between old and new versions in our CVS
1.75 rillig 8699: repository is very useful for people who read the pkgsrc-changes mailing
8700: list, so that they can make tactical decisions about when to upgrade
1.87 wiz 8701: the package.</p></li>
1.75 rillig 8702: </ul></div>
1.87 wiz 8703: <p>Please also recognize that, just because a new version of a package
1.75 rillig 8704: has been released, it should not automatically be upgraded in the CVS
8705: repository. We prefer to be conservative in the packages that are
8706: included in pkgsrc - development or beta packages are not really the
8707: best thing for most places in which pkgsrc is used. Please use your
8708: judgement about what should go into pkgsrc, and bear in mind that
1.87 wiz 8709: stability is to be preferred above new and possibly untested features.</p>
1.75 rillig 8710: </div>
8711: <div class="sect1" lang="en">
8712: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8713: <a name="moving-package"></a>19.6. Moving a package in pkgsrc</h2></div></div></div>
1.75 rillig 8714: <div class="orderedlist"><ol type="1">
8715: <li><p>Make a copy of the directory somewhere else.</p></li>
8716: <li>
8717: <p>Remove all CVS dirs.</p>
1.87 wiz 8718: <p>Alternatively to the first two steps you can also do:</p>
1.75 rillig 8719: <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>
1.87 wiz 8720: <p>and use that for further work.</p>
1.75 rillig 8721: </li>
8722: <li><p>Fix <code class="varname">CATEGORIES</code> and any
8723: <code class="varname">DEPENDS</code> paths that just did “<span class="quote">../package</span>”
8724: instead of “<span class="quote">../../category/package</span>”.</p></li>
8725: <li><p><span><strong class="command">cvs import</strong></span> the modified package in the new
8726: place.</p></li>
8727: <li>
8728: <p>Check if any package depends on it:
8729: </p>
8730: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
8731: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
8732: </li>
8733: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
8734: <li><p><span><strong class="command">cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.76 rillig 8735: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
8736: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
1.75 rillig 8737: <li>
8738: <p>Commit the changed and removed files:</p>
8739: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong></pre>
1.87 wiz 8740: <p>(and any packages from step 5, of course).</p>
1.75 rillig 8741: </li>
8742: </ol></div>
8743: </div>
8744: </div>
8745: <div class="chapter" lang="en">
8746: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8747: <a name="devfaq"></a>Chapter 20. Frequently Asked Questions</h2></div></div></div>
1.75 rillig 8748: <p>This section contains the answers to questions that may
8749: arise when you are writing a package. If you don't find your
8750: question answered here, first have a look in the other chapters,
8751: and if you still don't have the answer, ask on the
8752: <code class="literal">pkgsrc-users</code> mailing list.</p>
8753: <div class="qandaset">
8754: <dl>
1.88 ! wiz 8755: <dt>20.1. <a href="#id2699778">What is the difference between
1.75 rillig 8756: MAKEFLAGS, .MAKEFLAGS and
8757: MAKE_FLAGS?</a>
8758: </dt>
1.88 ! wiz 8759: <dt>20.2. <a href="#id2699814">What is the difference between
1.75 rillig 8760: MAKE, GMAKE and
8761: MAKE_PROGRAM?</a>
8762: </dt>
1.88 ! wiz 8763: <dt>20.3. <a href="#id2699852">What is the difference between
1.75 rillig 8764: CC, PKG_CC and
8765: PKGSRC_COMPILER?</a>
8766: </dt>
1.88 ! wiz 8767: <dt>20.4. <a href="#id2699890">What is the difference between
1.75 rillig 8768: BUILDLINK_LDFLAGS,
8769: BUILDLINK_LDADD and
8770: BUILDLINK_LIBS?</a>
8771: </dt>
1.88 ! wiz 8772: <dt>20.5. <a href="#id2699908">Why does make show-var
1.75 rillig 8773: VARNAME=BUILDLINK_PREFIX.foo
8774: say it's empty?</a>
8775: </dt>
1.88 ! wiz 8776: <dt>20.6. <a href="#id2699936">What does
1.78 rillig 8777: ${MASTER_SITE_SOURCEFORGE:=package/} mean? I
8778: don't understand the := inside
8779: it.</a>
8780: </dt>
1.88 ! wiz 8781: <dt>20.7. <a href="#id2700078">Which mailing lists are there for package
1.78 rillig 8782: developers?</a>
8783: </dt>
1.88 ! wiz 8784: <dt>20.8. <a href="#id2700115">Where is the pkgsrc
1.80 rillig 8785: documentation?</a>
8786: </dt>
1.75 rillig 8787: </dl>
8788: <table border="0" summary="Q and A Set">
8789: <col align="left" width="1%">
8790: <tbody>
8791: <tr class="question">
8792: <td align="left" valign="top">
1.88 ! wiz 8793: <a name="id2699778"></a><a name="id2699779"></a><b>20.1.</b>
1.75 rillig 8794: </td>
8795: <td align="left" valign="top"><p>What is the difference between
8796: <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
8797: <code class="varname">MAKE_FLAGS</code>?</p></td>
8798: </tr>
8799: <tr class="answer">
1.83 wiz 8800: <td align="left" valign="top"></td>
1.75 rillig 8801: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
8802: 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
8803: <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
8804: the <code class="varname">MAKE_PROGRAM</code> when building the
8805: package. [FIXME: What is .MAKEFLAGS for?]</p></td>
8806: </tr>
8807: <tr class="question">
8808: <td align="left" valign="top">
1.88 ! wiz 8809: <a name="id2699814"></a><a name="id2699815"></a><b>20.2.</b>
1.75 rillig 8810: </td>
8811: <td align="left" valign="top"><p>What is the difference between
8812: <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
8813: <code class="varname">MAKE_PROGRAM</code>?</p></td>
8814: </tr>
8815: <tr class="answer">
1.83 wiz 8816: <td align="left" valign="top"></td>
1.75 rillig 8817: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
8818: <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
8819: infrastructure. <code class="varname">GMAKE</code> is the path to GNU
8820: Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
8821: use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
8822: Make program that is used for building the
8823: package.</p></td>
8824: </tr>
8825: <tr class="question">
8826: <td align="left" valign="top">
1.88 ! wiz 8827: <a name="id2699852"></a><a name="id2699853"></a><b>20.3.</b>
1.75 rillig 8828: </td>
8829: <td align="left" valign="top"><p>What is the difference between
8830: <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
8831: <code class="varname">PKGSRC_COMPILER</code>?</p></td>
8832: </tr>
8833: <tr class="answer">
1.83 wiz 8834: <td align="left" valign="top"></td>
1.75 rillig 8835: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
8836: compiler, which can be configured by the pkgsrc user.
8837: <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
8838: <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
8839: path to a compiler, but the type of compiler that should be
1.76 rillig 8840: used. See <code class="filename">mk/compiler.mk</code> for more
1.75 rillig 8841: information about the latter variable.</p></td>
8842: </tr>
8843: <tr class="question">
8844: <td align="left" valign="top">
1.88 ! wiz 8845: <a name="id2699890"></a><a name="id2699891"></a><b>20.4.</b>
1.75 rillig 8846: </td>
8847: <td align="left" valign="top"><p>What is the difference between
8848: <code class="varname">BUILDLINK_LDFLAGS</code>,
8849: <code class="varname">BUILDLINK_LDADD</code> and
8850: <code class="varname">BUILDLINK_LIBS</code>?</p></td>
8851: </tr>
8852: <tr class="answer">
1.83 wiz 8853: <td align="left" valign="top"></td>
1.75 rillig 8854: <td align="left" valign="top"><p>[FIXME]</p></td>
8855: </tr>
8856: <tr class="question">
8857: <td align="left" valign="top">
1.88 ! wiz 8858: <a name="id2699908"></a><a name="id2699909"></a><b>20.5.</b>
1.75 rillig 8859: </td>
8860: <td align="left" valign="top"><p>Why does <span><strong class="command">make show-var
8861: VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
8862: say it's empty?</p></td>
8863: </tr>
8864: <tr class="answer">
1.83 wiz 8865: <td align="left" valign="top"></td>
1.75 rillig 8866: <td align="left" valign="top"><p>For optimization reasons, some variables are only
8867: available in the “<span class="quote">wrapper</span>” phase and later. To
8868: “<span class="quote">simulate</span>” the wrapper phase, append
8869: <span><strong class="command">PKG_PHASE=wrapper</strong></span> to the above
8870: command.</p></td>
8871: </tr>
1.78 rillig 8872: <tr class="question">
8873: <td align="left" valign="top">
1.88 ! wiz 8874: <a name="id2699936"></a><a name="id2699937"></a><b>20.6.</b>
1.78 rillig 8875: </td>
8876: <td align="left" valign="top"><p>What does
8877: <code class="literal">${MASTER_SITE_SOURCEFORGE:=package/}</code> mean? I
8878: don't understand the <code class="literal">:=</code> inside
8879: it.</p></td>
8880: </tr>
8881: <tr class="answer">
1.83 wiz 8882: <td align="left" valign="top"></td>
1.78 rillig 8883: <td align="left" valign="top"><p>The <code class="literal">:=</code> is not really an
8884: assignment operator, like you might expect at first sight.
8885: Instead, it is a degenerate form of
8886: <code class="literal">${LIST:<em class="replaceable"><code>old_string</code></em>=<em class="replaceable"><code>new_string</code></em>}</code>,
8887: 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
8888: may have seen as in <code class="literal">${SRCS:.c=.o}</code>. In the
8889: case of <code class="varname">MASTER_SITE_*</code>,
8890: <em class="replaceable"><code>old_string</code></em> is the empty string and
8891: <em class="replaceable"><code>new_string</code></em> is
8892: <code class="literal">package/</code>. That's where the
8893: <code class="literal">:</code> and the <code class="literal">=</code> fall
8894: together.</p></td>
8895: </tr>
8896: <tr class="question">
8897: <td align="left" valign="top">
1.88 ! wiz 8898: <a name="id2700078"></a><a name="id2700080"></a><b>20.7.</b>
1.78 rillig 8899: </td>
8900: <td align="left" valign="top"><p>Which mailing lists are there for package
8901: developers?</p></td>
8902: </tr>
8903: <tr class="answer">
1.83 wiz 8904: <td align="left" valign="top"></td>
1.78 rillig 8905: <td align="left" valign="top"><div class="variablelist"><dl>
8906: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">tech-pkg</a></span></dt>
8907: <dd><p>This is a list for technical discussions related
8908: to pkgsrc development, e.g. soliciting feedback for changes to
8909: pkgsrc infrastructure, proposed new features, questions related
8910: to porting pkgsrc to a new platform, advice for maintaining a
8911: package, patches that affect many packages, help requests moved
8912: from pkgsrc-users when an infrastructure bug is found,
8913: etc.</p></dd>
8914: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a></span></dt>
8915: <dd><p>All bug reports in category "pkg" sent with
8916: <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
8917: directly; use one of the other mailing
8918: lists.</p></dd>
8919: </dl></div></td>
8920: </tr>
1.80 rillig 8921: <tr class="question">
8922: <td align="left" valign="top">
1.88 ! wiz 8923: <a name="id2700115"></a><a name="id2700116"></a><b>20.8.</b>
1.80 rillig 8924: </td>
8925: <td align="left" valign="top"><p>Where is the pkgsrc
8926: documentation?</p></td>
8927: </tr>
8928: <tr class="answer">
1.83 wiz 8929: <td align="left" valign="top"></td>
1.80 rillig 8930: <td align="left" valign="top">
8931: <p>There are many places where you can find
8932: documentation about pkgsrc:</p>
8933: <div class="itemizedlist"><ul type="disc">
8934: <li><p>The pkgsrc guide (this document) is a collection
8935: of chapters that explain large parts of pkgsrc, but some
8936: chapters tend to be outdated. Which ones they are is hard to
8937: say.</p></li>
8938: <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
8939: about certain features, announcements of new parts of the pkgsrc
8940: infrastructure and sometimes even announcements that a certain
8941: feature has been marked as obsolete. The benefit here is that
8942: each message has a date appended to it.</p></li>
8943: <li><p>Many of the files in the
8944: <code class="filename">mk/</code> directory start with a comment that
8945: describes the purpose of the file and how it can be used by the
8946: pkgsrc user and package authors.</p></li>
8947: <li><p>The CVS log messages are a rich source of
8948: information, but they tend to be highly abbreviated, especially
8949: for actions that occur often. Some contain a detailed
8950: description of what has changed, but they are geared towards the
8951: other pkgsrc developers, not towards an average pkgsrc user.
8952: They also only document <span class="emphasis"><em>changes</em></span>, so if you
8953: don't know what has been before, these messages may not be worth
8954: too much to you.</p></li>
8955: <li><p>Some parts of pkgsrc are only “<span class="quote">implicitly
8956: documented</span>”, that is the documentation exists only in the
8957: mind of the developer who wrote the code. To get this
8958: information, use the the <span><strong class="command">cvs annotate</strong></span> command
8959: to see who has written it and ask on the
8960: <code class="literal">tech-pkg</code> mailing list, so that others can
8961: find your questions later (see above). To be sure that the
8962: developer in charge reads the mail, you may CC him or
8963: her.</p></li>
8964: </ul></div>
8965: </td>
8966: </tr>
1.75 rillig 8967: </tbody>
8968: </table>
8969: </div>
8970: </div>
1.85 jmmv 8971: <div class="chapter" lang="en">
8972: <div class="titlepage"><div><div><h2 class="title">
8973: <a name="gnome"></a>Chapter 21. GNOME packaging and porting</h2></div></div></div>
8974: <div class="toc">
8975: <p><b>Table of Contents</b></p>
8976: <dl>
8977: <dt><span class="sect1"><a href="#meta-packages">21.1. Meta packages</a></span></dt>
8978: <dt><span class="sect1"><a href="#new-package">21.2. Packaging a GNOME application</a></span></dt>
8979: <dt><span class="sect1"><a href="#full-update">21.3. Updating GNOME to a newer version</a></span></dt>
8980: <dt><span class="sect1"><a href="#patching">21.4. Patching guidelines</a></span></dt>
8981: </dl>
8982: </div>
8983: <p>Quoting <a href="http://www.gnome.org/" target="_top">GNOME's web
8984: site</a>:</p>
8985: <div class="blockquote"><blockquote class="blockquote"><p>The GNOME project provides two things: The GNOME desktop
8986: environment, an intuitive and attractive desktop for users, and the
8987: GNOME development platform, an extensive framework for building
8988: applications that integrate into the rest of the desktop.</p></blockquote></div>
8989: <p>pkgsrc provides a seamless way to automatically build and install
8990: a complete GNOME environment <span class="emphasis"><em>under many different
8991: platforms</em></span>. We can say with confidence that pkgsrc is one of
8992: the most advanced build and packaging systems for GNOME due to its
8993: included technologies buildlink3, the wrappers and tools framework and
8994: automatic configuration file management. Lots of efforts are put into
8995: achieving a completely clean deinstallation of installed software
8996: components.</p>
8997: <p>Given that pkgsrc is <a href="http://www.NetBSD.org/" target="_top">NetBSD</a>'s official packaging system,
8998: the above also means that great efforts are put into making GNOME work
8999: under this operating system. Recently, <a href="http://www.dragonflybsd.org/" target="_top">DragonFly BSD</a> also adopted
9000: pkgsrc as its preferred packaging system, contributing lots of
9001: portability fixes to make GNOME build and install under it.</p>
9002: <p>This chapter is aimed at pkgsrc developers and other people
9003: interested in helping our GNOME porting and packaging efforts. It
9004: provides instructions on how to manage the existing packages and some
9005: important information regarding their internals.</p>
9006: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
9007: <h3 class="title">We need your help!</h3>
9008: <p>Should you have some spare cycles to devote to NetBSD, pkgsrc
9009: and GNOME and are willing to learn new exciting stuff, please jump
9010: straight to the <a href="http://www.NetBSD.org/contrib/projects.html#gnome" target="_top">pending
9011: work</a> list! There is still a long way to go to get a
9012: fully-functional GNOME desktop under NetBSD and we need your help to
9013: achieve it!</p>
9014: </div>
9015: <div class="sect1" lang="en">
9016: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9017: <a name="meta-packages"></a>21.1. Meta packages</h2></div></div></div>
9018: <p>pkgsrc includes three GNOME-related meta packages:</p>
9019: <div class="itemizedlist"><ul type="disc">
9020: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome-base/README.html" target="_top"><code class="filename">meta-pkgs/gnome-base</code></a>: Provides
9021: the core GNOME desktop environment. It only includes the necessary
9022: bits to get it to boot correctly, although it may lack important
9023: functionality for daily operation. The idea behind this package is
9024: to let end users build their own configurations on top of this one,
9025: first installing this meta package to achieve a functional setup and
9026: then adding individual applications.</p></li>
9027: <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>: Provides a
9028: complete installation of the GNOME platform and desktop as defined
9029: by the GNOME project; this is based on the components distributed in
9030: the <code class="filename">platform/x.y/x.y.z/sources</code> and
9031: <code class="filename">desktop/x.y/x.y.z/sources</code> directories of the
9032: official FTP server. Developer-only tools found in those
9033: directories are not installed unless required by some other
9034: component to work properly. Similarly, packages from the bindings
9035: set (<code class="filename">bindings/x.y/x.y.z/sources</code>) are not pulled
9036: in unless required as a dependency for an end-user component. This
9037: package "extends" <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome-base/README.html" target="_top"><code class="filename">meta-pkgs/gnome-base</code></a>.</p></li>
9038: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome-devel/README.html" target="_top"><code class="filename">meta-pkgs/gnome-devel</code></a>:
9039: Installs all the tools required to build a GNOME component when
9040: fetched from the CVS repository. These are required to let the
9041: <span><strong class="command">autogen.sh</strong></span> scripts work appropriately.</p></li>
9042: </ul></div>
9043: <p>In all these packages, the <code class="varname">DEPENDS</code> lines are
9044: sorted in a way that eases updates: a package may depend on other
9045: packages listed before it but not on any listed after it. It is very
9046: important to keep this order to ease updates so... <span class="emphasis"><em>do not
9047: change it to alphabetical sorting!</em></span></p>
9048: </div>
9049: <div class="sect1" lang="en">
9050: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9051: <a name="new-package"></a>21.2. Packaging a GNOME application</h2></div></div></div>
9052: <p>Almost all GNOME applications are written in C and use a common
9053: set of tools as their build system. Things get different with the new
9054: bindings to other languages (such as Python), but the following will
9055: give you a general idea on the minimum required tools:</p>
9056: <div class="itemizedlist"><ul type="disc">
9057: <li>
9058: <p>Almost all GNOME applications use the GNU Autotools as their
9059: build system. As a general rule you will need to tell this to your
9060: package:</p>
9061: <pre class="programlisting">GNU_CONFIGURE=yes
9062: USE_LIBTOOL=yes
9063: USE_TOOLS+=gmake</pre>
9064: </li>
9065: <li>
9066: <p>If the package uses pkg-config to detect dependencies, add this
9067: tool to the list of required utilities:</p>
9068: <pre class="programlisting">USE_TOOLS+=pkg-config</pre>
9069: <p>Also use <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/verifypc/README.html" target="_top"><code class="filename">pkgtools/verifypc</code></a> at
9070: the end of the build process to ensure that you did not miss to
9071: specify any dependency in your package and that the version
9072: requirements are all correct.</p>
9073: </li>
9074: <li><p>If the package uses intltool, be sure to include the <a href="http://cvsweb.NetBSD.org/bsdweb.cgi/pkgsrc/textproc/intltool/buildlink3.mk?rev=HEAD&content-type=text/x-cvsweb-markup" target="_top"><code class="filename">pkgsrc/textproc/intltool/buildlink3.mk</code></a> file
9075: to handle dependencies and to force the package to use the latest
9076: available version.</p></li>
9077: <li>
9078: <p>If the package uses gtk-doc (a documentation generation
9079: utility), do <span class="emphasis"><em>not</em></span> add a dependency on it. The
9080: tool is rather big and the distfile should come with pregenerated
9081: documentation anyway; if it does not, it is a bug that you ought to
9082: report. For such packages you should disable gtk-doc (unless it is
9083: the default) and change the location of installed HTML files:</p>
9084: <pre class="programlisting">CONFIGURE_ARGS+=--disable-gtk-doc
9085: CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/doc</pre>
9086: </li>
9087: </ul></div>
9088: <p>GNOME uses multiple <span class="emphasis"><em>shared</em></span> directories and
9089: files under the installation prefix to maintain databases. In this
9090: context, shared means that those exact same directories and files are
9091: used among several different packages, leading to conflicts in the
9092: <code class="filename">PLIST</code>. pkgsrc currently includes functionality to
9093: handle the most common cases, so you have to forget about using
9094: <code class="literal">@unexec ${RMDIR}</code> lines in your file lists and
9095: omitting shared files from them. If you find yourself doing those,
9096: <span class="emphasis"><em>your package is most likely incorrect</em></span>.</p>
9097: <p>The following table lists the common situations that result in
9098: using shared directories or files. For each of them, the appropriate
9099: solution is given. After applying the solution be sure to
9100: <span class="emphasis"><em>regenerate the package's file list</em></span> with
9101: <span><strong class="command">make print-PLIST</strong></span> and ensure it is correct.</p>
9102: <div class="table">
9103: <a name="plist-handling"></a><p class="title"><b>Table 21.1. PLIST handling for GNOME packages</b></p>
9104: <div class="table-contents"><table summary="PLIST handling for GNOME packages" border="1">
9105: <colgroup>
9106: <col>
9107: <col>
9108: </colgroup>
9109: <thead><tr>
9110: <th>If the package...</th>
9111: <th>Then...</th>
9112: </tr></thead>
9113: <tbody>
9114: <tr>
9115: <td>Installs OMF files under <code class="filename">share/omf</code>.</td>
1.87 wiz 9116: <td>See <a href="#scrollkeeper-data-files" title="17.6.9. Packages installing scrollkeeper data files">Section 17.6.9, “Packages installing scrollkeeper data files”</a>.</td>
1.85 jmmv 9117: </tr>
9118: <tr>
9119: <td>Installs icons under the
9120: <code class="filename">share/icons/hicolor</code> hierarchy or updates
9121: <code class="filename">share/icons/hicolor/icon-theme.cache</code>.</td>
1.87 wiz 9122: <td>See <a href="#hicolor-theme" title="17.6.18. Packages installing hicolor theme icons">Section 17.6.18, “Packages installing hicolor theme icons”</a>.</td>
1.85 jmmv 9123: </tr>
9124: <tr>
9125: <td>Installs files under
9126: <code class="filename">share/mime/packages</code>.</td>
1.87 wiz 9127: <td>See <a href="#mime-database" title="17.6.13. Packages installing extensions to the MIME database">Section 17.6.13, “Packages installing extensions to the MIME database”</a>.</td>
1.85 jmmv 9128: </tr>
9129: <tr>
9130: <td>Installs <code class="filename">.desktop</code> files under
9131: <code class="filename">share/applications</code> and these include MIME
9132: information.</td>
1.87 wiz 9133: <td>See <a href="#desktop-files" title="17.6.19. Packages installing desktop files">Section 17.6.19, “Packages installing desktop files”</a>.</td>
1.85 jmmv 9134: </tr>
9135: </tbody>
9136: </table></div>
9137: </div>
9138: <br class="table-break">
9139: </div>
9140: <div class="sect1" lang="en">
9141: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9142: <a name="full-update"></a>21.3. Updating GNOME to a newer version</h2></div></div></div>
9143: <p>When seeing GNOME as a whole, there are two kinds of
9144: updates:</p>
9145: <div class="variablelist"><dl>
9146: <dt><span class="term">Major update</span></dt>
9147: <dd>
9148: <p>Given that there is still a very long way for GNOME 3 (if it
9149: ever appears), we consider a major update one that goes from a
9150: <code class="literal">2.X</code> version to a <code class="literal">2.Y</code> one,
9151: where <code class="literal">Y</code> is even and greater than
9152: <code class="literal">X</code>. These are hard to achieve because they
9153: introduce lots of changes in the components' code and almost all
9154: GNOME distfiles are updated to newer versions. Some of them can
9155: even break API and ABI compatibility with the previous major
9156: version series. As a result, the update needs to be done all at
9157: once to minimize breakage.</p>
9158: <p>A major update typically consists of around 80 package
9159: updates and the addition of some new ones.</p>
9160: </dd>
9161: <dt><span class="term">Minor update</span></dt>
9162: <dd>
9163: <p>We consider a minor update one that goes from a
9164: <code class="literal">2.A.X</code> version to a <code class="literal">2.A.Y</code>
9165: one where <code class="literal">Y</code> is greater than
9166: <code class="literal">X</code>. These are easy to achieve because they do
9167: not update all GNOME components, can be done in an incremental way
9168: and do not break API nor ABI compatibility.</p>
9169: <p>A minor update typically consists of around 50 package
9170: updates, although the numbers here may vary a lot.</p>
9171: </dd>
9172: </dl></div>
9173: <p>In order to update the GNOME components in pkgsrc to a new stable
9174: release (either major or minor), the following steps should be
9175: followed:</p>
9176: <div class="orderedlist"><ol type="1">
9177: <li>
9178: <p>Get a list of all the tarballs that form the new release by
9179: using the following commands. These will leave the full list of the
9180: components's distfiles into the <code class="filename">list.txt</code>
9181: file:</p>
1.88 ! wiz 9182: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>echo ls "*.tar.bz2" | \
1.85 jmmv 9183: ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
9184: awk '{ print $9 }' >list.txt</code></strong>
1.88 ! wiz 9185: <code class="prompt">%</code> <strong class="userinput"><code>echo ls "*.tar.bz2" | \
1.85 jmmv 9186: ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
9187: awk '{ print $9 }' >>list.txt</code></strong></pre>
9188: </li>
9189: <li><p>Open each meta package's <code class="filename">Makefile</code> and
9190: bump their version to the release you are updating them to. The
9191: three meta packages should be always consistent with versioning.
9192: Obviously remove any <code class="varname">PKGREVISION</code>s that might be
9193: in them.</p></li>
9194: <li>
9195: <p>For each meta package, update all its
9196: <code class="varname">DEPENDS</code> lines to match the latest versions as
9197: shown by the above commands. Do <span class="emphasis"><em>not</em></span> list any
9198: newer version (even if found in the FTP) because the meta packages
9199: are supposed to list the exact versions that form a specific GNOME
9200: release. Exceptions are permitted here if a newer version solves a
9201: serious issue in the overall desktop experience; these typically
9202: come in the form of a revision bump in pkgsrc, not in newer versions
9203: from the developers.</p>
9204: <p>Packages not listed in the <code class="filename">list.txt</code> file
9205: should be updated to the latest version available (if found in
9206: pkgsrc). This is the case, for example, of the dependencies on the
9207: GNU Autotools in the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome-devel/README.html" target="_top"><code class="filename">meta-pkgs/gnome-devel</code></a> meta package.</p>
9208: </li>
9209: <li>
9210: <p>Generate a patch from the modified meta packages and extract the
9211: list of "new" lines. This will provide you an outline on what
9212: packages need to be updated in pkgsrc and in what order:</p>
1.88 ! wiz 9213: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs diff gnome-devel gnome-base gnome | grep '^+D' >todo.txt</code></strong></pre>
1.85 jmmv 9214: </li>
9215: <li><p>For major desktop updates it is recommended to zap all your
9216: installed packages and start over from scratch at this point.</p></li>
9217: <li><p>Now comes the longest step by far: iterate over the contents
9218: of <code class="filename">todo.txt</code> and update the packages listed in
9219: it in order. For major desktop updates none of these should be
9220: commited until the entire set is completed because there are chances
9221: of breaking not-yet-updated packages.</p></li>
9222: <li><p>Once the packages are up to date and working, commit them to
9223: the tree one by one with appropriate log messages. At the end,
9224: commit the three meta package updates and all the corresponding
9225: changes to the <code class="filename">doc/CHANGES-<YEAR></code> and
9226: <a href="http://cvsweb.NetBSD.org/bsdweb.cgi/pkgsrc/doc/TODO?rev=HEAD&content-type=text/x-cvsweb-markup" target="_top"><code class="filename">pkgsrc/doc/TODO</code></a> files.</p></li>
9227: </ol></div>
9228: </div>
9229: <div class="sect1" lang="en">
9230: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9231: <a name="patching"></a>21.4. Patching guidelines</h2></div></div></div>
9232: <p>GNOME is a very big component in pkgsrc which approaches 100
9233: packages. Please, it is very important that you always, always,
9234: <span class="strong"><strong>always</strong></span> feed back any portability
9235: fixes you do to a GNOME package to the mainstream developers (see <a href="#components.patches.feedback" title="9.3.2. Feedback to the author">Section 9.3.2, “Feedback to the author”</a>). This is the only way to get
9236: their attention on portability issues and to ensure that future versions
9237: can be built out-of-the box on NetBSD. The less custom patches in
9238: pkgsrc, the easier further updates are. Those developers in charge of
9239: issuing major GNOME updates will be grateful if you do that.</p>
9240: <p>The most common places to report bugs are the <a href="http://bugzilla.gnome.org/" target="_top">GNOME's Bugzilla</a> and the <a href="http://bugzilla.freedesktop.org/" target="_top">freedesktop.org's
9241: Bugzilla</a>. Not all components use these to track bugs, but most
9242: of them do. Do not be short on your reports: always provide detailed
9243: explanations of the current failure, how it can be improved to achieve
9244: maximum portability and, if at all possible, provide a patch against CVS
9245: head. The more verbose you are, the higher chances of your patch being
9246: accepted.</p>
9247: <p>Also, please avoid using preprocessor magic to fix portability
9248: issues. While the FreeBSD GNOME people are doing a great job in porting
9249: GNOME to their operating system, the official GNOME sources are now
9250: plagued by conditionals that check for <code class="varname">__FreeBSD__</code>
9251: and similar macros. This hurts portability. Please see our patching
9252: guidelines (<a href="#components.patches.guidelines" title="9.3.1. Patching guidelines">Section 9.3.1, “Patching guidelines”</a>) for more
9253: details.</p>
9254: </div>
9255: </div>
1.75 rillig 9256: </div>
9257: <div class="part" lang="en">
9258: <div class="titlepage"><div><div><h1 class="title">
9259: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
9260: <div class="partintro" lang="en">
9261: <div></div>
9262: <p>This part of the guide deals with everything
9263: from the infrastructure that is behind the interfaces described
9264: in the developer's guide. A casual package maintainer should not
9265: need anything from this part.</p>
9266: <div class="toc">
9267: <p><b>Table of Contents</b></p>
9268: <dl>
1.85 jmmv 9269: <dt><span class="chapter"><a href="#infr.design">22. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 9270: <dd><dl>
1.85 jmmv 9271: <dt><span class="sect1"><a href="#infr.vardef">22.1. The meaning of variable definitions</a></span></dt>
9272: <dt><span class="sect1"><a href="#infr.vardef.problems">22.2. Avoiding problems before they arise</a></span></dt>
9273: <dt><span class="sect1"><a href="#infr.var">22.3. Variable evaluation</a></span></dt>
1.75 rillig 9274: <dd><dl>
1.85 jmmv 9275: <dt><span class="sect2"><a href="#infr.var.load">22.3.1. At load time</a></span></dt>
9276: <dt><span class="sect2"><a href="#infr.var.run">22.3.2. At runtime</a></span></dt>
1.75 rillig 9277: </dl></dd>
1.85 jmmv 9278: <dt><span class="sect1"><a href="#infr.varspec">22.4. How can variables be specified?</a></span></dt>
9279: <dt><span class="sect1"><a href="#infr.design.intf">22.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 9280: <dd><dl>
1.85 jmmv 9281: <dt><span class="sect2"><a href="#infr.design.intf.proc">22.5.1. Procedures with parameters</a></span></dt>
9282: <dt><span class="sect2"><a href="#infr.design.intf.action">22.5.2. Actions taken on behalf of parameters</a></span></dt>
1.81 rillig 9283: </dl></dd>
1.85 jmmv 9284: <dt><span class="sect1"><a href="#infr.order">22.6. The order in which files are loaded</a></span></dt>
1.81 rillig 9285: <dd><dl>
1.85 jmmv 9286: <dt><span class="sect2"><a href="#infr.order.prefs">22.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
9287: <dt><span class="sect2"><a href="#infr.order.pkg">22.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75 rillig 9288: </dl></dd>
9289: </dl></dd>
1.85 jmmv 9290: <dt><span class="chapter"><a href="#regression">23. Regression tests</a></span></dt>
1.75 rillig 9291: <dd><dl>
1.85 jmmv 9292: <dt><span class="sect1"><a href="#regression.descr">23.1. The regression tests framework</a></span></dt>
9293: <dt><span class="sect1"><a href="#regression.run">23.2. Running the regression tests</a></span></dt>
9294: <dt><span class="sect1"><a href="#regression.new">23.3. Adding a new regression test</a></span></dt>
1.75 rillig 9295: <dd><dl>
1.85 jmmv 9296: <dt><span class="sect2"><a href="#regression.fun.override">23.3.1. Overridable functions</a></span></dt>
9297: <dt><span class="sect2"><a href="#regression.fun.helper">23.3.2. Helper functions</a></span></dt>
1.75 rillig 9298: </dl></dd>
9299: </dl></dd>
1.85 jmmv 9300: <dt><span class="chapter"><a href="#porting">24. Porting pkgsrc</a></span></dt>
1.75 rillig 9301: <dd><dl>
1.85 jmmv 9302: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
9303: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 9304: </dl></dd>
9305: </dl>
9306: </div>
9307: </div>
9308: <div class="chapter" lang="en">
9309: <div class="titlepage"><div><div><h2 class="title">
1.85 jmmv 9310: <a name="infr.design"></a>Chapter 22. Design of the pkgsrc infrastructure</h2></div></div></div>
1.75 rillig 9311: <div class="toc">
9312: <p><b>Table of Contents</b></p>
9313: <dl>
1.85 jmmv 9314: <dt><span class="sect1"><a href="#infr.vardef">22.1. The meaning of variable definitions</a></span></dt>
9315: <dt><span class="sect1"><a href="#infr.vardef.problems">22.2. Avoiding problems before they arise</a></span></dt>
9316: <dt><span class="sect1"><a href="#infr.var">22.3. Variable evaluation</a></span></dt>
1.81 rillig 9317: <dd><dl>
1.85 jmmv 9318: <dt><span class="sect2"><a href="#infr.var.load">22.3.1. At load time</a></span></dt>
9319: <dt><span class="sect2"><a href="#infr.var.run">22.3.2. At runtime</a></span></dt>
1.81 rillig 9320: </dl></dd>
1.85 jmmv 9321: <dt><span class="sect1"><a href="#infr.varspec">22.4. How can variables be specified?</a></span></dt>
9322: <dt><span class="sect1"><a href="#infr.design.intf">22.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 9323: <dd><dl>
1.85 jmmv 9324: <dt><span class="sect2"><a href="#infr.design.intf.proc">22.5.1. Procedures with parameters</a></span></dt>
9325: <dt><span class="sect2"><a href="#infr.design.intf.action">22.5.2. Actions taken on behalf of parameters</a></span></dt>
1.75 rillig 9326: </dl></dd>
1.85 jmmv 9327: <dt><span class="sect1"><a href="#infr.order">22.6. The order in which files are loaded</a></span></dt>
1.75 rillig 9328: <dd><dl>
1.85 jmmv 9329: <dt><span class="sect2"><a href="#infr.order.prefs">22.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
9330: <dt><span class="sect2"><a href="#infr.order.pkg">22.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75 rillig 9331: </dl></dd>
9332: </dl>
9333: </div>
9334: <p>The pkgsrc infrastructure consists of many small Makefile
9335: fragments. Each such fragment needs a properly specified
9336: interface. This chapter explains how such an interface looks
9337: like.</p>
9338: <div class="sect1" lang="en">
9339: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9340: <a name="infr.vardef"></a>22.1. The meaning of variable definitions</h2></div></div></div>
1.81 rillig 9341: <p>Whenever a variable is defined in the pkgsrc
9342: infrastructure, the location and the way of definition provide
9343: much information about the intended use of that variable.
9344: Additionally, more documentation may be found in a header
9345: comment or in this pkgsrc guide.</p>
9346: <p>A special file is
9347: <code class="filename">mk/defaults/mk.conf</code>, which lists all
9348: variables that are intended to be user-defined. They are either
9349: defined using the <code class="literal">?=</code> operator or they are
9350: left undefined because defining them to anything would
9351: effectively mean “<span class="quote">yes</span>”. All these variables may be
9352: overridden by the pkgsrc user in the <code class="varname">MAKECONF</code>
9353: file.</p>
9354: <p>Outside this file, the following conventions apply:
9355: Variables that are defined using the <code class="literal">?=</code>
9356: operator may be overridden by a package.</p>
9357: <p>Variables that are defined using the <code class="literal">=</code>
9358: operator may be used read-only at run-time.</p>
9359: <p>Variables whose name starts with an underscore must not be
9360: accessed outside the pkgsrc infrastructure at all. They may
9361: change without further notice.</p>
9362: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
9363: <h3 class="title">Note</h3>
9364: <p>These conventions are currently not applied
9365: consistently to the complete pkgsrc
9366: infrastructure.</p>
9367: </div>
9368: </div>
9369: <div class="sect1" lang="en">
9370: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9371: <a name="infr.vardef.problems"></a>22.2. Avoiding problems before they arise</h2></div></div></div>
1.81 rillig 9372: <p>All variables that contain lists of things should default
9373: to being empty. Two examples that do not follow this rule are
9374: <code class="varname">USE_LANGUAGES</code> and
9375: <code class="varname">DISTFILES</code>. These variables cannot simply be
9376: modified using the <code class="literal">+=</code> operator in package
9377: <code class="filename">Makefile</code>s (or other files included by
9378: them), since there is no guarantee whether the variable is
9379: already set or not, and what its value is. In the case of
9380: <code class="varname">DISTFILES</code>, the packages “<span class="quote">know</span>”
9381: the default value and just define it as in the following
9382: example.</p>
9383: <pre class="programlisting">
9384: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
9385: </pre>
9386: <p>Because of the selection of this default value, the same
9387: value appears in many package Makefiles. Similarly for
9388: <code class="varname">USE_LANGUAGES</code>, but in this case the default
9389: value (“<span class="quote"><code class="literal">c</code></span>”) is so short that it
9390: doesn't stand out. Nevertheless it is mentioned in many
9391: files.</p>
9392: </div>
9393: <div class="sect1" lang="en">
9394: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9395: <a name="infr.var"></a>22.3. Variable evaluation</h2></div></div></div>
1.75 rillig 9396: <div class="sect2" lang="en">
9397: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9398: <a name="infr.var.load"></a>22.3.1. At load time</h3></div></div></div>
1.75 rillig 9399: <p>Variable evaluation takes place either at load time or at
9400: runtime, depending on the context in which they occur. The
9401: contexts where variables are evaluated at load time are:</p>
9402: <div class="itemizedlist"><ul type="disc">
9403: <li><p>The right hand side of the <code class="literal">:=</code>
9404: and <code class="literal">!=</code> operators,</p></li>
9405: <li><p>Make directives like <code class="literal">.if</code> or
9406: <code class="literal">.for</code>,</p></li>
9407: <li><p>Dependency lines.</p></li>
9408: </ul></div>
9409: <p>A special exception are references to the iteration
9410: variables of <code class="literal">.for</code> loops, which are expanded
9411: inline, no matter in which context they appear.</p>
9412: <p>As the values of variables may change during load time,
9413: care must be taken not to evaluate them by accident. Typical
9414: examples for variables that should not be evaluated at load time
9415: are <code class="varname">DEPENDS</code> and
9416: <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
9417: clear, here is an example:</p>
9418: <pre class="programlisting">
9419: CONFIGURE_ARGS= # none
9420: CFLAGS= -O
9421: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
1.1 grant 9422:
1.75 rillig 9423: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
1.1 grant 9424:
1.75 rillig 9425: CFLAGS+= -Wall
9426: </pre>
9427: <p>This code shows how the use of the <code class="literal">:=</code>
9428: operator can quickly lead to unexpected results. The first
9429: paragraph is fairly common code. The second paragraph evaluates
9430: the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
9431: <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
9432: <code class="literal">-Wall</code> is appended to the
9433: <code class="varname">CFLAGS</code>, but this addition will not appear in
9434: <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
9435: paragraphs from above typically occur in completely unrelated
9436: files.</p>
9437: </div>
9438: <div class="sect2" lang="en">
9439: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9440: <a name="infr.var.run"></a>22.3.2. At runtime</h3></div></div></div>
1.75 rillig 9441: <p>After all the files have been loaded, the values of the
9442: variables cannot be changed anymore. Variables that are used in
9443: the shell commands are expanded at this point.</p>
9444: </div>
9445: </div>
9446: <div class="sect1" lang="en">
9447: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9448: <a name="infr.varspec"></a>22.4. How can variables be specified?</h2></div></div></div>
1.78 rillig 9449: <p>There are many ways in which the definition and use of a
9450: variable can be restricted in order to detect bugs and
9451: violations of the (mostly unwritten) policies. See the
9452: <code class="literal">pkglint</code> developer's documentation for further
9453: details.</p>
9454: </div>
9455: <div class="sect1" lang="en">
9456: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9457: <a name="infr.design.intf"></a>22.5. Designing interfaces for Makefile fragments</h2></div></div></div>
1.76 rillig 9458: <p>Most of the <code class="filename">.mk</code> files fall into one
1.75 rillig 9459: of the following classes. Cases where a file falls into more
9460: than one class should be avoided as it often leads to subtle
9461: bugs.</p>
9462: <div class="sect2" lang="en">
9463: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9464: <a name="infr.design.intf.proc"></a>22.5.1. Procedures with parameters</h3></div></div></div>
1.75 rillig 9465: <p>In a traditional imperative programming language some of
1.76 rillig 9466: the <code class="filename">.mk</code> files could be described as
1.87 wiz 9467: procedures. They take some input parameters and—after
9468: inclusion—provide a result in output parameters. Since all
1.76 rillig 9469: variables in <code class="filename">Makefile</code>s have global scope
1.75 rillig 9470: care must be taken not to use parameter names that have already
9471: another meaning. For example, <code class="varname">PKGNAME</code> is a
9472: bad choice for a parameter name.</p>
9473: <p>Procedures are completely evaluated at preprocessing time.
9474: That is, when calling a procedure all input parameters must be
9475: completely resolvable. For example,
9476: <code class="varname">CONFIGURE_ARGS</code> should never be an input
9477: parameter since it is very likely that further text will be
9478: added after calling the procedure, which would effectively apply
9479: the procedure to only a part of the variable. Also, references
9480: to other variables wit will be modified after calling the
9481: procedure.</p>
9482: <p>A procedure can declare its output parameters either as
9483: suitable for use in preprocessing directives or as only
9484: available at runtime. The latter alternative is for variables
9485: that contain references to other runtime variables.</p>
9486: <p>Procedures shall be written such that it is possible to
9487: call the procedure more than once. That is, the file must not
9488: contain multiple-inclusion guards.</p>
9489: <p>Examples for procedures are
1.76 rillig 9490: <code class="filename">mk/bsd.options.mk</code> and
9491: <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
1.75 rillig 9492: that the parameters are evaluated at load time, they should be
9493: assigned using the <code class="literal">:=</code> operator, which should
9494: be used only for this purpose.</p>
9495: </div>
9496: <div class="sect2" lang="en">
9497: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9498: <a name="infr.design.intf.action"></a>22.5.2. Actions taken on behalf of parameters</h3></div></div></div>
1.75 rillig 9499: <p>Action files take some input parameters and may define
9500: runtime variables. They shall not define loadtime variables.
9501: There are action files that are included implicitly by the
9502: pkgsrc infrastructure, while other must be included
9503: explicitly.</p>
9504: <p>An example for action files is
1.76 rillig 9505: <code class="filename">mk/subst.mk</code>.</p>
1.75 rillig 9506: </div>
9507: </div>
1.81 rillig 9508: <div class="sect1" lang="en">
9509: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9510: <a name="infr.order"></a>22.6. The order in which files are loaded</h2></div></div></div>
1.81 rillig 9511: <p>Package <code class="filename">Makefile</code>s usually consist of
9512: a set of variable definitions, and include the file
9513: <code class="filename">../../mk/bsd.pkg.mk</code> in the very last line.
9514: Before that, they may also include various other
9515: <code class="filename">*.mk</code> files if they need to query the
9516: availability of certain features like the type of compiler or
9517: the X11 implementation. Due to the heavy use of preprocessor
9518: directives like <code class="literal">.if</code> and
9519: <code class="literal">.for</code>, the order in which the files are loaded
9520: matters.</p>
9521: <p>This section describes at which point the various files
9522: are loaded and gives reasons for that order.</p>
9523: <div class="sect2" lang="en">
9524: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9525: <a name="infr.order.prefs"></a>22.6.1. The order in <code class="filename">bsd.prefs.mk</code></h3></div></div></div>
1.81 rillig 9526: <p>The very first action in <code class="filename">bsd.pkg.mk</code>
9527: is to define some essential variables like
9528: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code> and
9529: <code class="varname">MACHINE_ARCH</code>.</p>
9530: <p>Then, the user settings are loaded from the file specified
9531: in <code class="varname">MAKECONF</code>. If the bmake command from pkgsrc
9532: is used, <code class="varname">MAKECONF</code> defaults to
9533: <code class="filename"><em class="replaceable"><code>${prefix}</code></em>/etc/mk.conf</code>.
9534: 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
9535: <code class="filename">/etc/mk.conf</code>. After that, those variables
9536: that have not been overridden by the user are loaded from
9537: <code class="filename">mk/defaults/mk.conf</code>.</p>
9538: <p>After the user settings, the system settings and platform
9539: settings are loaded, which may override the user
9540: settings.</p>
9541: <p>Then, the tool definitions are loaded. The tool wrappers
9542: are not yet in effect. This only happens when building a
9543: package, so the proper variables must be used instead of the
9544: direct tool names.</p>
9545: <p>As the last steps, some essential variables from the
9546: wrapper and the package system flavor are loaded, as well as the
9547: variables that have been cached in earlier phases of a package
9548: build.</p>
9549: </div>
9550: <div class="sect2" lang="en">
9551: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9552: <a name="infr.order.pkg"></a>22.6.2. The order in <code class="filename">bsd.pkg.mk</code></h3></div></div></div>
1.81 rillig 9553: <p>First, <code class="filename">bsd.prefs.mk</code> is loaded.</p>
9554: <p>Then, the various <code class="filename">*-vars.mk</code> files are
9555: loaded, which fill default values for those variables that have
9556: not been defined by the the package. These variables may later
9557: be used even in unrelated files.</p>
9558: <p>Then, the file <code class="filename">bsd.pkg.error.mk</code>
9559: provides the target <code class="literal">error-check</code> that is added
9560: as a special dependency to all other targets that use
9561: <code class="varname">DELAYED_ERROR_MSG</code> or
9562: <code class="varname">DELAYED_WARNING_MSG</code>.</p>
9563: <p>Then, the package-specific hacks from
9564: <code class="filename">hacks.mk</code> are included.</p>
9565: <p>Then, various other files follow. Most of them don't have
9566: any dependencies on what they need to have included before or
9567: after them, though some do.</p>
9568: <p>The code to check <code class="varname">PKG_FAIL_REASON</code> and
9569: <code class="varname">PKG_SKIP_REASON</code> is then executed, which
9570: restricts the use of these variables to all the files that have
9571: been included before. Appearances in later files will be
9572: silently ignored.</p>
9573: <p>Then, the files for the main targets are included, in the
9574: order of later execution, though the actual order should not
9575: matter.</p>
9576: <p>At last, some more files are included that don't set any
9577: interesting variables but rather just define make targets to be
9578: executed.</p>
9579: </div>
9580: </div>
1.75 rillig 9581: </div>
9582: <div class="chapter" lang="en">
9583: <div class="titlepage"><div><div><h2 class="title">
1.85 jmmv 9584: <a name="regression"></a>Chapter 23. Regression tests</h2></div></div></div>
1.75 rillig 9585: <div class="toc">
9586: <p><b>Table of Contents</b></p>
9587: <dl>
1.85 jmmv 9588: <dt><span class="sect1"><a href="#regression.descr">23.1. The regression tests framework</a></span></dt>
9589: <dt><span class="sect1"><a href="#regression.run">23.2. Running the regression tests</a></span></dt>
9590: <dt><span class="sect1"><a href="#regression.new">23.3. Adding a new regression test</a></span></dt>
1.75 rillig 9591: <dd><dl>
1.85 jmmv 9592: <dt><span class="sect2"><a href="#regression.fun.override">23.3.1. Overridable functions</a></span></dt>
9593: <dt><span class="sect2"><a href="#regression.fun.helper">23.3.2. Helper functions</a></span></dt>
1.75 rillig 9594: </dl></dd>
9595: </dl>
9596: </div>
9597: <p>The pkgsrc infrastructure consists of a large codebase,
9598: and there are many corners where every little bit of a file is
9599: well thought out, making pkgsrc likely to fail as soon as
9600: anything is changed near those parts. To prevent most changes
9601: from breaking anything, a suite of regression tests should go
9602: along with every important part of the pkgsrc infrastructure.
9603: This chapter describes how regression tests work in pkgsrc and
9604: how you can add new tests.</p>
9605: <div class="sect1" lang="en">
9606: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9607: <a name="regression.descr"></a>23.1. The regression tests framework</h2></div></div></div>
1.75 rillig 9608: <p></p>
9609: </div>
9610: <div class="sect1" lang="en">
9611: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9612: <a name="regression.run"></a>23.2. Running the regression tests</h2></div></div></div>
1.76 rillig 9613: <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 9614: provides the <span><strong class="command">pkg_regress</strong></span> command. Then you
9615: can simply run that command, which will run all tests in the
1.76 rillig 9616: <code class="filename">regress</code> category.</p>
1.75 rillig 9617: </div>
9618: <div class="sect1" lang="en">
9619: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9620: <a name="regression.new"></a>23.3. Adding a new regression test</h2></div></div></div>
1.76 rillig 9621: <p>Every directory in the <code class="filename">regress</code>
9622: category that contains a file called <code class="filename">spec</code>
1.75 rillig 9623: is considered a regression test. This file is a shell program
9624: that is included by the <span><strong class="command">pkg_regress</strong></span> command.
9625: The following functions can be overridden to suit your
9626: needs.</p>
9627: <div class="sect2" lang="en">
9628: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9629: <a name="regression.fun.override"></a>23.3.1. Overridable functions</h3></div></div></div>
1.75 rillig 9630: <p>These functions do not take any parameters. They are all
9631: called in “<span class="quote">set -e</span>” mode, so you should be careful
9632: to check the exitcodes of any commands you run in the
9633: test.</p>
9634: <div class="variablelist"><dl>
9635: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
9636: <dd><p>This function prepares the environment for the
9637: test. By default it does nothing.</p></dd>
9638: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
9639: <dd><p>This function runs the actual test. By default,
9640: it calls <code class="varname">TEST_MAKE</code> with the arguments
9641: <code class="varname">MAKEARGS_TEST</code> and writes its output including
9642: error messages into the file
9643: <code class="varname">TEST_OUTFILE</code>.</p></dd>
9644: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
9645: <dd><p>This function is run after the test and is
9646: typically used to compare the actual output from the one that is
9647: expected. It can make use of the various helper functions from
9648: the next section.</p></dd>
9649: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
9650: <dd><p>This function cleans everything up after the
9651: test has been run. By default it does nothing.</p></dd>
9652: </dl></div>
9653: </div>
9654: <div class="sect2" lang="en">
9655: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9656: <a name="regression.fun.helper"></a>23.3.2. Helper functions</h3></div></div></div>
1.75 rillig 9657: <div class="variablelist"><dl>
9658: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
9659: <dd><p>This function compares the exitcode of the
9660: <span><strong class="command">do_test()</strong></span> function with its first parameter.
9661: If they differ, the test will fail.</p></dd>
9662: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
9663: <dd><p>This function checks for each of its parameters
9664: if the output from <span><strong class="command">do_test()</strong></span> matches the
9665: extended regular expression. If it does not, the test will
9666: fail.</p></dd>
9667: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
9668: <dd><p>This function checks for each of its parameters
9669: if the output from <span><strong class="command">do_test()</strong></span> does
9670: <span class="emphasis"><em>not</em></span> match the extended regular expression.
9671: If any of the regular expressions matches, the test will
9672: fail.</p></dd>
9673: </dl></div>
9674: </div>
9675: </div>
9676: </div>
9677: <div class="chapter" lang="en">
9678: <div class="titlepage"><div><div><h2 class="title">
1.85 jmmv 9679: <a name="porting"></a>Chapter 24. Porting pkgsrc</h2></div></div></div>
1.75 rillig 9680: <div class="toc">
9681: <p><b>Table of Contents</b></p>
9682: <dl>
1.85 jmmv 9683: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
9684: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 9685: </dl>
9686: </div>
9687: <p>The pkgsrc system has already been ported to many
9688: operating systems, hardware architectures and compilers. This
9689: chapter explains the necessary steps to make pkgsrc even more
9690: portable.</p>
9691: <div class="sect1" lang="en">
9692: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9693: <a name="porting.opsys"></a>24.1. Porting pkgsrc to a new operating system</h2></div></div></div>
1.75 rillig 9694: <p>To port pkgsrc to a new operating system (called
9695: <code class="literal">MyOS</code> in this example), you need to touch the
9696: following files:</p>
9697: <div class="variablelist"><dl>
1.76 rillig 9698: <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 9699: <dd><p>This file contains some basic definitions, for
9700: example the name of the C
9701: compiler.</p></dd>
1.76 rillig 9702: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
1.75 rillig 9703: <dd><p>Insert code that defines the variables
9704: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
9705: <code class="varname">LOWER_OS_VERSION</code>,
9706: <code class="varname">LOWER_VENDOR</code>,
9707: <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
9708: <code class="varname">APPEND_ELF</code>, and the other variables that
9709: appear in this file.</p></dd>
1.76 rillig 9710: <dt><span class="term"><code class="filename">mk/platform/MyOS.mk</code></span></dt>
1.75 rillig 9711: <dd><p>This file contains the platform-specific
9712: definitions that are used by pkgsrc. Start by copying one of the
9713: other files and edit it to your
9714: needs.</p></dd>
1.76 rillig 9715: <dt><span class="term"><code class="filename">mk/platform/MyOS.pkg.dist</code></span></dt>
1.75 rillig 9716: <dd><p>This file contains a list of directories,
9717: together with their permission bits and ownership. These
9718: directories will be created automatically with every package
9719: that does not explicitly set <code class="varname">NO_MTREE</code>. There
9720: have been some discussions about whether this file is needed at
9721: all, but with no result.</p></dd>
1.76 rillig 9722: <dt><span class="term"><code class="filename">mk/platform/MyOS.x11.dist</code></span></dt>
1.75 rillig 9723: <dd><p>Just copy one of the pre-existing x11.dist files
9724: to your
1.76 rillig 9725: <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
9726: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
1.75 rillig 9727: <dd><p>On some operating systems, the tools that are
9728: provided with the base system are not good enough for pkgsrc.
9729: 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
9730: narrow limit on the line length they can process. Therefore
9731: pkgsrc brings its own tools, which can be enabled
9732: here.</p></dd>
1.76 rillig 9733: <dt><span class="term"><code class="filename">mk/tools/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
1.75 rillig 9734: <dd><p>This file defines the paths to all the tools
9735: that are needed by one or the other package in pkgsrc, as well
9736: as by pkgsrc itself. Find out where these tools are on your
9737: platform and add them.</p></dd>
9738: </dl></div>
9739: <p>Now, you should be able to build some basic packages, like
1.76 rillig 9740: <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 9741: </div>
9742: <div class="sect1" lang="en">
9743: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9744: <a name="porting.compiler"></a>24.2. Adding support for a new compiler</h2></div></div></div>
1.75 rillig 9745: <p>TODO</p>
9746: </div>
9747: </div>
9748: </div>
9749: <div class="appendix" lang="en">
9750: <div class="titlepage"><div><div><h2 class="title">
9751: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
9752: <div class="toc">
9753: <p><b>Table of Contents</b></p>
9754: <dl>
9755: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
9756: <dd><dl>
9757: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
9758: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
9759: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
9760: <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>
9761: </dl></dd>
9762: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
9763: </dl>
9764: </div>
9765: <p>We checked to find a piece of software that wasn't in the packages
9766: collection, and picked GNU bison. Quite why someone would want to have
9767: <span><strong class="command">bison</strong></span> when Berkeley <span><strong class="command">yacc</strong></span> is already
9768: present in the tree is beyond us, but it's useful for the purposes of
9769: this exercise.</p>
9770: <div class="sect1" lang="en">
9771: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9772: <a name="example-files"></a>A.1. files</h2></div></div></div>
9773: <div class="sect2" lang="en">
9774: <div class="titlepage"><div><div><h3 class="title">
9775: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
9776: <pre class="programlisting">
1.51 rillig 9777: # $NetBSD$
9778: #
1.1 grant 9779:
1.51 rillig 9780: DISTNAME= bison-1.25
9781: CATEGORIES= devel
9782: MASTER_SITES= ${MASTER_SITE_GNU}
1.1 grant 9783:
1.51 rillig 9784: MAINTAINER= thorpej@NetBSD.org
9785: HOMEPAGE= http://www.gnu.org/software/bison/bison.html
9786: COMMENT= GNU yacc clone
1.1 grant 9787:
1.51 rillig 9788: GNU_CONFIGURE= yes
9789: INFO_FILES= bison.info
1.1 grant 9790:
1.51 rillig 9791: .include "../../mk/bsd.pkg.mk"
1.1 grant 9792: </pre>
1.75 rillig 9793: </div>
9794: <div class="sect2" lang="en">
9795: <div class="titlepage"><div><div><h3 class="title">
9796: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
9797: <pre class="programlisting">
1.51 rillig 9798: GNU version of yacc. Can make re-entrant parsers, and numerous other
1.75 rillig 9799: 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 9800: of the NetBSD source tree is beyond me.
1.1 grant 9801: </pre>
1.75 rillig 9802: </div>
9803: <div class="sect2" lang="en">
9804: <div class="titlepage"><div><div><h3 class="title">
9805: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
9806: <pre class="programlisting">
1.51 rillig 9807: @comment $NetBSD$
9808: bin/bison
9809: man/man1/bison.1.gz
9810: share/bison.simple
9811: share/bison.hairy
1.1 grant 9812: </pre>
1.75 rillig 9813: </div>
9814: <div class="sect2" lang="en">
9815: <div class="titlepage"><div><div><h3 class="title">
9816: <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>
9817: <p>The NetBSD package system comes with
1.76 rillig 9818: <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 9819: which helps to check the contents of these
9820: files. After installation it is quite easy to use, just change to the
9821: directory of the package you wish to examine and execute
9822: <span><strong class="command">pkglint</strong></span>:</p>
9823: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
9824: looks fine.</pre>
9825: <p>Depending on the supplied command line arguments (see pkglint(1)),
9826: more checks will be performed. Use e.g. <span><strong class="command">pkglint -Call
9827: -Wall</strong></span> for a very thorough check.</p>
9828: </div>
9829: </div>
9830: <div class="sect1" lang="en">
9831: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9832: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
9833: <p>Create the directory where the package lives,
9834: plus any auxiliary directories:</p>
9835: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
9836: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
9837: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
9838: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
1.76 rillig 9839: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.77 rillig 9840: <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 9841: then continue with fetching the distfile:</p>
9842: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
1.1 grant 9843: >> bison-1.25.tar.gz doesn't seem to exist on this system.
9844: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
9845: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
9846: ftp: Error retrieving file: 500 Internal error
9847:
9848: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
9849: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
9850: ftp: Error retrieving file: 500 Internal error
9851:
9852: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
9853: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
1.75 rillig 9854: Successfully retrieved file.</pre>
9855: <p>Generate the checksum of the distfile into
1.76 rillig 9856: <code class="filename">distinfo</code>:</p>
1.88 ! wiz 9857: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makedistinfo</code></strong></pre>
1.75 rillig 9858: <p>Now compile:</p>
9859: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 9860: >> Checksum OK for bison-1.25.tar.gz.
9861: ===> Extracting for bison-1.25
9862: ===> Patching for bison-1.25
9863: ===> Ignoring empty patch directory
9864: ===> Configuring for bison-1.25
9865: creating cache ./config.cache
9866: checking for gcc... cc
9867: checking whether we are using GNU C... yes
9868: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
9869: checking how to run the C preprocessor... cc -E
9870: checking for minix/config.h... no
9871: checking for POSIXized ISC... no
9872: checking whether cross-compiling... no
9873: checking for ANSI C header files... yes
9874: checking for string.h... yes
9875: checking for stdlib.h... yes
9876: checking for memory.h... yes
9877: checking for working const... yes
9878: checking for working alloca.h... no
9879: checking for alloca... yes
9880: checking for strerror... yes
9881: updating cache ./config.cache
9882: creating ./config.status
9883: creating Makefile
9884: ===> Building for bison-1.25
9885: 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
9886: 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
9887: 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
9888: 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
9889: 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 9890: 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 9891: 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
9892: 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
9893: 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
9894: 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
9895: 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
9896: 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
9897: 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
9898: 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
9899: 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
9900: 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
9901: 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
9902: 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
9903: 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
9904: 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
9905: 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
9906: 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
9907: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
9908: rm -f bison.s1
1.75 rillig 9909: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1</pre>
9910: <p>Everything seems OK, so install the files:</p>
9911: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 9912: >> Checksum OK for bison-1.25.tar.gz.
9913: ===> Installing for bison-1.25
9914: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
9915: rm -f /usr/pkg/bin/bison
9916: cd /usr/pkg/share; rm -f bison.simple bison.hairy
9917: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
9918: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
9919: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
9920: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
9921: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
9922: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
1.75 rillig 9923: ===> Registering installation for bison-1.25</pre>
9924: <p>You can now use bison, and also - if you decide so - remove it with
9925: <span><strong class="command">pkg_delete bison</strong></span>. Should you decide that you want a
9926: binary package, do this now:</p>
9927: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 9928: >> Checksum OK for bison-1.25.tar.gz.
9929: ===> Building package for bison-1.25
9930: Creating package bison-1.25.tgz
9931: Registering depends:.
1.75 rillig 9932: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
9933: <p>Now that you don't need the source and object files
9934: any more, clean up:</p>
9935: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
9936: ===> Cleaning for bison-1.25</pre>
9937: </div>
9938: </div>
9939: <div class="appendix" lang="en">
9940: <div class="titlepage"><div><div><h2 class="title">
9941: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
9942: <div class="toc">
9943: <p><b>Table of Contents</b></p>
9944: <dl>
9945: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
9946: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
9947: </dl>
9948: </div>
9949: <div class="sect1" lang="en">
9950: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9951: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
9952: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 9953: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9954: => figlet221.tar.gz doesn't seem to exist on this system.
9955: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
9956: => [172219 bytes]
9957: Connected to ftp.plig.net.
9958: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
9959: 331 Guest login ok, send your complete e-mail address as password.
9960: 230-You are user #5 of 500 simultaneous users allowed.
9961: 230-
1.68 rillig 9962: 230- ___ _ _ _
9963: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
1.1 grant 9964: 230- | _| _| . |_| . | | | . |_| . | _| . |
9965: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
9966: 230- |_| |_| |___| |___|
9967: 230-
9968: 230-** Welcome to ftp.plig.org **
9969: 230-
9970: 230-Please note that all transfers from this FTP site are logged. If you
9971: 230-do not like this, please disconnect now.
9972: 230-
9973: 230-This arhive is available via
9974: 230-
9975: 230-HTTP: http://ftp.plig.org/
9976: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
9977: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
9978: 230-
9979: 230-Please email comments, bug reports and requests for packages to be
1.68 rillig 9980: 230-mirrored to ftp-admin@plig.org.
1.1 grant 9981: 230-
9982: 230-
9983: 230 Logged in anonymously.
9984: Remote system type is UNIX.
9985: Using binary mode to transfer files.
9986: 200 Type okay.
9987: 250 "/pub" is new cwd.
9988: 250-"/pub/figlet" is new cwd.
9989: 250-
9990: 250-Welcome to the figlet archive at ftp.figlet.org
1.68 rillig 9991: 250-
1.75 rillig 9992: 250- ftp://ftp.figlet.org/pub/figlet/
1.1 grant 9993: 250-
9994: 250-The official FIGlet web page is:
1.75 rillig 9995: 250- http://www.figlet.org/
1.1 grant 9996: 250-
9997: 250-If you have questions, please mailto:info@figlet.org. If you want to
9998: 250-contribute a font or something else, you can email us.
1.68 rillig 9999: 250
1.1 grant 10000: 250 "/pub/figlet/program" is new cwd.
10001: 250 "/pub/figlet/program/unix" is new cwd.
10002: local: figlet221.tar.gz remote: figlet221.tar.gz
10003: 502 Unimplemented command.
10004: 227 Entering Passive Mode (195,40,6,41,246,104)
10005: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
10006: 38% |************** | 65800 64.16 KB/s 00:01 ETA
10007: 226 Transfer completed.
10008: 172219 bytes received in 00:02 (75.99 KB/s)
10009: 221 Goodbye.
10010: => Checksum OK for figlet221.tar.gz.
10011: ===> Extracting for figlet-2.2.1nb2
10012: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
10013: ===> Patching for figlet-2.2.1nb2
10014: ===> Applying pkgsrc patches for figlet-2.2.1nb2
10015: ===> Overriding tools for figlet-2.2.1nb2
10016: ===> Creating toolchain wrappers for figlet-2.2.1nb2
10017: ===> Configuring for figlet-2.2.1nb2
10018: ===> Building for figlet-2.2.1nb2
10019: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
10020: chmod a+x figlet
10021: gcc -O2 -o chkfont chkfont.c
10022: => Unwrapping files-to-be-installed.
1.14 xtraeme 10023: <code class="prompt">#</code>
1.75 rillig 10024: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 10025: ===> Checking for vulnerabilities in figlet-2.2.1nb2
10026: ===> Installing for figlet-2.2.1nb2
10027: install -d -o root -g wheel -m 755 /usr/pkg/bin
10028: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
10029: mkdir -p /usr/pkg/share/figlet
10030: cp figlet /usr/pkg/bin
10031: cp chkfont /usr/pkg/bin
10032: chmod 555 figlist showfigfonts
10033: cp figlist /usr/pkg/bin
10034: cp showfigfonts /usr/pkg/bin
10035: cp fonts/*.flf /usr/pkg/share/figlet
10036: cp fonts/*.flc /usr/pkg/share/figlet
10037: cp figlet.6 /usr/pkg/man/man6
10038: ===> Registering installation for figlet-2.2.1nb2
1.75 rillig 10039: <code class="prompt">#</code></pre>
10040: </div>
10041: <div class="sect1" lang="en">
10042: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10043: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
10044: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 10045: ===> Checking for vulnerabilities in figlet-2.2.1nb2
10046: ===> Packaging figlet-2.2.1nb2
10047: ===> Building binary package for figlet-2.2.1nb2
10048: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
10049: Using SrcDir value of /usr/pkg
1.68 rillig 10050: Registering depends:.
1.75 rillig 10051: <code class="prompt">#</code></pre>
10052: </div>
10053: </div>
10054: <div class="appendix" lang="en">
10055: <div class="titlepage"><div><div><h2 class="title">
1.76 rillig 10056: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
10057: <div class="toc">
10058: <p><b>Table of Contents</b></p>
10059: <dl>
10060: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
10061: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
10062: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
10063: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
10064: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
10065: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
10066: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
10067: source packages</a></span></dt>
10068: </dl>
10069: </div>
10070: <p>As in other big projects, the directory layout of pkgsrc
10071: is quite complex for newbies. This chapter explains where you
10072: find things on the FTP server. The base directory on
10073: <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>.
10074: This directory contains some subdirectories, which are explained
10075: below.</p>
10076: <div class="sect1" lang="en">
10077: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10078: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
10079: <p>For those who only want to manage binary packages on
10080: systems other than NetBSD, we provide the package management
10081: tools in a separate, small tar file.</p>
10082: </div>
10083: <div class="sect1" lang="en">
10084: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10085: <a name="ftp-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
10086: <p>The directory <code class="filename">distfiles</code> contains lots
10087: of archive files from all pkgsrc packages, which are mirrored
10088: here. The subdirectories are called after their package names
10089: and are used when the distributed files have names that don't
10090: explicitly contain a version number or are otherwise too generic
10091: (for example <code class="filename">release.tar.gz</code>).</p>
10092: </div>
10093: <div class="sect1" lang="en">
10094: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10095: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
10096: <p>This directory is currently not in use.</p>
10097: </div>
10098: <div class="sect1" lang="en">
10099: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10100: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
10101: <p>This directory contains things that individual pkgsrc
10102: developers find worth publishing.</p>
10103: </div>
10104: <div class="sect1" lang="en">
10105: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10106: <a name="ftp-packages"></a>C.5. <code class="filename">packages*</code>: Binary packages</h2></div></div></div>
10107: <p>These directories contain binary packages. Those
10108: directories that have a branch name
10109: (200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>)
10110: contain packages from that particular branch. The directory
10111: <code class="filename">packages</code> contains binary packages from
10112: pkgsrc-current. (However, this does not necessarily mean that
10113: the packages are still current anymore.)</p>
10114: <p>Below the <code class="filename">packages*</code> directories are
10115: directories that distinguish the packages by operating system
10116: and version, the next directory level specifies the hardware
10117: architecture.</p>
10118: <p>In each of the platform-specific directories, there is a
10119: whole binary packages collection. It has a directory called
10120: <code class="filename">All</code> which contains all binary packages.
10121: Besides that, there are various category directories that
10122: contain symbolic links to the real binary packages.</p>
10123: </div>
10124: <div class="sect1" lang="en">
10125: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10126: <a name="ftp-source"></a>C.6. <code class="filename">current</code>,
10127: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
10128: source packages</h2></div></div></div>
10129: <p>These directories contain the “<span class="quote">real</span>” pkgsrc,
10130: that is the files that define how to create binary packages from
10131: source archives.</p>
10132: <p>The directory <code class="filename">pkgsrc</code> contains a
10133: snapshot of the CVS repository, which is updated on a regularly
10134: basis. The file <code class="filename">pkgsrc.tar.gz</code> contains the
10135: same as the directory, ready to be downloaded as a whole.</p>
10136: <p>In the directories for the quarterly branches, there is an
10137: additional file called
10138: <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
10139: which contains the state of pkgsrc when it was branched.</p>
10140: </div>
1.75 rillig 10141: </div>
10142: <div class="appendix" lang="en">
10143: <div class="titlepage"><div><div><h2 class="title">
10144: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
10145: <div class="toc">
10146: <p><b>Table of Contents</b></p>
10147: <dl>
1.79 rillig 10148: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75 rillig 10149: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
10150: </dl>
10151: </div>
1.79 rillig 10152: <p>This section contains information on editing the pkgsrc
10153: guide itself.</p>
1.75 rillig 10154: <div class="sect1" lang="en">
10155: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.79 rillig 10156: <a name="targets"></a>D.1. Make targets</h2></div></div></div>
10157: <p>The pkgsrc guide's source code is stored in
10158: <code class="filename">pkgsrc/doc/guide/files</code>, and several files
10159: are created from it:</p>
10160: <div class="itemizedlist"><ul type="disc">
10161: <li><p><code class="filename">pkgsrc/doc/pkgsrc.txt</code></p></li>
10162: <li><p><code class="filename">pkgsrc/doc/pkgsrc.html</code></p></li>
10163: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/</a></p></li>
10164: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</a>:
10165: The PDF version of the pkgsrc guide.</p></li>
10166: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</a>:
10167: PostScript version of the pkgsrc guide.</p></li>
1.75 rillig 10168: </ul></div>
10169: </div>
10170: <div class="sect1" lang="en">
10171: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10172: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
1.79 rillig 10173: <p>The procedure to edit the pkgsrc guide is:</p>
10174: <div class="procedure"><ol type="1">
10175: <li><p>Make sure you have the packages needed to
1.83 wiz 10176: regenerate the pkgsrc guide (and other XML-based NetBSD
1.79 rillig 10177: 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
10178: 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
10179: PostScript and PDF versions. You will need both packages
10180: installed, to make sure documentation is consistent across all
10181: formats.</p></li>
10182: <li><p>Run <span><strong class="command">cd doc/guide</strong></span> to get to the
10183: right directory. All further steps will take place
10184: here.</p></li>
10185: <li><p>Edit the XML file(s) in
10186: <code class="filename">files/</code>.</p></li>
10187: <li><p>Run <span><strong class="command">bmake</strong></span> to check the pkgsrc
10188: guide for valid XML and to build the final output files. If you
10189: get any errors at this stage, you can just edit the files, as
10190: there are only symbolic links in the working directory, pointing
10191: to the files in <code class="filename">files/</code>.</p></li>
10192: <li><p><span><strong class="command">(cd files && cvs
10193: commit)</strong></span></p></li>
10194: <li><p>Run <span><strong class="command">bmake clean && bmake</strong></span> to
10195: regenerate the output files with the proper RCS
10196: Ids.</p></li>
1.83 wiz 10197: <li><p>Run <span><strong class="command">bmake regenerate</strong></span> to
10198: regenerate the files in both <code class="filename">pkgsrc/doc</code> and
10199: <code class="filename">htdocs</code>.</p></li>
10200: <li><p>If you have added, removed or renamed some chapters,
10201: you need to synchronize them using <span><strong class="command">cvs add</strong></span> or
10202: <span><strong class="command">cvs delete</strong></span> in the htdocs
10203: directory.</p></li>
1.79 rillig 10204: </ol></div>
1.75 rillig 10205: </div>
10206: </div>
10207: </div></body>
1.1 grant 10208: </html>
CVSweb <webmaster@jp.NetBSD.org>