Annotation of pkgsrc/doc/pkgsrc.html, revision 1.89
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.89 ! rillig 8: <meta name="description" content="pkgsrc is a centralized package management system for
! 9: Unix-like operating systems. This guide provides information for
! 10: users and developers of pkgsrc. It covers installation of binary
! 11: and source packages, creation of binary and source packages and
! 12: a high-level overview about the infrastructure.">
1.75 rillig 13: </head>
14: <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" lang="en">
15: <div class="titlepage">
16: <div>
17: <div><h1 class="title">
18: <a name="the-pkgsrc-guide"></a>The pkgsrc guide</h1></div>
19: <div><h2 class="subtitle">Documentation on the NetBSD packages system</h2></div>
20: <div><div class="authorgroup">
21: <div class="author">
22: <h3 class="author">
23: <span class="firstname">Alistair</span> <span class="surname">Crooks</span>
24: </h3>
25: <div class="affiliation"><div class="address"><p><code class="email"><<a href="mailto:agc@NetBSD.org">agc@NetBSD.org</a>></code></p></div></div>
26: </div>
27: <div class="author">
28: <h3 class="author">
29: <span class="firstname">Hubert</span> <span class="surname">Feyrer</span>
30: </h3>
31: <div class="affiliation"><div class="address"><p><code class="email"><<a href="mailto:hubertf@NetBSD.org">hubertf@NetBSD.org</a>></code></p></div></div>
32: </div>
33: <h3 class="corpauthor">
34: The pkgsrc Developers
35: </h3>
36: </div></div>
37: <div><p class="copyright">Copyright © 1994-2006 The NetBSD Foundation, Inc</p></div>
1.85 jmmv 38: <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.22 2006/09/01 16:35:39 jmmv Exp $</p></div>
1.76 rillig 39: <div><div class="abstract">
1.75 rillig 40: <p class="title"><b>Abstract</b></p>
41: <p>pkgsrc is a centralized package management system for
42: Unix-like operating systems. This guide provides information for
43: users and developers of pkgsrc. It covers installation of binary
44: and source packages, creation of binary and source packages and
45: a high-level overview about the infrastructure.</p>
46: </div></div>
47: </div>
48: <hr>
49: </div>
50: <div class="toc">
51: <p><b>Table of Contents</b></p>
52: <dl>
53: <dt><span class="chapter"><a href="#introduction">1. What is pkgsrc?</a></span></dt>
54: <dd><dl>
55: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
1.82 rillig 56: <dd><dl>
57: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
58: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
59: </dl></dd>
1.75 rillig 60: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
61: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.88 wiz 62: <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 63: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
64: </dl></dd>
65: <dt><span class="part"><a href="#users-guide">I. The pkgsrc user's guide</a></span></dt>
66: <dd><dl>
67: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
68: <dd><dl>
69: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
70: <dd><dl>
71: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
72: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
73: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
74: </dl></dd>
75: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
76: <dd><dl>
77: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
78: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
79: </dl></dd>
80: </dl></dd>
81: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
82: <dd><dl>
1.82 rillig 83: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
84: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
85: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
86: <dd><dl>
87: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
88: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
89: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
90: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
91: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
92: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
93: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75 rillig 94: </dl></dd>
95: </dl></dd>
96: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
97: <dd><dl>
98: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
99: <dd><dl>
100: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
101: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82 rillig 102: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
103: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
104: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
105: <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>
106: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
107: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75 rillig 108: </dl></dd>
109: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
110: <dd><dl>
111: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
112: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
113: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
114: </dl></dd>
115: </dl></dd>
116: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
117: <dd><dl>
118: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
119: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 120: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
1.88 wiz 121: <dd><dl>
1.89 ! rillig 122: <dt><span class="sect2"><a href="#selecting-the-compiler">5.3.1. Selecting the compiler</a></span></dt>
! 123: <dt><span class="sect2"><a href="#conf.cflags">5.3.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
! 124: <dt><span class="sect2"><a href="#conf.ldflags">5.3.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
1.88 wiz 125: </dl></dd>
1.78 rillig 126: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
127: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 128: </dl></dd>
129: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
130: <dd><dl>
131: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
132: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
133: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
134: <dd><dl>
135: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
136: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
137: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
138: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
139: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
140: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
141: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
142: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
143: </dl></dd>
144: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
145: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
146: </dl></dd>
147: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
148: <dd><dl>
149: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
150: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
151: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
152: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
153: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
154: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
155: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
156: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
157: <dt><span class="sect1"><a href="#passive-ftp">7.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
158: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
159: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
160: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
161: <dt><span class="sect1"><a href="#bsd.own.mk-missing">7.12. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</a></span></dt>
162: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
163: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
164: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
165: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
1.88 wiz 166: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.89 ! rillig 167: <dt><span class="sect1"><a href="#faq.rcs-conflicts">7.18. What does “<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>” mean?</a></span></dt>
! 168: <dt><span class="sect1"><a href="#too-much-time">7.19. I have a little time to kill. What shall I do?</a></span></dt>
1.75 rillig 169: </dl></dd>
170: </dl></dd>
171: <dt><span class="part"><a href="#developers-guide">II. The pkgsrc developer's guide</a></span></dt>
172: <dd><dl>
1.77 rillig 173: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
174: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75 rillig 175: <dd><dl>
1.77 rillig 176: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
177: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
178: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
1.85 jmmv 179: <dd><dl>
180: <dt><span class="sect2"><a href="#components.patches.guidelines">9.3.1. Patching guidelines</a></span></dt>
181: <dt><span class="sect2"><a href="#components.patches.feedback">9.3.2. Feedback to the author</a></span></dt>
182: </dl></dd>
1.77 rillig 183: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
184: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 185: <dd><dl>
186: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
187: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
188: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
189: </dl></dd>
1.77 rillig 190: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
191: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
192: </dl></dd>
193: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
194: <dd><dl>
195: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
196: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
197: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
198: <dd><dl>
199: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
200: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
201: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
202: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
203: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
204: </dl></dd>
205: </dl></dd>
206: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
207: <dd><dl>
208: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
209: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
210: <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>
211: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
212: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
213: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
214: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
215: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
216: </dl></dd>
217: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
218: <dd><dl>
219: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
220: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
221: <dd><dl>
222: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
223: <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>
224: </dl></dd>
225: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
226: <dd><dl>
227: <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>
228: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
229: </dl></dd>
230: </dl></dd>
231: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
232: <dd><dl>
233: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
234: <dd><dl>
235: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
236: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
237: </dl></dd>
238: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
239: <dd><dl>
240: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
241: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
242: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
243: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
244: </dl></dd>
245: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
246: <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>
247: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
248: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
249: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
250: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
251: <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>
252: </dl></dd>
253: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
254: <dd><dl>
255: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
256: <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>
257: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
258: </dl></dd>
259: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
260: <dd><dl>
261: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
262: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
263: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
264: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
265: <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 266: <dd><dl>
267: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
268: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
269: </dl></dd>
1.77 rillig 270: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
271: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
272: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
273: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
274: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
275: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
276: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
277: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
278: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
279: <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 280: <dt><span class="sect1"><a href="#build.clean">15.16. Cleaning up</a></span></dt>
281: <dt><span class="sect1"><a href="#build.helpful-targets">15.17. Other helpful targets</a></span></dt>
1.77 rillig 282: </dl></dd>
283: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
284: <dd><dl>
285: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
286: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
287: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
288: </dl></dd>
289: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
290: <dd><dl>
291: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
292: <dd><dl>
1.78 rillig 293: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
294: <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>
295: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
296: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
297: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
298: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
299: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
300: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
301: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
302: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
303: <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 304: <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 305: </dl></dd>
306: <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>
307: <dd><dl>
308: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
309: <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>
310: </dl></dd>
311: <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>
312: <dd><dl>
313: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
314: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
315: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
316: </dl></dd>
1.87 wiz 317: <dt><span class="sect1"><a href="#programming-languages">17.4. Programming languages</a></span></dt>
1.77 rillig 318: <dd><dl>
1.87 wiz 319: <dt><span class="sect2"><a href="#basic-programming-languages">17.4.1. C, C++, and Fortran</a></span></dt>
320: <dt><span class="sect2"><a href="#java-programming-language">17.4.2. Java</a></span></dt>
321: <dt><span class="sect2"><a href="#perl-scripts">17.4.3. Packages containing perl scripts</a></span></dt>
322: <dt><span class="sect2"><a href="#other-programming-languages">17.4.4. Other programming languages</a></span></dt>
323: </dl></dd>
324: <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>
325: <dd><dl>
326: <dt><span class="sect2"><a href="#fixes.build.cpp">17.5.1. Compiling C and C++ code conditionally</a></span></dt>
327: <dt><span class="sect2"><a href="#compiler-bugs">17.5.2. How to handle compiler bugs</a></span></dt>
328: <dt><span class="sect2"><a href="#undefined-reference">17.5.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
329: <dt><span class="sect2"><a href="#out-of-memory">17.5.4. Running out of memory</a></span></dt>
330: </dl></dd>
331: <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>
332: <dd><dl>
333: <dt><span class="sect2"><a href="#install-scripts">17.6.1. Creating needed directories</a></span></dt>
334: <dt><span class="sect2"><a href="#where-to-install-documentation">17.6.2. Where to install documentation</a></span></dt>
335: <dt><span class="sect2"><a href="#installing-score-files">17.6.3. Installing score files</a></span></dt>
336: <dt><span class="sect2"><a href="#hardcoded-paths">17.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
337: <dt><span class="sect2"><a href="#perl-modules">17.6.5. Packages installing perl modules</a></span></dt>
338: <dt><span class="sect2"><a href="#faq.info-files">17.6.6. Packages installing info files</a></span></dt>
339: <dt><span class="sect2"><a href="#manpages">17.6.7. Packages installing man pages</a></span></dt>
340: <dt><span class="sect2"><a href="#gconf2-data-files">17.6.8. Packages installing GConf2 data files</a></span></dt>
341: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.6.9. Packages installing scrollkeeper data files</a></span></dt>
342: <dt><span class="sect2"><a href="#x11-fonts">17.6.10. Packages installing X11 fonts</a></span></dt>
343: <dt><span class="sect2"><a href="#gtk2-modules">17.6.11. Packages installing GTK2 modules</a></span></dt>
344: <dt><span class="sect2"><a href="#sgml-xml-data">17.6.12. Packages installing SGML or XML data</a></span></dt>
345: <dt><span class="sect2"><a href="#mime-database">17.6.13. Packages installing extensions to the MIME database</a></span></dt>
346: <dt><span class="sect2"><a href="#intltool">17.6.14. Packages using intltool</a></span></dt>
347: <dt><span class="sect2"><a href="#startup-scripts">17.6.15. Packages installing startup scripts</a></span></dt>
348: <dt><span class="sect2"><a href="#tex-packages">17.6.16. Packages installing TeX modules</a></span></dt>
349: <dt><span class="sect2"><a href="#emulation-packages">17.6.17. Packages supporting running binaries in
350: emulation</a></span></dt>
351: <dt><span class="sect2"><a href="#hicolor-theme">17.6.18. Packages installing hicolor theme icons</a></span></dt>
352: <dt><span class="sect2"><a href="#desktop-files">17.6.19. Packages installing desktop files</a></span></dt>
1.77 rillig 353: </dl></dd>
1.87 wiz 354: <dt><span class="sect1"><a href="#punting">17.7. Marking packages as having problems</a></span></dt>
1.77 rillig 355: </dl></dd>
356: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
357: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
358: <dd><dl>
359: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
360: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
361: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
362: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
363: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
364: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 365: </dl></dd>
1.77 rillig 366: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.85 jmmv 367: <dt><span class="chapter"><a href="#gnome">21. GNOME packaging and porting</a></span></dt>
368: <dd><dl>
369: <dt><span class="sect1"><a href="#meta-packages">21.1. Meta packages</a></span></dt>
370: <dt><span class="sect1"><a href="#new-package">21.2. Packaging a GNOME application</a></span></dt>
371: <dt><span class="sect1"><a href="#full-update">21.3. Updating GNOME to a newer version</a></span></dt>
372: <dt><span class="sect1"><a href="#patching">21.4. Patching guidelines</a></span></dt>
373: </dl></dd>
1.75 rillig 374: </dl></dd>
375: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
376: <dd><dl>
1.85 jmmv 377: <dt><span class="chapter"><a href="#infr.design">22. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 378: <dd><dl>
1.85 jmmv 379: <dt><span class="sect1"><a href="#infr.vardef">22.1. The meaning of variable definitions</a></span></dt>
380: <dt><span class="sect1"><a href="#infr.vardef.problems">22.2. Avoiding problems before they arise</a></span></dt>
381: <dt><span class="sect1"><a href="#infr.var">22.3. Variable evaluation</a></span></dt>
1.81 rillig 382: <dd><dl>
1.85 jmmv 383: <dt><span class="sect2"><a href="#infr.var.load">22.3.1. At load time</a></span></dt>
384: <dt><span class="sect2"><a href="#infr.var.run">22.3.2. At runtime</a></span></dt>
1.81 rillig 385: </dl></dd>
1.85 jmmv 386: <dt><span class="sect1"><a href="#infr.varspec">22.4. How can variables be specified?</a></span></dt>
387: <dt><span class="sect1"><a href="#infr.design.intf">22.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 388: <dd><dl>
1.85 jmmv 389: <dt><span class="sect2"><a href="#infr.design.intf.proc">22.5.1. Procedures with parameters</a></span></dt>
390: <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 391: </dl></dd>
1.85 jmmv 392: <dt><span class="sect1"><a href="#infr.order">22.6. The order in which files are loaded</a></span></dt>
1.75 rillig 393: <dd><dl>
1.85 jmmv 394: <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>
395: <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 396: </dl></dd>
397: </dl></dd>
1.85 jmmv 398: <dt><span class="chapter"><a href="#regression">23. Regression tests</a></span></dt>
1.75 rillig 399: <dd><dl>
1.85 jmmv 400: <dt><span class="sect1"><a href="#regression.descr">23.1. The regression tests framework</a></span></dt>
401: <dt><span class="sect1"><a href="#regression.run">23.2. Running the regression tests</a></span></dt>
402: <dt><span class="sect1"><a href="#regression.new">23.3. Adding a new regression test</a></span></dt>
1.75 rillig 403: <dd><dl>
1.85 jmmv 404: <dt><span class="sect2"><a href="#regression.fun.override">23.3.1. Overridable functions</a></span></dt>
405: <dt><span class="sect2"><a href="#regression.fun.helper">23.3.2. Helper functions</a></span></dt>
1.75 rillig 406: </dl></dd>
407: </dl></dd>
1.85 jmmv 408: <dt><span class="chapter"><a href="#porting">24. Porting pkgsrc</a></span></dt>
1.75 rillig 409: <dd><dl>
1.85 jmmv 410: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
411: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 412: </dl></dd>
413: </dl></dd>
414: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
415: <dd><dl>
416: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
417: <dd><dl>
418: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
419: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
420: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
421: <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>
422: </dl></dd>
423: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
424: </dl></dd>
425: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
426: <dd><dl>
427: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
428: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
429: </dl></dd>
1.76 rillig 430: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
431: <dd><dl>
432: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
433: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
434: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
435: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
436: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
437: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
438: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
439: source packages</a></span></dt>
440: </dl></dd>
1.75 rillig 441: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
442: <dd><dl>
1.79 rillig 443: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75 rillig 444: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
445: </dl></dd>
446: </dl>
447: </div>
1.82 rillig 448: <div class="list-of-tables">
449: <p><b>List of Tables</b></p>
450: <dl>
451: <dt>1.1. <a href="#supported-platforms">Platforms supported by pkgsrc</a>
452: </dt>
453: <dt>3.1. <a href="#binary-kits">Binary kits and available packages</a>
454: </dt>
1.85 jmmv 455: <dt>9.1. <a href="#patch-examples">Patching examples</a>
456: </dt>
457: <dt>21.1. <a href="#plist-handling">PLIST handling for GNOME packages</a>
458: </dt>
1.82 rillig 459: </dl>
460: </div>
1.75 rillig 461: <div class="chapter" lang="en">
462: <div class="titlepage"><div><div><h2 class="title">
463: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
464: <div class="toc">
465: <p><b>Table of Contents</b></p>
466: <dl>
467: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
1.82 rillig 468: <dd><dl>
469: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
470: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
471: </dl></dd>
1.75 rillig 472: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
473: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.88 wiz 474: <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 475: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
476: </dl>
477: </div>
478: <div class="sect1" lang="en">
479: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
480: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
1.82 rillig 481: <p>There is a lot of software freely available for Unix-based
482: systems, which is usually available in form of the source code. Before
483: such software can be used, it needs to be configured to the local
484: system, compiled and installed, and this is exactly what The NetBSD
485: Packages Collection (pkgsrc) does. pkgsrc also has some basic commands
486: to handle binary packages, so that not every user has to build the
487: packages for himself, which is a time-costly task.</p>
1.75 rillig 488: <p>pkgsrc currently contains several thousand packages,
489: including:</p>
490: <div class="itemizedlist"><ul type="disc">
1.76 rillig 491: <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 492: web server</p></li>
1.83 wiz 493: <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 494: web browser</p></li>
1.76 rillig 495: <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 496: Desktop Environment</p></li>
1.76 rillig 497: <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 498: Desktop Environment</p></li>
499: </ul></div>
500: <p>...just to name a few.</p>
501: <p>pkgsrc has built-in support for handling varying dependencies,
502: such as pthreads and X11, and extended features such as IPv6 support on
503: a range of platforms.</p>
1.82 rillig 504: <div class="sect2" lang="en">
505: <div class="titlepage"><div><div><h3 class="title">
506: <a name="why-pkgsrc"></a>1.1.1. Why pkgsrc?</h3></div></div></div>
507: <p>
508: pkgsrc provides the following key features:
509: </p>
510: <div class="itemizedlist"><ul type="disc">
511: <li><p>Easy building of software from source as well as the creation
512: and installation of binary packages. The source and latest
513: patches are retrieved from a master or mirror download site, checksum
514: verified, then built on your system. Support for binary-only
515: distributions is available for both native platforms and NetBSD
516: emulated platforms.</p></li>
517: <li><p>All packages are installed in a consistent directory tree,
518: including binaries, libraries, man pages and other
519: documentation.</p></li>
520: <li><p>Package dependencies, including when performing package updates,
521: are handled automatically. The configuration files of various
522: packages are handled automatically during updates, so local changes
523: are preserved.</p></li>
524: <li><p>Like NetBSD, pkgsrc is designed with portability in mind and
525: consists of highly portable code. This allows the greatest speed of
526: development when porting to new a platform. This portability also
527: ensures that pkgsrc is <span class="emphasis"><em>consistent across all
528: platforms</em></span>.</p></li>
529: <li><p>The installation prefix, acceptable software licenses,
530: international encryption requirements and build-time options for a
531: large number of packages are all set in a simple, central
532: configuration file.</p></li>
533: <li><p>The entire source (not including the distribution files) is
534: freely available under a BSD license, so you may extend and adapt
535: pkgsrc to your needs. Support for local packages and patches is
536: available right out of the box, so you can configure it specifically
537: for your environment.</p></li>
538: </ul></div>
539: </div>
540: <div class="sect2" lang="en">
541: <div class="titlepage"><div><div><h3 class="title">
542: <a name="intro.platforms"></a>1.1.2. Supported platforms</h3></div></div></div>
543: <p>pkgsrc consists of both a source distribution and a binary
544: distribution for these operating systems. After retrieving the required
545: source or binaries, you can be up and running with pkgsrc in just
546: minutes!</p>
1.75 rillig 547: <p>pkgsrc was derived from FreeBSD's ports system, and
548: initially developed for NetBSD only. Since then, pkgsrc has
549: grown a lot, and now supports the following platforms:</p>
1.82 rillig 550: <div class="table">
551: <a name="supported-platforms"></a><p class="title"><b>Table 1.1. Platforms supported by pkgsrc</b></p>
1.89 ! rillig 552: <table summary="Platforms supported by pkgsrc" border="1">
1.82 rillig 553: <colgroup>
554: <col>
555: <col>
556: </colgroup>
557: <thead><tr>
558: <th>Platform</th>
559: <th>Date Support Added</th>
560: </tr></thead>
561: <tbody>
562: <tr>
563: <td><a href="http://www.NetBSD.org/" target="_top">NetBSD</a></td>
564: <td align="center">Aug 1997</td>
565: </tr>
566: <tr>
567: <td><a href="http://wwws.sun.com/software/solaris/" target="_top">Solaris</a></td>
568: <td align="center">Mar 1999</td>
569: </tr>
570: <tr>
571: <td><a href="http://www.kernel.org/" target="_top">Linux</a></td>
572: <td align="center">Jun 1999</td>
573: </tr>
574: <tr>
575: <td>
576: <a href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
577: (<a href="http://developer.apple.com/macosx/" target="_top">Mac OS X</a>)
578: </td>
579: <td align="center">Oct 2001</td>
580: </tr>
581: <tr>
582: <td><a href="http://www.freebsd.org/" target="_top">FreeBSD</a></td>
583: <td align="center">Nov 2002</td>
584: </tr>
585: <tr>
586: <td><a href="http://www.openbsd.org/" target="_top">OpenBSD</a></td>
587: <td align="center">Nov 2002</td>
588: </tr>
589: <tr>
590: <td><a href="http://www.sgi.com/software/irix/" target="_top">IRIX</a></td>
591: <td align="center">Dec 2002</td>
592: </tr>
593: <tr>
594: <td>BSD/OS</td>
595: <td align="center">Dec 2003</td>
596: </tr>
597: <tr>
598: <td><a href="http://www-1.ibm.com/servers/aix/" target="_top">AIX</a></td>
599: <td align="center">Dec 2003</td>
600: </tr>
601: <tr>
602: <td>
603: <a href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a>
604: (Microsoft Windows Services for Unix)
605: </td>
606: <td align="center">Mar 2004</td>
607: </tr>
608: <tr>
609: <td><a href="http://www.dragonflybsd.org/" target="_top">DragonFlyBSD</a></td>
610: <td align="center">Oct 2004</td>
611: </tr>
612: <tr>
613: <td><a href="http://www.tru64.org/" target="_top">OSF/1</a></td>
614: <td align="center">Nov 2004</td>
615: </tr>
616: </tbody>
1.89 ! rillig 617: </table>
1.82 rillig 618: </div>
619: </div>
1.75 rillig 620: </div>
621: <div class="sect1" lang="en">
622: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
623: <a name="overview"></a>1.2. Overview</h2></div></div></div>
624: <p>This document is divided into three parts. The first,
625: <a href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
626: describes how one can use one of the packages in the Package
627: Collection, either by installing a precompiled binary package,
628: or by building one's own copy using the NetBSD package system.
629: 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
630: package so it can be easily built by other NetBSD users without
631: knowing about the package's building details. The third part,
632: <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
633: is intended for those who want to understand how pkgsrc is
634: implemented.</p>
635: <p>This document is available in various formats:
636: <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>
637: </div>
638: <div class="sect1" lang="en">
639: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
640: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
641: <p>There has been a lot of talk about “<span class="quote">ports</span>”,
642: “<span class="quote">packages</span>”, etc. so far. Here is a description of all the
643: terminology used within this document.</p>
644: <div class="variablelist"><dl>
645: <dt><span class="term">Package</span></dt>
646: <dd><p>A set of files and building instructions
647: that describe what's necessary
648: to build a certain piece of software using
649: pkgsrc. Packages are traditionally stored under
1.76 rillig 650: <code class="filename">/usr/pkgsrc</code>.</p></dd>
1.75 rillig 651: <dt><span class="term">The NetBSD package system</span></dt>
1.87 wiz 652: <dd><p>This is the former name of “<span class="quote">pkgsrc</span>”. It
653: is part of the NetBSD operating system and can be bootstrapped
654: to run on non-NetBSD operating systems as well. It handles
655: building (compiling), installing, and removing of
656: packages.</p></dd>
1.75 rillig 657: <dt><span class="term">Distfile</span></dt>
658: <dd><p>This term describes the file or files that are
659: provided by the author of the piece of software to
660: distribute his work. All the changes necessary to build on
661: NetBSD are reflected in the corresponding package. Usually
662: the distfile is in the form of a compressed tar-archive,
663: but other types are possible, too. Distfiles are usually
664: stored below
1.76 rillig 665: <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
1.75 rillig 666: <dt><span class="term">Port</span></dt>
667: <dd><p>This is the term used by FreeBSD and OpenBSD people
668: for what we call a package.
669: In NetBSD terminology, “<span class="quote">port</span>” refers to a different
670: architecture.</p></dd>
671: <dt><span class="term">Precompiled/binary package</span></dt>
672: <dd>
673: <p>A set of binaries built with pkgsrc from a distfile
1.76 rillig 674: and stuffed together in a single <code class="filename">.tgz</code>
1.75 rillig 675: file so it can be installed on machines of the same
676: machine architecture without the need to
677: recompile. Packages are usually generated in
1.76 rillig 678: <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.75 rillig 679: an archive on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
680: <p>Sometimes, this is referred to by the term “<span class="quote">package</span>” too,
681: especially in the context of precompiled packages.</p>
682: </dd>
683: <dt><span class="term">Program</span></dt>
1.88 wiz 684: <dd><p>The piece of software to be installed which will be
685: constructed from all the files in the distfile by the
686: actions defined in the corresponding package.</p></dd>
1.75 rillig 687: </dl></div>
688: <div class="sect2" lang="en">
689: <div class="titlepage"><div><div><h3 class="title">
1.88 wiz 690: <a name="term.roles"></a>1.3.1. Roles involved in pkgsrc</h3></div></div></div>
1.75 rillig 691: <div class="variablelist"><dl>
692: <dt><span class="term">pkgsrc users</span></dt>
693: <dd>
694: <p>The
695: pkgsrc users are people who use the packages provided by pkgsrc.
696: Typically they are system administrators. The people using the
697: software that is inside the packages (maybe called “<span class="quote">end
698: users</span>”) are not covered by the pkgsrc guide.</p>
699: <p>There are two kinds of pkgsrc users: Some only want to
700: install pre-built binary packages. Others build the pkgsrc
701: packages from source, either for installing them directly or for
702: 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
703: documentation.</p>
704: </dd>
705: <dt><span class="term">package maintainers</span></dt>
706: <dd><p>A
707: 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>
708: <dt><span class="term">infrastructure developers</span></dt>
709: <dd><p>These people are involved in all those files
1.76 rillig 710: that live in the <code class="filename">mk/</code> directory and below.
1.75 rillig 711: 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,
712: too.</p></dd>
713: </dl></div>
714: </div>
715: </div>
716: <div class="sect1" lang="en">
717: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
718: <a name="typography"></a>1.4. Typography</h2></div></div></div>
719: <p>When giving examples for commands, shell prompts are used to
720: show if the command should/can be issued as root, or if
721: “<span class="quote">normal</span>” user privileges are sufficient. We use a
722: <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
723: shell prompt, assuming they use the C-shell or tcsh.</p>
724: </div>
725: </div>
726: <div class="part" lang="en">
727: <div class="titlepage"><div><div><h1 class="title">
728: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
729: <div class="toc">
730: <p><b>Table of Contents</b></p>
731: <dl>
732: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
733: <dd><dl>
734: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
735: <dd><dl>
736: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
737: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
738: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
739: </dl></dd>
740: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
741: <dd><dl>
742: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
743: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
744: </dl></dd>
745: </dl></dd>
746: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
747: <dd><dl>
1.82 rillig 748: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
749: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
750: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
751: <dd><dl>
752: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
753: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
754: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
755: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
756: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
757: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
758: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75 rillig 759: </dl></dd>
760: </dl></dd>
761: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
762: <dd><dl>
763: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
764: <dd><dl>
765: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
766: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82 rillig 767: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
768: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
769: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
770: <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>
771: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
772: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75 rillig 773: </dl></dd>
774: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
775: <dd><dl>
776: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
777: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
778: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
779: </dl></dd>
780: </dl></dd>
781: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
782: <dd><dl>
783: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
784: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 785: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
1.88 wiz 786: <dd><dl>
1.89 ! rillig 787: <dt><span class="sect2"><a href="#selecting-the-compiler">5.3.1. Selecting the compiler</a></span></dt>
! 788: <dt><span class="sect2"><a href="#conf.cflags">5.3.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
! 789: <dt><span class="sect2"><a href="#conf.ldflags">5.3.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
1.88 wiz 790: </dl></dd>
1.78 rillig 791: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
792: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 793: </dl></dd>
794: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
795: <dd><dl>
796: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
797: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
798: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
799: <dd><dl>
800: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
801: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
802: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
803: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
804: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
805: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
806: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
807: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
808: </dl></dd>
809: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
810: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
811: </dl></dd>
812: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
813: <dd><dl>
814: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
815: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
816: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
817: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
818: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
819: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
820: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
821: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
822: <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>
823: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
824: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
825: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
826: <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>
827: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
828: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
829: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
830: <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 831: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.89 ! rillig 832: <dt><span class="sect1"><a href="#faq.rcs-conflicts">7.18. What does “<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>” mean?</a></span></dt>
! 833: <dt><span class="sect1"><a href="#too-much-time">7.19. I have a little time to kill. What shall I do?</a></span></dt>
1.75 rillig 834: </dl></dd>
835: </dl>
836: </div>
837: <div class="chapter" lang="en">
838: <div class="titlepage"><div><div><h2 class="title">
839: <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
840: <div class="toc">
841: <p><b>Table of Contents</b></p>
842: <dl>
843: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
844: <dd><dl>
845: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
846: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
847: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
848: </dl></dd>
849: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
850: <dd><dl>
851: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
852: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
853: </dl></dd>
854: </dl>
855: </div>
856: <p>The most common location where pkgsrc is installed is
1.76 rillig 857: <code class="filename">/usr/pkgsrc</code> for the “<span class="quote">package
858: sources</span>” and <code class="filename">/usr/pkg</code> for the
1.75 rillig 859: installed binary packages. You are though free to install the
860: sources and binary packages wherever you want in your
861: filesystem, provided that both paths do not contain white-space
862: or other characters that are interpreted specially by the shell
863: and some other programs. A safe bet is to use only letters,
864: digits, underscores and dashes in the names.</p>
865: <div class="sect1" lang="en">
866: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
867: <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
868: <p>Before you download any pkgsrc files, you should decide
869: whether you want the <span class="emphasis"><em>current</em></span> branch or the
870: <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
871: quarterly basis from the current branch and only gets modified
872: for security updates. The names of the stable branches are built
873: from the year and the quarter, for example
874: <code class="literal">2006Q1</code>.</p>
875: <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
876: want to download pkgsrc. You can get it as a tar file, via SUP,
877: or via CVS. All three ways are described here.</p>
878: <div class="sect2" lang="en">
879: <div class="titlepage"><div><div><h3 class="title">
880: <a name="getting-via-tar"></a>2.1.1. As tar file</h3></div></div></div>
881: <p>The primary download location for all pkgsrc files is
882: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>. There are a
883: number of subdirectories for different purposes, which are
1.76 rillig 884: 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 885: <p>The tar file for the current branch is in the directory
1.76 rillig 886: <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 887: It is autogenerated daily.</p>
888: <p>The tar file for the stable branch 2006Q1 is in the
1.76 rillig 889: 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 890: <p>After downloading the tar file, change to the directory
891: where you want to have pkgsrc. This is usually
1.76 rillig 892: <code class="filename">/usr</code>. Then, run <span><strong class="command">tar xfz
1.75 rillig 893: pkgsrc.tar.gz</strong></span> to extract the files.</p>
894: </div>
895: <div class="sect2" lang="en">
896: <div class="titlepage"><div><div><h3 class="title">
897: <a name="getting-via-sup"></a>2.1.2. Via SUP</h3></div></div></div>
898: <p>As an alternative to the tar file, you can get pkgsrc via
899: the Software Update Protocol, SUP. To do so, make sure your
900: supfile has a line
1.1 grant 901:
1.75 rillig 902: </p>
903: <pre class="programlisting">
1.51 rillig 904: release=pkgsrc
1.1 grant 905: </pre>
1.75 rillig 906: <p>
1.1 grant 907:
1.75 rillig 908: in it, see the examples in
1.76 rillig 909: <code class="filename">/usr/share/examples/supfiles</code>, and that the
910: <code class="filename">/usr/pkgsrc</code> directory exists. Then, simply
1.75 rillig 911: run <span><strong class="command">sup -v
912: <em class="replaceable"><code>/path/to/your/supfile</code></em></strong></span>.</p>
913: </div>
914: <div class="sect2" lang="en">
915: <div class="titlepage"><div><div><h3 class="title">
916: <a name="getting-via-cvs"></a>2.1.3. Via CVS</h3></div></div></div>
917: <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>
918: installed. To do an initial (full) checkout of pkgsrc, you first
919: have to set some environment variables. For the C-Shell,
920: type:</p>
921: <pre class="screen">
922: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
923: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVS_RSH ssh</code></strong>
924: </pre>
925: <p>Or, the same for the bourne shell:</p>
926: <pre class="screen">
927: <code class="prompt">$</code> <strong class="userinput"><code>CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"</code></strong>
928: <code class="prompt">$</code> <strong class="userinput"><code>CVS_RSH="ssh"</code></strong>
929: <code class="prompt">$</code> <strong class="userinput"><code>export CVSROOT CVS_RSH</code></strong>
930: </pre>
931: <p>Then, you change to the directory where you want to have
932: your copy of pkgsrc. In most cases this is
1.76 rillig 933: <code class="filename">/usr</code>. In that directory you run the
1.75 rillig 934: checkout command, which is <span><strong class="command">cvs -q checkout -P
935: pkgsrc</strong></span> for the current branch and <span><strong class="command">cvs -q
936: checkout -rpkgsrc-2006Q1 -P pkgsrc</strong></span> for the stable
937: branch. This command will create a directory called
1.76 rillig 938: <code class="filename">pkgsrc</code> with all the pkgsrc files in
1.75 rillig 939: it.</p>
940: </div>
941: </div>
942: <div class="sect1" lang="en">
943: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
944: <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
945: <p>The preferred way to keep pkgsrc up-to-date is via CVS
946: (which also works if you have first installed it via a tar
947: file). It saves bandwidth and hard disk activity, compared to
948: downloading the tar file again.</p>
949: <div class="sect2" lang="en">
950: <div class="titlepage"><div><div><h3 class="title">
951: <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
952: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
953: <h3 class="title">Warning</h3>
1.77 rillig 954: <p>When updating from a tar file, you first need to
955: completely remove the old pkgsrc directory. Otherwise those
956: files that have been removed from pkgsrc in the mean time will
957: not be removed on your local disk, resulting in inconsistencies.
958: When removing the old files, any changes that you have done to
959: the pkgsrc files will be lost after updating. Therefore updating
960: via CVS is strongly recommended.</p>
1.75 rillig 961: </div>
1.82 rillig 962: <p>Note that by default the distfiles and the binary packages
963: are saved in the pkgsrc tree, so don't forget to rescue them
964: before updating. You can also configure pkgsrc to use other than
965: the default directories by setting the
966: <code class="varname">DISTDIR</code> and <code class="varname">PACKAGES</code>
967: variables. See <a href="#configuring" title="Chapter 5. Configuring pkgsrc">Chapter 5, <i>Configuring pkgsrc</i></a> for the details.</p>
1.75 rillig 968: <p>To update pkgsrc from a tar file, download the tar file as
969: explained above. Then, make sure that you have not made any
970: changes to the files in the pkgsrc directory. Remove the pkgsrc
971: directory and extract the new tar file. Done.</p>
972: </div>
973: <div class="sect2" lang="en">
974: <div class="titlepage"><div><div><h3 class="title">
975: <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
976: <p>To update pkgsrc via CVS, make sure the environment
977: variable <code class="varname">CVS_RSH</code> is set as above. Then,
978: change to the pkgsrc directory and run <span><strong class="command">cvs -q update
1.77 rillig 979: -dP</strong></span>.</p>
1.75 rillig 980: <div class="sect3" lang="en">
981: <div class="titlepage"><div><div><h4 class="title">
982: <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
983: <p>When updating pkgsrc, the CVS program keeps track of the
984: branch you selected. But if you, for whatever reason, want to
985: switch from the stable branch to the current one, you can do it
986: by adding the option “<span class="quote">-A</span>” after the
987: “<span class="quote">update</span>” keyword. To switch from the current branch
988: back to the stable branch, add the
989: “<span class="quote">-rpkgsrc-2006Q1</span>” option.</p>
990: </div>
991: <div class="sect3" lang="en">
992: <div class="titlepage"><div><div><h4 class="title">
993: <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
994: <p>When you update pkgsrc, the CVS program will only touch
995: those files that are registered in the CVS repository. That
996: means that any packages that you created on your own will stay
997: unmodified. If you change files that are managed by CVS, later
998: updates will try to merge your changes with those that have been
999: done by others. See the CVS manual, chapter
1000: “<span class="quote">update</span>” for details.</p>
1001: </div>
1002: </div>
1003: </div>
1004: </div>
1005: <div class="chapter" lang="en">
1006: <div class="titlepage"><div><div><h2 class="title">
1007: <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
1008: <div class="toc">
1009: <p><b>Table of Contents</b></p>
1010: <dl>
1.82 rillig 1011: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
1012: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
1013: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
1014: <dd><dl>
1015: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
1016: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
1017: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
1018: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
1019: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
1020: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
1021: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75 rillig 1022: </dl></dd>
1023: </dl>
1024: </div>
1025: <div class="sect1" lang="en">
1026: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82 rillig 1027: <a name="binarydist"></a>3.1. Binary distribution</h2></div></div></div>
1028: <p>
1029: We provide a bootstrap kit in both source and binary form for other
1030: platforms than NetBSD, consisting of the pkg administration tools and other
1031: tools required to use pkgsrc and build packages.
1032: </p>
1033: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1034: <h3 class="title">Note</h3>
1035: <p>
1036: Older binary snapshots are available in the
1037: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/archive/" target="_top">bootstrap-pkgsrc/archive</a>
1038: directory on ftp.NetBSD.org.</p>
1039: </div>
1040: <div class="table">
1041: <a name="binary-kits"></a><p class="title"><b>Table 3.1. Binary kits and available packages</b></p>
1.89 ! rillig 1042: <table summary="Binary kits and available packages" border="1">
1.82 rillig 1043: <colgroup>
1044: <col>
1045: <col>
1046: <col>
1047: <col>
1048: </colgroup>
1049: <thead><tr>
1050: <th>Platform</th>
1051: <th>Latest snapshot</th>
1052: <th>Binary kit</th>
1053: <th>Binary packages</th>
1054: </tr></thead>
1055: <tbody>
1056: <tr>
1057: <td class="osname">Darwin 5.5/powerpc (Mac OS X 10.1.5)</td>
1058: <td class="date">20021209</td>
1059: <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>
1060: <td class="binary-pkgs-url"> </td>
1061: </tr>
1062: <tr>
1063: <td class="osname">Darwin 6.6/powerpc (Mac OS X 10.2.6)</td>
1064: <td class="date">20030623</td>
1065: <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>
1066: <td class="binary-pkgs-url"> </td>
1067: </tr>
1068: <tr>
1069: <td class="osname">Darwin 7.6/powerpc (Mac OS X 10.3.6)</td>
1070: <td class="date">20041219</td>
1071: <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>
1072: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/Darwin-7.6/" target="_top">binary packages</a></td>
1073: </tr>
1074: <tr>
1075: <td class="osname">Darwin 7.8/powerpc (Mac OS X 10.3.8)</td>
1076: <td class="date">20050320</td>
1077: <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>
1078: <td class="binary-pkgs-url"> </td>
1079: </tr>
1080: <tr>
1081: <td class="osname">Darwin 8.1/powerpc (Mac OS X 10.4.1)</td>
1082: <td class="date">20050625</td>
1083: <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>
1084: <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>
1085: </tr>
1086: <tr>
1087: <td class="osname">Debian GNU Linux/i386</td>
1088: <td class="date">20031023</td>
1089: <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>
1090: <td class="binary-pkgs-url"> </td>
1091: </tr>
1092: <tr>
1093: <td class="osname">Fedora Core 2 Linux/i386</td>
1094: <td class="date">20050618</td>
1095: <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>
1096: <td class="binary-pkgs-url"> </td>
1097: </tr>
1098: <tr>
1099: <td class="osname">Fedora Core 4 Linux/i386</td>
1100: <td class="date">20060105</td>
1101: <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>
1102: <td class="binary-pkgs-url"> </td>
1103: </tr>
1104: <tr>
1105: <td class="osname">FreeBSD 3.5/i386</td>
1106: <td class="date">20030411</td>
1107: <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>
1108: <td class="binary-pkgs-url"> </td>
1109: </tr>
1110: <tr>
1111: <td class="osname">FreeBSD 4.7/i386</td>
1112: <td class="date">20021211</td>
1113: <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>
1114: <td class="binary-pkgs-url"> </td>
1115: </tr>
1116: <tr>
1117: <td class="osname">FreeBSD 5.0/i386</td>
1118: <td class="date">20030411</td>
1119: <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>
1120: <td class="binary-pkgs-url"> </td>
1121: </tr>
1122: <tr>
1123: <td class="osname">FreeBSD 5.1/i386</td>
1124: <td class="date">20030630</td>
1125: <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>
1126: <td class="binary-pkgs-url"> </td>
1127: </tr>
1128: <tr>
1129: <td class="osname">FreeBSD 5.2.1/i386</td>
1130: <td class="date">20040227</td>
1131: <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>
1132: <td class="binary-pkgs-url"> </td>
1133: </tr>
1134: <tr>
1135: <td class="osname">FreeBSD 5.3/i386</td>
1136: <td class="date">20050119</td>
1137: <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>
1138: <td class="binary-pkgs-url"> </td>
1139: </tr>
1140: <tr>
1141: <td class="osname">Interix 3.5</td>
1142: <td class="date">20051010</td>
1143: <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>
1144: <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>
1145: </tr>
1146: <tr>
1147: <td class="osname">IRIX 6.5 n32-bit ABI</td>
1148: <td class="date">20040911</td>
1149: <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>
1150: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/n32/" target="_top">binary packages</a></td>
1151: </tr>
1152: <tr>
1153: <td class="osname">IRIX 6.5 64-bit ABI</td>
1154: <td class="date">20040912</td>
1155: <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>
1156: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/64/" target="_top">binary packages</a></td>
1157: </tr>
1158: <tr>
1159: <td class="osname">OpenBSD 3.2/i386</td>
1160: <td class="date">20030420</td>
1161: <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>
1162: <td class="binary-pkgs-url"> </td>
1163: </tr>
1164: <tr>
1165: <td class="osname">OpenBSD 3.3/i386</td>
1166: <td class="date">20030503</td>
1167: <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>
1168: <td class="binary-pkgs-url"> </td>
1169: </tr>
1170: <tr>
1171: <td class="osname">OpenBSD 3.5/i386</td>
1172: <td class="date">20040507</td>
1173: <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>
1174: <td class="binary-pkgs-url"> </td>
1175: </tr>
1176: <tr>
1177: <td class="osname">Slackware Linux 8.1/i386</td>
1178: <td class="date">20030417</td>
1179: <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>
1180: <td class="binary-pkgs-url"> </td>
1181: </tr>
1182: <tr>
1183: <td class="osname">Slackware Linux 9/i386</td>
1184: <td class="date">20031023</td>
1185: <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>
1186: <td class="binary-pkgs-url"> </td>
1187: </tr>
1188: <tr>
1189: <td class="osname">Solaris 8/sparc</td>
1190: <td class="date">20050220</td>
1191: <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>
1192: <td class="binary-pkgs-url"> </td>
1193: </tr>
1194: <tr>
1195: <td class="osname">Solaris 8/i386</td>
1196: <td class="date">20050220</td>
1197: <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>
1198: <td class="binary-pkgs-url"> </td>
1199: </tr>
1200: <tr>
1201: <td class="osname">Solaris 9/sparc</td>
1202: <td class="date">20041208</td>
1203: <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>
1204: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/SunOS-5.9/sparc/" target="_top">binary packages</a></td>
1205: </tr>
1206: <tr>
1207: <td class="osname">Solaris 9/i386</td>
1208: <td class="date">20030411</td>
1209: <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>
1210: <td class="binary-pkgs-url"> </td>
1211: </tr>
1212: </tbody>
1.89 ! rillig 1213: </table>
1.82 rillig 1214: </div>
1.89 ! rillig 1215: <p>
1.82 rillig 1216: Simply download the binary kit for your platform, and extract it into
1217: <code class="filename">/</code> e.g.
1218: </p>
1219: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
1220: <code class="prompt">#</code> <strong class="userinput"><code>gzip -c -d /tmp/bootstrap-pkgsrc-SunOS-5.9-sparc-20031023.tar.gz \
1221: | tar -xpf -</code></strong></pre>
1222: <p>
1223: Of course, as with any binary distributions, you should verify the
1224: checksum against the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/SUM" target="_top">SUM</a>
1225: or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/CKSUM" target="_top">CKSUM</a>
1226: file and inspect the contents before extracting it.
1227: </p>
1228: </div>
1229: <div class="sect1" lang="en">
1230: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1231: <a name="bootstrapping-pkgsrc"></a>3.2. Bootstrapping pkgsrc</h2></div></div></div>
1232: <p>Installing the bootstrap kit from source should be as simple as:</p>
1.75 rillig 1233: <pre class="screen">
1234: <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
1235: <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1.87 wiz 1236: <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong>
1237: </pre>
1.75 rillig 1238: <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 1239: pkgsrc before bootstrapping. The given
1240: <span><strong class="command">bootstrap</strong></span> command will use the defaults of
1241: <code class="filename">/usr/pkg</code> for the
1242: <span class="emphasis"><em>prefix</em></span> where programs will be installed in,
1243: and <code class="filename">/var/db/pkg</code> for the package database
1244: directory where pkgsrc will do its internal bookkeeping.
1245: However, these can also be set using command-line
1246: arguments.</p>
1.75 rillig 1247: <p>Binary packages for the pkgsrc tools and an initial set of packages is
1.87 wiz 1248: available for supported platforms. An up-to-date list of these can be
1249: found on <a href="http://www.pkgsrc.org/" target="_top">www.pkgsrc.org</a>.
1250: Note that this only works for privileged builds that install
1251: into <code class="filename">/usr/pkg</code>.</p>
1.75 rillig 1252: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1253: <h3 class="title">Note</h3>
1254: <p>The bootstrap installs a <span><strong class="command">bmake</strong></span> tool.
1.87 wiz 1255: Use this <span><strong class="command">bmake</strong></span> when building via pkgsrc.
1256: For examples in this guide, use <span><strong class="command">bmake</strong></span>
1257: instead of “<span class="quote">make</span>”.</p>
1.75 rillig 1258: </div>
1259: </div>
1260: <div class="sect1" lang="en">
1261: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82 rillig 1262: <a name="platform-specific-notes"></a>3.3. Platform-specific notes</h2></div></div></div>
1.75 rillig 1263: <p>Here are some platform-specific notes you should be aware of.</p>
1264: <div class="sect2" lang="en">
1265: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1266: <a name="darwin"></a>3.3.1. Darwin (Mac OS X)</h3></div></div></div>
1.85 jmmv 1267: <p>Darwin 5.x and up are supported. There are two methods of using
1.82 rillig 1268: pkgsrc on Mac OS X, by using a <a href="#platform.osx-image" title="3.3.1.1. Using a disk image">disk
1.89 ! rillig 1269: image</a>, or a <a href="#platform.osx-part" title="3.3.1.2. Using a UFS or HFSX partition">UFS or HFSX
1.75 rillig 1270: partition</a>.</p>
1271: <p>Before you start, you will need to download and install the Mac OS X Developer
1.87 wiz 1272: Tools from Apple's Developer Connection. See <a href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
1273: for details. Also, make sure you install X11 for Mac OS X and the X11 SDK
1274: from <a href="http://www.apple.com/macosx/x11/download/" target="_top">http://www.apple.com/macosx/x11/download/</a>
1275: if you intend to build packages that use the X11 Window System.</p>
1.89 ! rillig 1276: <p>If you already have a UFS or HFSX partition, or have a spare partition
! 1277: that you can format as UFS or HFSX, it is recommended to use that instead of
1.87 wiz 1278: the disk image. It'll be somewhat faster and will mount automatically
1279: at boot time, where you must manually mount a disk image.</p>
1.75 rillig 1280: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1281: <h3 class="title">Note</h3>
1.85 jmmv 1282: <p>You cannot use an ordinary HFS+ file system for pkgsrc, because pkgsrc currently
1.89 ! rillig 1283: requires the file system to be case-sensitive. You can, however, use a case-sensitive HFS+ (aka HFSX) file system as found in Darwin 7.0 and newer.</p>
1.75 rillig 1284: </div>
1285: <div class="sect3" lang="en">
1286: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1287: <a name="platform.osx-image"></a>3.3.1.1. Using a disk image</h4></div></div></div>
1.75 rillig 1288: <p>Create the disk image:</p>
1289: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1.85 jmmv 1290: <code class="prompt">#</code> <strong class="userinput"><code>./darwindiskimage create ~/Documents/NetBSD 512</code></strong> # megabytes - season to taste
1291: <code class="prompt">#</code> <strong class="userinput"><code>./darwindiskimage mount ~/Documents/NetBSD</code></strong>
1.75 rillig 1292: <code class="prompt">#</code> <strong class="userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong></pre>
1.85 jmmv 1293: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1294: <h3 class="title">Note</h3>
1.89 ! rillig 1295: <p>darwindiskimage will mount the filesystem nosuid, which will cause problems for packages that depend on setgid. In the case of UFS, it will also mount the filesystem asynchronous, which is somewhat dangerous according to the mount(8) man page. In the case of HFSX, it will disable journalling.</p>
1.85 jmmv 1296: </div>
1.89 ! rillig 1297: <p>Allow suid:</p>
! 1298: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sudo mount -u -o suid /Volumes/NetBSD</code></strong></pre>
1.75 rillig 1299: </div>
1300: <div class="sect3" lang="en">
1301: <div class="titlepage"><div><div><h4 class="title">
1.89 ! rillig 1302: <a name="platform.osx-part"></a>3.3.1.2. Using a UFS or HFSX partition</h4></div></div></div>
1.76 rillig 1303: <p>By default, <code class="filename">/usr</code> will be on your root file
1.87 wiz 1304: system, normally HFS+. It is possible to use the default
1305: <span class="emphasis"><em>prefix</em></span> of <code class="filename">/usr/pkg</code>
1306: by symlinking <code class="filename">/usr/pkg</code> to a directory on a UFS
1.89 ! rillig 1307: or HFSX file system. Obviously, another symlink is required if you want to
1.87 wiz 1308: place the package database directory outside the
1309: <span class="emphasis"><em>prefix</em></span>. e.g.</p>
1.75 rillig 1310: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb</code></strong></pre>
1311: <p>If you created your partitions at the time of installing Mac OS X
1.89 ! rillig 1312: and formatted the target partition as UFS or HFSX, it should automatically
1.87 wiz 1313: mount on <code class="filename">/Volumes/<volume name></code> when the
1.89 ! rillig 1314: machine boots. If you are (re)formatting a partition as UFS or HFSX, you need
1.87 wiz 1315: to ensure that the partition map correctly reflects
1.89 ! rillig 1316: “<span class="quote">Apple_UFS</span>” or “<span class="quote">Apple_HFSX</span>” and not “<span class="quote">Apple_HFS</span>”.</p>
1.75 rillig 1317: <p>The problem is that none of the disk tools will let you touch a
1.87 wiz 1318: disk that is booted from. You can unmount the partition, but even if
1319: you newfs it, the partition type will be incorrect and the
1320: automounter won't mount it. It can be mounted manually, but it won't
1321: appear in Finder.</p>
1.75 rillig 1322: <p>You'll need to boot off of the OS X Installation (User) CD. When
1.87 wiz 1323: the Installation program starts, go up to the menu and select Disk
1324: Utility. Now, you will be able to select the partition you want
1.89 ! rillig 1325: to be UFS or HFSX, and Format it Apple UFS or HFSX. Quit the Disk Utility, quit the
! 1326: installer which will reboot your machine. The new UFS or HFSX file system
1.87 wiz 1327: will appear in Finder.</p>
1.75 rillig 1328: <p>Be aware that the permissions on the new file system will be writable
1.87 wiz 1329: by root only.</p>
1.75 rillig 1330: <p>This note is as of 10.2 (Jaguar) and applies to earlier versions.
1.87 wiz 1331: Hopefully Apple will fix Disk Utility in 10.3 (Panther).</p>
1.75 rillig 1332: </div>
1333: </div>
1334: <div class="sect2" lang="en">
1335: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1336: <a name="freebsd"></a>3.3.2. FreeBSD</h3></div></div></div>
1.87 wiz 1337: <p>FreeBSD 4.7 and 5.0 have been tested and are supported,
1338: other versions may work.</p>
1.75 rillig 1339: <p>Care should be taken so that the tools that this kit installs do not conflict
1.87 wiz 1340: with the FreeBSD userland tools. There are several steps:</p>
1.75 rillig 1341: <div class="orderedlist"><ol type="1">
1342: <li><p>FreeBSD stores its ports pkg database in
1.87 wiz 1343: <code class="filename">/var/db/pkg</code>. It is therefore
1344: recommended that you choose a different location (e.g.
1345: <code class="filename">/usr/pkgdb</code>) by
1346: using the --pkgdbdir option to the bootstrap script.</p></li>
1.75 rillig 1347: <li>
1348: <p>If you do not intend to use the FreeBSD ports tools, it's probably a
1.87 wiz 1349: good idea to move them out of the way to avoid confusion, e.g.</p>
1350: <pre class="screen">
1351: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1.75 rillig 1352: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1353: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1354: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1.87 wiz 1355: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong>
1356: </pre>
1.75 rillig 1357: </li>
1.76 rillig 1358: <li><p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1.87 wiz 1359: <code class="filename">/etc/mk.conf.example</code> file
1360: when you use the bootstrap script.</p></li>
1.75 rillig 1361: </ol></div>
1362: </div>
1363: <div class="sect2" lang="en">
1364: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1365: <a name="interix"></a>3.3.3. Interix</h3></div></div></div>
1.75 rillig 1366: <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
1.87 wiz 1367: providing a Unix-like environment with a tighter kernel integration than
1368: available with Cygwin. It is part of the Windows Services for Unix
1369: package, available for free for any licensed copy of Windows 2000, XP
1370: (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 1371: <p>Services for Unix 3.5, current as of this writing, has been tested. 3.0
1.87 wiz 1372: or 3.1 may work, but are not officially supported. (The main difference
1373: in 3.0/3.1 is lack of pthreads.)</p>
1.75 rillig 1374: <div class="sect3" lang="en">
1375: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1376: <a name="platform.interix-sfu-install"></a>3.3.3.1. When installing Interix/SFU</h4></div></div></div>
1.75 rillig 1377: <p>At an absolute minimum, the following packages must be installed from
1.87 wiz 1378: the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
1.75 rillig 1379: <div class="itemizedlist"><ul type="disc">
1380: <li><p>Utilities -> Base Utilities</p></li>
1381: <li><p>Interix GNU Components -> (all)</p></li>
1382: <li><p>Remote Connectivity</p></li>
1383: <li><p>Interix SDK</p></li>
1384: </ul></div>
1385: <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
1.87 wiz 1386: "UNIX Perl". That is Perl 5.6 without shared module support, installed to
1387: /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
1388: pkgsrc (or from a binary package).</p>
1.75 rillig 1389: <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
1.87 wiz 1390: not need to be installed, but Remote Connectivity itself should be
1391: installed in order to have a working inetd.</p>
1.75 rillig 1392: <p>During installation you may be asked whether to enable setuid
1.87 wiz 1393: behavior for Interix programs, and whether to make pathnames default to
1394: case-sensitive. Setuid should be enabled, and case-sensitivity MUST be
1395: enabled. (Without case-sensitivity, a large number of packages including
1396: perl will not build.)</p>
1.75 rillig 1397: <p>NOTE: Newer Windows service packs change the way binary execution
1.87 wiz 1398: works (via the Data Execution Prevention feature). In order to use
1399: pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
1400: POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
1401: must be installed. Hotfixes are available from Microsoft through a
1402: support contract; however, a NetBSD developer has made most Interix
1403: 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 1404: </div>
1405: <div class="sect3" lang="en">
1406: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1407: <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 1408: <p>If SFU is already installed and you wish to alter these settings to work
1.87 wiz 1409: with pkgsrc, note the following things.</p>
1.75 rillig 1410: <div class="itemizedlist"><ul type="disc">
1411: <li><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
1.87 wiz 1412: Windows Services for UNIX, then click Change. In the installer, choose
1413: Add or Remove, then uncheck Utilities->UNIX Perl.</p></li>
1.75 rillig 1414: <li>
1415: <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
1.87 wiz 1416: change the following registry key:</p>
1.75 rillig 1417: <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
1418: <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
1419: </li>
1420: <li>
1421: <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
1.87 wiz 1422: following registry key:</p>
1.75 rillig 1423: <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
1424: <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
1425: </li>
1426: </ul></div>
1427: </div>
1428: <div class="sect3" lang="en">
1429: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1430: <a name="platform.interix-notes"></a>3.3.3.3. Important notes for using pkgsrc</h4></div></div></div>
1.75 rillig 1431: <p>The package manager (either the pkgsrc "su" user, or the user
1.87 wiz 1432: running "pkg_add") must be a member of the local Administrators
1433: group. Such a user must also be used to run the bootstrap. This is
1434: slightly relaxed from the normal pkgsrc requirement of "root".</p>
1.75 rillig 1435: <p>The package manager should use a umask of 002. "make install" will
1.87 wiz 1436: automatically complain if this is not the case. This ensures that
1437: directories written in /var/db/pkg are Administrators-group writeable.</p>
1.75 rillig 1438: <p>The popular Interix binary packages from http://www.interopsystems.com/
1.87 wiz 1439: use an older version of pkgsrc's pkg_* tools. Ideally, these should
1440: NOT be used in conjunction with pkgsrc. If you choose to use them at
1441: the same time as the pkgsrc packages, ensure that you use the proper
1442: pkg_* tools for each type of binary package.</p>
1.75 rillig 1443: <p>The TERM setting used for DOS-type console windows (including those
1.87 wiz 1444: invoked by the csh and ksh startup shortcuts) is "interix". Most systems
1445: don't have a termcap/terminfo entry for it, but the following .termcap
1446: entry provides adequate emulation in most cases:</p>
1.75 rillig 1447: <pre class="programlisting">
1.87 wiz 1448: interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
1449: </pre>
1.75 rillig 1450: </div>
1451: <div class="sect3" lang="en">
1452: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1453: <a name="platform.interix-limits"></a>3.3.3.4. Limitations of the Interix platform</h4></div></div></div>
1.75 rillig 1454: <p>Though Interix suffices as a familiar and flexible substitute
1.87 wiz 1455: for a full Unix-like platform, it has some drawbacks that should
1456: be noted for those desiring to make the most of Interix.</p>
1.75 rillig 1457: <div class="itemizedlist"><ul type="disc">
1458: <li>
1459: <p><span class="strong"><strong>X11:</strong></span></p>
1460: <p>Interix comes with the standard set of X11R6 client libraries,
1.87 wiz 1461: and can run X11 based applications, but it does
1462: <span class="emphasis"><em>not</em></span> come with an X server. Some options are
1463: <a href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
1464: <a href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
1465: (available in a trimmed version for Interix from Interop Systems as the
1466: <a href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
1467: and the free X11 server included with
1468: <a href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
1.75 rillig 1469: <p>Also, StarNet Communications has graciously provided a free
1.87 wiz 1470: version of their X-Win32 product that accepts connections only
1471: from localhost:
1472: <a href="http://www.starnet.com/xwin32LX/get_xwin32LX.htm" target="_top">X-Win32 LX</a>,
1473: recommended by the maintainer of Interix pkgsrc support.</p>
1.75 rillig 1474: </li>
1475: <li>
1476: <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
1477: <p>Because Interix runs in a completely different NT subsystem from
1.87 wiz 1478: Win32 applications, it does not currently support various X11
1479: protocol extensions for acceleration (such as MIT-SHM or DGA).
1480: Most interactive applications to a local X server will run
1481: reasonably fast, but full motion video and other graphics
1482: intensive applications may require a faster-than-expected CPU.</p>
1.75 rillig 1483: </li>
1484: <li>
1485: <p><span class="strong"><strong>Audio:</strong></span></p>
1486: <p>Interix has no native support for audio output. For audio
1.87 wiz 1487: support, pkgsrc uses the <span><strong class="command">esound</strong></span> client/server
1488: audio system on Interix. Unlike on most platforms, the
1489: <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
1490: <span class="emphasis"><em>not</em></span> contain the <span><strong class="command">esd</strong></span>
1491: server component. To output audio via an Interix host, the
1492: <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
1493: must also be installed.</p>
1.75 rillig 1494: </li>
1495: <li>
1496: <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
1497: <p>Direct device access is not currently supported in Interix, so it
1.87 wiz 1498: is not currently possible to access CD/DVD drives, USB devices,
1499: or SCSI devices through non-filesystem means. Among other things,
1500: this makes it impossible to use Interix directly for CD/DVD
1501: burning.</p>
1.75 rillig 1502: </li>
1503: <li>
1504: <p><span class="strong"><strong>Tape drives:</strong></span></p>
1505: <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
1.87 wiz 1506: drives are also not directly accessible in Interix. However,
1507: support is in work to make tape drive access possible by using
1508: Cygwin as a bridge (similarly to audio bridged via Cygwin's
1509: esound server).</p>
1.75 rillig 1510: </li>
1511: </ul></div>
1512: </div>
1513: <div class="sect3" lang="en">
1514: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1515: <a name="platform.interix-knownissues"></a>3.3.3.5. Known issues for pkgsrc on Interix</h4></div></div></div>
1.75 rillig 1516: <p>It is not necessary, in general, to have a "root" user on the
1.87 wiz 1517: Windows system; any member of the local Administrators group will
1518: suffice. However, some packages currently assume that the user
1519: named "root" is the privileged user. To accommodate these, you
1520: may create such a user; make sure it is in the local group
1521: Administrators (or your language equivalent).</p>
1522: <p><span><strong class="command">pkg_add</strong></span> creates directories of mode
1523: 0755, not 0775, in <code class="filename">$PKG_DBDIR</code>. For the
1524: time being, install packages as the local Administrator (or
1525: your language equivalent), or run the following command after
1526: installing a package to work around the issue:</p>
1.75 rillig 1527: <pre class="screen">
1.87 wiz 1528: <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong>
1529: </pre>
1.75 rillig 1530: </div>
1531: </div>
1532: <div class="sect2" lang="en">
1533: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1534: <a name="irix"></a>3.3.4. IRIX</h3></div></div></div>
1.75 rillig 1535: <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
1.87 wiz 1536: compiler (cc/c89). Please set the <code class="varname">CC</code> environment variable
1537: according to your preference. If you do not have a license for the MIPSpro
1538: 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 1539: <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
1.87 wiz 1540: 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>,
1541: etc.</p>
1.86 schwarz 1542: <p>At this point in time, pkgsrc only supports one ABI at a time. That is, you cannot
1.75 rillig 1543: switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI. If
1544: you start out using "abi=n32", that's what all your packages will be built
1545: with.</p>
1546: <p>Therefore, please make sure that you have no conflicting
1.87 wiz 1547: <code class="varname">CFLAGS</code> in your environment or the
1548: <code class="filename">/etc/mk.conf</code>. Particularly, make sure that you do not
1549: try to link n32 object files with lib64 or vice versa. Check your
1550: <code class="filename">/etc/compiler.defaults</code>!</p>
1.75 rillig 1551: <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
1.87 wiz 1552: please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
1553: as it appears that IRIX linker occasionally runs into issues when trying to
1554: link over a network-mounted file system.</p>
1.75 rillig 1555: <p>The bootstrapping process should set all the right options for programs such
1.87 wiz 1556: as imake(1), but you may want to set some options depending on your local
1557: setup. Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
1558: course, your compiler's man pages for details.</p>
1.75 rillig 1559: <p>If you are using SGI's MIPSPro compiler, please set
1.1 grant 1560:
1.87 wiz 1561: </p>
1.75 rillig 1562: <pre class="programlisting">
1.87 wiz 1563: PKGSRC_COMPILER= mipspro
1564: </pre>
1.75 rillig 1565: <p>
1.1 grant 1566:
1.87 wiz 1567: in <code class="filename">/etc/mk.conf</code>. Otherwise, pkgsrc will assume you
1568: are using gcc and may end up passing invalid flags to the compiler. Note that
1569: bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
1570: default.</p>
1.75 rillig 1571: <p>If you have both the MIPSPro compiler chain installed as well as gcc,
1.87 wiz 1572: but want to make sure that MIPRPro is used, please set your <code class="varname">PATH</code>
1573: to <span class="emphasis"><em>not</em></span> include the location of gcc (often
1574: <code class="filename">/usr/freeware/bin</code>), and (important) pass the
1575: '--preserve-path' flag.</p>
1.75 rillig 1576: </div>
1577: <div class="sect2" lang="en">
1578: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1579: <a name="linux"></a>3.3.5. Linux</h3></div></div></div>
1.87 wiz 1580: <p>Some versions of Linux (for example Debian GNU/Linux) need
1581: either libtermcap or libcurses (libncurses). Installing the
1582: distributions libncurses-dev package (or equivalent) should fix
1583: the problem.</p>
1584: <p>pkgsrc supports both gcc (GNU Compiler Collection) and icc
1585: (Intel C++ Compiler). gcc is the default. icc 8.0 and 8.1 on
1586: i386 have been tested.</p>
1.75 rillig 1587: <p>To bootstrap using icc, assuming the default icc installation
1.87 wiz 1588: directory:</p>
1.75 rillig 1589: <pre class="programlisting">
1.87 wiz 1590: env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
1591: ac_cv___attribute__=yes ./bootstrap
1592: </pre>
1.75 rillig 1593: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1594: <h3 class="title">Note</h3>
1595: <p>icc 8.1 needs the `-i-static' argument instead of -static-libcxa.</p>
1596: </div>
1597: <p>icc supports __attribute__, but the GNU configure test uses a nested
1.87 wiz 1598: function, which icc does not support. #undef'ing __attribute__ has the
1599: unfortunate side-effect of breaking many of the Linux header files, which
1600: cannot be compiled properly without __attribute__. The test must be
1601: overridden so that __attribute__ is assumed supported by the
1602: compiler.</p>
1.75 rillig 1603: <p>After bootstrapping, you should set <code class="varname">PKGSRC_COMPILER</code>
1.87 wiz 1604: in <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1605: <pre class="programlisting">
1.87 wiz 1606: PKGSRC_COMPILER= icc
1607: </pre>
1.75 rillig 1608: <p>The default installation directory for icc is
1.87 wiz 1609: <code class="filename">/opt/intel_cc_80</code>, which
1610: is also the pkgsrc default. If you have installed it into a different
1611: directory, set <code class="varname">ICCBASE</code> in
1612: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1613: <pre class="programlisting">
1.87 wiz 1614: ICCBASE= /opt/icc
1615: </pre>
1.75 rillig 1616: <p>pkgsrc uses the static linking method of the runtime libraries
1.87 wiz 1617: provided by icc, so binaries can be run on other systems which do not
1618: have the shared libraries installed.</p>
1619: <p>Libtool, however, extracts a list of libraries from the
1620: <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
1621: records it, throwing away the -Bstatic and -Bdynamic options
1622: interspersed between the libraries. This means that
1623: libtool-linked C++ shared libraries will have a runtime
1624: dependency on the icc libraries until this is fixed in
1625: libtool.</p>
1.75 rillig 1626: </div>
1627: <div class="sect2" lang="en">
1628: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1629: <a name="openbsd"></a>3.3.6. OpenBSD</h3></div></div></div>
1.75 rillig 1630: <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
1631: <p>Care should be taken so that the tools that this kit installs do not conflict
1.87 wiz 1632: with the OpenBSD userland tools. There are several steps:</p>
1.75 rillig 1633: <div class="orderedlist"><ol type="1">
1634: <li><p>OpenBSD stores its ports pkg database in
1.87 wiz 1635: <code class="filename">/var/db/pkg</code>. It is therefore
1636: recommended that you choose a different location (e.g.
1637: <code class="filename">/usr/pkgdb</code>) by
1638: using the --pkgdbdir option to the bootstrap script.</p></li>
1.75 rillig 1639: <li>
1640: <p>If you do not intend to use the OpenBSD ports tools, it's probably a
1.87 wiz 1641: good idea to move them out of the way to avoid confusion, e.g.</p>
1642: <pre class="screen">
1643: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1.75 rillig 1644: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1645: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1646: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1.87 wiz 1647: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong>
1648: </pre>
1.75 rillig 1649: </li>
1650: <li>
1.76 rillig 1651: <p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1.87 wiz 1652: <code class="filename">/etc/mk.conf.example</code> file
1653: when you use the bootstrap script. OpenBSD's make program uses
1654: <code class="filename">/etc/mk.conf</code>
1655: as well. You can work around this by enclosing all the pkgsrc-specific parts
1656: of the file with:</p>
1657: <pre class="programlisting">
1658: .ifdef BSD_PKG_MK
1659: # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
1660: .else
1661: # OpenBSD stuff
1662: .endif
1663: </pre>
1.75 rillig 1664: </li>
1665: </ol></div>
1666: </div>
1667: <div class="sect2" lang="en">
1668: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1669: <a name="solaris"></a>3.3.7. Solaris</h3></div></div></div>
1.75 rillig 1670: <p>Solaris 2.6 through 9 are supported on both x86 and sparc.
1.87 wiz 1671: You will need a working C compiler. Both gcc 2.95.3 and
1672: Sun WorkShop 5 have been tested.</p>
1.75 rillig 1673: <p>The following packages are required on Solaris 8 for the bootstrap
1.87 wiz 1674: process and to build packages.</p>
1.75 rillig 1675: <div class="itemizedlist"><ul type="disc">
1676: <li><p>SUNWsprot</p></li>
1677: <li><p>SUNWarc</p></li>
1678: <li><p>SUNWbtool</p></li>
1679: <li><p>SUNWtoo</p></li>
1680: <li><p>SUNWlibm</p></li>
1681: </ul></div>
1.78 rillig 1682: <p>Please note that the use of GNU binutils on Solaris is
1.87 wiz 1683: <span class="emphasis"><em>not</em></span> supported, as of June 2006.</p>
1.75 rillig 1684: <p>Whichever compiler you use, please ensure the compiler tools and
1.87 wiz 1685: your $prefix are in your <code class="varname">PATH</code>. This includes
1686: <code class="filename">/usr/ccs/{bin,lib}</code>
1687: and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1.75 rillig 1688: <div class="sect3" lang="en">
1689: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1690: <a name="solaris-gcc-note"></a>3.3.7.1. If you are using gcc</h4></div></div></div>
1.75 rillig 1691: <p>It makes life much simpler if you only use the same gcc consistently
1.87 wiz 1692: for building all packages.</p>
1.75 rillig 1693: <p>It is recommended that an external gcc be used only for bootstrapping,
1.87 wiz 1694: then either build gcc from
1695: <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
1696: package, then remove gcc used during bootstrapping.</p>
1.75 rillig 1697: <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>
1698: </div>
1699: <div class="sect3" lang="en">
1700: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1701: <a name="solaris-sun-workshop-note"></a>3.3.7.2. If you are using Sun WorkShop</h4></div></div></div>
1.75 rillig 1702: <p>You will need at least the following packages installed (from WorkShop
1.87 wiz 1703: 5.0)</p>
1.75 rillig 1704: <div class="itemizedlist"><ul type="disc">
1705: <li><p>SPROcc
1.87 wiz 1706: - Sun WorkShop Compiler C 5.0</p></li>
1.75 rillig 1707: <li><p>SPROcpl
1.87 wiz 1708: - Sun WorkShop Compiler C++ 5.0</p></li>
1.75 rillig 1709: <li><p>SPROild
1.87 wiz 1710: - Sun WorkShop Incremental Linker</p></li>
1.75 rillig 1711: <li><p>SPROlang
1.87 wiz 1712: - Sun WorkShop Compilers common components</p></li>
1.75 rillig 1713: </ul></div>
1714: <p>You should set <code class="varname">CC</code>, <code class="varname">CXX</code> and
1.87 wiz 1715: optionally, <code class="varname">CPP</code> in <code class="filename">/etc/mk.conf</code>,
1716: e.g.:</p>
1.75 rillig 1717: <pre class="programlisting">
1.87 wiz 1718: CC= cc
1719: CXX= CC
1720: CPP= /usr/ccs/lib/cpp
1721: </pre>
1.75 rillig 1722: </div>
1723: <div class="sect3" lang="en">
1724: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1725: <a name="solaris-sunpro-64"></a>3.3.7.3. Buildling 64-bit binaries with SunPro</h4></div></div></div>
1.75 rillig 1726: <p>Building 64-bit binaries is a little trickier. First, you
1727: need to bootstrap pkgsrc in 64-bit mode. One problem here is
1728: that while building one of the programs in the bootstrap kit
1.76 rillig 1729: (<code class="filename">bmake</code>), the <code class="varname">CFLAGS</code>
1.75 rillig 1730: variable is not honored, even if it is set in the environment.
1731: To work around this bug, you can create a simple shell script
1.76 rillig 1732: called <code class="filename">cc64</code> and put it somewhere in the
1.75 rillig 1733: <code class="varname">PATH</code>:</p>
1734: <pre class="programlisting">
1.87 wiz 1735: #! /bin/sh
1736: exec /opt/SUNWspro/bin/cc -xtarget=ultra -xarch=v9 ${1+"$@"}
1737: </pre>
1.75 rillig 1738: <p>Then, pass the definition for <code class="varname">CC</code> in the
1739: environment of the <span><strong class="command">bootstrap</strong></span> command:</p>
1740: <pre class="programlisting">
1.87 wiz 1741: <code class="prompt">$</code> <strong class="userinput"><code>cd bootstrap</code></strong>
1742: <code class="prompt">$</code> <strong class="userinput"><code>CC=cc64 ./bootstrap</code></strong>
1743: </pre>
1.75 rillig 1744: <p>After bootstrapping, there are two alternative ways,
1745: depending on whether you want to find bugs in packages or get
1746: your system ready quickly. If you just want a running system,
1.76 rillig 1747: add the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1748: file:</p>
1749: <pre class="programlisting">
1.87 wiz 1750: CC= cc64
1751: CXX= CC64
1752: PKGSRC_COMPILER= sunpro
1753: </pre>
1.75 rillig 1754: <p>This way, all calls to the compiler will be intercepted by
1755: the above wrapper and therefore get the necessary ABI options
1756: automatically. (Don't forget to create the shell script
1.76 rillig 1757: <code class="filename">CC64</code>, too.)</p>
1.75 rillig 1758: <p>To find packages that ignore the user-specified
1759: <code class="varname">CFLAGS</code> and <code class="varname">CXXFLAGS</code>, add
1.76 rillig 1760: the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1761: file:</p>
1762: <pre class="programlisting">
1.87 wiz 1763: CC= cc
1764: CXX= CC
1765: PKGSRC_COMPILER= sunpro
1766: CFLAGS= -xtarget=ultra -xarch=v9
1767: CXXFLAGS= -xtarget=ultra -xarch=v9
1768: LDFLAGS= -xtarget=ultra -xarch=v9
1769: </pre>
1.75 rillig 1770: <p>Packages that don't use the flags provided in the
1771: configuration file will try to build 32-bit binaries and fail
1772: during linking. Detecting this is useful to prevent bugs on
1773: other platforms where the error would not show up but pass
1774: silently.</p>
1775: </div>
1776: <div class="sect3" lang="en">
1777: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1778: <a name="plat.sunos.problems"></a>3.3.7.4. Common problems</h4></div></div></div>
1.75 rillig 1779: <p>Sometimes, when using <span><strong class="command">libtool</strong></span>,
1.87 wiz 1780: <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
1781: The workaround is to use another shell for the configure
1782: 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
1783: to your <code class="filename">mk.conf</code>:</p>
1784: <pre class="programlisting">
1785: CONFIG_SHELL= ${LOCALBASE}/bin/bash
1786: WRAPPER_SHELL= ${LOCALBASE}/bin/bash
1787: </pre>
1.76 rillig 1788: <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 1789: </div>
1790: </div>
1791: </div>
1792: </div>
1793: <div class="chapter" lang="en">
1794: <div class="titlepage"><div><div><h2 class="title">
1795: <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
1796: <div class="toc">
1797: <p><b>Table of Contents</b></p>
1798: <dl>
1799: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
1800: <dd><dl>
1801: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
1802: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82 rillig 1803: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
1804: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
1805: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
1806: <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>
1807: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
1808: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75 rillig 1809: </dl></dd>
1810: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
1811: <dd><dl>
1812: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
1813: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
1814: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
1815: </dl></dd>
1816: </dl>
1817: </div>
1818: <p>Basically, there are two ways of using pkgsrc. The first
1.88 wiz 1819: is to only install the package tools and to use binary packages
1820: that someone else has prepared. This is the “<span class="quote">pkg</span>”
1821: in pkgsrc. The second way is to install the “<span class="quote">src</span>”
1822: of pkgsrc, too. Then you are able to build your own packages,
1823: and you can still use binary packages from someone else.</p>
1.75 rillig 1824: <div class="sect1" lang="en">
1825: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1826: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
1827: <p>To use binary packages, you need some tools to manage
1.88 wiz 1828: them. On NetBSD, these tools are already installed. On all other
1829: operating systems, you need to install them first. For the
1830: following platforms, prebuilt versions of the package tools
1831: are available and can simply be downloaded and unpacked in the
1832: <code class="filename">/</code> directory:</p>
1.75 rillig 1833: <div class="informaltable">
1834: <a name="binary-bootstrap-kits"></a><table border="1">
1835: <colgroup>
1836: <col>
1837: <col>
1838: </colgroup>
1839: <thead><tr>
1840: <th>Platform</th>
1841: <th>URL</th>
1842: </tr></thead>
1843: <tbody>
1844: <tr>
1845: <td>Solaris 9</td>
1.76 rillig 1846: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1847: </tr>
1848: <tr>
1849: <td>Solaris 10</td>
1.76 rillig 1850: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1851: </tr>
1852: </tbody>
1853: </table>
1854: </div>
1.82 rillig 1855: <p>These pre-built package tools use
1.88 wiz 1856: <code class="filename">/usr/pkg</code> for the base directory, and
1857: <code class="filename">/var/db/pkg</code> for the database of installed
1858: packages. If you cannot use these directories for whatever
1859: reasons (maybe because you're not root), you have to build the
1860: 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 1861: <div class="sect2" lang="en">
1862: <div class="titlepage"><div><div><h3 class="title">
1863: <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
1864: <p>To install binary packages, you first need to know from
1.88 wiz 1865: where to get them. You can get them on CD-ROMs, DVDs, or via FTP
1866: or HTTP.</p>
1.81 rillig 1867: <p>The binary packages can be found at the following
1.88 wiz 1868: locations.</p>
1.75 rillig 1869: <div class="informaltable">
1870: <a name="binary-packages"></a><table border="1">
1871: <colgroup>
1872: <col>
1873: <col>
1874: </colgroup>
1875: <thead><tr>
1876: <th>Platform</th>
1877: <th>URL</th>
1878: </tr></thead>
1879: <tbody>
1880: <tr>
1.81 rillig 1881: <td>NetBSD</td>
1882: <td><code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/</code></td>
1883: </tr>
1884: <tr>
1.75 rillig 1885: <td>Solaris 9</td>
1.76 rillig 1886: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/</code></td>
1.75 rillig 1887: </tr>
1888: <tr>
1889: <td>Solaris 10</td>
1.76 rillig 1890: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/</code></td>
1.75 rillig 1891: </tr>
1892: </tbody>
1893: </table>
1894: </div>
1.81 rillig 1895: <p>Most of these directories contain binary packages for
1.88 wiz 1896: multiple platforms. Select the appropriate subdirectories,
1897: according to your machine architecture and operating system,
1898: until you find a directory called <code class="filename">All</code>. This
1899: directory contains all the binary packages. Further, there are
1900: subdirectories for categories that contain symbolic links that
1901: point to the actual binary package in
1902: <code class="filename">../All</code>. This directory layout is used for
1903: all package repositories, no matter if they are accessed via
1904: HTTP, FTP, NFS, CD-ROM, or the local filesystem.</p>
1.75 rillig 1905: </div>
1906: <div class="sect2" lang="en">
1907: <div class="titlepage"><div><div><h3 class="title">
1908: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
1.87 wiz 1909: <p>If you have the files on a CD-ROM or downloaded them to
1.88 wiz 1910: your hard disk, you can install them with the following command
1911: (be sure to <span><strong class="command">su</strong></span> to root first):</p>
1.75 rillig 1912: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add /path/to/package.tgz</code></strong></pre>
1.87 wiz 1913: <p>If you have FTP access and you don't want to download the
1.88 wiz 1914: packages via FTP prior to installation, you can do this
1915: automatically by giving <span><strong class="command">pkg_add</strong></span> an FTP URL:</p>
1.82 rillig 1916: <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 1917: <p>Note that any prerequisite packages needed to run the
1.88 wiz 1918: package in question will be installed, too, assuming they are
1919: present where you install from.</p>
1.75 rillig 1920: <p>To save some typing, you can set the
1.88 wiz 1921: <code class="varname">PKG_PATH</code> environment variable to a semicolon-separated
1922: list of paths (including remote URLs); trailing slashes are not allowed.
1923: </p>
1.76 rillig 1924: <p>Additionally to the <code class="filename">All</code> directory
1.88 wiz 1925: there exists a <code class="filename">vulnerable</code> directory to
1926: which binary packages with known vulnerabilities are
1927: moved, since removing them could cause missing dependencies. To
1928: use these packages, add the <code class="filename">vulnerable</code>
1929: directory to your <code class="varname">PKG_PATH</code>. However, you should run
1930: <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,
1931: especially after installing new packages, and verify that the
1932: vulnerabilities are acceptable for your configuration. An example
1933: <code class="varname">PKG_PATH</code> would be:
1934: <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/<OSVERSION>/<ARCH>/All;ftp://ftp.NetBSD.org/pub/NetBSD/packages/<OSVERSION>/<ARCH>/vulnerable</code>
1935: Please note that semicolon (';') is a shell meta-character, so
1936: you'll probably have to quote it.</p>
1.75 rillig 1937: <p>After you've installed packages, be sure to have
1.88 wiz 1938: <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
1939: <code class="varname">PATH</code> so you can actually start the just
1940: installed program.</p>
1.75 rillig 1941: </div>
1942: <div class="sect2" lang="en">
1943: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1944: <a name="using.pkg_delete"></a>4.1.3. Deinstalling packages</h3></div></div></div>
1945: <p>To deinstall a package, it does not matter whether it was
1.88 wiz 1946: installed from source code or from a binary package. The
1947: <span><strong class="command">pkg_delete</strong></span> command does not know it anyway.
1948: To delete a package, you can just run <span><strong class="command">pkg_delete
1949: <em class="replaceable"><code>package-name</code></em></strong></span>. The package
1950: name can be given with or without version number. Wildcards can
1951: also be used to deinstall a set of packages, for example
1952: <code class="literal">*emacs*</code>. Be sure to include them in quotes,
1953: so that the shell does not expand them before
1954: <code class="literal">pkg_delete</code> sees them.</p>
1.82 rillig 1955: <p>The <code class="option">-r</code> option is very powerful: it
1.88 wiz 1956: removes all the packages that require the package in question
1957: and then removes the package itself. For example:
1.82 rillig 1958:
1.88 wiz 1959: </p>
1.82 rillig 1960: <pre class="screen">
1.88 wiz 1961: <code class="prompt">#</code> <strong class="userinput"><code>pkg_delete -r jpeg</code></strong>
1962: </pre>
1.82 rillig 1963: <p>
1964:
1.88 wiz 1965: will remove jpeg and all the packages that used it; this allows
1966: upgrading the jpeg package.</p>
1.82 rillig 1967: </div>
1968: <div class="sect2" lang="en">
1969: <div class="titlepage"><div><div><h3 class="title">
1970: <a name="using.pkg_info"></a>4.1.4. Getting information about installed packages</h3></div></div></div>
1971: <p>The <span><strong class="command">pkg_info</strong></span> shows information about
1.88 wiz 1972: installed packages or binary package files.</p>
1.82 rillig 1973: </div>
1974: <div class="sect2" lang="en">
1975: <div class="titlepage"><div><div><h3 class="title">
1976: <a name="vulnerabilities"></a>4.1.5. Checking for security vulnerabilities in installed packages</h3></div></div></div>
1977: <p>
1.88 wiz 1978: The NetBSD Security-Officer and Packages Groups maintain a list of
1979: known security vulnerabilities to packages which are (or have been)
1980: included in pkgsrc. The list is available from the NetBSD
1981: FTP site at <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities</a>.
1982: </p>
1.82 rillig 1983: <p>
1.88 wiz 1984: 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>,
1985: this list can be downloaded
1986: automatically, and a security audit of all packages installed on a system
1987: can take place.
1988: </p>
1.82 rillig 1989: <p>
1.88 wiz 1990: There are two components to
1991: <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
1992: component, “<span class="quote">download-vulnerability-list</span>”, is for downloading
1993: the list of vulnerabilities from the NetBSD FTP site. The second
1994: component, “<span class="quote">audit-packages</span>”, checks to see if any of your
1995: installed packages are vulnerable. If a package is vulnerable, you
1996: will see output similar to the following:
1997: </p>
1.82 rillig 1998: <pre class="screen">Package samba-2.0.9 has a local-root-shell vulnerability, see
1.88 wiz 1999: http://www.samba.org/samba/whatsnew/macroexploit.html</pre>
1.82 rillig 2000: <p>
1.88 wiz 2001: 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
2002: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">vulnerabilities</a>
2003: file daily, and include a package audit in the daily security script.
2004: 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>
2005: 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>.
2006: </p>
1.82 rillig 2007: </div>
2008: <div class="sect2" lang="en">
2009: <div class="titlepage"><div><div><h3 class="title">
2010: <a name="pkg_versions"></a>4.1.6. Finding if newer versions of your installed packages are in pkgsrc</h3></div></div></div>
2011: <p>
1.88 wiz 2012: 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
2013: <span><strong class="command">lintpkgsrc</strong></span> with the “<span class="quote">-i</span>”
2014: argument to check if your packages are up-to-date, e.g.
2015: </p>
2016: <pre class="screen">
2017: <code class="prompt">%</code> <strong class="userinput"><code>lintpkgsrc -i</code></strong>
1.82 rillig 2018: ...
1.88 wiz 2019: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
2020: </pre>
1.82 rillig 2021: <p>You can then use <span><strong class="command">make update</strong></span> to update the
1.88 wiz 2022: package on your system and rebuild any dependencies.
2023: </p>
1.82 rillig 2024: </div>
2025: <div class="sect2" lang="en">
2026: <div class="titlepage"><div><div><h3 class="title">
2027: <a name="using.pkg_admin"></a>4.1.7. Other administrative functions</h3></div></div></div>
2028: <p>The <span><strong class="command">pkg_admin</strong></span> executes various
1.88 wiz 2029: administrative functions on the package system.</p>
1.82 rillig 2030: </div>
2031: <div class="sect2" lang="en">
2032: <div class="titlepage"><div><div><h3 class="title">
2033: <a name="a-word-of-warning"></a>4.1.8. A word of warning</h3></div></div></div>
1.75 rillig 2034: <p>Please pay very careful attention to the warnings
1.88 wiz 2035: 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
2036: inherent dangers of installing binary packages which you did
2037: not create yourself, and the security holes that can be
2038: introduced onto your system by indiscriminate adding of such
2039: files.</p>
1.75 rillig 2040: <p>The same warning of course applies to every package you
1.88 wiz 2041: install from source when you haven't completely read and
2042: understood the source code of the package, the compiler that
2043: is used to build the package and all the other tools that are
2044: involved.</p>
1.75 rillig 2045: </div>
2046: </div>
2047: <div class="sect1" lang="en">
2048: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2049: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
1.88 wiz 2050: <p>After obtaining pkgsrc, the <code class="filename">pkgsrc</code>
2051: directory now contains a set of packages, organized into
2052: categories. You can browse the online index of packages, or run
2053: <span><strong class="command">make readme</strong></span> from the <code class="filename">pkgsrc</code>
2054: directory to build local <code class="filename">README.html</code> files for
2055: 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>
2056: <p>The default <span class="emphasis"><em>prefix</em></span> for installed packages
2057: is <code class="filename">/usr/pkg</code>. If you wish to change this, you
2058: should do so by setting <code class="varname">LOCALBASE</code> in
2059: <code class="filename">mk.conf</code>. You should not try to use multiple
2060: different <code class="varname">LOCALBASE</code> definitions on the same
2061: system (inside a chroot is an exception). </p>
2062: <p>The rest of this chapter assumes that the package is already
2063: 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
2064: instructions how to create your own packages.</p>
1.75 rillig 2065: <div class="sect2" lang="en">
2066: <div class="titlepage"><div><div><h3 class="title">
2067: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
1.82 rillig 2068: <p>To build packages from source, you need a working C
1.88 wiz 2069: compiler. On NetBSD, you need to install the
2070: “<span class="quote">comp</span>” and the “<span class="quote">text</span>” distribution
2071: sets. If you want to build X11-related packages, the
2072: “<span class="quote">xbase</span>” and “<span class="quote">xcomp</span>” distribution
2073: sets are required, too.</p>
1.75 rillig 2074: </div>
2075: <div class="sect2" lang="en">
2076: <div class="titlepage"><div><div><h3 class="title">
2077: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
2078: <p>The first step for building a package is downloading the
1.88 wiz 2079: distfiles (i.e. the unmodified source). If they have not yet been
2080: downloaded, pkgsrc will fetch them automatically.</p>
2081: <p>If you have all files that you need in the
2082: <code class="filename">distfiles</code> directory,
2083: you don't need to connect. If the distfiles are on CD-ROM, you can
2084: mount the CD-ROM on <code class="filename">/cdrom</code> and add:
2085: </p>
1.82 rillig 2086: <pre class="screen">DISTDIR=/cdrom/pkgsrc/distfiles</pre>
2087: <p>
1.88 wiz 2088: to your <code class="filename">mk.conf</code>.</p>
2089: <p>You can overwrite some of the major distribution sites to
2090: fit to sites that are close to your own. By setting one or two
2091: variables you can modify the order in which the master sites are
2092: accessed. <code class="varname">MASTER_SORT</code> contains a whitespace
2093: delimited list of domain suffixes.
2094: <code class="varname">MASTER_SORT_REGEX</code> is even more flexible, it
2095: contains a whitespace delimited list of regular expressions. It
2096: has higher priority than <code class="varname">MASTER_SORT</code>. Have a
2097: look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find
2098: some examples. This may save some of your bandwidth and
2099: time.</p>
1.75 rillig 2100: <p>You can change these settings either in your shell's environment, or,
1.88 wiz 2101: if you want to keep the settings, by editing the
2102: <code class="filename">/etc/mk.conf</code> file,
2103: and adding the definitions there.</p>
1.82 rillig 2104: <p>
1.88 wiz 2105: If a package depends on many other packages (such as
2106: <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
2107: alternate between periods of
2108: downloading source, and compiling. To ensure you have all the source
2109: downloaded initially you can run the command:
2110: </p>
1.82 rillig 2111: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch-list | sh</code></strong></pre>
2112: <p>
1.88 wiz 2113: which will output and run a set of shell commands to fetch the
2114: necessary files into the <code class="filename">distfiles</code> directory. You can
2115: also choose to download the files manually.
2116: </p>
1.75 rillig 2117: </div>
2118: <div class="sect2" lang="en">
2119: <div class="titlepage"><div><div><h3 class="title">
2120: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
1.82 rillig 2121: <p>
1.88 wiz 2122: Once the software has downloaded, any patches will be applied, then it
2123: will be compiled for you. This may take some time depending on your
2124: computer, and how many other packages the software depends on and their
2125: compile time.
2126: </p>
1.75 rillig 2127: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
2128: <h3 class="title">Note</h3>
2129: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
1.88 wiz 2130: use the pkgsrc <span><strong class="command">bmake</strong></span> command instead of
2131: “<span class="quote">make</span>” in the examples in this guide.</p>
1.75 rillig 2132: </div>
1.87 wiz 2133: <p>For example, type</p>
1.88 wiz 2134: <pre class="screen">
2135: <code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
2136: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
2137: </pre>
1.75 rillig 2138: <p>at the shell prompt to build the various components of the
1.88 wiz 2139: package.</p>
1.82 rillig 2140: <p>The next stage is to actually install the newly compiled
1.88 wiz 2141: program onto your system. Do this by entering:
1.82 rillig 2142:
1.88 wiz 2143: </p>
1.82 rillig 2144: <pre class="screen">
1.88 wiz 2145: <code class="prompt">%</code> <strong class="userinput"><code>make install</code></strong>
2146: </pre>
1.82 rillig 2147: <p>
2148:
1.88 wiz 2149: while you are still in the directory for whatever package you
2150: are installing.</p>
1.82 rillig 2151: <p>Installing the package on your system may require you to
1.88 wiz 2152: be root. However, pkgsrc has a
2153: <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
2154: to only become root for the actual installation step.</p>
1.82 rillig 2155: <p>That's it, the software should now be installed and setup for use.
1.88 wiz 2156: You can now enter:
1.82 rillig 2157:
1.88 wiz 2158: </p>
1.82 rillig 2159: <pre class="screen">
1.88 wiz 2160: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong>
2161: </pre>
1.82 rillig 2162: <p>
2163:
1.88 wiz 2164: to remove the compiled files in the work directory, as you shouldn't need
2165: them any more. If other packages were also added to your system
2166: (dependencies) to allow your program to compile, you can tidy these up
2167: also with the command:</p>
1.82 rillig 2168: <pre class="screen">
1.88 wiz 2169: <code class="prompt">%</code> <strong class="userinput"><code>make clean-depends</code></strong>
2170: </pre>
1.75 rillig 2171: <p>Taking the figlet utility as an example, we can install it on our
1.88 wiz 2172: system by building as shown in <a href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
2173: <p>The program is installed under the default root of the
2174: packages tree - <code class="filename">/usr/pkg</code>. Should this not
2175: conform to your tastes, set the <code class="varname">LOCALBASE</code>
2176: variable in your environment, and it will use that value as the
2177: root of your packages tree. So, to use
2178: <code class="filename">/usr/local</code>, set
2179: <code class="varname">LOCALBASE=/usr/local</code> in your environment.
2180: Please note that you should use a directory which is dedicated to
2181: packages and not shared with other programs (i.e., do not try and
2182: use <code class="varname">LOCALBASE=/usr</code>). Also, you should not try
2183: to add any of your own files or directories (such as
2184: <code class="filename">src/</code>, <code class="filename">obj/</code>, or
2185: <code class="filename">pkgsrc/</code>) below the
2186: <code class="varname">LOCALBASE</code> tree. This is to prevent possible
2187: conflicts between programs and other files installed by the
2188: package system and whatever else may have been installed
2189: there.</p>
2190: <p>Some packages look in <code class="filename">/etc/mk.conf</code> to
2191: alter some configuration options at build time. Have a look at
2192: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to get an overview
2193: of what will be set there by default. Environment variables such
2194: as <code class="varname">LOCALBASE</code> can be set in
2195: <code class="filename">/etc/mk.conf</code> to save having to remember to
2196: set them each time you want to use pkgsrc.</p>
2197: <p>Occasionally, people want to “<span class="quote">look under the
2198: covers</span>” to see what is going on when a package is building
2199: or being installed. This may be for debugging purposes, or out of
2200: simple curiosity. A number of utility values have been added to
2201: help with this.</p>
1.75 rillig 2202: <div class="orderedlist"><ol type="1">
2203: <li>
1.88 wiz 2204: <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
2205: <code class="varname">PKG_DEBUG_LEVEL=2</code>, then a huge amount of
2206: information will be displayed. For example,</p>
1.75 rillig 2207: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
1.88 wiz 2208: <p>will show all the commands that are invoked, up to and
2209: including the “<span class="quote">patch</span>” stage.</p>
1.75 rillig 2210: </li>
2211: <li>
1.88 wiz 2212: <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>
2213: definition, then the <code class="varname">VARNAME</code> definition
2214: should be used, in conjunction with the show-var
2215: 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>
2216: variable <code class="varname">LOCALBASE</code>:</p>
2217: <pre class="screen">
2218: <code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
1.75 rillig 2219: /usr/pkg
2220: <code class="prompt">%</code>
1.88 wiz 2221: </pre>
1.75 rillig 2222: </li>
2223: </ol></div>
2224: <p>If you want to install a binary package that you've either
1.88 wiz 2225: created yourself (see next section), that you put into
2226: pkgsrc/packages manually or that is located on a remote FTP
2227: server, you can use the "bin-install" target. This target will
2228: 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>,
2229: else do a <span><strong class="command">make package</strong></span>. The list of remote FTP
2230: sites searched is kept in the variable
2231: <code class="varname">BINPKG_SITES</code>, which defaults to
2232: 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>
2233: can be put into <code class="varname">BIN_INSTALL_FLAGS</code>. See
2234: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more
2235: details.</p>
2236: <p>A final word of warning: If you set up a system that has a
2237: non-standard setting for <code class="varname">LOCALBASE</code>, be sure to
2238: set that before any packages are installed, as you cannot use
2239: several directories for the same purpose. Doing so will result in
2240: pkgsrc not being able to properly detect your installed packages,
2241: and fail miserably. Note also that precompiled binary packages are
2242: usually built with the default <code class="varname">LOCALBASE</code> of
2243: <code class="filename">/usr/pkg</code>, and that you should
2244: <span class="emphasis"><em>not</em></span> install any if you use a non-standard
2245: <code class="varname">LOCALBASE</code>.</p>
1.75 rillig 2246: </div>
2247: </div>
2248: </div>
2249: <div class="chapter" lang="en">
2250: <div class="titlepage"><div><div><h2 class="title">
2251: <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
2252: <div class="toc">
2253: <p><b>Table of Contents</b></p>
2254: <dl>
2255: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
2256: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 2257: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
1.88 wiz 2258: <dd><dl>
1.89 ! rillig 2259: <dt><span class="sect2"><a href="#selecting-the-compiler">5.3.1. Selecting the compiler</a></span></dt>
! 2260: <dt><span class="sect2"><a href="#conf.cflags">5.3.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
! 2261: <dt><span class="sect2"><a href="#conf.ldflags">5.3.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
1.88 wiz 2262: </dl></dd>
1.78 rillig 2263: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
2264: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 2265: </dl>
2266: </div>
1.89 ! rillig 2267: <p>The whole pkgsrc system is configured in a single file, usually
! 2268: called <code class="filename">mk.conf</code>. In which directory pkgsrc looks for
! 2269: that file depends on the installation. On NetBSD, when you use
! 2270: <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> from the base system, it is in the directory
! 2271: <code class="filename">/etc/</code>. In all other cases the default location is
! 2272: <code class="literal">${PREFIX}/etc/</code>, depending on where you told the
! 2273: bootstrap program to install the binary packages.</p>
! 2274: <p>During the bootstrap, an example configuration file is created. To
! 2275: use that, you have to create the directory
! 2276: <code class="filename">${PREFIX}/etc</code> and copy the example file
! 2277: there.</p>
! 2278: <p>The format of the configuration file is that of the usual
! 2279: BSD-style <code class="filename">Makefile</code>s. The whole pkgsrc configuration
! 2280: is done by setting variables in this file. Note that you can define all
! 2281: kinds of variables, and no special error checking (for example for
! 2282: spelling mistakes) takes place, so you have to try it out to see if it
! 2283: works.</p>
1.75 rillig 2284: <div class="sect1" lang="en">
2285: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2286: <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
2287: <p>In this section, you can find some variables that apply to all
1.89 ! rillig 2288: pkgsrc packages. A complete list of the variables that can be
! 2289: configured by the user is available in
! 2290: <code class="filename">mk/defaults/mk.conf</code>, together with some
! 2291: comments that describe each variable's intent.</p>
1.75 rillig 2292: <div class="itemizedlist"><ul type="disc">
2293: <li><p><code class="varname">LOCALBASE</code>: Where
2294: packages will be installed. The default is
1.76 rillig 2295: <code class="filename">/usr/pkg</code>. Do not mix binary packages
1.75 rillig 2296: with different <code class="varname">LOCALBASE</code>s!</p></li>
2297: <li><p><code class="varname">CROSSBASE</code>: Where
2298: “<span class="quote">cross</span>” category packages will be
2299: installed. The default is
1.76 rillig 2300: <code class="filename">${LOCALBASE}/cross</code>.</p></li>
1.75 rillig 2301: <li><p><code class="varname">X11BASE</code>: Where
2302: X11 is installed on the system. The default is
1.76 rillig 2303: <code class="filename">/usr/X11R6</code>.</p></li>
1.75 rillig 2304: <li><p><code class="varname">DISTDIR</code>: Where to store the
2305: downloaded copies of the original source distributions used
2306: for building pkgsrc packages. The default is
1.76 rillig 2307: <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
1.75 rillig 2308: <li><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
2309: If set, override the packages'
2310: <code class="varname">MASTER_SITES</code> with this value.</p></li>
2311: <li><p><code class="varname">MASTER_SITE_BACKUP</code>:
2312: Backup location(s) for distribution files and patch files
2313: if not found locally or in
1.76 rillig 2314: <code class="filename">${MASTER_SITES}</code> or
2315: <code class="filename">${PATCH_SITES}</code> respectively.
1.75 rillig 2316: The defaults are
1.76 rillig 2317: <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
1.75 rillig 2318: and
1.76 rillig 2319: <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
1.75 rillig 2320: <li><p><code class="varname">BINPKG_SITES</code>:
2321: List of sites carrying binary pkgs.</p></li>
1.82 rillig 2322: <li><p><code class="varname">ACCEPTABLE_LICENSES</code>:
2323: List of acceptable licenses. Whenever you try to build a package
2324: whose license is not in this list, you will get an error message
2325: that includes instructions on how to change this variable.</p></li>
1.75 rillig 2326: </ul></div>
2327: </div>
2328: <div class="sect1" lang="en">
2329: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2330: <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
2331: <p>XXX
2332: </p>
2333: <div class="itemizedlist"><ul type="disc">
2334: <li><p><code class="varname">PACKAGES</code>: The top level
2335: directory for the binary packages. The default is
1.76 rillig 2336: <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
1.75 rillig 2337: <li><p><code class="varname">WRKOBJDIR</code>:
2338: The top level directory where, if defined, the separate
2339: working directories will get created, and symbolically
1.76 rillig 2340: linked to from <code class="filename">${WRKDIR}</code> (see below).
1.75 rillig 2341: This is useful for building packages on several
1.76 rillig 2342: architectures, then <code class="filename">${PKGSRCDIR}</code>
2343: can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
1.75 rillig 2344: is local to every architecture. (It should be noted that
2345: <code class="varname">PKGSRCDIR</code> should not be set by the user
1.89 ! rillig 2346: — it is an internal definition which refers to the
1.75 rillig 2347: root of the pkgsrc tree. It is possible to have many
2348: pkgsrc tree instances.)</p></li>
2349: <li><p><code class="varname">LOCALPATCHES</code>:
2350: Directory for local patches that aren't part of pkgsrc.
1.77 rillig 2351: See <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a> for more
1.75 rillig 2352: information. <em class="replaceable"><code>rel</code></em> and
2353: <em class="replaceable"><code>arch</code></em> are replaced with OS
2354: release (“<span class="quote">2.0</span>”, etc.) and architecture
2355: (“<span class="quote">mipsel</span>”, etc.).</p></li>
2356: <li><p><code class="varname">PKGMAKECONF</code>: Location of
1.76 rillig 2357: the <code class="filename">mk.conf</code> file used by a package's
1.75 rillig 2358: BSD-style Makefile. If this is not set,
2359: <code class="varname">MAKECONF</code> is set to
1.76 rillig 2360: <code class="filename">/dev/null</code> to avoid picking up
2361: settings used by builds in <code class="filename">/usr/src</code>.</p></li>
1.82 rillig 2362: <li><p><code class="varname">DEPENDS_TARGET</code>:
2363: By default, dependencies are only installed, and no binary
2364: package is created for them. You can set this variable to
2365: <code class="literal">package</code> to automatically create binary
2366: packages after installing dependencies.</p></li>
1.75 rillig 2367: </ul></div>
2368: </div>
2369: <div class="sect1" lang="en">
2370: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 2371: <a name="conf.compiler"></a>5.3. Selecting and configuring the compiler</h2></div></div></div>
2372: <div class="sect2" lang="en">
2373: <div class="titlepage"><div><div><h3 class="title">
1.89 ! rillig 2374: <a name="selecting-the-compiler"></a>5.3.1. Selecting the compiler</h3></div></div></div>
! 2375: <p>By default, pkgsrc will use GCC to build packages. This may be
! 2376: overridden by setting the following variables in /etc/mk.conf:</p>
! 2377: <div class="variablelist"><dl>
! 2378: <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
! 2379: <dd>
! 2380: <p>This is a list of values specifying the chain of
! 2381: compilers to invoke when building packages. Valid values
! 2382: are:</p>
! 2383: <div class="itemizedlist"><ul type="disc">
! 2384: <li><p><code class="varname">distcc</code>:
! 2385: distributed C/C++ (chainable)</p></li>
! 2386: <li><p><code class="varname">ccache</code>:
! 2387: compiler cache (chainable)</p></li>
! 2388: <li><p><code class="varname">gcc</code>:
! 2389: GNU C/C++ Compiler</p></li>
! 2390: <li><p><code class="varname">mipspro</code>:
! 2391: Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
! 2392: <li><p><code class="varname">mipspro</code>:
! 2393: Silicon Graphics, Inc. MIPSpro (o32)</p></li>
! 2394: <li><p><code class="varname">sunpro</code>:
! 2395: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
! 2396: </ul></div>
! 2397: <p>The default is
! 2398: “<span class="quote"><code class="varname">gcc</code></span>”. You can use
! 2399: <code class="varname">ccache</code> and/or
! 2400: <code class="varname">distcc</code> with an appropriate
! 2401: <code class="varname">PKGSRC_COMPILER</code> setting,
! 2402: e.g. “<span class="quote"><code class="varname">ccache gcc</code></span>”. This
! 2403: variable should always be
! 2404: terminated with a value for a real compiler.</p>
! 2405: </dd>
! 2406: <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
! 2407: <dd><p>This specifies the minimum version of GCC to use
! 2408: when building packages. If the system GCC doesn't
! 2409: satisfy this requirement, then pkgsrc will build and
! 2410: install one of the GCC packages to use instead.</p></dd>
! 2411: </dl></div>
! 2412: </div>
! 2413: <div class="sect2" lang="en">
! 2414: <div class="titlepage"><div><div><h3 class="title">
! 2415: <a name="conf.cflags"></a>5.3.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</h3></div></div></div>
1.78 rillig 2416: <p>If you wish to set the <code class="varname">CFLAGS</code> variable,
2417: please make sure to use the <code class="literal">+=</code> operator
2418: instead of the <code class="literal">=</code> operator:</p>
2419: <pre class="programlisting">
2420: CFLAGS+= -your -flags
2421: </pre>
2422: <p>Using <code class="varname">CFLAGS=</code> (i.e. without the
2423: “<span class="quote">+</span>”) may lead to problems with packages that need
2424: to add their own flags. Also, you may want to take a look at
2425: 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
2426: you're interested in optimization for the current CPU.</p>
2427: </div>
1.88 wiz 2428: <div class="sect2" lang="en">
2429: <div class="titlepage"><div><div><h3 class="title">
1.89 ! rillig 2430: <a name="conf.ldflags"></a>5.3.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</h3></div></div></div>
1.88 wiz 2431: <p>If you want to pass flags to the linker, both in the configure
2432: step and the build step, you can do this in two ways. Either set
2433: <code class="varname">LDFLAGS</code> or <code class="varname">LIBS</code>. The difference
2434: between the two is that <code class="varname">LIBS</code> will be appended to
2435: the command line, while <code class="varname">LDFLAGS</code> come earlier.
2436: <code class="varname">LDFLAGS</code> is pre-loaded with rpath settings for ELF
2437: machines depending on the setting of <code class="varname">USE_IMAKE</code> or
2438: the inclusion of <code class="filename">mk/x11.buildlink3.mk</code>. As with
2439: <code class="varname">CFLAGS</code>, if you do not wish to override these
2440: settings, use the <code class="literal">+=</code> operator:</p>
2441: <pre class="programlisting">
2442: LDFLAGS+= -your -linkerflags
2443: </pre>
2444: </div>
1.78 rillig 2445: </div>
2446: <div class="sect1" lang="en">
2447: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2448: <a name="developer-advanced-settings"></a>5.4. Developer/advanced settings</h2></div></div></div>
1.75 rillig 2449: <p>XXX
2450: </p>
2451: <div class="itemizedlist"><ul type="disc">
2452: <li>
2453: <p><code class="varname">PKG_DEVELOPER</code>:
2454: Run some sanity checks that package developers want:
2455: </p>
2456: <div class="itemizedlist"><ul type="circle">
1.88 wiz 2457: <li><p>make sure patches apply with zero
2458: fuzz</p></li>
2459: <li><p>run check-shlibs to see that all
2460: binaries will find their shared libs.</p></li>
1.75 rillig 2461: </ul></div>
2462: <p>
1.87 wiz 2463: </p>
1.75 rillig 2464: </li>
1.88 wiz 2465: <li><p><code class="varname">PKG_DEBUG_LEVEL</code>: The level
2466: of debugging output which is displayed whilst making and
2467: installing the package. The default value for this is 0,
2468: which will not display the commands as they are executed
2469: (normal, default, quiet operation); the value 1 will display
2470: all shell commands before their invocation, and the value 2
2471: will display both the shell commands before their invocation,
2472: and their actual execution progress with <span><strong class="command">set
2473: -x</strong></span> will be displayed.</p></li>
1.75 rillig 2474: </ul></div>
2475: <p>
2476: </p>
2477: </div>
2478: <div class="sect1" lang="en">
2479: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 2480: <a name="selecting-build-options"></a>5.5. Selecting Build Options</h2></div></div></div>
1.88 wiz 2481: <p>Some packages have build time options, usually to select
2482: between different dependencies, enable optional support for big
2483: dependencies or enable experimental features.</p>
1.75 rillig 2484: <p>To see which options, if any, a package supports, and which
1.88 wiz 2485: options are mutually exclusive, run <span><strong class="command">make
2486: show-options</strong></span>, for example:</p>
1.75 rillig 2487: <pre class="programlisting">
2488: The following options are supported by this package:
2489: ssl Enable SSL support.
2490: Exactly one of the following gecko options is required:
2491: firefox Use firefox as gecko rendering engine.
2492: mozilla Use mozilla as gecko rendering engine.
2493: At most one of the following database options may be selected:
2494: mysql Enable support for MySQL database.
2495: pgsql Enable support for PostgreSQL database.
1.1 grant 2496:
1.75 rillig 2497: These options are enabled by default: firefox
2498: These options are currently enabled: mozilla ssl
1.1 grant 2499: </pre>
1.75 rillig 2500: <p>The following variables can be defined in
1.88 wiz 2501: <code class="filename">/etc/mk.conf</code> to select which options to
2502: enable for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>,
2503: which can be used to select or disable options for all packages
2504: that support them, and
2505: <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
2506: which can be used to select or disable options specifically for
2507: package <em class="replaceable"><code>pkgbase</code></em>. Options listed in
2508: these variables are selected, options preceded by “<span class="quote">-</span>”
2509: are disabled. A few examples:</p>
1.75 rillig 2510: <pre class="screen">
2511: <code class="prompt">$</code> <span><strong class="command">grep "PKG.*OPTION" /etc/mk.conf</strong></span>
2512: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
2513: PKG_OPTIONS.kdebase= debug -sasl
2514: PKG_OPTIONS.apache= suexec </pre>
1.88 wiz 2515: <p>The following settings are consulted in the order given, and
2516: the last setting that selects or disables an option is
2517: used:</p>
1.75 rillig 2518: <div class="orderedlist"><ol type="1">
2519: <li><p>the default options as suggested by the package
1.88 wiz 2520: maintainer</p></li>
1.75 rillig 2521: <li><p>the options implied by the settings of legacy
1.88 wiz 2522: variables (see below)</p></li>
1.75 rillig 2523: <li><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
2524: <li><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
2525: </ol></div>
2526: <p>For groups of mutually exclusive options, the last option
1.88 wiz 2527: selected is used, all others are automatically disabled. If an
2528: option of the group is explicitly disabled, the previously
2529: selected option, if any, is used. It is an error if no option
2530: from a required group of options is selected, and building the
2531: package will fail.</p>
2532: <p>Before the options framework was introduced, build options
2533: were selected by setting a variable (often named
2534: <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
2535: <code class="filename">/etc/mk.conf</code> for each option. To ease
2536: transition to the options framework for the user, these legacy
2537: variables are converted to the appropriate options setting
2538: (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
2539: automatically. A warning is issued to prompt the user to update
2540: <code class="filename">/etc/mk.conf</code> to use the options framework
2541: directly. Support for the legacy variables will be removed
2542: eventually.</p>
1.75 rillig 2543: </div>
2544: </div>
2545: <div class="chapter" lang="en">
2546: <div class="titlepage"><div><div><h2 class="title">
2547: <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
2548: <div class="toc">
2549: <p><b>Table of Contents</b></p>
2550: <dl>
2551: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
2552: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
2553: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
2554: <dd><dl>
2555: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
2556: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
2557: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
2558: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
2559: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
2560: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
2561: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
2562: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
2563: </dl></dd>
2564: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
2565: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
2566: </dl>
2567: </div>
2568: <div class="sect1" lang="en">
2569: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2570: <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
1.87 wiz 2571: <p>Once you have built and installed a package, you can create
2572: a <span class="emphasis"><em>binary package</em></span> which can be installed on
2573: 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
2574: the same package on a group of hosts and wasting CPU time. It also
2575: provides a simple means for others to install your package, should
2576: you distribute it.</p>
2577: <p>To create a binary package, change into the appropriate
2578: directory in pkgsrc, and run <span><strong class="command">make
2579: package</strong></span>:</p>
2580: <pre class="screen">
2581: <code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
2582: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
2583: </pre>
2584: <p>This will build and install your package (if not already done),
2585: and then build a binary package from what was installed. You can
2586: then use the <span><strong class="command">pkg_*</strong></span> tools to manipulate
2587: it. Binary packages are created by default in
2588: <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
2589: gzipped tar file. See <a href="#logs.package" title="B.2. Packaging figlet">Section B.2, “Packaging figlet”</a> for a
2590: 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>
2591: <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
2592: such a binary package.</p>
1.75 rillig 2593: </div>
2594: <div class="sect1" lang="en">
2595: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2596: <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
1.88 wiz 2597: <p>See <a href="#build.helpful-targets" title="15.17. Other helpful targets">Section 15.17, “Other helpful targets”</a>.</p>
1.75 rillig 2598: </div>
2599: <div class="sect1" lang="en">
2600: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2601: <a name="bulkbuild"></a>6.3. Doing a bulk build of all packages</h2></div></div></div>
2602: <p>If you want to get a full set of precompiled binary
1.87 wiz 2603: packages, this section describes how to get them. Beware that
2604: the bulk build will remove all currently installed packages from
2605: your system!</p>
1.75 rillig 2606: <p>Having an FTP server configured either on the
1.87 wiz 2607: machine doing the bulk builds or on a nearby NFS server can help
2608: to make the packages available to other machines that can then
2609: 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
2610: more information. If you use a remote NFS server's storage, be
2611: sure to not actually compile on NFS storage, as this slows
2612: things down a lot.</p>
1.75 rillig 2613: <div class="sect2" lang="en">
2614: <div class="titlepage"><div><div><h3 class="title">
2615: <a name="binary.configuration"></a>6.3.1. Configuration</h3></div></div></div>
2616: <div class="sect3" lang="en">
2617: <div class="titlepage"><div><div><h4 class="title">
1.76 rillig 2618: <a name="binary.bulk.build.conf"></a>6.3.1.1. <code class="filename">build.conf</code></h4></div></div></div>
2619: <p>The <code class="filename">build.conf</code> file is the main
1.87 wiz 2620: configuration file for bulk builds. You can configure how your
2621: copy of pkgsrc is kept up to date, how the distfiles are
2622: downloaded, how the packages are built and how the report is
2623: generated. You can find an annotated example file in
2624: <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
2625: it, copy <code class="filename">build.conf-example</code> to
2626: <code class="filename">build.conf</code> and edit it, following the
2627: comments in that file.</p>
1.75 rillig 2628: </div>
2629: <div class="sect3" lang="en">
2630: <div class="titlepage"><div><div><h4 class="title">
2631: <a name="binary.mk.conf"></a>6.3.1.2. /etc/mk.conf</h4></div></div></div>
2632: <p>You may want to set variables in
1.87 wiz 2633: <code class="filename">/etc/mk.conf</code>.
2634: Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
2635: details of the default settings. You will want to ensure that
2636: <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
2637: As used in this example, <code class="varname">_ACCEPTABLE=yes</code>
2638: accepts <span class="emphasis"><em>all</em></span> licenses.</p>
2639: <pre class="programlisting">
2640: PACKAGES?= ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
2641: WRKOBJDIR?= /usr/tmp/pkgsrc # build here instead of in pkgsrc
2642: BSDSRCDIR= /usr/src
2643: BSDXSRCDIR= /usr/xsrc # for x11/xservers
2644: OBJHOSTNAME?= yes # use work.`hostname`
2645: FAILOVER_FETCH= yes # insist on the correct checksum
2646: PKG_DEVELOPER?= yes
2647: _ACCEPTABLE= yes
2648: </pre>
1.75 rillig 2649: <p>Some options that are especially useful for bulk builds
2650: can be found at the top lines of the file
1.76 rillig 2651: <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
1.75 rillig 2652: options of these are briefly described here.</p>
2653: <div class="itemizedlist"><ul type="disc">
2654: <li><p>If you are on a slow machine, you may want to
1.87 wiz 2655: set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
2656: “<span class="quote">no</span>”.</p></li>
1.75 rillig 2657: <li><p>If you are doing bulk builds from a read-only
1.87 wiz 2658: copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
2659: to the directory where all log files are created. Otherwise the
2660: log files are created in the pkgsrc directory.</p></li>
1.75 rillig 2661: <li><p>Another important variable is
1.87 wiz 2662: <code class="varname">BULK_PREREQ</code>, which is a list of packages that
2663: should be always available while building other
2664: packages.</p></li>
1.75 rillig 2665: </ul></div>
2666: <p>Some other options are scattered in the pkgsrc
2667: infrastructure:</p>
2668: <div class="itemizedlist"><ul type="disc">
2669: <li><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
1.87 wiz 2670: should be set to <code class="literal">yes</code>. The purpose of the bulk
2671: builds is creating binary packages, no matter if they are
2672: vulnerable or not. When uploading the packages to a public
2673: server, the vulnerable packages will be put into a directory of
2674: their own. Leaving this variable unset would prevent the bulk
2675: build system from even trying to build them, so possible
2676: building errors would not show up.</p></li>
1.75 rillig 2677: <li><p><code class="varname">CHECK_FILES</code>
1.87 wiz 2678: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
2679: “<span class="quote">yes</span>” to check that the installed set of files
2680: matches the <code class="filename">PLIST</code>.</p></li>
1.75 rillig 2681: <li><p><code class="varname">CHECK_INTERPRETER</code>
1.87 wiz 2682: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
2683: “<span class="quote">yes</span>” to check that the installed
2684: “<span class="quote">#!</span>”-scripts will find their
2685: interpreter.</p></li>
1.75 rillig 2686: </ul></div>
2687: </div>
2688: <div class="sect3" lang="en">
2689: <div class="titlepage"><div><div><h4 class="title">
1.76 rillig 2690: <a name="pre-build.local"></a>6.3.1.3. <code class="filename">pre-build.local</code></h4></div></div></div>
1.75 rillig 2691: <p>It is possible to configure the bulk build to perform
1.87 wiz 2692: certain site-specific tasks at the end of the pre-build
2693: stage. If the file
2694: <code class="filename">pre-build.local</code> exists in
2695: <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
2696: (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
2697: stage. An example use of
2698: <code class="filename">pre-build.local</code> is to have the line:</p>
1.75 rillig 2699: <pre class="screen">echo "I do not have enough disk space to build this pig." \
1.87 wiz 2700: > misc/openoffice/$BROKENF</pre>
1.75 rillig 2701: <p>to prevent the system from trying to build a particular package
1.87 wiz 2702: which requires nearly 3 GB of disk space.</p>
1.75 rillig 2703: </div>
2704: </div>
2705: <div class="sect2" lang="en">
2706: <div class="titlepage"><div><div><h3 class="title">
2707: <a name="other-environmental-considerations"></a>6.3.2. Other environmental considerations</h3></div></div></div>
1.76 rillig 2708: <p>As <code class="filename">/usr/pkg</code> will be completely
1.87 wiz 2709: deleted at the start of bulk builds, make sure your login
2710: shell is placed somewhere else. Either drop it into
2711: <code class="filename">/usr/local/bin</code> (and adjust your login
2712: shell in the passwd file), or (re-)install it via
2713: <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
2714: you can login after a reboot (remember that your current
2715: process won't die if the package is removed, you just can't
2716: start any new instances of the shell any more). Also, if you
2717: use NetBSD earlier than 1.5, or you still want to use the pkgsrc
2718: version of ssh for some reason, be sure to install ssh before
2719: starting it from <code class="filename">rc.local</code>:</p>
2720: <pre class="programlisting">
2721: ( cd /usr/pkgsrc/security/ssh ; make bulk-install )
2722: if [ -f /usr/pkg/etc/rc.d/sshd ]; then
2723: /usr/pkg/etc/rc.d/sshd
2724: fi
2725: </pre>
1.75 rillig 2726: <p>Not doing so will result in you being not able to log in
1.87 wiz 2727: via ssh after the bulk build is finished or if the machine
2728: gets rebooted or crashes. You have been warned! :)</p>
1.75 rillig 2729: </div>
2730: <div class="sect2" lang="en">
2731: <div class="titlepage"><div><div><h3 class="title">
2732: <a name="operation"></a>6.3.3. Operation</h3></div></div></div>
2733: <p>Make sure you don't need any of the packages still
1.87 wiz 2734: installed.</p>
1.75 rillig 2735: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
2736: <h3 class="title">Warning</h3>
2737: <p>During the bulk build, <span class="emphasis"><em>all packages will be
1.87 wiz 2738: removed!</em></span></p>
1.75 rillig 2739: </div>
2740: <p>Be sure to remove all other things that might
1.87 wiz 2741: interfere with builds, like some libs installed in
2742: <code class="filename">/usr/local</code>, etc. then become root and type:</p>
2743: <pre class="screen">
2744: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2745: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong>
2746: </pre>
1.75 rillig 2747: <p>If for some reason your last build didn't complete (power
1.87 wiz 2748: failure, system panic, ...), you can continue it by
2749: running:</p>
1.75 rillig 2750: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
1.87 wiz 2751: <p>At the end of the bulk build, you will get a summary via mail,
2752: and find build logs in the directory specified by
2753: <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
2754: file.</p>
1.75 rillig 2755: </div>
2756: <div class="sect2" lang="en">
2757: <div class="titlepage"><div><div><h3 class="title">
2758: <a name="what-it-does"></a>6.3.4. What it does</h3></div></div></div>
2759: <p>The bulk builds consist of three steps:</p>
2760: <div class="variablelist"><dl>
2761: <dt><span class="term">1. pre-build</span></dt>
1.87 wiz 2762: <dd><p>The script updates your pkgsrc tree via (anon)cvs, then
2763: cleans out any broken distfiles, and removes all
2764: packages installed.</p></dd>
1.75 rillig 2765: <dt><span class="term">2. the bulk build</span></dt>
1.87 wiz 2766: <dd><p>This is basically “<span class="quote">make bulk-package</span>” with
2767: an optimised order in which packages will be
2768: built. Packages that don't require other packages will
2769: be built first, and packages with many dependencies will
2770: be built later.</p></dd>
1.75 rillig 2771: <dt><span class="term">3. post-build</span></dt>
1.87 wiz 2772: <dd><p>Generates a report that's placed in the directory
2773: specified in the <code class="filename">build.conf</code> file
2774: named <code class="filename">broken.html</code>, a short version
2775: of that report will also be mailed to the build's
2776: admin.</p></dd>
1.75 rillig 2777: </dl></div>
1.87 wiz 2778: <p>During the build, a list of broken packages will be compiled
2779: in <code class="filename">/usr/pkgsrc/.broken</code> (or
2780: <code class="filename">.../.broken.${MACHINE}</code> if
2781: <code class="varname">OBJMACHINE</code> is set), individual build logs
2782: of broken builds can be found in the package's
2783: directory. These files are used by the bulk-targets to mark
2784: broken builds to not waste time trying to rebuild them, and
2785: they can be used to debug these broken package builds
2786: later.</p>
1.75 rillig 2787: </div>
2788: <div class="sect2" lang="en">
2789: <div class="titlepage"><div><div><h3 class="title">
2790: <a name="disk-space-requirements"></a>6.3.5. Disk space requirements</h3></div></div></div>
2791: <p>Currently, roughly the following requirements are valid for
1.87 wiz 2792: NetBSD 2.0/i386:</p>
1.75 rillig 2793: <div class="itemizedlist"><ul type="disc">
1.87 wiz 2794: <li><p>10 GB - distfiles (NFS ok)</p></li>
2795: <li><p>8 GB - full set of all binaries (NFS ok)</p></li>
2796: <li><p>5 GB - temp space for compiling (local disk recommended)</p></li>
2797: </ul></div>
2798: <p>Note that all pkgs will be de-installed as soon as they are
2799: turned into a binary package, and that sources are removed,
2800: so there is no excessively huge demand to disk
2801: space. Afterwards, if the package is needed again, it will
2802: 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
2803: there are no cycles wasted by recompiling.</p>
1.75 rillig 2804: </div>
2805: <div class="sect2" lang="en">
2806: <div class="titlepage"><div><div><h3 class="title">
2807: <a name="setting-up-a-sandbox"></a>6.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
1.87 wiz 2808: <p>If you don't want all the packages nuked from a machine
2809: (rendering it useless for anything but pkg compiling), there
2810: is the possibility of doing the package bulk build inside a
2811: chroot environment.</p>
2812: <p>The first step is to set up a chroot sandbox,
2813: e.g. <code class="filename">/usr/sandbox</code>. This can be done by
2814: using null mounts, or manually.</p>
2815: <p>There is a shell script called
2816: <code class="filename">pkgsrc/mk/bulk/mksandbox</code> which will set
2817: up the sandbox environment using null mounts. It will also
2818: create a script called <code class="filename">sandbox</code> in the
2819: root of the sandbox environment, which will allow the null
2820: mounts to be activated using the <span><strong class="command">sandbox
2821: mount</strong></span> command and deactivated using the
2822: <span><strong class="command">sandbox umount</strong></span> command.</p>
2823: <p>To set up a sandbox environment by hand, after extracting all
2824: the sets from a NetBSD installation or doing a <span><strong class="command">make
2825: distribution DESTDIR=/usr/sandbox</strong></span> in
2826: <code class="filename">/usr/src/etc</code>, be sure the following items
2827: are present and properly configured:</p>
1.75 rillig 2828: <div class="procedure"><ol type="1">
2829: <li>
2830: <p>Kernel</p>
2831: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
2832: </li>
2833: <li>
1.76 rillig 2834: <p><code class="filename">/dev/*</code></p>
1.75 rillig 2835: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
2836: </li>
2837: <li>
1.76 rillig 2838: <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 2839: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
2840: </li>
2841: <li>
2842: <p>Working(!) mail config (hostname, sendmail.cf):</p>
2843: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
2844: </li>
2845: <li>
1.76 rillig 2846: <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 2847: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
2848: </li>
2849: <li>
1.76 rillig 2850: <p><code class="filename">/usr/src</code> (system sources,
1.89 ! rillig 2851: 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 2852: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
1.87 wiz 2853: <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
1.75 rillig 2854: </li>
2855: <li>
1.76 rillig 2856: <p>Create <code class="filename">/var/db/pkg</code> (not part of default install):</p>
1.75 rillig 2857: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong></pre>
2858: </li>
2859: <li>
1.76 rillig 2860: <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
1.75 rillig 2861: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
2862: </li>
2863: <li>
2864: <p>Checkout pkgsrc via cvs into
1.87 wiz 2865: <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
2866: <pre class="screen">
2867: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
2868: <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong>
2869: </pre>
1.75 rillig 2870: <p>Do not mount/link this to the copy of your pkgsrc tree
1.87 wiz 2871: you do development in, as this will likely cause problems!</p>
1.75 rillig 2872: </li>
2873: <li><p>Make
1.87 wiz 2874: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
2875: <code class="filename">.../distfiles</code> point somewhere
2876: appropriate. NFS- and/or nullfs-mounts may come in handy!</p></li>
1.76 rillig 2877: <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>
2878: <li><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
1.75 rillig 2879: </ol></div>
2880: <p>When the chroot sandbox is set up, you can start
1.87 wiz 2881: the build with the following steps:</p>
2882: <pre class="screen">
2883: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2884: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong>
2885: </pre>
2886: <p>This will just jump inside the sandbox and start building. At
2887: the end of the build, mail will be sent with the results of
2888: the build. Created binary pkgs will be in
2889: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
2890: (wherever that points/mounts to/from).</p>
1.75 rillig 2891: </div>
2892: <div class="sect2" lang="en">
2893: <div class="titlepage"><div><div><h3 class="title">
2894: <a name="building-a-partial-set"></a>6.3.7. Building a partial set of packages</h3></div></div></div>
1.87 wiz 2895: <p>In addition to building a complete set of all packages in
2896: pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
2897: may be used to build a subset of the packages contained in
2898: pkgsrc. By setting <code class="varname">SPECIFIC_PKGS</code>
2899: in <code class="filename">/etc/mk.conf</code>, the variables</p>
1.75 rillig 2900: <div class="itemizedlist"><ul type="disc">
2901: <li><p>SITE_SPECIFIC_PKGS</p></li>
2902: <li><p>HOST_SPECIFIC_PKGS</p></li>
2903: <li><p>GROUP_SPECIFIC_PKGS</p></li>
2904: <li><p>USER_SPECIFIC_PKGS</p></li>
2905: </ul></div>
1.87 wiz 2906: <p>will define the set of packages which should be built.
2907: The bulk build code will also include any packages which are
2908: needed as dependencies for the explicitly listed packages.</p>
2909: <p>One use of this is to do a bulk build with
2910: <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
2911: periodically to have a complete set of the binary packages
2912: needed for your site available without the overhead of
2913: building extra packages that are not needed.</p>
1.75 rillig 2914: </div>
2915: <div class="sect2" lang="en">
2916: <div class="titlepage"><div><div><h3 class="title">
2917: <a name="bulk-upload"></a>6.3.8. Uploading results of a bulk build</h3></div></div></div>
1.87 wiz 2918: <p>This section describes how pkgsrc developers can upload binary
2919: pkgs built by bulk builds to ftp.NetBSD.org.</p>
2920: <p>If you would like to automatically create checksum files for the
2921: binary packages you intend to upload, remember to set
2922: <code class="varname">MKSUMS=yes</code> in your
2923: <code class="filename">mk/bulk/build.conf</code>.</p>
2924: <p>If you would like to PGP sign the checksum files (highly
2925: recommended!), remember to set
2926: <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
2927: <code class="filename">mk/bulk/build.conf</code>. This will prompt you for
2928: your GPG password to sign the files before uploading everything.</p>
2929: <p>Then, make sure that you have <code class="varname">RSYNC_DST</code>
2930: set properly in your <code class="filename">mk/bulk/build.conf</code>
2931: file, i.e. adjust it to something like one of the following:</p>
1.75 rillig 2932: <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
2933: <p>Please use appropriate values for "pkgsrc-200xQy",
1.87 wiz 2934: "NetBSD-a.b.c" and "arch" here. If your login on ftp.NetBSD.org
2935: is different from your local login, write your login directly
2936: into the variable, e.g. my local account is "feyrer", but for my
2937: login "hubertf", I use:</p>
2938: <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload</pre>
2939: <p>A separate <code class="filename">upload</code> directory is used
2940: here to allow "closing" the directory during upload. To do
2941: so, run the following command on ftp.NetBSD.org next:</p>
1.75 rillig 2942: <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 2943: <p>Please note that <code class="filename">/pub/NetBSD/packages</code> is
2944: only appropriate for packages for the NetBSD operating
2945: system. Binary packages for other operating systems should go
2946: into <code class="filename">/pub/pkgsrc</code>.</p>
2947: <p>Before uploading the binary pkgs, ssh authentication needs
2948: to be set up. This example shows how to set up temporary keys
2949: for the root account <span class="emphasis"><em>inside the sandbox</em></span>
2950: (assuming that no keys should be present there usually):</p>
2951: <pre class="screen">
2952: <code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
1.75 rillig 2953: chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
2954: chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t dsa</code></strong>
1.87 wiz 2955: chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong>
2956: </pre>
2957: <p>Now take the output of <code class="filename">id-dsa.pub</code> and
2958: append it to your <code class="filename">~/.ssh/authorized_keys</code>
2959: file on ftp.NetBSD.org. You can remove the key after the
2960: upload is done!</p>
2961: <p>Next, test if your ssh connection really works:</p>
1.75 rillig 2962: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
1.87 wiz 2963: <p>Use "-l yourNetBSDlogin" here as appropriate!</p>
2964: <p>Now after all this works, you can exit the sandbox and start
2965: the upload:</p>
2966: <pre class="screen">
2967: chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
1.75 rillig 2968: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
1.87 wiz 2969: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong>
2970: </pre>
2971: <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
2972: <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
2973: upload. The upload script will take care of not uploading
2974: restricted packages and putting vulnerable packages into the
2975: <code class="filename">vulnerable</code> subdirectory.</p>
2976: <p>After the upload has ended, first thing is to revoke ssh access:</p>
1.75 rillig 2977: <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
1.87 wiz 2978: Gdd:x! </pre>
2979: <p>Use whatever is needed to remove the key you've entered
2980: before! Last, move the uploaded packages out of the
2981: <code class="filename">upload</code> directory to have them accessible
2982: to everyone:</p>
2983: <pre class="screen">
2984: nbftp% <strong class="userinput"><code>cd /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch</code></strong>
1.75 rillig 2985: nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
2986: nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
1.87 wiz 2987: nbftp% <strong class="userinput"><code>chmod 755 .</code></strong>
2988: </pre>
1.75 rillig 2989: </div>
2990: </div>
2991: <div class="sect1" lang="en">
2992: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2993: <a name="creating-cdroms"></a>6.4. Creating a multiple CD-ROM packages collection</h2></div></div></div>
1.87 wiz 2994: <p>After your pkgsrc bulk-build has completed, you may wish to
2995: create a CD-ROM set of the resulting binary packages to assist
2996: in installing packages on other machines. The
2997: <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
2998: a simple tool for creating the ISO 9660 images.
2999: <span><strong class="command">cdpack</strong></span> arranges the packages on the CD-ROMs in a
3000: way that keeps all the dependencies for a given package on the same
3001: CD as that package.</p>
1.75 rillig 3002: <div class="sect2" lang="en">
3003: <div class="titlepage"><div><div><h3 class="title">
3004: <a name="cdpack-example"></a>6.4.1. Example of cdpack</h3></div></div></div>
1.87 wiz 3005: <p>Complete documentation for cdpack is found in the cdpack(1)
3006: man page. The following short example assumes that the binary
3007: packages are left in
3008: <code class="filename">/usr/pkgsrc/packages/All</code> and that
3009: sufficient disk space exists in <code class="filename">/u2</code> to
3010: hold the ISO 9660 images.</p>
3011: <pre class="screen">
3012: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
1.75 rillig 3013: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
1.87 wiz 3014: <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong>
3015: </pre>
3016: <p>If you wish to include a common set of files
3017: (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
3018: etc.) on each CD in the collection, then you need to create a
3019: directory which contains these files. e.g.</p>
3020: <pre class="screen">
3021: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
1.75 rillig 3022: <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" > /tmp/common/README</code></strong>
3023: <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" > /tmp/common/COPYING</code></strong>
3024: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
3025: <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" > /tmp/common/bin/myscript</code></strong>
3026: <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" >> /tmp/common/bin/myscript</code></strong>
1.87 wiz 3027: <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong>
3028: </pre>
1.75 rillig 3029: <p>Now create the images:</p>
3030: <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 3031: <p>Each image will contain <code class="filename">README</code>,
1.87 wiz 3032: <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
3033: in their root directories.</p>
1.75 rillig 3034: </div>
3035: </div>
3036: </div>
3037: <div class="chapter" lang="en">
3038: <div class="titlepage"><div><div><h2 class="title">
3039: <a name="faq"></a>Chapter 7. Frequently Asked Questions</h2></div></div></div>
3040: <div class="toc">
3041: <p><b>Table of Contents</b></p>
3042: <dl>
3043: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
3044: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
3045: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
3046: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
3047: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
3048: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
3049: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
3050: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
3051: <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>
3052: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
3053: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does “<span class="quote">Don't know how to make
3054: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
3055: <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>
3056: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
3057: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
3058: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
3059: <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 3060: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.89 ! rillig 3061: <dt><span class="sect1"><a href="#faq.rcs-conflicts">7.18. What does “<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>” mean?</a></span></dt>
! 3062: <dt><span class="sect1"><a href="#too-much-time">7.19. I have a little time to kill. What shall I do?</a></span></dt>
1.75 rillig 3063: </dl>
3064: </div>
3065: <p>This section contains hints, tips & tricks on special things in
3066: pkgsrc that we didn't find a better place for in the previous chapters, and
3067: it contains items for both pkgsrc users and developers.</p>
3068: <div class="sect1" lang="en">
3069: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3070: <a name="mailing-list-pointers"></a>7.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
3071: <p>The following mailing lists may be of interest to pkgsrc users:</p>
3072: <div class="itemizedlist"><ul type="disc">
1.78 rillig 3073: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-users" target="_top">pkgsrc-users</a>:
3074: This is a general purpose list for most issues regarding
3075: pkgsrc, regardless of platform, e.g. soliciting user help
3076: for pkgsrc configuration, unexpected build failures, using
3077: particular packages, upgrading pkgsrc installations,
3078: questions regarding the pkgsrc release branches, etc. General announcements or
3079: proposals for changes that impact the pkgsrc user community,
3080: e.g. major infrastructure changes, new features, package
3081: removals, etc., may also be posted.</p></li>
1.75 rillig 3082: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
3083: A list where the results of pkgsrc bulk builds are sent and
3084: discussed.</p></li>
3085: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
3086: This list is for those who are interested in getting a
3087: commit message for every change committed to pkgsrc. It is
3088: also available in digest form, meaning one daily message
3089: containing all commit messages for changes to the package
3090: source tree in that 24 hour period.</p></li>
3091: </ul></div>
3092: <p>To subscribe, do:</p>
3093: <pre class="programlisting">
3094: <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
3095: </pre>
3096: <p>Archives for all these mailing lists are available from
3097: <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
3098: </div>
3099: <div class="sect1" lang="en">
3100: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3101: <a name="pkgviews-docs"></a>7.2. Where's the pkgviews documentation?</h2></div></div></div>
3102: <p>Pkgviews is tightly integrated with buildlink. You can find a
3103: pkgviews User's guide in
1.76 rillig 3104: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
1.75 rillig 3105: </div>
3106: <div class="sect1" lang="en">
3107: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3108: <a name="faq-pkgtools"></a>7.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.80 rillig 3109: <p>The directory <code class="filename">pkgsrc/pkgtools</code> contains
1.75 rillig 3110: a number of useful utilities for both users and developers of pkgsrc. This
3111: section attempts only to make the reader aware of the utilities and when
3112: they might be useful, and not to duplicate the documentation that comes
3113: with each package.</p>
3114: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
1.76 rillig 3115: <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 3116: Symlinks for use by buildlink.</p></li></ul></div>
3117: <p>OS tool augmentation (automatically installed when needed):</p>
3118: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3119: <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 3120: Calculates various kinds of checksums (including SHA1).</p></li>
1.76 rillig 3121: <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 3122: Compatibility library for pkgsrc tools.</p></li>
1.76 rillig 3123: <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 3124: non-BSD systems due to lack of native mtree.</p></li>
1.76 rillig 3125: <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 3126: Up-to-date replacement for
1.76 rillig 3127: <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
1.75 rillig 3128: systems where pkg_install is not present.</p></li>
3129: </ul></div>
3130: <p>Utilities used by pkgsrc (not automatically installed):</p>
3131: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3132: <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 3133: Create a binary package from an
3134: already-installed package. Used by <span><strong class="command">make replace</strong></span> to
3135: save the old package.</p></li>
1.76 rillig 3136: <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 3137: Adds extra functionality to pkgsrc, allowing it to fetch distfiles
3138: from multiple locations. It currently supports the following
3139: methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
1.76 rillig 3140: <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 3141: packages someplace else (enabled by default).</p></li>
1.76 rillig 3142: <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 3143: best compiler flags to optimise code for your current CPU and
3144: compiler.</p></li>
3145: </ul></div>
3146: <p>Utilities for keeping track of installed packages, being up to date,
3147: etc:</p>
3148: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3149: <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 3150: packages whose installed versions do not match the latest pkgsrc
3151: entries.</p></li>
1.76 rillig 3152: <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 3153: dependency graphs of packages, to aid in choosing a strategy for
3154: updating.</p></li>
1.76 rillig 3155: <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
3156: 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>
3157: <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 3158: pkglint(1) program checks a pkgsrc entry for errors, lintpkgsrc(1)
3159: does various checks on the complete pkgsrc system.</p></li>
1.76 rillig 3160: <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 3161: packages you have installed.</p></li>
3162: </ul></div>
3163: <p>Utilities for people maintaining or creating individual packages:</p>
3164: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3165: <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 3166: making and maintaining patches for a package (includes pkgdiff,
3167: pkgvi, mkpatches, etc.).</p></li>
1.76 rillig 3168: <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>,
3169: <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 3170: converting to pkgsrc.</p></li>
1.76 rillig 3171: <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 3172: pkgsrc to a Solaris package.</p></li>
3173: </ul></div>
3174: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
3175: utilities)</p>
3176: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3177: <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 3178: packages in a chrooted area.</p></li>
1.76 rillig 3179: <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 3180: kernel version for chrooted cross builds.</p></li>
3181: </ul></div>
3182: </div>
3183: <div class="sect1" lang="en">
3184: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3185: <a name="non-root-pkgsrc"></a>7.4. How to use pkgsrc as non-root</h2></div></div></div>
3186: <p>If you want to use pkgsrc as non-root user, you can set some
3187: variables to make pkgsrc work under these conditions. At the very least,
3188: you need to set <code class="varname">UNPRIVILEGED</code> to “<span class="quote">yes</span>”; this
3189: will turn on unprivileged mode and set multiple related variables to allow
3190: installation of packages as non-root.</p>
3191: <p>In case the defaults are not enough, you may want to tune some other
3192: variables used. For example, if the automatic user/group detection leads
3193: to incorrect values (or not the ones you would like to use), you can change
3194: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
3195: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
3196: <p>As regards bootstrapping, please note that the
3197: <span><strong class="command">bootstrap</strong></span> script will ease non-root configuration when
3198: given the “<span class="quote">--ignore-user-check</span>” flag, as it will choose and
1.76 rillig 3199: use multiple default directories under <code class="filename">~/pkg</code> as the
1.75 rillig 3200: installation targets. These directories can be overriden by the
3201: “<span class="quote">--prefix</span>” flag provided by the script, as well as some others
3202: that allow finer tuning of the tree layout.</p>
3203: </div>
3204: <div class="sect1" lang="en">
3205: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3206: <a name="resume-transfers"></a>7.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
3207: <p>By default, resuming transfers in pkgsrc is disabled, but you can
3208: enable this feature by adding the option
3209: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.76 rillig 3210: <code class="filename">/etc/mk.conf</code>. If, during a fetch step, an incomplete
1.75 rillig 3211: distfile is found, pkgsrc will try to resume it.</p>
3212: <p>You can also
3213: 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
3214: <code class="varname">FETCH_CMD</code> variable. Don't forget to set
3215: <code class="varname">FETCH_RESUME_ARGS</code> and
3216: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
3217: values.</p>
3218: <p>For example, if you want to use
1.76 rillig 3219: <code class="filename">wget</code> to resume downloads, you'll have to use something
1.75 rillig 3220: like:</p>
3221: <pre class="programlisting">
3222: FETCH_CMD= wget
3223: FETCH_BEFORE_ARGS= --passive-ftp
3224: FETCH_RESUME_ARGS= -c
3225: FETCH_OUTPUT_ARGS= -O
1.1 grant 3226: </pre>
1.75 rillig 3227: </div>
3228: <div class="sect1" lang="en">
3229: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3230: <a name="XFree86-from-pkgsrc"></a>7.6. How can I install/use XFree86 from pkgsrc?</h2></div></div></div>
3231: <p>If you want to use XFree86 from pkgsrc instead of your system's own
1.76 rillig 3232: X11 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>,
1.75 rillig 3233: ...), you will have to add the following line into
1.76 rillig 3234: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 3235: <pre class="programlisting">
3236: X11_TYPE=XFree86
1.1 grant 3237: </pre>
1.75 rillig 3238: </div>
3239: <div class="sect1" lang="en">
3240: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3241: <a name="x.org-from-pkgsrc"></a>7.7. How can I install/use X.org from pkgsrc?</h2></div></div></div>
3242: <p>If you want to use X.org from pkgsrc instead of your system's own X11
1.76 rillig 3243: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
1.75 rillig 3244: you will have to add the following line into
1.76 rillig 3245: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 3246: <pre class="programlisting">
3247: X11_TYPE=xorg
1.1 grant 3248: </pre>
1.75 rillig 3249: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
3250: <h3 class="title">Note</h3>
3251: <p>The DragonFly operating system defaults to using
1.87 wiz 3252: this X.org X11 implementation from pkgsrc.</p>
1.75 rillig 3253: </div>
3254: </div>
3255: <div class="sect1" lang="en">
3256: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3257: <a name="fetch-behind-firewall"></a>7.8. How to fetch files from behind a firewall</h2></div></div></div>
3258: <p>If you are sitting behind a firewall which does not allow direct
3259: connections to Internet hosts (i.e. non-NAT), you may specify the
3260: relevant proxy hosts. This is done using an environment variable in the
3261: form of a URL, e.g. in Amdahl, the machine
3262: “<span class="quote">orpheus.amdahl.com</span>” is one of the firewalls, and it uses
3263: port 80 as the proxy port number. So the proxy environment variables
3264: are:</p>
3265: <pre class="programlisting">
3266: ftp_proxy=ftp://orpheus.amdahl.com:80/
3267: http_proxy=http://orpheus.amdahl.com:80/
1.1 grant 3268: </pre>
1.75 rillig 3269: </div>
3270: <div class="sect1" lang="en">
3271: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3272: <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>
3273: <p>This depends on which utility is used to retrieve distfiles. From
1.76 rillig 3274: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
1.75 rillig 3275: the first available command from the following list:</p>
3276: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3277: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
3278: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
1.75 rillig 3279: </ul></div>
3280: <p>On a default NetBSD installation, this will be
1.76 rillig 3281: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
1.75 rillig 3282: connections first, and falls back to active connections if the server
3283: refuses to do passive. For the other tools, add the following to your
1.76 rillig 3284: <code class="filename">/etc/mk.conf</code> file:
1.75 rillig 3285: <code class="varname">PASSIVE_FETCH=1</code>.</p>
3286: <p>Having that option present will prevent
1.76 rillig 3287: <code class="filename">/usr/bin/ftp</code> from falling back to active
1.75 rillig 3288: transfers.</p>
3289: </div>
3290: <div class="sect1" lang="en">
3291: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3292: <a name="fetching-all-distfiles"></a>7.10. How to fetch all distfiles at once</h2></div></div></div>
1.88 wiz 3293: <p>You would like to download all the distfiles in a single batch
3294: from work or university, where you can't run a <span><strong class="command">make
3295: 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 3296: but downloading the entire directory may not be appropriate.</p>
3297: <p>The answer here is to do a <span><strong class="command">make fetch-list</strong></span> in
1.76 rillig 3298: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
1.75 rillig 3299: resulting list to your machine at work/school and use it there. If you
3300: 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
3301: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
3302: URL:</p>
3303: <p>At home:</p>
3304: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
3305: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh</code></strong>
3306: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
3307: <p>At work:</p>
3308: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
1.76 rillig 3309: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
1.75 rillig 3310: home.</p>
3311: <p>If you have a machine running NetBSD, and you want to get
1.88 wiz 3312: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your
3313: machine architecture), you can do so by using the above-mentioned
3314: <span><strong class="command">make fetch-list</strong></span> approach, or fetch the distfiles
3315: directly by running:</p>
1.75 rillig 3316: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
3317: <p>If you even decide to ignore
3318: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
3319: by running:</p>
3320: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
3321: </div>
3322: <div class="sect1" lang="en">
3323: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3324: <a name="tmac.andoc-missing"></a>7.11. What does “<span class="quote">Don't know how to make
3325: /usr/share/tmac/tmac.andoc</span>” mean?</h2></div></div></div>
1.76 rillig 3326: <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 3327: package, you get the error from make that it doesn't know how to make
1.76 rillig 3328: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
1.75 rillig 3329: you don't have installed the “<span class="quote">text</span>” set (nroff, ...) from
3330: the NetBSD base distribution on your machine. It is recommended to do
3331: that to format man pages.</p>
1.76 rillig 3332: <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 3333: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.76 rillig 3334: environment or in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 3335: </div>
3336: <div class="sect1" lang="en">
3337: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3338: <a name="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 3339: <p>You didn't install the compiler set, <code class="filename">comp.tgz</code>,
1.75 rillig 3340: when you installed your NetBSD machine. Please get and install it, by
1.76 rillig 3341: extracting it in <code class="filename">/</code>:</p>
1.75 rillig 3342: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
3343: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
1.76 rillig 3344: <p><code class="filename">comp.tgz</code> is part of every NetBSD release. Get
1.75 rillig 3345: the one that corresponds to your release (determine via <span><strong class="command">uname
3346: -r</strong></span>).</p>
3347: </div>
3348: <div class="sect1" lang="en">
3349: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3350: <a name="using-sudo-with-pkgsrc"></a>7.13. Using 'sudo' with pkgsrc</h2></div></div></div>
3351: <p>When installing packages as non-root user and using the just-in-time
3352: <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
3353: password for each required package installed. To avoid this, the sudo
3354: package can be used, which does password caching over a limited time. To
3355: use it, install sudo (either as binary package or from
1.76 rillig 3356: <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
3357: into your <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 3358: <pre class="programlisting">
3359: .if exists(${LOCALBASE}/bin/sudo)
3360: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
3361: .endif
1.1 grant 3362: </pre>
1.75 rillig 3363: </div>
3364: <div class="sect1" lang="en">
3365: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3366: <a name="faq.conf"></a>7.14. How do I change the location of configuration files?</h2></div></div></div>
3367: <p>As the system administrator, you can choose where configuration files
3368: are installed. The default settings make all these files go into
1.76 rillig 3369: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
1.75 rillig 3370: be suboptimal depending on your expectations (e.g., a read-only,
3371: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
3372: configuration of the provided packages).</p>
3373: <p>In order to change the defaults, you can modify the
3374: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.76 rillig 3375: <code class="filename">/etc/mk.conf</code>) to point to your preferred configuration
3376: directory; some common examples include <code class="filename">/etc</code> or
3377: <code class="filename">/etc/pkg</code>.</p>
1.75 rillig 3378: <p>Furthermore, you can change this value on a per-package basis by
3379: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
3380: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
3381: package you would like to modify, that is, the contents of
3382: <code class="varname">PKGBASE</code>.</p>
3383: <p>Note that after changing these settings, you must rebuild and
3384: reinstall any affected packages.</p>
3385: </div>
3386: <div class="sect1" lang="en">
3387: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3388: <a name="audit-packages"></a>7.15. Automated security checks</h2></div></div></div>
3389: <p>Please be aware that there can often be bugs in third-party software,
3390: and some of these bugs can leave a machine vulnerable to exploitation by
3391: attackers. In an effort to lessen the exposure, the NetBSD packages team
3392: maintains a database of known-exploits to packages which have at one time
3393: been included in pkgsrc. The database can be downloaded automatically, and
3394: a security audit of all packages installed on a system can take place. To
1.76 rillig 3395: 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 3396: components:</p>
3397: <div class="orderedlist"><ol type="1">
3398: <li>
3399: <p><span><strong class="command">download-vulnerability-list</strong></span>, an easy way to
3400: download a list of the security vulnerabilities information. This list
3401: is kept up to date by the NetBSD security officer and the NetBSD
3402: packages team, and is distributed from the NetBSD ftp server:</p>
3403: <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>
3404: </li>
3405: <li><p><span><strong class="command">audit-packages</strong></span>, an easy way to audit the
3406: current machine, checking each vulnerability which is known. If a
3407: vulnerable package is installed, it will be shown by output to stdout,
3408: including a description of the type of vulnerability, and a URL
3409: containing more information.</p></li>
3410: </ol></div>
1.76 rillig 3411: <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 3412: package is strongly recommended! After
3413: “<span class="quote">audit-packages</span>” is installed, please read
3414: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
3415: audit-packages</code></strong>.</p>
1.87 wiz 3416: <p>If this package is installed, pkgsrc builds will use it to
3417: 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
3418: check.</p>
1.75 rillig 3419: </div>
3420: <div class="sect1" lang="en">
3421: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3422: <a name="ufaq-cflags"></a>7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
3423: <p>When you add your own preferences to the
3424: <code class="varname">CFLAGS</code> variable in your
1.76 rillig 3425: <code class="filename">mk.conf</code>, these flags are passed in
3426: environment variables to the <code class="filename">./configure</code>
1.75 rillig 3427: 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
3428: <code class="varname">CFLAGS</code> from the environment variable by
1.76 rillig 3429: overriding them in the <code class="filename">Makefile</code>s of their
1.75 rillig 3430: package.</p>
3431: <p>Currently there is no solution to this problem. If you
3432: really need the package to use your <code class="varname">CFLAGS</code>
3433: you should run <span><strong class="command">make patch</strong></span> in the package
1.76 rillig 3434: directory and then inspect any <code class="filename">Makefile</code> and
3435: <code class="filename">Makefile.in</code> for whether they define
1.75 rillig 3436: <code class="varname">CFLAGS</code> explicitly. Usually you can remove
3437: these lines. But be aware that some “<span class="quote">smart</span>”
3438: programmers write so bad code that it only works for the
3439: specific combination of <code class="varname">CFLAGS</code> they have
3440: chosen.</p>
3441: </div>
1.80 rillig 3442: <div class="sect1" lang="en">
3443: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.88 wiz 3444: <a name="ufaq-fail"></a>7.17. A package does not build. What shall I do?</h2></div></div></div>
1.80 rillig 3445: <div class="procedure"><ol type="1">
3446: <li><p>Make sure that your copy of pkgsrc is consistent. A
3447: case that occurs often is that people only update pkgsrc in
3448: parts, because of performance reasons. Since pkgsrc is one large
3449: system, not a collection of many small systems, there are
3450: sometimes changes that only work when the whole pkgsrc tree is
3451: updated.</p></li>
3452: <li><p>Make sure that you don't have any CVS conflicts.
3453: Search for “<span class="quote"><<<<<<</span>” or
3454: “<span class="quote">>>>>>></span>” in all your pkgsrc
3455: files.</p></li>
3456: <li><p>Make sure that you don't have old copies of the packages
3457: extracted. Run <span><strong class="command">make clean clean-depends</strong></span> to
3458: verify this.</p></li>
3459: <li><p>If the problem still exists, write a mail to the
3460: <code class="literal">pkgsrc-users</code> mailing list.</p></li>
3461: </ol></div>
3462: </div>
1.88 wiz 3463: <div class="sect1" lang="en">
3464: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.89 ! rillig 3465: <a name="faq.rcs-conflicts"></a>7.18. What does “<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>” mean?</h2></div></div></div>
! 3466: <p>You have modified a file from pkgsrc, and someone else has
! 3467: modified that same file afterwards in the CVS repository. Both changes
! 3468: are in the same region of the file, so when you updated pkgsrc, the
! 3469: <code class="literal">cvs</code> command marked the conflicting changes in the
! 3470: file. Because of these markers, the file is no longer a valid
! 3471: <code class="filename">Makefile</code>.</p>
! 3472: <p>Have a look at that file, and if you don't need your local changes
! 3473: anymore, you can remove that file and run <span><strong class="command">cvs -q update
! 3474: -dP</strong></span> in that directory to download the current version.</p>
! 3475: </div>
! 3476: <div class="sect1" lang="en">
! 3477: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 3478: <a name="too-much-time"></a>7.19. I have a little time to kill. What shall I do?</h2></div></div></div>
1.88 wiz 3479: <p>This is not really an FAQ yet, but here's the answer
3480: anyway.</p>
3481: <div class="itemizedlist"><ul type="disc">
3482: <li><p>Run <span><strong class="command">pkg_chk -N</strong></span> (from the
3483: <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
3484: will tell you about newer versions of installed packages that are
3485: available, but not yet updated in pkgsrc.</p></li>
3486: <li><p>Browse <code class="filename">pkgsrc/doc/TODO</code>
1.89 ! rillig 3487: — it contains a list of suggested new packages and a list of
1.88 wiz 3488: cleanups and enhancements for pkgsrc that would be nice to
3489: have.</p></li>
3490: <li><p>Review packages for which review was requested on
3491: the <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">pkgsrc-wip</a> review
3492: mailing list.</p></li>
3493: </ul></div>
3494: </div>
1.75 rillig 3495: </div>
3496: </div>
3497: <div class="part" lang="en">
3498: <div class="titlepage"><div><div><h1 class="title">
3499: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
1.77 rillig 3500: <div class="partintro" lang="en">
3501: <div></div>
3502: <p>This part of the book deals with creating and
3503: modifying packages. It starts with a “<span class="quote">HOWTO</span>”-like
3504: guide on creating a new package. The remaining chapters are more
3505: like a reference manual for pkgsrc.</p>
1.75 rillig 3506: <div class="toc">
3507: <p><b>Table of Contents</b></p>
3508: <dl>
1.77 rillig 3509: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
3510: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75 rillig 3511: <dd><dl>
1.77 rillig 3512: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
3513: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
3514: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
1.85 jmmv 3515: <dd><dl>
3516: <dt><span class="sect2"><a href="#components.patches.guidelines">9.3.1. Patching guidelines</a></span></dt>
3517: <dt><span class="sect2"><a href="#components.patches.feedback">9.3.2. Feedback to the author</a></span></dt>
3518: </dl></dd>
1.77 rillig 3519: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
3520: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 3521: <dd><dl>
3522: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
3523: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
3524: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
3525: </dl></dd>
1.77 rillig 3526: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
3527: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
3528: </dl></dd>
3529: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
3530: <dd><dl>
3531: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
3532: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
3533: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
3534: <dd><dl>
3535: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
3536: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
3537: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
3538: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
3539: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
3540: </dl></dd>
3541: </dl></dd>
3542: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
3543: <dd><dl>
3544: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
3545: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
3546: <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>
3547: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
3548: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
3549: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
3550: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
3551: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
3552: </dl></dd>
3553: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
3554: <dd><dl>
3555: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
3556: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
3557: <dd><dl>
3558: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
3559: <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>
3560: </dl></dd>
3561: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
3562: <dd><dl>
3563: <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>
3564: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
3565: </dl></dd>
3566: </dl></dd>
3567: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
3568: <dd><dl>
3569: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
3570: <dd><dl>
3571: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
3572: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
3573: </dl></dd>
3574: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
3575: <dd><dl>
3576: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
3577: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
3578: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
3579: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
3580: </dl></dd>
3581: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
3582: <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>
3583: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
3584: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
3585: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
3586: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
3587: <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>
3588: </dl></dd>
3589: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
3590: <dd><dl>
3591: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
3592: <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>
3593: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
3594: </dl></dd>
3595: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
3596: <dd><dl>
3597: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
3598: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
3599: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
3600: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
3601: <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 3602: <dd><dl>
3603: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
3604: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
3605: </dl></dd>
1.77 rillig 3606: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
3607: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
3608: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
3609: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
3610: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
3611: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
3612: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3613: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
3614: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3615: <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 3616: <dt><span class="sect1"><a href="#build.clean">15.16. Cleaning up</a></span></dt>
3617: <dt><span class="sect1"><a href="#build.helpful-targets">15.17. Other helpful targets</a></span></dt>
1.77 rillig 3618: </dl></dd>
3619: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
3620: <dd><dl>
3621: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
3622: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
3623: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
3624: </dl></dd>
3625: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
3626: <dd><dl>
3627: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
3628: <dd><dl>
1.78 rillig 3629: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
3630: <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>
3631: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
3632: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
3633: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
3634: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
3635: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
3636: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
3637: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
3638: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
3639: <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 3640: <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 3641: </dl></dd>
3642: <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>
3643: <dd><dl>
3644: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
3645: <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>
3646: </dl></dd>
3647: <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>
3648: <dd><dl>
3649: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
3650: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
3651: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
3652: </dl></dd>
1.87 wiz 3653: <dt><span class="sect1"><a href="#programming-languages">17.4. Programming languages</a></span></dt>
1.77 rillig 3654: <dd><dl>
1.87 wiz 3655: <dt><span class="sect2"><a href="#basic-programming-languages">17.4.1. C, C++, and Fortran</a></span></dt>
3656: <dt><span class="sect2"><a href="#java-programming-language">17.4.2. Java</a></span></dt>
3657: <dt><span class="sect2"><a href="#perl-scripts">17.4.3. Packages containing perl scripts</a></span></dt>
3658: <dt><span class="sect2"><a href="#other-programming-languages">17.4.4. Other programming languages</a></span></dt>
3659: </dl></dd>
3660: <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>
3661: <dd><dl>
3662: <dt><span class="sect2"><a href="#fixes.build.cpp">17.5.1. Compiling C and C++ code conditionally</a></span></dt>
3663: <dt><span class="sect2"><a href="#compiler-bugs">17.5.2. How to handle compiler bugs</a></span></dt>
3664: <dt><span class="sect2"><a href="#undefined-reference">17.5.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
3665: <dt><span class="sect2"><a href="#out-of-memory">17.5.4. Running out of memory</a></span></dt>
3666: </dl></dd>
3667: <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>
3668: <dd><dl>
3669: <dt><span class="sect2"><a href="#install-scripts">17.6.1. Creating needed directories</a></span></dt>
3670: <dt><span class="sect2"><a href="#where-to-install-documentation">17.6.2. Where to install documentation</a></span></dt>
3671: <dt><span class="sect2"><a href="#installing-score-files">17.6.3. Installing score files</a></span></dt>
3672: <dt><span class="sect2"><a href="#hardcoded-paths">17.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
3673: <dt><span class="sect2"><a href="#perl-modules">17.6.5. Packages installing perl modules</a></span></dt>
3674: <dt><span class="sect2"><a href="#faq.info-files">17.6.6. Packages installing info files</a></span></dt>
3675: <dt><span class="sect2"><a href="#manpages">17.6.7. Packages installing man pages</a></span></dt>
3676: <dt><span class="sect2"><a href="#gconf2-data-files">17.6.8. Packages installing GConf2 data files</a></span></dt>
3677: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.6.9. Packages installing scrollkeeper data files</a></span></dt>
3678: <dt><span class="sect2"><a href="#x11-fonts">17.6.10. Packages installing X11 fonts</a></span></dt>
3679: <dt><span class="sect2"><a href="#gtk2-modules">17.6.11. Packages installing GTK2 modules</a></span></dt>
3680: <dt><span class="sect2"><a href="#sgml-xml-data">17.6.12. Packages installing SGML or XML data</a></span></dt>
3681: <dt><span class="sect2"><a href="#mime-database">17.6.13. Packages installing extensions to the MIME database</a></span></dt>
3682: <dt><span class="sect2"><a href="#intltool">17.6.14. Packages using intltool</a></span></dt>
3683: <dt><span class="sect2"><a href="#startup-scripts">17.6.15. Packages installing startup scripts</a></span></dt>
3684: <dt><span class="sect2"><a href="#tex-packages">17.6.16. Packages installing TeX modules</a></span></dt>
3685: <dt><span class="sect2"><a href="#emulation-packages">17.6.17. Packages supporting running binaries in
3686: emulation</a></span></dt>
3687: <dt><span class="sect2"><a href="#hicolor-theme">17.6.18. Packages installing hicolor theme icons</a></span></dt>
3688: <dt><span class="sect2"><a href="#desktop-files">17.6.19. Packages installing desktop files</a></span></dt>
1.77 rillig 3689: </dl></dd>
1.87 wiz 3690: <dt><span class="sect1"><a href="#punting">17.7. Marking packages as having problems</a></span></dt>
1.77 rillig 3691: </dl></dd>
3692: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
3693: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
3694: <dd><dl>
3695: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
3696: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
3697: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
3698: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
3699: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
3700: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 3701: </dl></dd>
1.77 rillig 3702: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.85 jmmv 3703: <dt><span class="chapter"><a href="#gnome">21. GNOME packaging and porting</a></span></dt>
3704: <dd><dl>
3705: <dt><span class="sect1"><a href="#meta-packages">21.1. Meta packages</a></span></dt>
3706: <dt><span class="sect1"><a href="#new-package">21.2. Packaging a GNOME application</a></span></dt>
3707: <dt><span class="sect1"><a href="#full-update">21.3. Updating GNOME to a newer version</a></span></dt>
3708: <dt><span class="sect1"><a href="#patching">21.4. Patching guidelines</a></span></dt>
3709: </dl></dd>
1.75 rillig 3710: </dl>
3711: </div>
1.77 rillig 3712: </div>
3713: <div class="chapter" lang="en">
3714: <div class="titlepage"><div><div><h2 class="title">
3715: <a name="creating"></a>Chapter 8. Creating a new pkgsrc package from scratch</h2></div></div></div>
3716: <p>When you find a package that is not yet in pkgsrc, you
3717: most likely have a URL from where you can download the source
3718: code. Starting with this URL, creating a package involves only a
3719: few steps.</p>
3720: <div class="procedure"><ol type="1">
3721: <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>
3722: <li><p>Then, choose one of the top-level directories as the
3723: category in which you want to place your package. You can also
3724: create a directory of your own (maybe called
3725: <code class="filename">local</code>). In that category directory, create
3726: another directory for your package and change into
3727: it.</p></li>
3728: <li><p>Run the program <span><strong class="command">url2pkg</strong></span>, which
3729: will ask you for a URL. Enter the URL of the distribution file
3730: (in most cases a <code class="filename">.tar.gz</code> file) and watch
3731: how the basic ingredients of your package are created
3732: automatically. The distribution file is extracted automatically
3733: to fill in some details in the <code class="filename">Makefile</code>
3734: that would otherwise have to be done manually.</p></li>
3735: <li>
3736: <p>Examine the extracted files to determine the
3737: dependencies of your package. Ideally, this is mentioned in some
3738: <code class="filename">README</code> file, but things may differ. For
3739: each of these dependencies, look where it exists in pkgsrc, and
3740: if there is a file called <code class="filename">buildlink3.mk</code> in
3741: that directory, add a line to your package
3742: <code class="filename">Makefile</code> which includes that file just
3743: before the last line. If the <code class="filename">buildlink3.mk</code>
3744: file does not exist, add a <code class="varname">DEPENDS</code> line to
3745: the Makefile, which specifies the version of the dependency and
3746: where it can be found in pkgsrc. This line should be placed in
3747: the third paragraph. If the dependency is only needed for
3748: building the package, but not when using it, use
3749: <code class="varname">BUILD_DEPENDS</code> instead of
3750: <code class="varname">DEPENDS</code>. Your package may then look like
3751: this:</p>
3752: <pre class="programlisting">
3753: [...]
3754:
3755: BUILD_DEPENDS+= lua>=5.0:../../lang/lua
3756: DEPENDS+= screen-[0-9]*:../../misc/screen
3757: DEPENDS+= screen>=4.0:../../misc/screen
3758:
3759: [...]
3760:
3761: .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
3762: .include "../../devel/glib2/buildlink3.mk"
3763: .include "../../mk/bsd.pkg.mk"
3764: </pre>
3765: </li>
3766: <li><p>Run <span><strong class="command">pkglint</strong></span> to see what things
3767: still need to be done to make your package a “<span class="quote">good</span>”
3768: one. If you don't know what pkglint's warnings want to tell you,
3769: try <span><strong class="command">pkglint --explain</strong></span> or <span><strong class="command">pkglint
3770: -e</strong></span>, which outputs additional
3771: explanations.</p></li>
3772: <li><p>Now, run <span><strong class="command">bmake</strong></span> to build the
3773: package. For the various things that can go wrong in this phase,
3774: consult <a href="#fixes" title="Chapter 17. Making your package work">Chapter 17, <i>Making your package work</i></a>.</p></li>
3775: <li><p>When the package builds fine, the next step is to
3776: install the package. Run <span><strong class="command">bmake install</strong></span> and
3777: hope that everything works.</p></li>
3778: <li><p>Up to now, the file <code class="filename">PLIST</code>,
3779: which contains a list of the files that are installed by the
3780: package, is nearly empty. Run <span><strong class="command">bmake print-PLIST
3781: >PLIST</strong></span> to generate a probably correct list. Check
3782: the file using your preferred text editor to see if the list of
3783: files looks plausible.</p></li>
3784: <li><p>Run <span><strong class="command">pkglint</strong></span> again to see if the
3785: generated <code class="filename">PLIST</code> contains garbage or
3786: not.</p></li>
3787: <li><p>When you ran <span><strong class="command">bmake install</strong></span>, the
3788: package has been registered in the database of installed files,
3789: but with an empty list of files. To fix this, run <span><strong class="command">bmake
3790: deinstall</strong></span> and <span><strong class="command">bmake install</strong></span> again.
3791: Now the package is registered with the list of files from
3792: <code class="filename">PLIST</code>.</p></li>
3793: <li><p>Run <span><strong class="command">bmake package</strong></span> to create a
3794: binary package from the set of installed files.</p></li>
3795: </ol></div>
3796: </div>
1.75 rillig 3797: <div class="chapter" lang="en">
3798: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 3799: <a name="components"></a>Chapter 9. Package components - files, directories and contents</h2></div></div></div>
1.75 rillig 3800: <div class="toc">
3801: <p><b>Table of Contents</b></p>
3802: <dl>
1.77 rillig 3803: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
3804: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
3805: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
1.85 jmmv 3806: <dd><dl>
3807: <dt><span class="sect2"><a href="#components.patches.guidelines">9.3.1. Patching guidelines</a></span></dt>
3808: <dt><span class="sect2"><a href="#components.patches.feedback">9.3.2. Feedback to the author</a></span></dt>
3809: </dl></dd>
1.77 rillig 3810: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
3811: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78 rillig 3812: <dd><dl>
3813: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
3814: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
3815: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
3816: </dl></dd>
1.77 rillig 3817: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
3818: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
1.75 rillig 3819: </dl>
3820: </div>
1.87 wiz 3821: <p>Whenever you're preparing a package, there are a number of
3822: files involved which are described in the following
3823: sections.</p>
1.75 rillig 3824: <div class="sect1" lang="en">
3825: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3826: <a name="components.Makefile"></a>9.1. <code class="filename">Makefile</code></h2></div></div></div>
1.75 rillig 3827: <p>Building, installation and creation of a binary package are all
1.87 wiz 3828: controlled by the package's <code class="filename">Makefile</code>.
3829: The <code class="filename">Makefile</code> describes various things about
3830: a package, for example from where to get it, how to configure,
3831: build, and install it.</p>
1.76 rillig 3832: <p>A package <code class="filename">Makefile</code> contains several
1.87 wiz 3833: sections that describe the package.</p>
1.75 rillig 3834: <p>In the first section there are the following variables, which
1.87 wiz 3835: should appear exactly in the order given here. The order and
3836: grouping of the variables is mostly historical and has no further
3837: meaning.</p>
1.75 rillig 3838: <div class="itemizedlist"><ul type="disc">
3839: <li><p><code class="varname">DISTNAME</code> is the basename of the
1.87 wiz 3840: distribution file to be downloaded from the package's
3841: website.</p></li>
1.75 rillig 3842: <li><p><code class="varname">PKGNAME</code> is the name of the
1.87 wiz 3843: package, as used by pkgsrc. You only need to provide it if
3844: <code class="varname">DISTNAME</code> (which is the default) is not a good
3845: name for the package in pkgsrc. Usually it is the pkgsrc
3846: directory name together with the version number. It must match the
3847: regular expression
3848: <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
3849: starts with a letter or digit, and contains only letters, digits,
3850: dashes, underscores, dots and plus signs.</p></li>
3851: <li><p><code class="varname">SVR4_PKGNAME</code> is the name of
3852: the package file to create if the <code class="varname">PKGNAME</code>
3853: isn't unique on a SVR4 system. The default is
3854: <code class="varname">PKGNAME</code>, which may be shortened when you use
3855: <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
3856: <code class="varname">SVR4_PKGNAME</code> if <code class="varname">PKGNAME</code>
3857: does not produce an unique package name on a SVR4 system.
3858: The length of <code class="varname">SVR4_PKGNAME</code> is limited to 5
3859: characters.</p></li>
1.75 rillig 3860: <li>
3861: <p><code class="varname">CATEGORIES</code> is a list of categories
1.87 wiz 3862: which the package fits in. You can choose any of the top-level
3863: directories of pkgsrc for it.</p>
1.75 rillig 3864: <p>Currently the following values are available for
1.87 wiz 3865: <code class="varname">CATEGORIES</code>. If more than
3866: one is used, they need to be separated by spaces:</p>
1.75 rillig 3867: <pre class="programlisting">
1.87 wiz 3868: archivers cross geography meta-pkgs security
3869: audio databases graphics misc shells
3870: benchmarks devel ham multimedia sysutils
3871: biology editors inputmethod net textproc
3872: cad emulators lang news time
3873: chat finance mail parallel wm
3874: comms fonts math pkgtools www
3875: converters games mbone print x11
3876: </pre>
1.75 rillig 3877: </li>
1.81 rillig 3878: <li><p><code class="varname">MASTER_SITES</code>,
1.87 wiz 3879: <code class="varname">DYNAMIC_MASTER_SITES</code>,
3880: <code class="varname">DIST_SUBDIR</code>, <code class="varname">EXTRACT_SUFX</code>
3881: and <code class="varname">DISTFILES</code> are discussed in detail in
3882: <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 3883: </ul></div>
3884: <p>The second section contains information about separately
1.87 wiz 3885: downloaded patches, if any.
3886: </p>
1.75 rillig 3887: <div class="itemizedlist"><ul type="disc">
3888: <li><p><code class="varname">PATCHFILES:</code>
1.87 wiz 3889: Name(s) of additional files that contain distribution patches.
3890: There is no default. pkgsrc will look for them at
3891: <code class="varname">PATCH_SITES</code>.
3892: They will automatically be uncompressed before patching if
3893: the names end with <code class="filename">.gz</code> or
3894: <code class="filename">.Z</code>.</p></li>
1.75 rillig 3895: <li><p><code class="varname">PATCH_SITES</code>:
1.87 wiz 3896: Primary location(s) for distribution patch files (see
3897: <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
1.75 rillig 3898: </ul></div>
3899: <p>The third section contains the following variables.
1.87 wiz 3900: </p>
1.75 rillig 3901: <div class="itemizedlist"><ul type="disc">
3902: <li><p><code class="varname">MAINTAINER</code> is the email address
1.87 wiz 3903: of the person who feels responsible for this package, and who is
3904: most likely to look at problems or questions regarding this
3905: 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
3906: developers should contact the <code class="varname">MAINTAINER</code> before
3907: making major changes to the package. When packaging a new program,
3908: set <code class="varname">MAINTAINER</code> to yourself. If you really can't
3909: maintain the package for future updates, set it to
3910: <code class="email"><<a href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>></code>.</p></li>
1.75 rillig 3911: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
1.87 wiz 3912: find more information about the package.</p></li>
1.75 rillig 3913: <li><p><code class="varname">COMMENT</code> is a one-line
1.87 wiz 3914: description of the package (should not include the package
3915: name).</p></li>
1.75 rillig 3916: </ul></div>
3917: <p>Other variables that affect the build:
1.87 wiz 3918: </p>
1.75 rillig 3919: <div class="itemizedlist"><ul type="disc"><li>
3920: <p><code class="varname">WRKSRC</code>: The directory where the
1.87 wiz 3921: interesting distribution files of the package are found. The
3922: default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
3923: works for most packages.</p>
1.75 rillig 3924: <p>If a package doesn't create a subdirectory for itself
1.87 wiz 3925: (most GNU software does, for instance), but extracts itself in
3926: the current directory, you should set
3927: <code class="varname">WRKSRC=${WRKDIR}</code>.</p>
3928: <p>If a package doesn't create a subdirectory with the
3929: name of <code class="varname">DISTNAME</code> but some different name,
3930: set <code class="varname">WRKSRC</code> to point to the proper name in
3931: <code class="filename">${WRKDIR}</code>, for example
3932: <code class="varname">WRKSRC=${WRKDIR}/${DISTNAME}/unix</code>. See
3933: <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 3934: <p>The name of the working directory created by pkgsrc is
1.87 wiz 3935: taken from the <code class="varname">WRKDIR_BASENAME</code>
3936: variable. By default, its value is
3937: <code class="filename">work</code>. If you want to use the same
3938: pkgsrc tree for building different kinds of binary packages,
3939: you can change the variable according to your needs. Two
3940: other variables handle common cases of setting
3941: <code class="varname">WRKDIR_BASENAME</code> individually. If
3942: <code class="varname">OBJHOSTNAME</code> is defined in
3943: <code class="filename">/etc/mk.conf</code>, the first component of
3944: the host's name is attached to the directory name. If
3945: <code class="varname">OBJMACHINE</code> is defined, the platform name
3946: is attached, which might look like
3947: <code class="filename">work.i386</code> or
3948: <code class="filename">work.sparc</code>.</p>
1.75 rillig 3949: </li></ul></div>
3950: <p>Please pay attention to the following gotchas:</p>
3951: <div class="itemizedlist"><ul type="disc">
1.87 wiz 3952: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are
1.88 wiz 3953: installed in compressed form by the package. For packages using
3954: BSD-style makefiles which honor MANZ, there is
3955: <code class="varname">MANCOMPRESSED_IF_MANZ</code>.</p></li>
1.76 rillig 3956: <li><p>Replace <code class="filename">/usr/local</code> with
1.88 wiz 3957: “<span class="quote">${PREFIX}</span>” in all files (see patches,
3958: below).</p></li>
3959: <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 3960: </ul></div>
3961: </div>
3962: <div class="sect1" lang="en">
3963: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3964: <a name="components.distinfo"></a>9.2. <code class="filename">distinfo</code></h2></div></div></div>
1.76 rillig 3965: <p>The <code class="filename">distinfo</code> file contains the message
1.87 wiz 3966: digest, or checksum, of each distfile needed for the package. This
3967: ensures that the distfiles retrieved from the Internet have not been
3968: corrupted during transfer or altered by a malign force to introduce
3969: a security hole. Due to recent rumor about weaknesses of digest
3970: algorithms, all distfiles are protected using both SHA1 and RMD160
3971: message digests, as well as the file size.</p>
1.76 rillig 3972: <p>The <code class="filename">distinfo</code> file also contains the
1.87 wiz 3973: checksums for all the patches found in the
3974: <code class="filename">patches</code> directory (see <a href="#components.patches" title="9.3. patches/*">Section 9.3, “patches/*”</a>).</p>
1.76 rillig 3975: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.87 wiz 3976: <span><strong class="command">make makedistinfo</strong></span> or <span><strong class="command">make mdi</strong></span>
3977: command.</p>
1.75 rillig 3978: <p>Some packages have different sets of distfiles depending on
1.87 wiz 3979: 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
3980: <code class="filename">distinfo</code> file and care should be taken when
3981: upgrading such a package to ensure distfile information is not
3982: lost.</p>
1.75 rillig 3983: </div>
3984: <div class="sect1" lang="en">
3985: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 3986: <a name="components.patches"></a>9.3. patches/*</h2></div></div></div>
1.75 rillig 3987: <p>This directory contains files that are used by the
1.87 wiz 3988: <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
3989: modify the sources as distributed in the distribution file into a form
3990: that will compile and run perfectly on NetBSD. The files are applied
3991: successively in alphabetic order (as returned by a shell
3992: “<span class="quote">patches/patch-*</span>” glob expansion), so
3993: <code class="filename">patch-aa</code> is applied before
3994: <code class="filename">patch-ab</code>, etc.</p>
1.76 rillig 3995: <p>The <code class="filename">patch-*</code> files should be in
1.87 wiz 3996: <span><strong class="command">diff -bu</strong></span> format, and apply without a fuzz to avoid
3997: problems. (To force patches to apply
3998: with fuzz you can set <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>).
3999: Furthermore, do not put changes for more than one file into a single
4000: patch file, as this will make future modifications more difficult.</p>
1.75 rillig 4001: <p>Similar, a file should be patched at most once, not several times by
1.87 wiz 4002: several different patches. If a file needs several patches, they should
4003: be combined into one file.</p>
1.75 rillig 4004: <p>One important thing to mention is to pay attention that no RCS IDs
1.87 wiz 4005: get stored in the patch files, as these will cause problems when
4006: later checked into the NetBSD CVS tree. Use the
4007: <span><strong class="command">pkgdiff</strong></span> from the
4008: <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
4009: these problems.</p>
4010: <p>For even more automation, we recommend using
4011: <span><strong class="command">mkpatches</strong></span> from the same package to make a
4012: whole set of patches. You just have to backup files before you
4013: edit them to <code class="filename">filename.orig</code>, e.g. with
4014: <span><strong class="command">cp -p filename filename.orig</strong></span> or, easier, by
4015: using <span><strong class="command">pkgvi</strong></span> again from the same package. If
4016: you upgrade a package this way, you can easily compare the new
4017: set of patches with the previously existing one with
4018: <span><strong class="command">patchdiff</strong></span>. Copy the patches you want to use
4019: or update from the <code class="filename">work/.newpatches</code>
4020: directory to <code class="filename">patches/</code>.</p>
4021: <p>When you have finished a package, remember to generate
4022: the checksums for the patch files by using the <span><strong class="command">make
4023: makepatchsum</strong></span> command, see <a href="#components.distinfo" title="9.2. distinfo">Section 9.2, “<code class="filename">distinfo</code>”</a>.</p>
4024: <p>When adding a patch that corrects a problem in the
4025: distfile (rather than e.g. enforcing pkgsrc's view of where
4026: man pages should go), send the patch as a bug report to the
4027: maintainer. This benefits non-pkgsrc users of the package,
4028: and usually makes it possible to remove the patch in future
4029: version.</p>
4030: <p>If you want to share patches between multiple packages
4031: in pkgsrc, e.g. because they use the same distfiles, set
4032: <code class="varname">PATCHDIR</code> to the path where the patch files
4033: can be found, e.g.:</p>
4034: <pre class="programlisting">
4035: PATCHDIR= ${.CURDIR}/../xemacs/patches
4036: </pre>
1.75 rillig 4037: <p>Patch files that are distributed by the author or other
1.87 wiz 4038: maintainers can be listed in
4039: <code class="varname">PATCHFILES</code>.</p>
4040: <p>If it is desired to store any patches that should not be
4041: committed into pkgsrc, they can be kept outside the pkgsrc
4042: tree in the <code class="filename">$LOCALPATCHES</code> directory. The
4043: directory tree there is expected to have the same
4044: “<span class="quote">category/package</span>” structure as pkgsrc, and
4045: patches are expected to be stored inside these dirs (also
4046: known as <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
4047: example, if you want to keep a private patch for
4048: <code class="filename">pkgsrc/graphics/png</code>, keep it in
4049: <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
4050: files in the named directory are expected to be patch files,
4051: and <span class="emphasis"><em>they are applied after pkgsrc patches are
4052: applied</em></span>.</p>
1.85 jmmv 4053: <div class="sect2" lang="en">
4054: <div class="titlepage"><div><div><h3 class="title">
4055: <a name="components.patches.guidelines"></a>9.3.1. Patching guidelines</h3></div></div></div>
4056: <p>When fixing a portability issue in the code do not use
4057: preprocessor magic to check for the current operating system nor
4058: platform. Doing so hurts portability to other platforms because
4059: the OS-specific details are not abstracted appropriately.</p>
4060: <p>The general rule to follow is: instead of checking for the
4061: operating system the application is being built on, check for the
4062: specific <span class="emphasis"><em>features</em></span> you need. For example,
4063: instead of assuming that kqueue is available under NetBSD and
4064: using the <code class="varname">__NetBSD__</code> macro to conditionalize
1.89 ! rillig 4065: kqueue support, add a check that detects kqueue itself —
1.85 jmmv 4066: yes, this generally involves patching the
4067: <span><strong class="command">configure</strong></span> script. There is absolutely nothing
4068: that prevents some OSes from adopting interfaces from other OSes
4069: (e.g. Linux implementing kqueue), something that the above checks
4070: cannot take into account.</p>
4071: <p>Of course, checking for features generally involves more
4072: work on the developer's side, but the resulting changes are
1.87 wiz 4073: cleaner and there are chances they will work on many other
1.85 jmmv 4074: platforms. Not to mention that there are higher chances of being
4075: later integrated into the mainstream sources. Remember:
4076: <span class="emphasis"><em>It doesn't work unless it is right!</em></span></p>
4077: <p>Some typical examples:</p>
4078: <div class="table">
4079: <a name="patch-examples"></a><p class="title"><b>Table 9.1. Patching examples</b></p>
1.89 ! rillig 4080: <table summary="Patching examples" border="1">
1.85 jmmv 4081: <colgroup>
4082: <col>
4083: <col>
4084: <col>
4085: </colgroup>
4086: <thead><tr>
4087: <th>Where</th>
4088: <th>Incorrect</th>
4089: <th>Correct</th>
4090: </tr></thead>
4091: <tbody>
4092: <tr>
4093: <td>configure script</td>
4094: <td>
4095: <pre class="programlisting">case ${target_os} in
1.87 wiz 4096: netbsd*) have_kvm=yes ;;
4097: *) have_kvm=no ;;
4098: esac</pre>
1.85 jmmv 4099: </td>
4100: <td>
4101: <pre class="programlisting">AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)</pre>
4102: </td>
4103: </tr>
4104: <tr>
4105: <td>C source file</td>
4106: <td>
4107: <pre class="programlisting">#if defined(__NetBSD__)
1.87 wiz 4108: # include <sys/event.h>
4109: #endif</pre>
1.85 jmmv 4110: </td>
4111: <td>
4112: <pre class="programlisting">#if defined(HAVE_SYS_EVENT_H)
1.87 wiz 4113: # include <sys/event.h>
4114: #endif</pre>
1.85 jmmv 4115: </td>
4116: </tr>
4117: <tr>
4118: <td>C source file</td>
4119: <td>
4120: <pre class="programlisting">int
1.87 wiz 4121: monitor_file(...)
4122: {
4123: #if defined(__NetBSD__)
4124: int fd = kqueue();
4125: ...
4126: #else
4127: ...
4128: #endif
4129: }</pre>
1.85 jmmv 4130: </td>
4131: <td>
4132: <pre class="programlisting">int
1.87 wiz 4133: monitor_file(...)
4134: {
4135: #if defined(HAVE_KQUEUE)
4136: int fd = kqueue();
4137: ...
4138: #else
4139: ...
4140: #endif
4141: }</pre>
1.85 jmmv 4142: </td>
4143: </tr>
4144: </tbody>
1.89 ! rillig 4145: </table>
1.85 jmmv 4146: </div>
1.89 ! rillig 4147: <p>For more information, please read the <span class="emphasis"><em>Making
1.85 jmmv 4148: packager-friendly software</em></span> article (<a href="http://www.onlamp.com/pub/a/onlamp/2005/03/31/packaging.html" target="_top">part
4149: 1</a>, <a href="http://www.oreillynet.com/pub/a/onlamp/2005/04/28/packaging2.html" target="_top">part
4150: 2</a>). It summarizes multiple details on how to make
4151: software easier to package; all the suggestions in it were
4152: collected from our experience in pkgsrc work, so they are possibly
4153: helpful when creating patches too.</p>
4154: </div>
4155: <div class="sect2" lang="en">
4156: <div class="titlepage"><div><div><h3 class="title">
4157: <a name="components.patches.feedback"></a>9.3.2. Feedback to the author</h3></div></div></div>
4158: <p>Always, always, <span class="strong"><strong>always</strong></span>
4159: feed back any <span class="emphasis"><em>portability fixes</em></span> or
4160: improvements you do to a package to the mainstream developers.
4161: This is the only way to get their attention on portability issues
4162: and to ensure that future versions can be built out-of-the box on
4163: NetBSD. Furthermore, any user that gets newer distfiles will get
4164: the fixes straight from the packaged code.</p>
4165: <p>This generally involves cleaning up the patches as described
4166: in the following section (because sometimes the patches that are
4167: added to pkgsrc are quick hacks), filling bug reports in the
4168: appropriate trackers for the projects and working with the
4169: mainstream authors to accept your changes. It is
4170: <span class="emphasis"><em>extremely important</em></span> that you do it so that
4171: the packages in pkgsrc are kept simple and thus further changes
4172: can be done without much hassle.</p>
4173: <p>Support the idea of free software!</p>
4174: </div>
1.75 rillig 4175: </div>
4176: <div class="sect1" lang="en">
4177: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4178: <a name="other-mandatory-files"></a>9.4. Other mandatory files</h2></div></div></div>
1.75 rillig 4179: <div class="variablelist"><dl>
1.76 rillig 4180: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
1.75 rillig 4181: <dd><p>A multi-line description of the piece of software. This should include
1.87 wiz 4182: any credits where they are due. Please bear in mind that others do not
4183: share your sense of humour (or spelling idiosyncrasies), and that others
4184: will read everything that you write here.</p></dd>
1.76 rillig 4185: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
1.87 wiz 4186: <dd><p>This file governs the files that are installed on your
4187: system: all the binaries, manual pages, etc. There are other
4188: directives which may be entered in this file, to control the
4189: creation and deletion of directories, and the location of
4190: inserted files. See <a href="#plist" title="Chapter 11. PLIST issues">Chapter 11, <i>PLIST issues</i></a> for more
4191: information.</p></dd>
1.75 rillig 4192: </dl></div>
4193: </div>
4194: <div class="sect1" lang="en">
4195: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4196: <a name="components.optional"></a>9.5. Optional files</h2></div></div></div>
1.78 rillig 4197: <div class="sect2" lang="en">
4198: <div class="titlepage"><div><div><h3 class="title">
4199: <a name="components.optional.bin"></a>9.5.1. Files affecting the binary package</h3></div></div></div>
1.75 rillig 4200: <div class="variablelist"><dl>
1.76 rillig 4201: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.75 rillig 4202: <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 4203: First time after package extraction and before files are
4204: moved in place, the second time after the files to install
4205: are moved in place. This can be used to do any custom
4206: procedures not possible with @exec commands in
4207: <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
4208: <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 4209: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
1.75 rillig 4210: <dd><p>This script is executed before and after any files are removed. It is
1.87 wiz 4211: this script's responsibility to clean up any additional messy details
4212: around the package's installation, since all pkg_delete knows is how to
4213: delete the files created in the original distribution.
4214: 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>
4215: 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 4216: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
1.75 rillig 4217: <dd>
4218: <p>This file is displayed after installation of the package.
1.87 wiz 4219: Useful for things like legal notices on almost-free
4220: software and hints for updating config files after
4221: installing modules for apache, PHP etc.
4222: Please note that you can modify variables in it easily by using
4223: <code class="varname">MESSAGE_SUBST</code> in the package's
4224: <code class="filename">Makefile</code>:</p>
1.75 rillig 4225: <pre class="programlisting">
1.87 wiz 4226: MESSAGE_SUBST+= SOMEVAR="somevalue"
4227: </pre>
1.75 rillig 4228: <p>replaces "${SOMEVAR}" with “<span class="quote">somevalue</span>” in
1.87 wiz 4229: <code class="filename">MESSAGE</code>. By default, substitution is
4230: performed for <code class="varname">PKGNAME</code>,
4231: <code class="varname">PKGBASE</code>, <code class="varname">PREFIX</code>,
4232: <code class="varname">LOCALBASE</code>, <code class="varname">X11PREFIX</code>,
4233: <code class="varname">X11BASE</code>,
4234: <code class="varname">PKG_SYSCONFDIR</code>,
4235: <code class="varname">ROOT_GROUP</code>, and
4236: <code class="varname">ROOT_GROUP</code>.</p>
4237: <p>You can display a different or additional files by
4238: setting the <code class="varname">MESSAGE_SRC</code> variable. Its
4239: default is <code class="filename">MESSAGE</code>, if the file
4240: exists.</p>
1.75 rillig 4241: </dd>
1.78 rillig 4242: <dt><span class="term"><code class="filename">ALTERNATIVES</code></span></dt>
4243: <dd><p>FIXME: There is no documentation on the
4244: alternatives framework.</p></dd>
4245: </dl></div>
4246: </div>
4247: <div class="sect2" lang="en">
4248: <div class="titlepage"><div><div><h3 class="title">
4249: <a name="components.optional.build"></a>9.5.2. Files affecting the build process</h3></div></div></div>
4250: <div class="variablelist"><dl>
4251: <dt><span class="term"><code class="filename">Makefile.common</code></span></dt>
4252: <dd><p>This file contains arbitrary things that could
4253: also go into a <code class="filename">Makefile</code>, but its purpose is
4254: to be used by more than one package. This file should only be
4255: used when the packages that will use the file are known in
4256: advance. For other purposes it is often better to write a
4257: <code class="filename">*.mk</code> file and give it a good name that
4258: describes what it does.</p></dd>
4259: <dt><span class="term"><code class="filename">buildlink3.mk</code></span></dt>
4260: <dd><p>This file contains the dependency information
4261: for the buildlink3 framework (see <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a>).</p></dd>
4262: <dt><span class="term"><code class="filename">hacks.mk</code></span></dt>
4263: <dd><p>This file contains workarounds for compiler bugs
4264: and similar things. It is included automatically by the pkgsrc
4265: infrastructure, so you don't need an extra
4266: <code class="literal">.include</code> line for
4267: it.</p></dd>
4268: <dt><span class="term"><code class="filename">options.mk</code></span></dt>
4269: <dd><p>This file contains the code for the
4270: package-specific options (see <a href="#options" title="Chapter 14. Options handling">Chapter 14, <i>Options handling</i></a>) that can be
4271: selected by the user. If a package has only one or two options,
4272: it is equally acceptable to put the code directly into the
4273: <code class="filename">Makefile</code>.</p></dd>
4274: </dl></div>
4275: </div>
4276: <div class="sect2" lang="en">
4277: <div class="titlepage"><div><div><h3 class="title">
4278: <a name="components.optional.none"></a>9.5.3. Files affecting nothing at all</h3></div></div></div>
4279: <div class="variablelist"><dl>
4280: <dt><span class="term"><code class="filename">README*</code></span></dt>
4281: <dd><p>These files do not take place in the creation of
4282: a package and thus are purely informative to the package
4283: developer.</p></dd>
4284: <dt><span class="term"><code class="filename">TODO</code></span></dt>
4285: <dd><p>This file contains things that need to be done
4286: to make the package even
4287: better.</p></dd>
1.75 rillig 4288: </dl></div>
4289: </div>
1.78 rillig 4290: </div>
1.75 rillig 4291: <div class="sect1" lang="en">
4292: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4293: <a name="work-dir"></a>9.6. <code class="filename">work*</code></h2></div></div></div>
1.75 rillig 4294: <p>When you type <span><strong class="command">make</strong></span>, the distribution files are
1.87 wiz 4295: unpacked into the directory denoted by
4296: <code class="varname">WRKDIR</code>. It can be removed by running
4297: <span><strong class="command">make clean</strong></span>. Besides the sources, this
4298: directory is also used to keep various timestamp files.
4299: The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
4300: The default is <code class="filename">${.CURDIR}/work</code>
4301: or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
4302: if <code class="varname">OBJMACHINE</code> is set.</p>
1.75 rillig 4303: </div>
4304: <div class="sect1" lang="en">
4305: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4306: <a name="files-dir"></a>9.7. <code class="filename">files/*</code></h2></div></div></div>
1.75 rillig 4307: <p>If you have any files that you wish to be placed in the package prior
1.87 wiz 4308: to configuration or building, you could place these files here and use
4309: a <span><strong class="command">${CP}</strong></span> command in the
4310: “<span class="quote">pre-configure</span>” target to achieve
4311: this. Alternatively, you could simply diff the file against
4312: <code class="filename">/dev/null</code> and use the patch mechanism to manage
4313: the creation of this file.</p>
4314: <p>If you want to share files in this way with other
4315: packages, set the <code class="varname">FILESDIR</code> variable to point
4316: to the other package's <code class="filename">files</code> directory,
4317: e.g.:</p>
4318: <pre class="programlisting">
4319: FILESDIR=${.CURDIR}/../xemacs/files
4320: </pre>
1.75 rillig 4321: </div>
4322: </div>
4323: <div class="chapter" lang="en">
4324: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4325: <a name="makefile"></a>Chapter 10. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.75 rillig 4326: <div class="toc">
4327: <p><b>Table of Contents</b></p>
4328: <dl>
1.77 rillig 4329: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
4330: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
4331: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
4332: <dd><dl>
4333: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
4334: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
4335: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
4336: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
4337: <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 4338: </dl></dd>
4339: </dl>
4340: </div>
1.76 rillig 4341: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
1.75 rillig 4342: each of which forms a well-defined part of the pkgsrc system. Using
4343: 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
4344: like pkgsrc requires some discipline to keep the code correct and
4345: understandable.</p>
1.76 rillig 4346: <p>The basic ingredients for <code class="filename">Makefile</code>
1.75 rillig 4347: programming are variables (which are actually macros) and shell
4348: commands. Among these shell commands may even be more complex ones
4349: 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
4350: as intended it is necessary to quote all variables correctly when they
4351: are used.</p>
4352: <p>This chapter describes some patterns, that appear quite often in
1.76 rillig 4353: <code class="filename">Makefile</code>s, including the pitfalls that come along
1.75 rillig 4354: with them.</p>
4355: <div class="sect1" lang="en">
4356: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4357: <a name="makefile.variables"></a>10.1. <code class="filename">Makefile</code> variables</h2></div></div></div>
1.76 rillig 4358: <p><code class="filename">Makefile</code> variables contain strings that
1.75 rillig 4359: can be processed using the five operators ``='', ``+='', ``?='',
4360: ``:='', 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
4361: page.</p>
4362: <p>When a variable's value is parsed from a
1.76 rillig 4363: <code class="filename">Makefile</code>, the hash character ``#'' and the
1.75 rillig 4364: backslash character ``\'' are handled specially. If a backslash is
4365: followed by a newline, any whitespace immediately in front of the
4366: backslash, the backslash, the newline, and any whitespace
4367: immediately behind the newline are replaced with a single space. A
4368: backslash character and an immediately following hash character are
4369: replaced with a single hash character. Otherwise, the backslash is
4370: passed as is. In a variable assignment, any hash character that is
4371: not preceded by a backslash starts a comment that continues upto the
4372: end of the logical line.</p>
4373: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
4374: the only way to create a variable consisting of a single backslash
4375: is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
4376: <p>So far for defining variables. The other thing you can do with
4377: variables is evaluating them. A variable is evaluated when it is
4378: part of the right side of the ``:='' or the ``!='' operator, or
4379: directly before executing a shell command which the variable is part
4380: 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
4381: is, variables are not evaluated until there's no other way. The
4382: ``modifiers'' mentioned in the man page also evaluate the
4383: variable.</p>
4384: <p>Some of the modifiers split the string into words and then
4385: operate on the words, others operate on the string as a whole. When
4386: a string is split into words, it is split as you would expect
4387: 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.89 ! rillig 4388: <p>No rule without exception—the <span><strong class="command">.for</strong></span>
1.75 rillig 4389: loop does not follow the shell quoting rules but splits at sequences
4390: of whitespace.</p>
4391: <p>There are several types of variables that should be handled
4392: differently. Strings and two types of lists.</p>
4393: <div class="itemizedlist"><ul type="disc">
4394: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
4395: characters. Nevertheless, you should restrict yourself to only
4396: using printable characters. Examples are
4397: <code class="varname">PREFIX</code> and
4398: <code class="varname">COMMENT</code>.</p></li>
4399: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
4400: are never exported to any shell command. Their elements are
4401: separated by whitespace. Therefore, the elements themselves cannot
4402: have embedded whitespace. Any other characters are allowed.
4403: Internal lists can be used in <span><strong class="command">.for</strong></span> loops.
4404: Examples are <code class="varname">DEPENDS</code> and
4405: <code class="varname">BUILD_DEPENDS</code>.</p></li>
4406: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
4407: may be exported to a shell command. Their elements can contain any
4408: characters, including whitespace. That's why they cannot be used
4409: in <span><strong class="command">.for</strong></span> loops. Examples are
4410: <code class="varname">DISTFILES</code> and
4411: <code class="varname">MASTER_SITES</code>.</p></li>
4412: </ul></div>
4413: <div class="sect2" lang="en">
4414: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4415: <a name="makefile.variables.names"></a>10.1.1. Naming conventions</h3></div></div></div>
1.75 rillig 4416: <div class="itemizedlist"><ul type="disc">
4417: <li><p>All variable names starting with an underscore
4418: are reserved for use by the pkgsrc infrastructure. They shall
4419: not be used by package
1.76 rillig 4420: <code class="filename">Makefile</code>s.</p></li>
1.75 rillig 4421: <li><p>In <span><strong class="command">.for</strong></span> loops you should use
4422: lowercase variable names for the iteration
4423: variables.</p></li>
4424: <li><p>All list variables should have a ``plural''
4425: name, e.g. <code class="varname">PKG_OPTIONS</code> or
4426: <code class="varname">DISTFILES</code>.</p></li>
4427: </ul></div>
4428: </div>
4429: </div>
4430: <div class="sect1" lang="en">
4431: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4432: <a name="makefile.code"></a>10.2. Code snippets</h2></div></div></div>
1.75 rillig 4433: <p>This section presents you with some code snippets you should
4434: use in your own code. If you don't find anything appropriate here,
4435: you should test your code and add it here.</p>
4436: <div class="sect2" lang="en">
4437: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4438: <a name="adding-to-list"></a>10.2.1. Adding things to a list</h3></div></div></div>
1.75 rillig 4439: <pre class="programlisting">
4440: STRING= foo * bar `date`
4441: INT_LIST= # empty
4442: ANOTHER_INT_LIST= apache-[0-9]*:../../www/apache
4443: EXT_LIST= # empty
4444: ANOTHER_EXT_LIST= a=b c=d
1.1 grant 4445:
1.75 rillig 4446: INT_LIST+= ${STRING} # 1
4447: INT_LIST+= ${ANOTHER_INT_LIST} # 2
4448: EXT_LIST+= ${STRING:Q} # 3
4449: EXT_LIST+= ${ANOTHER_EXT_LIST} # 4
1.1 grant 4450: </pre>
1.75 rillig 4451: <p>When you add a string to an external list (example 3), it
4452: must be quoted. In all other cases, you must not add a quoting
4453: level. You must not merge internal and external lists, unless you
4454: are sure that all entries are correctly interpreted in both
4455: lists.</p>
4456: </div>
4457: <div class="sect2" lang="en">
4458: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4459: <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 4460: <pre class="programlisting">
4461: EXT_LIST= # empty
4462: .for i in ${INT_LIST}
4463: EXT_LIST+= ${i:Q}""
4464: .endfor
1.1 grant 4465: </pre>
1.75 rillig 4466: <p>This code converts the internal list
4467: <code class="varname">INT_LIST</code> into the external list
4468: <code class="varname">EXT_LIST</code>. As the elements of an internal list
4469: are unquoted they must be quoted here. The reason for appending
4470: <code class="varname">""</code> is explained below.</p>
4471: </div>
4472: <div class="sect2" lang="en">
4473: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4474: <a name="passing-variable-to-shell"></a>10.2.3. Passing variables to a shell command</h3></div></div></div>
1.79 rillig 4475: <p>Sometimes you may want to print an arbitrary string. There
4476: are many ways to get it wrong and only few that can handle every
4477: nastiness.</p>
1.75 rillig 4478: <pre class="programlisting">
4479: STRING= foo bar < > * `date` $$HOME ' "
4480: EXT_LIST= string=${STRING:Q} x=second\ item
1.1 grant 4481:
1.75 rillig 4482: all:
4483: echo ${STRING} # 1
4484: echo "${STRING}" # 2
4485: echo "${STRING:Q}" # 3
4486: echo ${STRING:Q} # 4
4487: echo x${STRING:Q} | sed 1s,.,, # 5
1.79 rillig 4488: printf "%s\\n" ${STRING:Q}"" # 6
1.75 rillig 4489: env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
1.1 grant 4490: </pre>
1.75 rillig 4491: <p>Example 1 leads to a syntax error in the shell, as the
4492: characters are just copied.</p>
4493: <p>Example 2 leads to a syntax error too, and if you leave out
4494: the last " character from <code class="varname">${STRING}</code>,
4495: <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
4496: variable would be evaluated, too.</p>
4497: <p>Example 3 outputs each space character preceded by a
4498: backslash (or not), depending on the implementation of the
4499: <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>
4500: <p>Example 4 handles correctly every string that does not start
4501: with a dash. In that case, the result depends on the
4502: 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
4503: guarantee that your input does not start with a dash, this form is
4504: appropriate.</p>
4505: <p>Example 5 handles even the case of a leading dash
4506: correctly.</p>
1.79 rillig 4507: <p>Example 6 also works with every string and is the
4508: light-weight solution, since it does not involve a pipe, which has
4509: its own problems.</p>
1.75 rillig 4510: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
4511: because the quoting has already been done when adding elements to
4512: the list.</p>
4513: <p>As internal lists shall not be passed to the shell, there is
4514: no example for it.</p>
4515: </div>
4516: <div class="sect2" lang="en">
4517: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4518: <a name="quoting-guideline"></a>10.2.4. Quoting guideline</h3></div></div></div>
1.75 rillig 4519: <p>There are many possible sources of wrongly quoted variables.
4520: This section lists some of the commonly known ones.</p>
4521: <div class="itemizedlist"><ul type="disc">
4522: <li>
4523: <p>Whenever you use the value of a list, think
4524: about what happens to leading or trailing whitespace. If the
4525: list is a well-formed shell expression, you can apply the
4526: <code class="varname">:M*</code> modifier to strip leading and trailing
4527: whitespace from each word. The <code class="varname">:M</code> operator
4528: first splits its argument according to the rules of the shell,
4529: and then creates a new list consisting of all words that match
4530: the shell glob expression <code class="varname">*</code>, that is: all.
4531: One class of situations where this is needed is when adding a
4532: variable like <code class="varname">CPPFLAGS</code> to
4533: <code class="varname">CONFIGURE_ARGS</code>. If the configure script
4534: invokes other configure scripts, it strips the leading and
4535: trailing whitespace from the variable and then passes it to the
4536: other configure scripts. But these configure scripts expect the
4537: (child) <code class="varname">CPPFLAGS</code> variable to be the same as
4538: the parent <code class="varname">CPPFLAGS</code>. That's why we better
4539: pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
4540: here is how we do it:</p>
4541: <pre class="programlisting">
4542: CPPFLAGS= # empty
4543: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX:Q}\"
4544: CPPFLAGS+= ${MY_CPPFLAGS}
1.1 grant 4545:
1.75 rillig 4546: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
1.1 grant 4547:
1.75 rillig 4548: all:
4549: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
4550: echo x${CONFIGURE_ARGS}x # properly trimmed
1.1 grant 4551: </pre>
1.75 rillig 4552: </li>
4553: <li><p>The example above contains one bug: The
4554: <code class="varname">${PREFIX}</code> is a properly quoted shell
4555: expression, but there is the C compiler after it, which also
4556: expects a properly quoted string (this time in C syntax). The
4557: version above is therefore only correct if
4558: <code class="varname">${PREFIX}</code> does not have embedded backslashes
4559: or double quotes. If you want to allow these, you have to add
4560: another layer of quoting to each variable that is used as a C
4561: string literal. You cannot use the <code class="varname">:Q</code>
4562: operator for it, as this operator only works for the
4563: shell.</p></li>
4564: <li>
4565: <p>Whenever a variable can be empty, the
4566: <code class="varname">:Q</code> operator can have surprising results. Here
4567: are two completely different cases which can be solved with the
4568: same trick.</p>
4569: <pre class="programlisting">
4570: EMPTY= # empty
4571: empty_test:
4572: for i in a ${EMPTY:Q} c; do \
4573: echo "$$i"; \
4574: done
1.1 grant 4575:
1.75 rillig 4576: for_test:
4577: .for i in a:\ a:\test.txt
4578: echo ${i:Q}
4579: echo "foo"
4580: .endfor
1.1 grant 4581: </pre>
1.75 rillig 4582: <p>The first example will only print two of the three lines
4583: we might have expected. This is because
4584: <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
4585: the shell cannot see. The workaround is to write
4586: <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
4587: as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
4588: -f ${FNAME:Q}</code> (both of these are wrong).</p>
4589: <p>The second example will only print three lines instead of
4590: four. The first line looks like <code class="varname">a:\ echo foo</code>.
4591: This is because the backslash of the value
4592: <code class="varname">a:\</code> is interpreted as a line-continuation by
4593: <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
4594: <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
4595: <code class="varname">${i:Q}""</code>.</p>
4596: </li>
4597: </ul></div>
4598: </div>
4599: <div class="sect2" lang="en">
4600: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4601: <a name="bsd-make-bug-workaround"></a>10.2.5. Workaround for a bug in BSD Make</h3></div></div></div>
1.75 rillig 4602: <p>The pkgsrc bmake program does not handle the following
4603: assignment correctly. In case <code class="varname">_othervar_</code>
4604: contains a ``-'' character, one of the closing braces is included
4605: in <code class="varname">${VAR}</code> after this code executes.</p>
4606: <pre class="programlisting">
4607: VAR:= ${VAR:N${_othervar_:C/-//}}
1.1 grant 4608: </pre>
1.75 rillig 4609: <p>For a more complex code snippet and a workaround, see the
1.76 rillig 4610: 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 4611: <code class="varname">bug1</code>.</p>
4612: </div>
4613: </div>
4614: </div>
4615: <div class="chapter" lang="en">
4616: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4617: <a name="plist"></a>Chapter 11. PLIST issues</h2></div></div></div>
1.75 rillig 4618: <div class="toc">
4619: <p><b>Table of Contents</b></p>
4620: <dl>
1.77 rillig 4621: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
4622: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
4623: <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>
4624: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
4625: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
4626: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
4627: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
4628: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
1.75 rillig 4629: </dl>
4630: </div>
1.87 wiz 4631: <p>The <code class="filename">PLIST</code> file contains a package's
4632: “<span class="quote">packing list</span>”, i.e. a list of files that belong to
4633: the package (relative to the <code class="filename">${PREFIX}</code>
4634: directory it's been installed in) plus some additional statements
4635: - 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.
4636: This chapter addresses some issues that need attention when
4637: dealing with the <code class="filename">PLIST</code> file (or files, see
4638: below!).</p>
1.75 rillig 4639: <div class="sect1" lang="en">
4640: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4641: <a name="rcs-id"></a>11.1. RCS ID</h2></div></div></div>
1.87 wiz 4642: <p>Be sure to add a RCS ID line as the first thing in any
4643: <code class="filename">PLIST</code> file you write:</p>
1.75 rillig 4644: <pre class="programlisting">
1.87 wiz 4645: @comment $NetBSD$
4646: </pre>
1.75 rillig 4647: </div>
4648: <div class="sect1" lang="en">
4649: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4650: <a name="automatic-plist-generation"></a>11.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.75 rillig 4651: <p>You can use the <span><strong class="command">make print-PLIST</strong></span> command
1.87 wiz 4652: to output a PLIST that matches any new files since the package
1.88 wiz 4653: 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 4654: more information on this target.</p>
1.75 rillig 4655: </div>
4656: <div class="sect1" lang="en">
4657: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4658: <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 4659: <p>If you have used any of the *-dirs packages, as explained in
4660: <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
4661: <span><strong class="command">make print-PLIST</strong></span> outputs a set of
4662: <code class="varname">@comment</code>s instead of real
4663: <code class="varname">@dirrm</code> lines. You can also do this for
4664: specific directories and files, so that the results of that
4665: command are very close to reality. This helps <span class="emphasis"><em>a
4666: lot</em></span> during the update of packages.</p>
4667: <p>The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
4668: of AWK patterns and actions that are used to filter the output of
4669: print-PLIST. You can <span class="emphasis"><em>append</em></span> any chunk of AWK
4670: scripting you like to it, but be careful with quoting.</p>
4671: <p>For example, to get all files inside the
4672: <code class="filename">libdata/foo</code> directory removed from the
4673: resulting PLIST:</p>
4674: <pre class="programlisting">
4675: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
4676: </pre>
4677: <p>And to get all the <code class="varname">@dirrm</code> lines referring
4678: to a specific (shared) directory converted to
4679: <code class="varname">@comment</code>s:</p>
1.75 rillig 4680: <pre class="programlisting">
1.87 wiz 4681: PRINT_PLIST_AWK+= /^@dirrm share\/specific/ { print "@comment " $$0; next; }
4682: </pre>
1.75 rillig 4683: </div>
4684: <div class="sect1" lang="en">
4685: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4686: <a name="plist.misc"></a>11.4. Variable substitution in PLIST</h2></div></div></div>
1.87 wiz 4687: <p>A number of variables are substituted automatically in
4688: PLISTs when a package is installed on a system. This includes the
4689: following variables:</p>
1.75 rillig 4690: <div class="variablelist"><dl>
4691: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
4692: <dd>
4693: <p>Some packages like emacs and perl embed information
1.87 wiz 4694: about which architecture they were built on into the
4695: pathnames where they install their files. To handle this
4696: case, PLIST will be preprocessed before actually used, and
4697: the symbol
4698: “<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>” will be
4699: replaced by what <span><strong class="command">uname -p</strong></span> gives. The
4700: same is done if the string
4701: <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
4702: PLIST somewhere - use this on packages that have GNU
4703: autoconf-created configure scripts.</p>
1.75 rillig 4704: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
4705: <h3 class="title">Legacy note</h3>
4706: <p>There used to be a symbol
1.87 wiz 4707: “<span class="quote"><code class="varname">$ARCH</code></span>” that
4708: was replaced by the output of <span><strong class="command">uname
4709: -m</strong></span>, but that's no longer supported and has
4710: been removed.</p>
1.75 rillig 4711: </div>
4712: </dd>
4713: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
4714: <dd>
4715: <p>Some packages want to embed the OS name and version
1.87 wiz 4716: into some paths. To do this, use these variables in the
4717: <code class="filename">PLIST</code>:
4718: </p>
1.75 rillig 4719: <div class="itemizedlist"><ul type="disc">
4720: <li><p><code class="varname">${OPSYS}</code> - output of “<span class="quote"><span><strong class="command">uname -s</strong></span></span>”</p></li>
4721: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. “<span class="quote">solaris</span>”)</p></li>
4722: <li><p><code class="varname">${OS_VERSION}</code> - “<span class="quote"><span><strong class="command">uname -r</strong></span></span>”</p></li>
4723: </ul></div>
4724: </dd>
4725: </dl></div>
1.87 wiz 4726: <p>For a complete list of values which are replaced by
4727: default, please look in <code class="filename">bsd.pkg.mk</code> (and
4728: search for <code class="varname">PLIST_SUBST</code>).</p>
4729: <p>If you want to change other variables not listed above, you
4730: can add variables and their expansions to this variable in the
4731: 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 4732: <pre class="programlisting">
1.87 wiz 4733: PLIST_SUBST+= SOMEVAR="somevalue"
4734: </pre>
1.75 rillig 4735: <p>This replaces all occurrences of “<span class="quote">${SOMEVAR}</span>”
1.87 wiz 4736: in the <code class="filename">PLIST</code> with
4737: “<span class="quote">somevalue</span>”.</p>
1.75 rillig 4738: </div>
4739: <div class="sect1" lang="en">
4740: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4741: <a name="manpage-compression"></a>11.5. Man page compression</h2></div></div></div>
1.75 rillig 4742: <p>Man pages should be installed in compressed form if
1.87 wiz 4743: <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
4744: and uncompressed otherwise. To handle this in the
4745: <code class="filename">PLIST</code> file, the suffix “<span class="quote">.gz</span>” is
4746: appended/removed automatically for man pages according to
4747: <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
4748: or not, see above for details. This modification of the
4749: <code class="filename">PLIST</code> file is done on a copy of it, not
4750: <code class="filename">PLIST</code> itself.</p>
1.75 rillig 4751: </div>
4752: <div class="sect1" lang="en">
4753: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4754: <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 4755: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
1.87 wiz 4756: in generating the binary package, set the variable
4757: <code class="varname">PLIST_SRC</code> to the names of that file(s).
4758: 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
4759: important. The default for <code class="varname">PLIST_SRC</code> is
4760: <code class="filename">${PKGDIR}/PLIST</code>.</p>
1.75 rillig 4761: </div>
4762: <div class="sect1" lang="en">
4763: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4764: <a name="platform-specific-plist"></a>11.7. Platform-specific and differing PLISTs</h2></div></div></div>
1.75 rillig 4765: <p>Some packages decide to install a different set of files based on
1.87 wiz 4766: the operating system being used. These differences can be
4767: automatically handled by using the following files:</p>
1.75 rillig 4768: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4769: <li><p><code class="filename">PLIST.common</code></p></li>
4770: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
4771: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
4772: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
4773: <li><p><code class="filename">PLIST.common_end</code></p></li>
1.75 rillig 4774: </ul></div>
4775: </div>
4776: <div class="sect1" lang="en">
4777: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4778: <a name="faq.common-dirs"></a>11.8. Sharing directories between packages</h2></div></div></div>
1.87 wiz 4779: <p>A “<span class="quote">shared directory</span>” is a directory where
4780: multiple (and unrelated) packages install files. These
4781: directories are problematic because you have to add special tricks
4782: in the PLIST to conditionally remove them, or have some
4783: centralized package handle them.</p>
4784: <p>Within pkgsrc, you'll find both approaches. If a directory
4785: is shared by a few unrelated packages, it's often not worth to add
4786: an extra package to remove it. Therefore, one simply does:</p>
4787: <pre class="programlisting">
4788: @unexec ${RMDIR} %D/path/to/shared/directory 2>/dev/null || ${TRUE}
4789: </pre>
4790: <p>in the PLISTs of all affected packages, instead of the
4791: regular "@dirrm" line.</p>
4792: <p>However, if the directory is shared across many packages, two
4793: different solutions are available:</p>
1.75 rillig 4794: <div class="orderedlist"><ol type="1">
1.87 wiz 4795: <li><p>If the packages have a common dependency, the directory
4796: can be removed in that. For example, see
4797: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/textproc/scrollkeeper/README.html" target="_top"><code class="filename">textproc/scrollkeeper</code></a>, which
4798: removes the shared directory
4799: <code class="filename">share/omf</code>.</p></li>
4800: <li><p>If the packages using the directory are not related at
4801: all (they have no common dependencies), a *-dirs package is
4802: used.</p></li>
1.75 rillig 4803: </ol></div>
1.87 wiz 4804: <p>From now on, we'll discuss the second solution. To get an
4805: idea of the *-dirs packages available, issue:</p>
1.75 rillig 4806: <pre class="programlisting">
1.87 wiz 4807: <code class="prompt">%</code> cd .../pkgsrc
4808: <code class="prompt">%</code> ls -d */*-dirs
4809: </pre>
4810: <p>Their use from other packages is very simple. The
4811: <code class="varname">USE_DIRS</code> variable takes a list of package names
4812: (without the “<span class="quote">-dirs</span>” part) together with the required
4813: version number (always pick the latest one when writing new
4814: packages).</p>
4815: <p>For example, if a package installs files under
4816: <code class="filename">share/applications</code>, it should have the
4817: following line in it:</p>
4818: <pre class="programlisting">
4819: USE_DIRS+= xdg-1.1
4820: </pre>
4821: <p>After regenerating the PLIST using <span><strong class="command">make
4822: print-PLIST</strong></span>, you should get the right (commented out)
4823: lines.</p>
4824: <p>Note that even if your package is using
4825: <code class="filename">$X11BASE</code>, it must not depend on the
4826: *-x11-dirs packages. Just specify the name without that part and
4827: pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
4828: care of it.</p>
1.75 rillig 4829: </div>
4830: </div>
4831: <div class="chapter" lang="en">
4832: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 4833: <a name="buildlink"></a>Chapter 12. Buildlink methodology</h2></div></div></div>
1.75 rillig 4834: <div class="toc">
4835: <p><b>Table of Contents</b></p>
4836: <dl>
1.77 rillig 4837: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
4838: <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 4839: <dd><dl>
1.77 rillig 4840: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
4841: <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 4842: </dl></dd>
1.77 rillig 4843: <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 4844: <dd><dl>
1.77 rillig 4845: <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>
4846: <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 4847: </dl></dd>
4848: </dl>
4849: </div>
4850: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
1.87 wiz 4851: are seen by a package's configure and build processes. This is implemented
4852: in a two step process:</p>
1.75 rillig 4853: <div class="orderedlist"><ol type="1">
4854: <li><p>Symlink headers and libraries for dependencies into
1.87 wiz 4855: <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
4856: of <code class="varname">WRKDIR</code>.</p></li>
1.75 rillig 4857: <li><p>Create wrapper scripts that are used in place of the normal compiler
1.87 wiz 4858: tools that translate <code class="option">-I${LOCALBASE}/include</code> and
4859: <code class="option">-L${LOCALBASE}/lib</code> into references to
4860: <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
4861: native compiler on some operating systems look like GCC, so that
4862: packages that expect GCC won't require modifications to build with
4863: those native compilers.</p></li>
1.75 rillig 4864: </ol></div>
4865: <p>This normalizes the environment in which a package is built so that the
1.87 wiz 4866: package may be built consistently despite what other software may be
4867: installed. Please note that the normal system header and library paths,
4868: e.g. <code class="filename">/usr/include</code>,
4869: <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
4870: designed to insulate the package build from non-system-supplied
4871: software.</p>
1.75 rillig 4872: <div class="sect1" lang="en">
4873: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4874: <a name="converting-to-buildlink3"></a>12.1. Converting packages to use buildlink3</h2></div></div></div>
1.75 rillig 4875: <p>The process of converting packages to use the buildlink3
1.87 wiz 4876: framework (“<span class="quote">bl3ifying</span>”) is fairly straightforward.
4877: The things to keep in mind are:</p>
1.75 rillig 4878: <div class="orderedlist"><ol type="1">
1.87 wiz 4879: <li><p>Ensure that the build always calls the wrapper scripts
4880: instead of the actual toolchain. Some packages are tricky,
4881: and the only way to know for sure is the check
4882: <code class="filename">${WRKDIR}/.work.log</code> to see if the
4883: wrappers are being invoked.</p></li>
4884: <li><p>Don't override <code class="varname">PREFIX</code> from within
4885: the package Makefile, e.g. Java VMs, standalone shells,
4886: etc., because the code to symlink files into
4887: <code class="filename">${BUILDLINK_DIR}</code> looks for files
4888: relative to “<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>”.
4889: </p></li>
4890: <li><p>Remember that <span class="emphasis"><em>only</em></span> the
4891: <code class="filename">buildlink3.mk</code> files that you list in a
4892: package's Makefile are added as dependencies for that package.
4893: </p></li>
1.75 rillig 4894: </ol></div>
1.87 wiz 4895: <p>If a dependency on a particular package is required for its libraries and
4896: headers, then we replace:</p>
1.75 rillig 4897: <pre class="programlisting">
1.87 wiz 4898: DEPENDS+= foo>=1.1.0:../../category/foo
4899: </pre>
1.75 rillig 4900: <p>with</p>
4901: <pre class="programlisting">
1.87 wiz 4902: .include "../../category/foo/buildlink3.mk"
4903: </pre>
1.75 rillig 4904: <p>The buildlink3.mk files usually define the required dependencies.
4905: If you need a newer version of the dependency when using buildlink3.mk
1.87 wiz 4906: files, then you can define it in your Makefile; for example:</p>
1.75 rillig 4907: <pre class="programlisting">
1.87 wiz 4908: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
4909: .include "../../category/foo/buildlink3.mk"
4910: </pre>
1.76 rillig 4911: <p>There are several <code class="filename">buildlink3.mk</code>
1.87 wiz 4912: files in <code class="filename">pkgsrc/mk</code>
4913: that handle special package issues:</p>
1.75 rillig 4914: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4915: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
1.87 wiz 4916: the native or a pkgsrc Berkeley DB implementation based on
4917: the values of <code class="varname">BDB_ACCEPTED</code> and
4918: <code class="varname">BDB_DEFAULT</code>.</p></li>
1.76 rillig 4919: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
1.87 wiz 4920: comes with neither Curses nor NCurses, this will take care
4921: 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 4922: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
1.87 wiz 4923: of <code class="varname">KRB5_ACCEPTED</code> to choose between
4924: adding a dependency on Heimdal or MIT-krb5 for packages that
4925: require a Kerberos 5 implementation.</p></li>
1.88 wiz 4926: <li><p><code class="filename">motif.buildlink3.mk</code> checks for a
4927: system-provided Motif installation or adds a dependency on
4928: <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
4929: <code class="varname">MOTIF_TYPE</code> to “<span class="quote">dt</span>”,
4930: “<span class="quote">lesstif</span>”, or “<span class="quote">openmotif</span>” to choose
4931: which Motif version will be used.</p></li>
1.76 rillig 4932: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
1.87 wiz 4933: variables that may be used by packages that use the
4934: Open Sound System (OSS) API.</p></li>
1.76 rillig 4935: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
1.87 wiz 4936: either Postgres 7.3 or 7.4, whichever is found installed. See
4937: the file for more information.</p></li>
1.76 rillig 4938: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
1.87 wiz 4939: <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
4940: 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 4941: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
1.87 wiz 4942: <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
4943: library.</p></li>
1.75 rillig 4944: </ul></div>
1.76 rillig 4945: <p>The comments in those <code class="filename">buildlink3.mk</code>
1.87 wiz 4946: files provide a more complete
4947: description of how to use them properly.</p>
1.75 rillig 4948: </div>
4949: <div class="sect1" lang="en">
4950: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 4951: <a name="creating-buildlink3.mk"></a>12.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
1.87 wiz 4952: <p>A package's <code class="filename">buildlink3.mk</code> file is
4953: included by Makefiles to indicate the need to compile and link
4954: against header files and libraries provided by the package. A
4955: <code class="filename">buildlink3.mk</code> file should always provide
4956: enough information to add the correct type of dependency
4957: relationship and include any other
4958: <code class="filename">buildlink3.mk</code> files that it needs to find
4959: headers and libraries that it needs in turn.</p>
4960: <p>To generate an initial <code class="filename">buildlink3.mk</code>
4961: 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>
4962: package is highly recommended. For most packages, the following
4963: command will generate a good starting point for
4964: <code class="filename">buildlink3.mk</code> files:</p>
4965: <pre class="screen">
4966: <code class="prompt">%</code> <strong class="userinput"><code>cd pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>pkgdir</code></em>
4967: <code class="prompt">%</code> createbuildlink >buildlink3.mk</code></strong>
4968: </pre>
1.75 rillig 4969: <div class="sect2" lang="en">
4970: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 4971: <a name="anatomy-of-bl3"></a>12.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
1.75 rillig 4972: <p>The following real-life example
1.87 wiz 4973: <code class="filename">buildlink3.mk</code> is taken
4974: from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
1.75 rillig 4975: <pre class="programlisting">
1.87 wiz 4976: # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
1.1 grant 4977:
1.87 wiz 4978: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
4979: TIFF_BUILDLINK3_MK:= ${TIFF_BUILDLINK3_MK}+
1.1 grant 4980:
1.87 wiz 4981: .if !empty(BUILDLINK_DEPTH:M+)
4982: BUILDLINK_DEPENDS+= tiff
4983: .endif
4984:
4985: BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Ntiff}
4986: BUILDLINK_PACKAGES+= tiff
4987:
4988: .if !empty(TIFF_BUILDLINK3_MK:M+)
4989: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
4990: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
4991: .endif # TIFF_BUILDLINK3_MK
4992:
4993: .include "../../devel/zlib/buildlink3.mk"
4994: .include "../../graphics/jpeg/buildlink3.mk"
4995:
4996: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
4997: </pre>
4998: <p>The header and footer manipulate
4999: <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
5000: <code class="filename">buildlink3.mk</code> files and is used to track
5001: at what depth we are including
5002: <code class="filename">buildlink3.mk</code> files.</p>
5003: <p>The first section controls if the dependency on
5004: <em class="replaceable"><code>pkg</code></em> is added.
5005: <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
5006: packages for which dependencies are added by
5007: buildlink3.</p>
5008: <p>The second section advises pkgsrc that the
5009: <code class="filename">buildlink3.mk</code> file for
5010: <em class="replaceable"><code>pkg</code></em> has been included at some point.
5011: <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
5012: packages for which <code class="filename">buildlink3.mk</code> files
5013: have been included. It must <span class="emphasis"><em>always</em></span> be
5014: appended to within a <code class="filename">buildlink3.mk</code>
5015: file.</p>
5016: <p>The third section is protected from multiple inclusion
5017: and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
5018: added. Several important variables are set in the section:</p>
5019: <div class="itemizedlist"><ul type="disc">
5020: <li><p><code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5021: is the actual dependency recorded in the installed
5022: package; this should always be set using
5023: <span><strong class="command">+=</strong></span> to ensure that
5024: we're appending to any pre-existing list of values. This
5025: variable should be set to the first version of the
5026: package that had an API change.
5027: </p></li>
5028: <li><p><code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
5029: is the location of the <em class="replaceable"><code>pkg</code></em>
5030: pkgsrc directory.</p></li>
5031: <li><p><code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
5032: (not shown above) controls whether we use
5033: <code class="varname">BUILD_DEPENDS</code> or
5034: <code class="varname">DEPENDS</code> to add the dependency on
5035: <em class="replaceable"><code>pkg</code></em>. The build dependency is
5036: selected by setting
5037: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
5038: to “<span class="quote">build</span>”. By default, the full dependency is
5039: used.</p></li>
5040: <li><p><code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5041: and
5042: <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
5043: (not shown above) are lists of subdirectories of
1.76 rillig 5044: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 5045: to add to the header and library search paths. These
5046: default to “<span class="quote">include</span>” and “<span class="quote">lib</span>”
1.87 wiz 5047: respectively.</p></li>
5048: <li><p><code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5049: (not shown above) is the list of preprocessor flags to add
5050: to <code class="varname">CPPFLAGS</code>, which are passed on to the
5051: configure and build phases. The “<span class="quote">-I</span>” option
5052: should be avoided and instead be handled using
5053: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
1.87 wiz 5054: above.</p></li>
1.75 rillig 5055: </ul></div>
1.87 wiz 5056: <p>The following variables are all optionally defined within
5057: this second section (protected against multiple inclusion) and
5058: control which package files are symlinked into
5059: <code class="filename">${BUILDLINK_DIR}</code> and how their names are
5060: transformed during the symlinking:</p>
1.75 rillig 5061: <div class="itemizedlist"><ul type="disc">
1.87 wiz 5062: <li><p><code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5063: (not shown above) is a shell glob pattern relative to
1.76 rillig 5064: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 5065: to be symlinked into
1.76 rillig 5066: <code class="filename">${BUILDLINK_DIR}</code>,
1.87 wiz 5067: e.g. <code class="filename">include/*.h</code>.</p></li>
5068: <li><p><code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
5069: (not shown above) is a shell pipeline that
5070: outputs to stdout a list of files relative to
5071: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
5072: The resulting files are to be symlinked
5073: into <code class="filename">${BUILDLINK_DIR}</code>. By default,
5074: this takes the <code class="filename">+CONTENTS</code> of a
5075: <em class="replaceable"><code>pkg</code></em> and filters it through
5076: <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.</p></li>
5077: <li><p><code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5078: (not shown above) is a filter command that filters
1.76 rillig 5079: <code class="filename">+CONTENTS</code> input into a list of files
1.75 rillig 5080: relative to
1.76 rillig 5081: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 5082: on stdout. By default for overwrite packages,
5083: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.76 rillig 5084: outputs the contents of the <code class="filename">include</code>
5085: and <code class="filename">lib</code> directories in the package
5086: <code class="filename">+CONTENTS</code>, and for pkgviews packages,
1.75 rillig 5087: it outputs any libtool archives in
1.87 wiz 5088: <code class="filename">lib</code> directories.</p></li>
5089: <li><p><code class="varname">BUILDLINK_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5090: (not shown above) is a list of sed arguments used to
5091: transform the name of the source filename into a
5092: destination filename, e.g. <span><strong class="command">-e
1.87 wiz 5093: "s|/curses.h|/ncurses.h|g"</strong></span>.</p></li>
1.75 rillig 5094: </ul></div>
1.87 wiz 5095: <p>The last section includes any
5096: <code class="filename">buildlink3.mk</code> needed for
5097: <em class="replaceable"><code>pkg</code></em>'s library dependencies.
5098: Including these <code class="filename">buildlink3.mk</code> files
5099: means that the headers and libraries for these
5100: dependencies are also symlinked into
5101: <code class="filename">${BUILDLINK_DIR}</code>
5102: whenever the <em class="replaceable"><code>pkg</code></em>
5103: <code class="filename">buildlink3.mk</code>
5104: file is included.</p>
1.75 rillig 5105: </div>
5106: <div class="sect2" lang="en">
5107: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5108: <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 5109: <p>The situation that requires increasing the dependency listed in
1.75 rillig 5110: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5111: after a package update is when the API or interface to the
1.87 wiz 5112: header files change.</p>
5113: <p>In this case,
5114: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5115: should be adjusted to require at least the new package
5116: version. In some cases, the packages that depend on this new
5117: version may need their <code class="varname">PKGREVISION</code>s
5118: increased and, if they have <code class="filename">buildlink3.mk</code>
5119: files, their
5120: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5121: adjusted, too. This is needed so pkgsrc will require the
5122: correct package dependency and not settle for an older one
5123: when building the source.</p>
5124: <p><code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5125: should be increased when the binary interface or sonames
5126: (major number of the library version) of any installed
5127: shared libraries change. This is needed so that binary
5128: packages made using it will require the correct package
5129: dependency and not settle for an older one which will not
1.87 wiz 5130: contain the necessary shared libraries.</p>
5131: <p>See <a href="#dependencies" title="17.1.6. Handling dependencies">Section 17.1.6, “Handling dependencies”</a> for
1.75 rillig 5132: more information about dependencies on other packages,
5133: including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
1.87 wiz 5134: <code class="varname">ABI_DEPENDS</code> definitions.</p>
5135: <p>Please take careful consideration before adjusting
5136: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5137: or
5138: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5139: as we don't want to cause unneeded package deletions and
5140: rebuilds. In many cases, new versions of packages work just
5141: fine with older dependencies.</p>
5142: <p>Also it is not needed to set
1.75 rillig 5143: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5144: when it is identical to
1.87 wiz 5145: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>. </p>
1.75 rillig 5146: </div>
5147: </div>
5148: <div class="sect1" lang="en">
5149: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5150: <a name="writing-builtin.mk"></a>12.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.87 wiz 5151: <p>Some packages in pkgsrc install headers and libraries that
1.75 rillig 5152: coincide with headers and libraries present in the base system.
1.76 rillig 5153: Aside from a <code class="filename">buildlink3.mk</code> file, these
5154: packages should also include a <code class="filename">builtin.mk</code>
1.75 rillig 5155: file that includes the necessary checks to decide whether using
5156: the built-in software or the pkgsrc software is
1.87 wiz 5157: appropriate.</p>
5158: <p>The only requirements of a builtin.mk file for
5159: <em class="replaceable"><code>pkg</code></em> are:</p>
1.75 rillig 5160: <div class="orderedlist"><ol type="1">
1.87 wiz 5161: <li><p>It should set
5162: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5163: to either “<span class="quote">yes</span>” or “<span class="quote">no</span>”
5164: after it is included.</p></li>
5165: <li><p>It should <span class="emphasis"><em>not</em></span> override any
5166: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5167: which is already set before the
5168: <code class="filename">builtin.mk</code> file is included.</p></li>
5169: <li><p>It should be written to allow multiple inclusion. This
5170: is <span class="emphasis"><em>very</em></span> important and takes careful
5171: attention to <code class="filename">Makefile</code> coding.</p></li>
1.75 rillig 5172: </ol></div>
5173: <div class="sect2" lang="en">
5174: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5175: <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 5176: <p>The following is the recommended template for builtin.mk
1.87 wiz 5177: files:</p>
1.75 rillig 5178: <pre class="programlisting">
1.87 wiz 5179: .if !defined(IS_BUILTIN.foo)
5180: #
5181: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
5182: # genuinely exists in the system or not.
5183: #
5184: IS_BUILTIN.foo?= no
5185:
5186: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
5187: # version can be determined.
5188: #
5189: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
5190: BUILTIN_PKG.foo?= foo-1.0
5191: . endif
5192: .endif # IS_BUILTIN.foo
5193:
5194: .if !defined(USE_BUILTIN.foo)
5195: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
5196: . if defined(BUILTIN_PKG.foo)
5197: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
5198: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
5199: USE_BUILTIN.foo!= \
5200: if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then \
5201: ${ECHO} "yes"; \
5202: else \
5203: ${ECHO} "no"; \
5204: fi
5205: . endif
5206: . endfor
5207: . endif
5208: .endif # USE_BUILTIN.foo
5209:
5210: CHECK_BUILTIN.foo?= no
5211: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
5212: #
5213: # Here we place code that depends on whether USE_BUILTIN.foo is set to
5214: # "yes" or "no".
5215: #
5216: .endif # CHECK_BUILTIN.foo
5217: </pre>
5218: <p>The first section sets
5219: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5220: depending on if <em class="replaceable"><code>pkg</code></em> really exists
5221: in the base system. This should not be a base system software
5222: with similar functionality to <em class="replaceable"><code>pkg</code></em>;
5223: it should only be “<span class="quote">yes</span>” if the actual package is
5224: included as part of the base system. This variable is only
5225: used internally within the <code class="filename">builtin.mk</code>
5226: file.</p>
5227: <p>The second section sets
5228: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
5229: to the version of <em class="replaceable"><code>pkg</code></em> in the base
5230: system if it exists (if
5231: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5232: is “<span class="quote">yes</span>”). This variable is only used internally
5233: within the <code class="filename">builtin.mk</code> file.</p>
5234: <p>The third section sets
5235: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5236: and is <span class="emphasis"><em>required</em></span> in all
5237: <code class="filename">builtin.mk</code> files. The code in this
5238: section must make the determination whether the built-in
5239: software is adequate to satisfy the dependencies listed in
5240: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
5241: This is typically done by comparing
5242: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
5243: against each of the dependencies in
5244: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
5245: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5246: <span class="emphasis"><em>must</em></span> be set to the correct value by the
5247: end of the <code class="filename">builtin.mk</code> file. Note that
5248: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5249: may be “<span class="quote">yes</span>” even if
5250: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5251: is “<span class="quote">no</span>” because we may make the determination
5252: that the built-in version of the software is similar enough to
5253: be used as a replacement.</p>
5254: <p>The last section is guarded by
5255: <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
5256: and includes code that uses the value of
5257: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5258: set in the previous section. This typically includes, e.g.,
5259: adding additional dependency restrictions and listing additional
5260: files to symlink into <code class="filename">${BUILDLINK_DIR}</code> (via
5261: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).</p>
1.75 rillig 5262: </div>
5263: <div class="sect2" lang="en">
5264: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5265: <a name="native-or-pkgsrc-preference"></a>12.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
1.87 wiz 5266: <p>When building packages, it's possible to choose whether to set
5267: a global preference for using either the built-in (native)
5268: version or the pkgsrc version of software to satisfy a
5269: dependency. This is controlled by setting
5270: <code class="varname">PREFER_PKGSRC</code> and
5271: <code class="varname">PREFER_NATIVE</code>. These variables take values
5272: of either “<span class="quote">yes</span>”, “<span class="quote">no</span>”, or a list of
5273: packages. <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
5274: use the pkgsrc versions of software, while
5275: <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
5276: built-in versions. Preferences are determined by the most
5277: specific instance of the package in either
5278: <code class="varname">PREFER_PKGSRC</code> or
5279: <code class="varname">PREFER_NATIVE</code>. If a package is specified
5280: in neither or in both variables, then
5281: <code class="varname">PREFER_PKGSRC</code> has precedence over
5282: <code class="varname">PREFER_NATIVE</code>. For example, to require
5283: using pkgsrc versions of software for all but the most basic
5284: bits on a NetBSD system, you can set:</p>
5285: <pre class="programlisting">
5286: PREFER_PKGSRC= yes
5287: PREFER_NATIVE= getopt skey tcp_wrappers
5288: </pre>
5289: <p>A package <span class="emphasis"><em>must</em></span> have a
5290: <code class="filename">builtin.mk</code>
5291: file to be listed in <code class="varname">PREFER_NATIVE</code>,
5292: otherwise it is simply ignored in that list.</p>
1.75 rillig 5293: </div>
5294: </div>
5295: </div>
5296: <div class="chapter" lang="en">
5297: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5298: <a name="pkginstall"></a>Chapter 13. The pkginstall framework</h2></div></div></div>
1.75 rillig 5299: <div class="toc">
5300: <p><b>Table of Contents</b></p>
5301: <dl>
1.77 rillig 5302: <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 5303: <dd><dl>
1.77 rillig 5304: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
5305: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
1.75 rillig 5306: </dl></dd>
1.77 rillig 5307: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
1.75 rillig 5308: <dd><dl>
1.77 rillig 5309: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
5310: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
5311: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
5312: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
5313: </dl></dd>
5314: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
5315: <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>
5316: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
5317: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
5318: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
5319: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
5320: <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 5321: </dl>
5322: </div>
5323: <p>This chapter describes the framework known as
5324: <code class="literal">pkginstall</code>, whose key features are:</p>
5325: <div class="itemizedlist"><ul type="disc">
5326: <li><p>Generic installation and manipulation of directories and files
5327: outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
5328: <li><p>Automatic handling of configuration files during installation,
5329: provided that packages are correctly designed.</p></li>
5330: <li><p>Generation and installation of system startup scripts.</p></li>
5331: <li><p>Registration of system users and groups.</p></li>
5332: <li><p>Registration of system shells.</p></li>
5333: <li><p>Automatic updating of fonts databases.</p></li>
5334: </ul></div>
5335: <p>The following sections inspect each of the above points in detail.</p>
5336: <p>You may be thinking that many of the things described here could be
5337: easily done with simple code in the package's post-installation target
5338: (<code class="literal">post-install</code>). <span class="emphasis"><em>This is incorrect</em></span>,
5339: as the code in them is only executed when building from source. Machines
5340: using binary packages could not benefit from it at all (as the code itself
5341: could be unavailable). Therefore, the only way to achieve any of the items
5342: described above is by means of the installation scripts, which are
5343: automatically generated by pkginstall.</p>
5344: <div class="sect1" lang="en">
5345: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5346: <a name="files-and-dirs-outside-prefix"></a>13.1. Files and directories outside the installation prefix</h2></div></div></div>
1.76 rillig 5347: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
1.75 rillig 5348: of files and directories that belong to a package. The names used in it
1.76 rillig 5349: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
1.75 rillig 5350: which means that it cannot register files outside this directory (absolute
5351: path names are not allowed). Despite this restriction, some packages need
5352: to install files outside this location; e.g., under
1.76 rillig 5353: <code class="filename">${VARBASE}</code> or
1.87 wiz 5354: <code class="filename">${PKG_SYSCONFDIR}</code>. The only way to achieve this
5355: is to create such files during installation time by using
5356: installation scripts.</p>
5357: <p>The generic installation scripts are shell scripts that can
5358: contain arbitrary code. The list of scripts to execute is taken from
5359: the <code class="varname">INSTALL_FILE</code> variable, which defaults to
5360: <code class="filename">INSTALL</code>. A similar variable exists for package
5361: removal (<code class="varname">DEINSTALL_FILE</code>, whose default is
5362: <code class="filename">DEINSTALL</code>). These scripts can run arbitrary
5363: commands, so they have the potential to create and manage files
5364: anywhere in the file system.</p>
5365: <p>Using these general installation files is not recommended, but
5366: may be needed in some special cases. One reason for avoiding them is
5367: that the user has to trust the packager that there is no unwanted or
5368: simply erroneous code included in the installation script. Also,
5369: previously there were many similar scripts for the same functionality,
5370: and fixing a common error involved finding and changing all of
5371: them.</p>
5372: <p>The pkginstall framework offers another, standardized way. It
5373: provides generic scripts to abstract the manipulation of such files
5374: and directories based on variables set in the package's
5375: <code class="filename">Makefile</code>. The rest of this section describes
5376: these variables.</p>
1.75 rillig 5377: <div class="sect2" lang="en">
5378: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5379: <a name="dirs-outside-prefix"></a>13.1.1. Directory manipulation</h3></div></div></div>
1.75 rillig 5380: <p>The following variables can be set to request the creation of
5381: directories anywhere in the file system:</p>
5382: <div class="itemizedlist"><ul type="disc">
5383: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
5384: contain a list of directories that should be created and should attempt
5385: to be destroyed by the installation scripts. The difference between
5386: the two is that the latter prompts the administrator to remove any
5387: directories that may be left after deinstallation (because they were
5388: not empty), while the former does not.</p></li>
5389: <li>
5390: <p><code class="varname">MAKE_DIRS_PERMS</code> and
5391: <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
5392: which directories should be created and should attempt to be destroyed
5393: by the installation scripts. Each tuple holds the following values,
5394: separated by spaces: the directory name, its owner, its group and its
5395: numerical mode. For example:</p>
5396: <pre class="programlisting">
5397: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 5398: </pre>
1.75 rillig 5399: <p>The difference between the two is exactly the same as their
5400: non-<code class="varname">PERMS</code> counterparts.</p>
5401: </li>
5402: </ul></div>
5403: </div>
5404: <div class="sect2" lang="en">
5405: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5406: <a name="files-outside-prefix"></a>13.1.2. File manipulation</h3></div></div></div>
1.75 rillig 5407: <p>Creating non-empty files outside the installation prefix is tricky
1.76 rillig 5408: because the <code class="filename">PLIST</code> forces all files to be inside it.
1.75 rillig 5409: To overcome this problem, the only solution is to extract the file in the
5410: known place (i.e., inside the installation prefix) and copy it to the
5411: appropriate location during installation (done by the installation scripts
5412: generated by pkginstall). We will call the former the <span class="emphasis"><em>master
5413: file</em></span> in the following paragraphs, which describe the variables
5414: that can be used to automatically and consistently handle files outside the
5415: installation prefix:</p>
5416: <div class="itemizedlist"><ul type="disc">
5417: <li>
5418: <p><code class="varname">CONF_FILES</code> and
5419: <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
5420: During installation time, the master file is copied to the target one
5421: if and only if the latter does not exist. Upon deinstallation, the
5422: target file is removed provided that it was not modified by the
5423: installation.</p>
5424: <p>The difference between the two is that the latter prompts the
5425: administrator to remove any files that may be left after
5426: deinstallation (because they were not empty), while the former does
5427: not.</p>
5428: </li>
5429: <li>
5430: <p><code class="varname">CONF_FILES_PERMS</code> and
5431: <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
5432: files as well as their target locations. For each of them, it also
5433: specifies their owner, their group and their numeric permissions, in
5434: this order. For example:</p>
5435: <pre class="programlisting">
5436: SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 5437: </pre>
1.75 rillig 5438: <p>The difference between the two is exactly the same as their
5439: non-<code class="varname">PERMS</code> counterparts.</p>
5440: </li>
5441: </ul></div>
5442: </div>
5443: </div>
5444: <div class="sect1" lang="en">
5445: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5446: <a name="conf-files"></a>13.2. Configuration files</h2></div></div></div>
1.75 rillig 5447: <p>Configuration files are special in the sense that they are installed
5448: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
5449: need special treatment during installation (most of which is automated by
5450: pkginstall). The main concept you must bear in mind is that files marked
5451: as configuration files are automatically copied to the right place (somewhere
5452: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
5453: and only if</em></span> they didn't exist before. Similarly, they will not
5454: be removed if they have local modifications. This ensures that
5455: administrators never lose any custom changes they may have made.</p>
5456: <div class="sect2" lang="en">
5457: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5458: <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 5459: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
5460: specifies where configuration files shall be installed. Its contents are
5461: set based upon the following variables:</p>
5462: <div class="itemizedlist"><ul type="disc">
5463: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
1.76 rillig 5464: directory. Defaults to <code class="filename">${PREFIX}/etc</code> although it may
1.75 rillig 5465: be overridden by the user to point to his preferred location (e.g.,
1.76 rillig 5466: <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
1.75 rillig 5467: Packages must not use it directly.</p></li>
5468: <li>
5469: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
5470: <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
5471: for the package being built shall be installed. The definition of this
5472: variable only makes sense in the package's
1.76 rillig 5473: <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
1.75 rillig 5474: <p>As an example, consider the Apache package,
1.76 rillig 5475: <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 5476: configuration files under the
1.76 rillig 5477: <code class="filename">httpd/</code> subdirectory of
1.75 rillig 5478: <code class="varname">PKG_SYSCONFBASE</code>. This should be set in the package
5479: Makefile.</p>
5480: </li>
5481: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
5482: variable that holds this package's configuration directory (if
5483: different from <code class="varname">PKG_SYSCONFBASE</code>). It defaults to
5484: <code class="varname">PKGBASE</code>'s value, and is always prefixed with
5485: <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
5486: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
5487: directory where the configuration files for the package identified by
5488: <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
5489: </ul></div>
5490: <p>Based on the above variables, pkginstall determines the value of
5491: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
5492: variable that can be used within a package to refer to its configuration
5493: directory. The algorithm used to set its value is basically the
5494: following:</p>
5495: <div class="orderedlist"><ol type="1">
5496: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
5497: its value is used.</p></li>
5498: <li><p>If the previous variable is not defined but
5499: <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
1.76 rillig 5500: <code class="filename">Makefile</code>, the resulting value is
5501: <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
1.75 rillig 5502: <li><p>Otherwise, it is set to
1.76 rillig 5503: <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
1.75 rillig 5504: </ol></div>
1.76 rillig 5505: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
1.77 rillig 5506: 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 5507: </div>
5508: <div class="sect2" lang="en">
5509: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5510: <a name="conf-files-configure"></a>13.2.2. Telling the software where configuration files are</h3></div></div></div>
1.75 rillig 5511: <p>Given that pkgsrc (and users!) expect configuration files to be in a
5512: known place, you need to teach each package where it shall install its
5513: files. In some cases you will have to patch the package Makefiles to
5514: achieve it. If you are lucky, though, it may be as easy as passing an
5515: extra flag to the configuration script; this is the case of GNU Autoconf-
5516: generated files:</p>
5517: <pre class="programlisting">
5518: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1 grant 5519: </pre>
1.75 rillig 5520: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
5521: for</em></span> its configuration files, not where they will be originally
5522: installed (although the difference is never explicit,
5523: unfortunately).</p>
5524: </div>
5525: <div class="sect2" lang="en">
5526: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5527: <a name="conf-files-patching"></a>13.2.3. Patching installations</h3></div></div></div>
1.75 rillig 5528: <p>As said before, pkginstall automatically handles configuration files.
5529: This means that <span class="strong"><strong>the packages themselves must not
1.76 rillig 5530: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
1.75 rillig 5531: directly</strong></span>. Bad news is that many software installation scripts
5532: will, out of the box, mess with the contents of that directory. So what is
5533: the correct procedure to fix this issue?</p>
5534: <p>You must teach the package (usually by manually patching it) to
5535: install any configuration files under the examples hierarchy,
1.76 rillig 5536: <code class="filename">share/examples/${PKGBASE}/</code>. This way, the
5537: <code class="filename">PLIST</code> registers them and the administrator always
1.75 rillig 5538: has the original copies available.</p>
5539: <p>Once the required configuration files are in place (i.e., under the
5540: examples hierarchy), the pkginstall framework can use them as master copies
5541: during the package installation to update what is in
1.76 rillig 5542: <code class="filename">${PKG_SYSCONFDIR}</code>. To achieve this, the variables
1.75 rillig 5543: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
1.77 rillig 5544: 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 5545: about their syntax and their purpose. Here is an example, taken from the
1.76 rillig 5546: <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 5547: <pre class="programlisting">
5548: EGDIR= ${PREFIX}/share/doc/mutt/samples
5549: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1 grant 5550: </pre>
1.75 rillig 5551: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
5552: package and has no meaning outside it.</p>
5553: </div>
5554: <div class="sect2" lang="en">
5555: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5556: <a name="conf-files-disable"></a>13.2.4. Disabling handling of configuration files</h3></div></div></div>
1.75 rillig 5557: <p>The automatic copying of config files can be toggled by setting the
5558: environment variable <code class="varname">PKG_CONFIG</code> prior to package
5559: installation.</p>
5560: </div>
5561: </div>
5562: <div class="sect1" lang="en">
5563: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5564: <a name="rcd-scripts"></a>13.3. System startup scripts</h2></div></div></div>
1.75 rillig 5565: <p>System startup scripts are special files because they must be
5566: installed in a place known by the underlying OS, usually outside the
1.77 rillig 5567: 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 5568: can be used. However, pkginstall provides a special mechanism to handle
5569: these files.</p>
5570: <p>In order to provide system startup scripts, the package has
5571: to:</p>
5572: <div class="orderedlist"><ol type="1">
1.76 rillig 5573: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
1.75 rillig 5574: the <code class="literal">.sh</code> suffix appended. Considering the
1.76 rillig 5575: <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
5576: <code class="filename">cupsd.sh</code> in its files directory.</p></li>
1.75 rillig 5577: <li>
5578: <p>Tell pkginstall to handle it, appending the name of the script,
5579: without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
5580: Continuing the previous example:</p>
5581: <pre class="programlisting">
5582: RCD_SCRIPTS+= cupsd
1.1 grant 5583: </pre>
1.75 rillig 5584: </li>
5585: </ol></div>
5586: <p>Once this is done, pkginstall will do the following steps for each
5587: script in an automated fashion:</p>
5588: <div class="orderedlist"><ol type="1">
5589: <li><p>Process the file found in the files directory applying all the
1.76 rillig 5590: substitutions described in the <code class="filename">FILES_SUBST</code>
1.75 rillig 5591: variable.</p></li>
5592: <li><p>Copy the script from the files directory to the examples
1.76 rillig 5593: hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>. Note
1.75 rillig 5594: that this master file must be explicitly registered in the
1.76 rillig 5595: <code class="filename">PLIST</code>.</p></li>
1.75 rillig 5596: <li><p>Add code to the installation scripts to copy the startup script
5597: from the examples hierarchy into the system-wide startup scripts
5598: directory.</p></li>
5599: </ol></div>
5600: <div class="sect2" lang="en">
5601: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5602: <a name="rcd-scripts-disable"></a>13.3.1. Disabling handling of system startup scripts</h3></div></div></div>
1.75 rillig 5603: <p>The automatic copying of config files can be toggled by setting the
5604: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
5605: installation. Note that the scripts will be always copied inside the
1.76 rillig 5606: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
1.75 rillig 5607: matter what the value of this variable is.</p>
5608: </div>
5609: </div>
5610: <div class="sect1" lang="en">
5611: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5612: <a name="users-and-groups"></a>13.4. System users and groups</h2></div></div></div>
1.75 rillig 5613: <p>If a package needs to create special users and/or groups during
5614: installation, it can do so by using the pkginstall framework.</p>
5615: <p>Users can be created by adding entries to the
5616: <code class="varname">PKG_USERS</code> variable. Each entry has the following
5617: syntax:</p>
5618: <pre class="programlisting">
5619: user:group
1.1 grant 5620: </pre>
1.87 wiz 5621: <p>Further specification of user details may be done by setting
5622: per-user variables.
5623: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the
5624: numeric UID for the user.
5625: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the
5626: user's description or comment.
5627: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the
5628: user's home directory, and defaults to
5629: <code class="filename">/nonexistent</code> if not specified.
5630: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the
5631: user's shell, and defaults to <code class="filename">/sbinno/login</code> if
5632: not specified.</p>
1.75 rillig 5633: <p>Similarly, groups can be created by adding entries to the
5634: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
5635: <pre class="programlisting">
5636: group
1.1 grant 5637: </pre>
1.75 rillig 5638: <p>The numeric GID of the group may be set by defining
5639: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
5640: <p>If a package needs to create the users and groups at an earlier
5641: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
5642: either <code class="literal">configure</code> or <code class="literal">build</code> to
5643: indicate the phase before which the users and groups are created. In
5644: this case, the numeric UIDs and GIDs of the created users and groups
5645: are automatically hardcoded into the final installation scripts.</p>
5646: </div>
5647: <div class="sect1" lang="en">
5648: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5649: <a name="shells"></a>13.5. System shells</h2></div></div></div>
1.75 rillig 5650: <p>Packages that install system shells should register them in the shell
1.76 rillig 5651: database, <code class="filename">/etc/shells</code>, to make things easier to the
1.75 rillig 5652: administrator. This must be done from the installation scripts to keep
5653: binary packages working on any system. pkginstall provides an easy way to
5654: accomplish this task.</p>
5655: <p>When a package provides a shell interpreter, it has to set the
5656: <code class="varname">PKG_SHELL</code> variable to its absolute file name. This will
5657: add some hooks to the installation scripts to handle it. Consider the
1.76 rillig 5658: 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 5659: <pre class="programlisting">
5660: PKG_SHELL= ${PREFIX}/bin/zsh
1.1 grant 5661: </pre>
1.75 rillig 5662: <div class="sect2" lang="en">
5663: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5664: <a name="shells-disable"></a>13.5.1. Disabling shell registration</h3></div></div></div>
1.75 rillig 5665: <p>The automatic registration of shell interpreters can be disabled by
1.76 rillig 5666: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
1.75 rillig 5667: environment variable to <code class="literal">NO</code>.</p>
5668: </div>
5669: </div>
5670: <div class="sect1" lang="en">
5671: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5672: <a name="fonts"></a>13.6. Fonts</h2></div></div></div>
1.75 rillig 5673: <p>Packages that install X11 fonts should update the database files
5674: that index the fonts within each fonts directory. This can easily be
5675: accomplished within the pkginstall framework.</p>
5676: <p>When a package installs X11 fonts, it must list the directories in
5677: which fonts are installed in the
5678: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
5679: where <em class="replaceable"><code>type</code></em> can be one of “<span class="quote">ttf</span>”,
5680: “<span class="quote">type1</span>” or “<span class="quote">x11</span>”. This will add hooks to the
5681: installation scripts to run the appropriate commands to update the fonts
5682: database files within each of those directories. For convenience, if the
5683: directory path is relative, it is taken to be relative to the package's
1.76 rillig 5684: 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 5685: <pre class="programlisting">
5686: FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
1.1 grant 5687: </pre>
1.75 rillig 5688: <div class="sect2" lang="en">
5689: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 5690: <a name="fonts-disable"></a>13.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
1.75 rillig 5691: <p>The automatic update of fonts databases can be disabled by
1.76 rillig 5692: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
1.75 rillig 5693: environment variable to <code class="literal">NO</code>.</p>
5694: </div>
5695: </div>
5696: </div>
5697: <div class="chapter" lang="en">
5698: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5699: <a name="options"></a>Chapter 14. Options handling</h2></div></div></div>
1.75 rillig 5700: <div class="toc">
5701: <p><b>Table of Contents</b></p>
5702: <dl>
1.77 rillig 5703: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
5704: <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>
5705: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
1.75 rillig 5706: </dl>
5707: </div>
5708: <p>Many packages have the ability to be built to support different
1.76 rillig 5709: sets of features. <code class="filename">bsd.options.mk</code> is a framework
1.75 rillig 5710: in pkgsrc that provides generic handling of those options that
5711: determine different ways in which the packages can be built. It's
5712: possible for the user to specify exactly which sets of options will be
5713: built into a package or to allow a set of global default options
5714: apply.</p>
5715: <div class="sect1" lang="en">
5716: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5717: <a name="global-default-options"></a>14.1. Global default options</h2></div></div></div>
1.75 rillig 5718: <p>Global default options are listed in
5719: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
5720: that should be built into every package if that option is supported.
1.76 rillig 5721: This variable should be set in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 5722: </div>
5723: <div class="sect1" lang="en">
5724: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5725: <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 5726: <p>The following example shows how
1.76 rillig 5727: <code class="filename">bsd.options.mk</code> should be used
1.75 rillig 5728: by the hypothetical ``wibble'' package, either in the package
1.76 rillig 5729: <code class="filename">Makefile</code>, or in a file,
5730: e.g. <code class="filename">options.mk</code>, that is included by the
5731: main package <code class="filename">Makefile</code>.</p>
1.75 rillig 5732: <pre class="programlisting">
5733: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
5734: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
5735: PKG_OPTIONS_OPTIONAL_GROUPS= database
5736: PKG_OPTIONS_GROUP.database= mysql pgsql
5737: PKG_SUGGESTED_OPTIONS= wibble-foo
5738: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
5739: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
1.1 grant 5740:
1.75 rillig 5741: .include "../../mk/bsd.prefs.mk"
1.69 rillig 5742:
1.75 rillig 5743: # this package was previously named wibble2
5744: .if defined(PKG_OPTIONS.wibble2)
5745: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
5746: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
1.78 rillig 5747: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
1.75 rillig 5748: .endif
1.69 rillig 5749:
1.75 rillig 5750: .include "../../mk/bsd.options.mk"
1.69 rillig 5751:
1.75 rillig 5752: # Package-specific option-handling
1.69 rillig 5753:
1.75 rillig 5754: ###
5755: ### FOO support
5756: ###
5757: .if !empty(PKG_OPTIONS:Mwibble-foo)
5758: CONFIGURE_ARGS+= --enable-foo
5759: .endif
1.69 rillig 5760:
1.75 rillig 5761: ###
5762: ### LDAP support
5763: ###
5764: .if !empty(PKG_OPTIONS:Mldap)
1.77 rillig 5765: . include "../../databases/openldap-client/buildlink3.mk"
5766: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
1.75 rillig 5767: .endif
1.69 rillig 5768:
1.75 rillig 5769: ###
5770: ### database support
5771: ###
5772: .if !empty(PKG_OPTIONS:Mmysql)
5773: . include "../../mk/mysql.buildlink3.mk"
5774: .endif
5775: .if !empty(PKG_OPTIONS:Mpgsql)
5776: . include "../../mk/pgsql.buildlink3.mk"
5777: .endif
5778: </pre>
5779: <p>The first section contains the information about which build
5780: options are supported by the package, and any default options settings
5781: if needed.</p>
5782: <div class="orderedlist"><ol type="1">
5783: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
5784: <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
5785: options. It should be set to
1.78 rillig 5786: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
5787: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is not defined
5788: at the point where the options are processed.</p></li>
1.75 rillig 5789: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
5790: build options supported by the package.</p></li>
5791: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
5792: list of names of groups of mutually exclusive options. The options in
5793: each group are listed in
5794: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
5795: The most specific setting of any option from the group takes
5796: precedence over all other options in the group. Options from the
5797: groups will be automatically added to
5798: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
5799: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
5800: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
5801: packages will fail if no option from the group is
5802: selected.</p></li>
5803: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
5804: of names of sets of options. At least one option from each set must
5805: be selected. The options in each set are listed in
5806: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
5807: Options from the sets will be automatically added to
5808: <code class="varname">PKG_SUPPORTED_OPTIONS</code>. Building the package will
5809: fail if no option from the set is selected.</p></li>
5810: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
5811: build options which are enabled by default.</p></li>
5812: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
5813: of
5814: “<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>”
1.76 rillig 5815: pairs that map legacy <code class="filename">/etc/mk.conf</code> variables to
1.75 rillig 5816: their option counterparts. Pairs should be added with
5817: “<span class="quote">+=</span>” to keep the listing of global legacy variables. A
5818: warning will be issued if the user uses a legacy
5819: variable.</p></li>
5820: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
5821: of
5822: “<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>”
5823: pairs that map options that have been renamed to their new
5824: counterparts. Pairs should be added with “<span class="quote">+=</span>” to keep
5825: the listing of global legacy options. A warning will be issued if
5826: the user uses a legacy option.</p></li>
5827: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
5828: options implied by deprecated variables used. This can be used for
5829: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
5830: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
5831: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
5832: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
5833: a list of warnings about deprecated variables or options used, and
5834: what to use instead.</p></li>
5835: </ol></div>
5836: <p>A package should never modify
5837: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
5838: <code class="varname">PKG_OPTIONS_VAR</code>. These are strictly user-settable.
5839: To suggest a default set of options, use
5840: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
5841: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
1.76 rillig 5842: including <code class="filename">bsd.options.mk</code>. If none of
1.75 rillig 5843: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
5844: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
5845: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
5846: happen with platform-specific options if none of them is supported on
5847: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
5848: empty list and the package is otherwise treated as not using the
5849: options framework.</p>
1.76 rillig 5850: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
1.75 rillig 5851: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
5852: build options, properly filtered to remove unsupported and duplicate
5853: options.</p>
5854: <p>The remaining sections contain the logic that is specific to
5855: each option. The correct way to check for an option is to check
5856: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
5857: <pre class="programlisting">
5858: .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
5859: </pre>
5860: </div>
5861: <div class="sect1" lang="en">
5862: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5863: <a name="option-names"></a>14.3. Option Names</h2></div></div></div>
1.75 rillig 5864: <p>Options that enable similar features in different packages (like
5865: optional support for a library) should use a common name in all
5866: packages that support it (like the name of the library). If another
5867: package already has an option with the same meaning, use the same
5868: name.</p>
5869: <p>Options that enable features specific to one package, where it's
5870: unlikely that another (unrelated) package has the same (or a similar)
5871: optional feature, should use a name prefixed with
5872: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
5873: <p>If a group of related packages share an optional feature
5874: specific to that group, prefix it with the name of the
5875: “<span class="quote">main</span>” package
5876: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
5877: <p>For new options, add a line to
1.76 rillig 5878: <code class="filename">mk/defaults/options.description</code>. Lines have two
1.75 rillig 5879: fields, separated by tab. The first field is the option name, the
5880: second its description. The description should be a whole sentence
5881: (starting with an uppercase letter and ending with a period) that
5882: describes what enabling the option does. E. g. “<span class="quote">Enable ispell
5883: support.</span>” The file is sorted by option names.</p>
5884: </div>
5885: </div>
5886: <div class="chapter" lang="en">
5887: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 5888: <a name="build"></a>Chapter 15. The build process</h2></div></div></div>
1.75 rillig 5889: <div class="toc">
5890: <p><b>Table of Contents</b></p>
5891: <dl>
1.77 rillig 5892: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
5893: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
5894: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
5895: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
5896: <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 5897: <dd><dl>
5898: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
5899: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
5900: </dl></dd>
1.77 rillig 5901: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
5902: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
5903: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
5904: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
5905: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
5906: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
5907: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
5908: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
5909: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
5910: <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 5911: <dt><span class="sect1"><a href="#build.clean">15.16. Cleaning up</a></span></dt>
5912: <dt><span class="sect1"><a href="#build.helpful-targets">15.17. Other helpful targets</a></span></dt>
1.75 rillig 5913: </dl>
5914: </div>
5915: <div class="sect1" lang="en">
5916: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5917: <a name="build.intro"></a>15.1. Introduction</h2></div></div></div>
1.75 rillig 5918: <p>This chapter gives a detailed description on how a package is
1.87 wiz 5919: built. Building a package is separated into different
5920: <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
5921: <code class="varname">build</code>, <code class="varname">install</code>), all of which are
5922: described in the following sections. Each phase is splitted into
5923: so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
5924: containing phase, prefixed by one of <code class="varname">pre-</code>,
5925: <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
5926: <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
5927: of the actual work is done in the <code class="varname">do-*</code> stages.</p>
1.75 rillig 5928: <p>The basic steps for building a program are always the same. First
1.87 wiz 5929: the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
5930: the local system and then extracted. After any pkgsrc-specific patches
5931: to compile properly are applied, the software can be configured, then
5932: built (usually by compiling), and finally the generated binaries, etc.
5933: can be put into place on the system.</p>
1.75 rillig 5934: </div>
5935: <div class="sect1" lang="en">
5936: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 5937: <a name="build.prefix"></a>15.2. Program location</h2></div></div></div>
1.75 rillig 5938: <p>Before outlining the process performed by the NetBSD package system in
1.87 wiz 5939: the next section, here's a brief discussion on where programs are
5940: installed, and which variables influence this.</p>
1.75 rillig 5941: <p>The automatic variable <code class="varname">PREFIX</code> indicates
1.87 wiz 5942: where all files of the final program shall be installed. It is
5943: usually set to <code class="varname">LOCALBASE</code>
5944: (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
1.88 wiz 5945: for pkgs in the <code class="filename">cross</code> category. The value of
1.87 wiz 5946: <code class="varname">PREFIX</code> needs to be put
5947: into the various places in the program's source where paths to
5948: 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 5949: <p>When choosing which of these variables to use,
1.87 wiz 5950: follow the following rules:</p>
1.75 rillig 5951: <div class="itemizedlist"><ul type="disc">
1.88 wiz 5952: <li><p><code class="varname">PREFIX</code> always points to the location
5953: where the current pkg will be installed. When referring to a
5954: pkg's own installation path, use
5955: “<span class="quote">${PREFIX}</span>”.</p></li>
5956: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs
5957: are installed. If you need to construct a -I or -L argument
5958: to the compiler to find includes and libraries installed by
5959: another non-X11 pkg, use “<span class="quote">${LOCALBASE}</span>”. The name
1.87 wiz 5960: <code class="varname">LOCALBASE</code> stems from FreeBSD, which
5961: installed all packages in <code class="filename">/usr/local</code>. As
5962: pkgsrc leaves <code class="filename">/usr/local</code> for the system
5963: administrator, this variable is a misnomer.</p></li>
1.88 wiz 5964: <li><p><code class="varname">X11BASE</code> is where the actual X11
5965: distribution (from xsrc, etc.) is installed. When looking for
5966: <span class="emphasis"><em>standard</em></span> X11 includes (not those
5967: installed by a package), use “<span class="quote">${X11BASE}</span>”.</p></li>
5968: <li>
5969: <p>X11-based packages are special in that they may be
5970: installed in either <code class="varname">X11BASE</code> or
5971: <code class="varname">LOCALBASE</code>.</p>
1.75 rillig 5972: <p>Usually, X11 packages should be installed under
1.88 wiz 5973: <code class="varname">LOCALBASE</code> whenever possible. Note that you
5974: will need to include
5975: <code class="filename">../../mk/x11.buildlink3.mk</code> in them to
5976: request the presence of X11 and to get the right compilation
5977: flags.</p>
1.75 rillig 5978: <p>Even though, there are some packages that cannot be installed
1.87 wiz 5979: under <code class="varname">LOCALBASE</code>: those that come with app-defaults
5980: files. These packages are special and they must be placed under
5981: <code class="varname">X11BASE</code>. To accomplish this, set either
5982: <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
5983: your package.</p>
1.75 rillig 5984: <p>Some notes: If you need
1.87 wiz 5985: to find includes or libraries installed by a pkg that has
5986: <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
5987: its pkg <code class="filename">Makefile</code>, you need to look in
5988: <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
5989: <code class="filename">${LOCALBASE}</code>. To force installation of
5990: all X11 packages in <code class="varname">LOCALBASE</code>, the
5991: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a> package
5992: is enabled by default.</p>
1.75 rillig 5993: </li>
1.88 wiz 5994: <li><p><code class="varname">X11PREFIX</code> should be used to refer to
5995: the installed location of an X11
5996: package. <code class="varname">X11PREFIX</code> will be set to
5997: <code class="varname">X11BASE</code> if xpkgwedge is not installed, and
5998: to <code class="varname">LOCALBASE</code> if xpkgwedge is
5999: installed.</p></li>
6000: <li>
6001: <p>If xpkgwedge is installed, it is possible to have some
6002: packages installed in <code class="varname">X11BASE</code> and some in
6003: <code class="varname">LOCALBASE</code>. To determine the prefix of an
6004: installed package, the <code class="varname">EVAL_PREFIX</code>
6005: definition can be used. It takes pairs in the format
6006: “<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>
6007: variable <code class="varname">DIRNAME</code> will be set to the prefix
6008: of the installed package <package>, or
6009: “<span class="quote">${X11PREFIX}</span>” if the package is not
6010: installed.</p>
1.75 rillig 6011: <p>This is best illustrated by example.</p>
6012: <p>The following lines are taken from
1.87 wiz 6013: <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
1.75 rillig 6014: <pre class="programlisting">
1.87 wiz 6015: EVAL_PREFIX+= GTKDIR=gtk+
6016: CONFIGURE_ARGS+= --with-guile-prefix=${LOCALBASE:Q}
6017: CONFIGURE_ARGS+= --with-gtk-prefix=${GTKDIR:Q}
6018: CONFIGURE_ARGS+= --enable-multibyte
6019: </pre>
1.88 wiz 6020: <p>Specific defaults can be defined for the packages
6021: evaluated using <code class="varname">EVAL_PREFIX</code>, by using a
6022: definition of the form:</p>
1.75 rillig 6023: <pre class="programlisting">
1.87 wiz 6024: GTKDIR_DEFAULT= ${LOCALBASE}
6025: </pre>
1.75 rillig 6026: <p>where <code class="varname">GTKDIR</code> corresponds
1.87 wiz 6027: to the first definition in
6028: the <code class="varname">EVAL_PREFIX</code> pair.</p>
1.75 rillig 6029: </li>
1.76 rillig 6030: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.87 wiz 6031: 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
6032: manual pages go into <code class="filename">${PREFIX}/man</code>, not
6033: <code class="filename">${PREFIX}/share/man</code>.</p></li>
1.75 rillig 6034: </ul></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.builddirs"></a>15.3. Directories used during the build process</h2></div></div></div>
1.75 rillig 6039: <p>When building a package, a number of directories is used to store
1.87 wiz 6040: source files, temporary files, pkgsrc-internal files, and so on. These
6041: directories are explained here.</p>
1.75 rillig 6042: <p>Some of the directory variables contain relative pathnames. There
1.87 wiz 6043: are two common base directories for these relative directories:
6044: <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
6045: pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
6046: inside the package itself.</p>
1.75 rillig 6047: <div class="variablelist"><dl>
6048: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
6049: <dd><p>This is an absolute pathname that points to the pkgsrc
1.87 wiz 6050: root directory. Generally, you don't need
6051: it.</p></dd>
1.75 rillig 6052: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
6053: <dd><p>This is a pathname relative to
1.87 wiz 6054: <code class="varname">PKGSRCDIR</code> that points to the current
6055: package.</p></dd>
1.75 rillig 6056: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
6057: <dd><p>This is an absolute pathname pointing to the directory
1.87 wiz 6058: where all work takes place. The distfiles are extraced to this
6059: directory. It also contains temporary directories and log files used by
6060: the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
6061: the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
1.75 rillig 6062: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
6063: <dd><p>This is an absolute pathname pointing to the directory
1.87 wiz 6064: where the distfiles are extracted. It is usually a direct subdirectory
6065: of <code class="varname">WRKDIR</code>, and often it's the only directory entry
6066: that isn't hidden. This variable may be changed by a package
6067: <code class="filename">Makefile</code>.</p></dd>
1.75 rillig 6068: </dl></div>
6069: </div>
6070: <div class="sect1" lang="en">
6071: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6072: <a name="build.running"></a>15.4. Running a phase</h2></div></div></div>
1.75 rillig 6073: <p>You can run a particular phase by typing <span><strong class="command">make
1.87 wiz 6074: phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
6075: phase. This will automatically run all phases that are required for this
6076: phase. The default phase is <code class="varname">build</code>, that is, when you
6077: run <span><strong class="command">make</strong></span> without parameters in a package directory,
6078: the package will be built, but not installed.</p>
1.75 rillig 6079: </div>
6080: <div class="sect1" lang="en">
6081: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6082: <a name="build.fetch"></a>15.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.81 rillig 6083: <p>The first step in building a package is to fetch the
1.88 wiz 6084: distribution files (distfiles) from the sites that are providing
6085: them. This is the task of the <span class="emphasis"><em>fetch</em></span>
6086: phase.</p>
1.81 rillig 6087: <div class="sect2" lang="en">
6088: <div class="titlepage"><div><div><h3 class="title">
6089: <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 6090: <p>In simple cases, <code class="varname">MASTER_SITES</code>
6091: defines all URLs from where the distfile, whose name is
6092: derived from the <code class="varname">DISTNAME</code> variable, is
6093: fetched. The more complicated cases are described
6094: below.</p>
6095: <p>The variable <code class="varname">DISTFILES</code> specifies
6096: the list of distfiles that have to be fetched. Its value
6097: defaults to <code class="literal">${DISTNAME}${EXTRACT_SUFX}</code>,
6098: so that most packages don't need to define it at all.
6099: <code class="varname">EXTRACT_SUFX</code> is
6100: <code class="literal">.tar.gz</code> by default, but can be changed
6101: freely. Note that if your package requires additional
6102: distfiles to the default one, you cannot just append the
6103: additional filenames using the <code class="literal">+=</code>
6104: operator, but you have write for example:</p>
1.81 rillig 6105: <pre class="programlisting">
1.88 wiz 6106: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
6107: </pre>
6108: <p>Each distfile is fetched from a list of sites, usually
6109: <code class="varname">MASTER_SITES</code>. If the package has multiple
6110: <code class="varname">DISTFILES</code> or multiple
6111: <code class="varname">PATCHFILES</code> from different sites, you can
6112: set
6113: <code class="varname">SITES.<em class="replaceable"><code>distfile</code></em></code>
6114: to the list of URLs where the file
6115: <code class="filename"><em class="replaceable"><code>distfile</code></em></code>
6116: (including the suffix) can be found.</p>
6117: <pre class="programlisting">
6118: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
6119: DISTFILES+= foo-file.tar.gz
6120: SITES.foo-file.tar.gz= \
6121: http://www.somewhere.com/somehow/ \
6122: http://www.somewhereelse.com/mirror/somehow/
6123: </pre>
1.81 rillig 6124: <p>When actually fetching the distfiles, each item from
1.88 wiz 6125: <code class="varname">MASTER_SITES</code> or
6126: <code class="varname">SITES.*</code> gets the name of each distfile
6127: appended to it, without an intermediate slash. Therefore,
6128: all site values have to end with a slash or other separator
6129: character. This allows for example to set
6130: <code class="varname">MASTER_SITES</code> to a URL of a CGI script
6131: that gets the name of the distfile as a parameter. In this
6132: case, the definition would look like:</p>
1.81 rillig 6133: <pre class="programlisting">
1.88 wiz 6134: MASTER_SITES= http://www.example.com/download.cgi?file=
6135: </pre>
1.81 rillig 6136: <p>There are some predefined values for
1.88 wiz 6137: <code class="varname">MASTER_SITES</code>, which can be used in
6138: packages. The names of the variables should speak for
6139: themselves.</p>
6140: <pre class="programlisting">
6141: ${MASTER_SITE_APACHE}
6142: ${MASTER_SITE_BACKUP}
6143: ${MASTER_SITE_CYGWIN}
6144: ${MASTER_SITE_DEBIAN}
6145: ${MASTER_SITE_FREEBSD}
6146: ${MASTER_SITE_FREEBSD_LOCAL}
6147: ${MASTER_SITE_GNOME}
6148: ${MASTER_SITE_GNU}
6149: ${MASTER_SITE_GNUSTEP}
6150: ${MASTER_SITE_IFARCHIVE}
6151: ${MASTER_SITE_KDE}
6152: ${MASTER_SITE_MOZILLA}
6153: ${MASTER_SITE_MYSQL}
6154: ${MASTER_SITE_OPENOFFICE}
6155: ${MASTER_SITE_PERL_CPAN}
6156: ${MASTER_SITE_PGSQL}
6157: ${MASTER_SITE_R_CRAN}
6158: ${MASTER_SITE_SOURCEFORGE}
6159: ${MASTER_SITE_SOURCEFORGE_JP}
6160: ${MASTER_SITE_SUNSITE}
6161: ${MASTER_SITE_SUSE}
6162: ${MASTER_SITE_TEX_CTAN}
6163: ${MASTER_SITE_XCONTRIB}
6164: ${MASTER_SITE_XEMACS}
6165: </pre>
6166: <p>Some explanations for the less self-explaining ones:
6167: <code class="varname">MASTER_SITE_BACKUP</code> contains backup sites
6168: 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
6169: 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>
6170: <p>If you choose one of these predefined sites, you may
6171: want to specify a subdirectory of that site. Since these
6172: macros may expand to more than one actual site, you
6173: <span class="emphasis"><em>must</em></span> use the following construct to
6174: specify a subdirectory:</p>
1.81 rillig 6175: <pre class="programlisting">
1.88 wiz 6176: MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
6177: MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
6178: </pre>
1.81 rillig 6179: <p>Note the trailing slash after the subdirectory
1.88 wiz 6180: name.</p>
1.81 rillig 6181: </div>
6182: <div class="sect2" lang="en">
6183: <div class="titlepage"><div><div><h3 class="title">
6184: <a name="build.fetch.how"></a>15.5.2. How are the files fetched?</h3></div></div></div>
1.88 wiz 6185: <p>The <span class="emphasis"><em>fetch</em></span> phase makes sure that
6186: all the distfiles exist in a local directory
6187: (<code class="varname">DISTDIR</code>), which can be set by the pkgsrc
6188: user). If the files do not exist, they are fetched using
6189: commands of the form</p>
1.75 rillig 6190: <pre class="programlisting">
1.88 wiz 6191: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
6192: </pre>
6193: <p>where <code class="literal">${site}</code> varies through
6194: several possibilities in turn: first,
6195: <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the
6196: sites specified in either <code class="varname">SITES.file</code> if
6197: defined, else <code class="varname">MASTER_SITES</code> or
6198: <code class="varname">PATCH_SITES</code>, as applies, then finally the
6199: value of <code class="varname">MASTER_SITE_BACKUP</code>. The order of
6200: all except the first can be optionally sorted by the user,
6201: via setting either <code class="varname">MASTER_SORT_AWK</code> or
6202: <code class="varname">MASTER_SORT_REGEX</code>.</p>
1.81 rillig 6203: </div>
1.75 rillig 6204: </div>
6205: <div class="sect1" lang="en">
6206: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6207: <a name="build.checksum"></a>15.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
1.88 wiz 6208: <p>After the distfile(s) are fetched, their checksum is
6209: generated and compared with the checksums stored in the
6210: distinfo file. If the checksums don't match, the build is
6211: aborted. This is to ensure the same distfile is used for
6212: building, and that the distfile wasn't changed, e.g. by some
6213: malign force, deliberately changed distfiles on the master
6214: distribution site or network lossage.</p>
1.75 rillig 6215: </div>
6216: <div class="sect1" lang="en">
6217: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6218: <a name="build.extract"></a>15.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
1.75 rillig 6219: <p>When the distfiles are present on the local system, they
1.88 wiz 6220: need to be extracted, as they usually come in the form of some
6221: compressed archive format.</p>
1.75 rillig 6222: <p>By default, all <code class="varname">DISTFILES</code> are
1.88 wiz 6223: extracted. If you only need some of them, you can set the
6224: <code class="varname">EXTRACT_ONLY</code> variable to the list of those
6225: files.</p>
6226: <p>Extracting the files is usually done by a little
6227: program, <code class="filename">mk/scripts/extract</code>, which
6228: already knows how to extract various archive formats, so most
6229: likely you will not need to change anything here. But if you
6230: need, the following variables may help you:</p>
1.75 rillig 6231: <div class="variablelist"><dl>
6232: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
6233: <dd><p>Use these variables to override the default
1.88 wiz 6234: options for an extract command, which are defined in
6235: <code class="filename">mk/scripts/extract</code>.</p></dd>
1.75 rillig 6236: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
6237: <dd><p>This variable can be set to
1.88 wiz 6238: <code class="literal">pax</code>, <code class="literal">tar</code> or an
6239: absolute pathname pointing to the command with which tar
6240: archives should be
6241: extracted.</p></dd>
1.75 rillig 6242: </dl></div>
1.88 wiz 6243: <p>If the <code class="filename">extract</code> program doesn't
6244: serve your needs, you can also override the
6245: <code class="varname">EXTRACT_CMD</code> variable, which holds the
6246: command used for extracting the files. This command is
6247: executed in the <code class="filename">${WRKSRC}</code>
6248: directory. During execution of this command, the shell
6249: variable <code class="varname">extract_file</code> holds the absolute
6250: pathname of the file that is going to be extracted.</p>
1.75 rillig 6251: <p>And if that still does not suffice, you can override the
1.88 wiz 6252: <code class="varname">do-extract</code> target in the package
6253: Makefile.</p>
1.75 rillig 6254: </div>
6255: <div class="sect1" lang="en">
6256: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6257: <a name="build.patch"></a>15.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
1.75 rillig 6258: <p>After extraction, all the patches named by the
1.88 wiz 6259: <code class="varname">PATCHFILES</code>, those present in the patches
6260: subdirectory of the package as well as in
6261: $LOCALPATCHES/$PKGPATH (e.g.
6262: <code class="filename">/usr/local/patches/graphics/png</code>) are
6263: applied. Patchfiles ending in <code class="filename">.Z</code> or
6264: <code class="filename">.gz</code> are uncompressed before they are
6265: applied, files ending in <code class="filename">.orig</code> or
6266: <code class="filename">.rej</code> are ignored. Any special options to
6267: <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
6268: <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>
6269: <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
6270: it fail if the patches apply with some lines of fuzz. Please
6271: fix (regen) the patches so that they apply cleanly. The
6272: rationale behind this is that patches that don't apply cleanly
6273: may end up being applied in the wrong place, and cause severe
6274: harm there.</p>
1.75 rillig 6275: </div>
6276: <div class="sect1" lang="en">
6277: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6278: <a name="build.tools"></a>15.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
1.88 wiz 6279: <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>.
6280: </p>
1.75 rillig 6281: </div>
6282: <div class="sect1" lang="en">
6283: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6284: <a name="build.wrapper"></a>15.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
1.75 rillig 6285: <p>This phase creates wrapper programs for the compilers and
1.88 wiz 6286: linkers. The following variables can be used to tweak the
6287: wrappers.</p>
1.75 rillig 6288: <div class="variablelist"><dl>
6289: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
6290: <dd><p>The command used to print progress
1.88 wiz 6291: messages. Does nothing by default. Set to
6292: <code class="literal">${ECHO}</code> to see the progress
6293: messages.</p></dd>
1.75 rillig 6294: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
6295: <dd><p>This variable can be set to
1.88 wiz 6296: <code class="literal">yes</code> (default) or <code class="literal">no</code>,
6297: depending on whether you want additional information in the
6298: wrapper log file.</p></dd>
1.75 rillig 6299: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
6300: <dd><p>This variable can be set to
1.88 wiz 6301: <code class="literal">yes</code> or <code class="literal">no</code>, depending
6302: on whether the wrapper should use its cache, which will
6303: improve the speed. The default value is
6304: <code class="literal">yes</code>, but is forced to
6305: <code class="literal">no</code> if the platform does not support
6306: it.</p></dd>
1.75 rillig 6307: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
1.88 wiz 6308: <dd><p>A list of reordering commands. A reordering
6309: command has the form
6310: <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
6311: It ensures that that
6312: <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code> occurs
6313: before <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
6314: </p></dd>
1.75 rillig 6315: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
6316: <dd><p>A list of transformation commands. [TODO:
1.88 wiz 6317: investigate further]</p></dd>
1.75 rillig 6318: </dl></div>
6319: </div>
6320: <div class="sect1" lang="en">
6321: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6322: <a name="build.configure"></a>15.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.88 wiz 6323: <p>Most pieces of software need information on the header
6324: files, system calls, and library routines which are available
6325: on the platform they run on. The process of determining this
6326: information is known as configuration, and is usually
6327: automated. In most cases, a script is supplied with the
6328: distfiles, and its invocation results in generation of header
6329: files, Makefiles, etc.</p>
6330: <p>If the package contains a configure script, this can be
6331: invoked by setting <code class="varname">HAS_CONFIGURE</code> to
6332: “<span class="quote">yes</span>”. If the configure script is a GNU autoconf
6333: script, you should set <code class="varname">GNU_CONFIGURE</code> to
6334: “<span class="quote">yes</span>” instead. What happens in the
6335: <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
6336: <pre class="programlisting">
6337: .for d in ${CONFIGURE_DIRS}
6338: cd ${WRKSRC} && cd ${d} && env ${CONFIGURE_ENV} \
6339: ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
6340: .endfor
6341: </pre>
6342: <p><code class="varname">CONFIGURE_DIRS</code> (default:
6343: “<span class="quote">.</span>”) is a list of pathnames relative to
6344: <code class="varname">WRKSRC</code>. In each of these directories, the
6345: configure script is run with the environment
6346: <code class="varname">CONFIGURE_ENV</code> and arguments
6347: <code class="varname">CONFIGURE_ARGS</code>. The variables
6348: <code class="varname">CONFIGURE_ENV</code>,
6349: <code class="varname">CONFIGURE_SCRIPT</code> (default:
6350: “<span class="quote">./configure</span>”) and
6351: <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
6352: package.</p>
6353: <p>If the program uses an <code class="filename">Imakefile</code>
6354: for configuration, the appropriate steps can be invoked by
6355: setting <code class="varname">USE_IMAKE</code> to
6356: “<span class="quote">yes</span>”. (If you only want the package installed in
6357: <code class="varname">${X11PREFIX}</code> but xmkmf not being run, set
6358: <code class="varname">USE_X11BASE</code> instead.)</p>
1.75 rillig 6359: </div>
6360: <div class="sect1" lang="en">
6361: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6362: <a name="build.build"></a>15.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.88 wiz 6363: <p>For building a package, a rough equivalent of the
6364: following code is executed.</p>
1.75 rillig 6365: <pre class="programlisting">
1.88 wiz 6366: .for d in ${BUILD_DIRS}
6367: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
6368: ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
6369: -f ${MAKE_FILE} ${BUILD_TARGET}
6370: .endfor
6371: </pre>
6372: <p><code class="varname">BUILD_DIRS</code> (default:
6373: “<span class="quote">.</span>”) is a list of pathnames relative to
6374: <code class="varname">WRKSRC</code>. In each of these directories,
6375: <code class="varname">MAKE_PROGRAM</code> is run with the environment
6376: <code class="varname">MAKE_ENV</code> and arguments
6377: <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
6378: <code class="varname">MAKE_ENV</code>,
6379: <code class="varname">BUILD_MAKE_FLAGS</code>,
6380: <code class="varname">MAKE_FILE</code> and
6381: <code class="varname">BUILD_TARGET</code> may all be changed by the
6382: package.</p>
1.75 rillig 6383: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
1.88 wiz 6384: “<span class="quote">gmake</span>” if <code class="varname">USE_TOOLS</code> contains
6385: “<span class="quote">gmake</span>”, “<span class="quote">make</span>” otherwise. The
6386: default value of <code class="varname">MAKE_FILE</code> is
6387: “<span class="quote">Makefile</span>”, and <code class="varname">BUILD_TARGET</code>
6388: defaults to “<span class="quote">all</span>”.</p>
1.75 rillig 6389: </div>
6390: <div class="sect1" lang="en">
6391: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6392: <a name="build.test"></a>15.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
1.75 rillig 6393: <p>[TODO]</p>
6394: </div>
6395: <div class="sect1" lang="en">
6396: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6397: <a name="build.install"></a>15.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75 rillig 6398: <p>Once the build stage has completed, the final step is to
1.88 wiz 6399: install the software in public directories, so users can
6400: access the programs and files.</p>
1.75 rillig 6401: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
1.88 wiz 6402: equivalent of the following code is executed. Additionally,
6403: before and after this code, much magic is performed to do
6404: consistency checks, registering the package, and so on.</p>
6405: <pre class="programlisting">
6406: .for d in ${INSTALL_DIRS}
6407: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
6408: ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
6409: -f ${MAKE_FILE} ${BUILD_TARGET}
6410: .endfor
6411: </pre>
1.75 rillig 6412: <p>The variable's meanings are analogous to the ones in the
1.88 wiz 6413: <span class="emphasis"><em>build</em></span> phase.
6414: <code class="varname">INSTALL_DIRS</code> defaults to
6415: <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
6416: is “<span class="quote">install</span>” by default, plus
6417: “<span class="quote">install.man</span>” if <code class="varname">USE_IMAKE</code> is
6418: defined and <code class="varname">NO_INSTALL_MANPAGES</code> is not
6419: defined.</p>
1.75 rillig 6420: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
1.88 wiz 6421: variables are useful. They are all variations of the
6422: <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
6423: permissions preset. <code class="varname">INSTALL</code> is the plain
6424: install command. The specialized variants, together with their
6425: intended use, are:</p>
1.75 rillig 6426: <div class="variablelist"><dl>
6427: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
1.88 wiz 6428: <dd><p>directories that contain
6429: binaries</p></dd>
1.75 rillig 6430: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
1.88 wiz 6431: <dd><p>directories that contain
6432: scripts</p></dd>
1.75 rillig 6433: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
1.88 wiz 6434: <dd><p>directories that contain shared and static
6435: libraries</p></dd>
1.75 rillig 6436: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
1.88 wiz 6437: <dd><p>directories that contain data
6438: files</p></dd>
1.75 rillig 6439: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
1.88 wiz 6440: <dd><p>directories that contain man
6441: pages</p></dd>
1.75 rillig 6442: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
1.88 wiz 6443: <dd><p>binaries that can be stripped from debugging
6444: symbols</p></dd>
1.75 rillig 6445: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
1.88 wiz 6446: <dd><p>binaries that cannot be
6447: stripped</p></dd>
1.75 rillig 6448: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
1.88 wiz 6449: <dd><p>game
6450: binaries</p></dd>
1.75 rillig 6451: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
1.88 wiz 6452: <dd><p>shared and static
6453: libraries</p></dd>
1.75 rillig 6454: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
6455: <dd><p>data files</p></dd>
6456: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
1.88 wiz 6457: <dd><p>data files for
6458: games</p></dd>
1.75 rillig 6459: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
6460: <dd><p>man pages</p></dd>
6461: </dl></div>
6462: <p>Some other variables are:</p>
6463: <div class="variablelist"><dl>
6464: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
6465: <dd><p>A list of directories relative to
1.88 wiz 6466: <code class="varname">PREFIX</code> that are created by pkgsrc at the
6467: beginning of the <span class="emphasis"><em>install</em></span> phase. If
6468: this variable is set,
6469: <code class="varname">NO_MTREE</code>=“<span class="quote">yes</span>” is assumed,
6470: which means that the package claims to create all needed
6471: directories itself before installing files to it. Therefore
6472: this variable should only be set in
6473: <code class="filename">Makefile</code>s that are under control of the
6474: package's author. The directories are created with the
6475: correct ownership, depending on their
6476: name.</p></dd>
1.75 rillig 6477: </dl></div>
6478: </div>
6479: <div class="sect1" lang="en">
6480: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6481: <a name="build.package"></a>15.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
1.88 wiz 6482: <p>Once the install stage has completed, a binary package of
6483: the installed files can be built. These binary packages can be
6484: used for quick installation without previous compilation, e.g. by
6485: the <span><strong class="command">make bin-install</strong></span> or by using
6486: <span><strong class="command">pkg_add</strong></span>.</p>
6487: <p>By default, the binary packages are created in
6488: <code class="filename">${PACKAGES}/All</code> and symlinks are created in
6489: <code class="filename">${PACKAGES}/<em class="replaceable"><code>category</code></em></code>,
6490: one for each category in the <code class="varname">CATEGORIES</code>
6491: variable. <code class="varname">PACKAGES</code> defaults to
6492: <code class="filename">pkgsrc/packages</code>.</p>
6493: </div>
6494: <div class="sect1" lang="en">
6495: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6496: <a name="build.clean"></a>15.16. Cleaning up</h2></div></div></div>
6497: <p>Once you're finished with a package, you can clean the work
6498: directory by running <span><strong class="command">make clean</strong></span>. If you want
6499: to clean the work directories of all dependencies too, use
6500: <span><strong class="command">make clean-depends</strong></span>.</p>
1.75 rillig 6501: </div>
6502: <div class="sect1" lang="en">
6503: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.88 wiz 6504: <a name="build.helpful-targets"></a>15.17. Other helpful targets</h2></div></div></div>
1.75 rillig 6505: <div class="variablelist"><dl>
6506: <dt><span class="term">pre/post-*</span></dt>
1.88 wiz 6507: <dd><p>For any of the main targets described in the
6508: previous section, two auxiliary targets exist with
1.87 wiz 6509: “<span class="quote">pre-</span>” and “<span class="quote">post-</span>” used as a
6510: prefix for the main target's name. These targets are
1.88 wiz 6511: invoked before and after the main target is called,
6512: allowing extra configuration or installation steps be
6513: performed from a package's Makefile, for example, which
6514: a program's configure script or install target
6515: omitted.</p></dd>
1.75 rillig 6516: <dt><span class="term">do-*</span></dt>
1.88 wiz 6517: <dd><p>Should one of the main targets do the wrong thing,
6518: and should there be no variable to fix this, you can
6519: redefine it with the do-* target. (Note that redefining
6520: the target itself instead of the do-* target is a bad
6521: idea, as the pre-* and post-* targets won't be called
6522: anymore, etc.) You will not usually need to do
6523: this.</p></dd>
1.75 rillig 6524: <dt><span class="term">reinstall</span></dt>
1.88 wiz 6525: <dd>
6526: <p>If you did a <span><strong class="command">make install</strong></span> and
6527: you noticed some file was not installed properly, you
6528: can repeat the installation with this target, which will
6529: ignore the “<span class="quote">already installed</span>” flag.</p>
6530: <p>This is the default value of
6531: <code class="varname">DEPENDS_TARGET</code> except in the case of
6532: <span><strong class="command">make update</strong></span> and <span><strong class="command">make
6533: package</strong></span>, where the defaults are
6534: “<span class="quote">package</span>” and “<span class="quote">update</span>”,
6535: respectively.</p>
6536: </dd>
1.75 rillig 6537: <dt><span class="term">deinstall</span></dt>
6538: <dd>
1.88 wiz 6539: <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
6540: current directory, effectively de-installing the
6541: package. The following variables can be used to tune the
6542: behaviour:</p>
1.75 rillig 6543: <div class="variablelist"><dl>
6544: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
6545: <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>
6546: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
1.88 wiz 6547: <dd><p>Remove all packages that require (depend on)
6548: the given package. This can be used to remove any
6549: packages that may have been pulled in by a given
6550: package, e.g. if <span><strong class="command">make deinstall
1.87 wiz 6551: DEINSTALLDEPENDS=1</strong></span> is done in
1.88 wiz 6552: <code class="filename">pkgsrc/x11/kde</code>, this is
6553: likely to remove whole KDE. Works by adding
6554: “<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>
6555: command line.</p></dd>
1.75 rillig 6556: </dl></div>
6557: </dd>
1.88 wiz 6558: <dt><span class="term">bin-install</span></dt>
6559: <dd><p>Install a binary package from local disk and via FTP
6560: from a list of sites (see the
6561: <code class="varname">BINPKG_SITES</code> variable), and do a
6562: <span><strong class="command">make package</strong></span> if no binary package is
6563: available anywhere. The arguments given to
6564: <span><strong class="command">pkg_add</strong></span> can be set via
6565: <code class="varname">BIN_INSTALL_FLAGS</code> e.g., to do verbose
6566: operation, etc.</p></dd>
1.75 rillig 6567: <dt><span class="term">update</span></dt>
6568: <dd>
1.88 wiz 6569: <p>This target causes the current package to be
6570: updated to the latest version. The package and all
6571: depending packages first get de-installed, then current
6572: versions of the corresponding packages get compiled and
6573: installed. This is similar to manually noting which
6574: packages are currently installed, then performing a
6575: series of <span><strong class="command">make deinstall</strong></span> and
6576: <span><strong class="command">make install</strong></span> (or whatever
6577: <code class="varname">UPDATE_TARGET</code> is set to) for these
6578: packages.</p>
6579: <p>You can use the “<span class="quote">update</span>” target to
6580: resume package updating in case a previous <span><strong class="command">make
6581: update</strong></span> was interrupted for some reason.
6582: However, in this case, make sure you don't call
6583: <span><strong class="command">make clean</strong></span> or otherwise remove the
6584: list of dependent packages in <code class="varname">WRKDIR</code>.
6585: Otherwise, you lose the ability to automatically update
6586: the current package along with the dependent packages
6587: you have installed.</p>
6588: <p>Resuming an interrupted <span><strong class="command">make
6589: update</strong></span> will only work as long as the package
6590: tree remains unchanged. If the source code for one of
6591: the packages to be updated has been changed, resuming
6592: <span><strong class="command">make update</strong></span> will most certainly
6593: fail!</p>
6594: <p>The following variables can be used either on the
6595: command line or in <code class="filename">/etc/mk.conf</code> to
6596: alter the behaviour of <span><strong class="command">make
6597: update</strong></span>:</p>
1.75 rillig 6598: <div class="variablelist"><dl>
6599: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
1.88 wiz 6600: <dd><p>Install target to recursively use for the
6601: updated package and the dependent packages.
6602: Defaults to <code class="varname">DEPENDS_TARGET</code> if
6603: set, “<span class="quote">install</span>” otherwise for
6604: <span><strong class="command">make update</strong></span>. Other good
6605: targets are “<span class="quote">package</span>” or
6606: “<span class="quote">bin-install</span>”. Do not set this to
6607: “<span class="quote">update</span>” or you will get stuck in an
6608: endless loop!</p></dd>
1.75 rillig 6609: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
1.88 wiz 6610: <dd><p>Don't clean up after updating. Useful if
6611: you want to leave the work sources of the updated
6612: packages around for inspection or other purposes.
6613: Be sure you eventually clean up the source tree
6614: (see the “<span class="quote">clean-update</span>” target below)
6615: or you may run into troubles with old source code
6616: still lying around on your next
6617: <span><strong class="command">make</strong></span> or <span><strong class="command">make
6618: update</strong></span>.</p></dd>
1.75 rillig 6619: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
1.88 wiz 6620: <dd><p>Deinstall each package before installing
6621: (making <code class="varname">DEPENDS_TARGET</code>). This
6622: may be necessary if the
6623: “<span class="quote">clean-update</span>” target (see below) was
6624: called after interrupting a running <span><strong class="command">make
6625: update</strong></span>.</p></dd>
1.75 rillig 6626: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
1.88 wiz 6627: <dd><p>Allows you to disable recursion and hardcode
6628: the target for packages. The default is
6629: “<span class="quote">update</span>” for the update target,
6630: facilitating a recursive update of prerequisite
6631: packages. Only set
6632: <code class="varname">DEPENDS_TARGET</code> if you want to
6633: disable recursive updates. Use
6634: <code class="varname">UPDATE_TARGET</code> instead to just
6635: set a specific target for each package to be
6636: installed during <span><strong class="command">make update</strong></span>
6637: (see above).</p></dd>
1.75 rillig 6638: </dl></div>
6639: </dd>
6640: <dt><span class="term">clean-update</span></dt>
6641: <dd>
1.88 wiz 6642: <p>Clean the source tree for all packages that would
6643: get updated if <span><strong class="command">make update</strong></span> was called
6644: from the current directory. This target should not be
6645: used if the current package (or any of its depending
6646: packages) have already been de-installed (e.g., after
6647: calling <span><strong class="command">make update</strong></span>) or you may lose
6648: some packages you intended to update. As a rule of
6649: thumb: only use this target <span class="emphasis"><em>before</em></span>
6650: the first time you run <span><strong class="command">make update</strong></span>
6651: and only if you have a dirty package tree (e.g., if you
6652: used <code class="varname">NOCLEAN</code>).</p>
6653: <p>If you are unsure about whether your tree is
6654: clean, you can either perform a <span><strong class="command">make
6655: clean</strong></span> at the top of the tree, or use the
6656: following sequence of commands from the directory of the
6657: package you want to update (<span class="emphasis"><em>before</em></span>
6658: running <span><strong class="command">make update</strong></span> for the first
6659: time, otherwise you lose all the packages you wanted to
6660: update!):</p>
1.87 wiz 6661: <pre class="screen">
6662: <code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
1.75 rillig 6663: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
1.87 wiz 6664: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong>
6665: </pre>
1.88 wiz 6666: <p>The following variables can be used either on the
6667: command line or in <code class="filename">/etc/mk.conf</code> to
6668: alter the behaviour of <span><strong class="command">make
6669: clean-update</strong></span>:</p>
1.75 rillig 6670: <div class="variablelist"><dl>
6671: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
1.88 wiz 6672: <dd><p>After <span><strong class="command">make clean</strong></span>, do not
6673: reconstruct the list of directories to update for
6674: this package. Only use this if <span><strong class="command">make
6675: update</strong></span> successfully installed all
6676: packages you wanted to update. Normally, this is
6677: done automatically on <span><strong class="command">make
6678: update</strong></span>, but may have been suppressed by
6679: the <code class="varname">NOCLEAN</code> variable (see
6680: above).</p></dd>
1.75 rillig 6681: </dl></div>
6682: </dd>
1.88 wiz 6683: <dt><span class="term">replace</span></dt>
6684: <dd>
6685: <p>Update the installation of the current package. This
6686: differs from update in that it does not replace dependent
6687: 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
6688: target to work.</p>
6689: <p><span class="emphasis"><em>Be careful when using this
6690: target!</em></span> There are no guarantees that dependent
6691: packages will still work, in particular they will most
6692: certainly break if you <span><strong class="command">make replace</strong></span> a
6693: library package whose shared library major version changed
6694: between your installed version and the new one. For this
6695: reason, this target is not officially supported and only
6696: recommended for advanced users.</p>
6697: </dd>
1.75 rillig 6698: <dt><span class="term">info</span></dt>
6699: <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 6700: package. You can use this to check which version of a
6701: package is installed.</p></dd>
6702: <dt><span class="term">index</span></dt>
6703: <dd>
6704: <p>This is a top-level command, i.e. it should be used in
6705: the <code class="filename">pkgsrc</code> directory. It creates a
6706: database of all packages in the local pkgsrc tree, including
6707: dependencies, comment, maintainer, and some other useful
6708: information. Individual entries are created by running
6709: <span><strong class="command">make describe</strong></span> in the packages'
6710: directories. This index file is saved as
6711: <code class="filename">pkgsrc/INDEX</code>. It can be displayed in
6712: verbose format by running <span><strong class="command">make
6713: print-index</strong></span>. You can search in it with
6714: <span><strong class="command">make search
6715: key=<em class="replaceable"><code>something</code></em></strong></span>. You can
6716: extract a list of all packages that depend on a particular
6717: one by running <span><strong class="command">make show-deps
6718: PKG=<em class="replaceable"><code>somepackage</code></em></strong></span>.</p>
6719: <p>Running this command takes a very long time, some
6720: hours even on fast machines!</p>
6721: </dd>
1.75 rillig 6722: <dt><span class="term">readme</span></dt>
1.88 wiz 6723: <dd>
6724: <p>This target generates a
6725: <code class="filename">README.html</code> file, which can be
6726: 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
6727: contain references to any packages which are in the
6728: <code class="varname">PACKAGES</code> directory on the local
6729: host. The generated files can be made to refer to URLs
6730: based on <code class="varname">FTP_PKG_URL_HOST</code> and
6731: <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I
6732: wanted to generate <code class="filename">README.html</code>
6733: files which pointed to binary packages on the local
6734: machine, in the directory
6735: <code class="filename">/usr/packages</code>, set
6736: <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
6737: <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
6738: <code class="varname">${PACKAGES}</code> directory and its
6739: subdirectories will be searched for all the binary
6740: packages.</p>
6741: <p>The target can be run at the toplevel or in category
6742: directories, in which case it descends recursively.</p>
6743: </dd>
1.75 rillig 6744: <dt><span class="term">readme-all</span></dt>
1.88 wiz 6745: <dd><p>This is a top-level command, run it in
6746: <code class="filename">pkgsrc</code>. Use this target to create a
6747: file <code class="filename">README-all.html</code> which contains a
6748: list of all packages currently available in the NetBSD
6749: Packages Collection, together with the category they belong
6750: to and a short description. This file is compiled from the
6751: <code class="filename">pkgsrc/*/README.html</code> files, so be sure
6752: to run this <span class="emphasis"><em>after</em></span> a <span><strong class="command">make
6753: readme</strong></span>.</p></dd>
1.75 rillig 6754: <dt><span class="term">cdrom-readme</span></dt>
1.88 wiz 6755: <dd><p>This is very much the same as the
6756: “<span class="quote">readme</span>” target (see above), but is to be
6757: used when generating a pkgsrc tree to be written to a
6758: CD-ROM. This target also produces
6759: <code class="filename">README.html</code> files, and can be made
6760: to refer to URLs based on
6761: <code class="varname">CDROM_PKG_URL_HOST</code> and
1.87 wiz 6762: <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
1.75 rillig 6763: <dt><span class="term">show-distfiles</span></dt>
1.88 wiz 6764: <dd><p>This target shows which distfiles and patchfiles
6765: are needed to build the package
6766: (<code class="varname">ALLFILES</code>, which contains all
6767: <code class="varname">DISTFILES</code> and
1.87 wiz 6768: <code class="varname">PATCHFILES</code>, but not
6769: <code class="filename">patches/*</code>).</p></dd>
1.75 rillig 6770: <dt><span class="term">show-downlevel</span></dt>
1.88 wiz 6771: <dd><p>This target shows nothing if the package is not
6772: installed. If a version of this package is installed,
6773: but is not the version provided in this version of
6774: pkgsrc, then a warning message is displayed. This target
6775: can be used to show which of your installed packages are
6776: downlevel, and so the old versions can be deleted, and
6777: the current ones added.</p></dd>
1.75 rillig 6778: <dt><span class="term">show-pkgsrc-dir</span></dt>
1.88 wiz 6779: <dd><p>This target shows the directory in the pkgsrc
6780: hierarchy from which the package can be built and
6781: installed. This may not be the same directory as the one
6782: from which the package was installed. This target is
6783: intended to be used by people who may wish to upgrade
6784: many packages on a single host, and can be invoked from
6785: the top-level pkgsrc Makefile by using the
1.87 wiz 6786: “<span class="quote">show-host-specific-pkgs</span>” target.</p></dd>
1.75 rillig 6787: <dt><span class="term">show-installed-depends</span></dt>
1.88 wiz 6788: <dd><p>This target shows which installed packages match
6789: the current package's <code class="varname">DEPENDS</code>. Useful
6790: if out of date dependencies are causing build
6791: problems.</p></dd>
1.75 rillig 6792: <dt><span class="term">check-shlibs</span></dt>
1.88 wiz 6793: <dd><p>After a package is installed, check all its
6794: binaries and (on ELF platforms) shared libraries to see
6795: if they find the shared libs they need. Run by default
6796: if <code class="varname">PKG_DEVELOPER</code> is set in
1.87 wiz 6797: <code class="filename">/etc/mk.conf</code>.</p></dd>
1.75 rillig 6798: <dt><span class="term">print-PLIST</span></dt>
6799: <dd>
6800: <p>After a “<span class="quote">make install</span>” from a new or
1.88 wiz 6801: upgraded pkg, this prints out an attempt to generate a
6802: new <code class="filename">PLIST</code> from a <span><strong class="command">find
6803: -newer work/.extract_done</strong></span>. An attempt is made
6804: to care for shared libs etc., but it is
1.87 wiz 6805: <span class="emphasis"><em>strongly</em></span> recommended to review the
6806: result before putting it into
6807: <code class="filename">PLIST</code>. On upgrades, it's useful to
6808: diff the output of this command against an already
6809: existing <code class="filename">PLIST</code> file.</p>
1.88 wiz 6810: <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
6811: other methods that don't update file access times, be
6812: sure to add these files manually to your
1.87 wiz 6813: <code class="filename">PLIST</code>, as the “<span class="quote">find
6814: -newer</span>” command used by this target won't catch
6815: them!</p>
6816: <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
6817: information on this target.</p>
1.75 rillig 6818: </dd>
6819: <dt><span class="term">bulk-package</span></dt>
6820: <dd>
1.88 wiz 6821: <p>Used to do bulk builds. If an appropriate binary
6822: package already exists, no action is taken. If not, this
6823: target will compile, install and package it (and its
6824: depends, if <code class="varname">PKG_DEPENDS</code> is set
6825: properly. See <a href="#binary.configuration" title="6.3.1. Configuration">Section 6.3.1, “Configuration”</a>).
6826: After creating the binary package, the sources, the
6827: just-installed package and its required packages are
6828: removed, preserving free disk space.</p>
6829: <p><span class="emphasis"><em>Beware that this target may deinstall
6830: all packages installed on a system!</em></span></p>
1.75 rillig 6831: </dd>
6832: <dt><span class="term">bulk-install</span></dt>
6833: <dd>
1.88 wiz 6834: <p>Used during bulk-installs to install required
6835: packages. If an up-to-date binary package is available,
6836: 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,
6837: <span><strong class="command">make bulk-package</strong></span> will be executed,
1.87 wiz 6838: but the installed binary won't be removed.</p>
1.88 wiz 6839: <p>A binary package is considered
6840: “<span class="quote">up-to-date</span>” to be installed via
6841: <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>
6842: <div class="itemizedlist"><ul type="disc">
6843: <li><p>None of the package's files
6844: (<code class="filename">Makefile</code>, ...) were modified
6845: since it was built.</p></li>
6846: <li><p>None of the package's required (binary)
6847: packages were modified since it was built.</p></li>
1.75 rillig 6848: </ul></div>
1.88 wiz 6849: <p><span class="emphasis"><em>Beware that this target may deinstall
6850: all packages installed on a system!</em></span></p>
1.75 rillig 6851: </dd>
6852: </dl></div>
6853: </div>
6854: </div>
6855: <div class="chapter" lang="en">
6856: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 6857: <a name="tools"></a>Chapter 16. Tools needed for building or running</h2></div></div></div>
1.75 rillig 6858: <div class="toc">
6859: <p><b>Table of Contents</b></p>
6860: <dl>
1.77 rillig 6861: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
6862: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
6863: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
1.75 rillig 6864: </dl>
6865: </div>
1.87 wiz 6866: <p>The <code class="varname">USE_TOOLS</code> definition is used both internally
1.75 rillig 6867: by pkgsrc and also for individual packages to define what commands
6868: are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
6869: or for later run-time of an installed packaged (such as
6870: <code class="varname">DEPENDS</code>).
6871: If the native system provides an adequate tool, then in many cases, a pkgsrc
1.87 wiz 6872: package will not be used.</p>
6873: <p>When building a package, the replacement tools are
1.75 rillig 6874: made available in a directory (as symlinks or wrapper scripts)
6875: that is early in the executable search path. Just like the buildlink
1.87 wiz 6876: system, this helps with consistent builds.</p>
6877: <p>A tool may be needed to help build a specific package. For example,
6878: perl, GNU make (gmake) or yacc may be needed.</p>
6879: <p>Also a tool may be needed, for example, because the native system's supplied
1.75 rillig 6880: tool may be inefficient for building a package with pkgsrc.
6881: For example, a package may need GNU awk, bison (instead of
1.87 wiz 6882: yacc) or a better sed.</p>
6883: <p>The tools used by a package can be listed by running
6884: <span><strong class="command">make show-tools</strong></span>.</p>
1.75 rillig 6885: <div class="sect1" lang="en">
6886: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6887: <a name="pkgsrc-tools"></a>16.1. Tools for pkgsrc builds</h2></div></div></div>
1.87 wiz 6888: <p>The default set of tools used by pkgsrc is defined in
1.76 rillig 6889: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.75 rillig 6890: such as: <span><strong class="command">cat</strong></span>, <span><strong class="command">awk</strong></span>,
6891: <span><strong class="command">chmod</strong></span>, <span><strong class="command">test</strong></span>, and so on.
6892: These can be seen by running:
1.87 wiz 6893: <span><strong class="command">make show-var VARNAME=USE_TOOLS</strong></span>.</p>
6894: <p>If a package needs a specific program to build
1.75 rillig 6895: then the <code class="varname">USE_TOOLS</code> variable can be used
1.87 wiz 6896: to define the tools needed.</p>
1.75 rillig 6897: </div>
6898: <div class="sect1" lang="en">
6899: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6900: <a name="package-tools"></a>16.2. Tools needed by packages</h2></div></div></div>
1.87 wiz 6901: <p>In the following examples, the :pkgsrc means to use the pkgsrc version
1.75 rillig 6902: and not the native version for a build dependency.
6903: And the :run means that it is used for a
6904: run-time dependencies also (and becomes a DEPENDS).
6905: The default is a build dependency which can be set with
6906: :build. (So in this example, it is the same as gmake:build
1.87 wiz 6907: and pkg-config:build.)</p>
1.75 rillig 6908: <pre class="programlisting">
6909: USE_TOOLS+= mktemp:pkgsrc
6910: USE_TOOLS+= gmake perl:run pkg-config
6911: </pre>
1.87 wiz 6912: <p>When using the tools framework, a
1.75 rillig 6913: <code class="varname">TOOLS_PATH.foo</code> variable is defined
6914: which contains the full path to the appropriate tool. For example,
6915: <code class="varname">TOOLS_PATH.bash</code> could be “<span class="quote">/bin/bash</span>”
1.87 wiz 6916: on Linux systems.</p>
6917: <p>If you always need a pkgsrc version of the
1.75 rillig 6918: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
6919: </p>
6920: </div>
6921: <div class="sect1" lang="en">
6922: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 6923: <a name="platform-tools"></a>16.3. Tools provided by platforms</h2></div></div></div>
1.87 wiz 6924: <p>When improving or porting pkgsrc to a new platform, have a look
1.75 rillig 6925: at (or create) the corresponding platform specific make file fragment under
1.76 rillig 6926: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
1.75 rillig 6927: the name of the common tools. For example:</p>
6928: <pre class="programlisting">
6929: .if exists(/usr/bin/bzcat)
6930: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
6931: .elif exists(/usr/bin/bzip2)
6932: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
6933: .endif
1.69 rillig 6934:
1.75 rillig 6935: TOOLS_PLATFORM.true?= true # shell builtin
6936: </pre>
6937: </div>
6938: </div>
6939: <div class="chapter" lang="en">
6940: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 6941: <a name="fixes"></a>Chapter 17. Making your package work</h2></div></div></div>
1.75 rillig 6942: <div class="toc">
6943: <p><b>Table of Contents</b></p>
6944: <dl>
1.77 rillig 6945: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
1.75 rillig 6946: <dd><dl>
1.78 rillig 6947: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
6948: <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>
6949: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
6950: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
6951: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
6952: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
6953: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
6954: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
6955: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
6956: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
6957: <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 6958: <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 6959: </dl></dd>
6960: <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>
6961: <dd><dl>
6962: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
6963: <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>
6964: </dl></dd>
6965: <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>
6966: <dd><dl>
6967: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
6968: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
6969: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
6970: </dl></dd>
1.87 wiz 6971: <dt><span class="sect1"><a href="#programming-languages">17.4. Programming languages</a></span></dt>
1.77 rillig 6972: <dd><dl>
1.87 wiz 6973: <dt><span class="sect2"><a href="#basic-programming-languages">17.4.1. C, C++, and Fortran</a></span></dt>
6974: <dt><span class="sect2"><a href="#java-programming-language">17.4.2. Java</a></span></dt>
6975: <dt><span class="sect2"><a href="#perl-scripts">17.4.3. Packages containing perl scripts</a></span></dt>
6976: <dt><span class="sect2"><a href="#other-programming-languages">17.4.4. Other programming languages</a></span></dt>
6977: </dl></dd>
6978: <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>
6979: <dd><dl>
6980: <dt><span class="sect2"><a href="#fixes.build.cpp">17.5.1. Compiling C and C++ code conditionally</a></span></dt>
6981: <dt><span class="sect2"><a href="#compiler-bugs">17.5.2. How to handle compiler bugs</a></span></dt>
6982: <dt><span class="sect2"><a href="#undefined-reference">17.5.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
6983: <dt><span class="sect2"><a href="#out-of-memory">17.5.4. Running out of memory</a></span></dt>
6984: </dl></dd>
6985: <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>
6986: <dd><dl>
6987: <dt><span class="sect2"><a href="#install-scripts">17.6.1. Creating needed directories</a></span></dt>
6988: <dt><span class="sect2"><a href="#where-to-install-documentation">17.6.2. Where to install documentation</a></span></dt>
6989: <dt><span class="sect2"><a href="#installing-score-files">17.6.3. Installing score files</a></span></dt>
6990: <dt><span class="sect2"><a href="#hardcoded-paths">17.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
6991: <dt><span class="sect2"><a href="#perl-modules">17.6.5. Packages installing perl modules</a></span></dt>
6992: <dt><span class="sect2"><a href="#faq.info-files">17.6.6. Packages installing info files</a></span></dt>
6993: <dt><span class="sect2"><a href="#manpages">17.6.7. Packages installing man pages</a></span></dt>
6994: <dt><span class="sect2"><a href="#gconf2-data-files">17.6.8. Packages installing GConf2 data files</a></span></dt>
6995: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.6.9. Packages installing scrollkeeper data files</a></span></dt>
6996: <dt><span class="sect2"><a href="#x11-fonts">17.6.10. Packages installing X11 fonts</a></span></dt>
6997: <dt><span class="sect2"><a href="#gtk2-modules">17.6.11. Packages installing GTK2 modules</a></span></dt>
6998: <dt><span class="sect2"><a href="#sgml-xml-data">17.6.12. Packages installing SGML or XML data</a></span></dt>
6999: <dt><span class="sect2"><a href="#mime-database">17.6.13. Packages installing extensions to the MIME database</a></span></dt>
7000: <dt><span class="sect2"><a href="#intltool">17.6.14. Packages using intltool</a></span></dt>
7001: <dt><span class="sect2"><a href="#startup-scripts">17.6.15. Packages installing startup scripts</a></span></dt>
7002: <dt><span class="sect2"><a href="#tex-packages">17.6.16. Packages installing TeX modules</a></span></dt>
7003: <dt><span class="sect2"><a href="#emulation-packages">17.6.17. Packages supporting running binaries in
7004: emulation</a></span></dt>
7005: <dt><span class="sect2"><a href="#hicolor-theme">17.6.18. Packages installing hicolor theme icons</a></span></dt>
7006: <dt><span class="sect2"><a href="#desktop-files">17.6.19. Packages installing desktop files</a></span></dt>
1.75 rillig 7007: </dl></dd>
1.87 wiz 7008: <dt><span class="sect1"><a href="#punting">17.7. Marking packages as having problems</a></span></dt>
1.75 rillig 7009: </dl>
7010: </div>
7011: <div class="sect1" lang="en">
7012: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7013: <a name="general-operation"></a>17.1. General operation</h2></div></div></div>
1.75 rillig 7014: <div class="sect2" lang="en">
7015: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7016: <a name="portability-of-packages"></a>17.1.1. Portability of packages</h3></div></div></div>
7017: <p>One appealing feature of pkgsrc is that it runs on many
1.87 wiz 7018: different platforms. As a result, it is important to ensure,
7019: where possible, that packages in pkgsrc are portable. This
7020: chapter mentions some particular details you should pay
7021: attention to while working on pkgsrc.</p>
1.78 rillig 7022: </div>
7023: <div class="sect2" lang="en">
7024: <div class="titlepage"><div><div><h3 class="title">
7025: <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>
7026: <p>The pkgsrc user can configure pkgsrc by overriding several
1.87 wiz 7027: variables in the file pointed to by <code class="varname">MAKECONF</code>,
7028: which is <code class="filename">/etc/mk.conf</code> by default. When you
7029: want to use those variables in the preprocessor directives of
7030: <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
7031: <code class="literal">.for</code>), you need to include the file
7032: <code class="filename">../../mk/bsd.prefs.mk</code> before, which in turn
7033: loads the user preferences.</p>
1.78 rillig 7034: <p>But note that some variables may not be completely defined
1.87 wiz 7035: after <code class="filename">../../mk/bsd.prefs.mk</code> has been
7036: included, as they may contain references to variables that are
7037: not yet defined. In shell commands this is no problem, since
7038: variables are actually macros, which are only expanded when they
7039: are used. But in the preprocessor directives mentioned above and
7040: in dependency lines (of the form <code class="literal">target:
7041: dependencies</code>) the variables are expanded at load
7042: time.</p>
1.78 rillig 7043: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7044: <h3 class="title">Note</h3>
7045: <p>Currently there is no exhaustive list of all
1.87 wiz 7046: variables that tells you whether they can be used at load time
7047: or only at run time, but it is in preparation.</p>
1.78 rillig 7048: </div>
7049: </div>
7050: <div class="sect2" lang="en">
7051: <div class="titlepage"><div><div><h3 class="title">
7052: <a name="user-interaction"></a>17.1.3. User interaction</h3></div></div></div>
1.88 wiz 7053: <p>Occasionally, packages require interaction from the user,
7054: and this can be in a number of ways:</p>
1.78 rillig 7055: <div class="itemizedlist"><ul type="disc">
1.79 rillig 7056: <li><p>When fetching the distfiles, some packages require user
1.87 wiz 7057: interaction such as entering username/password or accepting a
7058: license on a web page.</p></li>
1.88 wiz 7059: <li><p>When extracting the distfiles, some packages may ask for
7060: passwords.</p></li>
1.78 rillig 7061: <li><p>help to configure the package before it is built</p></li>
7062: <li><p>help during the build process</p></li>
7063: <li><p>help during the installation of a package</p></li>
7064: </ul></div>
1.88 wiz 7065: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is
7066: provided to notify the pkgsrc mechanism of an interactive stage
7067: which will be needed, and this should be set in the package's
7068: <code class="filename">Makefile</code>, e.g.:</p>
1.75 rillig 7069: <pre class="programlisting">
1.87 wiz 7070: INTERACTIVE_STAGE= build
7071: </pre>
1.78 rillig 7072: <p>Multiple interactive stages can be specified:</p>
1.75 rillig 7073: <pre class="programlisting">
1.87 wiz 7074: INTERACTIVE_STAGE= configure install
7075: </pre>
1.88 wiz 7076: <p>The user can then decide to skip this package by setting the
7077: <code class="varname">BATCH</code> variable.</p>
1.75 rillig 7078: </div>
7079: <div class="sect2" lang="en">
7080: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7081: <a name="handling-licenses"></a>17.1.4. Handling licenses</h3></div></div></div>
7082: <p>A package may be covered by a license which the user has
1.87 wiz 7083: or has not agreed to accept. For these cases, pkgsrc contains
7084: a mechanism to note that a package is covered by a particular
7085: license, and the package cannot be built unless the user has
7086: accepted the license. (Installation of binary packages are
7087: not currently subject to this mechanism.) Packages with
7088: licenses that are either Open Source according to the Open
7089: Source Initiative or Free according to the Free Software
7090: Foundation will not be marked with a license tag. Packages
7091: with licenses that have not been determined to meet either
7092: definition will be marked with a license tag referring to the
7093: license. This will prevent building unless pkgsrc is informed
7094: that the license is acceptable, and enables displaying the
7095: license.</p>
1.78 rillig 7096: <p>The license tag mechanism is intended to address
1.87 wiz 7097: copyright-related issues surrounding building, installing and
7098: using a package, and not to address redistribution issues (see
7099: <code class="varname">RESTRICTED</code> and
7100: <code class="varname">NO_SRC_ON_FTP</code>, etc.). However, the above
7101: definition of licenses for which tags are not needed implies
7102: that packages with redistribution restrictions should have
7103: tags.</p>
7104: <p>Denoting that a package is covered by a particular license
7105: is done by placing the license in
7106: <code class="filename">pkgsrc/licenses</code> and setting the
7107: <code class="varname">LICENSE</code> variable to a string identifying the
7108: 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>
7109: <pre class="programlisting">
7110: LICENSE= xv-license
7111: </pre>
7112: <p>When trying to build, the user will get a notice that the
7113: package is covered by a license which has not been
7114: accepted:</p>
7115: <pre class="programlisting">
7116: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
7117: ===> xv-3.10anb9 has an unacceptable license: xv-license.
7118: ===> To view the license, enter "/usr/bin/make show-license".
7119: ===> To indicate acceptance, add this line to your /etc/mk.conf:
7120: ===> ACCEPTABLE_LICENSES+=xv-license
7121: *** Error code 1
7122: </pre>
1.78 rillig 7123: <p>The license can be viewed with <span><strong class="command">make
1.87 wiz 7124: show-license</strong></span>, and if it is considered appropriate,
7125: the line printed above can be added to
7126: <code class="filename">/etc/mk.conf</code> to indicate acceptance of
7127: the particular license:</p>
1.78 rillig 7128: <pre class="programlisting">
1.87 wiz 7129: ACCEPTABLE_LICENSES+=xv-license
7130: </pre>
1.78 rillig 7131: <p>When adding a package with a new license, the license
1.87 wiz 7132: text should be added to <code class="filename">pkgsrc/licenses</code>
7133: for displaying. A list of known licenses can be seen in this
7134: directory as well as by looking at the list of (commented
7135: out) <code class="varname">ACCEPTABLE_LICENSES</code> variable
7136: settings in
7137: <code class="filename">pkgsrc/mk/defaults/mk.conf</code>.</p>
1.78 rillig 7138: <p>The use of <code class="varname">LICENSE=shareware</code>,
1.87 wiz 7139: <code class="varname">LICENSE=no-commercial-use</code>, and similar
7140: language is deprecated because it does not crisply refer to
7141: a particular license text. Another problem with such usage
7142: is that it does not enable a user to denote acceptance of
7143: the license for a single package without accepting the same
7144: license text for another package. In particular, this can
7145: be inappropriate when e.g. one accepts a particular license to
7146: indicate to pkgsrc that a fee has been paid.</p>
1.75 rillig 7147: </div>
7148: <div class="sect2" lang="en">
7149: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7150: <a name="restricted-packages"></a>17.1.5. Restricted packages</h3></div></div></div>
1.75 rillig 7151: <p>Some licenses restrict how software may be re-distributed.
1.87 wiz 7152: In order to satisfy these restrictions, the package system
7153: defines five make variables that can be set to note these
7154: restrictions:</p>
1.75 rillig 7155: <div class="itemizedlist"><ul type="disc">
7156: <li>
7157: <p><code class="varname">RESTRICTED</code></p>
7158: <p>This variable should be set whenever a restriction
1.87 wiz 7159: exists (regardless of its kind). Set this variable to a
7160: string containing the reason for the restriction.</p>
1.75 rillig 7161: </li>
7162: <li>
7163: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
7164: <p>Binaries may not be placed on CD-ROM. Set this
1.87 wiz 7165: variable to <code class="varname">${RESTRICTED}</code> whenever a
7166: binary package may not be included on a CD-ROM.</p>
1.75 rillig 7167: </li>
7168: <li>
7169: <p><code class="varname">NO_BIN_ON_FTP</code></p>
7170: <p>Binaries may not be placed on an FTP server. Set
1.87 wiz 7171: this variable to <code class="varname">${RESTRICTED}</code>
7172: whenever a binary package may not not be made available
7173: on the Internet.</p>
1.75 rillig 7174: </li>
7175: <li>
7176: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
7177: <p>Distfiles may not be placed on CD-ROM. Set this
1.87 wiz 7178: variable to <code class="varname">${RESTRICTED}</code> if
7179: re-distribution of the source code or other distfile(s) is
7180: not allowed on CD-ROMs.</p>
1.75 rillig 7181: </li>
7182: <li>
7183: <p><code class="varname">NO_SRC_ON_FTP</code></p>
7184: <p>Distfiles may not be placed on FTP. Set this variable
1.87 wiz 7185: to <code class="varname">${RESTRICTED}</code> if re-distribution of
7186: the source code or other distfile(s) via the Internet is not
7187: allowed. If this variable is not set, the distfile(s) will
7188: be mirrored on ftp.NetBSD.org.</p>
1.75 rillig 7189: </li>
7190: </ul></div>
7191: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
1.87 wiz 7192: <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
7193: generic make variables to denote restrictions is deprecated,
7194: because they unconditionally prevent users from generating
7195: binary packages!</p>
1.75 rillig 7196: </div>
7197: <div class="sect2" lang="en">
7198: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7199: <a name="dependencies"></a>17.1.6. Handling dependencies</h3></div></div></div>
1.75 rillig 7200: <p>Your package may depend on some other package being present
1.88 wiz 7201: - and there are various ways of expressing this dependency.
7202: pkgsrc supports the <code class="varname">BUILD_DEPENDS</code> and
7203: <code class="varname">DEPENDS</code> definitions, the
7204: <code class="varname">USE_TOOLS</code> definition, as well as dependencies
7205: via <code class="filename">buildlink3.mk</code>, which is the preferred way
7206: to handle dependencies, and which uses the variables named above.
7207: See <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a> for more information.</p>
1.75 rillig 7208: <p>The basic difference between the two variables is as
1.87 wiz 7209: follows: The <code class="varname">DEPENDS</code> definition registers
7210: that pre-requisite in the binary package so it will be pulled in
7211: when the binary package is later installed, whilst the
7212: <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
7213: dependency that is only needed for building the package.</p>
1.75 rillig 7214: <p>This means that if you only need a package present whilst
1.87 wiz 7215: you are building, it should be noted as a
7216: <code class="varname">BUILD_DEPENDS</code>.</p>
1.75 rillig 7217: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
1.87 wiz 7218: <code class="varname">DEPENDS</code> definition is:</p>
1.75 rillig 7219: <pre class="programlisting">
1.87 wiz 7220: <pre-req-package-name>:../../<category>/<pre-req-package>
7221: </pre>
1.75 rillig 7222: <p>Please note that the “<span class="quote">pre-req-package-name</span>”
1.87 wiz 7223: may include any of the wildcard version numbers recognized by
7224: <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 7225: <div class="orderedlist"><ol type="1">
7226: <li>
7227: <p>If your package needs another package's binaries or
1.87 wiz 7228: libraries to build or run, and if that package has a
7229: <code class="filename">buildlink3.mk</code> file available, use it:</p>
1.75 rillig 7230: <pre class="programlisting">
1.87 wiz 7231: .include "../../graphics/jpeg/buildlink3.mk"
7232: </pre>
1.75 rillig 7233: </li>
7234: <li>
7235: <p>If your package needs to use another package to build
1.87 wiz 7236: itself and there is no <code class="filename">buildlink3.mk</code>
7237: file available, use the <code class="varname">BUILD_DEPENDS</code>
7238: definition:</p>
1.75 rillig 7239: <pre class="programlisting">
1.87 wiz 7240: BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
7241: </pre>
1.75 rillig 7242: </li>
7243: <li>
7244: <p>If your package needs a library with which to link and
1.76 rillig 7245: again there is no <code class="filename">buildlink3.mk</code> file
1.87 wiz 7246: available, this is specified using the
7247: <code class="varname">DEPENDS</code> definition. For example:</p>
1.75 rillig 7248: <pre class="programlisting">
1.87 wiz 7249: DEPENDS+= xpm-3.4j:../../graphics/xpm
7250: </pre>
1.75 rillig 7251: <p>You can also use wildcards in package dependences:</p>
7252: <pre class="programlisting">
1.87 wiz 7253: DEPENDS+= xpm-[0-9]*:../../graphics/xpm
7254: </pre>
1.75 rillig 7255: <p>Note that such wildcard dependencies are retained when
1.87 wiz 7256: creating binary packages. The dependency is checked when
7257: installing the binary package and any package which matches
7258: the pattern will be used. Wildcard dependencies should be
7259: used with care.</p>
1.75 rillig 7260: <p>The “<span class="quote">-[0-9]*</span>” should be used instead of
1.87 wiz 7261: “<span class="quote">-*</span>” to avoid potentially ambiguous matches
7262: such as “<span class="quote">tk-postgresql</span>” matching a
7263: “<span class="quote">tk-*</span>” <code class="varname">DEPENDS</code>.</p>
1.75 rillig 7264: <p>Wildcards can also be used to specify that a package
1.87 wiz 7265: will only build against a certain minimum version of a
7266: pre-requisite:</p>
1.75 rillig 7267: <pre class="programlisting">
1.87 wiz 7268: DEPENDS+= tiff>=3.5.4:../../graphics/tiff
7269: </pre>
1.75 rillig 7270: <p>This means that the package will build against version
1.87 wiz 7271: 3.5.4 of the tiff library or newer. Such a dependency may
7272: be warranted if, for example, the API of the library has
7273: changed with version 3.5.4 and a package would not compile
7274: against an earlier version of tiff.</p>
1.75 rillig 7275: <p>Please note that such dependencies should only be
1.87 wiz 7276: updated if a package requires a newer pre-requisite, but
7277: not to denote recommendations such as
7278: ABI changes that do not prevent a package from building
7279: correctly. Such recommendations can be expressed using
7280: <code class="varname">ABI_DEPENDS</code>:</p>
1.75 rillig 7281: <pre class="programlisting">
1.87 wiz 7282: ABI_DEPENDS+= tiff>=3.6.1:../../graphics/tiff
7283: </pre>
1.75 rillig 7284: <p>In addition to the above <code class="varname">DEPENDS</code>
1.87 wiz 7285: line, this denotes that while a package will build against
7286: tiff>=3.5.4, at least version 3.6.1 is recommended.
7287: <code class="varname">ABI_DEPENDS</code> entries will be turned into
7288: dependencies unless explicitly ignored (in which case a
7289: warning will be printed).</p>
1.75 rillig 7290: <p>To ignore these ABI dependency recommendations and just
1.87 wiz 7291: use the required <code class="varname">DEPENDS</code>, set
7292: <code class="varname">USE_ABI_DEPENDS=NO</code>. This may make
7293: it easier and faster to update packages built using pkgsrc,
7294: since older compatible dependencies can continue to be
7295: used. This is useful for people who watch their rebuilds
7296: very carefully; it is not very good as a general-purpose
7297: hammer. If you use it, you need to be mindful of possible
7298: ABI changes, including those from the underlying OS.</p>
1.75 rillig 7299: <p>Packages that are built with recommendations ignored
1.87 wiz 7300: may not be uploaded to ftp.NetBSD.org by developers and
7301: should not be used across different systems that may have
7302: different versions of binary packages installed.</p>
1.75 rillig 7303: <p>For security fixes, please update the package
1.87 wiz 7304: 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
7305: information.</p>
1.75 rillig 7306: </li>
7307: <li>
7308: <p>If your package needs some executable to be able to run
1.87 wiz 7309: correctly and if there's no
7310: <code class="filename">buildlink3.mk</code> file, this is specified
7311: using the <code class="varname">DEPENDS</code> variable. The
7312: <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
7313: be able to execute the latex binary from the teTeX package
7314: when it runs, and that is specified:</p>
1.75 rillig 7315: <pre class="programlisting">
1.87 wiz 7316: DEPENDS+= teTeX-[0-9]*:../../print/teTeX
7317: </pre>
1.75 rillig 7318: <p>The comment about wildcard dependencies from previous
1.87 wiz 7319: paragraph applies here, too.</p>
1.75 rillig 7320: </li>
7321: </ol></div>
7322: <p>If your package needs files from another package to build,
1.87 wiz 7323: add the relevant distribution files to
7324: <code class="varname">DISTFILES</code>, so they will be extracted
7325: 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.
7326: (It relies on the jpeg sources being present in source form
7327: during the build.)</p>
1.88 wiz 7328: <p>Please also note the
7329: <code class="varname">BUILD_USES_GETTEXT_M4</code> definition, which is
7330: provided as convenience definition. It adds a build dependency on
7331: either an installed version of an older gettext package, or if it
7332: 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 7333: </div>
7334: <div class="sect2" lang="en">
7335: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7336: <a name="conflicts"></a>17.1.7. Handling conflicts with other packages</h3></div></div></div>
1.75 rillig 7337: <p>Your package may conflict with other packages a user might
1.87 wiz 7338: already have installed on his system, e.g. if your package
1.88 wiz 7339: installs the same set of files as another package in the pkgsrc
7340: tree.</p>
1.75 rillig 7341: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
1.87 wiz 7342: space-separated list of packages (including version string) your
7343: package conflicts with.</p>
1.76 rillig 7344: <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 7345: 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>
7346: install the same shared library, thus you set in
7347: <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
7348: <pre class="programlisting">
7349: CONFLICTS= Xaw-Xpm-[0-9]*
7350: </pre>
7351: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:</p>
1.75 rillig 7352: <pre class="programlisting">
1.87 wiz 7353: CONFLICTS= Xaw3d-[0-9]*
7354: </pre>
1.75 rillig 7355: <p>Packages will automatically conflict with other packages
1.87 wiz 7356: with the name prefix and a different version
7357: string. “<span class="quote">Xaw3d-1.5</span>” e.g. will automatically
7358: conflict with the older version “<span class="quote">Xaw3d-1.3</span>”.</p>
1.75 rillig 7359: </div>
7360: <div class="sect2" lang="en">
7361: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7362: <a name="not-building-packages"></a>17.1.8. Packages that cannot or should not be built</h3></div></div></div>
1.75 rillig 7363: <p>There are several reasons why a package might be
1.88 wiz 7364: instructed to not build under certain circumstances. If the
1.87 wiz 7365: package builds and runs on most platforms, the exceptions
7366: should be noted with <code class="varname">NOT_FOR_PLATFORM</code>. If
7367: the package builds and runs on a small handful of platforms,
7368: set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
7369: Both <code class="varname">ONLY_FOR_PLATFORM</code> and
7370: <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
7371: (OS-version-platform) that can use glob-style
7372: wildcards.</p>
1.88 wiz 7373: <p>Some packages are tightly bound to a specific version of an
7374: 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
7375: backwards compatible with other versions of the OS, and should be
7376: uploaded to a version specific directory on the FTP server. Mark
7377: these packages by setting <code class="varname">OSVERSION_SPECIFIC</code> to
7378: “<span class="quote">yes</span>”. This variable is not currently used by any of
7379: the package system internals, but may be used in the
7380: future.</p>
1.75 rillig 7381: <p>If the package should be skipped (for example, because it
1.87 wiz 7382: provides functionality already provided by the system), set
1.88 wiz 7383: <code class="varname">PKG_SKIP_REASON</code> to a descriptive message. If
7384: the package should fail because some preconditions are not met,
7385: set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
1.87 wiz 7386: message.</p>
1.75 rillig 7387: </div>
7388: <div class="sect2" lang="en">
7389: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7390: <a name="undeletable-packages"></a>17.1.9. Packages which should not be deleted, once installed</h3></div></div></div>
1.75 rillig 7391: <p>To ensure that a package may not be deleted, once it has been
1.87 wiz 7392: installed, the <code class="varname">PKG_PRESERVE</code> definition should
7393: be set in the package Makefile. This will be carried into any
7394: binary package that is made from this pkgsrc entry. A
7395: “<span class="quote">preserved</span>” package will
7396: 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
7397: “<span class="quote">-f</span>” option is used.</p>
1.75 rillig 7398: </div>
7399: <div class="sect2" lang="en">
7400: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7401: <a name="security-handling"></a>17.1.10. Handling packages with security problems</h3></div></div></div>
1.75 rillig 7402: <p>When a vulnerability is found, this should be noted in
1.87 wiz 7403: <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
7404: and after committing that file, use <span><strong class="command">make upload</strong></span>
7405: in the same directory to update the file on ftp.NetBSD.org.</p>
1.75 rillig 7406: <p>After fixing the vulnerability by a patch, its
1.87 wiz 7407: <code class="varname">PKGREVISION</code> should be increased (this
7408: is of course not necessary if the problem is fixed by using
7409: a newer release of the software).</p>
1.75 rillig 7410: <p>Also, if the fix should be applied to the stable pkgsrc
1.87 wiz 7411: branch, be sure to submit a pullup request!</p>
1.75 rillig 7412: <p>Binary packages already on ftp.NetBSD.org will be handled
1.87 wiz 7413: semi-automatically by a weekly cron job.</p>
1.75 rillig 7414: </div>
7415: <div class="sect2" lang="en">
7416: <div class="titlepage"><div><div><h3 class="title">
1.78 rillig 7417: <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 7418: <p>When making fixes to an existing package it can be useful
1.87 wiz 7419: to change the version number in <code class="varname">PKGNAME</code>. To
7420: avoid conflicting with future versions by the original author, a
7421: “<span class="quote">nb1</span>”, “<span class="quote">nb2</span>”, ... suffix can be used
7422: on package versions by setting <code class="varname">PKGREVISION=1</code>
7423: (2, ...). The “<span class="quote">nb</span>” is treated like a
7424: “<span class="quote">.</span>” by the package tools. e.g.</p>
7425: <pre class="programlisting">
7426: DISTNAME= foo-17.42
7427: PKGREVISION= 9
7428: </pre>
1.75 rillig 7429: <p>will result in a <code class="varname">PKGNAME</code> of
1.87 wiz 7430: “<span class="quote">foo-17.42nb9</span>”. If you want to use the original
7431: value of <code class="varname">PKGNAME</code> without the “<span class="quote">nbX</span>”
7432: suffix, e.g. for setting <code class="varname">DIST_SUBDIR</code>, use
7433: <code class="varname">PKGNAME_NOREV</code>.</p>
1.75 rillig 7434: <p>When a new release of the package is released, the
1.87 wiz 7435: <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
7436: minor release of the above package, things should be like:</p>
1.75 rillig 7437: <pre class="programlisting">
1.87 wiz 7438: DISTNAME= foo-17.43
7439: </pre>
7440: <p><code class="varname">PKGREVISION</code> should be incremented for any
7441: non-trivial change in the resulting binary package. Without a
7442: <code class="varname">PKGREVISION</code> bump, someone with the previous
7443: version installed has no way of knowing that their package is out
7444: of date. Thus, changes without increasing
7445: <code class="varname">PKGREVISION</code> are essentially labeled "this is so
7446: trivial that no reasonable person would want to upgrade", and this
7447: is the rough test for when increasing
7448: <code class="varname">PKGREVISION</code> is appropriate. Examples of
7449: changes that do not merit increasing
7450: <code class="varname">PKGREVISION</code> are:</p>
7451: <pre class="programlisting">
7452: Changing <code class="varname">HOMEPAGE</code>, <code class="varname">MAINTAINER</code>,
7453: or comments in Makefile.
7454: Changing build variables if the resulting binary package is the same.
7455: Changing <code class="filename">DESCR</code>.
7456: Adding <code class="varname">PKG_OPTIONS</code> if the default options don't change.
7457: </pre>
7458: <p>Examples of changes that do merit an increase to
7459: <code class="varname">PKGREVISION</code> include:</p>
7460: <pre class="programlisting">
7461: Security fixes
7462: Changes or additions to a patch file
7463: Changes to the <code class="filename">PLIST</code>
7464: </pre>
1.78 rillig 7465: <p>PKGREVISION must also be incremented when dependencies have ABI
7466: changes.</p>
1.75 rillig 7467: </div>
1.79 rillig 7468: <div class="sect2" lang="en">
7469: <div class="titlepage"><div><div><h3 class="title">
7470: <a name="fixes.subst"></a>17.1.12. Substituting variable text in the package files (the SUBST framework)</h3></div></div></div>
7471: <p>When you want to replace the same text in multiple files
1.87 wiz 7472: or when the replacement text varies, patches alone cannot help.
7473: This is where the SUBST framework comes in. It provides an
7474: easy-to-use interface for replacing text in files.
7475: Example:</p>
7476: <pre class="programlisting">
7477: SUBST_CLASSES+= fix-paths
7478: SUBST_STAGE.fix-paths= pre-configure
7479: SUBST_MESSAGE.fix-paths= Fixing absolute paths.
7480: SUBST_FILES.fix-paths= src/*.c
7481: SUBST_FILES.fix-paths+= scripts/*.sh
7482: SUBST_SED.fix-paths= -e 's,"/usr/local,"${PREFIX},g'
7483: SUBST_SED.fix-paths+= -e 's,"/var/log,"${VARBASE}/log,g'
7484: </pre>
1.79 rillig 7485: <p><code class="varname">SUBST_CLASSES</code> is a list of identifiers
1.87 wiz 7486: that are used to identify the different SUBST blocks that are
7487: defined. The SUBST framework is heavily used by pkgsrc, so it is
7488: important to always use the <code class="literal">+=</code> operator with
7489: this variable. Otherwise some substitutions may be
7490: skipped.</p>
1.79 rillig 7491: <p>The remaining variables of each SUBST block are
1.87 wiz 7492: parameterized with the identifier from the first line
7493: (<code class="literal">fix-paths</code> in this case.) They can be seen as
7494: parameters to a function call.</p>
1.79 rillig 7495: <p><code class="varname">SUBST_STAGE.*</code> specifies the stage at
1.87 wiz 7496: which the replacement will take place. All combinations of
7497: <code class="literal">pre-</code>, <code class="literal">do-</code> and
7498: <code class="literal">post-</code> together with a phase name are
7499: possible, though only few are actually used. Most commonly used
7500: are <code class="literal">post-patch</code> and
7501: <code class="literal">pre-configure</code>. Of these two,
7502: <code class="literal">pre-configure</code> should be preferred because
7503: then it is possible to run <span><strong class="command">bmake patch</strong></span> and
7504: have the state after applying the patches but before making any
7505: other changes. This is especially useful when you are debugging
7506: a package in order to create new patches for it. Similarly,
7507: <code class="literal">post-build</code> is preferred over
7508: <code class="literal">pre-install</code>, because the install phase should
7509: generally be kept as simple as possible. When you use
7510: <code class="literal">post-build</code>, you have the same files in the
7511: working directory that will be installed later, so you can check
7512: if the substitution has succeeded.</p>
1.79 rillig 7513: <p><code class="varname">SUBST_MESSAGE.*</code> is an optional text
1.87 wiz 7514: that is printed just before the substitution is done.</p>
1.79 rillig 7515: <p><code class="varname">SUBST_FILES.*</code> is the list of shell
1.87 wiz 7516: globbing patterns that specifies the files in which the
7517: substitution will take place. The patterns are interpreted
7518: relatively to the <code class="varname">WRKSRC</code> directory.</p>
1.79 rillig 7519: <p><code class="varname">SUBST_SED.*</code> is a list of arguments to
1.87 wiz 7520: <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
7521: command should be prefixed with <code class="literal">-e</code>, so that
7522: all SUBST blocks look uniform.</p>
1.79 rillig 7523: <p>There are some more variables, but they are so seldomly
1.87 wiz 7524: used that they are only documented in the
7525: <code class="filename">mk/subst.mk</code> file.</p>
1.79 rillig 7526: </div>
1.75 rillig 7527: </div>
7528: <div class="sect1" lang="en">
7529: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7530: <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 7531: <div class="sect2" lang="en">
7532: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7533: <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 7534: <p>If you need to download from a dynamic URL you can set
1.87 wiz 7535: <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span><strong class="command">make
7536: fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
7537: with the name of each file to download as an argument, expecting
7538: it to output the URL of the directory from which to download
7539: 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
7540: example of this usage.</p>
1.75 rillig 7541: <p>If the download can't be automated, because the user must
1.87 wiz 7542: submit personal information to apply for a password, or must pay
7543: for the source, or whatever, you can set
7544: <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
7545: displayed to the user before aborting the build. Example:</p>
7546: <pre class="programlisting">
7547: FETCH_MESSAGE= "Please download the files"
7548: FETCH_MESSAGE+= " "${DISTFILES:Q}
7549: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
7550: </pre>
1.75 rillig 7551: </div>
7552: <div class="sect2" lang="en">
7553: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7554: <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 7555: <p>Sometimes authors of a software package make some
1.87 wiz 7556: modifications after the software was released, and they put up a
7557: new distfile without changing the package's version number. If a
7558: package is already in pkgsrc at that time, the checksum will
7559: no longer match. The contents of the new distfile should be
7560: compared against the old one before changing anything, to make
7561: sure the distfile was really updated on purpose, and that
7562: no trojan horse or so crept in.
7563: Then, the correct way to work around this is to
7564: set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
7565: usually based on <code class="varname">PKGNAME_NOREV</code>. All
7566: <code class="varname">DISTFILES</code> and
7567: <code class="varname">PATCHFILES</code> for this package will be put in that
7568: subdirectory of the local distfiles directory. In case this
7569: happens more often, <code class="varname">PKGNAME</code> can be used (thus
7570: including the <code class="filename">nbX</code> suffix) or a date stamp
7571: can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
7572: Do not forget regenerating the <code class="filename">distinfo</code> file
7573: after that, since it contains the <code class="varname">DIST_SUBDIR</code>
7574: path in the filenames.
7575: Furthermore, a mail to the package's authors seems appropriate
7576: telling them that changing distfiles after releases without
7577: changing the file names is not good practice.</p>
1.75 rillig 7578: </div>
7579: </div>
7580: <div class="sect1" lang="en">
7581: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 7582: <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 7583: <div class="sect2" lang="en">
7584: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7585: <a name="fixes.libtool"></a>17.3.1. Shared libraries - libtool</h3></div></div></div>
1.75 rillig 7586: <p>pkgsrc supports many different machines, with different
1.87 wiz 7587: object formats like a.out and ELF, and varying abilities to do
7588: shared library and dynamic loading at all. To accompany this,
7589: varying commands and options have to be passed to the
7590: compiler, linker, etc. to get the Right Thing, which can be
7591: pretty annoying especially if you don't have all the machines
7592: at your hand to test things. The
7593: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/libtool/README.html" target="_top"><code class="filename">devel/libtool</code></a> pkg
7594: can help here, as it just “<span class="quote">knows</span>” how to build
7595: both static and dynamic libraries from a set of source files,
7596: thus being platform-independent.</p>
7597: <p>Here's how to use libtool in a package in seven simple
7598: steps:</p>
1.75 rillig 7599: <div class="orderedlist"><ol type="1">
7600: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
1.87 wiz 7601: Makefile.</p></li>
1.75 rillig 7602: <li><p>For library objects, use “<span class="quote">${LIBTOOL} --mode=compile
1.87 wiz 7603: ${CC}</span>” in place of “<span class="quote">${CC}</span>”. You could even
7604: add it to the definition of <code class="varname">CC</code>, if only
7605: libraries are being built in a given Makefile. This one command
7606: will build both PIC and non-PIC library objects, so you need not
7607: have separate shared and non-shared library rules.</p></li>
1.75 rillig 7608: <li>
7609: <p>For the linking of the library, remove any
1.87 wiz 7610: “<span class="quote">ar</span>”, “<span class="quote">ranlib</span>”, and “<span class="quote">ld
7611: -Bshareable</span>” commands, and instead use:</p>
1.75 rillig 7612: <pre class="programlisting">
1.87 wiz 7613: ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
7614: -rpath ${PREFIX}/lib -version-info major:minor
7615: </pre>
1.75 rillig 7616: <p>Note that the library is changed to have a
1.87 wiz 7617: <code class="filename">.la</code> extension, and the objects are
7618: changed to have a <code class="filename">.lo</code>
7619: extension. Change <code class="varname">OBJS</code> as
7620: necessary. This automatically creates all of the
7621: <code class="filename">.a</code>,
7622: <code class="filename">.so.major.minor</code>, and ELF symlinks (if
7623: necessary) in the build directory. Be sure to include
7624: “<span class="quote">-version-info</span>”, especially when major and
7625: minor are zero, as libtool will otherwise strip off the
7626: shared library version.</p>
1.75 rillig 7627: <p>From the libtool manual:</p>
7628: <pre class="programlisting">
1.87 wiz 7629: So, libtool library versions are described by three integers:
1.69 rillig 7630:
1.87 wiz 7631: CURRENT
7632: The most recent interface number that this library implements.
1.69 rillig 7633:
1.87 wiz 7634: REVISION
7635: The implementation number of the CURRENT interface.
1.69 rillig 7636:
1.87 wiz 7637: AGE
7638: The difference between the newest and oldest interfaces that
7639: this library implements. In other words, the library implements
7640: all the interface numbers in the range from number `CURRENT -
7641: AGE' to `CURRENT'.
1.1 grant 7642:
1.87 wiz 7643: If two libraries have identical CURRENT and AGE numbers, then the
7644: dynamic linker chooses the library with the greater REVISION number.
7645: </pre>
1.75 rillig 7646: <p>The “<span class="quote">-release</span>” option will produce
1.87 wiz 7647: different results for a.out and ELF (excluding symlinks)
7648: in only one case. An ELF library of the form
7649: “<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
7650: will have a symlink of
7651: “<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
7652: on an a.out platform. This is handled
7653: automatically.</p>
1.75 rillig 7654: <p>The “<span class="quote">-rpath argument</span>” is the install
1.87 wiz 7655: directory of the library being built.</p>
1.76 rillig 7656: <p>In the <code class="filename">PLIST</code>, include only the
1.87 wiz 7657: <code class="filename">.la</code> file, the other files will be
7658: added automatically.</p>
1.75 rillig 7659: </li>
7660: <li>
1.76 rillig 7661: <p>When linking shared object (<code class="filename">.so</code>)
1.87 wiz 7662: 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
7663: shared libraries, use “<span class="quote">-module
7664: -avoid-version</span>” to prevent them getting version
7665: tacked on.</p>
1.76 rillig 7666: <p>The <code class="filename">PLIST</code> file gets the
1.87 wiz 7667: <code class="filename">foo.so</code> entry.</p>
1.75 rillig 7668: </li>
7669: <li>
7670: <p>When linking programs that depend on these libraries
1.87 wiz 7671: <span class="emphasis"><em>before</em></span> they are installed, preface
7672: 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}
7673: --mode=link</span>”, and it will find the correct
7674: libraries (static or shared), but please be aware that
7675: libtool will not allow you to specify a relative path in
7676: -L (such as “<span class="quote">-L../somelib</span>”), because it
7677: expects you to change that argument to be the
7678: <code class="filename">.la</code> file. e.g.</p>
1.75 rillig 7679: <pre class="programlisting">
1.87 wiz 7680: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
7681: </pre>
1.75 rillig 7682: <p>should be changed to:</p>
7683: <pre class="programlisting">
1.87 wiz 7684: ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
7685: </pre>
1.75 rillig 7686: <p>and it will do the right thing with the libraries.</p>
7687: </li>
7688: <li>
7689: <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 7690: 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}
7691: --mode=install</span>”, and change the library name to
7692: <code class="filename">.la</code>. e.g.</p>
1.75 rillig 7693: <pre class="programlisting">
1.87 wiz 7694: ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
7695: </pre>
1.76 rillig 7696: <p>This will install the static <code class="filename">.a</code>,
1.87 wiz 7697: shared library, any needed symlinks, and run
7698: <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 7699: </li>
1.76 rillig 7700: <li><p>In your <code class="filename">PLIST</code>, include only
1.87 wiz 7701: the <code class="filename">.la</code>
7702: file (this is a change from previous behaviour).</p></li>
1.75 rillig 7703: </ol></div>
7704: </div>
7705: <div class="sect2" lang="en">
7706: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7707: <a name="using-libtool"></a>17.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
1.75 rillig 7708: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
1.87 wiz 7709: package Makefile. This will override the package's own libtool
7710: in most cases. For older libtool using packages, libtool is
7711: made by ltconfig script during the do-configure step; you can
7712: check the libtool script location by doing <span><strong class="command">make
7713: configure; find work*/ -name libtool</strong></span>.</p>
1.75 rillig 7714: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
1.87 wiz 7715: scripts, relative to <code class="varname">WRKSRC</code>, to override. By
7716: default, it is set to “<span class="quote">libtool */libtool
7717: */*/libtool</span>”. If this does not match the location of the
7718: package's libtool script(s), set it as appropriate.</p>
1.76 rillig 7719: <p>If you do not need <code class="filename">*.a</code> static
1.87 wiz 7720: libraries built and installed, then use
7721: <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
1.75 rillig 7722: <p>If your package makes use of the platform-independent library
1.87 wiz 7723: for loading dynamic shared objects, that comes with libtool
7724: (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
7725: <p>Some packages use libtool incorrectly so that the package
7726: may not work or build in some circumstances. Some of the more
7727: common errors are:</p>
1.75 rillig 7728: <div class="itemizedlist"><ul type="disc">
7729: <li>
7730: <p>The inclusion of a shared object (-module) as a dependent library in an
1.87 wiz 7731: executable or library. This in itself isn't a problem if one of two things
7732: has been done:</p>
1.75 rillig 7733: <div class="orderedlist"><ol type="1">
7734: <li><p>The shared object is named correctly, i.e.
1.87 wiz 7735: <code class="filename">libfoo.la</code>, not
7736: <code class="filename">foo.la</code></p></li>
1.75 rillig 7737: <li><p>The -dlopen option is used when linking an executable.</p></li>
7738: </ol></div>
7739: </li>
7740: <li><p>The use of libltdl without the correct calls to initialisation routines.
1.87 wiz 7741: The function lt_dlinit() should be called and the macro
7742: <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
7743: executables.</p></li>
1.75 rillig 7744: </ul></div>
7745: </div>
7746: <div class="sect2" lang="en">
7747: <div class="titlepage"><div><div><h3 class="title">
1.77 rillig 7748: <a name="autoconf-automake"></a>17.3.3. GNU Autoconf/Automake</h3></div></div></div>
1.75 rillig 7749: <p>If a package needs GNU autoconf or automake to be executed
1.87 wiz 7750: to regenerate the configure script and Makefile.in makefile
7751: templates, then they should be executed in a pre-configure
7752: target.</p>
1.75 rillig 7753: <p>For packages that need only autoconf:</p>
7754: <pre class="programlisting">
1.87 wiz 7755: AUTOCONF_REQD= 2.50 # if default version is not good enough
7756: USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
7757: ...
1.1 grant 7758:
1.87 wiz 7759: pre-configure:
7760: cd ${WRKSRC}; autoconf
1.1 grant 7761:
1.87 wiz 7762: ...
7763: </pre>
1.75 rillig 7764: <p>and for packages that need automake and autoconf:</p>
7765: <pre class="programlisting">
1.87 wiz 7766: AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
7767: USE_TOOLS+= automake # use "automake14" for automake-1.4
7768: ...
7769:
7770: pre-configure:
7771: cd ${WRKSRC}; \
7772: aclocal; autoheader; \
7773: automake -a --foreign -i; autoconf
1.1 grant 7774:
1.87 wiz 7775: ...
7776: </pre>
1.75 rillig 7777: <p>Packages which use GNU Automake will almost certainly
1.87 wiz 7778: require GNU Make.</p>
1.75 rillig 7779: <p>There are times when the configure process makes
1.87 wiz 7780: additional changes to the generated files, which then causes
7781: the build process to try to re-execute the automake sequence.
7782: This is prevented by touching various files in the configure
7783: stage. If this causes problems with your package you can set
7784: <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
7785: Makefile.</p>
1.75 rillig 7786: </div>
7787: </div>
7788: <div class="sect1" lang="en">
7789: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.87 wiz 7790: <a name="programming-languages"></a>17.4. Programming languages</h2></div></div></div>
7791: <div class="sect2" lang="en">
7792: <div class="titlepage"><div><div><h3 class="title">
7793: <a name="basic-programming-languages"></a>17.4.1. C, C++, and Fortran</h3></div></div></div>
7794: <p>Compilers for the C, C++, and Fortran languages comes with
7795: the NetBSD base system. By default, pkgsrc assumes that a package
7796: is written in C and will hide all other compilers (via the wrapper
7797: framework, see <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a>).</p>
7798: <p>To declare which language's compiler a package needs, set
7799: the <code class="varname">USE_LANGUAGES</code> variable. Allowed values
7800: currently are “<span class="quote">c</span>”, “<span class="quote">c++</span>”, and
7801: “<span class="quote">fortran</span>” (and any combination). The default is
7802: “<span class="quote">c</span>”. Packages using GNU configure scripts, even if
7803: written in C++, usually need a C compiler for the configure
7804: phase.</p>
7805: </div>
7806: <div class="sect2" lang="en">
7807: <div class="titlepage"><div><div><h3 class="title">
7808: <a name="java-programming-language"></a>17.4.2. Java</h3></div></div></div>
7809: <p>If a program is written in Java, use the Java framework in
7810: pkgsrc. The package must include
7811: <code class="filename">../../mk/java-vm.mk</code>. This Makefile fragment
7812: provides the following variables:</p>
7813: <div class="itemizedlist"><ul type="disc">
7814: <li><p><code class="varname">USE_JAVA</code> defines if a build
7815: dependency on the JDK is added. If
7816: <code class="varname">USE_JAVA</code> is set to “<span class="quote">run</span>”, then
7817: there is only a runtime dependency on the JDK. The default is
7818: “<span class="quote">yes</span>”, which also adds a build dependency on the
7819: JDK.</p></li>
7820: <li><p>Set <code class="varname">USE_JAVA2</code> to declare that
7821: a package needs a Java2 implementation. The supported values
7822: are “<span class="quote">yes</span>”, “<span class="quote">1.4</span>”, and
7823: “<span class="quote">1.5</span>”. “<span class="quote">yes</span>” accepts any Java2
7824: implementation, “<span class="quote">1.4</span>” insists on versions 1.4 or
7825: above, and “<span class="quote">1.5</span>” only accepts versions 1.5 or
7826: above. This variable is not set by default.</p></li>
7827: </ul></div>
7828: </div>
7829: <div class="sect2" lang="en">
7830: <div class="titlepage"><div><div><h3 class="title">
7831: <a name="perl-scripts"></a>17.4.3. Packages containing perl scripts</h3></div></div></div>
7832: <p>If your package contains interpreted perl scripts, add
7833: “<span class="quote">perl</span>” to the <code class="varname">USE_TOOLS</code> variable
7834: and set <code class="varname">REPLACE_PERL</code> to ensure that the proper
7835: interpreter path is set. <code class="varname">REPLACE_PERL</code> should
7836: contain a list of scripts, relative to <code class="varname">WRKSRC</code>,
7837: that you want adjusted. Every occurrence of
7838: <code class="filename">*/bin/perl</code> will be replaced with the full
7839: path to the perl executable.</p>
7840: <p>If a particular version of perl is needed, set the
7841: <code class="varname">PERL5_REQD</code> variable to the version number. The
7842: default is “<span class="quote">5.0</span>”.</p>
7843: <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
7844: about handling perl modules.</p>
7845: </div>
7846: <div class="sect2" lang="en">
7847: <div class="titlepage"><div><div><h3 class="title">
7848: <a name="other-programming-languages"></a>17.4.4. Other programming languages</h3></div></div></div>
7849: <p>Currently, there is no special handling for other languages
7850: in pkgsrc. If a compiler package provides a
7851: <code class="filename">buildlink3.mk</code> file, include that, otherwise
7852: just add a (build) dependency on the appropriate compiler
7853: package.</p>
7854: </div>
7855: </div>
7856: <div class="sect1" lang="en">
7857: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7858: <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 7859: <p>The most common failures when building a package are that
7860: some platforms do not provide certain header files, functions or
7861: libraries, or they provide the functions in a library that the
7862: original package author didn't know. To work around this, you
7863: can rewrite the source code in most cases so that it does not
7864: use the missing functions or provides a replacement function.</p>
7865: <div class="sect2" lang="en">
7866: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 7867: <a name="fixes.build.cpp"></a>17.5.1. Compiling C and C++ code conditionally</h3></div></div></div>
1.77 rillig 7868: <p>If a package already comes with a GNU configure script, the
7869: preferred way to fix the build failure is to change the
7870: configure script, not the code. In the other cases, you can
7871: utilize the C preprocessor, which defines certain macros
7872: depending on the operating system and hardware architecture it
7873: compiles for. These macros can be queried using for example
7874: <code class="varname">#if defined(__i386)</code>. Almost every operating
7875: system, hardware architecture and compiler has its own macro.
7876: For example, if the macros <code class="varname">__GNUC__</code>,
7877: <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
7878: are all defined, you know that you are using NetBSD on an i386
7879: compatible CPU, and your compiler is GCC.</p>
7880: <p>The list of the following macros for hardware and
7881: operating system depends on the compiler that is used. For
7882: example, if you want to conditionally compile code on Solaris,
7883: don't use <code class="varname">__sun__</code>, as the SunPro compiler
7884: does not define it. Use <code class="varname">__sun</code> instead.</p>
1.75 rillig 7885: <div class="sect3" lang="en">
7886: <div class="titlepage"><div><div><h4 class="title">
1.87 wiz 7887: <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 7888: <p>To distinguish between 4.4 BSD-derived systems and the
7889: rest of the world, you should use the following code.</p>
7890: <pre class="programlisting">
7891: #include <sys/param.h>
7892: #if (defined(BSD) && BSD >= 199306)
7893: /* BSD-specific code goes here */
7894: #else
7895: /* non-BSD-specific code goes here */
7896: #endif
7897: </pre>
1.77 rillig 7898: <p>If this distinction is not fine enough, you can also test
7899: for the following macros.</p>
1.75 rillig 7900: <pre class="programlisting">
7901: FreeBSD __FreeBSD__
7902: DragonFly __DragonFly__
7903: Interix __INTERIX
7904: Linux linux, __linux, __linux__
7905: NetBSD __NetBSD__
7906: OpenBSD __OpenBSD__
7907: Solaris sun, __sun
7908: </pre>
7909: </div>
7910: <div class="sect3" lang="en">
7911: <div class="titlepage"><div><div><h4 class="title">
1.87 wiz 7912: <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 7913: <pre class="programlisting">
7914: i386 i386, __i386, __i386__
7915: MIPS __mips
7916: SPARC sparc, __sparc
7917: </pre>
7918: </div>
7919: <div class="sect3" lang="en">
7920: <div class="titlepage"><div><div><h4 class="title">
1.87 wiz 7921: <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 7922: <pre class="programlisting">
7923: GCC __GNUC__ (major version), __GNUC_MINOR__
7924: SunPro __SUNPRO_C (0x570 for version 5.7)
1.81 rillig 7925: SunPro C++ __SUNPRO_CC (0x580 for version 5.8)
1.75 rillig 7926: </pre>
7927: </div>
7928: </div>
1.78 rillig 7929: <div class="sect2" lang="en">
7930: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 7931: <a name="compiler-bugs"></a>17.5.2. How to handle compiler bugs</h3></div></div></div>
1.78 rillig 7932: <p>Some source files trigger bugs in the compiler, based on
1.87 wiz 7933: combinations of compiler version and architecture and almost
7934: always relation to optimisation being enabled. Common symptoms
7935: are gcc internal errors or never finishing compiling a
1.78 rillig 7936: file.</p>
7937: <p>Typically, a workaround involves testing the
7938: <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
7939: optimisation for that combination of file,
7940: <code class="varname">MACHINE_ARCH</code> and compiler, and documenting it
1.87 wiz 7941: in <code class="filename">pkgsrc/doc/HACKS</code>. See that file for a
1.78 rillig 7942: number of examples.</p>
7943: </div>
7944: <div class="sect2" lang="en">
7945: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 7946: <a name="undefined-reference"></a>17.5.3. Undefined reference to “<span class="quote">...</span>”</h3></div></div></div>
1.78 rillig 7947: <p>This compiler error often means that a package did not
7948: link to a shared library it needs. The following functions are
7949: known to cause this error message over and over.</p>
7950: <div class="informaltable">
7951: <a name="undefined-reference-functions"></a><table border="1">
7952: <colgroup>
7953: <col>
7954: <col>
7955: <col>
7956: </colgroup>
7957: <thead><tr>
7958: <th>Function</th>
7959: <th>Library</th>
7960: <th>Affected platforms</th>
7961: </tr></thead>
7962: <tbody>
7963: <tr>
7964: <td>accept, bind, connect</td>
7965: <td>-lsocket</td>
7966: <td>Solaris</td>
7967: </tr>
7968: <tr>
7969: <td>crypt</td>
7970: <td>-lcrypt</td>
7971: <td>DragonFly, NetBSD</td>
7972: </tr>
7973: <tr>
7974: <td>dlopen, dlsym</td>
7975: <td>-ldl</td>
7976: <td>Linux</td>
7977: </tr>
7978: <tr>
7979: <td>gethost*</td>
7980: <td>-lnsl</td>
7981: <td>Solaris</td>
7982: </tr>
7983: <tr>
7984: <td>inet_aton</td>
7985: <td>-lresolv</td>
7986: <td>Solaris</td>
7987: </tr>
7988: <tr>
7989: <td>nanosleep, sem_*, timer_*</td>
7990: <td>-lrt</td>
7991: <td>Solaris</td>
7992: </tr>
7993: <tr>
7994: <td>openpty</td>
7995: <td>-lutil</td>
7996: <td>Linux</td>
7997: </tr>
7998: </tbody>
7999: </table>
8000: </div>
8001: <p>To fix these linker errors, it is often sufficient to say
1.87 wiz 8002: <code class="literal">LIBS.<em class="replaceable"><code>OperatingSystem</code></em>+=
8003: -l<em class="replaceable"><code>foo</code></em></code> to the package
8004: <code class="filename">Makefile</code> and then say <span><strong class="command">bmake clean;
8005: bmake</strong></span>.</p>
8006: </div>
8007: <div class="sect2" lang="en">
8008: <div class="titlepage"><div><div><h3 class="title">
8009: <a name="out-of-memory"></a>17.5.4. Running out of memory</h3></div></div></div>
8010: <p>Sometimes packages fail to build because the compiler runs
8011: into an operating system specific soft limit. With the
8012: <code class="varname">UNLIMIT_RESOURCES</code> variable pkgsrc can be told
8013: to unlimit the resources. Currently, the allowed values are
8014: “<span class="quote">datasize</span>” and “<span class="quote">stacksize</span>” (or both).
8015: Setting this variable is similar to running the shell builtin
8016: <span><strong class="command">ulimit</strong></span> command to raise the maximum data
8017: segment size or maximum stack size of a process, respectively, to
8018: their hard limits.</p>
1.78 rillig 8019: </div>
1.75 rillig 8020: </div>
8021: <div class="sect1" lang="en">
8022: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.87 wiz 8023: <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 8024: <div class="sect2" lang="en">
8025: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8026: <a name="install-scripts"></a>17.6.1. Creating needed directories</h3></div></div></div>
1.78 rillig 8027: <p>The BSD-compatible <span><strong class="command">install</strong></span> supplied
1.87 wiz 8028: with some operating systems cannot create more than one
8029: directory at a time. As such, you should call
8030: <code class="literal">${INSTALL_*_DIR}</code> like this:</p>
8031: <pre class="programlisting">
8032: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
8033: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
8034: </pre>
1.78 rillig 8035: <p>You can also just append “<span class="quote"><code class="literal">dir1
1.87 wiz 8036: dir2</code></span>” to the
8037: <code class="varname">INSTALLATION_DIRS</code> variable, which will
8038: automatically do the right thing.</p>
1.75 rillig 8039: </div>
8040: <div class="sect2" lang="en">
8041: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8042: <a name="where-to-install-documentation"></a>17.6.2. Where to install documentation</h3></div></div></div>
1.83 wiz 8043: <p>In general, documentation should be installed into
1.87 wiz 8044: <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
8045: <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the latter
8046: includes the version number of the package).</p>
1.84 wiz 8047: <p>Many modern packages using GNU autoconf allow to set the
1.87 wiz 8048: directory where HTML documentation is installed with the
8049: “<span class="quote">--with-html-dir</span>” option. Sometimes using this flag
8050: is needed because otherwise the documentation ends up in
8051: <code class="filename">${PREFIX}/share/doc/html</code> or other
8052: places.</p>
8053: <p>An exception to the above is that library API documentation
8054: 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
8055: browsers (devhelp) should be left at their default location, which
8056: is <code class="filename">${PREFIX}/share/gtk-doc</code>. Such
8057: documentation can be recognized from files ending in
8058: <code class="filename">.devhelp</code> or <code class="filename">.devhelp2</code>.
8059: (It is also acceptable to install such files in
8060: <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
8061: <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code>; the
8062: <code class="filename">.devhelp*</code> file must be directly in that
8063: directory then, no additional subdirectory level is allowed in
8064: this case. This is usually achieved by using
8065: “<span class="quote">--with-html-dir=${PREFIX}/share/doc</span>”.
8066: <code class="filename">${PREFIX}/share/gtk-doc</code> is preferred
8067: though.)</p>
1.75 rillig 8068: </div>
8069: <div class="sect2" lang="en">
8070: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8071: <a name="installing-score-files"></a>17.6.3. Installing score files</h3></div></div></div>
1.75 rillig 8072: <p>Certain packages, most of them in the games category, install
1.87 wiz 8073: a score file that allows all users on the system to record their
8074: highscores. In order for this to work, the binaries need to be
8075: installed setgid and the score files owned by the appropriate
8076: group and/or owner (traditionally the "games" user/group). The
8077: following variables, documented in more detail in
8078: <code class="filename">mk/defaults/mk.conf</code>, control this
8079: behaviour: <code class="varname">SETGIDGAME</code>,
8080: <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
8081: <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
1.75 rillig 8082: <p>Note that per default, setgid installation of games is
1.87 wiz 8083: disabled; setting <code class="varname">SETGIDGAME=YES</code> will set all
8084: the other variables accordingly.</p>
1.75 rillig 8085: <p>A package should therefor never hard code file ownership or
1.87 wiz 8086: access permissions but rely on <code class="varname">INSTALL_GAME</code> and
8087: <code class="varname">INSTALL_GAME_DATA</code> to set these
8088: correctly.</p>
1.75 rillig 8089: </div>
8090: <div class="sect2" lang="en">
8091: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8092: <a name="hardcoded-paths"></a>17.6.4. Packages with hardcoded paths to other interpreters</h3></div></div></div>
8093: <p>Your package may also contain scripts with hardcoded paths to
8094: other interpreters besides (or as well as) perl. To correct the
8095: full pathname to the script interpreter, you need to set the
8096: following definitions in your <code class="filename">Makefile</code> (we
8097: shall use <span><strong class="command">tclsh</strong></span> in this example):</p>
8098: <pre class="programlisting">
8099: REPLACE_INTERPRETER+= tcl
8100: REPLACE.tcl.old= .*/bin/tclsh
8101: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
8102: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
8103: # relative to ${WRKSRC}, just as in REPLACE_PERL
8104: </pre>
1.75 rillig 8105: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
8106: <h3 class="title">Note</h3>
8107: <p>Before March 2006, these variables were called
1.87 wiz 8108: <code class="varname">_REPLACE.*</code> and
8109: <code class="varname">_REPLACE_FILES.*</code>.</p>
1.75 rillig 8110: </div>
8111: </div>
8112: <div class="sect2" lang="en">
8113: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8114: <a name="perl-modules"></a>17.6.5. Packages installing perl modules</h3></div></div></div>
1.75 rillig 8115: <p>Makefiles of packages providing perl5 modules should include
1.87 wiz 8116: the Makefile fragment
8117: <code class="filename">../../lang/perl5/module.mk</code>. It provides a
8118: <span><strong class="command">do-configure</strong></span> target for the standard perl
8119: configuration for such modules as well as various hooks to tune
8120: this configuration. See comments in this file for
8121: details.</p>
1.75 rillig 8122: <p>Perl5 modules will install into different places depending
1.87 wiz 8123: on the version of perl used during the build process. To
8124: address this, pkgsrc will append lines to the
8125: <code class="filename">PLIST</code> corresponding to the files listed in
8126: the installed <code class="filename">.packlist</code> file generated by
8127: most perl5 modules. This is invoked by defining
8128: <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
8129: paths to packlist files, e.g.:</p>
1.75 rillig 8130: <pre class="programlisting">
1.87 wiz 8131: PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
8132: </pre>
1.75 rillig 8133: <p>The variables <code class="varname">PERL5_SITELIB</code>,
1.87 wiz 8134: <code class="varname">PERL5_SITEARCH</code>, and
8135: <code class="varname">PERL5_ARCHLIB</code> represent the three locations
8136: in which perl5 modules may be installed, and may be used by
8137: perl5 packages that don't have a packlist. These three
8138: variables are also substituted for in the
8139: <code class="filename">PLIST</code>.</p>
1.75 rillig 8140: </div>
8141: <div class="sect2" lang="en">
8142: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8143: <a name="faq.info-files"></a>17.6.6. Packages installing info files</h3></div></div></div>
1.75 rillig 8144: <p>Some packages install info files or use the
1.87 wiz 8145: “<span class="quote">makeinfo</span>” or “<span class="quote">install-info</span>”
8146: commands. <code class="varname">INFO_FILES</code> should be defined in
8147: the package Makefile so that <code class="filename">INSTALL</code> and
8148: <code class="filename">DEINSTALL</code> scripts will be generated to
8149: handle registration of the info files in the Info directory
8150: file. The “<span class="quote">install-info</span>” command used for the info
8151: files registration is either provided by the system, or by a
8152: special purpose package automatically added as dependency if
8153: needed.</p>
1.75 rillig 8154: <p><code class="varname">PKGINFODIR</code> is the directory under
1.87 wiz 8155: <code class="filename">${PREFIX}</code> where info files are primarily
8156: located. <code class="varname">PKGINFODIR</code> defaults to
8157: “<span class="quote">info</span>” and can be overridden by the user.</p>
1.75 rillig 8158: <p>The info files for the package should be listed in the
1.87 wiz 8159: package <code class="filename">PLIST</code>; however any split info files
8160: need not be listed.</p>
1.75 rillig 8161: <p>A package which needs the “<span class="quote">makeinfo</span>” command
1.87 wiz 8162: at build time must add “<span class="quote">makeinfo</span>” to
8163: <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
8164: version of the “<span class="quote">makeinfo</span>” command is needed it
8165: should be noted with the <code class="varname">TEXINFO_REQD</code>
8166: variable in the package <code class="filename">Makefile</code>. By
8167: default, a minimum version of 3.12 is required. If the system
8168: does not provide a <span><strong class="command">makeinfo</strong></span> command or if it
8169: does not match the required minimum, a build dependency on the
8170: <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
8171: be added automatically.</p>
1.75 rillig 8172: <p>The build and installation process of the software provided
1.87 wiz 8173: by the package should not use the
8174: <span><strong class="command">install-info</strong></span> command as the registration of
8175: info files is the task of the package
8176: <code class="filename">INSTALL</code> script, and it must use the
8177: appropriate <span><strong class="command">makeinfo</strong></span> command.</p>
1.75 rillig 8178: <p>To achieve this goal, the pkgsrc infrastructure creates
1.87 wiz 8179: overriding scripts for the <span><strong class="command">install-info</strong></span> and
8180: <span><strong class="command">makeinfo</strong></span> commands in a directory listed early
8181: in <code class="varname">PATH</code>.</p>
1.75 rillig 8182: <p>The script overriding <span><strong class="command">install-info</strong></span> has
1.87 wiz 8183: no effect except the logging of a message. The script overriding
8184: <span><strong class="command">makeinfo</strong></span> logs a message and according to the
8185: value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
8186: <span><strong class="command">makeinfo</strong></span> command or exit on error.</p>
1.75 rillig 8187: </div>
8188: <div class="sect2" lang="en">
8189: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8190: <a name="manpages"></a>17.6.7. Packages installing man pages</h3></div></div></div>
1.81 rillig 8191: <p>All packages that install manual pages should install them
1.87 wiz 8192: into the same directory, so that there is one common place to look
8193: for them. In pkgsrc, this place is
8194: <code class="literal">${PREFIX}/${PKGMANDIR}</code>, and this expression
8195: should be used in packages. The default for
8196: <code class="varname">PKGMANDIR</code> is
8197: “<span class="quote"><code class="filename">man</code></span>”. Another often-used value
8198: is “<span class="quote"><code class="filename">share/man</code></span>”.</p>
1.75 rillig 8199: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
8200: <h3 class="title">Note</h3>
1.87 wiz 8201: <p>The support for a custom <code class="varname">PKGMANDIR</code>
8202: is far from complete.</p>
1.75 rillig 8203: </div>
1.81 rillig 8204: <p>The <code class="filename">PLIST</code> files can just use
1.87 wiz 8205: <code class="filename">man/</code> as the top level directory for the man
8206: page file entries, and the pkgsrc framework will convert as
8207: needed. In all other places, the correct
8208: <code class="varname">PKGMANDIR</code> must be used.</p>
8209: <p>Packages that are
8210: configured with <code class="varname">GNU_CONFIGURE</code> set as
8211: “<span class="quote">yes</span>”, by default will use the
8212: <code class="filename">./configure</code>
8213: --mandir switch to set where the man pages should be installed.
8214: The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
8215: to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.</p>
8216: <p>Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
8217: use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
8218: to “<span class="quote">no</span>”.
8219: Or if the <code class="filename">./configure</code> script uses
8220: a non-standard use of --mandir, you can set
8221: <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.</p>
1.77 rillig 8222: <p>See <a href="#manpage-compression" title="11.5. Man page compression">Section 11.5, “Man page compression”</a> for
1.87 wiz 8223: information on installation of compressed manual pages.</p>
1.75 rillig 8224: </div>
8225: <div class="sect2" lang="en">
8226: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8227: <a name="gconf2-data-files"></a>17.6.8. Packages installing GConf2 data files</h3></div></div></div>
8228: <p>If a package installs <code class="filename">.schemas</code> or
8229: <code class="filename">.entries</code> files, used by GConf2,
8230: you need to take some extra steps to make sure they get registered
8231: in the database:</p>
1.75 rillig 8232: <div class="orderedlist"><ol type="1">
1.76 rillig 8233: <li><p>Include <code class="filename">../../devel/GConf2/schemas.mk</code>
1.87 wiz 8234: instead of its <code class="filename">buildlink3.mk</code> file. This
8235: takes care of rebuilding the GConf2 database at installation and
8236: deinstallation time, and tells the package where to install
8237: GConf2 data files using some standard configure arguments. It
8238: also disallows any access to the database directly from the
8239: package.</p></li>
1.75 rillig 8240: <li><p>Ensure that the package installs its
1.87 wiz 8241: <code class="filename">.schemas</code> files under
8242: <code class="filename">${PREFIX}/share/gconf/schemas</code>. If they get
8243: installed under <code class="filename">${PREFIX}/etc</code>, you will
8244: need to manually patch the package.</p></li>
1.75 rillig 8245: <li><p>Check the PLIST and remove any entries under the etc/gconf
1.87 wiz 8246: directory, as they will be handled automatically. See
8247: <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 8248: <li><p>Define the <code class="varname">GCONF2_SCHEMAS</code> variable in
1.87 wiz 8249: your <code class="filename">Makefile</code> with a list of all
8250: <code class="filename">.schemas</code> files installed by the package, if
8251: any. Names must not contain any directories in them.</p></li>
1.75 rillig 8252: <li><p>Define the <code class="varname">GCONF2_ENTRIES</code> variable in
1.87 wiz 8253: your <code class="filename">Makefile</code> with a
8254: list of all <code class="filename">.entries</code> files installed by the
8255: package, if any. Names must not contain any directories in
8256: them.</p></li>
1.75 rillig 8257: </ol></div>
8258: </div>
8259: <div class="sect2" lang="en">
8260: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8261: <a name="scrollkeeper-data-files"></a>17.6.9. Packages installing scrollkeeper data files</h3></div></div></div>
8262: <p>If a package installs <code class="filename">.omf</code> files, used by
8263: scrollkeeper, you need to take some extra steps to make sure they
8264: get registered in the database:</p>
1.75 rillig 8265: <div class="orderedlist"><ol type="1">
8266: <li><p>Include
1.87 wiz 8267: <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
8268: instead of its <code class="filename">buildlink3.mk</code> file. This
8269: takes care of rebuilding the scrollkeeper database at
8270: installation and deinstallation time, and disallows any access
8271: to it directly from the package.</p></li>
1.75 rillig 8272: <li><p>Check the PLIST and remove any entries under the
1.87 wiz 8273: <code class="filename">libdata/scrollkeeper</code> directory, as they
8274: will be handled automatically.</p></li>
1.76 rillig 8275: <li><p>Remove the <code class="filename">share/omf</code> directory from
1.87 wiz 8276: the PLIST. It will be handled by scrollkeeper.</p></li>
1.75 rillig 8277: </ol></div>
8278: </div>
8279: <div class="sect2" lang="en">
8280: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8281: <a name="x11-fonts"></a>17.6.10. Packages installing X11 fonts</h3></div></div></div>
1.75 rillig 8282: <p>If a package installs font files, you will need to rebuild
1.87 wiz 8283: the fonts database in the directory where they get installed at
8284: installation and deinstallation time. This can be automatically
8285: done by using the pkginstall framework.</p>
1.75 rillig 8286: <p>You can list the directories where fonts are installed in the
1.87 wiz 8287: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
8288: variables, where <em class="replaceable"><code>type</code></em> can be one of
8289: “<span class="quote">ttf</span>”, “<span class="quote">type1</span>” or “<span class="quote">x11</span>”.
8290: Also make sure that the database file
8291: <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
1.75 rillig 8292: <p>Note that you should not create new directories for fonts;
1.87 wiz 8293: instead use the standard ones to avoid that the user needs to
8294: manually configure his X server to find them.</p>
1.75 rillig 8295: </div>
8296: <div class="sect2" lang="en">
8297: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8298: <a name="gtk2-modules"></a>17.6.11. Packages installing GTK2 modules</h3></div></div></div>
1.75 rillig 8299: <p>If a package installs GTK2 immodules or loaders, you need to
1.87 wiz 8300: take some extra steps to get them registered in the GTK2 database
8301: properly:</p>
1.75 rillig 8302: <div class="orderedlist"><ol type="1">
8303: <li><p>Include
1.87 wiz 8304: <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
8305: <code class="filename">buildlink3.mk</code> file. This takes care of
8306: rebuilding the database at installation and deinstallation time.</p></li>
8307: <li><p>Set <code class="varname">GTK2_IMMODULES=YES</code> if
8308: your package installs GTK2 immodules.</p></li>
8309: <li><p>Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
8310: GTK2 loaders.</p></li>
1.75 rillig 8311: <li>
1.87 wiz 8312: <p>Patch the package to not touch any of the GTK2
8313: databases directly. These are:</p>
1.75 rillig 8314: <div class="itemizedlist"><ul type="disc">
1.76 rillig 8315: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
8316: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
1.75 rillig 8317: </ul></div>
8318: </li>
1.87 wiz 8319: <li><p>Check the <code class="filename">PLIST</code> and remove
8320: any entries under the <code class="filename">libdata/gtk-2.0</code>
8321: directory, as they will be handled automatically.</p></li>
1.75 rillig 8322: </ol></div>
8323: </div>
8324: <div class="sect2" lang="en">
8325: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8326: <a name="sgml-xml-data"></a>17.6.12. Packages installing SGML or XML data</h3></div></div></div>
1.75 rillig 8327: <p>If a package installs SGML or XML data files that need to be
1.87 wiz 8328: registered in system-wide catalogs (like DTDs, sub-catalogs,
8329: etc.), you need to take some extra steps:</p>
1.75 rillig 8330: <div class="orderedlist"><ol type="1">
8331: <li><p>Include
1.87 wiz 8332: <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
8333: your <code class="filename">Makefile</code>, which takes care of
8334: registering those files in system-wide catalogs at
8335: installation and deinstallation time.</p></li>
1.75 rillig 8336: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
1.87 wiz 8337: any SGML catalogs installed by the package.</p></li>
1.75 rillig 8338: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
1.87 wiz 8339: any XML catalogs installed by the package.</p></li>
1.75 rillig 8340: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
1.87 wiz 8341: to be added to the SGML catalog. These come in groups of
8342: three strings; see xmlcatmgr(1) for more information
8343: (specifically, arguments recognized by the 'add' action).
8344: Note that you will normally not use this variable.</p></li>
1.75 rillig 8345: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
1.87 wiz 8346: to be added to the XML catalog. These come in groups of three
8347: strings; see xmlcatmgr(1) for more information (specifically,
8348: arguments recognized by the 'add' action). Note that you will
8349: normally not use this variable.</p></li>
1.75 rillig 8350: </ol></div>
8351: </div>
8352: <div class="sect2" lang="en">
8353: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8354: <a name="mime-database"></a>17.6.13. Packages installing extensions to the MIME database</h3></div></div></div>
1.75 rillig 8355: <p>If a package provides extensions to the MIME database by
1.87 wiz 8356: installing <code class="filename">.xml</code> files inside
8357: <code class="filename">${PREFIX}/share/mime/packages</code>, you
8358: need to take some extra steps to ensure that the database is kept
8359: consistent with respect to these new files:</p>
1.75 rillig 8360: <div class="orderedlist"><ol type="1">
8361: <li><p>Include
1.87 wiz 8362: <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
8363: (avoid using the <code class="filename">buildlink3.mk</code> file from
8364: this same directory, which is reserved for inclusion from
8365: other <code class="filename">buildlink3.mk</code> files). It takes
8366: care of rebuilding the MIME database at installation and
8367: deinstallation time, and disallows any access to it directly
8368: from the package.</p></li>
1.75 rillig 8369: <li><p>Check the PLIST and remove any entries under the
1.87 wiz 8370: <code class="filename">share/mime</code> directory,
8371: <span class="emphasis"><em>except</em></span> for files saved under
8372: <code class="filename">share/mime/packages</code>. The former are
8373: handled automatically by
8374: the update-mime-database program, but the latter are
8375: package-dependent and must be removed by the package that
8376: installed them in the first place.</p></li>
1.76 rillig 8377: <li><p>Remove any <code class="filename">share/mime/*</code> directories
1.87 wiz 8378: from the PLIST. They will be handled by the shared-mime-info
8379: package.</p></li>
1.75 rillig 8380: </ol></div>
8381: </div>
8382: <div class="sect2" lang="en">
8383: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8384: <a name="intltool"></a>17.6.14. Packages using intltool</h3></div></div></div>
1.75 rillig 8385: <p>If a package uses intltool during its build, include the
1.87 wiz 8386: <code class="filename">../../textproc/intltool/buildlink3.mk</code> file,
8387: which forces it to use the intltool package provided by pkgsrc,
8388: instead of the one bundled with the distribution file.</p>
1.75 rillig 8389: <p>This tracks intltool's build-time dependencies and uses the
1.87 wiz 8390: latest available version; this way, the package benefits of any
8391: bug fixes that may have appeared since it was released.</p>
1.75 rillig 8392: </div>
8393: <div class="sect2" lang="en">
8394: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8395: <a name="startup-scripts"></a>17.6.15. Packages installing startup scripts</h3></div></div></div>
1.75 rillig 8396: <p>If a package contains a rc.d script, it won't be copied into
1.87 wiz 8397: the startup directory by default, but you can enable it, by adding
8398: the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
8399: <code class="filename">/etc/mk.conf</code>. This option will copy the scripts
8400: into <code class="filename">/etc/rc.d</code> when a package is installed, and
8401: it will automatically remove the scripts when the package is
8402: deinstalled.</p>
1.75 rillig 8403: </div>
8404: <div class="sect2" lang="en">
8405: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8406: <a name="tex-packages"></a>17.6.16. Packages installing TeX modules</h3></div></div></div>
1.75 rillig 8407: <p>If a package installs TeX packages into the texmf tree,
1.87 wiz 8408: the <code class="filename">ls-R</code> database of the tree needs to be
8409: updated.</p>
1.75 rillig 8410: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
8411: <h3 class="title">Note</h3>
8412: <p>Except the main TeX packages such as teTeX-texmf,
1.87 wiz 8413: packages should install files
8414: into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
8415: not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
1.75 rillig 8416: </div>
8417: <div class="orderedlist"><ol type="1">
8418: <li><p>Include
1.87 wiz 8419: <code class="filename">../../print/teTeX/module.mk</code> instead
8420: of <code class="filename">../../mk/tex.buildlink3.mk</code>. This
8421: takes care of rebuilding the <code class="filename">ls-R</code>
8422: database at installation and deinstallation time.</p></li>
1.75 rillig 8423: <li>
8424: <p>If your package installs files into a texmf
1.87 wiz 8425: tree other than the one
8426: at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
8427: set <code class="varname">TEXMFDIRS</code> to the list of all texmf
8428: trees that need database update.</p>
1.75 rillig 8429: <p>If your package also installs font map files that need
1.87 wiz 8430: to be registered using <span><strong class="command">updmap</strong></span>,
8431: set <code class="varname">TEX_FONTMAPS</code> to the list of all
8432: such font map files. Then <span><strong class="command">updmap</strong></span> will
8433: be run automatically at installation/deinstallation to
8434: enable/disable font map files for TeX output
8435: drivers.</p>
1.75 rillig 8436: </li>
1.76 rillig 8437: <li><p>Make sure that none of <code class="filename">ls-R</code>
1.87 wiz 8438: databases are included in <code class="filename">PLIST</code>, as
8439: they will be removed only by the teTeX-bin package.</p></li>
1.75 rillig 8440: </ol></div>
8441: </div>
1.85 jmmv 8442: <div class="sect2" lang="en">
8443: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8444: <a name="emulation-packages"></a>17.6.17. Packages supporting running binaries in
8445: emulation</h3></div></div></div>
8446: <p>There are some packages that provide libraries and
8447: executables for running binaries from a one operating system
8448: on a different one (if the latter supports it). One example
8449: is running Linux binaries on NetBSD.</p>
8450: <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>
8451: helps in extracting and packaging Linux rpm packages.</p>
8452: <p>The <code class="varname">CHECK_SHLIBS</code> can be set to no to
8453: avoid the <span><strong class="command">check-shlibs</strong></span> target, which tests
8454: if all libraries for each installed executable can be found by
8455: the dynamic linker. Since the standard dynamic linker is run,
8456: this fails for emulation packages, because the libraries used
8457: by the emulation are not in the standard directories.</p>
8458: </div>
8459: <div class="sect2" lang="en">
8460: <div class="titlepage"><div><div><h3 class="title">
8461: <a name="hicolor-theme"></a>17.6.18. Packages installing hicolor theme icons</h3></div></div></div>
1.85 jmmv 8462: <p>If a package installs images under the
1.87 wiz 8463: <code class="filename">share/icons/hicolor</code> and/or updates the
8464: <code class="filename">share/icons/hicolor/icon-theme.cache</code>
8465: database, you need to take some extra steps to make sure that the
8466: shared theme directory is handled appropriately and that the cache
8467: database is rebuilt:</p>
1.85 jmmv 8468: <div class="orderedlist"><ol type="1">
8469: <li><p>Include
1.87 wiz 8470: <code class="filename">../../graphics/hicolor-icon-theme/buildlink3.mk</code>.</p></li>
8471: <li><p>Check the <code class="filename">PLIST</code> and remove the
8472: entry that refers to the theme cache.</p></li>
1.85 jmmv 8473: <li><p>Ensure that the PLIST does not remove the shared icon
8474: directories from the <code class="filename">share/icons/hicolor</code>
8475: hierarchy because they will be handled automatically.</p></li>
8476: </ol></div>
8477: <p>The best way to verify that the PLIST is correct with
8478: respect to the last two points is to regenerate it using
8479: <span><strong class="command">make print-PLIST</strong></span>.</p>
8480: </div>
8481: <div class="sect2" lang="en">
8482: <div class="titlepage"><div><div><h3 class="title">
1.87 wiz 8483: <a name="desktop-files"></a>17.6.19. Packages installing desktop files</h3></div></div></div>
1.85 jmmv 8484: <p>If a package installs <code class="filename">.desktop</code> files
8485: under <code class="filename">share/applications</code> and these include
8486: MIME information, you need to take extra steps to ensure that they
8487: are registered into the MIME database:</p>
8488: <div class="orderedlist"><ol type="1">
8489: <li><p>Include
8490: <code class="filename">../../sysutils/desktop-file-utils/desktopdb.mk</code>.</p></li>
8491: <li><p>Check the PLIST and remove the entry that refers to the
8492: <code class="filename">share/applications/mimeinfo.cache</code> file.
8493: It will be handled automatically.</p></li>
8494: </ol></div>
8495: <p>The best way to verify that the PLIST is correct with
8496: respect to the last point is to regenerate it using <span><strong class="command">make
8497: print-PLIST</strong></span>.</p>
1.75 rillig 8498: </div>
8499: </div>
1.87 wiz 8500: <div class="sect1" lang="en">
8501: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8502: <a name="punting"></a>17.7. Marking packages as having problems</h2></div></div></div>
8503: <p>In some cases one does not have the time to solve a problem
8504: immediately. There are currently two ways to declare that one knows
8505: that a package has problems.</p>
8506: <div class="itemizedlist"><ul type="disc">
8507: <li><p>The first way is to plainly mark it as broken. For
8508: this, one just sets the variable <code class="varname">BROKEN</code> to the
8509: reason why the package is broken (similar to the
8510: <code class="varname">RESTRICTED</code> variable). A user trying to build
8511: the package will immediately be shown this message, and the build
8512: will not be even tried.</p></li>
8513: <li><p>After each pkgsrc freeze period (a time when the
8514: tree is stabilized and a new pkgsrc branch is cut), the packages
8515: that were not building in the official branch build on the latest
8516: NetBSD release will be marked as broken on that branch. This is
8517: done by setting the <code class="varname">BROKEN_IN</code> variable to the
8518: branch name (or appending the branch name to it). If a user tries
8519: to build such a package and the build fails, the user gets a
8520: message that says that the package was broken on the respective
8521: branch(es).</p></li>
8522: </ul></div>
8523: <p>Both types of packages are removed from pkgsrc in irregular
8524: intervals.</p>
8525: </div>
1.75 rillig 8526: </div>
8527: <div class="chapter" lang="en">
8528: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8529: <a name="debug"></a>Chapter 18. Debugging</h2></div></div></div>
1.88 wiz 8530: <p>To check out all the gotchas when building a package, here are
8531: the steps that I do in order to get a package working. Please note
8532: this is basically the same as what was explained in the previous
8533: sections, only with some debugging aids.</p>
1.75 rillig 8534: <div class="itemizedlist"><ul type="disc">
1.88 wiz 8535: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=1</code> in
8536: <code class="filename">/etc/mk.conf</code></p></li>
1.75 rillig 8537: <li>
1.76 rillig 8538: <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 8539: create a directory for a new package, change into it, then run
8540: <span><strong class="command">url2pkg</strong></span>:</p>
1.75 rillig 8541: <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>
8542: <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>
8543: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
8544: </li>
1.76 rillig 8545: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
8546: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.87 wiz 8547: <li><p>Run <span><strong class="command">make configure</strong></span></p></li>
1.75 rillig 8548: <li><p>Add any dependencies glimpsed from documentation and the
1.88 wiz 8549: configure step to the package's
8550: <code class="filename">Makefile</code>.</p></li>
1.75 rillig 8551: <li>
8552: <p>Make the package compile, doing multiple rounds of</p>
8553: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
8554: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
8555: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
8556: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
8557: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
8558: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
8559: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
1.88 wiz 8560: <p>Doing this step as non-root user will ensure that no files
8561: are modified that shouldn't be, especially during the build
8562: phase. <span><strong class="command">mkpatches</strong></span>,
8563: <span><strong class="command">patchdiff</strong></span> and <span><strong class="command">pkgvi</strong></span> are
8564: 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>
8565: package.</p>
1.75 rillig 8566: </li>
1.88 wiz 8567: <li><p>Look at the <code class="filename">Makefile</code>, fix if
8568: necessary; see <a href="#components.Makefile" title="9.1. Makefile">Section 9.1, “<code class="filename">Makefile</code>”</a>.</p></li>
1.75 rillig 8569: <li>
1.76 rillig 8570: <p>Generate a <code class="filename">PLIST</code>:</p>
1.75 rillig 8571: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
8572: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST >PLIST</code></strong>
8573: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
8574: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
8575: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
1.88 wiz 8576: <p>You usually need to be <code class="username">root</code> to do
8577: this. Look if there are any files left:</p>
1.75 rillig 8578: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
8579: <p>If this reveals any files that are missing in
1.88 wiz 8580: <code class="filename">PLIST</code>, add them.</p>
1.75 rillig 8581: </li>
8582: <li>
1.88 wiz 8583: <p>Now that the <code class="filename">PLIST</code> is OK, install the
8584: package again and make a binary package:</p>
1.75 rillig 8585: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
8586: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
8587: </li>
8588: <li>
8589: <p>Delete the installed package:</p>
1.88 wiz 8590: <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 8591: </li>
8592: <li>
1.88 wiz 8593: <p>Repeat the above <span><strong class="command">make print-PLIST</strong></span>
8594: command, which shouldn't find anything now:</p>
1.75 rillig 8595: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
8596: </li>
8597: <li>
8598: <p>Reinstall the binary package:</p>
1.88 wiz 8599: <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 8600: </li>
1.88 wiz 8601: <li><p>Play with it. Make sure everything works.</p></li>
1.75 rillig 8602: <li>
1.88 wiz 8603: <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
8604: reports:</p>
1.75 rillig 8605: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
8606: </li>
1.88 wiz 8607: <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 8608: </ul></div>
8609: </div>
8610: <div class="chapter" lang="en">
8611: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8612: <a name="submit"></a>Chapter 19. Submitting and Committing</h2></div></div></div>
1.75 rillig 8613: <div class="toc">
8614: <p><b>Table of Contents</b></p>
8615: <dl>
1.77 rillig 8616: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
8617: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
8618: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
8619: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
8620: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
8621: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 8622: </dl>
8623: </div>
8624: <div class="sect1" lang="en">
8625: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8626: <a name="submitting-binary-packages"></a>19.1. Submitting binary packages</h2></div></div></div>
1.75 rillig 8627: <p>Our policy is that we accept binaries only from pkgsrc
8628: developers to guarantee that the packages don't contain any
8629: trojan horses etc. This is not to annoy anyone but rather to
8630: protect our users! You're still free to put up your home-made
8631: binary packages and tell the world where to get them. NetBSD
8632: developers doing bulk builds and wanting to upload them please
8633: 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>
8634: </div>
8635: <div class="sect1" lang="en">
8636: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8637: <a name="submitting-your-package"></a>19.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
1.75 rillig 8638: <p>First, check that your package is complete, compiles and
1.77 rillig 8639: runs well; see <a href="#debug" title="Chapter 18. Debugging">Chapter 18, <i>Debugging</i></a> and the rest of this
1.75 rillig 8640: 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 8641: archive that contains all files that make up the package.
1.87 wiz 8642: Finally, send this package to the pkgsrc bug tracking system,
8643: 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
8644: that, go to the web page
8645: <a href="http://www.NetBSD.org/Misc/send-pr.html" target="_top">http://www.NetBSD.org/Misc/send-pr.html</a>,
8646: which contains some instructions and a link to a form, where you
8647: can submit packages.</p>
8648: <p>In the form of the problem report, the category should be
8649: “<span class="quote">pkg</span>”, the synopsis should include the package name
8650: and version number, and the description field should contain a
8651: short description of your package (contents of the COMMENT
8652: variable or DESCR file are OK). The uuencoded package data should
8653: go into the “<span class="quote">fix</span>” field.</p>
1.75 rillig 8654: <p>If you want to submit several packages, please send a
8655: separate PR for each one, it's easier for us to track things
8656: that way.</p>
8657: <p>Alternatively, you can also import new packages into
8658: pkgsrc-wip (“<span class="quote">pkgsrc work-in-progress</span>”); see the
8659: homepage at <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
8660: for details.</p>
8661: </div>
8662: <div class="sect1" lang="en">
8663: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8664: <a name="general-notes-for-changes"></a>19.3. General notes when adding, updating, or removing packages</h2></div></div></div>
1.75 rillig 8665: <p>Please note all package additions, updates, moves, and
1.76 rillig 8666: removals in <code class="filename">pkgsrc/doc/CHANGES</code>. It's very
1.75 rillig 8667: important to keep this file up to date and conforming to the
8668: existing format, because it will be used by scripts to
8669: automatically update pages on <a href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
8670: sites. Additionally, check the
1.76 rillig 8671: <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
1.75 rillig 8672: for the package you updated or removed, in case it was mentioned
8673: there.</p>
8674: <p>When the <code class="varname">PKGREVISION</code> of a package is
8675: bumped, the change should appear in
1.76 rillig 8676: <code class="filename">pkgsrc/doc/CHANGES</code> if it is security
1.75 rillig 8677: related or otherwise relevant. Mass bumps that result from a
8678: dependency being updated should not be mentioned. In all other
8679: cases it's the developer's decision.</p>
8680: <p>There is a make target that helps in creating proper
1.76 rillig 8681: <code class="filename">CHANGES</code> entries: <span><strong class="command">make
1.75 rillig 8682: changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
8683: and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
1.76 rillig 8684: usage is to first make sure that your <code class="filename">CHANGES</code>
1.75 rillig 8685: file is up-to-date (to avoid having to resolve conflicts later-on)
8686: and then to <span><strong class="command">cd</strong></span> to the package directory. For
8687: package updates, <span><strong class="command">make changes-entry</strong></span> is enough.
8688: For new packages, or package moves or removals, set the
8689: <code class="varname">CTYPE</code> variable on the command line to "Added",
8690: "Moved", or "Removed". You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.76 rillig 8691: in <code class="filename">/etc/mk.conf</code> if your local login name is
1.75 rillig 8692: not the same as your NetBSD login name. Don't forget to commit
1.76 rillig 8693: the changes to <code class="filename">pkgsrc/doc/CHANGES</code>!</p>
1.75 rillig 8694: </div>
8695: <div class="sect1" lang="en">
8696: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8697: <a name="committing-importing"></a>19.4. Committing: Importing a package into CVS</h2></div></div></div>
1.87 wiz 8698: <p>This section is only of interest for pkgsrc developers with write
1.75 rillig 8699: access to the pkgsrc repository. Please remember that cvs
8700: imports files relative to the current working directory, and that
8701: the pathname that you
8702: give the <span><strong class="command">cvs import</strong></span> command is so that it knows where
8703: to place the files in the repository. Newly created packages should be
8704: imported with a vendor tag of “<span class="quote">TNF</span>” and a release tag of
1.87 wiz 8705: “<span class="quote">pkgsrc-base</span>”, e.g:</p>
1.75 rillig 8706: <pre class="programlisting">
8707: <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
8708: <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
8709: </pre>
1.87 wiz 8710: <p>Remember to move the directory from which you imported out of
1.75 rillig 8711: the way, or cvs will complain the next time you “<span class="quote">cvs
8712: update</span>” your source tree. Also don't forget to add the new
1.87 wiz 8713: package to the category's <code class="filename">Makefile</code>.</p>
8714: <p>The commit message of the initial import should include part of the
1.76 rillig 8715: <code class="filename">DESCR</code> file, so people reading the mailing lists know
1.87 wiz 8716: what the package is/does.</p>
8717: <p>For new packages, “<span class="quote">cvs import</span>” is preferred to “<span class="quote">cvs
1.75 rillig 8718: add</span>” because the former gets everything with a single command,
1.87 wiz 8719: and provides a consistent tag.</p>
1.75 rillig 8720: </div>
8721: <div class="sect1" lang="en">
8722: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8723: <a name="updating-package"></a>19.5. Updating a package to a newer version</h2></div></div></div>
1.87 wiz 8724: <p>Please always put a concise, appropriate and relevant summary of the
1.75 rillig 8725: changes between old and new versions into the commit log when updating
1.87 wiz 8726: a package. There are various reasons for this:</p>
1.75 rillig 8727: <div class="itemizedlist"><ul type="disc">
1.87 wiz 8728: <li><p>A URL is volatile, and can change over time. It may go away completely
8729: or its information may be overwritten by newer information.</p></li>
8730: <li><p>Having the change information between old and new versions in our CVS
8731: repository is very useful for people who use either cvs or anoncvs.</p></li>
8732: <li><p>Having the change information between old and new versions in our CVS
1.75 rillig 8733: repository is very useful for people who read the pkgsrc-changes mailing
8734: list, so that they can make tactical decisions about when to upgrade
1.87 wiz 8735: the package.</p></li>
1.75 rillig 8736: </ul></div>
1.87 wiz 8737: <p>Please also recognize that, just because a new version of a package
1.75 rillig 8738: has been released, it should not automatically be upgraded in the CVS
8739: repository. We prefer to be conservative in the packages that are
8740: included in pkgsrc - development or beta packages are not really the
8741: best thing for most places in which pkgsrc is used. Please use your
8742: judgement about what should go into pkgsrc, and bear in mind that
1.87 wiz 8743: stability is to be preferred above new and possibly untested features.</p>
1.75 rillig 8744: </div>
8745: <div class="sect1" lang="en">
8746: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77 rillig 8747: <a name="moving-package"></a>19.6. Moving a package in pkgsrc</h2></div></div></div>
1.75 rillig 8748: <div class="orderedlist"><ol type="1">
8749: <li><p>Make a copy of the directory somewhere else.</p></li>
8750: <li>
8751: <p>Remove all CVS dirs.</p>
1.87 wiz 8752: <p>Alternatively to the first two steps you can also do:</p>
1.75 rillig 8753: <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 8754: <p>and use that for further work.</p>
1.75 rillig 8755: </li>
8756: <li><p>Fix <code class="varname">CATEGORIES</code> and any
8757: <code class="varname">DEPENDS</code> paths that just did “<span class="quote">../package</span>”
8758: instead of “<span class="quote">../../category/package</span>”.</p></li>
8759: <li><p><span><strong class="command">cvs import</strong></span> the modified package in the new
8760: place.</p></li>
8761: <li>
8762: <p>Check if any package depends on it:
8763: </p>
8764: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
8765: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
8766: </li>
8767: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
8768: <li><p><span><strong class="command">cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.76 rillig 8769: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
8770: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
1.75 rillig 8771: <li>
8772: <p>Commit the changed and removed files:</p>
8773: <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 8774: <p>(and any packages from step 5, of course).</p>
1.75 rillig 8775: </li>
8776: </ol></div>
8777: </div>
8778: </div>
8779: <div class="chapter" lang="en">
8780: <div class="titlepage"><div><div><h2 class="title">
1.77 rillig 8781: <a name="devfaq"></a>Chapter 20. Frequently Asked Questions</h2></div></div></div>
1.75 rillig 8782: <p>This section contains the answers to questions that may
8783: arise when you are writing a package. If you don't find your
8784: question answered here, first have a look in the other chapters,
8785: and if you still don't have the answer, ask on the
8786: <code class="literal">pkgsrc-users</code> mailing list.</p>
8787: <div class="qandaset">
8788: <dl>
1.89 ! rillig 8789: <dt>20.1. <a href="#id2657911">What is the difference between
1.75 rillig 8790: MAKEFLAGS, .MAKEFLAGS and
8791: MAKE_FLAGS?</a>
8792: </dt>
1.89 ! rillig 8793: <dt>20.2. <a href="#id2657947">What is the difference between
1.75 rillig 8794: MAKE, GMAKE and
8795: MAKE_PROGRAM?</a>
8796: </dt>
1.89 ! rillig 8797: <dt>20.3. <a href="#id2657986">What is the difference between
1.75 rillig 8798: CC, PKG_CC and
8799: PKGSRC_COMPILER?</a>
8800: </dt>
1.89 ! rillig 8801: <dt>20.4. <a href="#id2658023">What is the difference between
1.75 rillig 8802: BUILDLINK_LDFLAGS,
8803: BUILDLINK_LDADD and
8804: BUILDLINK_LIBS?</a>
8805: </dt>
1.89 ! rillig 8806: <dt>20.5. <a href="#id2658041">Why does make show-var
1.75 rillig 8807: VARNAME=BUILDLINK_PREFIX.foo
8808: say it's empty?</a>
8809: </dt>
1.89 ! rillig 8810: <dt>20.6. <a href="#id2658069">What does
1.78 rillig 8811: ${MASTER_SITE_SOURCEFORGE:=package/} mean? I
8812: don't understand the := inside
8813: it.</a>
8814: </dt>
1.89 ! rillig 8815: <dt>20.7. <a href="#id2658144">Which mailing lists are there for package
1.78 rillig 8816: developers?</a>
8817: </dt>
1.89 ! rillig 8818: <dt>20.8. <a href="#id2658180">Where is the pkgsrc
1.80 rillig 8819: documentation?</a>
8820: </dt>
1.75 rillig 8821: </dl>
8822: <table border="0" summary="Q and A Set">
8823: <col align="left" width="1%">
8824: <tbody>
8825: <tr class="question">
8826: <td align="left" valign="top">
1.89 ! rillig 8827: <a name="id2657911"></a><a name="id2657912"></a><b>20.1.</b>
1.75 rillig 8828: </td>
8829: <td align="left" valign="top"><p>What is the difference between
8830: <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
8831: <code class="varname">MAKE_FLAGS</code>?</p></td>
8832: </tr>
8833: <tr class="answer">
1.89 ! rillig 8834: <td align="left" valign="top"><b></b></td>
1.75 rillig 8835: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
8836: 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
8837: <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
8838: the <code class="varname">MAKE_PROGRAM</code> when building the
8839: package. [FIXME: What is .MAKEFLAGS for?]</p></td>
8840: </tr>
8841: <tr class="question">
8842: <td align="left" valign="top">
1.89 ! rillig 8843: <a name="id2657947"></a><a name="id2657948"></a><b>20.2.</b>
1.75 rillig 8844: </td>
8845: <td align="left" valign="top"><p>What is the difference between
8846: <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
8847: <code class="varname">MAKE_PROGRAM</code>?</p></td>
8848: </tr>
8849: <tr class="answer">
1.89 ! rillig 8850: <td align="left" valign="top"><b></b></td>
1.75 rillig 8851: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
8852: <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
8853: infrastructure. <code class="varname">GMAKE</code> is the path to GNU
8854: Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
8855: use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
8856: Make program that is used for building the
8857: package.</p></td>
8858: </tr>
8859: <tr class="question">
8860: <td align="left" valign="top">
1.89 ! rillig 8861: <a name="id2657986"></a><a name="id2657987"></a><b>20.3.</b>
1.75 rillig 8862: </td>
8863: <td align="left" valign="top"><p>What is the difference between
8864: <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
8865: <code class="varname">PKGSRC_COMPILER</code>?</p></td>
8866: </tr>
8867: <tr class="answer">
1.89 ! rillig 8868: <td align="left" valign="top"><b></b></td>
1.75 rillig 8869: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
8870: compiler, which can be configured by the pkgsrc user.
8871: <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
8872: <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
8873: path to a compiler, but the type of compiler that should be
1.76 rillig 8874: used. See <code class="filename">mk/compiler.mk</code> for more
1.75 rillig 8875: information about the latter variable.</p></td>
8876: </tr>
8877: <tr class="question">
8878: <td align="left" valign="top">
1.89 ! rillig 8879: <a name="id2658023"></a><a name="id2658024"></a><b>20.4.</b>
1.75 rillig 8880: </td>
8881: <td align="left" valign="top"><p>What is the difference between
8882: <code class="varname">BUILDLINK_LDFLAGS</code>,
8883: <code class="varname">BUILDLINK_LDADD</code> and
8884: <code class="varname">BUILDLINK_LIBS</code>?</p></td>
8885: </tr>
8886: <tr class="answer">
1.89 ! rillig 8887: <td align="left" valign="top"><b></b></td>
1.75 rillig 8888: <td align="left" valign="top"><p>[FIXME]</p></td>
8889: </tr>
8890: <tr class="question">
8891: <td align="left" valign="top">
1.89 ! rillig 8892: <a name="id2658041"></a><a name="id2658042"></a><b>20.5.</b>
1.75 rillig 8893: </td>
8894: <td align="left" valign="top"><p>Why does <span><strong class="command">make show-var
8895: VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
8896: say it's empty?</p></td>
8897: </tr>
8898: <tr class="answer">
1.89 ! rillig 8899: <td align="left" valign="top"><b></b></td>
1.75 rillig 8900: <td align="left" valign="top"><p>For optimization reasons, some variables are only
8901: available in the “<span class="quote">wrapper</span>” phase and later. To
8902: “<span class="quote">simulate</span>” the wrapper phase, append
8903: <span><strong class="command">PKG_PHASE=wrapper</strong></span> to the above
8904: command.</p></td>
8905: </tr>
1.78 rillig 8906: <tr class="question">
8907: <td align="left" valign="top">
1.89 ! rillig 8908: <a name="id2658069"></a><a name="id2658070"></a><b>20.6.</b>
1.78 rillig 8909: </td>
8910: <td align="left" valign="top"><p>What does
8911: <code class="literal">${MASTER_SITE_SOURCEFORGE:=package/}</code> mean? I
8912: don't understand the <code class="literal">:=</code> inside
8913: it.</p></td>
8914: </tr>
8915: <tr class="answer">
1.89 ! rillig 8916: <td align="left" valign="top"><b></b></td>
1.78 rillig 8917: <td align="left" valign="top"><p>The <code class="literal">:=</code> is not really an
8918: assignment operator, like you might expect at first sight.
8919: Instead, it is a degenerate form of
8920: <code class="literal">${LIST:<em class="replaceable"><code>old_string</code></em>=<em class="replaceable"><code>new_string</code></em>}</code>,
8921: 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
8922: may have seen as in <code class="literal">${SRCS:.c=.o}</code>. In the
8923: case of <code class="varname">MASTER_SITE_*</code>,
8924: <em class="replaceable"><code>old_string</code></em> is the empty string and
8925: <em class="replaceable"><code>new_string</code></em> is
8926: <code class="literal">package/</code>. That's where the
8927: <code class="literal">:</code> and the <code class="literal">=</code> fall
8928: together.</p></td>
8929: </tr>
8930: <tr class="question">
8931: <td align="left" valign="top">
1.89 ! rillig 8932: <a name="id2658144"></a><a name="id2658145"></a><b>20.7.</b>
1.78 rillig 8933: </td>
8934: <td align="left" valign="top"><p>Which mailing lists are there for package
8935: developers?</p></td>
8936: </tr>
8937: <tr class="answer">
1.89 ! rillig 8938: <td align="left" valign="top"><b></b></td>
1.78 rillig 8939: <td align="left" valign="top"><div class="variablelist"><dl>
8940: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">tech-pkg</a></span></dt>
8941: <dd><p>This is a list for technical discussions related
8942: to pkgsrc development, e.g. soliciting feedback for changes to
8943: pkgsrc infrastructure, proposed new features, questions related
8944: to porting pkgsrc to a new platform, advice for maintaining a
8945: package, patches that affect many packages, help requests moved
8946: from pkgsrc-users when an infrastructure bug is found,
8947: etc.</p></dd>
8948: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a></span></dt>
8949: <dd><p>All bug reports in category "pkg" sent with
8950: <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
8951: directly; use one of the other mailing
8952: lists.</p></dd>
8953: </dl></div></td>
8954: </tr>
1.80 rillig 8955: <tr class="question">
8956: <td align="left" valign="top">
1.89 ! rillig 8957: <a name="id2658180"></a><a name="id2658181"></a><b>20.8.</b>
1.80 rillig 8958: </td>
8959: <td align="left" valign="top"><p>Where is the pkgsrc
8960: documentation?</p></td>
8961: </tr>
8962: <tr class="answer">
1.89 ! rillig 8963: <td align="left" valign="top"><b></b></td>
1.80 rillig 8964: <td align="left" valign="top">
8965: <p>There are many places where you can find
8966: documentation about pkgsrc:</p>
8967: <div class="itemizedlist"><ul type="disc">
8968: <li><p>The pkgsrc guide (this document) is a collection
8969: of chapters that explain large parts of pkgsrc, but some
8970: chapters tend to be outdated. Which ones they are is hard to
8971: say.</p></li>
8972: <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
8973: about certain features, announcements of new parts of the pkgsrc
8974: infrastructure and sometimes even announcements that a certain
8975: feature has been marked as obsolete. The benefit here is that
8976: each message has a date appended to it.</p></li>
8977: <li><p>Many of the files in the
8978: <code class="filename">mk/</code> directory start with a comment that
8979: describes the purpose of the file and how it can be used by the
8980: pkgsrc user and package authors.</p></li>
8981: <li><p>The CVS log messages are a rich source of
8982: information, but they tend to be highly abbreviated, especially
8983: for actions that occur often. Some contain a detailed
8984: description of what has changed, but they are geared towards the
8985: other pkgsrc developers, not towards an average pkgsrc user.
8986: They also only document <span class="emphasis"><em>changes</em></span>, so if you
8987: don't know what has been before, these messages may not be worth
8988: too much to you.</p></li>
8989: <li><p>Some parts of pkgsrc are only “<span class="quote">implicitly
8990: documented</span>”, that is the documentation exists only in the
8991: mind of the developer who wrote the code. To get this
8992: information, use the the <span><strong class="command">cvs annotate</strong></span> command
8993: to see who has written it and ask on the
8994: <code class="literal">tech-pkg</code> mailing list, so that others can
8995: find your questions later (see above). To be sure that the
8996: developer in charge reads the mail, you may CC him or
8997: her.</p></li>
8998: </ul></div>
8999: </td>
9000: </tr>
1.75 rillig 9001: </tbody>
9002: </table>
9003: </div>
9004: </div>
1.85 jmmv 9005: <div class="chapter" lang="en">
9006: <div class="titlepage"><div><div><h2 class="title">
9007: <a name="gnome"></a>Chapter 21. GNOME packaging and porting</h2></div></div></div>
9008: <div class="toc">
9009: <p><b>Table of Contents</b></p>
9010: <dl>
9011: <dt><span class="sect1"><a href="#meta-packages">21.1. Meta packages</a></span></dt>
9012: <dt><span class="sect1"><a href="#new-package">21.2. Packaging a GNOME application</a></span></dt>
9013: <dt><span class="sect1"><a href="#full-update">21.3. Updating GNOME to a newer version</a></span></dt>
9014: <dt><span class="sect1"><a href="#patching">21.4. Patching guidelines</a></span></dt>
9015: </dl>
9016: </div>
9017: <p>Quoting <a href="http://www.gnome.org/" target="_top">GNOME's web
9018: site</a>:</p>
9019: <div class="blockquote"><blockquote class="blockquote"><p>The GNOME project provides two things: The GNOME desktop
9020: environment, an intuitive and attractive desktop for users, and the
9021: GNOME development platform, an extensive framework for building
9022: applications that integrate into the rest of the desktop.</p></blockquote></div>
9023: <p>pkgsrc provides a seamless way to automatically build and install
9024: a complete GNOME environment <span class="emphasis"><em>under many different
9025: platforms</em></span>. We can say with confidence that pkgsrc is one of
9026: the most advanced build and packaging systems for GNOME due to its
9027: included technologies buildlink3, the wrappers and tools framework and
9028: automatic configuration file management. Lots of efforts are put into
9029: achieving a completely clean deinstallation of installed software
9030: components.</p>
9031: <p>Given that pkgsrc is <a href="http://www.NetBSD.org/" target="_top">NetBSD</a>'s official packaging system,
9032: the above also means that great efforts are put into making GNOME work
9033: under this operating system. Recently, <a href="http://www.dragonflybsd.org/" target="_top">DragonFly BSD</a> also adopted
9034: pkgsrc as its preferred packaging system, contributing lots of
9035: portability fixes to make GNOME build and install under it.</p>
9036: <p>This chapter is aimed at pkgsrc developers and other people
9037: interested in helping our GNOME porting and packaging efforts. It
9038: provides instructions on how to manage the existing packages and some
9039: important information regarding their internals.</p>
9040: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
9041: <h3 class="title">We need your help!</h3>
9042: <p>Should you have some spare cycles to devote to NetBSD, pkgsrc
9043: and GNOME and are willing to learn new exciting stuff, please jump
9044: straight to the <a href="http://www.NetBSD.org/contrib/projects.html#gnome" target="_top">pending
9045: work</a> list! There is still a long way to go to get a
9046: fully-functional GNOME desktop under NetBSD and we need your help to
9047: achieve it!</p>
9048: </div>
9049: <div class="sect1" lang="en">
9050: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9051: <a name="meta-packages"></a>21.1. Meta packages</h2></div></div></div>
9052: <p>pkgsrc includes three GNOME-related meta packages:</p>
9053: <div class="itemizedlist"><ul type="disc">
9054: <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
9055: the core GNOME desktop environment. It only includes the necessary
9056: bits to get it to boot correctly, although it may lack important
9057: functionality for daily operation. The idea behind this package is
9058: to let end users build their own configurations on top of this one,
9059: first installing this meta package to achieve a functional setup and
9060: then adding individual applications.</p></li>
9061: <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
9062: complete installation of the GNOME platform and desktop as defined
9063: by the GNOME project; this is based on the components distributed in
9064: the <code class="filename">platform/x.y/x.y.z/sources</code> and
9065: <code class="filename">desktop/x.y/x.y.z/sources</code> directories of the
9066: official FTP server. Developer-only tools found in those
9067: directories are not installed unless required by some other
9068: component to work properly. Similarly, packages from the bindings
9069: set (<code class="filename">bindings/x.y/x.y.z/sources</code>) are not pulled
9070: in unless required as a dependency for an end-user component. This
9071: 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>
9072: <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>:
9073: Installs all the tools required to build a GNOME component when
9074: fetched from the CVS repository. These are required to let the
9075: <span><strong class="command">autogen.sh</strong></span> scripts work appropriately.</p></li>
9076: </ul></div>
9077: <p>In all these packages, the <code class="varname">DEPENDS</code> lines are
9078: sorted in a way that eases updates: a package may depend on other
9079: packages listed before it but not on any listed after it. It is very
9080: important to keep this order to ease updates so... <span class="emphasis"><em>do not
9081: change it to alphabetical sorting!</em></span></p>
9082: </div>
9083: <div class="sect1" lang="en">
9084: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9085: <a name="new-package"></a>21.2. Packaging a GNOME application</h2></div></div></div>
9086: <p>Almost all GNOME applications are written in C and use a common
9087: set of tools as their build system. Things get different with the new
9088: bindings to other languages (such as Python), but the following will
9089: give you a general idea on the minimum required tools:</p>
9090: <div class="itemizedlist"><ul type="disc">
9091: <li>
9092: <p>Almost all GNOME applications use the GNU Autotools as their
9093: build system. As a general rule you will need to tell this to your
9094: package:</p>
9095: <pre class="programlisting">GNU_CONFIGURE=yes
9096: USE_LIBTOOL=yes
9097: USE_TOOLS+=gmake</pre>
9098: </li>
9099: <li>
9100: <p>If the package uses pkg-config to detect dependencies, add this
9101: tool to the list of required utilities:</p>
9102: <pre class="programlisting">USE_TOOLS+=pkg-config</pre>
9103: <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
9104: the end of the build process to ensure that you did not miss to
9105: specify any dependency in your package and that the version
9106: requirements are all correct.</p>
9107: </li>
9108: <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
9109: to handle dependencies and to force the package to use the latest
9110: available version.</p></li>
9111: <li>
9112: <p>If the package uses gtk-doc (a documentation generation
9113: utility), do <span class="emphasis"><em>not</em></span> add a dependency on it. The
9114: tool is rather big and the distfile should come with pregenerated
9115: documentation anyway; if it does not, it is a bug that you ought to
9116: report. For such packages you should disable gtk-doc (unless it is
1.89 ! rillig 9117: the default):</p>
! 9118: <pre class="programlisting">CONFIGURE_ARGS+=--disable-gtk-doc</pre>
! 9119: <p>The default location of installed HTML files
! 9120: (<code class="filename">share/gtk-doc/<package-name></code>) is correct
! 9121: and should not be changed unless the package insists on installing
! 9122: them somewhere else. Otherwise programs as
! 9123: <span><strong class="command">devhelp</strong></span> will not be able to open them. You can
! 9124: do that with an entry similar to:</p>
! 9125: <pre class="programlisting">CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...</pre>
1.85 jmmv 9126: </li>
9127: </ul></div>
9128: <p>GNOME uses multiple <span class="emphasis"><em>shared</em></span> directories and
9129: files under the installation prefix to maintain databases. In this
9130: context, shared means that those exact same directories and files are
9131: used among several different packages, leading to conflicts in the
9132: <code class="filename">PLIST</code>. pkgsrc currently includes functionality to
9133: handle the most common cases, so you have to forget about using
9134: <code class="literal">@unexec ${RMDIR}</code> lines in your file lists and
9135: omitting shared files from them. If you find yourself doing those,
9136: <span class="emphasis"><em>your package is most likely incorrect</em></span>.</p>
9137: <p>The following table lists the common situations that result in
9138: using shared directories or files. For each of them, the appropriate
9139: solution is given. After applying the solution be sure to
9140: <span class="emphasis"><em>regenerate the package's file list</em></span> with
9141: <span><strong class="command">make print-PLIST</strong></span> and ensure it is correct.</p>
9142: <div class="table">
9143: <a name="plist-handling"></a><p class="title"><b>Table 21.1. PLIST handling for GNOME packages</b></p>
1.89 ! rillig 9144: <table summary="PLIST handling for GNOME packages" border="1">
1.85 jmmv 9145: <colgroup>
9146: <col>
9147: <col>
9148: </colgroup>
9149: <thead><tr>
9150: <th>If the package...</th>
9151: <th>Then...</th>
9152: </tr></thead>
9153: <tbody>
9154: <tr>
9155: <td>Installs OMF files under <code class="filename">share/omf</code>.</td>
1.87 wiz 9156: <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 9157: </tr>
9158: <tr>
9159: <td>Installs icons under the
9160: <code class="filename">share/icons/hicolor</code> hierarchy or updates
9161: <code class="filename">share/icons/hicolor/icon-theme.cache</code>.</td>
1.87 wiz 9162: <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 9163: </tr>
9164: <tr>
9165: <td>Installs files under
9166: <code class="filename">share/mime/packages</code>.</td>
1.87 wiz 9167: <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 9168: </tr>
9169: <tr>
9170: <td>Installs <code class="filename">.desktop</code> files under
9171: <code class="filename">share/applications</code> and these include MIME
9172: information.</td>
1.87 wiz 9173: <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 9174: </tr>
9175: </tbody>
1.89 ! rillig 9176: </table>
1.85 jmmv 9177: </div>
9178: </div>
9179: <div class="sect1" lang="en">
9180: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9181: <a name="full-update"></a>21.3. Updating GNOME to a newer version</h2></div></div></div>
9182: <p>When seeing GNOME as a whole, there are two kinds of
9183: updates:</p>
9184: <div class="variablelist"><dl>
9185: <dt><span class="term">Major update</span></dt>
9186: <dd>
9187: <p>Given that there is still a very long way for GNOME 3 (if it
9188: ever appears), we consider a major update one that goes from a
9189: <code class="literal">2.X</code> version to a <code class="literal">2.Y</code> one,
9190: where <code class="literal">Y</code> is even and greater than
9191: <code class="literal">X</code>. These are hard to achieve because they
9192: introduce lots of changes in the components' code and almost all
9193: GNOME distfiles are updated to newer versions. Some of them can
9194: even break API and ABI compatibility with the previous major
9195: version series. As a result, the update needs to be done all at
9196: once to minimize breakage.</p>
9197: <p>A major update typically consists of around 80 package
9198: updates and the addition of some new ones.</p>
9199: </dd>
9200: <dt><span class="term">Minor update</span></dt>
9201: <dd>
9202: <p>We consider a minor update one that goes from a
9203: <code class="literal">2.A.X</code> version to a <code class="literal">2.A.Y</code>
9204: one where <code class="literal">Y</code> is greater than
9205: <code class="literal">X</code>. These are easy to achieve because they do
9206: not update all GNOME components, can be done in an incremental way
9207: and do not break API nor ABI compatibility.</p>
9208: <p>A minor update typically consists of around 50 package
9209: updates, although the numbers here may vary a lot.</p>
9210: </dd>
9211: </dl></div>
9212: <p>In order to update the GNOME components in pkgsrc to a new stable
9213: release (either major or minor), the following steps should be
9214: followed:</p>
9215: <div class="orderedlist"><ol type="1">
9216: <li>
9217: <p>Get a list of all the tarballs that form the new release by
9218: using the following commands. These will leave the full list of the
9219: components's distfiles into the <code class="filename">list.txt</code>
9220: file:</p>
1.88 wiz 9221: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>echo ls "*.tar.bz2" | \
1.85 jmmv 9222: ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
9223: awk '{ print $9 }' >list.txt</code></strong>
1.88 wiz 9224: <code class="prompt">%</code> <strong class="userinput"><code>echo ls "*.tar.bz2" | \
1.85 jmmv 9225: ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
9226: awk '{ print $9 }' >>list.txt</code></strong></pre>
9227: </li>
9228: <li><p>Open each meta package's <code class="filename">Makefile</code> and
9229: bump their version to the release you are updating them to. The
9230: three meta packages should be always consistent with versioning.
9231: Obviously remove any <code class="varname">PKGREVISION</code>s that might be
9232: in them.</p></li>
9233: <li>
9234: <p>For each meta package, update all its
9235: <code class="varname">DEPENDS</code> lines to match the latest versions as
9236: shown by the above commands. Do <span class="emphasis"><em>not</em></span> list any
9237: newer version (even if found in the FTP) because the meta packages
9238: are supposed to list the exact versions that form a specific GNOME
9239: release. Exceptions are permitted here if a newer version solves a
9240: serious issue in the overall desktop experience; these typically
9241: come in the form of a revision bump in pkgsrc, not in newer versions
9242: from the developers.</p>
9243: <p>Packages not listed in the <code class="filename">list.txt</code> file
9244: should be updated to the latest version available (if found in
9245: pkgsrc). This is the case, for example, of the dependencies on the
9246: 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>
9247: </li>
9248: <li>
9249: <p>Generate a patch from the modified meta packages and extract the
9250: list of "new" lines. This will provide you an outline on what
9251: packages need to be updated in pkgsrc and in what order:</p>
1.88 wiz 9252: <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 9253: </li>
9254: <li><p>For major desktop updates it is recommended to zap all your
9255: installed packages and start over from scratch at this point.</p></li>
9256: <li><p>Now comes the longest step by far: iterate over the contents
9257: of <code class="filename">todo.txt</code> and update the packages listed in
9258: it in order. For major desktop updates none of these should be
9259: commited until the entire set is completed because there are chances
9260: of breaking not-yet-updated packages.</p></li>
9261: <li><p>Once the packages are up to date and working, commit them to
9262: the tree one by one with appropriate log messages. At the end,
9263: commit the three meta package updates and all the corresponding
9264: changes to the <code class="filename">doc/CHANGES-<YEAR></code> and
9265: <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>
9266: </ol></div>
9267: </div>
9268: <div class="sect1" lang="en">
9269: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9270: <a name="patching"></a>21.4. Patching guidelines</h2></div></div></div>
9271: <p>GNOME is a very big component in pkgsrc which approaches 100
9272: packages. Please, it is very important that you always, always,
9273: <span class="strong"><strong>always</strong></span> feed back any portability
9274: 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
9275: their attention on portability issues and to ensure that future versions
9276: can be built out-of-the box on NetBSD. The less custom patches in
9277: pkgsrc, the easier further updates are. Those developers in charge of
9278: issuing major GNOME updates will be grateful if you do that.</p>
9279: <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
9280: Bugzilla</a>. Not all components use these to track bugs, but most
9281: of them do. Do not be short on your reports: always provide detailed
9282: explanations of the current failure, how it can be improved to achieve
9283: maximum portability and, if at all possible, provide a patch against CVS
9284: head. The more verbose you are, the higher chances of your patch being
9285: accepted.</p>
9286: <p>Also, please avoid using preprocessor magic to fix portability
9287: issues. While the FreeBSD GNOME people are doing a great job in porting
9288: GNOME to their operating system, the official GNOME sources are now
9289: plagued by conditionals that check for <code class="varname">__FreeBSD__</code>
9290: and similar macros. This hurts portability. Please see our patching
9291: guidelines (<a href="#components.patches.guidelines" title="9.3.1. Patching guidelines">Section 9.3.1, “Patching guidelines”</a>) for more
9292: details.</p>
9293: </div>
9294: </div>
1.75 rillig 9295: </div>
9296: <div class="part" lang="en">
9297: <div class="titlepage"><div><div><h1 class="title">
9298: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
9299: <div class="partintro" lang="en">
9300: <div></div>
9301: <p>This part of the guide deals with everything
9302: from the infrastructure that is behind the interfaces described
9303: in the developer's guide. A casual package maintainer should not
9304: need anything from this part.</p>
9305: <div class="toc">
9306: <p><b>Table of Contents</b></p>
9307: <dl>
1.85 jmmv 9308: <dt><span class="chapter"><a href="#infr.design">22. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 9309: <dd><dl>
1.85 jmmv 9310: <dt><span class="sect1"><a href="#infr.vardef">22.1. The meaning of variable definitions</a></span></dt>
9311: <dt><span class="sect1"><a href="#infr.vardef.problems">22.2. Avoiding problems before they arise</a></span></dt>
9312: <dt><span class="sect1"><a href="#infr.var">22.3. Variable evaluation</a></span></dt>
1.75 rillig 9313: <dd><dl>
1.85 jmmv 9314: <dt><span class="sect2"><a href="#infr.var.load">22.3.1. At load time</a></span></dt>
9315: <dt><span class="sect2"><a href="#infr.var.run">22.3.2. At runtime</a></span></dt>
1.75 rillig 9316: </dl></dd>
1.85 jmmv 9317: <dt><span class="sect1"><a href="#infr.varspec">22.4. How can variables be specified?</a></span></dt>
9318: <dt><span class="sect1"><a href="#infr.design.intf">22.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 9319: <dd><dl>
1.85 jmmv 9320: <dt><span class="sect2"><a href="#infr.design.intf.proc">22.5.1. Procedures with parameters</a></span></dt>
9321: <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 9322: </dl></dd>
1.85 jmmv 9323: <dt><span class="sect1"><a href="#infr.order">22.6. The order in which files are loaded</a></span></dt>
1.81 rillig 9324: <dd><dl>
1.85 jmmv 9325: <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>
9326: <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 9327: </dl></dd>
9328: </dl></dd>
1.85 jmmv 9329: <dt><span class="chapter"><a href="#regression">23. Regression tests</a></span></dt>
1.75 rillig 9330: <dd><dl>
1.85 jmmv 9331: <dt><span class="sect1"><a href="#regression.descr">23.1. The regression tests framework</a></span></dt>
9332: <dt><span class="sect1"><a href="#regression.run">23.2. Running the regression tests</a></span></dt>
9333: <dt><span class="sect1"><a href="#regression.new">23.3. Adding a new regression test</a></span></dt>
1.75 rillig 9334: <dd><dl>
1.85 jmmv 9335: <dt><span class="sect2"><a href="#regression.fun.override">23.3.1. Overridable functions</a></span></dt>
9336: <dt><span class="sect2"><a href="#regression.fun.helper">23.3.2. Helper functions</a></span></dt>
1.75 rillig 9337: </dl></dd>
9338: </dl></dd>
1.85 jmmv 9339: <dt><span class="chapter"><a href="#porting">24. Porting pkgsrc</a></span></dt>
1.75 rillig 9340: <dd><dl>
1.85 jmmv 9341: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
9342: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 9343: </dl></dd>
9344: </dl>
9345: </div>
9346: </div>
9347: <div class="chapter" lang="en">
9348: <div class="titlepage"><div><div><h2 class="title">
1.85 jmmv 9349: <a name="infr.design"></a>Chapter 22. Design of the pkgsrc infrastructure</h2></div></div></div>
1.75 rillig 9350: <div class="toc">
9351: <p><b>Table of Contents</b></p>
9352: <dl>
1.85 jmmv 9353: <dt><span class="sect1"><a href="#infr.vardef">22.1. The meaning of variable definitions</a></span></dt>
9354: <dt><span class="sect1"><a href="#infr.vardef.problems">22.2. Avoiding problems before they arise</a></span></dt>
9355: <dt><span class="sect1"><a href="#infr.var">22.3. Variable evaluation</a></span></dt>
1.81 rillig 9356: <dd><dl>
1.85 jmmv 9357: <dt><span class="sect2"><a href="#infr.var.load">22.3.1. At load time</a></span></dt>
9358: <dt><span class="sect2"><a href="#infr.var.run">22.3.2. At runtime</a></span></dt>
1.81 rillig 9359: </dl></dd>
1.85 jmmv 9360: <dt><span class="sect1"><a href="#infr.varspec">22.4. How can variables be specified?</a></span></dt>
9361: <dt><span class="sect1"><a href="#infr.design.intf">22.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 9362: <dd><dl>
1.85 jmmv 9363: <dt><span class="sect2"><a href="#infr.design.intf.proc">22.5.1. Procedures with parameters</a></span></dt>
9364: <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 9365: </dl></dd>
1.85 jmmv 9366: <dt><span class="sect1"><a href="#infr.order">22.6. The order in which files are loaded</a></span></dt>
1.75 rillig 9367: <dd><dl>
1.85 jmmv 9368: <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>
9369: <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 9370: </dl></dd>
9371: </dl>
9372: </div>
9373: <p>The pkgsrc infrastructure consists of many small Makefile
9374: fragments. Each such fragment needs a properly specified
9375: interface. This chapter explains how such an interface looks
9376: like.</p>
9377: <div class="sect1" lang="en">
9378: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9379: <a name="infr.vardef"></a>22.1. The meaning of variable definitions</h2></div></div></div>
1.81 rillig 9380: <p>Whenever a variable is defined in the pkgsrc
9381: infrastructure, the location and the way of definition provide
9382: much information about the intended use of that variable.
9383: Additionally, more documentation may be found in a header
9384: comment or in this pkgsrc guide.</p>
9385: <p>A special file is
9386: <code class="filename">mk/defaults/mk.conf</code>, which lists all
9387: variables that are intended to be user-defined. They are either
9388: defined using the <code class="literal">?=</code> operator or they are
9389: left undefined because defining them to anything would
9390: effectively mean “<span class="quote">yes</span>”. All these variables may be
9391: overridden by the pkgsrc user in the <code class="varname">MAKECONF</code>
9392: file.</p>
9393: <p>Outside this file, the following conventions apply:
9394: Variables that are defined using the <code class="literal">?=</code>
9395: operator may be overridden by a package.</p>
9396: <p>Variables that are defined using the <code class="literal">=</code>
9397: operator may be used read-only at run-time.</p>
9398: <p>Variables whose name starts with an underscore must not be
9399: accessed outside the pkgsrc infrastructure at all. They may
9400: change without further notice.</p>
9401: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
9402: <h3 class="title">Note</h3>
9403: <p>These conventions are currently not applied
9404: consistently to the complete pkgsrc
9405: infrastructure.</p>
9406: </div>
9407: </div>
9408: <div class="sect1" lang="en">
9409: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9410: <a name="infr.vardef.problems"></a>22.2. Avoiding problems before they arise</h2></div></div></div>
1.81 rillig 9411: <p>All variables that contain lists of things should default
9412: to being empty. Two examples that do not follow this rule are
9413: <code class="varname">USE_LANGUAGES</code> and
9414: <code class="varname">DISTFILES</code>. These variables cannot simply be
9415: modified using the <code class="literal">+=</code> operator in package
9416: <code class="filename">Makefile</code>s (or other files included by
9417: them), since there is no guarantee whether the variable is
9418: already set or not, and what its value is. In the case of
9419: <code class="varname">DISTFILES</code>, the packages “<span class="quote">know</span>”
9420: the default value and just define it as in the following
9421: example.</p>
9422: <pre class="programlisting">
9423: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
9424: </pre>
9425: <p>Because of the selection of this default value, the same
9426: value appears in many package Makefiles. Similarly for
9427: <code class="varname">USE_LANGUAGES</code>, but in this case the default
9428: value (“<span class="quote"><code class="literal">c</code></span>”) is so short that it
9429: doesn't stand out. Nevertheless it is mentioned in many
9430: files.</p>
9431: </div>
9432: <div class="sect1" lang="en">
9433: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9434: <a name="infr.var"></a>22.3. Variable evaluation</h2></div></div></div>
1.75 rillig 9435: <div class="sect2" lang="en">
9436: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9437: <a name="infr.var.load"></a>22.3.1. At load time</h3></div></div></div>
1.75 rillig 9438: <p>Variable evaluation takes place either at load time or at
9439: runtime, depending on the context in which they occur. The
9440: contexts where variables are evaluated at load time are:</p>
9441: <div class="itemizedlist"><ul type="disc">
9442: <li><p>The right hand side of the <code class="literal">:=</code>
9443: and <code class="literal">!=</code> operators,</p></li>
9444: <li><p>Make directives like <code class="literal">.if</code> or
9445: <code class="literal">.for</code>,</p></li>
9446: <li><p>Dependency lines.</p></li>
9447: </ul></div>
9448: <p>A special exception are references to the iteration
9449: variables of <code class="literal">.for</code> loops, which are expanded
9450: inline, no matter in which context they appear.</p>
9451: <p>As the values of variables may change during load time,
9452: care must be taken not to evaluate them by accident. Typical
9453: examples for variables that should not be evaluated at load time
9454: are <code class="varname">DEPENDS</code> and
9455: <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
9456: clear, here is an example:</p>
9457: <pre class="programlisting">
9458: CONFIGURE_ARGS= # none
9459: CFLAGS= -O
9460: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
1.1 grant 9461:
1.75 rillig 9462: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
1.1 grant 9463:
1.75 rillig 9464: CFLAGS+= -Wall
9465: </pre>
9466: <p>This code shows how the use of the <code class="literal">:=</code>
9467: operator can quickly lead to unexpected results. The first
9468: paragraph is fairly common code. The second paragraph evaluates
9469: the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
9470: <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
9471: <code class="literal">-Wall</code> is appended to the
9472: <code class="varname">CFLAGS</code>, but this addition will not appear in
9473: <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
9474: paragraphs from above typically occur in completely unrelated
9475: files.</p>
9476: </div>
9477: <div class="sect2" lang="en">
9478: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9479: <a name="infr.var.run"></a>22.3.2. At runtime</h3></div></div></div>
1.75 rillig 9480: <p>After all the files have been loaded, the values of the
9481: variables cannot be changed anymore. Variables that are used in
9482: the shell commands are expanded at this point.</p>
9483: </div>
9484: </div>
9485: <div class="sect1" lang="en">
9486: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9487: <a name="infr.varspec"></a>22.4. How can variables be specified?</h2></div></div></div>
1.78 rillig 9488: <p>There are many ways in which the definition and use of a
9489: variable can be restricted in order to detect bugs and
9490: violations of the (mostly unwritten) policies. See the
9491: <code class="literal">pkglint</code> developer's documentation for further
9492: details.</p>
9493: </div>
9494: <div class="sect1" lang="en">
9495: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9496: <a name="infr.design.intf"></a>22.5. Designing interfaces for Makefile fragments</h2></div></div></div>
1.76 rillig 9497: <p>Most of the <code class="filename">.mk</code> files fall into one
1.75 rillig 9498: of the following classes. Cases where a file falls into more
9499: than one class should be avoided as it often leads to subtle
9500: bugs.</p>
9501: <div class="sect2" lang="en">
9502: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9503: <a name="infr.design.intf.proc"></a>22.5.1. Procedures with parameters</h3></div></div></div>
1.75 rillig 9504: <p>In a traditional imperative programming language some of
1.76 rillig 9505: the <code class="filename">.mk</code> files could be described as
1.89 ! rillig 9506: procedures. They take some input parameters and—after
! 9507: inclusion—provide a result in output parameters. Since all
1.76 rillig 9508: variables in <code class="filename">Makefile</code>s have global scope
1.75 rillig 9509: care must be taken not to use parameter names that have already
9510: another meaning. For example, <code class="varname">PKGNAME</code> is a
9511: bad choice for a parameter name.</p>
9512: <p>Procedures are completely evaluated at preprocessing time.
9513: That is, when calling a procedure all input parameters must be
9514: completely resolvable. For example,
9515: <code class="varname">CONFIGURE_ARGS</code> should never be an input
9516: parameter since it is very likely that further text will be
9517: added after calling the procedure, which would effectively apply
9518: the procedure to only a part of the variable. Also, references
9519: to other variables wit will be modified after calling the
9520: procedure.</p>
9521: <p>A procedure can declare its output parameters either as
9522: suitable for use in preprocessing directives or as only
9523: available at runtime. The latter alternative is for variables
9524: that contain references to other runtime variables.</p>
9525: <p>Procedures shall be written such that it is possible to
9526: call the procedure more than once. That is, the file must not
9527: contain multiple-inclusion guards.</p>
9528: <p>Examples for procedures are
1.76 rillig 9529: <code class="filename">mk/bsd.options.mk</code> and
9530: <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
1.75 rillig 9531: that the parameters are evaluated at load time, they should be
9532: assigned using the <code class="literal">:=</code> operator, which should
9533: be used only for this purpose.</p>
9534: </div>
9535: <div class="sect2" lang="en">
9536: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9537: <a name="infr.design.intf.action"></a>22.5.2. Actions taken on behalf of parameters</h3></div></div></div>
1.75 rillig 9538: <p>Action files take some input parameters and may define
9539: runtime variables. They shall not define loadtime variables.
9540: There are action files that are included implicitly by the
9541: pkgsrc infrastructure, while other must be included
9542: explicitly.</p>
9543: <p>An example for action files is
1.76 rillig 9544: <code class="filename">mk/subst.mk</code>.</p>
1.75 rillig 9545: </div>
9546: </div>
1.81 rillig 9547: <div class="sect1" lang="en">
9548: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9549: <a name="infr.order"></a>22.6. The order in which files are loaded</h2></div></div></div>
1.81 rillig 9550: <p>Package <code class="filename">Makefile</code>s usually consist of
9551: a set of variable definitions, and include the file
9552: <code class="filename">../../mk/bsd.pkg.mk</code> in the very last line.
9553: Before that, they may also include various other
9554: <code class="filename">*.mk</code> files if they need to query the
9555: availability of certain features like the type of compiler or
9556: the X11 implementation. Due to the heavy use of preprocessor
9557: directives like <code class="literal">.if</code> and
9558: <code class="literal">.for</code>, the order in which the files are loaded
9559: matters.</p>
9560: <p>This section describes at which point the various files
9561: are loaded and gives reasons for that order.</p>
9562: <div class="sect2" lang="en">
9563: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9564: <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 9565: <p>The very first action in <code class="filename">bsd.pkg.mk</code>
9566: is to define some essential variables like
9567: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code> and
9568: <code class="varname">MACHINE_ARCH</code>.</p>
9569: <p>Then, the user settings are loaded from the file specified
9570: in <code class="varname">MAKECONF</code>. If the bmake command from pkgsrc
9571: is used, <code class="varname">MAKECONF</code> defaults to
9572: <code class="filename"><em class="replaceable"><code>${prefix}</code></em>/etc/mk.conf</code>.
9573: 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
9574: <code class="filename">/etc/mk.conf</code>. After that, those variables
9575: that have not been overridden by the user are loaded from
9576: <code class="filename">mk/defaults/mk.conf</code>.</p>
9577: <p>After the user settings, the system settings and platform
9578: settings are loaded, which may override the user
9579: settings.</p>
9580: <p>Then, the tool definitions are loaded. The tool wrappers
9581: are not yet in effect. This only happens when building a
9582: package, so the proper variables must be used instead of the
9583: direct tool names.</p>
9584: <p>As the last steps, some essential variables from the
9585: wrapper and the package system flavor are loaded, as well as the
9586: variables that have been cached in earlier phases of a package
9587: build.</p>
9588: </div>
9589: <div class="sect2" lang="en">
9590: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9591: <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 9592: <p>First, <code class="filename">bsd.prefs.mk</code> is loaded.</p>
9593: <p>Then, the various <code class="filename">*-vars.mk</code> files are
9594: loaded, which fill default values for those variables that have
9595: not been defined by the the package. These variables may later
9596: be used even in unrelated files.</p>
9597: <p>Then, the file <code class="filename">bsd.pkg.error.mk</code>
9598: provides the target <code class="literal">error-check</code> that is added
9599: as a special dependency to all other targets that use
9600: <code class="varname">DELAYED_ERROR_MSG</code> or
9601: <code class="varname">DELAYED_WARNING_MSG</code>.</p>
9602: <p>Then, the package-specific hacks from
9603: <code class="filename">hacks.mk</code> are included.</p>
9604: <p>Then, various other files follow. Most of them don't have
9605: any dependencies on what they need to have included before or
9606: after them, though some do.</p>
9607: <p>The code to check <code class="varname">PKG_FAIL_REASON</code> and
9608: <code class="varname">PKG_SKIP_REASON</code> is then executed, which
9609: restricts the use of these variables to all the files that have
9610: been included before. Appearances in later files will be
9611: silently ignored.</p>
9612: <p>Then, the files for the main targets are included, in the
9613: order of later execution, though the actual order should not
9614: matter.</p>
9615: <p>At last, some more files are included that don't set any
9616: interesting variables but rather just define make targets to be
9617: executed.</p>
9618: </div>
9619: </div>
1.75 rillig 9620: </div>
9621: <div class="chapter" lang="en">
9622: <div class="titlepage"><div><div><h2 class="title">
1.85 jmmv 9623: <a name="regression"></a>Chapter 23. Regression tests</h2></div></div></div>
1.75 rillig 9624: <div class="toc">
9625: <p><b>Table of Contents</b></p>
9626: <dl>
1.85 jmmv 9627: <dt><span class="sect1"><a href="#regression.descr">23.1. The regression tests framework</a></span></dt>
9628: <dt><span class="sect1"><a href="#regression.run">23.2. Running the regression tests</a></span></dt>
9629: <dt><span class="sect1"><a href="#regression.new">23.3. Adding a new regression test</a></span></dt>
1.75 rillig 9630: <dd><dl>
1.85 jmmv 9631: <dt><span class="sect2"><a href="#regression.fun.override">23.3.1. Overridable functions</a></span></dt>
9632: <dt><span class="sect2"><a href="#regression.fun.helper">23.3.2. Helper functions</a></span></dt>
1.75 rillig 9633: </dl></dd>
9634: </dl>
9635: </div>
9636: <p>The pkgsrc infrastructure consists of a large codebase,
9637: and there are many corners where every little bit of a file is
9638: well thought out, making pkgsrc likely to fail as soon as
9639: anything is changed near those parts. To prevent most changes
9640: from breaking anything, a suite of regression tests should go
9641: along with every important part of the pkgsrc infrastructure.
9642: This chapter describes how regression tests work in pkgsrc and
9643: how you can add new tests.</p>
9644: <div class="sect1" lang="en">
9645: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9646: <a name="regression.descr"></a>23.1. The regression tests framework</h2></div></div></div>
1.75 rillig 9647: <p></p>
9648: </div>
9649: <div class="sect1" lang="en">
9650: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9651: <a name="regression.run"></a>23.2. Running the regression tests</h2></div></div></div>
1.76 rillig 9652: <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 9653: provides the <span><strong class="command">pkg_regress</strong></span> command. Then you
9654: can simply run that command, which will run all tests in the
1.76 rillig 9655: <code class="filename">regress</code> category.</p>
1.75 rillig 9656: </div>
9657: <div class="sect1" lang="en">
9658: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9659: <a name="regression.new"></a>23.3. Adding a new regression test</h2></div></div></div>
1.76 rillig 9660: <p>Every directory in the <code class="filename">regress</code>
9661: category that contains a file called <code class="filename">spec</code>
1.75 rillig 9662: is considered a regression test. This file is a shell program
9663: that is included by the <span><strong class="command">pkg_regress</strong></span> command.
9664: The following functions can be overridden to suit your
9665: needs.</p>
9666: <div class="sect2" lang="en">
9667: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9668: <a name="regression.fun.override"></a>23.3.1. Overridable functions</h3></div></div></div>
1.75 rillig 9669: <p>These functions do not take any parameters. They are all
9670: called in “<span class="quote">set -e</span>” mode, so you should be careful
9671: to check the exitcodes of any commands you run in the
9672: test.</p>
9673: <div class="variablelist"><dl>
9674: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
9675: <dd><p>This function prepares the environment for the
9676: test. By default it does nothing.</p></dd>
9677: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
9678: <dd><p>This function runs the actual test. By default,
9679: it calls <code class="varname">TEST_MAKE</code> with the arguments
9680: <code class="varname">MAKEARGS_TEST</code> and writes its output including
9681: error messages into the file
9682: <code class="varname">TEST_OUTFILE</code>.</p></dd>
9683: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
9684: <dd><p>This function is run after the test and is
9685: typically used to compare the actual output from the one that is
9686: expected. It can make use of the various helper functions from
9687: the next section.</p></dd>
9688: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
9689: <dd><p>This function cleans everything up after the
9690: test has been run. By default it does nothing.</p></dd>
9691: </dl></div>
9692: </div>
9693: <div class="sect2" lang="en">
9694: <div class="titlepage"><div><div><h3 class="title">
1.85 jmmv 9695: <a name="regression.fun.helper"></a>23.3.2. Helper functions</h3></div></div></div>
1.75 rillig 9696: <div class="variablelist"><dl>
9697: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
9698: <dd><p>This function compares the exitcode of the
9699: <span><strong class="command">do_test()</strong></span> function with its first parameter.
9700: If they differ, the test will fail.</p></dd>
9701: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
9702: <dd><p>This function checks for each of its parameters
9703: if the output from <span><strong class="command">do_test()</strong></span> matches the
9704: extended regular expression. If it does not, the test will
9705: fail.</p></dd>
9706: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
9707: <dd><p>This function checks for each of its parameters
9708: if the output from <span><strong class="command">do_test()</strong></span> does
9709: <span class="emphasis"><em>not</em></span> match the extended regular expression.
9710: If any of the regular expressions matches, the test will
9711: fail.</p></dd>
9712: </dl></div>
9713: </div>
9714: </div>
9715: </div>
9716: <div class="chapter" lang="en">
9717: <div class="titlepage"><div><div><h2 class="title">
1.85 jmmv 9718: <a name="porting"></a>Chapter 24. Porting pkgsrc</h2></div></div></div>
1.75 rillig 9719: <div class="toc">
9720: <p><b>Table of Contents</b></p>
9721: <dl>
1.85 jmmv 9722: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
9723: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 9724: </dl>
9725: </div>
9726: <p>The pkgsrc system has already been ported to many
9727: operating systems, hardware architectures and compilers. This
9728: chapter explains the necessary steps to make pkgsrc even more
9729: portable.</p>
9730: <div class="sect1" lang="en">
9731: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9732: <a name="porting.opsys"></a>24.1. Porting pkgsrc to a new operating system</h2></div></div></div>
1.75 rillig 9733: <p>To port pkgsrc to a new operating system (called
9734: <code class="literal">MyOS</code> in this example), you need to touch the
9735: following files:</p>
9736: <div class="variablelist"><dl>
1.76 rillig 9737: <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 9738: <dd><p>This file contains some basic definitions, for
9739: example the name of the C
9740: compiler.</p></dd>
1.76 rillig 9741: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
1.75 rillig 9742: <dd><p>Insert code that defines the variables
9743: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
9744: <code class="varname">LOWER_OS_VERSION</code>,
9745: <code class="varname">LOWER_VENDOR</code>,
9746: <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
9747: <code class="varname">APPEND_ELF</code>, and the other variables that
9748: appear in this file.</p></dd>
1.76 rillig 9749: <dt><span class="term"><code class="filename">mk/platform/MyOS.mk</code></span></dt>
1.75 rillig 9750: <dd><p>This file contains the platform-specific
9751: definitions that are used by pkgsrc. Start by copying one of the
9752: other files and edit it to your
9753: needs.</p></dd>
1.76 rillig 9754: <dt><span class="term"><code class="filename">mk/platform/MyOS.pkg.dist</code></span></dt>
1.75 rillig 9755: <dd><p>This file contains a list of directories,
9756: together with their permission bits and ownership. These
9757: directories will be created automatically with every package
9758: that does not explicitly set <code class="varname">NO_MTREE</code>. There
9759: have been some discussions about whether this file is needed at
9760: all, but with no result.</p></dd>
1.76 rillig 9761: <dt><span class="term"><code class="filename">mk/platform/MyOS.x11.dist</code></span></dt>
1.75 rillig 9762: <dd><p>Just copy one of the pre-existing x11.dist files
9763: to your
1.76 rillig 9764: <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
9765: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
1.75 rillig 9766: <dd><p>On some operating systems, the tools that are
9767: provided with the base system are not good enough for pkgsrc.
9768: 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
9769: narrow limit on the line length they can process. Therefore
9770: pkgsrc brings its own tools, which can be enabled
9771: here.</p></dd>
1.76 rillig 9772: <dt><span class="term"><code class="filename">mk/tools/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
1.75 rillig 9773: <dd><p>This file defines the paths to all the tools
9774: that are needed by one or the other package in pkgsrc, as well
9775: as by pkgsrc itself. Find out where these tools are on your
9776: platform and add them.</p></dd>
9777: </dl></div>
9778: <p>Now, you should be able to build some basic packages, like
1.76 rillig 9779: <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 9780: </div>
9781: <div class="sect1" lang="en">
9782: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85 jmmv 9783: <a name="porting.compiler"></a>24.2. Adding support for a new compiler</h2></div></div></div>
1.75 rillig 9784: <p>TODO</p>
9785: </div>
9786: </div>
9787: </div>
9788: <div class="appendix" lang="en">
9789: <div class="titlepage"><div><div><h2 class="title">
9790: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
9791: <div class="toc">
9792: <p><b>Table of Contents</b></p>
9793: <dl>
9794: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
9795: <dd><dl>
9796: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
9797: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
9798: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
9799: <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>
9800: </dl></dd>
9801: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
9802: </dl>
9803: </div>
9804: <p>We checked to find a piece of software that wasn't in the packages
9805: collection, and picked GNU bison. Quite why someone would want to have
9806: <span><strong class="command">bison</strong></span> when Berkeley <span><strong class="command">yacc</strong></span> is already
9807: present in the tree is beyond us, but it's useful for the purposes of
9808: this exercise.</p>
9809: <div class="sect1" lang="en">
9810: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9811: <a name="example-files"></a>A.1. files</h2></div></div></div>
9812: <div class="sect2" lang="en">
9813: <div class="titlepage"><div><div><h3 class="title">
9814: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
9815: <pre class="programlisting">
1.51 rillig 9816: # $NetBSD$
9817: #
1.1 grant 9818:
1.51 rillig 9819: DISTNAME= bison-1.25
9820: CATEGORIES= devel
9821: MASTER_SITES= ${MASTER_SITE_GNU}
1.1 grant 9822:
1.51 rillig 9823: MAINTAINER= thorpej@NetBSD.org
9824: HOMEPAGE= http://www.gnu.org/software/bison/bison.html
9825: COMMENT= GNU yacc clone
1.1 grant 9826:
1.51 rillig 9827: GNU_CONFIGURE= yes
9828: INFO_FILES= bison.info
1.1 grant 9829:
1.51 rillig 9830: .include "../../mk/bsd.pkg.mk"
1.1 grant 9831: </pre>
1.75 rillig 9832: </div>
9833: <div class="sect2" lang="en">
9834: <div class="titlepage"><div><div><h3 class="title">
9835: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
9836: <pre class="programlisting">
1.51 rillig 9837: GNU version of yacc. Can make re-entrant parsers, and numerous other
1.75 rillig 9838: 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 9839: of the NetBSD source tree is beyond me.
1.1 grant 9840: </pre>
1.75 rillig 9841: </div>
9842: <div class="sect2" lang="en">
9843: <div class="titlepage"><div><div><h3 class="title">
9844: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
9845: <pre class="programlisting">
1.51 rillig 9846: @comment $NetBSD$
9847: bin/bison
9848: man/man1/bison.1.gz
9849: share/bison.simple
9850: share/bison.hairy
1.1 grant 9851: </pre>
1.75 rillig 9852: </div>
9853: <div class="sect2" lang="en">
9854: <div class="titlepage"><div><div><h3 class="title">
9855: <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>
9856: <p>The NetBSD package system comes with
1.76 rillig 9857: <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 9858: which helps to check the contents of these
9859: files. After installation it is quite easy to use, just change to the
9860: directory of the package you wish to examine and execute
9861: <span><strong class="command">pkglint</strong></span>:</p>
9862: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
9863: looks fine.</pre>
9864: <p>Depending on the supplied command line arguments (see pkglint(1)),
9865: more checks will be performed. Use e.g. <span><strong class="command">pkglint -Call
9866: -Wall</strong></span> for a very thorough check.</p>
9867: </div>
9868: </div>
9869: <div class="sect1" lang="en">
9870: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9871: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
9872: <p>Create the directory where the package lives,
9873: plus any auxiliary directories:</p>
9874: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
9875: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
9876: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
9877: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
1.76 rillig 9878: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.77 rillig 9879: <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 9880: then continue with fetching the distfile:</p>
9881: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
1.1 grant 9882: >> bison-1.25.tar.gz doesn't seem to exist on this system.
9883: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
9884: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
9885: ftp: Error retrieving file: 500 Internal error
9886:
9887: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
9888: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
9889: ftp: Error retrieving file: 500 Internal error
9890:
9891: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
9892: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
1.75 rillig 9893: Successfully retrieved file.</pre>
9894: <p>Generate the checksum of the distfile into
1.76 rillig 9895: <code class="filename">distinfo</code>:</p>
1.88 wiz 9896: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makedistinfo</code></strong></pre>
1.75 rillig 9897: <p>Now compile:</p>
9898: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 9899: >> Checksum OK for bison-1.25.tar.gz.
9900: ===> Extracting for bison-1.25
9901: ===> Patching for bison-1.25
9902: ===> Ignoring empty patch directory
9903: ===> Configuring for bison-1.25
9904: creating cache ./config.cache
9905: checking for gcc... cc
9906: checking whether we are using GNU C... yes
9907: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
9908: checking how to run the C preprocessor... cc -E
9909: checking for minix/config.h... no
9910: checking for POSIXized ISC... no
9911: checking whether cross-compiling... no
9912: checking for ANSI C header files... yes
9913: checking for string.h... yes
9914: checking for stdlib.h... yes
9915: checking for memory.h... yes
9916: checking for working const... yes
9917: checking for working alloca.h... no
9918: checking for alloca... yes
9919: checking for strerror... yes
9920: updating cache ./config.cache
9921: creating ./config.status
9922: creating Makefile
9923: ===> Building for bison-1.25
9924: 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
9925: 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
9926: 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
9927: 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
9928: 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 9929: 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 9930: 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
9931: 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
9932: 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
9933: 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
9934: 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
9935: 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
9936: 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
9937: 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
9938: 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
9939: 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
9940: 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
9941: 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
9942: 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
9943: 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
9944: 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
9945: 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
9946: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
9947: rm -f bison.s1
1.75 rillig 9948: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1</pre>
9949: <p>Everything seems OK, so install the files:</p>
9950: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 9951: >> Checksum OK for bison-1.25.tar.gz.
9952: ===> Installing for bison-1.25
9953: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
9954: rm -f /usr/pkg/bin/bison
9955: cd /usr/pkg/share; rm -f bison.simple bison.hairy
9956: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
9957: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
9958: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
9959: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
9960: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
9961: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
1.75 rillig 9962: ===> Registering installation for bison-1.25</pre>
9963: <p>You can now use bison, and also - if you decide so - remove it with
9964: <span><strong class="command">pkg_delete bison</strong></span>. Should you decide that you want a
9965: binary package, do this now:</p>
9966: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 9967: >> Checksum OK for bison-1.25.tar.gz.
9968: ===> Building package for bison-1.25
9969: Creating package bison-1.25.tgz
9970: Registering depends:.
1.75 rillig 9971: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
9972: <p>Now that you don't need the source and object files
9973: any more, clean up:</p>
9974: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
9975: ===> Cleaning for bison-1.25</pre>
9976: </div>
9977: </div>
9978: <div class="appendix" lang="en">
9979: <div class="titlepage"><div><div><h2 class="title">
9980: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
9981: <div class="toc">
9982: <p><b>Table of Contents</b></p>
9983: <dl>
9984: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
9985: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
9986: </dl>
9987: </div>
9988: <div class="sect1" lang="en">
9989: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9990: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
9991: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 9992: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9993: => figlet221.tar.gz doesn't seem to exist on this system.
9994: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
9995: => [172219 bytes]
9996: Connected to ftp.plig.net.
9997: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
9998: 331 Guest login ok, send your complete e-mail address as password.
9999: 230-You are user #5 of 500 simultaneous users allowed.
10000: 230-
1.68 rillig 10001: 230- ___ _ _ _
10002: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
1.1 grant 10003: 230- | _| _| . |_| . | | | . |_| . | _| . |
10004: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
10005: 230- |_| |_| |___| |___|
10006: 230-
10007: 230-** Welcome to ftp.plig.org **
10008: 230-
10009: 230-Please note that all transfers from this FTP site are logged. If you
10010: 230-do not like this, please disconnect now.
10011: 230-
10012: 230-This arhive is available via
10013: 230-
10014: 230-HTTP: http://ftp.plig.org/
10015: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
10016: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
10017: 230-
10018: 230-Please email comments, bug reports and requests for packages to be
1.68 rillig 10019: 230-mirrored to ftp-admin@plig.org.
1.1 grant 10020: 230-
10021: 230-
10022: 230 Logged in anonymously.
10023: Remote system type is UNIX.
10024: Using binary mode to transfer files.
10025: 200 Type okay.
10026: 250 "/pub" is new cwd.
10027: 250-"/pub/figlet" is new cwd.
10028: 250-
10029: 250-Welcome to the figlet archive at ftp.figlet.org
1.68 rillig 10030: 250-
1.75 rillig 10031: 250- ftp://ftp.figlet.org/pub/figlet/
1.1 grant 10032: 250-
10033: 250-The official FIGlet web page is:
1.75 rillig 10034: 250- http://www.figlet.org/
1.1 grant 10035: 250-
10036: 250-If you have questions, please mailto:info@figlet.org. If you want to
10037: 250-contribute a font or something else, you can email us.
1.68 rillig 10038: 250
1.1 grant 10039: 250 "/pub/figlet/program" is new cwd.
10040: 250 "/pub/figlet/program/unix" is new cwd.
10041: local: figlet221.tar.gz remote: figlet221.tar.gz
10042: 502 Unimplemented command.
10043: 227 Entering Passive Mode (195,40,6,41,246,104)
10044: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
10045: 38% |************** | 65800 64.16 KB/s 00:01 ETA
10046: 226 Transfer completed.
10047: 172219 bytes received in 00:02 (75.99 KB/s)
10048: 221 Goodbye.
10049: => Checksum OK for figlet221.tar.gz.
10050: ===> Extracting for figlet-2.2.1nb2
10051: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
10052: ===> Patching for figlet-2.2.1nb2
10053: ===> Applying pkgsrc patches for figlet-2.2.1nb2
10054: ===> Overriding tools for figlet-2.2.1nb2
10055: ===> Creating toolchain wrappers for figlet-2.2.1nb2
10056: ===> Configuring for figlet-2.2.1nb2
10057: ===> Building for figlet-2.2.1nb2
10058: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
10059: chmod a+x figlet
10060: gcc -O2 -o chkfont chkfont.c
10061: => Unwrapping files-to-be-installed.
1.14 xtraeme 10062: <code class="prompt">#</code>
1.75 rillig 10063: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 10064: ===> Checking for vulnerabilities in figlet-2.2.1nb2
10065: ===> Installing for figlet-2.2.1nb2
10066: install -d -o root -g wheel -m 755 /usr/pkg/bin
10067: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
10068: mkdir -p /usr/pkg/share/figlet
10069: cp figlet /usr/pkg/bin
10070: cp chkfont /usr/pkg/bin
10071: chmod 555 figlist showfigfonts
10072: cp figlist /usr/pkg/bin
10073: cp showfigfonts /usr/pkg/bin
10074: cp fonts/*.flf /usr/pkg/share/figlet
10075: cp fonts/*.flc /usr/pkg/share/figlet
10076: cp figlet.6 /usr/pkg/man/man6
10077: ===> Registering installation for figlet-2.2.1nb2
1.75 rillig 10078: <code class="prompt">#</code></pre>
10079: </div>
10080: <div class="sect1" lang="en">
10081: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10082: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
10083: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 10084: ===> Checking for vulnerabilities in figlet-2.2.1nb2
10085: ===> Packaging figlet-2.2.1nb2
10086: ===> Building binary package for figlet-2.2.1nb2
10087: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
10088: Using SrcDir value of /usr/pkg
1.68 rillig 10089: Registering depends:.
1.75 rillig 10090: <code class="prompt">#</code></pre>
10091: </div>
10092: </div>
10093: <div class="appendix" lang="en">
10094: <div class="titlepage"><div><div><h2 class="title">
1.76 rillig 10095: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
10096: <div class="toc">
10097: <p><b>Table of Contents</b></p>
10098: <dl>
10099: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
10100: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
10101: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
10102: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
10103: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
10104: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
10105: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
10106: source packages</a></span></dt>
10107: </dl>
10108: </div>
10109: <p>As in other big projects, the directory layout of pkgsrc
10110: is quite complex for newbies. This chapter explains where you
10111: find things on the FTP server. The base directory on
1.89 ! rillig 10112: <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>.
! 10113: On other servers it may be different, but inside this directory,
! 10114: everything should look the same, no matter on which server you
! 10115: are. This directory contains some subdirectories, which are
! 10116: explained below.</p>
1.76 rillig 10117: <div class="sect1" lang="en">
10118: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10119: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
10120: <p>For those who only want to manage binary packages on
10121: systems other than NetBSD, we provide the package management
10122: tools in a separate, small tar file.</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-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
10127: <p>The directory <code class="filename">distfiles</code> contains lots
10128: of archive files from all pkgsrc packages, which are mirrored
10129: here. The subdirectories are called after their package names
10130: and are used when the distributed files have names that don't
10131: explicitly contain a version number or are otherwise too generic
10132: (for example <code class="filename">release.tar.gz</code>).</p>
10133: </div>
10134: <div class="sect1" lang="en">
10135: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10136: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
10137: <p>This directory is currently not in use.</p>
10138: </div>
10139: <div class="sect1" lang="en">
10140: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10141: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
10142: <p>This directory contains things that individual pkgsrc
10143: developers find worth publishing.</p>
10144: </div>
10145: <div class="sect1" lang="en">
10146: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10147: <a name="ftp-packages"></a>C.5. <code class="filename">packages*</code>: Binary packages</h2></div></div></div>
10148: <p>These directories contain binary packages. Those
10149: directories that have a branch name
10150: (200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>)
10151: contain packages from that particular branch. The directory
10152: <code class="filename">packages</code> contains binary packages from
10153: pkgsrc-current. (However, this does not necessarily mean that
10154: the packages are still current anymore.)</p>
10155: <p>Below the <code class="filename">packages*</code> directories are
10156: directories that distinguish the packages by operating system
10157: and version, the next directory level specifies the hardware
10158: architecture.</p>
10159: <p>In each of the platform-specific directories, there is a
10160: whole binary packages collection. It has a directory called
10161: <code class="filename">All</code> which contains all binary packages.
10162: Besides that, there are various category directories that
10163: contain symbolic links to the real binary packages.</p>
10164: </div>
10165: <div class="sect1" lang="en">
10166: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10167: <a name="ftp-source"></a>C.6. <code class="filename">current</code>,
10168: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
10169: source packages</h2></div></div></div>
10170: <p>These directories contain the “<span class="quote">real</span>” pkgsrc,
10171: that is the files that define how to create binary packages from
10172: source archives.</p>
10173: <p>The directory <code class="filename">pkgsrc</code> contains a
1.89 ! rillig 10174: snapshot of the CVS repository, which is updated regularly. The
! 10175: file <code class="filename">pkgsrc.tar.gz</code> contains the same as the
! 10176: directory, ready to be downloaded as a whole.</p>
1.76 rillig 10177: <p>In the directories for the quarterly branches, there is an
10178: additional file called
10179: <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
10180: which contains the state of pkgsrc when it was branched.</p>
10181: </div>
1.75 rillig 10182: </div>
10183: <div class="appendix" lang="en">
10184: <div class="titlepage"><div><div><h2 class="title">
10185: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
10186: <div class="toc">
10187: <p><b>Table of Contents</b></p>
10188: <dl>
1.79 rillig 10189: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75 rillig 10190: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
10191: </dl>
10192: </div>
1.79 rillig 10193: <p>This section contains information on editing the pkgsrc
10194: guide itself.</p>
1.75 rillig 10195: <div class="sect1" lang="en">
10196: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.79 rillig 10197: <a name="targets"></a>D.1. Make targets</h2></div></div></div>
10198: <p>The pkgsrc guide's source code is stored in
10199: <code class="filename">pkgsrc/doc/guide/files</code>, and several files
10200: are created from it:</p>
10201: <div class="itemizedlist"><ul type="disc">
10202: <li><p><code class="filename">pkgsrc/doc/pkgsrc.txt</code></p></li>
10203: <li><p><code class="filename">pkgsrc/doc/pkgsrc.html</code></p></li>
10204: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/</a></p></li>
10205: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</a>:
10206: The PDF version of the pkgsrc guide.</p></li>
10207: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</a>:
10208: PostScript version of the pkgsrc guide.</p></li>
1.75 rillig 10209: </ul></div>
10210: </div>
10211: <div class="sect1" lang="en">
10212: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10213: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
1.79 rillig 10214: <p>The procedure to edit the pkgsrc guide is:</p>
10215: <div class="procedure"><ol type="1">
10216: <li><p>Make sure you have the packages needed to
1.83 wiz 10217: regenerate the pkgsrc guide (and other XML-based NetBSD
1.79 rillig 10218: 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
10219: 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
10220: PostScript and PDF versions. You will need both packages
10221: installed, to make sure documentation is consistent across all
10222: formats.</p></li>
10223: <li><p>Run <span><strong class="command">cd doc/guide</strong></span> to get to the
10224: right directory. All further steps will take place
10225: here.</p></li>
10226: <li><p>Edit the XML file(s) in
10227: <code class="filename">files/</code>.</p></li>
10228: <li><p>Run <span><strong class="command">bmake</strong></span> to check the pkgsrc
10229: guide for valid XML and to build the final output files. If you
10230: get any errors at this stage, you can just edit the files, as
10231: there are only symbolic links in the working directory, pointing
10232: to the files in <code class="filename">files/</code>.</p></li>
10233: <li><p><span><strong class="command">(cd files && cvs
10234: commit)</strong></span></p></li>
10235: <li><p>Run <span><strong class="command">bmake clean && bmake</strong></span> to
10236: regenerate the output files with the proper RCS
10237: Ids.</p></li>
1.83 wiz 10238: <li><p>Run <span><strong class="command">bmake regenerate</strong></span> to
10239: regenerate the files in both <code class="filename">pkgsrc/doc</code> and
10240: <code class="filename">htdocs</code>.</p></li>
10241: <li><p>If you have added, removed or renamed some chapters,
10242: you need to synchronize them using <span><strong class="command">cvs add</strong></span> or
10243: <span><strong class="command">cvs delete</strong></span> in the htdocs
10244: directory.</p></li>
1.79 rillig 10245: </ol></div>
1.75 rillig 10246: </div>
10247: </div>
10248: </div></body>
1.1 grant 10249: </html>
CVSweb <webmaster@jp.NetBSD.org>